akhauriyash/Code-Regression huggingface dataset:
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln         PIC X(15).
01 A          PIC 9(10).
01 B          PIC 9(10).
01 C          PIC 9(10).
01 D          PIC 9(10).
01 TK         PIC 9(10).
01 AK         PIC 9(10).

PROCEDURE DIVISION.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO A B C D.
  COMPUTE TK = (C + B - 1) / B.
  COMPUTE AK = (A + D - 1) / D.
  IF TK <= AK
    DISPLAY "Yes"
  ELSE
    DISPLAY "No"
  END-IF.
  STOP RUN.


Measured memory_bytes: 3880
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 61;
ll C[N][N];

int main(){
    C[0][0] = 1;
    for(int i=1; i<N; ++i){
        C[i][0] = C[i][i] = 1;
        for(int j=1; j<i; ++j){
            C[i][j] = C[i-1][j-1] + C[i-1][j];
            // printf(" %d %d :: %lld\n",i,j,C[i][j]);
        }
    }

    ll n,m;
    while(cin >>n >>m,n){
        --m;
        int b = 0;
        ll now = 0;
        while(b<n){
            if(now + C[n][b] > m) break;

            now += C[n][b];
            ++b;
        }

        m -= now;

        int rem = n;
        string ans(n,' ');
        rep(i,n-1){
            // check set this bit to 1?
            bool ok = false;
            if(b>0 && m - C[rem-1][b] >= 0) ok = true;

            if(ok){
                ans[i] = '1';
                m -= C[rem-1][b];
                --b;
            }
            else{
                ans[i] = '0';
            }
            --rem;
        }
        assert(b<=1);
        ans[n-1] = '0'+b;
        cout << ans << "\n";
    }
    return 0;
}



Measured memory_bytes: 3020
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
int N, M, K, H, W, L, R;



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

	cin >> N;
	vector<int>v(N + 1);
	for (int i = 2; i <= N; i++) {
		int box = i;
		for (int j = 2; j <= box; j++) {
			while (box%j == 0) {
				v[j]++;
				box /= j;
			}
		}
	}
	int ans = 0;
	for (int i = 2; i <= N; i++) {
		if (v[i] >= 74)ans++;
		for (int j = i+1; j <= N; j++) {
			if (v[i] >= 24 && v[j] >= 2)ans++;
			if (v[i] >= 2 && v[j] >= 24)ans++;
			if (v[i] >= 14 && v[j] >= 4)ans++;
			if (v[i] >= 4 && v[j] >= 14)ans++;
			for (int k = j + 1; k <= N; k++) {
				if (v[i] >= 2 && v[j] >= 4 && v[k] >= 4)ans++;
				if (v[i] >= 4 && v[j] >= 2 && v[k] >= 4)ans++;
				if (v[i] >= 4 && v[j] >= 4 && v[k] >= 2)ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		sc.close();
		long p = N % K;
		// System.out.println("p = " + p);
		// System.out.println("abs = " + Math.abs(p - K));
		// System.out.println(1000000000000000000L - 1);
		// 1000000000000000000 999999999999999999
		System.out.println(N % K == 0 ? 0 : Math.min(Math.min(p, Math.abs(p - K)), N));
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n=0;
	int w=0;
	int s=0;
	int e=0;
	string ss;
	cin>>ss;
	for (char c:ss){
		if (c=='N') n=1;
		if (c=='W') w=1;
		if (c=='S') s=1;
		if (c=='E') e=1;
	}
	if ((n^s)==1||(e^w)==1){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
}

Measured memory_bytes: 764
#include <stdio.h>
int main(){
  char s[100000];
  scanf("%s",s);
  int count=0;
  int i=0;
  do{
    if(s[i]==s[i+1]){
      if(s[i]=='0')
        s[i+1]='1';
 	  else if(s[i]=='1')
        s[i+1]='0';
      
      count++;
    }
    	i++;
  	}while(s[i]!='\0');
  
   printf("%d\n",count);
   
   return 0;
 }

Measured memory_bytes: 256
#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 all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long mod(long long a, long long b) { return (a%b+b)%b; }
long long gcd(long long x, long long y) { return __gcd(x, y); }
long long lcm(long long x, long long y) { return x * 1ll * y / gcd(x, y); }
 
 
const long long MAXN = 1e9 + 9;
const long long SIZE = 2e6 + 6;
const long long MOD = 1e9 + 7;


int N, M, c[SIZE], p[SIZE], f[SIZE], res[SIZE], lazy[SIZE];
vector<pair<int, int>> qr[SIZE];

void push (int v) {
	lazy[v * 2] += lazy[v];
	lazy[v * 2 + 1] += lazy[v];
	lazy[v] = 0;
}

void update (int v, int l, int r, int tl, int tr, int val) {
	if (tl > r || tr < l) 
		return;

	if (l <= tl && tr <= r) {
		lazy[v] += val;
		return;
	}
	
	push (v);
	int tm = (tl + tr) >> 1;
	update (v * 2, l, r, tl, tm, val);
	update (v * 2 + 1, l, r, tm + 1, tr, val);
}



int calc (int v, int l, int r, int pos) {
	if (l == r)
		return lazy[v];
	
	push (v);

	int m = (l + r) >> 1;
	if (pos <= m)
		return calc (v * 2, l, m, pos);
	else 
		return calc (v * 2 + 1, m + 1, r, pos);
}



int main() { speedhack()

	cin >> N >> M;

	forn (i, N) {
		cin >> c[i];
		p[i] = f[c[i]];
		f[c[i]] = i;
	}

	forn (i, M) {
		int l, r;
		cin >> l >> r;
		qr[r].push_back({l, i});
	}

	forn (i, N) {
		update (1, p[i] + 1, i, 1, N, 1);

		for (auto q : qr[i]) 
			res[q.second] = calc (1, 1, N, q.first);
	}

	forn (i, M)
		cout << res[i] << endl;

	return 0;
}


Measured memory_bytes: 72516
program twofold
  implicit none 
  integer(8) :: n, i, ans
  integer(8), allocatable :: a(:)
  read *, n 
  allocate(a(n)) 
  read *, a 
  ans = 0
  do i = 1, n 
    do while (mod(a(i),2) == 0)
      a(i) = a(i) / 2 
      ans = ans + 1
    end do
  end do
  print '(i0)', ans
  stop
end program twofold

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
#include <set>
using namespace std;
typedef long long ll;

int main(void){
    ll n, q, d[200020];
    set<ll> s;
    vector<tuple<ll, ll, ll>> v;
    cin >> n >> q;
    for (int i = 0; i < n; i++) {
        ll ss, t, x;
        cin >> ss >> t >> x;
        v.emplace_back(x, x - t, x - ss);
    }
    for (int i = 0; i < q; i++) {
        cin >> d[i];
        s.insert(-d[i]);
    }
    
    sort(v.begin(), v.end());
    vector<pair<ll, ll>> ans;
    for (int i = 0; i < n; i++) {
        set<ll>::iterator it = s.lower_bound(get<1>(v[i]) + 1);
        while (it != s.end() && *it <= get<2>(v[i])) {
            ans.emplace_back(*it, get<0>(v[i]));
            it = s.erase(it);
        }
    }
    while (!s.empty()) {
        set<ll>::iterator it = s.begin();
        ans.emplace_back(*it, -1);
        it = s.erase(it);
    }
    
    sort(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); i++) cout << ans[ans.size() - 1 - i].second << endl;
}


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

bool dp[100001];
int cnt[100001];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    dp[1] = true;
    for(int i = 0; i < m; i++){
        int x, y; cin >> x >> y;
        dp[y] |= dp[x];
        cnt[x]--;
        cnt[y]++;
        if(cnt[x] == -1) dp[x] = false;
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(dp[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string s;

bool is_parindrome(string &dropped) {
  int l = 0;
  int r = dropped.size() - 1;

  while (l <= r) {
    if (dropped[l] != dropped[r]) {
      return false;
    }

    l += 1;
    r -= 1;
  }

  return true;
}

int main(void) {
  // Here your code !

  cin >> s;

  deque<int> dq;

  for (auto &e : s) {
    dq.push_back(e);
  }

  int ans = 0;

  while (!dq.empty()) {
    if (dq.front() == dq.back()) {
      dq.pop_front();

      if (!dq.empty()) {
        dq.pop_back();
      }

    } else if (dq.front() == 'x') {
      dq.push_back('x');
      ans += 1;
    } else if (dq.back() == 'x') {
      dq.push_front('x');
      ans += 1;
    } else {
      printf("%d\n", -1);
      return 0;
    }
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  if(a + b >= c)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3596
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    string S;
    cin>>S;
    long long int nowmod=0;
    long long int rui10mod=1;
    long long int modnum[2030]={0};
    modnum[0]++;
    for(int i=S.size()-1;0<=i;i--){
        nowmod=(nowmod+rui10mod*(S[i]-'0'))%2019;
        modnum[nowmod]++;
        rui10mod=(rui10mod*10)%2019;
    }
    long long int ans=0;
    for(int i=0;i<2030;i++){
        ans+=modnum[i]*(modnum[i]-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3720
#include <iostream>
#include <string>

int main(){
    std::string n;
    std::cin >> n;

    if(std::string::npos == n.find('9')){
        std::cout << "No" << std::endl;
    }else{
        std::cout << "Yes" << std::endl;
    }

    return 0;
}


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

typedef long long   ll;
typedef long double ld;

using namespace std;
const ld pi=2*acos(0.0);
ll mod = 998244353;

int main() {
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
 // ios::sync_with_stdio(0);
 // cin.tie(0);
    int n,k;
     cin >> n>>k;
    cout << ( n +1<k+k? "NO" : "YES");
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define foreach(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define len(a) ((int) (a).size())

#ifdef CUTEBMAING
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

using namespace std;

typedef long long int64;
typedef long double ld;
typedef unsigned long long lint;

const int inf = (1 << 30) - 1;
const int64 linf = (1ll << 62) - 1;
const int N = 400;
const int M = 1e9 + 7;

inline int power(int a, int b) {
    int res = 1;
    for (; b; b >>= 1) {
        if (b & 1) {
            res = (1ll * res * a) % M;
        }
        a = (1ll * a * a) % M;
    }
    return res;
}

int n, m;
int wdp[N][N];
int dp[N][N];
int pw[N][N];

int fact[N], ifact[N];

inline int cnk(int n, int k) {
    return (((1ll * fact[n] * ifact[k]) % M) * ifact[n - k]) % M;
}

int main() {
#ifdef XCODE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> m;
    fact[0] = 1;
    ifact[0] = 1;
    for (int i = 1; i <= m; i++) {
        fact[i] = (1ll * fact[i - 1] * i) % M;
        ifact[i] = power(fact[i], M - 2);
    }
    for (int i = 0; i <= m; i++) {
        for (int j = 0; j <= m; j++) {
            pw[j][i] = i == 0 ? 1 : (1ll * pw[j][i - 1] * j) % M;
        }
    }
    for (int i = 0; i <= m; i++) {
        for (int j = 0; j <= i; j++) {
            wdp[i][j] = pw[j][i];
            for (int z = 1; z < j; z++) {
                wdp[i][j] = (wdp[i][j] - 1ll * cnk(j, z) * wdp[i][j - z]) % M;
                if (wdp[i][j] < 0) {
                    wdp[i][j] += M;
                }
            }
        }
    }
    dp[0][1] = 1;
    for (int i = 0; i < m; i++) {
        for (int j = 1; j <= n; j++) {
            if (!dp[i][j]) {
                continue;
            }
            for (int l = 0; j + l <= n; l++) {
                int cur2 = cnk(n - j, l);
                for (int z = l; z <= m - i - 1; z++) {
                    int cur = (((1ll * j * wdp[z][l]) % M) * cur2) % M;
                    dp[i + z + 1][j + l] = (dp[i + z + 1][j + l] + 1ll * cur * dp[i][j]) % M;
                }
            }
        }
    }
    cout << dp[m][n] << endl;
    return 0;
}


Measured memory_bytes: 1664
#include <cstdio>
#include <vector>
#include <algorithm>

using int64 = long long;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  std::vector<int64> dp(m + 1);
  for (int i = 0; i < n; ++i) {
    int w, v;
    scanf("%d%d", &w, &v);
    for (int j = m; j >= w; --j) {
      dp[j] = std::max(dp[j], dp[j - w] + v);
    }
  }
  printf("%lld\n", *std::max_element(dp.begin(), dp.end()));
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second

int main() {

   int r;
   cin>>r;
   
   if(r<1200)
      cout<<"ABC";
      
    else  if(r>=1200&&r<2800)
        cout<<"ARC";
        
   else
        cout<<"AGC";
   
   
	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
l = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    l[a-1].append(b-1)
    l[b-1].append(a-1)
def dfs(i,done):
    ret = 0
    if i in done:
        return 0
    if len(done)==n-1:
        return 1
    for j in range(len(l[i])):
        ret += dfs(l[i][j],done+[i])
    return ret
print(dfs(0,[]))

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


int N,M;

int main(){
	cin >> N;
	int T[N+1];
	for(int i=0;i<N;i++){
		cin >> T[i];
	}
	cin >> M;
	int P[M+1],X[M+1];
	for(int i=0;i<M;i++){
		cin >> P[i] >> X[i];
	}
	for(int i=0;i<M;i++){
		int ans=0;
		for(int j=0;j<N;j++){
			if(j == P[i]-1)ans+=X[i];
			else ans+=T[j];
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
from copy import copy

N,M = map(int,input().split())
A = list(map(int,input().split()))

ms = [2,5,5,4,5,6,3,7,6]
dic = defaultdict(lambda: 0)
for a in A:
    dic[ms[a-1]] = max(dic[ms[a-1]], a)

sd = sorted(dic.items())

dp = [None] * (N+1)
dp[0] = defaultdict(lambda: 0)

for i in range(sd[0][0], N+1):
    cands = []
    least_len = -1
    for l,a in sd:
        if i-l < 0: break
        if dp[i-l] is None: continue
        if cands and sum(dp[i-l].values())+1 < least_len:
            continue
        cands.append(copy(dp[i-l]))
        cands[-1][a] += 1
        least_len = sum(cands[-1].values())
    if not cands: continue
    max_v = 0
    max_j = -1
    for j,cand_dic in enumerate(cands):
        tmp_s = ''
        for a,n in sorted(cand_dic.items(), reverse=True):
            tmp_s += str(a) * n
        tmp_v = int(tmp_s)
        if tmp_v > max_v:
            max_v = tmp_v
            max_j = j
    dp[i] = cands[max_j]

ans = ''
for a,n in sorted(dp[-1].items(), reverse=True):
    ans += str(a) * n
print(ans)

Measured memory_bytes: 7068
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define SG string
#define DB double
#define LL long long
using namespace std;
inline LL Read(){
	LL X=0;char CH=getchar();bool F=0;
	while(CH>'9'||CH<'0'){if(CH=='-')F=1;CH=getchar();}
	while(CH>='0'&&CH<='9'){X=(X<<1)+(X<<3)+CH-'0';CH=getchar();}
	return F?-X:X;
}
inline void Write(LL X){
	if(X<0)X=-X,putchar('-');
	if(X>9)Write(X/10);
	putchar(X%10+48);
}
int main(){
	LL I,J,K;
	LL N=Read();
	for(I=0;I<=N/4;I++){
		for(J=0;J<=N/7;J++){
			if(I*4+J*7==N){
				puts("Yes");
				return 0;
			}
		}
	}puts("No");
	if(N)
	return 0;
}

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

int main(){
    string s;
    cin >> s;

    int len = s.length();
    rep(i, len){
        s.at(i) = 'x';
    }
    
    cout << s << endl;
    return 0;
}

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

class UnionFind {
	public:
		vector<ll> table, num;

		UnionFind(){}
		UnionFind(int size){
			table.resize(size, -1);
			num.resize(size, 1);
		}

		int find(int x){
			if (table[x] < 0) return x;
			else {
				table[x] = find(table[x]);
				return table[x];
			}
		}

		bool is_root(int x){
			if (table[x] < 0) return true;
			else return false;
		}

		ll get_size(int x){
			return num[find(x)];
		}

		void unite(int x, int y){
			int r1 = find(x);
			int r2 = find(y);
			if (r1 != r2) {
				if (table[r1] > table[r2]){
					table[r2] = r1;
					table[r1]--;
					num[r1] += num[r2];
					num[r2]--;
				} else {
					table[r1] = r2;
					table[r2]--;
					num[r2] += num[r1];
					num[r1]--;
				}
			}
			return;
		}
};

int main() {
	int n, m, k; cin >> n >> m >> k;
	UnionFind uf(n);

	vector<vector<ll> > fr(n);
	vector<vector<ll> > bl(n);

	for (int i = 0; i < m; ++i)
	{
		int a, b; cin >> a >> b;
		fr[a-1].push_back(b-1);
		fr[b-1].push_back(a-1);
		uf.unite(a-1, b-1);
	}

	for (int i = 0; i < k; ++i)
	{
		int a, b; cin >> a >> b;
		bl[a-1].push_back(b-1);
		bl[b-1].push_back(a-1);
	}

	vector<int> ans(n);
	for (int i = 0; i < n; ++i)
	{
		int res = uf.get_size(i) - 1 - fr[i].size();
		for (auto v : bl[i]) {
			if (uf.find(i) == uf.find(v)) res--;
		}
		ans[i] = res;
	}

	for (int i = 0; i < n-1; ++i)
	{
		cout << ans[i] << " ";
	}
	cout << ans[n-1] << endl;

	return 0;
}

Measured memory_bytes: 16628
X=int(input())

A = X//1000
X%=1000
B= X//100
X%=100
C = X//10
X%=10
D = X
a=str(A)
b=str(B)
c=str(C)
d=str(D)

if A+B+C+D == 7:
    print(a+"+"+b+"+"+c+"+"+d+"=7")
elif A+B+C-D == 7:
    print(a+"+"+b+"+"+c+"-"+d+"=7")
elif A+B-C+D == 7:
    print(a+"+"+b+"-"+c+"+"+d+"=7")
elif A+B-C-D == 7:
    print(a+"+"+b+"-"+c+"-"+d+"=7")
elif A-B+C+D == 7:
    print(a+"-"+b+"+"+c+"+"+d+"=7")
elif A-B+C-D == 7:
    print(a+"-"+b+"+"+c+"-"+d+"=7")
elif A-B-C+D == 7:
    print(a+"-"+b+"-"+c+"+"+d+"=7")
elif A-B-C-D == 7:
    print(a+"-"+b+"-"+c+"-"+d+"=7")

Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <string>
#include<math.h>
#include<bits/stdc++.h>
#include <map>
#include <algorithm>
#include <cmath>



using namespace std;
const int INF = 1e9+7;
int solve(int arr[][3],int n){
    int dp[n+1][3];
    memset(dp,0,sizeof(dp));
    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];

    for(int i=1;i<=n;i++){
        dp[i][0] = arr[i][0] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = arr[i][1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = arr[i][2] + max(dp[i-1][0],dp[i-1][1]);
    }
    return max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

int main(){
    int n;
    cin>>n;
    int arr[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>arr[i][j];
        }
    }
    cout<<solve(arr,n)<<endl;
}


Measured memory_bytes: 5960
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <memory.h>
#include <queue>
#include <string.h>
#include <set>
using namespace std;

#define N 200005

int A[N];
long long cc[N];
int jump[N];

bool comp(long long &add,int ind) {
  long long mini = min(cc[ind-1],cc[ind]);
  long long a = cc[ind-1]- mini,
  b = cc[ind] - mini;
  if(a==0) {
    long long tmp = 0;
    if(b>=32) {
      return true;
    }
    long long x= A[ind-1],y = A[ind];
    assert(b%2==0);
    while(b>0) {
      y*= 4;
      b-=2;
    }
    if(x<=y) {
      return true;
    }
    while(x>y) {
      tmp +=2;
      y *= 4;
    }
    add += tmp;
    return false;
  } else {
    long long tmp = 0;
    if(a>=32) {
      a = 32;
      add += a-32;
    }
    long long x = A[ind-1],y = A[ind];
    assert(a%2==0);
    while(a>0) {
      x *=4;
      a -=2;
    }
    if(x<=y) {
      return true;
    }
    while(x>y) {
      tmp += 2;
      y *=4;
    }
    add += tmp;
    return false;
  }
}
void calculate(long long *save,int n) {
  memset(cc,0,sizeof(cc));
  long long ret = 0;
  for(int i=n;i>=1;--i) {
    jump[i] = i+1;
    int go = jump[i];
    while(go<=n) {
      long long tmp = 0;
      if(!comp(tmp,go)) {
        int nextGo = jump[go];
        cc[nextGo-1] += tmp;
        int numJump = nextGo-go;
        ret += (long long)numJump*tmp;
        go = nextGo;
      } else {
        break;
      }
    }
    jump[i] = go;
    save[i] = ret;
  }
}
long long tmp[N],tmp2[N];
void solve() {
  int n;scanf("%d ", &n);
  for(int i=1;i<=n;++i) {
    scanf("%d ", &A[i]);
  }
  calculate(tmp,n);
  reverse(A+1,A+n+1);
  calculate(tmp2,n);
  reverse(tmp2+1,tmp2+n+1);
  long long mini = 1e18;
  for(int i=1;i<=n+1;++i) {
    long long R = i-1;
    R += tmp2[i-1] + tmp[i];
    mini = min(mini,R);
  }
  printf("%lld\n", mini);
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


Measured memory_bytes: 6528
package main

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

type Path struct {
	To  int
	Len int
}

var (
	paths   map[int][]Path
	sc      = bufio.NewScanner(os.Stdin)
	ans     []int
	visited []bool
)

func init() {
	sc.Split(bufio.ScanWords)
	paths = map[int][]Path{}
	ans = make([]int, 101010)
	visited = make([]bool, 101010)
}

func input() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func calcNextCol(nxtLen, col int) int {
	if nxtLen == 0 {
		return col
	}
	return (col + 1) % 2
}

func dfs(node int, col int) {

	if visited[node] {
		return
	}
	visited[node] = true
	ans[node] = col

	for i := 0; i < len(paths[node]); i++ {
		nxtPath := paths[node][i]

		nxtCol := calcNextCol(nxtPath.Len, col)
		dfs(nxtPath.To, nxtCol)
	}
}

func main() {
	var n int
	fmt.Scan(&n)

	for i := 0; i < n-1; i++ {
		var f, t, l int
		f = input() - 1
		t = input() - 1
		l = input() % 2

		paths[f] = append(paths[f], Path{
			To:  t,
			Len: l,
		})

		paths[t] = append(paths[t], Path{
			To:  f,
			Len: l,
		})
	}

	//start dfs
	dfs(0, 0)

	for _, v := range ans[:n] {
		fmt.Println(v)
	}
}

Measured memory_bytes: 22816
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll k;
    cin>>k;
    ll arr[n];
    for(ll i=0;i<n;i++)
    {
    	cin>>arr[i];
    }
    sort(arr,arr+n);
    ll sum=0;
    for(ll i=0;i<k;i++)
    {
    	sum=sum+arr[i];
    }
    cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3652
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long a=0;
		long b=0;
		for(int i=-150;i<=150;i++){
			long a1 = x+(long)Math.pow(i,5);
			for(int j=-150;j<=150;j++){
				long h = (long)Math.pow(j,5);
				if(a1==h){
					a=j;
					b=i;
					break;
				}
			}
		}
		System.out.println(a+" "+b);
	}
	 static long floorRoot5(long n) 
    { 
          
        // Base cases 
        if (n == 0 || n == 1) 
        return n; 
        // Do Binary Search for  
        // floor of 5th square root 
        long low = 1, high = n, ans = 0; 
        while (low <= high) 
        { 
            // Find the middle point 
            // and its power 5 
            long mid = (low + high) / 2; 
            long mid5 = mid * mid * mid *  
                            mid * mid; 
            // If mid is the required root 
            if (mid5 == n) 
                return mid;       
            // Since we need floor,  
            // we update answer when 
            // mid5 is smaller than n,  
            // and move closer to 
            // 5'th root 
            if (mid5 < n) 
            { 
                low = mid + 1; 
                ans = mid; 
            } 
            // If mid^5 is greater 
            // than n 
            else
                high = mid - 1; 
        } 
        return ans; 
    } 
}

Measured memory_bytes: 38876
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

string s[3];

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	for(int i = 0; i < 3; i++) cin >> s[i];
	for(int i = 0; i < 3; i++) cout << (char)toupper(s[i][0]);
	cout << "\n";
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(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 inf 1e9
using ll = int64_t;
#define waru 1000000007

void Main() {
  ll n;
  std::cin >> n;
  std::set<ll> a;
  rep(i, n) {
    ll tmp;
    std::cin >> tmp;

    if (a.find(tmp) == a.end()) {
      a.insert(tmp);
    } else {
      a.erase(tmp);
    }
  }

  std::cout << sz(a) << '\n';

  return;
}

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


Measured memory_bytes: 4992
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;


namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {


            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       
       
        public static long gcd(long x,long y)
        {
            if (x < y) gcd(y, x);
            
            while (y > 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }

        public static long lcm(long x,long y)
        {
            return x * y / gcd(x, y);
        }



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var ab = Reads();
            var a = ab[0];
            var b = ab[1];
            Console.WriteLine(lcm(a, b));
          
            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 19020
import java.util.Scanner;


public class Main {
	
	static int[][] memory;
	
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
   
        int count = 0;
        int[] member = new int[5];
        
        for(int i = 0;i<N;i++){
        	
        	String line = sc.next();
        	
        	if('M'==line.charAt(0)){
        		member[0]++;
        		
        	}else if('A'==line.charAt(0)){
        		member[1]++;
        	}else if('R'==line.charAt(0)){
        		member[2]++;
        	}else if('C'==line.charAt(0)){
        		member[3]++;
        	}else if('H'==line.charAt(0)){
        		member[4]++;
        	}
        	
        	
        	
        }
        
        long ans = result(member,0,0);
        
        System.out.println(ans);
		
	}

	private static long result(int[] member,int count,int choise) {
		
		long ans=1;
		
		if(choise==4)
			if(count==2)	return member[choise];
			else if(count==3)	return 1;
			else return 0;
		
		if(count<3&&member[choise]>0){
			ans = (result(member,count,choise+1)+result(member,count+1,choise+1)*member[choise]);
		}else{
			ans = result(member,count,choise+1);
		}
		
		return ans;
		
	}
		

    
}

Measured memory_bytes: 44560
teisu :: Int
teisu = 1000000007

toInt :: (String -> Int)
toInt x = read x ::Int

getInts :: IO [Int]
getInts = do
    x <- getLine
    let y = (map$toInt)$words x
    return y

plus :: Int -> Int -> Int
plus a b = mod (a + b) teisu

times :: (Int, Int) -> Int
times x = mod (fst x * snd x) teisu

main :: IO ()
main = do
    n <- getInts
    xa <- getInts
    let tempSum = scanr plus 0 (tail xa)
    let pairs = zip xa tempSum
    let tempTimes = map times pairs
    let r = foldr plus 0 tempTimes
    (putStrLn . show) r


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

using namespace std;

using ll = long long;
using ld = long double;

bool Solve() {
    string s;
    cin >> s;

    int num = 0;
    for (auto c : s)
        if (c == 'x') ++num;

    return num <= 7;
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    cout << (Solve() ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define forn(i,a,n) for(int i =a;i < n; i++)
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
typedef long long int lli;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define MAXN 3005
int a[MAXN];
lli dp[MAXN][MAXN][2];
int used[MAXN][MAXN][2];

lli solve(int l, int r, int id){
	if( l > r ){
		return 0;
	}

	if(used[l][r][id]) return dp[l][r][id];
	used[l][r][id] = 1;
	lli ans = -1;
	if(id == 0){//maximizar
		ans = max(solve(l+1,r,!id) + a[l], solve(l,r-1,!id) + a[r]);
	}
	else{//minimizar
		ans = min(solve(l+1,r,!id) - a[l], solve(l,r-1,!id) - a[r]);
	}

	return dp[l][r][id] = ans;
}


int main(){__
	int n;
	cin >> n;
	forn(i,1,n+1) cin >> a[i];
	cout << solve(1,n,0) << endl;
}


Measured memory_bytes: 211456
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var a = o.a();
  var b = o.a();
  return 0+Math.max(a+b,a-b,a*b);
}


Measured memory_bytes: 22076
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
const int maxn = 1e6+10;
const int inf = 1e7;
int a[55];
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		memset(a,0,sizeof(a));
		int MAX = -inf, MIN = inf;
		int idx , idn;
		for(int i = 1 ; i <= n ; i++)
		{
			scanf("%d",&a[i]);
			if(a[i] > MAX)
			{
				MAX = a[i];
				idx = i;
			}
			if(a[i] < MIN)
			{
				MIN = a[i];
				idn = i;
			}
		}
		if(MIN>=0)
		{
			printf("%d\n",n-1);
			for(int i = 1 ; i <n ;i++)
			{
				printf("%d %d\n",i,i+1);
			}
		}
		else if(MAX <= 0)
		{
			printf("%d\n",n-1);
			for(int i = n ; i>1 ; i--)
			{
				printf("%d %d\n",i,i-1);
			}
		}
		else if(abs(MAX)>=abs(MIN))
		{
			printf("%d\n",2*n-1);
			for(int i = 1 ; i <= n ; i++)
			{
				printf("%d %d\n",idx , i);
			}
			for(int i = 1 ; i < n ; i++)
			{
				printf("%d %d\n",i,i+1);
			}
		}
		else
		{
			printf("%d\n",2*n-1);
			for(int i = 1 ; i <= n ; i++)
			{
				printf("%d %d\n",idn,i);
			}
			for(int i = n ; i >1;i--)
			{
				printf("%d %d\n",i,i-1);
			}
		}
	}
}

Measured memory_bytes: 128
package main
import (
    "fmt"
    )

func main() {
    var A, B int
    fmt.Scan(&A, &B)
    var ok bool
    var res int = -1
    for i:=13; i <= 1250; i++ {
        if int(float64(i)*0.08) == A && int(float64(i)*0.1) == B {
            res = i
            ok = true
            break
        }
    }
    if ok {
        fmt.Println(res)
    } else {
        fmt.Println(res)
    }
    
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, m;
vector<int> et[100000];
bool used[100000];
queue<int> que;

signed main() {
	int i;
	
	cin >> n >> m;
	rep(i, m) {
		int x, y, z;
		cin >> x >> y >> z;
		x--; y--;
		et[x].push_back(y);
		et[y].push_back(x);
	}
	
	int ans = 0;
	rep(i, n) {
		if (used[i]) continue;
		used[i] = true;
		que.push(i);
		while (!que.empty()) {
			int v = que.front(); que.pop();
			int j;
			rep(j, et[v].size()) {
				int nv = et[v][j];
				if (!used[nv]) {
					used[nv] = true;
					que.push(nv);
				}
			}
		}
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6648
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long ll;
int main()
{
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vector<int> p(a);
	vector<int> q(b);
	vector<int> r(c);
	rep(i,a) cin>>p[i];
	rep(i,b) cin>>q[i];
	rep(i,c) cin>>r[i];
	sort(p.begin(),p.end(),greater<int>());
	sort(q.begin(),q.end(),greater<int>());
	for(int i = 0; i < x; i++){
		r.push_back(p[i]);
	}
	for(int i = 0; i < y; i++){
		r.push_back(q[i]);
	}
	sort(r.begin(),r.end(),greater<int>());
	ll ans = 0;
	for(int i = 0; i < (x+y); i++){
		ans += r[i];
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 5168
#include <iostream>

using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int MAXN = 1e5+10;

string s;
ll dp[MAXN][13];

void solve() {
  dp[0][0] = 1;
  int base = 1;
  for (int i=0;i<s.size();i++) {
    int index = s.size() - 1 - i;
    if (s[index] == '?') {
      for (int j=0;j<10;j++) {
        int d = (j * base) % 13;
        for (int k=0;k<13;k++) {
          dp[i+1][(k+d) % 13] = (dp[i+1][(k+d) % 13] + dp[i][k]) % MOD;
        }
      }
    } else {
      int d = ((s[index] - '0') * base) % 13;
      for (int j=0;j<13;j++) {
        dp[i+1][(j+d) % 13] = (dp[i+1][(j+d) % 13] + dp[i][j]) % MOD;
      }
    }
    base = (base * 10) % 13;
  }
  cout << dp[s.size()][5] << endl;
}

int main() {
  cin >> s;
  solve();
}


Measured memory_bytes: 10624
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#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__) << "] "
typedef long long ll;

int main(){
	long long n ; 
	cin >> n ; 
	long long neg = 0 ; 
	vector<long long> v(n) ; 
	long long nax = 1e9 ; 
	long long sum = 0 ; 
	for(long long &x : v){
		cin >> x ; 
		sum+= abs(x) ; 
		if ( x < 0 ) neg++ ; 
		nax = min(nax,abs(x));
	}
	if ( neg & 1 ){
		cout << sum - 2LL*nax << endl;
	}
	else cout << sum << endl;
    return 0 ;
}


Measured memory_bytes: 1024
def main():
    N, X = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    before_a, cnt = 0, 0
    for a in A:
        c = max([before_a + a - X, 0])
        before_a = a - c
        cnt += c
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14540
def main():
  n = int(input())
  li = list(map(int,input().split()))
  li.sort()
  ans = 1
  for i in range(n):
    ans *= li[i]
    if ans > (10 ** 18):
      print(-1)
      exit()
  print(ans)


if __name__ == '__main__':
  main()

Measured memory_bytes: 21660
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;

struct Node {
	int parent;
	vector<int> children;
	int num;
};
vector<Node> tree;

vector<int> divisor(int n)
{
	vector<int> ret;
	for (int i = 0; i * i <= n; ++i) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n)	ret.push_back(n / i);
		}
	}
	return ret;
}
void prime_factorize(int n, map<int, int> &prime)
{
	if (n <= 1)	return;
	int last = sqrt(n);
	for (int i = 2; i <= last; i++) {
		if (n % i == 0) {
			prime_factorize(i, prime);
			prime_factorize(n / i, prime);
			return;
		}
	}
	prime[n]++;
	return;
}
void addNumberToChildren(int p, int num) {
	if (tree[p].children.size() == 0)	return;
	for (int a : tree[p].children) {
		tree[a].num += num;
		addNumberToChildren(a, num);
	}
	return;
}

vector<int> to[200005];
vector<int> ans;
void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p)	continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}

int main()
{
	int n, q;
	cin >> n >> q;
	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	ans.resize(n);
	rep(i, q) {
		int p, x;
		cin >> p >> x;
		p--;
		ans[p] += x;
	}
	dfs(0);
	rep(i, n) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 24308
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;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 all(x) (x).begin(),(x).end()
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2){
        cout<<"Borys"<<endl;
    }else{
        cout<<"Alice"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		LinkedList<Integer> list = new LinkedList<Integer>();

		for (int i=0; i<n; i++) {
			String str = br.readLine();

			if (str.startsWith("insert")) {
				list.addFirst(Integer.parseInt(str.substring(str.indexOf(" ")+1)));
			}else if (str.equals("deleteFirst")) {
				list.pollFirst();
			}else if (str.equals("deleteLast")){
				list.pollLast();
			}else {
				list.remove((Integer)Integer.parseInt(str.substring(str.indexOf(" ")+1)));
			}
		}

		while (list.size() != 1) {
			System.out.print(list.pollFirst()+" ");
		}
		System.out.println(list.poll());

		br.close();
	}
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int a,b; cin >> a >> b;
    out(max(0,a - 2*b));
}


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

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

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 long long INFLL = 1LL << 60;
const int INF = 1 << 30;

typedef long long ll;
typedef unsigned long long ull;

int N;
int H[100001][3];
int memo[100001][3];

// n日目に活動aを選んだときの幸福度の最大値
// 0 <= n <= N-1
// a in {0, 1, 2}
int solve(int n, int a) {
  if (n < 0) return 0;
  if (memo[n][a] != -1) return memo[n][a];

  int res = 0;
  rep(i, 3) {
    if (i == a) continue;
    chmax(res, solve(n-1, i) + H[n][a]);
  }

  return memo[n][a] = res;
}

int main(void) {
  cin >> N;
  rep(i, N) cin >> H[i][0] >> H[i][1] >> H[i][2];
  memset(memo, -1, sizeof(memo));

  int res = 0;
  rep(i, 3) chmax(res, solve(N-1, i));
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 10368
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<unordered_set>
#include<cmath>
#include<tuple>
#include<numeric>
#include<iterator>
#include<set>
#include<unordered_map>
#include<map>
#include<queue>
#include<cstring>
#include<stdio.h>
#include<fstream>


#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define foru(i , a , b) for(ll i = a ; i < b ; i++)
#define ford(i , a , b) for(ll i = a ; i >= b ; i--)
#define dbg(a) cerr << #a << ": " << a << "\n";
#define ain(a , n) for(ll i = 0 ; i < n ; i++) cin >> a[i]
#define aout(a , n) for(ll i = 0 ; i < n ; i++) cout << a[i] << " "
#define M 1000000007
#define mp make_pair
#define mt make_tuple
#define cend cout << "\n"
#define all(x) x.begin() , x.end()
#define aout2(a , n , m) for(ll i = 0 ; i < n ; i++){for(ll j = 0 ; j < m ; j++){cout << a[i][j] << " ";} cout << endl;}
#define ain2(a , n , m) for(ll i = 0 ; i < n ; i++){for(ll j = 0 ; j < m ; j++){cin >> a[i][j];}}
#define ff first
#define ss second

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <char> vch;
typedef vector <string> vs;

/*----------------------------- # --- MATH ALGORITHMS --- # -----------------------------*/

template <class T> T gcd(T a , T b){ while(a != 0){T temp = a; a = b % a; b = temp;}return b;}
template <class T> T egcd(T a , T b , T &x , T &y){T gcd , xt , yt;if(a == 0){gcd = b;x = 0 , y = 1;}else {gcd = egcd(b % a , a , xt , yt);x = yt - (b/a)*xt; y = xt;}return gcd;}
template <class T> T expo(T base , T exp , T mod){T res = 1;base = base % mod;while (exp > 0){if (exp & 1)res = (res*base) % mod;exp = exp>>1;base = (base*base) % mod;}return res;}
template <class T> T modinv(T a , T mod){T x , y; egcd<T>(a , mod , x , y);while(x < 0) x += mod; while(x >= mod) x -= mod; return x;}
template <class T> T modinvfermat(T a , T mod){return expo<T>(a , mod - 2 , mod);}
template <class T> bool rev(T a , T b){return a > b;}
template <class T> ll maxpower(T a , T b){ll ans = 0;while(a > 0 && a % b == 0){ans++;a /= b;}return ans;}


/*----------------------------- # --- MAIN CODE --- # -----------------------------*/

int main(){
    fastio;
#ifndef ONLINE_JUDGE
    freopen("testcase.txt" , "r" , stdin);
    freopen("error.txt" , "w" , stderr);
    freopen("output.txt" , "w" , stdout);
#endif
//    double r;cin>>r;
//    cout << 2* 3.14159265*r;
    ll n; cin >> n; ll a[n];
    ll cnt[n]; memset(cnt , 0 , sizeof(cnt));
    foru(i , 0 , n - 1){
        cin >> a[i]; a[i]--; cnt[a[i]]++;
    }
    foru(i , 0 , n) cout << cnt[i] << endl;
}
























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

int main(){
  int a,b;
  cin>>a>>b;
  int cnt =0;
  string s;

  for (int i=a;i<=b;i++){
    s = to_string(i);
    if (s[0]==s[4] && s[1]==s[3])cnt++;
  }

  cout <<cnt <<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1000010;
const ll mod=1e9+7;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  vector<int> pos;
  for(int l=0,r=n-1; l<r; ){
    if(s[l]==s[r]){
      l++;
      r--;
      continue;
    }
    if(s[l]=='x'){
      pos.emplace_back(r+1);
      l++;
      continue;
    }
    if(s[r]=='x'){
      pos.emplace_back(l);
      r--;
      continue;
    }
    cout << -1 << endl; return 0;
  }
  cout << pos.size() << endl;
  return 0;
}

Measured memory_bytes: 1020
s = input()
ans = 1000
for c in 'abcdefghijklmnopqrstuvwxyz':
    t = s
    if c not in t:
        continue
    tmp = 0
    while len(set(t)) > 1:
        res = ''
        for i in range(len(t)-1):
            if t[i] == c or t[i+1] == c:
                res += c
            else:
                res += '0'
        t = res
        tmp += 1
    ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 3064