akhauriyash/Code-Regression huggingface dataset:
import copy

def f(t, i):
    if len(t) == i:
        return [t]

    result = []
    if t[i] == 'A':
        t1 = copy.deepcopy(t)
        t2 = copy.deepcopy(t)
        t1[i] = ''
        result.extend(f(t1, i + 1))
        result.extend(f(t2, i + 1))
    else:
        result.extend(f(t, i + 1))
    return result

st = set()
tokens = f(list('AKIHABARA'), 0)
for token in tokens:
    st.add(''.join(token))

s = input()
if s in st:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3572
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    for i in range(2):
        if s[i] == s[i + 1] == s[i + 2]:
            print("Yes")
            return
    print("No")
    return

#B
def B():
    return

#C
def C():
    abcd = list(map(int, S()))
    op = itertools.product(range(2), repeat=3)
    for opx in op:
        ans = abcd[0]
        for num, opi in enumerate(opx):
            if opi:
                ans += abcd[num + 1]
            else:
                ans -= abcd[num + 1]
        if ans == 7:
            print(abcd[0],end="")
            for num, opi in enumerate(opx):
                print(["-", "+"][opi] + str(abcd[num + 1]), end="")
            print("=7")
            return
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 39408
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright  2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <utility> // pair
#include <map>
#include <unordered_map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>


using namespace std;

#define ll long long
#define lll __int128
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it with "scanf" and other c input!
#define pb push_back
#define rep(i,a,b) for (int i = a;i <= b;i ++)
#define pre(i,a,b) for (int i = a;i >= b;i --)
#define REP(i,a,b) for (int i = a;i < b;i ++)

#define read(a,s,n) rep(i,s,n) scanf("%d",a + i);
#define READ(a,s,n) REP(i,s,n) scanf("%d",a + i);

#define read_ll(a,s,n) rep(i,s,n) scanf("%lld",a + i);
#define READ_ll(a,s,n) REP(i,s,n) scanf("%lld",a + i);

#define _T_(T) int T;scanf("%d",&T);while (T --)
#define __T _T_(TTESTCASES)
#define _E_(T) while (~T)

#define Tprint(a,s,e) {int f=1;REP(i,s,e){if(f)f=0;else printf(" ");printf("%d",a[i]);}}


#define endl '\n'

#define itn int
#define iny int
#define nit int
#define inr int
#define mian main
#define iman main
#define mina main
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */
int main()
{
    int n;
    ll d;
    scanf("%d%lld",&n,&d);
    ll a,b;
    d *= d;
    int x = 0;
    
    while (n --) {
        scanf("%lld%lld",&a,&b);
        if (a * a + b * b <= d) x ++;
    }
    printf("%d\n",x);
    return 0;
}


Measured memory_bytes: 3756
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    double r;
    cin >> r;

    double PI=3.14159265358979323846;
    print(2 * r * PI);
    return 0;
}


Measured memory_bytes: 3776
#include <iostream>

using namespace std;

int main(void)
{
    int N, K;
    cin >> N >> K;

    int n;
    int ans = 1;
    for(n = 0; n < N; ++n)
    {
        if(ans >= K)
            break;

        ans *= 2;
    }
    for(; n < N; ++n)
    {
        ans += K;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int a[110],b[110];

int main() {
	int n;
	while(n=in()){
		int i;
		for(i=0;i<n;i++){
			a[i]=in()-1;
		}
		sort(a,a+n);
		int j=0,k;
		for(i=0;i<2*n;i++){
			bool bb=true;
			for(k=0;k<n;k++){
				if(a[k]==i)bb=false;
			}
			if(bb)b[j++]=i;
		}
		int an=n,bn=n;
		bool teban=true;
		int ba=-1;
		while(an*bn){
			if(teban){
				teban=false;
				if(ba>=a[an-1]){
					ba=-1;
					continue;
				}
				for(i=0;i<an;i++){
					if(ba<a[i]){
//cout<<"a "<<a[i]<<endl;
						ba=a[i];
						a[i]=a[--an];
						sort(a,a+an);
						break;
					}
				}
			}else{
				teban=true;
				if(ba>=b[bn-1]){
					ba=-1;
					continue;
				}
				for(i=0;i<bn;i++){
					if(ba<b[i]){
//cout<<"b "<<b[i]<<endl;
						ba=b[i];
						b[i]=b[--bn];
						sort(b,b+bn);
						break;
					}
				}
			}
		}
		cout<<bn<<endl;
		cout<<an<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    int N; cin >> N;
    int L[2010];
    REP(i,N) cin >> L[i];

    sort(L, L + N);

    ll ans = 0;
    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            for (int k = j + 1; k < N; k++) {
                if (L[i] < L[j] + L[k]) {
                    if (L[j] < L[i] + L[k]) {
                        if (L[k] < L[i] + L[j]) {
                            ans++;
                        }
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[4];
    rep(i,2){
        cin >> A[i];
    }
    //sort(A,A+3);
    cout << ((A[0]+A[1])%2==0 ? (A[0]+A[1])/2 : (A[0]+A[1])/2+1) << endl;
}

// int main(){
//     char A[19];
//     cin >> A;
//     A[3]='8';
//     cout <<  A << endl;
// }

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;


int min(int i, int j){
  if(i <= j) return i;
  return j;
}


int main(){

int N, K;
long h[100000];
long aaa;
long ans=1000000001;
long sum=0;
int n;
n = N/sizeof(h[0]);

scanf("%d %d", &N, &K);

for(int i=0;i<N;i++){
  scanf("%ld", &h[i]);
}

sort(h, h + N);


for(int k=0; k<N-K+1;k++){
  sum = h[k+K-1]-h[k];
  ans = min(sum, ans);
  sum = 0;
}


  printf("%ld\n", ans);
  return 0;
}

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

const long long MOD = 2;


int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(N);
    for(int i = 0; i < M; ++i){
        int k;
        cin >> k;
        for(int j = 0; j < k; ++j){
            int s;
            cin >> s;
            s--;
            a[s] |= 1 << i;
        }
    }
    int p = 0;
    for(int i = 0; i < M; ++i){
        int x;
        cin >> x;
        p |= x << i;
    }
    int ans = 0;
    for(int s = 0; s < (1 << N); s++){
        int t = 0;
        for(int i = 0; i < N; i++){
            if(s >> i & 1){
                t ^= a[i];
            }
        }
        if(t == p) ans++;
    }
    cout << ans << endl;
    /*
    int N, M;
    cin >> N >> M;
    vector<vector<int> > S;
    for(int i = 0; i < M; ++i){
        int k;
        cin >> k;
        vector<int> s;
        for(int j = 0; j < k; ++j){
            int ss;
            cin >> ss;
            s.push_back(ss);
        }
        S.push_back(s);
    }
    vector<int> p;
    for(int i = 0; i < M; ++i){
        int pp;
        cin >> pp;
        p.push_back(pp);
    }
    */
    /*
    for(auto i : p) cout << i << " ";
    cout << endl;
    for(auto i : S){
        for(auto j : i) cout << j << " ";
        cout << endl;
    }
    */
    
    
    return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>

#define MAX 100005
#define NIL -1

typedef struct { int p, l, r;} Node;

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if( T[u].p == NIL ) printf("root, ");
  else if( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0, c=T[u].l; c != NIL; i++, c=T[c].r) {
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void) {
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
  for(i=0;i<n;i++) {
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++) {
      scanf("%d",&c);
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
ll a[100100];
ll ans;
vector<Pi> PP;

int main(){
	cin>>n;
	REP(i,n){
		cin>>a[i];
	}
	sort(a,a+n);
	if(n==2){
		ans=a[n-1]-a[0];
		cout<<ans<<endl;
		cout<<a[n-1]<<" "<<a[0]<<endl;
		return 0;
	}
	
	if(a[1]<0){
		PP.push_back(Pi(a[n-1],a[0]));
		ans=a[n-1]-a[0];
	}else{
		PP.push_back(Pi(a[0],a[n-1]));
		ans=a[0]-a[n-1];
	}
	for(int i=1;i<n-2;i++){
		if(a[i+1]>=0&&a[i]<0){
			PP.push_back(Pi(a[i],ans));
			ans=a[i]-ans;
		}else{
			PP.push_back(Pi(ans,a[i]));
			ans=ans-a[i];
		}
	}
	if(ans>0){
		PP.push_back(Pi(ans,a[n-2]));
		ans=ans-a[n-2];
	}else{
		PP.push_back(Pi(a[n-2],ans));
		ans=a[n-2]-ans;
	}
	
	cout<<ans<<endl;
	for(int i=0;i<PP.size();i++){
		cout<<PP[i].first<<" "<<PP[i].second<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 4336
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
void solve();
signed main(){
#ifdef Sprinkle
   clock_t clock_start=clock();assert(freopen("test.txt","r",stdin));
#else
   ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#endif
   solve();
#ifdef Sprinkle
   cerr<<"Running Time: "<<((clock()-clock_start) *1.0 / CLOCKS_PER_SEC)<<"s\n";
#endif
}
#ifdef Sprinkle
void err(){cerr<<"\n";}template<typename T,typename...U>void err(const T&hd,const U&...tl){cerr<<hd<<(sizeof...(tl)?", ":"");err(tl...);}
#define debug(x...) cerr<<""#x" = ";err(x)
#else
#define debug(...) 0
#endif
int n;
int a[300005],qian[300005];
int ans[300005];
void solve(){
    int n,k;
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>k;
        a[k]++;
    }
    sort(a+1,a+n+1);
    for(int i=1;i<=n;++i){
        qian[i]=qian[i-1]+a[i];
    }
    a[n+1]=n+1;
    int t=1;
    for(int i=1;i<=n;++i){
        while(t<n+1&&1ll*a[t]*(t-i)<=qian[t-1])t++;
        ans[n-i+1]=qian[t-1]/(t-i);
    }
    for(int i=1;i<=n;++i){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)



int main(){
ll D,T,S;
cin>>D>>T>>S;

if(S*T>=D){
cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}

}











Measured memory_bytes: 3620
#include<iostream>
#include <string.h>
using namespace std;

int main(){
    int n,k;
    int ans=0;
    cin>>n>>k;
    if((k-1)%(n-1)==0)ans=(k-1)/(n-1);
    else ans=(k-1)/(n-1)+1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,i,node[250];

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&node[i]);
  }

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,node[i]);
    if(i/2 > 0){
      printf("parent key = %d, ",node[i/2]);
    }
    if(2*i <= n){
      printf("left key = %d, ",node[2*i]);
    }
    if(2*i+1 <= n){
      printf("right key = %d, ",node[2*i+1]);
    }
    printf("\n");
  }

  return 0;
}
   

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
long long a,b,ans;
int main()
{
    cin>>a>>b;
    ans=(a+b)/2;
    if(ans*2<a+b) ans++;
    cout<<ans;
    return 0;
}


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

int main(){
  string s;
  cin>>s;
  long long a = 0;
  for(int i=0;i<s.length();i++){
    a += (s[i]-'0');
  }
  if(a%9==0){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
  
  return 0;
}

Measured memory_bytes: 3748
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A, B, C = LI()

ans = 0
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    a = A // 2
    b = B // 2
    c = C // 2
    A = (b + c)
    B = (a + c)
    C = (a + b)
    ans += 1
    if ans == 10000:
        break


if ans == 10000:
    print(-1)
else:
    print(ans)





Measured memory_bytes: 7240
#include <bits/stdc++.h> 
  
#define for1(i,a,b) for (int i = a; i <= b; i++)
#define for2(i,a,b) for (int i = a; i >= b; i--)
#define int long long

using namespace std;

signed main() {
    int n, ans=0;
    cin >> n;
    for1(i,1,n-1) {
        int r = n/i;
        if (n%i==0) r--;
        ans+=r;
    }
    cout << ans;
}

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

long long xorsum(long long x){
  if (x/2%2==0&&x%2==0){
    return x;
  }
  else if (x/2%2==0&&x%2==1){
    return 1;
  }
  else if (x/2%2==1&&x%2==0){
    return x+1;
  }
  else if (x/2%2==1&&x%2==1){
    return 0;
  }
}

int main() {
  long long A,B;
  cin >> A >> B;
  bitset<64> a(xorsum(max((long long)0,A-1)));
  bitset<64> b(xorsum(B));
  a=a^b;
  long long ans=0;
  for (int i=0;i<64;i++){
    if (a.test(i)){
      ans+=(long long)pow(2,i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;


int main()
{
	int N, M;
	map<string, int> s, t;
	string tmp;
	map<string, int>::iterator it, fn;
	int get = 0;

	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> tmp;
		it = s.find(tmp);
		if (it != s.end())
			it->second += 1;
		else
			s.insert(make_pair(tmp, 1));
	}
	cin >> M;
	for (int i = 0; i < M; i++)
	{
		cin >> tmp;
		it = t.find(tmp);
		if (it != t.end())
			it->second += 1;
		else
			t.insert(make_pair(tmp, 1));
	}

	for (it = s.begin(); it != s.end(); it++)
	{
		fn = t.find(it->first);
		if (fn != t.end())
		{
			if (it->second - fn->second> 0)
			{
				if (get < it->second - fn->second)
					get = it->second - fn->second;
			}
		}
		else
		{
			if (get < it->second)
				get = it->second;
		}
	}

	cout << get << endl;

	return 0;
}

Measured memory_bytes: 256
import numpy as np
line = list(map(int, input().split()))
k = int(input())
ans = 'No'
  
for i in range(2 ** k):
  _array = np.copy(line)
  for j in range(k):
    if ((i >> j) & 1):
      _array[1] *= 2
    else:
      _array[2] *= 2
  if (_array[0] < _array[1] and _array[1] < _array[2]):
    ans = 'Yes'
    break
print (ans)

Measured memory_bytes: 27152
N=int(input())
a=[int(i) for i in input().split()]
dp=[[0]*(N+1) for i in range(N+1)]
for d in range(1,N+1):
  for i in range(N+1-d):
    if (N-d)%2==0:
      dp[i][i+d]=max(dp[i+1][i+d]+a[i],dp[i][i+d-1]+a[i+d-1])
    if (N-d)%2==1:
      dp[i][i+d]=min(dp[i+1][i+d],dp[i][i+d-1])
print(2*dp[0][N]-sum(a))
    

Measured memory_bytes: 113372
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;

ll indegree[L];
vector <ll> adj[L];
bool visited[L];
ll dist[L];

void dfs(ll src)
{
    assert(!visited[src]);
    visited[src] = true;

    for(auto i: adj[src])
    {
        if(!visited[i])
        {
            indegree[i]--;

            dist[i] = max(dist[i], dist[src] + 1);

            if(indegree[i] == 0)
            {
                dfs(i);
            }
        }
    }
}

void solve()
{
    ll n = nxt(), m = nxt();

    for(ll i=0; i<m; i++)
    {
        ll u = nxt(), v = nxt();
        adj[u].pb(v);
        indegree[v]++;
    }    

    for(ll i=1; i<=n; i++)
    {
        if(!visited[i] && indegree[i] == 0)
        {
            dfs(i);
        }
    }

    ll ans = 0;

    for(ll i=1; i<=n; i++)
    {
        ans = max(ans, dist[i]);
    }

    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 10496
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;

 int main()
 {
   string s;
   while(cin>>s)
   {
     cout<<"2018";
     for(int i=0;i<s.length();i++)
     {
       if(i<4) continue;
       else cout<<s[i];        
     }             
     cout<<endl;
   }
   return 0;
 }
 

        

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

using namespace std;

using grid_t = std::array<std::array<int, 3>, 3>;

bool calc(const grid_t& grid, int a0) {
  std::array<int, 3> as{};
  std::array<int, 3> bs{};
  as[0] = a0;
  bs[0] = grid[0][0] - as[0];
  as[1] = grid[1][0] - bs[0];
  bs[1] = grid[0][1] - as[0];
  as[2] = grid[2][0] - bs[0];
  bs[2] = grid[0][2] - as[0];
  if (as[1] + bs[1] != grid[1][1]) {
    return false;
  }
  if (as[1] + bs[2] != grid[1][2]) {
    return false;
  }
  if (as[2] + bs[1] != grid[2][1]) {
    return false;
  }
  if (as[2] + bs[2] != grid[2][2]) {
    return false;
  }
  return true;
}

bool calc(const grid_t& grid) {
  for (int i = -100; i <= 200; i++) {
    if (calc(grid, i)) {
      return true;
    }
  }
  return false;
}

int main() {
  grid_t grid{};
  for (int row = 0; row < 3; row++) {
    for (int column = 0; column < 3; column++) {
      std::cin >> grid[row][column];
    }
  }
  std::cout << (calc(grid) ? "Yes" : "No") << std::endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import math
input = sys.stdin.readline

q, h, s, d = map(int, input().split())
n = int(input())
ans = 0

if n >= 2:
  ans += min(8 * q, 4 * h, 2 * s, d) * math.floor(n / 2)

if n % 2 == 1:
  ans += min(4 * q, 2 * h, s)
  
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    int a, b;
    bool first = true;
    while (cin >> a >> b, a) {
        vector<int> res;
        for (int i=a; i<=b; ++i) {
            if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) {
                res.push_back(i);
            }
        }
        if (first) {
            first = false;
        } else {
            cout << endl;
        }
        if (res.empty()) {
            cout << "NA" << endl;
        } else {
            for (int i=0; i<(int)res.size(); ++i) {
                cout << res[i] << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1228
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 100000;
char S[MAXN + 5]; int N, K;
int main() {
	scanf("%d%d%s", &N, &K, S + 1);
	int cnt = 0;
	for(int i=1;i<N;i++)
		cnt += (S[i] != S[i + 1]);
	while( cnt >= 2 && K )
		cnt -= 2, K--;
	if( cnt == 1 && K )
		cnt--, K--;
	printf("%d\n", N - cnt - 1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n, m;
    while(1){
        cin >> n >> m;
        if(n + m == 0) break;
        vector<pair<int, pair<int, int> > > data;
        rep(i, 0, m){
            int t, s, d;
            cin >> t >> s >> d; 
            data. push_back(make_pair(t, make_pair(s, d)));
        } 
        sort(all(data));
        set<int> st;
        st.insert(1);
        rep(i, 0, m){
            if(st.count(data[i]. second. first)){
                st.insert(data[i]. second. second);
            }
        }
        cout << st.size() << endl;
    }
}

Measured memory_bytes: 2480
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef string ST;
 
 
#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
 
 
LL modpow(LL a, LL n, LL mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void func() {
  LL N ;
  cin >>N;
  cout << N*N;
}
 

int main()
{
  func();
  return 0;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long int;
#define pb push_back

/*入力*/
lint a, b, c, d;
vector<lint> X;
vector<lint> Y;
lint res = 0;

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

    X.pb(a); X.pb(b);
    if(a * b <= 0) X.pb(0);  //0を含む

    Y.pb(c); Y.pb(d);
    if(c * d <= 0) Y.pb(0);  //0を含む

    int xlen = X.size();
    int ylen = Y.size();

    res = X[0] * Y[0];
    for(int i = 0; i < xlen; i++){
        for(int j = 0; j < ylen; j++) res = max(res, X[i]*Y[j]);
    }

    cout << res << endl;
    return 0;
}




Measured memory_bytes: 3636
n,k=map(int,input().split())
c=[0]*(10**5+1)
for i in range(n):
    a,b=map(int,input().split())
    c[a]+=b
tmp=0
for i in range(10**5+1):
    tmp+=c[i]
    if tmp>=k:
        print(i)
        break


Measured memory_bytes: 5736
n, a, b = map(int, input().split())
mod = pow(10, 9) + 7
total = pow(2, n, mod)
#print(total)
def comb(m, x):
  numerator = 1
  for i in range(m - x + 1, m + 1):
    numerator = numerator * i % mod
  denominator = 1
  for i in range(1, x + 1):
    denominator = denominator * i % mod
  d = pow(denominator, mod - 2, mod)
  return numerator * d
a = comb(n, a)
b = comb(n, b)
print((total - a - b - 1) % mod)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;

int main(void){

    double R; cin>>R;
    cout<<M_PI*R*2<<endl;


}


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

int main()
{
    int N, D, X, sum=0,count=0;
    cin >> N >> D >> X;
    vector<int> a(N);
    vector<int> b(N);

    for (int i = 0; i < N;i++){
        cin >> a.at(i);
    }
    for (int i = 0; i < N;i++){
        for (int j = 0; j < D;j++){
            if (((j * a.at(i)) + 1) <= D)
            {
                //b.at(i) += ((i * a.at(i)) + 1);
                count++;
            }
            b.at(i) = count;
        }
        count = 0;
    }
    for (int i = 0; i < N;i++){
        //cout << b.at(i) << endl;
        sum += b.at(i);
    }
    cout << sum + X << endl;
}

Measured memory_bytes: 256
# K, N = map(int, input().split())
# a = list(map(int, input().split()))

# N = int(input())

def gcd(a, b):
    if a < b:
        a, b = b, a
    r = a % b
    if r == 0:
        return b
    return gcd(r, b)

K = int(input())

ans = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        n = gcd(a, b)
        for c in range(1, K+1):
            ans += gcd(n, c)

print(ans)


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

using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool ok = true;

    for (int i = 0; i < s.size(); i++) {
        if (i == a) {
            if (s[i] != '-')
                ok = false;
        }
        else
            if (s[i] < '0' || '9' < s[i])
                ok = false;
    }
    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define po pop_back
#define mp make_pair
#define fi first
#define se second
#define hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007  
using namespace std;
bool comp(ll a,ll b){if(a>b)return true;else return false;}
int isP(ll n){if(n==1)return 0;if(n==2 || n==3)return 1;for(ll i=2;i<=sqrt(n);i++){if(n%i==0)return 0;}return 1;}
ll power(ll a,ll b){if(b==0)return 1;if(b==1) return a;ll t=power(a,b/2);if(b%2==1) return t*t*a;else return t*t;}
ll powMOD(ll x,ll y){if(y==0)return 1;if(y==1)return x;ll t=powMOD(x,y/2);if(y%2==1)return t*t%MOD*x%MOD;else return t*t%MOD;}
bool cmp(pair<ll,ll> p1,pair<ll,ll> p2){if(p1.fi>p2.fi) return true;if(p1.fi==p2.fi && p1.se>p2.se) return true;return false;}

int main()
{
    hello;
    
    ll t;
//    cin>>t;
	t=1;

	while(t--){
		ll n;
		cin>>n;
		ll ans[2001]={};
		ans[0]=1;
		ans[1]=ans[2]=0;
		ans[3]=1;
		for(ll i=4;i<=n;i++){
			for(ll j=3;j<=i;j++){
				ans[i]=(ans[i]+ans[i-j])%MOD;
			}
		}
		cout<<ans[n]<<"\n";
	}
    
    return 0;  
}

Measured memory_bytes: 3680
#include<iostream>
using namespace std;
bool vert[16][16];
bool horiz[16][16];
void clear_mata()
{
    for(int i=0;i<16;i++)
    {
        for(int j=0;j<16;j++)
        {
            vert[i][j]=true;
        }
    }
    for(int i=0;i<16;i++)
    {
        for(int j=0;j<16;j++)
        {
            horiz[i][j]=true;
        }
    }
}
int possible(int x,int y,int secret_x,int secret_y)
{
    if(x<0||x>secret_x||y<0||y>secret_y)
    {
        return 0;
    }
    else if(x==0&&y==0)
    {
        return 1;
    }
    else if((!vert[x][y])&&(!horiz[x][y]))
    {
        return 0;
    }
    else if(!vert[x][y])
    {
        return possible(x-1,y,secret_x,secret_y);
    }
    else if(!horiz[x][y])
    {
        return possible(x,y-1,secret_x,secret_y);
    }
    else
    {
        return possible(x,y-1,secret_x,secret_y)+possible(x-1,y,secret_x,secret_y);
    }
};
int main()
{

    int num;
    cin>>num;
    for(int i=0;i<num;i++)
    {
        int secret_x,secret_y;
        int p;
        clear_mata();
        cin>>secret_x>>secret_y;
        cin>>p;
        for(int j=0;j<p;j++)
        {
            int x1,x2,y1,y2;
            cin>>x1>>y1>>x2>>y2;
            if(x1==x2)
            {
                vert[x1][max(y1,y2)]=false;
            }
            if(y1==y2)
            {
                horiz[max(x1,x2)][y1]=false;
            }
        }
        if(possible(secret_x,secret_y,secret_x,secret_y)==0)
            cout<<"Miserable Hokusai!"<<endl;
        else
            cout<<possible(secret_x,secret_y,secret_x,secret_y)<<endl;
    }
}

Measured memory_bytes: 3000
#include <stdio.h>

int main()
{
  int N, M, X, C[13], A[13][13];
  int sum = 0;
  int j = 0;
  int sum_under = 0;
  int count = 0;
  int sum_end = 200000000;

  scanf("%d", &N);
  scanf("%d", &M);
  scanf("%d", &X);

  for(int i = 0; i < 13; i++){
    C[i] = 0;
    for(int k = 0; k < 13; k++){
      A[i][k] = 0;
    }
  }


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

  int q, w, e, r, t, y, u, o, p, a, s, d;

  for(q = 0; q < 2; q++){
    for(w = 0; w < 2; w++){
      for(e = 0; e < 2; e++){
        for(r = 0; r < 2; r++){
          for(t = 0; t < 2; t++){
            for(y = 0; y < 2; y++){
              for(u = 0; u < 2; u++){
                for(o = 0; o < 2; o++){
                  for(p = 0; p < 2; p++){
                    for(a = 0; a < 2; a++){
                      for(s = 0; s < 2; s++){
                        for(d = 0; d < 2; d++){
                          sum = q*C[0] + w*C[1] + e*C[2] + r*C[3] + t*C[4] + y*C[5] + u*C[6] + o*C[7] + p*C[8] + a*C[9] + s*C[10] + d*C[11];
                          for(int i = 0; i < M; i++){
                            sum_under = q*A[0][i] + w*A[1][i] + e*A[2][i] + r*A[3][i] + t*A[4][i] + y*A[5][i] + u*A[6][i] + o*A[7][i] + p*A[8][i] + a*A[9][i] + s*A[10][i] + d*A[11][i];
                            if(sum_under >= X){
                              count += 1;
                            }
                          }
                          if(count == M){
                            j = 1;
                            if(sum_end > sum){
                              sum_end = sum;
                            }
                          }
                          count = 0;
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }

if(j == 1){
  printf("%d\n", sum_end);
}
else{
  printf("-1\n");
}


    return 0;
  }


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

using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	int r = 1;
	for(int i = 0; i < n; i++){
		if( 2 * r < r + k)
			r = 2 * r;
		else
			r = r + k;
	}
	cout << r;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;
int n,tmp,Ans[10010];
int main(){
    scanf("%d",&n);
    for(int x = 1 ; x <= 100 ; x++){
        for(int y = 1 ; y <= 100 ; y++){
            for(int z = 1 ; z <= 100 ; z++){
                int k = (x * x) + (y * y) + (z * z) + (x * y) + (x * z) + (y * z);
                if(k <= n) Ans[k]++;
            }
        }
    }
    for(int i = 1 ; i <= n ; i++){
        printf("%d\n",Ans[i]);
    }
    return 0;
}

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

using namespace std;
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  int sum=0;
  for(int i=0;i<n;i++){
    int t;
    cin>>t;
    sum+=min(t,abs(t-k));

  }
  cout<<2*sum<<endl;


}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define min(q,w) ((q)<(w)?(q):(w))
#define max(q,w) ((q)>(w)?(q):(w))
#define JS(q,i) (f[q]+sum[q]-sum[i]+(LL)(((i)-(q))*((i)-(q)+1)/2))
#define pre(j) ((LL)(j)*(j))
#define XL(j) (f[j]*2+sum[j]*2+pre(j)-(LL)(j))
#define XLg(j) (g[j+1]*2-sum[j]*2+pre(j)+3*(LL)(j))
#define iXL(i,j) (2*((i)-(j)))
using namespace std;
typedef long long LL;
const int N=300500,mo=1e9+7;
int read(int &n)
{
	int w=1;n=0;char ch=' ';
	for(;ch!='-'&&(ch<'0'||ch>'9');ch=getchar());
	if(ch=='-')w=-1,ch=getchar();
	for(;ch<='9'&&ch>='0';ch=getchar())n=n*10+ch-48;
	return n=w*n;
}
int n,m;
LL f[N],g[N],h[N],h1[N];
int a[N];
int za[N];
LL sum[N];
void Doit()
{
	za[za[0]=1]=0;
	fo(i,1,n)
	{
		f[i]=-2e16;
		for(;za[0]>1&&XL(za[za[0]])-XL(za[za[0]-1])<i*iXL(za[za[0]],za[za[0]-1]);za[0]--);
		f[i]=max(JS(za[za[0]],i),f[i-1]);
		for(;za[0]>1&&(XL(za[za[0]])-XL(za[za[0]-1]))*iXL(i,za[za[0]])<
			(XL(i)-XL(za[za[0]]))*iXL(za[za[0]],za[za[0]-1]);za[0]--);
		za[++za[0]]=i;
	}
}
void divide(int l,int r)
{
	if(l==r){h[l]=max(h[l],1-a[l]);return;}
	int mid=(l+r)>>1;
	za[0]=0;
	fo(i,mid+1,r)
	{
		for(;za[0]>1&&(XLg(za[za[0]])-XLg(za[za[0]-1]))*iXL(i,za[za[0]])<
			 (XLg(i)-XLg(za[za[0]]))*iXL(za[za[0]],za[za[0]-1]);za[0]--);
		za[++za[0]]=i;
	}
	LL mx=-2e16;
	fo(i,l,mid)
	{
		for(;za[0]>1&&XLg(za[za[0]])-XLg(za[za[0]-1])<i*iXL(za[za[0]],za[za[0]-1]);za[0]--);
		int q=za[za[0]];
		mx=max(mx,f[i-1]+g[q+1]-sum[q]+sum[i-1]+(LL)(q-i+1)*(LL)(q-i+2)/2);
		h[i]=max(h[i],mx);
	}
	divide(l,mid);
	divide(mid+1,r);
}
int main()
{
	int q,w;
	read(n);
	fo(i,1,n)read(a[n-i+1]),h[i]=h1[i]=-2e16;
	fo(i,1,n)sum[i]=sum[i-1]+(LL)a[i];
	Doit();
	fo(i,1,n)g[n-i+1]=f[i];
	fo(i,1,n/2)swap(a[i],a[n-i+1]);
	fo(i,1,n+1)sum[i]=sum[i-1]+(LL)a[i];
	Doit();
	divide(1,n);
	fo(i,1,n/2)swap(a[i],a[n-i+1]);
	fo(i,1,n+1)sum[i]=sum[i-1]+(LL)a[i],swap(f[n-i+1],g[i]),swap(h[i],h1[i]);
	divide(1,n);
	fo(i,1,n/2)swap(h[i],h[n-i+1]);
	fo(i,1,n)h[i]=max(h[i],h1[i]),swap(f[n-i+1],g[i]);
	fo(i,1,n/2)swap(a[i],a[n-i+1]);
	read(m);
	fo(i,1,m)
	{
		read(q),read(w);
		printf("%lld\n",max(g[q+1]+f[q-1],h[q]+(LL)a[q]-(LL)w));
	}
	return 0;
}

Measured memory_bytes: 16640
n, k = map(int, input().split())
A = list(map(int, input().split()))
d = {}
for i, a in enumerate(A):
    d[i + 1] = int(a)

l = 1
nxt = d[1]
is_visit = [False for _ in range(n + 1)]
is_visit[1] = 0
while is_visit[nxt] is False:
    is_visit[nxt] = l
    l += 1
    nxt = d[nxt]
c = is_visit[nxt]
lc = l - is_visit[nxt]

if k <= c:
    r = 1
    for _ in range(k):
        r = d[r]
    print(r)
else:
    r = nxt
    m = (k - c) % lc
    for _ in range(m):
        r = d[nxt]
        nxt = d[nxt]
    print(r)


Measured memory_bytes: 41172
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= c && c <= b)cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
import java.util.*;
import java.util.function.ToDoubleFunction;


public class Main {
//    private static final String ex = "3\n" +
//            "1 10 100";
    private static final String ex = "6\n" +
        "2 7 1 8 2 8";
//    private static final String ex = "2\n" +
//        "1 1";
//    private static final String ex = "3\n" +
//        "1 4 1";
//    private static final String ex = "4\n" +
//            "1 2 3 4";

    public static void main(String[] args) {
        solve(new Scanner(System.in));
//        solve(new Scanner(ex));
    }

    private static void solve(Scanner scanner) {
        Integer N = Integer.parseInt(scanner.nextLine());

        int even2 = 0;
        int even4 = 0;
        int odd = 0;
        String split[] = scanner.nextLine().split(" ");
        for (int i = 0; i < N; i ++) {
            int num = Integer.parseInt(split[i]);

            if (num % 2 == 1) {
                odd ++;
            } else if (num % 4 == 0) {
                even4 ++;
            } else {
                even2 ++;
            }
        }

        if (even2 > 0) odd ++;

        String result = odd > (even4 + 1) ? "No" : "Yes";

        System.out.println(result);
    }
}


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

using namespace std;

int main(int argc, char* argv[])
{
	vector<vector<char>> table;

	int H, W;
	cin >> H;
	cin >> W;

	for( int i = 0; i < H; i++ ) {
		vector<char> row;
		for( int j = 0; j < W; j++ ) {
			char c;
			cin >> c;
			row.push_back(c);
		}
		table.push_back(row);
	}

	for( int i = 0; i < H; i++ ) {
		for( int j = 0; j < W; j++ ) {

			bool is_come = false;
			int count = 0;
			for( int k = j; -1 < k; k--, count++ ) {
				char c = table[i][k];
				if( c == 'c' ) {
					cout << count;
					if( j != W-1 ) cout << " ";
					is_come = true;
					break;
				}
			}
			if( !is_come ) {
				cout << -1;
				if( j != W-1 ) cout << " ";
			}
		}
		cout << endl;
	}

    return 0;
}

Measured memory_bytes: 3168
#include <stdio.h>

int main(void)
{
int a, b, c;
int i, count;

scanf("%d %d %d", &a, &b, &c);

count = 0;
for(i=a;i<=b;i++){
if(c%i==0)
count++;
}
printf("%d\n", count);
return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 10
class Team{
    public:
    char name;
    int id, win, defeat, draw;
    Team( int id=0, char name=' ', int win=0, int defeat=0, int draw=0 ): id(id), name(name), win(win), defeat(defeat), draw(draw){}
    bool operator < ( const Team &t ) const{
	if ( win == t.win ){
	    if ( defeat == t.defeat ) return id < t.id;
	    else return defeat < t.defeat;
	} else return win > t.win;
    }
};

main(){
    Team T[MAX];
    int n, x;
    while( cin >> n && n ){
	for ( int i = 0; i < n; i++ ) {
	    T[i] = i;
	    cin >> T[i].name;
	    T[i].defeat = T[i].win = T[i].draw = 0;
	    for ( int j = 0; j < n-1; j++ ){
		cin >> x;
		if ( x == 0 ) T[i].win++;
		else if ( x == 1 ) T[i].defeat++;
		else if ( x == 2 ) T[i].draw++;
	    }
	}
	sort( T, T + n );
	for ( int i = 0; i < n; i++ ){
	    cout << T[i].name << endl;
	}
    }
}

Measured memory_bytes: 0
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    const char Wh = '.';
    const char Bl = '#';
    const char Sp = ' ';

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var k = int.Parse(spl[1]);

        var pR = new List<int>();
        var pL = new List<int>();

        spl = input.ReadLine().Split(' ');
        for (int z = 0; z < n; z++) {
            var x = int.Parse(spl[z]);
            if (x < 0) {
                pL.Add(Math.Abs(x));
            } else if(x > 0) {
                pR.Add(Math.Abs(x));
            } else {
                k--;
                if (k == 0) return 0;
            }
        }

        pR.Sort();
        pL.Sort();

        long min = int.MaxValue;
        int i = Math.Min(pR.Count - 1, k-1);
        int j = k - (i + 1) - 1;

        while(true) {
            var cr = i >= 0 ? pR[i] : 0;
            var cl = j >= 0 ? pL[j] : 0;

            min = Math.Min(min, cr + cl * 2);
            min = Math.Min(min, cl + cr * 2);

            i--;
            j++;
            if (j >= pL.Count || j > k) break;
        }

        return min;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 20576
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

signed main() {
  ll N, M;
  cin >> N >> M;
  vector<P> ans;

  rep(i, N) {
    ans.pb({0, 0});
  }

  ll countWA = 0;
  rep(i, M) {
    ll p;
    string s;
    cin >> p >> s;
    p--;
    if (ans[p].first == 1) {
      continue;
    }
    if (s == "AC") {
      ans[p].first = 1;
      countWA += ans[p].second;
    } else {
      if (ans[p].first == 0) {
        ans[p].second += 1;
      }
    }
  }

  P sum = {0, 0};
  rep(i, N) {
    // debug(i);
    // debug(ans[i].second);
    sum.first += ans[i].first;
    // sum.second += ans[i].second;
  }

  cout << sum.first << " " << countWA << endl;
  return 0;
}

Measured memory_bytes: 2420
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
      
if __FILE__ == $0
  i = 1
  while line = STDIN.gets
    tokens = line.chomp!.split.map!(&:to_i)
    x = tokens[0].to_i
    break if x == 0
    puts "Case #{i}: #{x}"
    i += 1
  end
end

Measured memory_bytes: 8780
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,a,b;
  cin >> n >> a >> b;
  if(n==1&&a<b)cout << 0;
  else if(a>b)cout << 0;
  else cout << (a+b*(n-1))+1-(b+a*(n-1));
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	int n,cnt=0,ans=inf,w[100];
	cin>>n;
	rep(i,0,n)cin>>w[i],cnt+=w[i];
	int tmp=0;
	rep(i,0,n-1){
		tmp+=w[i];
		cnt-=w[i];
		ans=min(ans,abs(tmp-cnt));
	}

	print(ans);
}

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

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> a(n);

    int max = -1;
    int index = 0;
    for(int i = 0;i < n; i++){
        cin >> a[i];
        if(max < a[i]){
            max = a[i];
            index = i;
        }
    }

    sort(a.begin(),a.end(),greater<int>());

    int max2 = a[1];
    for(int i = 0;i < n; i++){
        if(index == i)cout << max2 << endl;
        else cout << max << endl;
    }

    return 0;
}

Measured memory_bytes: 2432
n=int(input())
if n<=2:
  print(0)
  exit()
count=0
a = input().split(" ")
lista = [int(n) for n in a]

for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      b=lista[i]
      c=lista[j]
      d=lista[k]
      if b==c or c==d or d==b or b==c==d:
        continue
      if b+c>d and c+d>b and b+d>c:
        count+=1
print(count)
      

Measured memory_bytes: 9116