akhauriyash/Code-Regression huggingface dataset:
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001



line = []

def calc_E(left,right):
    global line

    depth = 0
    Q = deque()

    #深さ0の、プラスまたはマイナスを探す(単項の-は無いものとする)
    i = left
    while i <= right:
        if line[i] == '(':
            depth += 1
        elif line[i] == ')':
            depth -= 1

        if depth != 0:
            i += 1
        elif line[i] != '+' and line[i] != '-':
            i += 1
        else:
            Q.append(i)
            i += 1

    if len(Q) == 0:
        return calc_T(left,right)

    tmp = calc_E(left,Q[0]-1)

    while len(Q) > 0:
        loc = Q.popleft()

        tmp_right = None

        if len(Q) == 0:
            tmp_right = calc_T(loc+1,right)
        else:
            tmp_right = calc_T(loc+1,Q[0]-1)

        if line[loc] == '+':
            tmp += tmp_right
        else:
            tmp -= tmp_right

    return tmp


def calc_T(left,right):
    global line

    depth = 0
    Q = deque()

    #深さ0の、*または/を探す
    i = left
    while i <= right:
        if line[i] == '(':
            depth += 1
        elif line[i] == ')':
            depth -= 1

        if depth != 0:
            i += 1
        elif line[i] != '*' and line[i] != '/':
            i += 1
        else:
            Q.append(i)
            i += 1

    if len(Q) == 0:
        return calc_F(left,right)

    tmp = calc_T(left,Q[0]-1)

    while len(Q) > 0:
        loc = Q.popleft()

        tmp_right = None

        if len(Q) == 0:
            tmp_right = calc_F(loc+1,right)
        else:
            tmp_right = calc_F(loc+1,Q[0]-1)

        if line[loc] == '*':
            tmp *= tmp_right
        else: #注意:たとえば(-3//2はpython3では-2になる模様)
            if tmp*tmp_right > 0:
                tmp = abs(tmp)//abs(tmp_right)
            else:
                tmp = abs(tmp)//abs(tmp_right)
                tmp *= -1

    return tmp


def calc_F(left,right):
    if line[left].isdecimal():
        return calc_NUM(left,right)
    elif line[left] == '(':

        depth = 0
        close_pos = None

        for i in range(left,right+1):
            if line[i] == '(':
                depth += 1
            elif line[i] == ')':
                depth -= 1
                if depth == 0:
                    close_pos = i
                    break

        return calc_E(left+1,close_pos-1)

def calc_NUM(left,right):
    global line
    ret = 0

    for i in range(left,right+1):
        ret = 10*ret+int(line[i])

    return ret

N = int(input())

for _ in range(N):
    line = str(input())
    print("%d"%(calc_E(0,len(line)-2)))




Measured memory_bytes: 6400
s = int(input())
n = s//3
mod = 10**9 + 7
ans = 0
fact = [1]
finv = [1]
for i in range(s):
    fact += [(fact[i] * (i+1)) % mod]
    finv += [pow(fact[i+1], mod-2, mod)]


def comb(n, k):
    return (fact[n] * finv[n-k] * finv[k]) % mod


for i in range(n):
    ans += comb(s-3*(i+1)+i, i)
    ans %= mod
print(ans)

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int k;
    cin >> k;
    for (int i=0; i<k; i++)
        cout << "ACL";
    cout << "\n";

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int NPrime=3000000;
bool prime[NPrime+1];
vi EnumeratePrime(){
	fill(prime+2,prime+NPrime+1,true);
	vi a;
	for(int i=2;i<=NPrime;i++) if(prime[i]){
		a.emplace_back(i);
		for(int j=2*i;j<=NPrime;j+=i) prime[j]=0;
	}
	return a;
}

int n;

int main(){
	EnumeratePrime();
	while(1){
		cin>>n;
		if(n==0) break;
		int res=0;
		for(int i=n+1;i<=2*n;i++) if(prime[i]) res++;
		cout<<res<<endl;
	}
}


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

void printArr(int *arr, int size)
{
	for (int i = 0; i < size; i++)
	{
		if (i != 0)cout << " ";
		cout << arr[i];
	}
	cout << endl;
}

void swap(int *arrA, int *arrB)
{
	int temp = *arrA;
	*arrA = *arrB;
	*arrB = temp;
}

int bubbleSort(int *arr, int size)
{
	int cnt = 0;
	for (int i = 0; i < size; i++)
	{
		for (int j = size - 1; j > i; j--)
		{
			if (arr[j] <  arr[j - 1]) {
				swap(&arr[j], &arr[j - 1]);
				cnt++;
			}
		}
	}
	return cnt;
}

int main()
{
	int arr[100];
	int N = 0;

	cin >> N;
	for (int i = 0; i < N; i++)cin >> arr[i];

	int sortCnt = bubbleSort(arr, N);
	printArr(arr, N);
	cout << sortCnt << endl;
	
	return 0;
}

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    string S;
    int Q;
    cin >> S >> Q;
    deque<char> ss(S.begin(), S.end());
    bool rev = false;
    for (int i = 0; i < Q; ++i) {
        int Ti;
        cin >> Ti;
        if (Ti == 1) {
            rev = !rev;
        } else {
            int Fi; char Ci;
            cin >> Fi >> Ci;
            if (Fi == 1 && !rev || Fi == 2 && rev) {
                ss.push_front(Ci);
            } else {
                ss.push_back(Ci);
            }
        }
    }
    cout << (rev ? string(ss.rbegin(), ss.rend()) : string(ss.begin(), ss.end())) << endl;
}

Measured memory_bytes: 1280
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

int n;
vector<int> a;
vector<vector<int>> edge;

bool dfs(int v, int par){
    int sum = 0;
    int maxi = 0;
    int child = 0;
    for(int u : edge[v]){
        if(u == par){
            continue;
        }
        if(not dfs(u, v)){
            return false;
        }
        sum += a[u];
        maxi = max(maxi, a[u]);
        child++;
    }

    if(child == 0){
        return true;
    }

    int rest = a[v] * 2 - sum;
    maxi = max(maxi, rest);
    if(rest < 0){
        return false;
    }
    if(maxi > a[v]){
        return false;
    }
    if(child == 1 && rest != a[v]){
        return false;
    }

    a[v] = rest;
    return true;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    a = vector<int>(n);
    rep(i, n) cin >> a[i];
    edge = vector<vector<int>>(n, vector<int>());
    rep(i, n - 1){
        int a, b;
        cin >> a >> b;
        edge[a-1].push_back(b-1);
        edge[b-1].push_back(a-1);
    }

    if(not dfs(0, -1)){
        cout << "NO" << endl;
        return 0;
    }
    if(SZ(edge[0]) > 1 && a[0] > 0){
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 13184
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int count = 0;
        bool last = false;
        for (int i = 0; i < x.Length; i++)
        {
            if (x[i] == i + 1)
            {
                if (last)
                {
                    count++;
                    last = false;
                }
                else
                {
                    last = true;
                }
            }
            else if (last)
            {
                count++;
                last = false;
            }
        }
        if (last)
        {
            count++;
        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 20064
MOD = 10**9 + 7
s = input()
n = len(s)
dp = [0 for _ in range(13)]
dp[0] = 1
for i in range(n):
	dpp = [0 for _ in range(13)]
	if s[i] != "?":
		for j in range(13):
			dpp[(j*10+int(s[i])) % 13] = dp[j]
	else:
		for j in range(13):
			for k in range(10):
				dpp[(j*10+k)%13] += dp[j]
				dpp[(j*10+k)%13] %= MOD
	dp = dpp
print(dp[5])

Measured memory_bytes: 45080
#include<bits/stdc++.h>
using namespace std;
const int maxn=200004;
int rmd[maxn];
int pref[maxn];
char s[maxn];
int main(){
	scanf("%s",s+1);
	int base=1;
	long long cnt=0;
	rmd[0]=1;
	int len=strlen(s+1);
	for(int i=len;i>=1;i--){
		pref[i]=(pref[i+1]+base*(s[i]-'0'))%2019;
		base=base*10%2019;
		cnt+=rmd[pref[i]];
		rmd[pref[i]]++;
	}
	printf("%lld\n",cnt);
}

Measured memory_bytes: 4708
#include<bits/stdc++.h>
using namespace std;
bool cmp(char a, char b)
{
	return a > b;
}
int main()
{
	string s, t;
	cin>>s>>t; 
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),cmp);
	if(s<t)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int w,h,x,y,z;
double ans;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>w>>h>>x>>y;
    ans = ((double)w*(double)h)/2;

    if(w%2==0 && h%2==0){
        int a,b;
        a = w/2;
        b = h/2;
        if(a==x && b==y){z=1;}
    }
    printf("%.7lf %d\n",ans,z);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, x, i, j, k, a;
	char s;
	
	while(1){
		scanf("%d%d", &n, &x);
		if((n == 0) && (x == 0)) break;
		
		a = 0;
		for(i = 1; i <= (n - 2); i++){
			for(j = (i + 1); j <= (n - 1); j++){
				for(k = (j + 1); k <= n; k++){
					if((i + j + k) == x) a++;
				}
			}
		}
		printf("%d\n", a);
	}
	
	return(0);
}



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


int main (void){
        int N;
        long long int ans=0,top[5];
        char name[11];
        scanf("%d",&N);
        for (int i = 0; i < 5; i++) {
                top[i]=0;
        }
        for (int i = 0; i < N; i++) {
                scanf("%s",name);
                if(name[0]=='M') {
                        top[0]++;
                }
                if(name[0]=='A') {
                        top[1]++;
                }
                if(name[0]=='R') {
                        top[2]++;
                }
                if(name[0]=='C') {
                        top[3]++;
                }
                if(name[0]=='H') {
                        top[4]++;
                }
        }
        ans=top[0]*top[1]*top[2]+top[0]*top[1]*top[3]+top[0]*top[1]*top[4]+top[0]*top[2]*top[3]+top[0]*top[2]*top[4]+top[0]*top[3]*top[4]+top[1]*top[2]*top[3]+top[1]*top[2]*top[4]+top[1]*top[3]*top[4]+top[2]*top[3]*top[4];
        printf("%lld",ans);
        return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)


const int MAX_N = 100;
int N, T;
int c[MAX_N], t[MAX_N];

void solve() {
    int c_min = INF;
    REP(i, N) {
        if (t[i] > T) continue;
        c_min = min(c_min, c[i]);
    }
    if (c_min == INF)cout << "TLE" << endl;
    else cout << c_min << endl;
}

int main() {
    cin >> N >> T;
    REP(i, N)cin >> c[i] >> t[i];
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
using namespace std;

#define ll long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;


int main() {
	ifstream fin("Text.txt");
	int i, j, k;
	ll a, b,t, c, e, n,x,y, m, r, d, q,ans=0;
	cin >> n;
	VEC vc(n);
	forn(i, n) {
		cin >> vc[i];
	}
	sort(vc.begin(), vc.end());
	i = 0;
	j = 0;
	while (j<n && i <n)
	{
		if (vc[j] - vc[i] <= 2) {
			ans = max(ans, (ll)(j - i + 1));
			j++;
		}
		else {
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    int H;
    while (cin >> H, H) {
	vector<vector<int>> mp(H, vector<int>(5));
	for (auto &a : mp) {
	    for (auto &b : a) {
		cin >> b;
	    }
	}
	int score = 0;
	bool down = true;
	while (down) {
	    down = false;
	    for (int h = H - 1; h >= 0; h--) {
		int prev = -1, cnt = 0;
		for (int w = 0; w < 5; w++) {
		    if (prev == mp[h][w]) {
			cnt++;
		    }  else {
			if (cnt >= 3) {
			    for (int ww = w - 1; cnt; ww--, cnt--) {
				score += mp[h][ww];
				mp[h][ww] = 0;
			    }
			}
			prev = mp[h][w];
			cnt = 1;
		    }
		}
		if (cnt >= 3) {
		    for (int ww = 4; cnt; ww--, cnt--) {
			score += mp[h][ww];
			mp[h][ww] = 0;
		    }
		}
	    }
	    for (int w = 0; w < 5; w++) {
		vector<int> rem;
		for (int h = H - 1; h >= 0; h--) {
		    if (mp[h][w] != 0) {
			rem.push_back(mp[h][w]);
		    }
		}
		rem.resize(H, 0);
		reverse(rem.begin(), rem.end());
		for (int h = H - 1; h >= 0; h--) {
		    if (mp[h][w] != rem[h]) {
			down = true;
		    }
		    mp[h][w] = rem[h];
		}
	    }
	}
	cout << score << endl;
    }
    return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>
int main(void){
   int M,N,fcnt[30],K[30],A[30][30],x,i,j,k,cnt=0;
   scanf("%d %d",&N,&M);
   /* 初期化 */
   for(j=0;j<N;j++){
   for(i=0;i<M;i++){
   K[i]=A[i][j]=fcnt[i]=0;
   }
   }
   
    for(i=0;i<N;i++){
       scanf("%d",&K[i]);
       for(j=0;j<K[i];j++){
       scanf("%d",&x);
       A[i][j]=x;
       }
    }
    
    for(k=0;k<M;k++){
        for(i=0;i<N;i++){
            for(j=0;j<K[i];j++){
             if(A[i][j]==k+1)
             fcnt[k]++;
            }
         }
         if(fcnt[k]==N)
         cnt++;
    }
    
  printf("%d",cnt);
   
   return(0);
}


Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class FPlayingTagOnTree {
    vector<vector<int>> edges_;

    void fillDepth(const int prev, const int cur, const int depth, vector<int>& leafDepth) {
        if (edges_[cur].size() == 1 && edges_[cur].front() == prev) {
            leafDepth[cur] = depth;
            return;
        }
        for (const auto& next : edges_[cur]) {
            if (next == prev) continue;
            fillDepth(cur, next, depth+1, leafDepth);
        }
    }
public:
    void solve(std::istream& in, std::ostream& out) {
        int N, u, v;
        in >> N >> u >> v;
        vector<int> A(N), B(N);
        REP(i,1,N) in >> A[i] >> B[i];
        edges_ = vector<vector<int>> (N+1);
        REP(i,1,N) {
            edges_[A[i]].emplace_back(B[i]);
            edges_[B[i]].emplace_back(A[i]);
        }
        vector<int> leafDepthU(N+1), leafDepthV(N+1);
        fillDepth(-1, u, 0, leafDepthU);
        fillDepth(-1, v, 0, leafDepthV);
        int answer = 0;
        REP(i,1,N+1) {
            if (leafDepthU[i] == 0 && leafDepthV[i] == 0 || leafDepthU[i] >= leafDepthV[i]) continue;
            answer = max(answer, leafDepthV[i] - 1);
        }
        out << answer << "\n";
    }
};


signed main() {
    FPlayingTagOnTree solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 9728
#include <cstdio>
#include <map>
using namespace std;
int main(void){
	map<int,int> remain;
	for(int i=0;i<3;++i){
		map<int,int> group;
		for(int j=0,num,p,q;j<8;++j){
			scanf("%d %d.%2d",&num,&p,&q);
			group[p*100+q]=num;
		}
		int j=0;
		for(map<int,int>::iterator it=group.begin();it!=group.end();++it){
			if(j<2) printf("%d %d.%02d\n",(*it).second,(*it).first/100,(*it).first%100);
			else remain[(*it).first] = (*it).second;
			++j;
		}
		
	}
	int i=0;
	for(map<int,int>::iterator it=remain.begin();it!=remain.end();++it){
		if(i<2) printf("%d %d.%02d\n",(*it).second,(*it).first/100,(*it).first%100);
		++i;
	}
	return 0;
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
using namespace std;
#define INF 1LL<<60



int main(){
    string S;
    cin >> S;
    int N=S.size();
    string s,new_s;
    s=S;
    reverse(S.begin(),S.end());
    // cout << S << endl;
    if(s!=S){
        cout << "No" << endl;
        return 0;
    }

    s=S.substr(0,(N-1)/2);
    new_s=s;
    reverse(s.begin(),s.end());
    // cout << s << endl;
    if(s!=new_s){
        cout << "No" << endl;
        return 0;
    }

    s=S.substr((N+3)/2-1,N-(N+3)/2+1);
    new_s=s;
    reverse(s.begin(),s.end());
    // cout << new_s << endl;
        if(s!=new_s){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    return 0;

}

Measured memory_bytes: 256
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

const int INF = 1e9;
vector<vector<int>> adj;
vector<int> num;
vector<pair<int, int>> range;
bool update(pair<int, int>& l, const pair<int, int>& r) {
    if(l.second < r.first || r.second < l.first) return false;
    bool ok = false;
    if(l.first <= r.first && r.second <= l.second) ok = true;
    if(r.first <= l.first && l.second <= r.second) ok = true;
    if(!ok) if((l.first & 1) == (r.first & 1)) ok = true;
    l.first = max(l.first, r.first);
    l.second = min(l.second, r.second);
    return ok;
}
bool dfs(int cur, int par) {
    auto& myRange = range[cur];
    bool stRange = (myRange != make_pair(-INF, INF));
    bool res = true;
    if(num[cur] == INF) {
        auto nRange = myRange;
        nRange.first--; nRange.second++;
        for(int nxt : adj[cur]) if(nxt != par) {
            if(stRange) range[nxt] = nRange;
            res &= dfs(nxt, cur);
            auto upRange = range[nxt];
            upRange.first--; upRange.second++;
            res &= update(myRange, upRange);
        }
    }
    else {
        if(stRange) {
            res &= ((myRange.first & 1) == (num[cur] & 1));
            res &= (myRange.first <= num[cur] && num[cur] <= myRange.second);
        }
        if(!res) return res;
        myRange = make_pair(num[cur], num[cur]);
        pair<int, int> nRange(num[cur] - 1, num[cur] + 1);
        for(int nxt : adj[cur]) if(nxt != par) {
            range[nxt] = nRange;
            res &= dfs(nxt, cur);
            auto upRange = range[nxt];
            upRange.first--; upRange.second++;
            res &= update(myRange, upRange);
        }
    }
    return res;
}
void dfs2(int cur, int par) {
    if(num[cur] == INF) {
        num[cur] = range[cur].first;
    }
    pair<int, int> nRange(num[cur] - 1, num[cur] + 1);
    for(int nxt : adj[cur]) if(nxt != par) {
        update(range[nxt], nRange);
        dfs2(nxt, cur);
    }
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    adj.assign(n, vector<int>());
    for(int _ : in(n - 1)) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        adj[u].emplace_back(v);
        adj[v].emplace_back(u);
    }
    num.assign(n, INF);
    int q;
    cin >> q;
    for(int _ : in(q)) {
        int v, p;
        cin >> v >> p;
        --v;
        num[v] = p;
    }
    range.assign(n, make_pair(-INF, INF));
    if(dfs(0, -1) == false) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes\n";
        dfs2(0, -1);
        for(int x : num) cout << x << '\n';
    }
    return 0;
}

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

using ll = long long;
using vll = vector<ll>;

#define all(v) (v).begin(), (v).end()

const ll INF = LLONG_MAX / 2ll;

ll doit(const vll& psum, const ll L, const ll X) {
	ll N = psum.size() - 1;
	ll ans = (N + L) * X;

	// do first pickups
	ans += 5ll * (psum[N] - psum[N - L]);
	if (ans > INF) return INF;
	// do all others
	for (ll j = 2, cur = N - L; cur > 0; j++, cur -= L) {
		ans += (2ll*j + 1ll) * (psum[cur] - psum[max(0ll, cur - L)]);
		if (ans > INF) return INF;
	}
	return ans;
}

int main() {
	ll N, X;
	scanf("%lld %lld", &N, &X);
	vll pos(N);
	for (ll &p : pos) scanf("%lld", &p);
	vll psum(1 + N, 0);
	partial_sum(all(pos), psum.begin() + 1);

	ll ans = LLONG_MAX;
	for (int L = 1; L <= N; L++)
		ans = min(ans, doit(psum, L, X));
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>

int main(void)
{
	
	int a,b,c;
	int i,j;
	int uru[1000]={};
	
	for(i=0;;i++){
		scanf("%d %d",&a,&b);
		
		if(a==0&&b==0){
			break;
		}
		if(i!=0){
			printf("\n");
		}
		
		c=0;
		for(j=a;j<=b;j++){
			if(j%4==0){
				if(j%100==0&&j%400!=0){
					continue;
				}
				uru[c]=j;
				c++;
			}
		}
		
		if(uru[0]==0){
			printf("NA\n");
			continue;
		}
		
		for(j=0;j<c;j++){
			printf("%d\n",uru[j]);
			uru[j]=0;
		}
	}
	return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 998244353
#define ll long long
using namespace std;
ll dp[305][100000];
ll dp2[305][100000];
signed main(){
	int n;
	cin>>n;
	vector<int> a;
	ll sum = 0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.pb(x);
		sum += x;
	}
	dp[0][0]=2;
	dp[0][a[0]]=1;
	for(int i=1;i<n;i++){
		for(int j=0;j<=90000;j++){
			dp[i][j+a[i]] += dp[i-1][j];
			dp[i][j+a[i]] %= inf;
			dp[i][j] += dp[i-1][j]*2;
			dp[i][j] %= inf;
		}
	}
	dp2[0][0]=1;
	dp2[0][a[0]]=1;
	for(int i=1;i<n;i++){
		for(int j=0;j<=90000;j++){
			dp2[i][j+a[i]] += dp2[i-1][j];
			dp2[i][j+a[i]] %= inf;
			dp2[i][j] += dp2[i-1][j];
			dp2[i][j] %= inf;
		}
	}
	ll ans=1;
	for(int i=1;i<=n;i++){
		ans *= 3;
		ans %= inf;
	}
	for(int i=(sum+1)/2;i<=sum;i++){
		ll dt = (dp[n-1][i]*3)%inf;
		//cout<<i<<" "<<dp[n-1][i]<<endl;
		ans = (ans - dt + inf)%inf;
	}
	if(sum%2==0)ans += dp2[n-1][sum/2]*3 ;
	ans %= inf;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 470400
N = int(input())
l = [list(map(int, input().split())) for l in range(N)]
for a in range(N-2):
    m = l[a]
    n = l[a+1]
    o = l[a+2]
    z = 0
    if m[0] == m[1]:
        if n[0] == n[1]:
            if o[0] == o[1]:
                z = z+1
                break;
            else:
                pass
        else:
            pass
    else:
        pass
if z == 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9204
N, M = map(int, input().split(" "))
cityList = []


class City:
    def __init__(self, id, pre, year):
        self.id = id
        self.pre = pre
        self.year = year
        self.number = ""


for i in range(M):
    P, Y = map(int, input().split(" "))
    city = City(i + 1, P, Y)
    cityList.append(city)

cityList.sort(key=lambda x: x.year)
cityList.sort(key=lambda x: x.pre)

num = 0
count = 0
for city in cityList:
    if city.pre != num:
        num = city.pre
        count = 1
    city.number = str(num).zfill(6) + str(count).zfill(6)
    count += 1

cityList.sort(key=lambda x: x.id)
for city in cityList:
    print(city.number)


Measured memory_bytes: 47204
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef long double td;
typedef vector<td> vd;
typedef pair<ll,ll> ii;
typedef vector<ii> vii; typedef vector<bool> vb;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(ll i = ll(a); i < (ll)(b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define show(v,n) cerr << #v << " = "; forn(i,n) cerr << v[i] << " "; cerr << endl;
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
int MAXN = 500005;
ll INF = (ll)(1e18+7);
ll modu = (ll)(1e9+7);

vector < vector <int> > v(100005);
vector <bool> visto(100005,false);
vector < vector <ll> > dp(100005,vector <ll>(4,1));

void DFS(int n)
{
	visto[n]=true;
	//DBG(n);
	bool d = false;
	vector < vector <ll> > ans(3);
	for(auto u : v[n])
	{
		if(!visto[u])
		{
			DFS(u);
			d=true;
			ans[0].pb(dp[u][0]+dp[u][1]);
			ans[1].pb(dp[u][0]);
		}
	}
	for(auto u : ans[0])
	{
		dp[n][0]*=u;
		dp[n][0]%=modu;
	}
	for(auto u : ans[1])
	{
		dp[n][1]*=u;
		dp[n][1]%=modu;
	}
}
 
int main()
{ 	
	FIN;
	#ifdef input
		//("T1.txt", "r", stdin);
	#endif
	
	int n;
	cin >> n;
	forn(i,n-1)
	{
		int x, y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	
	DFS(1);
	
	//forr(i,1,n+1) cout << dp[i][0] << " " << dp[i][1] << "\n";
	cout << (dp[1][0]+dp[1][1])%modu << "\n";
	
	
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	double p[n];
	for(int i=0; i<n; i++) {
		cin >> p[i];
	}
	double dp[n+1][n+1];
	memset(dp, 0.0, sizeof(dp));
	dp[0][0] = 1.0;
	for(int i=1; i<=n; i++) {
		for(int j=0; j<=i; j++) {
			if(j == 0) {
				dp[i][j] = dp[i-1][j] * (1.0 - p[i-1]);
			} else {
				dp[i][j] = dp[i-1][j] * (1.0 - p[i-1]) + dp[i-1][j-1] * p[i-1];
			}
		}
	}
	double prob = 0.0;
	for(int j=n/2+1; j<=n; j++) {
		prob += dp[n][j];
	}
	cout << setprecision(10) << prob << endl;
	return 0;
}

Measured memory_bytes: 70528
#include<iostream>

using namespace std;
int main()
{
    int st1,n;
    string s;
    cin>>s;
    int l=s.length();
    for(int i=0;i<l;i++)
    {
        if(s[i]=='A')
        {
            st1=i+1;
            break;
        }
    }
    for(int i=0;i<l;i++)
    {
        if(s[i]=='Z')
        {
            n=i+1;
        }
    }
    cout<<n-st1+1<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
int h, w, n;
array<int, 4> dx{1, -1, 0, 0}, dy{0, 0, 1, -1};
bool solve(vector<vector<char>> grid){
    int ok = 1;
    for (int i = 1; i <= h; ++i) {
        stable_sort(grid[i].begin()+1, grid[i].end()-1, [](char a, char b){
            return ((a == '.') > (b == '.'));
        });
    }
    
    while(true){
        ok = 0;
        vector<vector<bool>> kie(h+2, vector<bool>(w+2, false));
        for (int i = 1; i <= h; ++i) {
            for (int j = 1; j <= w; ++j) {
                if(!isalpha(grid[i][j])) continue;
                for (int k = 0; k < 4; ++k) {
                    int y = i, x = j;
                    while(grid[y+dy[k]][x+dx[k]] == grid[i][j]) y += dy[k], x += dx[k];
                    if(abs(y-i)+abs(x-j)+1 >= n){
                        for (int p = 0; p <= abs(y-i)+abs(x-j); ++p) {
                            kie[i+dy[k]*p][j+dx[k]*p] = true;
                        }
                    }
                }
            }
        }
        for (int i = 1; i <= h; ++i) {
            for (int j = 1; j <= w; ++j) {
                if(kie[i][j]) ok = 1, grid[i][j] = '.';
            }
        }
        if(!ok) break;
        for (int i = 1; i <= h; ++i) {
            stable_sort(grid[i].begin()+1, grid[i].end()-1, [](char a, char b){
                return ((a == '.') > (b == '.'));
            });
        }

    }
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if(grid[i][j] != '.') return false;
        }
    }
    return true;
}

int main() {

    cin >> h >> w >> n;
    swap(h, w);
    vector<vector<char>> v(h+2, vector<char> (w+2, 0));
    for (int i = 0; i < w; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < h; ++j) {
            v[j+1][i+1] = s[j];
        }
    }
    for (int i = 1; i < h; ++i) {
        for (int j = 1; j <= w; ++j) {
            swap(v[i][j], v[i+1][j]);
            if(solve(v)){
                puts("YES");
                return 0;
            }
            swap(v[i][j], v[i+1][j]);
        }
    }
    cout << "NO" << "\n";
    return 0;
}


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

int main() {
  int N = 0;
  int A = 0;
  
  cin >> N >> A;
  if ((N<1) || (N>100)){
    cout << "Nは1以上100以下の整数を入力してください" << endl;
  } else if ((A<0) || (A>N*N)){
    cout << "Aは0以上N^2以下の整数を入力してください" << endl;
  } else {
    cout << N*N-A << endl;
  }
}

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

#define int long long

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 2e5 + 5;
const int P = 1e9 + 7;
map<pair<int, int>, pair<int, int> > cnt;

int gcd(int a, int b){ return b ? gcd(b, a % b) : a; }
int Pow(int x, int t)
{
	int res = 1;
	for (; t; t >>= 1, x = x * x % P)
		if (t & 1) res = res * x % P;
	return res;
}

signed main()
{
	int n = read(), tot = P - 1;
	for (int i = 1; i <= n; ++i)
	{
		int a = read(), b = read();
		if (!a && !b) { ++tot; continue; }
		int g = gcd(a, b);
		a /= g; b /= g;
		if (b < 0) a = -a, b = -b;
		
		if (a > 0) ++cnt[{a, b}].first;
			else ++cnt[{b, -a}].second;
	}
	
	int ans = 1;
	for (auto i : cnt) 
		ans = ans * (Pow(2, i.second.first) + Pow(2, i.second.second) - 1) % P;
	printf("%lld\n", (ans + tot) % P);
	return 0;
}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	set<int> d;
	FOR(i,0,n){
		int tmp;
		cin >> tmp;
		d.insert(tmp);
	}
	ANS(d.size());
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

struct Node{
    int key;
    Node *prev, *next;
};

Node *nil;

void init() {
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    x->prev = nil;
    nil->next->prev = x;
    nil->next = x;
}

Node *listSearch(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void deleteNode(Node *t) {
    if (t == nil)  return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void printList() {
    Node *tmp = nil->next;
    while (tmp != nil) {
        printf("%d", tmp->key);
        if (tmp->next != nil) {
            printf(" ");
        }
        tmp = tmp->next;
    }
    printf("\n");
}

int main() {
    init();
    char com[20];
    int key, n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%s%d", com, &key);
        if (com[0] == 'i') {  // insert x
            insert(key);
        }
        else if (com[0] == 'd') {
            if (strlen(com) > 6) {
                if (com[6] == 'F') {  //deleteFirst
                    deleteFirst();
                }
                else if (com[6] == 'L') {  //deleteLast
                    deleteLast();
                }
            }
            else {
                deleteKey(key);
            }

        }
    }
    printList();   
    return 0;
}



Measured memory_bytes: 33920
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

bool is_prime[110000];
ll prime[1100000];

//n以下の素数の数を返す
ll sieve(ll n){
  ll count=0;
  for(int i=0;i<=n;i++) is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<n;i++){
    if(is_prime[i]){
      prime[count++]=i;
      for(int j=2*i;j<=n;j+=i) is_prime[j]=false;
    }
  }
  return count;
}

int main(){
  int Q,ans[110000],l,r;
  sieve(100000);
  ans[0]=ans[1]=ans[2]=0;
  ans[3]=1;
  cin>>Q;
  //cout<<"unko"<<endl;
  for(int i=5;i<=99999;i+=2){
    ans[i-1]=ans[i-2];
    ans[i]=ans[i-2];
    if(is_prime[i] && is_prime[(i+1)/2]) ans[i]++;
    //cout<<ans[i]<<endl;
  }

  for(int i=0;i<Q;i++){
    cin>>l>>r;
    cout<<ans[r]-ans[l-1]<<endl;
  }
}


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

int main()
{
    int N,K;
    cin >> N >> K;
    vector<pair<int,int>> edge;
    vector<vector<int>> des(N+1, vector<int>());
    for(int i=1;i<N;i++){
        // if(2*i<=N)edge.emplace_back(i,2*i);
        if(2*i+1<=N)edge.emplace_back(i,2*i+1);
    }
    for (int i = N; i >= 1;i--){
        if(2*i<=N){
            des[i].push_back(2 * i);
            for(auto x:des[2*i])
                des[i].push_back(x);
        }
        if (2 * i+1 <= N)
        {
            des[i].push_back(2*i+1);
            for (auto x : des[2 * i+1])
                des[i].push_back(x);
        }
    }
    for (int i = 1;i<N;i++){
        if(2*i+1<=N){
            for(auto x:des[2*i+1]){
                edge.emplace_back(i, x);
            }
        }
    }
    int M = edge.size();
    cout << edge.size() << endl;
    for (int i = 0; i < M; i++)
    {
        cout << edge[i].first << " " << edge[i].second << endl;
    }
    for(int i=0;i<K;i++){
        int num = 1;
        cout << num << endl;
        string answer;
        while (cin >> answer)
        {
            if (answer == "Yes")
            {
                break;
            }
            else if (answer == "No")
            {
                num = num * 2;
                cout << num << endl;
            }
            else
            {
                num = num * 2 + 1;
                cout << num << endl;
            }
        }
    }
    
}


Measured memory_bytes: 3336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main(){
    ll n;
    cin >> n;

    map<string,int> mp;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        sort(all(s));
        mp[s]++;
    }

    ll ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        ll t = itr->second;
        ans += t*(t-1)/2;
    }

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 11136
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn maxi(vs: Vec<usize>) -> (usize, usize) {
    let mut max = (0, 0);
    for (i, v) in vs.iter().enumerate() {
        if v > &max.1 {
            max = (i, *v);
        }
    }
    max
}

fn main() {
    input! {
        vs: [usize; 3],
    }


    let max = maxi(vs.clone());
    if max.0 == 0 {
        println!("{}", vs[1] * vs[2] / 2);
    } else if max.0 == 1 {
        println!("{}", vs[0] * vs[2] / 2);
    } else {
        println!("{}", vs[0] * vs[1] / 2);
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl

int main() {
  int x[3];
  cin >> x[0] >> x[1] >> x[2];
  sort(x, x+3);
  int cnt = 0;
  while (x[1] < x[2]) {
    x[0]++;
    x[1]++;
    cnt++;
  }
  while (x[0] < x[1]) {
    x[0] += 2;
    cnt++;
  }
  if (x[0] == x[1]) {
    dump(cnt);
  }
  else {
    dump(cnt+1);
  }
  return 0;
}


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

class Main{
    public static void main(String args[]) {
        int[] a = new int[55];
        int[] b = new int[55];
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int M = scan.nextInt();
        for (int i = 0; i < M; i++)
        {
            a[i] = scan.nextInt();
            b[i] = scan.nextInt();
        }
        scan.close();
        int[] ans = new int[55];
        Arrays.fill(ans, 0);
        for (int i = 0; i < M; i++)
        {
            ans[a[i]]++;
            ans[b[i]]++;
        }
        for (int i = 1; i <= N; i++)
        {
            System.out.println(ans[i]);
        }
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n';
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll s;
    cin >> s;
    ll x = (1000000000LL - s % 1000000000LL) % 1000000000LL;
    ll y = (s + x) / 1000000000LL;
    cout << "0 0 1000000000 1 " << x << " " << y << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n, m, x; cin >> n >> m >> x;
	vector<bool> a(n + 1);
	for (int i = 0; i < m; i++) {
		int j; cin >> j;
		a.at(j) = true;
	}
	int cnt = 0;
	for (int i = x + 1; i < n; i++) {
		if (a.at(i)) cnt++;
	}
	int cnt2 = 0;
	for (int i = x - 1; i > 0; i--) {
		if (a.at(i)) cnt2++;
	}
	cout << min(cnt, cnt2) << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string str;
    cin >> str;

    bool frag = true;
    if(str[0] == 'A' && str[1] >= 'a' && str[1] <= 'z' && str.back() >= 'a' && str.back() <= 'z'){
        LL c = 0;
        for(int i = 2; i < str.size() - 1; i++){
            if(str[i] >= 'a' && str[i] <= 'z'){

            }else if(str[i] == 'C'){
                c++;
            }else{
                frag = false;
            }
        }
        if(c != 1){
            frag = false;
        }
    }else{
        frag = false;
    }

    if(frag){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
    
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    int n;
    cin >> n;

    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    ll s1=0, s2=0, c1=0, c2=0;
    for (int i = 0; i < n; i++) {
        s1 += a[i];
        s2 += a[i];

        if (i & 1) {
            if (s1 <= 0) c1 += 1 - s1, s1 = 1;
            if (s2 >= 0) c2 += 1 + s2, s2 = -1;
        }else{
            if (s1 >= 0) c1 += 1 + s1, s1 = -1;
            if (s2 <= 0) c2 += 1 - s2, s2 = 1;
        }
    }


    cout << min(c1, c2) << endl;


    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define SPEED ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sz size()
#define all(x) x.begin(),x.end()
#define OO 1e18
#define iOO INT_MAX
#define Mdp memset(dp,-1,sizeof dp)
#define R return
#define Test int TT;cin>>TT;for(int T=1;T<=TT;T++)
using namespace std;

ll Get(ll x)
{
    R x/100;
}

int main()
{

    SPEED;
    ll x,Cur = 100;
    cin >> x;
    ll Ans = 0;

    while(Cur < x)
    {
        Ans++;
        Cur += Get(Cur);
    }
    cout << Ans << endl;
    R 0;
}


Measured memory_bytes: 3652
const rl = require('readline').createInterface({
	input: process.stdin, output: process.stdout});
var stepnml = 0, stepa = 0, stepb = 0, n, m, l, a = [], b = [],
	decode = decodeNML;

process.stdin.setEncoding('ascii');
rl.on('line', function (line) {
	if (stepnml === 0) decodeNML(line);
	else if (stepa < n) decodeA(line);
	else if (stepb < m) decodeB(line);
	else rl.close();
});

function decodeNML(line) {
	var ary = line.split(' ').map(Number);
	n = ary[0];
	m = ary[1];
	l = ary[2];
	var i;
	for (i = n; i > 0; i--) a.push(new Int16Array(m));
	for (i = l; i > 0; i--) b.push(new Int16Array(m));
	stepnml++;
}

function decodeA(line) {
	var ary = line.split(' ').map(Number);
	for (var i in ary) a[stepa][i] = ary[i];
	stepa++;
}

function decodeB(line) {
	var ary = line.split(' ');
	for (var k in ary) b[k][stepb] = ary[k];
	stepb++;
}

rl.on('close', function() {
	for (var i in a) {
		var line = "";
		for (var j in b) {
			line = line + inner_product(a[i], b[j]) + " ";
		}
		console.log(line.trim());
	}
});

function inner_product(a, b) {
	var res = 0;
	for (var i = m - 1; i >= 0; i--) res += a[i] * b[i];
	return res;
}

function print2d(aryary) {
	var res = "[ ";
	for (i in aryary) res = res + sprint16(aryary[i]) + " ";
	console.log(res + "]");
}

function sprint16(ary) {
	var res = "[ ";
	for (var i = 0; i < ary.length; i++) res = res + ary[i].toString() + " ";
	return res + "]";
}

Measured memory_bytes: 19152