akhauriyash/Code-Regression huggingface dataset:
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{
  ll n;
  cin >> n;
  vll a(n);
  rep(i,n) cin >> a[i];

  ll next = 1;
  ll cnt = 0;
  rep(i,n)
  {
    if(a[i] == next)
    {
      next++;
    }
    else
    {
      cnt++;
    }
  }

  if(cnt == n)
  {
    cnt = -1;
  }

  cout << cnt << endl;


  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)

int main() {
    char alpha;
    cin >> alpha;

    switch (alpha) {
        case 'a':
            cout << 'b' << endl;
            break;
        case 'b':
            cout << 'c' << endl;
            break;
        case 'c':
            cout << 'd' << endl;
            break;
        case 'd':
            cout << 'e' << endl;
            break;
        case 'e':
            cout << 'f' << endl;
            break;
        case 'f':
            cout << 'g' << endl;
            break;
        case 'g':
            cout << 'h' << endl;
            break;
        case 'h':
            cout << 'i' << endl;
            break;
        case 'i':
            cout << 'j' << endl;
            break;
        case 'j':
            cout << 'k' << endl;
            break;
        case 'k':
            cout << 'l' << endl;
            break;
        case 'l':
            cout << 'm' << endl;
            break;
        case 'm':
            cout << 'n' << endl;
            break;
        case 'n':
            cout << 'o' << endl;
            break;
        case 'o':
            cout << 'p' << endl;
            break;
        case 'p':
            cout << 'q' << endl;
            break;
        case 'q':
            cout << 'r' << endl;
            break;
        case 'r':
            cout << 's' << endl;
            break;
        case 's':
            cout << 't' << endl;
            break;
        case 't':
            cout << 'u' << endl;
            break;
        case 'u':
            cout << 'v' << endl;
            break;
        case 'v':
            cout << 'w' << endl;
            break;
        case 'w':
            cout << 'x' << endl;
            break;
        case 'x':
            cout << 'y' << endl;
            break;
        case 'y':
            cout << 'z' << endl;
            break;
    }

    return 0;

    
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
L = sorted(L)

import math
import bisect
max = L[-1]
maxdiv2 = max//2
posleft = bisect.bisect_left(L, maxdiv2)
posright = bisect.bisect_right(L, maxdiv2)

if len(L) == 2:
	print(L[1], L[0])
	exit()

if posleft!= posright:
	print(max, L[posleft])
	exit()

if abs(max/2 - L[posleft]) > abs(max/2 - L[posleft-1]):
	print(max, L[posleft-1])
else:
	print(max, L[posleft])

Measured memory_bytes: 20136
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n;
    in(n);
    string s;
    cin>>s;
    int ans=0,red=0,white=0;
    rep(i,n){
        if(s[i]=='R')red++;
        if(s[i]=='W')white++;
    }
    int red_index=0;
    for(int i=n-1;i>=0;i--){
        while(s[red_index]=='R'){
            red_index++;
        }
        if(s[i]=='W'){
            white--;
        }
        if(s[i]=='R'&&white>=1){
            white--;
            ans++;
            s[i]='W';
            s[red_index]='R';
        }
        if(red_index>=i)break;
    }
    out(ans);
}

Measured memory_bytes: 3860
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;


int n, t, a, mn, mxdf, cnt, mncnt, mxcnt;

int main() {
	cin >> n >> t;
	mn = intmax;
	mxdf = 0;
	cnt = 0;
	lp(n) {
		cin >> a;
		mn = min(mn, a);
		if (a - mn > mxdf) {
			mxdf = a - mn;
			cnt = 1;
		}
		else if (a - mn == mxdf) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
//From Naruto to Hokage
//#include <RJ>
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n,k,temp=0;
    cin>>n>>k;
    ll upp=((n-1)*(n-2))/2;
    if(k>upp) cout<<"-1";
    else{
        vector <pii> edges;
        rep(i,2,n) edges.pb({1,i});
        temp=upp;
        rep(i,2,n){
            rep(j,i+1,n){
                if(k==temp) break;
                edges.pb({i,j});
                temp--;
            }
            if(k==temp) break;
        }
        cout<<edges.size()<<endl;
        rep(i,0,sz(edges)-1){
            cout<<edges[i].F<<" "<<edges[i].S<<endl;
        }
    }
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 4
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	dd := make([]int, 0)
	for i := 2; i*i <= m; i++ {
		if m%i != 0 {
			continue
		}
		dd = append(dd, i)
		if i*i == m {
			continue
		}
		dd = append(dd, m/i)
	}
	dd = append(dd, m)
	dd = append(dd, 1)
	sort.Ints(dd)
	for i := len(dd) - 1; i >= 0; i-- {
		if dd[i] < n {
			fmt.Fprintln(writer, m/dd[i+1])
			return
		}
	}
	fmt.Fprintln(writer, m)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outi(ll i){cout<<i<<endl;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

int main(){
    ll n,m,v,p,ans=0;cin>>n>>m>>v>>p;
    vi d(n);rep(i,n)cin>>d[i];
    sort(all(d));reverse(all(d));
    ll w=p-1;
    ans=p;
    ll sum=d[w];w++;
    while(w<n){
        sum+=d[w];
        if(sum-(w-p+2)*d[w]>(n-v)*m||d[p-1]-d[w]>m)break;
        ans++;
        w++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>

#define rep(i, n) for(int (i) = 0; i < (n); ++(i))

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::cin >> N;

  std::map<std::string, bool> hist;
  int ans = 0;
  std::vector<std::string> S(N);
  rep(i, N) {
    std::cin >> S[i];
    if(! hist[S[i]]) {
      hist[S[i]] = true;
      ++ans;
    }
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 25172
#include<bits/stdc++.h>
using namespace std;
long A[22];
int main()
{
   long long a,b,c,n,i,m;
   map<int,int>M;
   std::cin >>n>>m;
   while(m--)
   {
     cin>>a>>b;
     M[a]++;
     M[b]++;
 }
 for(i=1;i<=n;i++)
 cout<<M[i]<<endl;
}


Measured memory_bytes: 3596
// UTPC2010 D. ツ鳴ウツ鳴オツ渉つづ按単ツ暗環系

#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <queue>
#include <map>

using namespace std;

int main(){
	int n;
	while(cin >> n, n){
		string s, t, r;
		map<string, int> mp;
		vector< vector< pair<int,int> > > vp;
		int size = 0;
		for(int i=0;i<n;i++){
			cin >> s >> s >> t >> t >> r;
			if(!mp.count(s)) { mp[s] = size++; vp.push_back(vector< pair<int,int> >()); }
			if(!mp.count(r)) { mp[r] = size++; vp.push_back(vector< pair<int,int> >()); }
			t[2] = ' ';
			istringstream iss(t);
			int a; iss >> a >> a;
			vp[mp[s]].push_back(make_pair(mp[r], a));
			vp[mp[r]].push_back(make_pair(mp[s],-a));
		}
		bool ok = true;
		vector<bool> visit(size, false);
		vector<int>  calc(size, 0);
		for(int i=0;i<size;i++){
			if(visit[i]) continue;
			queue<int> qu; qu.push(i);
			while(!qu.empty()){
				int c = qu.front(); qu.pop();
				if(visit[c]) continue;
				visit[c] = true;
				for(int j=0;j<vp[c].size();j++){
					int nxt = vp[c][j].first;
					if(visit[nxt]) {
						if(calc[nxt]!=calc[c]+vp[c][j].second) ok = false;
					} else {
						calc[nxt] = calc[c]+vp[c][j].second;
						qu.push(nxt);
					}
				}
			}
		}
		cout << (ok ? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 0
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
import std.regex;

void main()
{
    foreach(s;stdin.byLine())
        std.regex.split(s,regex("[ ,.]+")).filter!(w=>3<=w.length && w.length<=6)().join(" ").writeln();
}

Measured memory_bytes: 1452
const main = stdin => {
  const input = stdin.trim().split('\n')
  const R = input[0].split('\n').map(x => parseInt(x))
  const G = input[1].split('\n').map(x => parseInt(x))

  console.log(2 * G - R)
}
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 30476
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int Q = sc.nextInt();
        int[] arr = new int[N];
        Arrays.fill(arr, K);
        for(int i = 0; i < Q; i++) {
            int v = sc.nextInt();
            arr[v-1]++;
        }
        for(int i = 0; i < N; i++) {
            arr[i] -= Q;
        }
        for(int i = 0; i < N; i++) {
            if(arr[i] > 0) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 59884
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
  string s;
  int k;
  cin>>s>>k;
  bool ok=true;
  int n=s.size();
  for(int i=0;i<n-1;i++){
    if(s[i+1]!=s[i]){ok=false;}
  }
  if(ok){cout<<(int64_t)n*k/2<<endl;return 0;}
  int64_t sum=0;
  int cnt=0;
  for(int i=0;i<n;i++){
   if(s[i]==s[i+1]){cnt++;}
   else{sum+=(cnt+1)/2;cnt=0;}
  }
  if(s[0]!=s[n-1]){
   cout<<sum*k<<endl;
  }
  else{
    int a=1,b=1;
    for(int i=1;i<n;i++){
      if(s[i]==s[0]){a++;}
      else{break;}
    }
    for(int i=n-2;i>=0;i--){
      if(s[i]==s[n-1]){b++;}
      else{break;}
    }
    cout<<sum*k-((a/2)+(b/2)-(a+b)/2)*(k-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3584
#include <cstdio>

using u32 = unsigned int;

int n;
bool S[2999];
u32 dp[3001];

constexpr u32 mod = 1000000007;

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n-1; i++){
    char c;
    do { c = getchar(); } while(c != '>' && c != '<');
    S[i] = c == '>';
  }

  for(int j = 0; j < n; j++) dp[j] = 1;

  for(int i = 0; i < n-1; i++){
    if(S[i]){
      u32 sum = 0;
      for(int j = n-i-1; j >= 0; j--){
        u32 dpj = dp[j];
        dp[j] = sum;
        sum += dpj;
        if(sum >= mod) sum -= mod;
      }
    }
    else {
      for(int j = 0; j < n - i - 1; j++){
        dp[j] += dp[j-1];
        if(dp[j] >= mod) dp[j] -= mod;
      }
    }
//    for(int j = 0; j < n - i; j++) printf("%d ", dp[j]);
//    puts("");
  }

  printf("%d\n", dp[0]);

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    printf("a < b\n");
  } else if(a>b){
    printf("a > b\n");
  } else if(a==b){
    printf("a == b\n");
  }
    return 0;
  }

Measured memory_bytes: 580
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5+1)):
        if n%i==0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)

    return divisors

if __name__ == '__main__':
    N = int(input())
    divs = make_divisors(N)
    ans = 0
    for d in divs:
        if d == 1:
            continue
        if N%(d-1) == int(N/(d-1)):
            ans += d-1

    print(ans)


Measured memory_bytes: 39152
#include<stdio.h>
#include<stdlib.h>

int main(){

  int N,i,j,flag,box,count = 0;
  int *A;

  scanf("%d",&N);

  A=malloc(sizeof(int)*N);

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  flag = 1;
  while(flag){
    flag = 0;
    for(j=N-1;j>0;j--)
      if(A[j]<A[j-1]){
	count++;
	box = A[j];
	A[j] = A[j-1];
	A[j-1] = box;
	flag = 1;
      }
  }

  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[N-1]);
  printf("%d\n",count);
  free(A);

  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i =a; i<n; i++) 
#define ll long long
using namespace std;

int main() {
  ll X,A,B; cin >> X >> A >> B;
  string ans;
  if (A - B >=0 ) ans = "delicious";
  else if (B - A > X) ans = "dangerous";
  else ans = "safe";
  cout << ans << endl;
}

Measured memory_bytes: 3604
IDENTIFICATION DIVISION.
      PROGRAM-ID. 101B.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 INP PIC X(100).
      01 N   PIC 9(10).
      01 S.
      	03 WK-S PIC 9(1) OCCURS 10 TIMES.
      01 IDX PIC 9(2).
      01 ANS PIC 9(10).
      01 SHO PIC 9(10).
      01 AMA PIC 9(10).
      
      PROCEDURE DIVISION.
      ACCEPT INP.
      MOVE INP TO N.
      MOVE INP TO S.
      
      MOVE 1 TO IDX.
      PERFORM UNTIL ( IDX = 10 ) OR ( WK-S(IDX) = SPACE )
      ADD WK-S(IDX) TO ANS 
      ADD 1 TO IDX
      END-PERFORM.
      
      DIVIDE N BY ANS GIVING SHO REMAINDER AMA.
      
      IF AMA = 0
      	DISPLAY "Yes"
      ELSE
      	DISPLAY "No"
      END-IF.
      
      STOP RUN.
      


Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

mint operator*(long long l, mint r){ return r * l; }

vector<vector<ll>> net;
vector<vector<mint>> dp;

void dfs(ll cur, ll par){
    dp.at(cur).at(0) = 1;
    dp.at(cur).at(1) = 1;
    for(ll nxt : net.at(cur)){
        if(nxt == par){ continue; }
        dfs(nxt, cur);

        dp.at(cur).at(0) *= dp.at(nxt).at(1);
        dp.at(cur).at(1) *= (dp.at(nxt).at(0) + dp.at(nxt).at(1));
    }
}

int main(){
    ll n;
    cin >> n;
    net.resize(n);
    for(int i = 0; i < n - 1; ++i){
        ll x, y;
        cin >> x >> y;
        x--; y--;
        net.at(x).push_back(y);
        net.at(y).push_back(x);
    }
    dp.resize(n, vector<mint>(2, 0));
    dfs(0, -1);
    cout << (dp.at(0).at(0) + dp.at(0).at(1)).v << endl;
    return 0;
}

Measured memory_bytes: 19584
/*2019/09/13 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
int llasc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
int lldesc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
/*
int asc_t(const void *a,const void *b){return ((struct_t*)a)->member - ((struct_t*)b)->member;}
int desc_t(const void *a,const void *b){return ((struct_t*)b)->member - ((struct_t*)a)->member;}
*/

int main(){
    int N,T,t[300000];

    scanf("%d %d",&N,&T);
    for(int i=0;i<N;i++){
        scanf("%d",&t[i]);
    }
    ll ans=0;
    int tmp;
    for(int i=1;i<N;i++){
        tmp=t[i]-t[i-1];
        if(tmp>T){
            ans+=T;
        }else{
            ans+=tmp;
        }
    }
    printf("%lld\n",ans+T);

    return 0;
}

Measured memory_bytes: 896
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] x = new int[n];
		List<Integer> negList = new ArrayList<>();
		List<Integer> posList = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			if (x[i] == 0) {
				k--;
			}
			if (x[i] < 0) {
				negList.add(x[i] * -1);
			} else if (x[i] > 0) {
				posList.add(x[i]);
			}
		}
		Collections.sort(negList);
		int negnum = negList.size();
		int posnum = posList.size();
		int count = 300000000;
		int temp = 0;
		int negtemp = 0;
		int postemp = 0;
		int range = 0;
		int negrange = 0;
		int posrange = 0;
		if (negnum <= k) {
			negrange += negnum;
		} else {
			negrange += k;
		}
		if (posnum <= k) {
			posrange += posnum;
		} else {
			posrange += k;
		}
		range = negrange + posrange;
		for (int i = 0; i < range-k+1; i++) {
			if (negrange - i - 1 >= 0) {
				negtemp = negList.get(negrange - i - 1);
			} else {
				negtemp = 0;
			}
			if (negrange - i < k) {
				postemp = posList.get(k - (negrange - i) - 1);
			} else {
				postemp = 0;
			}
			temp = (Math.min(negtemp, postemp) * 2) + Math.max(negtemp, postemp);
			if (temp < count) {
				count = temp;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 62252
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()
#define MOD 1000000007

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
    if (a % b == 0) {
        return(b);
    }
    else {
        return(gcd(b, a % b));
    }
}

template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

int main(void) {
    string s;
    cin >> s;
    if (s[s.length() - 1] == 's') {
        cout << s + "es";
    }
    else {
        cout << s + "s";
    }
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;
const string YES = "Yes";
const string NO = "No";

void solve(string N);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    string N;
    cin >> N;
    solve(N);
}

void solve(string N){
    rep(i,3){
        if(N[i]=='7'){
            cout<<YES<<endl;
            return;
        }
    }
    cout<<NO<<endl;
}



Measured memory_bytes: 3612
#include <iostream>
using namespace std;

int max(int a,int b){
	if(a>=b)return a;
	else return b;
}

int main(){

	int q;
	int ten[7]={10,100,1000,10000,100000,1000000};

	while(cin>>q){

		int cnt=0;

		for(int l = 0;l<q;l++){
			int r;
			cin>>r;
			cnt=0;
			while(1){
				if(r<10){
					cout<<cnt<<endl;
					break;
				}
				else{
					int length=0;
					for(int i=0;i<7;i++){
						if(ten[i]>=r){
							length = i;
						break;
						}
					}
		
					int next=0;
		
					for(int i=0;i<=length;i++){
		
						int a,b;
						a = r % ten[i];
						b = r / ten[i];

					//	cout<<"a="<<a<<"b="<<b<<endl;
		
						next = max(next,a*b);		

					}
					//cout<<next<<endl;	
					r = next;
					cnt++;
				}
			}
		}

		break;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
 
int main()
{
    // get a integer
    int a;
	cin>>a;
  	string str = to_string(a);
  	if (str.find("7")!=string::npos) {
    	cout << "Yes" << endl;
    } else {
    	cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3668
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    S = input()

    ans = 0
    for s in S:
        if s == '1':
            ans +=1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62852
def f(e):
 a=[[*map(int,input().split())]for _ in[0]*int(e)]
 s,t=min(a)
 b={tuple(map(int,input().split()))for _ in[0]*int(input())}
 m=max(b)[0]-max(a)[0]+s
 for x,y in b:
  if x<=m:
   for u,v in a:
    if(x+u-s,y+v-t)not in b:break
   else:return print(x-s,y-t)
for e in iter(input,'0'):f(e)


Measured memory_bytes: 5912
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}


int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int n;
	cin >> n;

	int x = (n * 100 + 107) / 108;

	int m = x * 1.08;

	if(n != m)
		cout << ":(";
	else
		cout << x << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
#include<numeric>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

#define rep(i,n) for (int i = 0; i < (n); ++i)

int main()
{
  string s;
  cin >> s;
  if (s[s.size()-1] == 's') {
    cout << s << "es" << endl;
  } else {
    cout << s << "s" << endl;
  }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false

signed main(void){
    int K;
    cin >> K;
    int Ans=0;
    OREP(i,K){
        OREP(j,K){
            OREP(k,K){
                int g = gcd(i,j);
                g = gcd(g,k);
                Ans+=g;
            }
        }
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int D;
  cin>>D;
  VL C(26);
  rep(i,26) cin>>C[i];
  VVL S(D,VL(26));
  rep(i,D) rep(j,26) cin>>S[i][j];
  VL T(D);
  rep(i,D) cin>>T[i];
  ll ans=0;
  VL L(26);
  rep(i,D){
    ll tmp=0;
    L[T[i]-1]=i+1;
    rep(j,26) tmp+=C[j]*(i+1-L[j]);
    ans+=S[i][T[i]-1]-tmp;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3720
from collections import deque


def nearlist(N, LIST):  # 隣接リスト
    NEAR = [set() for _ in range(3 * N)]
    for a, b in LIST:
        a, b = 3 * (a - 1), 3 * (b - 1)
        NEAR[a].add(b + 1)
        NEAR[a + 1].add(b + 2)
        NEAR[a + 2].add(b)
    return NEAR


def bfs(S, T, N):  # 幅優先探索  # キュー
    S, T = 3 * (S - 1), 3 * (T - 1)
    dist, flag = [-3] * (3 * N), [0] * (3 * N)  # 前処理
    dist[S], flag[S], que = 0, 1, deque([S])

    while que:
        q = que.popleft()
        for i in near[q]:  # 移動先の候補
            if flag[i]:  # 処理済みか否か
                continue
            dist[i] = dist[q] + 1
            flag[i] = 1
            que.append(i)
    return dist[T] // 3


n, m = map(int, input().split())
uv = [list(map(int, input().split())) for _ in range(m)]
s, t = map(int, input().split())

# 解説AC
near = nearlist(n, uv)
ans = bfs(s, t, n)
print(ans)


Measured memory_bytes: 178400
# -*- coding: utf-8 -*-

def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  S = input()
  ans1 = 0
  ans2 = 0
  for i, c in enumerate(S):
    d = '0' if i % 2 == 0 else '1'
    d2 = '1' if i % 2 == 0 else '0'
    if c != d:
      ans1 += 1
    if c != d2:
      ans2 += 1
  print(min(ans1, ans2))

if __name__ == "__main__":
  main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <numeric>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i, n) for(int i = 1; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	string s; cin >> s;
	int S = s.size();
	REP(i, S) {
		if ((i + 1)  % 2 == 0 && s.at(i) != 'L' && s.at(i) != 'U' && s.at(i) != 'D') {
			cout << "No" << endl;
			return 0;
		}
		else if((i + 1) % 2 == 1 && s.at(i) != 'R' && s.at(i) != 'U' && s.at(i) != 'D') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>

//{{{ bit.hpp
#ifndef INCLUDE_BIT_HPP
#define INCLUDE_BIT_HPP
#include <vector>
namespace orislib {
namespace ds {
template<typename T>
struct BIT {
  std::vector<T> A;
  BIT(int n):A(n, 0){}
  T query(int l,int r){
    if (l) return query(0,r-1)-query(0,l-1);
    T S=0;
    for(;r>=0;r=(r&r+1)-1)S+=A[r];
    return S;
  }
  void add(int k,T a){
    for(int last=A.size();k<last;k|=k+1)A[k]+=a;
  }
};
}
}
#endif
//}}}

using namespace orislib::ds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
//{{{ templates
#define TMPINL_(...) template<__VA_ARGS__>inline
#define TT_ TMPINL_(typename T)
#define TTF_ TMPINL_(typename T,typename F)
#define TTTS_ TMPINL_(typename T,typename...Ts)
#define TITS_ TMPINL_(size_t I=0,typename...Ts)
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TITS_ typename enable_if<I==tuple_size<tuple<Ts...>>::value-1,string>::type join(string s,tuple<Ts...>t){return to_string(get<I>(t));}
TITS_ typename enable_if<I<tuple_size<tuple<Ts...>>::value-1,string>::type join(string s,tuple<Ts...>t){return to_string(get<I>(t))+s+join<I+1>(s,t);}
TT_ string join(string s,T t){return to_string(t);}
TTTS_ string join(string s,T t,Ts...ts){return join(s,t)+s+join(s,ts...);}

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
inline int puts(const string&s){ return puts(s.c_str()); }
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;

int main()
{
  BIT<int> seg(100000);
  int n, q;
  n = in(), q = in();
  for (int i = 0; i < q; i++){
    int a, b, c;
    a = in(), b = in(), c = in();
    if (a) printf("%d\n", seg.query(b, c + 1));
    else seg.add(b, c);
  }
  return 0;
}

Measured memory_bytes: 1524
n, m = input().strip().split(' ')
n, m = [int(n), int(m)]


array = list(map(int, input().strip().split(' ')))
sum = 0
for i in range(n):
    sum = sum + array[i]

bd = sum / (4*m)

cnt = 0
for i in range(n):
    if array[i] >=  bd:
            cnt = cnt + 1
ans = 'No'
if cnt >= m:
    ans = 'Yes'
print(ans)

Measured memory_bytes: 39088
using System;
using static System.Console;

class Class258
{
    static void Main()
    {
        var HN = Array.ConvertAll(ReadLine().Split(),int.Parse);
        int H = HN[0],N = HN[1];

        var dp = new int[H + 1];
        for (int i = 1; i <= H; i++) dp[i] = int.MaxValue;

        for (int i = 0; i < N; i++)
        {

            var ab = Array.ConvertAll(ReadLine().Split(),int.Parse);
            for (int j = 0; j < H; j++)
            {
                if (dp[j] != int.MaxValue)
                {
                    var v = Math.Min(j + ab[0], H);
                    dp[v] = Math.Min(dp[v], dp[j] + ab[1]);
                }
            }
        }
        WriteLine(dp[H]);
    }
}



Measured memory_bytes: 11220
#include<stdio.h>
int main(void){
	int i,count=0,flag,N,A[100],MI;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	
	flag=1;
	i=0;
	while(flag){
		flag=0;
		for(int j=N-1;j>i;j--){
			if(A[j]<A[j-1]){
				MI=A[j];
				A[j]=A[j-1];
				A[j-1]=MI;
				flag=1;
				count++;
			}
		}
	}
	
	for(i=0;i<N;i++){
		printf("%d",A[i]);
		if(i!=N-1){
			printf(" ");
		}
	}
	printf("\n%d\n",count);
	return 0;
}


Measured memory_bytes: 2000
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool chmax(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF 1000000007 //4000000000000000037
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int N,C;
  cin>>N>>C;

  vector<int> s,t;
  vector<set<int>> c(31);

  rep(i,N){
    int ss,tt,cc;
    cin>>ss>>tt>>cc;
    if(c[cc].count(ss)) s.emplace_back(2*ss);
    else s.emplace_back(2*ss-1);

    if(c[cc].count(tt)) t.emplace_back(2*tt-1);
    else t.emplace_back(2*tt);
    
    c[cc].insert(tt); c[cc].insert(ss);
  }

  SORT(s);
  SORT(t);


  int ct=0;
  int ans=0;
  int tnow=0;
  for(int i=0;i<N;){
    if(s[i]<t[tnow]){
      ++i;
      ct++;
      chmax(ans,ct);
    }
    else{
      tnow++;
      --ct;
    }
  }

  cout<< ans<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 10480
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define co cout
#define ci cin
#define sf1(n) scanf("%lld",&n);
#define sf2(n,m) scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define en cout<<endl;
#define pb push_back
#define coy cout<< "YES"<<endl;
#define con cout<< "NO"<<endl;
#define For(a,b) for(ll a=0;a<b;a++)
#define br break;
#define i64 long long
i64 M=10000000;
//ll b[805],ans[805];
map< ll,pair<ll,ll> >mp;

int main()
{
    ll t,n,g,k,m,mx=0,mn=1e9,res,c1,x,y,c2;
    string ab;
    ci>>ab;
    for(ll i=0; i<ab.size(); i++)
    {
        if(i%2!=0)
        {
            if(ab[i]=='L'||ab[i]=='U'||ab[i]=='D')
                continue;
            else
            {
                co<< "No";
                return 0;
            }
        }

    }
    for(ll i=0; i<ab.size(); i++)
    {
        if(i%2==0)
        {
            if(ab[i]=='R'||ab[i]=='U'||ab[i]=='D')
                continue;
            else
            {
                co<< "No";
                return 0;
            }
        }
    }
    co<< "Yes";
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	ans := int(1e9 * 1e9)
	ans = min(ans, calc(a, b, c))
	ans = min(ans, calc(b, a, c))
	ans = min(ans, calc(c, b, a))
	fmt.Println(ans)
}

func calc(a, b, c int) int {
	s1 := ((a + 1) / 2) * b * c
	s2 := (a / 2) * b * c
	return s1 - s2
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,m,k,a;
	cin >> n;
	k=n;
	long long t=10,ans=0;
	if(n%2==1) cout << 0 << endl;
	else{
		while(a=n/t){
			ans+=a;
			t*=10;		
		}
		t=50;
		while(a=n/t){
			ans+=a;
			t*=5;		
		}
		t=100;
		while(a=n/t){
			ans-=a;
			t*=10;		
		}
		cout << ans << endl;	
	}
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double PI=3.14159265358979323846;


int main(){
   double r;
   cin>>r;
   cout<<r*PI*2<<endl;
}


Measured memory_bytes: 3788
import sys
input = sys.stdin.readline
N = int(input())
xl = []
for i in range(N):
    x, l = [int(i) for i in input().split()]
    xl.append((x, l, x+l))
xl.sort(key=lambda x: x[2])
n = xl[0][2]
ans = 1
for x, l, s in xl[1:]:
    if x-l >= n:
        ans += 1
        n = s
print(ans)


Measured memory_bytes: 62172
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

// h(n, r) = c(n+r-1, r)

int main()
{
  ll n, a, b;
  cin >> n >> a >> b;

  if((b-a)%2==0) {
    cout << (b-a)/2 << endl;
  }
  else {
    cout << min(a-1, n-b)+1+(b-a-1)/2 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

vector<ll> divisor(ll n){
  vector<ll> ret;
  for(ll i=1; i*i<=n; i++){
    if(n%i==0){
      ret.push_back(i);
      if(i!=n/i) ret.push_back(n/i);
    }
  }
  return ret;
}

bool check(const vector<ll>& v, ll K, ll x){
  vector<ll> w;
  rep(i,v.size()){
    w.emplace_back(v[i]%x);
  }
  sort(ALLOF(w));

  ll cnt = 0;
  int i=0, j=w.size()-1;
  while(i<j){
    ll a = w[i];
    ll b = x-w[j];
    ll m = min(a,b);
    w[i]-=m;
    w[j]+=m;
    w[j]%=x;

    cnt += m;
    
    if(w[i]==0) i++;
    if(w[j]==0) j--;
  }

  bool flg = true;
  rep(i,w.size()) if(w[i] != 0) flg = false;
  return flg && cnt <= K;
}


int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll> v;
  ll sum = 0;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
    sum += a;
  }

  vector<ll> dv = divisor(sum);

  ll ret = 0;
  rep(i,dv.size()){
    if(check(v,K,dv[i])){
      ret = max(ret, dv[i]);
    }
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    map<string, int> m;
    string s;
    for (int i = 0; i < N; ++i) {
        cin >> s;
        sort(s.begin(), s.end());
        m[s]++;
    }

    vector<ll> tosa(100005);
    tosa[0] = 0;
    tosa[1] = 0;
    for (int i = 2; i < 100005; ++i) {
        tosa[i] = tosa[i - 1] + i - 1;
    }

    ll ans = 0;
    for (auto kv :m) {
        ans += tosa[kv.second];
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11904
N = int(input())
A = list(map(int, input().split()))
ans = 0
def yo(n):
    return n%2
def waru(n):
    return int(n / 2)

for i in range(200):
    B = list(map(yo, A))
    if sum(B) == 0:
        A = list(map(waru, A))
        ans += 1
print(ans)

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define MAXX 200005


#define PI 3.14159265358979323846264338327950

#define ll  long long int
vector<ll> v;
multiset<ll> ms;
multiset<ll>::iterator it;
ll a[MAXX], b[MAXX];
ll mod = 1000000007;
char c[MAXX];

int main()
{
	FAST;
	ll  ans = 0, a1 = 0, a2 = 0, n , mx = 0, m;
	cin >> n >> m;
	for(ll i = 1; i <= m; i++){
		cin >> a[i];

	}
	sort(a+1, a+m+1);
	for(ll i = 2; i <= m; i++){
		b[a1] = a[i]- a[i-1];
		a1 ++;
	}
	sort(b, b + a1);
	reverse(b, b + a1);
	for(ll i = 0; i< a1; i++){
		ans += b[i];
		mx = max(mx, b[i]);
		
	}
	for(ll i = 0; i < n - 1 ; i ++){
		ans -= b[i];
	}
	if(n > m){
		ans = 0;
	}
	cout << ans;
	
}

Measured memory_bytes: 1792
def main():
    S = int(input())
    x1, y1 = 10**9, 1
    if S < 10**9:
        x1 = 1
        x2 = 0
        y2 = S
    else:
        y2 = 0--S//10**9
        x2 = x1*y2 - S
    print(0, 0, x1, y1, x2, y2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384