akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <utility>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<string, string> P;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    map<P, int> mp;
    for(int i = 0; i < (1 << n); i++){
        string r = "";
        string b = "";
        for(int j = 0; j < n; j++){
            if(i & (1 << j)) r += s[n * 2 - 1 - j];
            else b += s[n * 2 - 1 - j];
        }
        mp[P(r, b)]++;
    }
    ll ans = 0;
    for(int i = 0; i < (1 << n); i++){
        string r = "";
        string b = "";
        for(int j = 0; j < n; j++){
            if(i & (1 << j)) r += s[j];
            else b += s[j];
        }
        ans += mp[P(r, b)];
    }
    cout << ans << endl;
}

Measured memory_bytes: 91904
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mpp = boost::multiprecision;
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
    mpp::cpp_dec_float_100 A;
    mpp::cpp_dec_float_100 B;
    cin>>A>>B;
    mpp::cpp_dec_float_100 result = A*B;
    cout<<ll(result)<<endl;
}



Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    std::vector<int> list(3);
    std::cin >> list[0] >> list[1] >> list[2];

    std::sort(list.begin(), list.end());

    std::cout << list[0] << " " << list[1] << " " << list[2] << std::endl;

    return 0;
}


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

int main() {
  int A;
  int B;
  cin >> A >> B;
  int ans;
  for (int i = 1; i <= 3; ++i) {
    if (A != i && B != i) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

string s, t;
int a, b, c, k;
int main(){
  cin >> a >> b >> c >> k;
  if(k <= a) cout << k << endl;
  else if(a+b >= k) cout << a <<endl;
  else cout << 2*a+b-k<<endl;
}

Measured memory_bytes: 3636
N, M = map(int, input().split())

dp = [[0 for i in range(N)] for j in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    dp[a-1][b-1] += 1
    dp[b-1][a-1] += 1
    
for i in range(N):
    print(sum(dp[i]))


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

const int MAXD = 160 * 80 + 1;

int dp[85][85][MAXD]; //! [h][w][diff] => reachable
int A[85][85];
int B[85][85];
int D[85][85];

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

    int H, W;
    cin >> H >> W;
    for (int y = 1; y <= H; ++y) {
        for (int x = 1; x <= W; ++x) {
            cin >> A[y][x];
        }
    }
    for (int y = 1; y <= H; ++y) {
        for (int x = 1; x <= W; ++x) {
            cin >> B[y][x];
        }
    }
    for (int y = 1; y <= H; ++y) {
        for (int x = 1; x <= W; ++x) {
            D[y][x] = abs(A[y][x]-B[y][x]);
        }
    }

    dp[1][1][D[1][1]] = true;

    for (int y = 1; y <= H; ++y) {
        for (int x = 1; x <= W; ++x) {
            if (y == 1 && x == 1) continue;
            int d = D[y][x];
            // cout << y << ' ' << x << ' ' << d << endl;
            for (int z = 0; z < MAXD; ++z) {
                if (dp[y-1][x][z]) {
                    // cout << "   down from " << (y-1) << ' ' << x << ' ' << z << endl;
                    if (d<z) {
                        dp[y][x][z-d] = true;
                    } else {
                        dp[y][x][d-z] = true;
                    }
                    if (d+z<MAXD) {
                        dp[y][x][d+z] = true;
                    }
                }
            }
            for (int z = 0; z < MAXD; ++z) {
                if (dp[y][x-1][z]) {
                    // cout << "    right from " << y << ' ' << (x-1) << ' ' << z << endl;
                    if (d<z) {
                        dp[y][x][z-d] = true;
                    } else {
                        dp[y][x][d-z] = true;
                    }
                    if (d+z<MAXD) {
                        dp[y][x][d+z] = true;
                    }
                }
            }
        }
    }

    // for (int y = 1; y <= H; ++y) {
    //     for (int x = 1; x <= W; ++x) {
    //         cout << "[";
    //         for (int z = 0; z < MAXD; ++z) {
    //             if (dp[y][x][z]) {
    //                 cout << z << ",";
    //             }
    //         }
    //         cout << "] ";
    //     }
    //     cout << endl;
    // }

    int ans = -1;
    for (int z = 0; ans < 0 && z < MAXD; ++z) {
        if (dp[H][W][z]) {
            ans = z;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 342400
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }
#define dump(...) cout<<#__VA_ARGS__<<": [L_"<<__LINE__<<"]"<<'\n'; print(__VA_ARGS__);cout<<'\n';

template<class T, class U>inline bool chmax(T &a, const U &b) { if(a<b){ a=b; return 1; } return 0; }
template<class T, class U>inline bool chmin(T &a, const U &b) { if(b<a){ a=b; return 1; } return 0; }


int main() {
  string s; cin>>s;
  deque<char> q;

  rep(i, s.size()) {
    q.push_back(s[i]);
  }

  int Q; cin>>Q;
  bool rev = false;
  rep(i, Q) {
    int T; cin>>T;
    if (T == 1) {
      rev = !rev;
    }
    if (T == 2) {
      int f; cin>>f;
      string c; cin>>c;
      if ((f == 1 and rev == false) or (f == 2 and rev == true)) {
        q.push_front(c[0]);
      } else {
        q.push_back(c[0]);
      }
    }
  }
  string ans = "";
  while(!q.empty()) {
    if (rev == false) {
      ans += q.front();
      q.pop_front();
    } else {
      ans += q.back();
      q.pop_back();
    }
  }
  print(ans);

  return 0;
}

Measured memory_bytes: 1368
r_num = int(input())
r_list = []

for i in range(r_num):
    name, score = input().split()
    temp_li = [i + 1, name, int(score)]
    r_list.append(temp_li)

r_sorted_li = sorted(r_list, key = lambda x:(x[1],-x[2]))

for index, name, score in r_sorted_li:
    print(index)

Measured memory_bytes: 3060
A, B, K = map(int,input().split())
if K>A and K<(A+B):
    B = B-(K-A)
    l = [0,B]
elif K>A and K>=(A+B):
    l = [0, 0]
else:
    l = [A-K,B]
print(' '.join(map(str, l)))


Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

int main(){
  rep(i,9){
    char c;
    cin >> c;
    if(i%4 == 0) cout << c;
  }
  cout << endl;
}

Measured memory_bytes: 256
/*	AtCoder 3574 3 Steps
	1st Edition:2017.10.21 Saturday
	Algorithm:Graph,Dfs
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;

#define For(a,b,c) for(ll (a)=(ll)(b);(a)<=(ll)(c);a++)
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
const ll inf=(ll)2e9;
const ll inf_ll=(ll)4e18;
const ll maxn=100005LL;
const ll maxm=100005LL;
const ll mod=998244353LL;

//all
struct edge{
	int x,y,nxt;
	edge(){}
	edge(int nx,int ny,int nnxt){
		x=nx;y=ny;nxt=nnxt;
	}
}E[maxm*2];
int head_e[maxn],cnt_e;

inline void link_e(int x,int y){
	E[++cnt_e]=edge(x,y,head_e[x]);
	head_e[x]=cnt_e;
	E[++cnt_e]=edge(y,x,head_e[y]);
	head_e[y]=cnt_e;
}

//input
int n,m;

void input(){
	scanf("%d %d",&n,&m);
	For(i,1,m){
		int x,y;
		scanf("%d %d",&x,&y);
		link_e(x,y);
	}
}

//Dfs
int col[maxn];
int cnt[2];

bool dfs(int u,int c){
	col[u]=c;
	cnt[c]++;
	bool res=true;
	for(int i=head_e[u],v=E[i].y;i;i=E[i].nxt,v=E[i].y){
		if(col[v]>=0 && col[v]^c==0)
			return false;
		if(col[v]>=0)
			continue;
		res&=dfs(v,c^1);
	}
	return res;
}

//main
bool ans;

int main(){
	input();
	memset(col,-1,sizeof(col));
	ans=dfs(1,0);
	if(!ans)
		printf("%lld\n",(ll)n*(ll)(n-1)/2-m);
	else printf("%lld\n",(ll)cnt[0]*(ll)cnt[1]-m);
	return 0;
}
/*
6 5
1 2
2 3
3 4
4 5
5 6
*/


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 998244353;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int maxn = 3e3+5;
// int maxn = 5;

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

    int n, s;
    while(cin>>n>>s){
        ll ans = 0;
        vi a(n);
        forn(i,n) cin>>a[i];

        vvl dp(n+1, vl(maxn));
        // Number of subseq till (i+1)th row, having sum j

        forn(i,n){
            dp[i+1] = dp[i]; // copy from prev row

            // start new seq
            add_self(dp[i+1][a[i]], i+1);

            // extend the prev sub seq
            for(int j=1; j+a[i]<=s; ++j)
                add_self(dp[i+1][j+a[i]], dp[i][j]);
            
            // # till i+1 th row, having sum s
            add_self(ans, dp[i+1][s]);
        }
        // print_vv(dp);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 70912
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=2019;
#define ll long long

int main(){
  int r;
  cin>>r;
  cout<<3*r*r<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}

int main(void){
    ll n,i;
    scanf("%lld",&n);
    if(n==2){
        printf("2\n");
        return 0;
    }
    if(n%2==0) n++;
    ll a;
    while(1){
        // printf("%lld ",n);
        a=sqrt(n);
        if(a%2==0) a--;
        for(i=a;i>2;i-=2){
            if(n%i==0) break;
        }
        if(i==1){
            break;
        }
        n+=2;
    }
    printf("%lld\n",n);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;

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

	int n; cin >> n;
	string s; cin >> s;
	int l = 0, r = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '<') l++;
		else break;
	}
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == '>') r++;
		else break;
	}
	cout << n - min(l, r) << endl;
}

Measured memory_bytes: 3328
def main():
    n = int(input())
    txys = [list(map(int, input().split())) for _ in range(n)]
    txys.insert(0, [0, 0, 0])
    ans = 'Yes'
    for i in range(n):
        time_diff = txys[i+1][0] - txys[i][0]
        manhattan_dis = abs(txys[i][1] - txys[i+1][1]) + abs(txys[i][2] - txys[i+1][2])
        if time_diff < manhattan_dis:
            ans = 'No'
            break
        elif time_diff == manhattan_dis:
            continue
        else:
            if (time_diff - manhattan_dis) % 2 == 0:
                continue
            else:
                ans = 'No'
                break
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27092
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase

#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
#show_flg=True

A,B,C,D,E,F=LI()

m=0
ans=(A*100,0)
for a in range(31):
    for b in range(16):
        for c in range(101):
            for d in range(101):
                if a*A*100+b*B*100+c*C+d*D<=F and (a*A+b*B)*E>=c*C+d*D and a+b>0:
                    if m<(c*C+d*D)/(a*A+b*B):
                        m=(c*C+d*D)/(a*A+b*B)
                        ans=(100*(a*A+b*B)+c*C+d*D,c*C+d*D)

print(*ans)





Measured memory_bytes: 42984
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;

inline int add(int a,int b){return (a%mod + b%mod)%mod;}
inline int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
inline int mul(int a,int b){return (a%mod * b%mod)%mod;}
inline int power(int a,int b,int MOD){int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
signed main()
{
     SPEED;
     string a,b,c;
     cin>>a>>b>>c;
     int currenta=0;
     int currentb=0;
     int currentc=0;
     int na=a.length();
     int nb=b.length();
     int nc=c.length();
     currenta++;
     char current_char=a[0];
     while(1)
     {
     	  if(current_char=='a')
     	  {
     	    if(currenta==na)
     	    {
     	        cout<<"A"<<endl;
     	        return 0;
     	    }
     	    current_char=a[currenta];	
     	  	currenta++;
          }
     	  else if(current_char=='b')
     	  {
     	  	if(currentb==nb)
     	  	{
     	  		  cout<<"B"<<endl;
     	  		  return 0;
     	  	}
     	  	current_char=b[currentb];
     	  	currentb++;
     	  }
     	  else
     	  {
     	  	if(currentc==nc)
     	  	{
     	  		 cout<<"C"<<endl;
     	  		 return 0;
     	  	}
     	  	current_char=c[currentc];
     	  	currentc++;
     	  }
     }
     time();
     return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{x:i64,a:i64,b:i64};
    println!("{}", if (-a+b) <= 0 {"delicious"} else if (-a+b)<=x {"safe"} else {"dangerous"});
}


Measured memory_bytes: 4352
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length === 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  async function solve() {
    const sc = new Scanner();
    const b: string = await sc.getLine();
    const ans: any = { A: 'T', T: 'A', C: 'G', G: 'C' };
    console.log(ans[b]);
    sc.close();
  }

  solve();
}


Measured memory_bytes: 7628
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define ii pair<ll,ll>
#define sc second
#define mp make_pair
#define All(v) v.begin(),v.end()
using namespace std;
ll n,A,B;
int a[200000];
int ch(ll mid)
{
    ll t = 0;
    for(int i=0;i<n;i++)
    {
        ll R = a[i];
        R-=mid*B;
        if(R > 0)
        {
            t+=R/(A-B);
            if(R%(A-B)!=0)
                t++;
        }
    }
    return t <= mid;
}
int main()
{

  cin>>n>>A>>B;
  for(int i=0;i<n;i++)
  {
      scanf("%d",&a[i]);
  }
  int st = 0 , En = 1e9;
  int ans = 0;
  while(st <= En)
  {
      int mid = (st+En)/2;
      if(ch(mid))
      {
          En = mid-1;
          ans = mid;
      }
      else
        st = mid+1;
  }
  cout<<ans<<endl;;
}


Measured memory_bytes: 640
n, m = map(int,input().split())
edge = []
c = []
ed_list = [[] for _ in range(n)]
for i in range(m):
    t_a, t_b, t_c = map(int,input().split())
    edge.append([t_a - 1,  t_b - 1])
    c.append(-t_c)
    ed_list[t_a - 1].append(t_b - 1)

INF = float('inf')
score = [INF for _ in range(n)]
score[0] = 0
for i in range(n):
    for u, cost in zip(edge, c):
        if score[u[1]] > score[u[0]] + cost:
            score[u[1]] = score[u[0]] + cost
ans = score[n-1]
for i in range(n):
    for u, cost in zip(edge, c):
        if score[u[1]] > score[u[0]] + cost:
            score[u[1]] = score[u[0]] + cost
print(-ans if ans == score[n-1] else 'inf')

Measured memory_bytes: 3572
#include "stdio.h"

long long int star;
long long int num;
long long int x[200] = {};
long long int y[200] = {};
long long int place[200] = {};
long long int pic_x[1000] = {};
long long int pic_y[1000] = {};
long long int pic_place[1000] = {};
long long int box;
long long int ans_x;
long long int ans_y;

void search(long long int start,long long int dis,long long int fig) {
//	printf("hijiki\n");
	for (int i = start; i < num&&pic_place[i]<=pic_place[start]+dis; i++) {
		if (pic_place[start] + dis == pic_place[i]) {
		//	printf("hijikihijiki\n");
			if (fig + 2 == star) {
		//		printf("hijikihijiki\n");
				ans_x = pic_place[i]/1000001 - place[star - 1]/1000001;
				ans_y= pic_place[i] % 1000001 - place[star - 1] % 1000001;
				return;
			}
			search(i, place[fig + 2] - place[fig+1], fig + 1);
		}
	}
	return;
}

int main() {
	scanf("%lld", &star);
	while (star != 0) {
		for (int i = 0; i < star; i++) {
			scanf("%lld %lld", &x[i], &y[i]);
		}
		for (int i = 0; i < star; i++) {
			place[i] = x[i] * 1000001 + y[i];
		//	printf("%lld\n", place[i]);
		}
		for (int i = 0; i < star - 1; i++) {
			for (int j = i; j < star; j++) {
				if (place[i] > place[j]) {
					box = place[i];
					place[i] = place[j];
					place[j] = box;
				}
			}
		}
		scanf("%lld", &num);
		for (int i = 0; i < num; i++) {
			scanf("%lld %lld", &pic_x[i], &pic_y[i]);
		}
		for (int i = 0; i < num; i++) {
			pic_place[i] = pic_x[i] * 1000001 + pic_y[i];
		}
		for (int i = 0; i < num - 1; i++) {
			for (int j = i; j < num; j++) {
				if (pic_place[i] > pic_place[j]) {
					box = pic_place[i];
					pic_place[i] = pic_place[j];
					pic_place[j] = box;
				}
			}
		}
		for (int i = 0; i < num; i++) {
			search(i, place[1] - place[0], 0);
		}
		printf("%lld %lld\n", ans_x, ans_y);
		scanf("%lld", &star);
	}
	return 0;
}

Measured memory_bytes: 1068
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		int sum = 1;
		for(int i = 0; i < N; i++) {
			if(sum + K > sum * 2) {
				sum *= 2;
			} else {
				sum += K;
			}
		}
		System.out.println(sum);
		scan.close();

	}

}


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

int main() {
    int a,b,c,d,e;
    cin >>a>>b>>c>>d>>e;

    if (a == 0) cout << 1 << endl;
    else if(b == 0)cout << 2 << endl;
    else if(c == 0)cout << 3 << endl;
    else if(d == 0)cout << 4 << endl;
    else cout << 5 << endl;

}

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

int main(){
    int a,b; cin>>a>>b;
    cout<<a*b<<endl;
}

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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

const ll inf = 1ll << 62;
const int maxn = 2e5 + 5;
ll dp[maxn][4];

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

    int n;
    cin >> n;
    vt<int> a(n);
    for (int &i : a) cin >> i;

    fill_n(dp[0], maxn * 4, -inf);
    dp[0][0] = dp[1][1] = dp[2][2] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            if (dp[i][j] == -inf) continue;

            ll r = dp[i][j] + a[i];
            dp[i + 2][j] = max(dp[i + 2][j], r);
            dp[i + 3][j + 1] = r;
        }
    }

    ll ans = max(dp[n / 2 * 2][0], dp[n / 2 * 2 + 1][1]);
    if (n & 1) cout << max(ans, dp[n + 1][2]);
    else cout << ans;
}


Measured memory_bytes: 10336
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

const int N = 20;
int g[N][N];
bool visited[N][N];
int w, h,x ,y, cnt;

int dx[] = {1, 0, 0, -1};
int dy[] = {0, -1, 1, 0};

bool check(int x, int y){
  return (x >= 0 && y >= 0 && x < w && y < h);	
}

void dfs(int c, int r){
	visited[c][r] = true;
	cnt++;
	for (int i = 0; i < 4; i++){
	  int nx = r + dx[i];
	  int ny = c + dy[i];
	  if (check(nx, ny) && g[ny][nx] == 1 && !visited[ny][nx]){
		  dfs(ny, nx);  
		}
	}
}

void solve(){
  while(cin >> w >> h && w > 0 && h > 0){
	  cnt = 0;
	  memset(visited, false, sizeof visited);
	  for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
		  char input;
		  cin >> input;
		  if (input == '.') g[i][j] = 1;
		  else if (input == '#') g[i][j] = 0;
		  else if (input == '@'){
			   x = i;
			   y = j; 
			 }	
		  }  
	  }
	  dfs(x, y);
	  cout << cnt << endl;  
	}	
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}




Measured memory_bytes: 3180
// https://atcoder.jp/contests/abc071/tasks/abc071_a

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int x, a, b;
  string r;

  cin >> x >> a >> b;

  r = abs(x - a) < abs(x - b) ? 'A' : 'B';

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
using namespace std;

tuple<int, int> min(vector<int> xs) {
  int ind = 0;
  int smallest = xs[0];
  for (int i=1; i<xs.size(); ++i) {
    if (xs[i] < smallest) {
      ind = i;
      smallest = xs[i];
    }
  }
  return(forward_as_tuple(smallest, ind));
}

int gcd(int a, int b) {
  if (a < b) return(gcd(b,a));
  else {
    int r = a % b;
    if (r==0) return(b);
    else return(gcd(b,r));
  }
}

int vec_gcd(vector<int> xs) {
  if (xs.size() < 2) return(xs[0]);
  int r = gcd(xs[0], xs[1]);
  for (int i=2; i<xs.size(); ++i) {
    r = gcd(r, xs[i]);
  }
  return(r);
}

int main() {
  int N, X;

  cin >> N >> X;

  vector<int> xs(N);
  for (int i=0; i<N; ++i) {
    cin >> xs[i];
  }

  //入力{x_i}の正規化
  int x_min, x_minInd;
  tie(x_min, x_minInd) = min(xs);

  if (X < x_min) {
    for (int i=0; i<N; ++i) xs[i] -= X;
  } else {
    xs[x_minInd] = X;
    for (int i=0; i<N; i++) {
      xs[i] -= x_min;
    }
  }

  //ここでのxsの全要素最大公約数を求めれば良い．
  int D = vec_gcd(xs);
  cout << D << endl;
  return(0);
}

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

char s[100+9];

void solve(){
	if(s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I'){
		puts("Yes");
		return;
	}
	puts("No");
}

int main(){
	scanf("%s",s);
	solve();
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define MAX 200000

int max(int a,int b){return a>b ? a:b;}
int min(int a,int b){return a<b ? a:b;}

int main(void){
	int R[MAX], i, n;
	
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&R[i]);
	
	int maxv = -2000000000;
	int minv = R[0];
	
	for(int i=1; i<n; i++){
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	
	printf("%d\n",maxv);
	
	return 0;
	
}



Measured memory_bytes: 2632
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            char[] s = in.next().toCharArray();
            char[] t = in.next().toCharArray();

            Arrays.sort(s);
            Arrays.sort(t);

            int ans = new String(s).compareTo(new StringBuilder(new String(t)).reverse().toString());

            // 出力
            out.println(ans < 0 ? "Yes" : "No");

        }

    }
}



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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  vector<vector<int>> ans(H, vector<int>(W));
  rep(i, B) rep(j, A) {
    ans[i][j] = 1;
  }
  rep(i, H - B) rep(j, W - A) {
    ans[i + B][j + A] = 1;
  }
  rep(i, H) {
    rep(j, W) {
      cout << ans[i][j];
    }
    cout << "\n";
  }
}


Measured memory_bytes: 5120
n, *a = map(int, open(0).read().split())
a.sort()

b = []
prev = cnt = 0
for i in range(n):
        if prev==a[i]: cnt+=1
        else:
                if cnt>1: b.append([prev, cnt])
                cnt = 1
        prev = a[i]
if cnt>1: b.append([prev, cnt])

h, w = 0, 0
for i, cnt in b:
        if cnt>3: h, w = i, i
        else: h, w = max(h, w), i
print(h*w)

Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define F first
#define S second
#define pb push_back
mt19937 rnd;


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

ll dp[55][55][3025];

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,a;
  cin>>n>>a;
  vector<int> x(n);
  rep(i,n) cin>>x[i];
  dp[0][0][0]=1;
  rep(i,n) rep(j,n) rep(k,2505){
    dp[i+1][j][k]+=dp[i][j][k];
    dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
  }
  //rep(i,n+1){rep(j,n){rep(k,20) cout<<dp[i][j][k]<<",";cout<<endl;}cout<<endl;}
  ll re=0;
  rep(i,n+1) if(i) re+=dp[n][i][a*i];
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 60544
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
int main(){
    int a;
    
    std::cin >> a;
    int b;
    std::cin >> b;
    if((a+b)%2!=0){
        std::cout << (a+b)/2+1 << std::endl;    
    }else{
        std::cout << (a+b)/2 << std::endl;
    }

}

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

int main() {
	int n,m;
	cin >> n >> m;
	vector<set<int>> t(n);
	rep(i,m) {
		int a, b;
		cin >> a >> b;
		a--;b--;
		t[a].insert(b);
		t[b].insert(a);
	}
	// 幅優先探索で、隣のとなりを探す。
	vector<int> s(n,-1);// i が持つ友人の数 検索前-1 に初期化
	rep(i,n) {
		if (s[i] != -1) continue;
		deque<int> q;
		if (t[i].size()>0) {
			for(auto itr=t[i].begin(); itr != t[i].end(); itr++) {
				q.emplace_back(int(*itr));
			}
			s[i] = 0;
		}
		while(!q.empty()){
			int x= q.front();
			q.pop_front();
			if (s[x] != -1) continue;
			s[i]++;
			if (t[x].size()>0) {
				for(auto itr=t[x].begin(); itr != t[x].end(); itr++) {
					q.emplace_back(int(*itr));
				}
				s[x]=0;
			}
		}
	}
	int ans=0;
	rep(i,n) {
		ans = max(ans, s[i]);
	}
	cout << ans+1 << endl;
	return 0;
}


Measured memory_bytes: 32456
#include<stdio.h>
int main()
{
    int len1,len2,i,j;
    char a[100],b[100],c[100];
    scanf("%s %s %s",&a,&b,&c);
    for(i=0;a[i];i++){}len1=i;
    for(i=0;b[i];i++){}len2=i;
    if(a[len1-1]==b[0]&&b[len2-1]==c[0]){printf("YES\n");}
    else{printf("NO\n");}
    return 0;
}




Measured memory_bytes: 128
n = int(input())
p = input().split()
i = 1
result = 0
while p:
  if (i+1)<n:
    if sorted([int(p[i-1]),int(p[i]),int(p[i+1])])[1] == int(p[i]):
      result+=1
    i+=1
  else:
    break
print(result)

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

ll f(ll n,ll x){
    if(n<0) return 0;
    else return n/x+1;
}

int main(void)
{
    ll a,b,c; cin>>a>>b>>c;
    bool can=false;
    for(int i=a;i<=a*b;i+=a) if(i%b==c) can=true;
    cout<<(can ? "YES":"NO")<<endl;
    return 0;
}

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

#define INF 0x3f3f3f3f
#define MAXN 100010
#define endl "\n"
#define abs(a, b) ((a > b) ? a-b : b-a)

typedef long long int ll;

/* End */

int n;
ll a[MAXN];
ll b[MAXN];
ll c[MAXN];
ll pd[MAXN][3];

ll solve(int i, int m) { //0 - a, 1 - b, 2 - c
	if (i == n+1) return 0;
	if (pd[i][m] != -1) return pd[i][m];
	if (m == 0)
		return pd[i][m] = max(b[i] + solve(i+1, 1), c[i] + solve(i+1, 2));
	else if (m == 1)
		return pd[i][m] = max(a[i] + solve(i+1, 0), c[i] + solve(i+1, 2));
	else
		return pd[i][m] = max(a[i] + solve(i+1, 0), b[i] + solve(i+1, 1));
}

int main() {
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	memset(pd, -1, sizeof(pd));

	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];

	cout << max(solve(1, 0), max(solve(1, 1), solve(1, 2))) << endl;

	return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
    long long x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<long long>r(a),g(b),n(c),rg;
    rep(i,a)cin>>r[i];
    rep(j,b)cin>>g[j];
    rep(k,c)cin>>n[k];
    //input
    sort(r.begin(),r.end(),greater<int>());
    sort(g.begin(),g.end(),greater<int>());
    sort(n.begin(),n.end(),greater<int>());
    rep(i,x)rg.push_back(r[i]);
    rep(j,y)rg.push_back(g[j]);
    sort(rg.begin(),rg.end());
    //sort
    int clr=0,m=0;
    long long ans=0;
    while(n[m]>rg[m]&&m<c&&m<x+y){
        m++;
    }
    for(int i=0;i<m;i++){
        ans+=n[i];
    }
    for(int i=m;i<x+y;i++){
        ans+=rg[i];
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 5368
A, B = list(map(int, input().split()))

ans = 0
for i in range(A, B+1):
    buf = str(i)
    is_par = True
    for u in range(len(buf)//2):
        if buf[u] != buf[-1-u]:
            is_par = False
            break
    if is_par:
        ans += 1


print(ans)

Measured memory_bytes: 3060
def bubbleSort(a):
  for i in range(len(a)):
    for j in range(len(a)-1,i,-1):
      if int(a[j][1])<int(a[j-1][1]):
        a[j],a[j-1]=a[j-1],a[j]
  return 0

def selectionSort(b):
  for i in range(len(b)):
    minIndex = i
    for j in range(i+1,len(b)):
      if(int(b[j][1])<int(b[minIndex][1])):
        minIndex = j
        
    b[i],b[minIndex] = b[minIndex],b[i]
    
  return 0
        

n = input()
a = input().split()
b = a[:]

bubbleSort(a)
print(*a)
print("Stable")

selectionSort(b)
print(*b)
if a==b:
  print("Stable")
else:
  print("Not stable")


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

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> a(m);
  int b=0;
  for(int i=0;i<m;i++){
    cin>>a[i];
  }
  for(int i=0;i<m;i++){
    b+=a[i];
  }
  if(n-b>=0)cout<<n-b<<endl;
  else cout<<-1<<endl;
}

Measured memory_bytes: 3596
N = int(input())
P = [int(x) for x in input().split()]
Q = [int(x) for x in input().split()]

set_p = set()
set_q = set()
factorial = [1, 1, 2, 6, 24, 120, 720, 5040]
for j in range(N):
    set_p.add(j + 1)
    set_q.add(j + 1)

order_p = 0
order_q = 0
for i in range(N):
    set_p.discard(P[i])
    set_q.discard(Q[i])
    new_set_p = set()
    new_set_q = set()
    new_set_p = set() | set_p
    new_set_q = set() | set_q
    numofbig_p = 0
    numofbig_q = 0

    for k in new_set_p:
        if k > P[i]:
            numofbig_p += 1
    for h in new_set_q:
        if h > Q[i]:
            numofbig_q += 1
    order_p += numofbig_p * factorial[N - i - 1]
    order_q += numofbig_q*factorial[N-i-1]

ans = abs(order_p-order_q)
print(ans)


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define PB push_back
#define LIM 1200000
typedef long long ll;
typedef vector<ll> vint;
bool prime[LIM]; 
vint v;
int main(){
	rep(i,LIM) prime[i]=true;
	prime[0]=prime[1]=false;
	rep(i,(int)sqrt(LIM)){
		if(prime[i]){
			for(int j=i*i;j<LIM;j+=i){
				prime[j]=false;
			}
		}
	}
	rep(i,LIM){
		if(prime[i]){
			v.PB((ll)i);
		}
	}
	ll N,P;
	while(cin>>N>>P,N!=-1||P!=-1){
		vint ans;
		int c=0;
		rep(i,LIM){
			if(v[i]>N){
				c=i;
				break;
			}
		}
		for(int i=c;i<c+P;i++){
			for(int j=i;j<i+P;j++){
				ans.PB(v[i]+v[j]);
			}
		}
		// cout<<ans.size()<<endl;
		sort(ans.begin(),ans.end());
		cout<<ans[P-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3156
package main

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

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	ans := 0
	for i := 0; i < n; i++ {
		tmp := sc.NextInt()
		for {
			if tmp%2 != 0 {
				break
			}
			tmp /= 2
			ans++
		}
	}
	fmt.Printf("%v\n", ans)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1280
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(s: str):
    N = len(s)

    for i in range(N):
        if i == 0:
            continue

        if s[i-1] == s[i]:
            print(i, i+1)
            return

        if i > 1:
            if s[i-2] == s[i]:
                print(i-1, i+1)
                return
    print("-1 -1")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316