akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

long long POW(long long x, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 1) return (x * POW(x, n - 1));
    long long t = POW(x, n / 2);
    return (t * t);
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> A(N);
    vector<long long> sum(N+1, 0);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
        sum[i+1] = sum[i] + A[i];
    }
    
    vector<long long> B;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j <= N; j++) {
            B.emplace_back(sum[j]-sum[i]);
        }
    }
    
    vector<bool> ok(B.size(), true);
    long long ans = 0;
    long long t = POW(2LL, 40LL);
    int s = 40;
    while (t > 0) {
        int cnt = 0;
        for (int i = 0; i < (int)B.size(); i++) if (ok[i]) {
            if (B[i]&t) cnt++;
        }
        if (K <= cnt) {
            ans += (1LL<<s);
            for (int i = 0; i < (int)B.size(); i++) if (ok[i]) {
                if (!(B[i]&t)) B[i] = false;
            }
        }
        t /= 2;
        s--;
    }
    
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 6388
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Pair[] p = new Pair[n];
		for (int i = 0; i < n; i++)
			p[i] = new Pair(scanner.nextInt(), scanner.nextInt());
		Arrays.sort(p);
		int ans = 1 << 25;
		for (int i = 0; i < n - 1; i++)
			for (int j = i; j >= 0; j--) {
				int dx = p[i + 1].x - p[j].x;
				int dy = p[i + 1].y - p[j].y;
				if (dx * dx >= ans)
					break;
				ans = Math.min(ans, dx * dx + dy * dy);
			}
		System.out.println(ans);
	}

	class Pair implements Comparable<Pair> {
		int x, y;

		@Override
		public String toString() {
			return "Pair [x=" + x + ", y=" + y + "]";
		}

		public Pair(int x, int y) {
			super();
			this.x = x;
			this.y = y;
		}

		@Override
		public int compareTo(Pair o) {
			return x - o.x;
		}

	}
}

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

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
    
    int64_t N;
    cin >> N;
    vector<int64_t> num(60);
    for(int i=0; i<N; i++) {
        int64_t A;
        cin >> A;
        for(int j=0; j<60; j++) {
            if(A & (1LL << j)) {
                ++num[j];
            }
        }
    }

    int64_t ans = 0;
    for(int j=0; j<60; j++) {
        ans = (((((1LL << j) % MOD * num[j]) % MOD) * (N-num[j]) % MOD) + ans) % MOD;
    }

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


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] d = new int[N];
		for(int i = 0; i < N; i++) {
			d[i] = sc.nextInt();
		}
		sc.close();
		
		Arrays.sort(d);
		int result = d[N/2] - d[N/2 - 1];
		System.out.println(result);
	}
}

Measured memory_bytes: 51088
#include <bits/stdc++.h>
 
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%lf",&x)
#define sl(x) scanf("%lld",&x)
#define pr(x) printf("%d\n",x)
#define prll(x) printf("%lld\n",x)
 
#define ll long long int
#define ull unsigned long long int
#define F first
#define S second
 
#define rep(i,x,y) for(int i=x;i<y;i++)
#define ii pair<int,int> 
#define pll pair<ll,ll> 
#define vi vector<int> 
#define vvi vector< vi > 
#define vl vector<long long int>
#define vvl vector< vl >
#define vii vector< ii >
#define vvii vector< vii >
#define priority_queue pq;
#define sz(a) ll((a).size()) 
#define pb push_back 
#define mp make_pair
 
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end() 
#define tr(i,c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ison(x,i) (((x) >> (i)) & 1)	//checks if ith bit is on
#define set0(x,i) (x & ~(1 << i))		//set ith bit in x to be zero
#define clr(a) memset(a,0,sizeof(a))
 
#define MOD 1000000007
#define INF 4000000000000000000
#define MAX 10+5
using namespace std;

int a[MAX];

int main()
{
	int n,odd=0,even=0;
	si(n);
	rep(i,0,n)
	{
		si(a[i]);
		if(a[i]%2)
			odd++;
		else
			even++;
	}
	int ans = pow(3,n) - pow(2,even);
	pr(ans);
	return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define x first
#define y second
typedef long long LL;
typedef pair<int, int> PII;
void R(char &c){c = getchar();};void R(string &s){scanf("%s",s.c_str());}void R(char s[]){scanf("%s",s);}template<typename T>void R(T&x){int f=1;x=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch-48);ch=getchar();}x*=f;}template<typename T,typename...Args>void R(T&x,Args&...args){R(x),R(args...);}void _W(const string&s){printf("%s",s.c_str());}void _W(const char&c){putchar(c);};void _W(const char s[]){printf("%s",s);}template<typename T>void _W(T x){if(x<0){putchar('-');x=-x;}static int dig[130];int top=0;do{dig[top++]=x%10,x/=10;}while(x);while(top)putchar(dig[--top]+48);}template<typename T>void _W(const vector<T> a){for(int i=0;i<SZ(a);++i)_W(a[i]),putchar(' ');}void W(){}template<typename T,typename...Args>void W(const T&x,const Args&...args){_W(x);putchar(sizeof...(args)?' ':'\n');W(args...);}


void solve(){
	LL n, m;
	R(n, m);
	n = -n;
	LL ans = n % m;
	ans = (ans % m + m) % m;
	W(min(ans, -n % m));
}

signed main(){
	//int T; R(T); while(T -- )
	solve(); return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n), bad(n, 0);
    for(int i = 0; i < k; i++){
        int m;  cin >> m;
        while(m-- > 0){
            int x;  cin >> x;
            v[--x] = i;
        }
    }
    int r;  cin >> r;
    while(r-- > 0){
        int p, q;
        cin >> p >> q;
        if(v[--p]==v[--q])  bad[p] = bad[q] = 1;
    }
    cout << accumulate(bad.begin(), bad.end(), 0) << endl;
    return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59



int main(){
  ll i,j;
  ll n,k;
  cin>>n>>k;

  if(2*k>(n-1)*(n-2)) {
    cout<<-1<<endl;
    return 0;
  }

  ll ge=((n-1)*(n-2))/2-k;

  ll m=n-1+ge;
  cout<<m<<endl;
  for(i=1;i<n;i++){
    cout<<1<<" "<<i+1<<endl;
  }
  vector<P> v;
  for(i=2;i<=n;i++){
    for(j=i+1;j<=n;j++) v.pb(P(i,j));
  }
  for(i=0;i<ge;i++){
    cout<<v[i].fi<<" "<<v[i].se<<endl;
  }

  return 0;  
}

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

int main() {
	string S;
	cin >> S;
	long long K; // 5000兆 = 5e+15
	cin >> K;
	int flag = 0, point = -1;
	if (K <= 100) {
		for (int i = 0; i < K; i++) {
			if (S.at(i) != '1') {
				flag = 1;
				point = i;
				break;
			}
		}
		if (flag == 1) {
			cout << S.at(point) << endl;
		} else {
			cout << 1 << endl;
		}
	} else {
		for (int i = 0; i < (int)S.size(); i++) {
			if (S.at(i) != '1') {
				cout << S.at(i) << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;



int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    long long  ans=0;
    
    int n;
    cin>>n;
    
    vector<long long> a(n);
    for(auto &i: a){
        cin>>i;
    }
    
    long long mel=*max_element(a.begin(),a.end());
    
    //long long stepsTot=0;
   
    while(mel>n-1){
        long long stepsTot=0;
        vector<long long> steps(n,0);
        for(int i=0; i<n; i++){
            if(a[i]>n-1){
                steps[i]=max((a[i]-n+1)/n,1ll);
                stepsTot+=steps[i];
            }
        }
        for(int i=0; i<n; i++){
            //cout<<steps[i]<<" ";
            a[i]=a[i]+stepsTot-steps[i]*(n+1);
        }
        ans+=stepsTot;
        mel=*max_element(a.begin(),a.end());
    }/*
    for(int i:a){
        cout<<i<<" ";
    }*/
    
    cout<<ans;
    
    
    
    
    
    return 0;
}

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

int main()
{
    int i = 0;
    int consequenece = 0, ans = 0;
    char ch;
    while (scanf("%c", &ch) != EOF)
    {
        if (ch == 'A' || ch == 'C' || ch == 'G' || ch == 'T')
        {
            consequenece++;
        }
        else
        {
            ans = max(ans, consequenece);
            consequenece = 0;
        }
    }
    cout << ans << endl;
}


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

using vi = vector<int>;

int main()
{
    ios_base::sync_with_stdio(0);

    int n, k; cin >> n >> k;

    map<int, int> mp;

    for(int i = 0; i < n; i++)
    {
        int x; cin >> x;

        mp[x]++;
    }

    vi v;

    for(auto& pr : mp)
        v.push_back(pr.second);

    sort(v.rbegin(), v.rend());

    int ans = 0;

    for(int i = k; i < int(v.size()); i++)
        ans += v[i];

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

Measured memory_bytes: 10744
n = int(input())
ans = ''

for i in range(1, 30):
    if n <= 26**i:
        n -= 1
        for j in range(i):
            ans += chr(ord('a') + n % 26)
            n //= 26
        break
    else:
        n -= 26**i

print(ans[::-1])


Measured memory_bytes: 9172
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n;
	cin>>n;
	if(n<1000) cout<<"ABC\n";
	else cout<<"ABD\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mx = 3005;

int n, a[mx];
int vis[mx][mx][2];
long long dp[mx][mx][2];

long long fun(int i, int j, int t){
    if(i > j) return 0;

    long long &ans = dp[i][j][t];
    if(vis[i][j][t]) return ans;
    vis[i][j][t] = 1;

    ans = a[i] - fun(i+1, j, !t);
    ans = max(ans, a[j] - fun(i, j-1, !t));
    return ans;
}

int main(){

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

    cin >> n;
    for(int i=0; i<n; i++) cin >> a[i];
    cout << fun(0, n-1, 0) << "\n";
    return 0;
}


Measured memory_bytes: 131816
#include<bits/stdc++.h>
using namespace std;
void solve(){
  vector<int>count(1000005);
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    count[k]++;
  }
  int ans=0;
  vector<int>vis(1000005,0);
  for(int i=1;i<=1000000;i++){
    if(count[i]==0||vis[i])
      continue;
    if(count[i]==1&&!vis[i])
      ans++;
    for(int j=i;j<=1000000;j+=i)
      vis[j]=1;
  }
  cout<<ans;
}
    
int main(){
  solve();
  return 0;
}
  

Measured memory_bytes: 11172
N = int(input())
a = list(map(int,input().split()))
ma = max(a)
maketa = len(bin(ma))-2
res = 0
dic = {}
for i in range(maketa):
    dic[i] = 0
for i in range(0,maketa):
    num = 0
    for elem in a:
        dic[i] += int((elem & (2**i))>>i)
for i in range(maketa):
    num = dic[i]
    res += num*(N-num)*(2**(i))
print(res%(10**9+7))


Measured memory_bytes: 122936
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, A: "List[int]"):
    acc = list(accumulate(A))
    li = 1
    rdiff = float('inf')
    ri = 0
    for i in range(3, len(acc)):
        d = acc[-1] - acc[i-1]
        c = acc[i-1] - acc[1]
        if abs(d - c) < rdiff:
            rdiff = abs(d -c)
            ri = i
    ci = 2

    def _g(li, ci, ri):
        a = acc[li - 1]
        b = acc[ci - 1] - acc[li-1]
        c = acc[ri - 1] - acc[ci - 1]
        d = acc[-1] - acc[ri - 1]
        cr = max([a, b, c, d]) - min([a, b, c, d])
        return cr

    def _f(h, m, l):
        bbb = acc[l-1] if 0 < l else 0
        return abs((acc[h - 1] - acc[m-1]) - (acc[m - 1] - bbb))
  
    r = _g(li, ci, ri)
    for i in range(3, len(acc) - 1):
        while _f(i, (li+1), 0) <  _f(i, li, 0):
            li += 1
        while _f(len(acc), (ri+1), i) <  _f(len(acc), ri, i):
            ri += 1
        cr = _g(li, i, ri)
        if cr < r:
            r = cr
    return r


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, A)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 36544
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
    int n;
    cin >> n;
    vector<int> v;
    for(int i = 0; i < n; i++){
        int temp;
        cin >> temp;
        v.push_back(temp);
    }
    bool w = true;
    for(const int& i : v){
        if(i & 1){
           w ^= 1;
           break;
        }
    }
    
    if(w) cout << "second";
    else cout << "first";
    
    return 0;
}

Measured memory_bytes: 3924
import heapq

x,y,a,b,c = map(int,input().split())
p_list = list(map(int,input().split()))
q_list = list(map(int,input().split()))
r_list = list(map(int,input().split()))

p_target = heapq.nlargest(x, p_list)
q_target = heapq.nlargest(y, q_list)
r_target = heapq.nlargest(c, r_list)

p_target.extend(q_target)
p_target.extend(r_target)

p_target.sort(reverse=True)
print(sum(p_target[:x+y]))

Measured memory_bytes: 31136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int n, m;
vector<int> par;
vector<int> siz;

int root(int x) {
  while (x != par[x]) {
    x = par[x];
  }
  return x;
}

bool merge(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y) return false;
  if (siz[x] < siz[y]) swap(x, y);
  siz[x] += siz[y];
  par[y] = x;
  return true;
}

int main() {
  int ans = 0;
  cin >> n >> m;
  vector<pair<int, int>> p(m);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    p[i] = make_pair(a, b);
  }
  rep(i, m) {
    par.resize(n);
    siz.resize(n);
    rep(i, n) par[i] = i;
    rep(i, n) siz[i] = 1;
    rep(j, m) {
      if (i == j) continue;
      merge(p[j].first, p[j].second);
    }
    if (root(p[i].first) != root(p[i].second)) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
  n,m=map(int,input().split())
  ab=[list(map(int,input().split()))for _ in range(m)]
  g=[[]for _ in range(n)]
  for a,b in ab:
    g[a-1].append(b-1)
    g[b-1].append(a-1)
  from collections import deque
  todo=deque([0])
  seen=[-1]*n
  seen[0]=0
  while todo:
    t=todo.popleft()
    l=g[t]
    for li in l:
      if seen[li]==-1:
        seen[li]=t
        todo.append(li)
  print('Yes')
  for si in seen[1:]:
    print(si+1)
if __name__=='__main__':
  main()


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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
using namespace std;
typedef long long int ll;
vector<int> ve(3006, 0);
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	int i = 0;
	long long a;
	long long sum=100;
	cin>>a;
	while(sum<a){
		if(a-sum*1/100<=sum){
			i++;
			break;
		}
		else{
			sum=sum+(sum)*1/100;
			i++;

		}
	}
	cout << i;

}

Measured memory_bytes: 3624
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){

	int a, b;
	cin >> a>> b;
	if(a<b){
		cout << "a < b" << endl;
	}
	if (a > b){
		cout << "a > b" << endl;
	}
	if (a == b){
		cout << "a == b" << endl;
	}
	return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define fo(i, n) for(int i = 1; i <= n; ++i)
#define rep(i, a, b) for(int (i) = (a); (i) < (b); ++(i))

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 200200;
const int mod = 1e9 + 7;
const ll INF = 1e18;

ll n, s,b[N],a[N];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	fo(i,n)
		cin>>a[i];
	ll s=0;
	multiset<ll> cur;
	for(int i=1;i<=n;++i)
		cur.insert(a[i]);
	ll multisum=0;
	for(int i=1;i<=n;++i)
		multisum+=a[i];
	ll already=0;
	for(int i=1;i<=n;++i)
	{
		ll s=0;
		a[i]-=already;
		if(a[i]<=0) 
		{
			cout<<0<<"\n";
			continue;
		}
		while((*cur.begin())-already<=a[i]&&cur.size()>0)
			s+=max(0ll,*cur.begin()-already),cur.erase(cur.begin());
		s+=cur.size()*a[i];
		already+=a[i];
		cout<<s<<'\n';
	}
	return 0;	
}

Measured memory_bytes: 6656
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef vector<vector<int>> vvi;

int main() {
	int N;
	cin>>N;
	vvi tree(N);
	for (int i = 1; i < N; i++){
		int a;
		cin>>a;
		tree[a-1].push_back(i);
	}
	for (int i = 0; i < N; i++){
		cout<<tree[i].size()<<endl;
	}
}

Measured memory_bytes: 20376
H,W,K=map(int,input().split())
mod=10**9+7
fib=[1,1,2,3,5,8,13,21]
memo=[[None]*W for _ in range(H+1)]
def dfs(cur,now):
    if cur==H:
        if now==K:
            return 1
        else:
            return 0
    elif now==1:
        if W==1:
            if memo[cur+1][0]==None:
                memo[cur+1][0]=dfs(cur+1,1)%mod
            return memo[cur+1][0]
        else:
            if memo[cur+1][0]==None:
                memo[cur+1][0]=dfs(cur+1,1)%mod
            if memo[cur+1][1]==None:
                memo[cur+1][1]=dfs(cur+1,2)%mod
            return (fib[W-1]*memo[cur+1][0]+fib[W-2]*memo[cur+1][1])%mod
    elif now==W:
        if memo[cur+1][W-2]==None:
            memo[cur+1][W-2]=dfs(cur+1,W-1)%mod
        if memo[cur+1][W-1]==None:
            memo[cur+1][W-1]=dfs(cur+1,W)%mod            
        return (fib[W-2]*memo[cur+1][W-2]+fib[W-1]*memo[cur+1][W-1])%mod
    else:
        if memo[cur+1][now-2]==None:
            memo[cur+1][now-2]=dfs(cur+1,now-1)%mod
        if memo[cur+1][now-1]==None:
            memo[cur+1][now-1]=dfs(cur+1,now)%mod     
        if memo[cur+1][now]==None:
            memo[cur+1][now]=dfs(cur+1,now+1)%mod  
        return (fib[W-now]*fib[now-2]*memo[cur+1][now-2]+fib[W-now]*fib[now-1]*memo[cur+1][now-1]+fib[W-now-1]*fib[now-1]*memo[cur+1][now])%mod
    
print(dfs(0,1))

Measured memory_bytes: 3192
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

int f(vi& a) {
  int l,r;
  scanf("%d%d",&l,&r);
  --l;
  return (a[r]-a[l]+MX*3)%3;
}

int main() {
  string s, t;
  cin>>s>>t;
  vi a, b;
  a = b = vi(1);
  rep(i,sz(s)) a.pb(s[i]=='A'?1:2);
  rep(i,sz(t)) b.pb(t[i]=='A'?1:2);
  rep(i,sz(a)-1) {
    a[i+1] += a[i];
    a[i+1] %= 3;
  }
  rep(i,sz(b)-1) {
    b[i+1] += b[i];
    b[i+1] %= 3;
  }
  int q;
  scanf("%d",&q);
  rep(qi,q) {
    int x = f(a);
    int y = f(b);
    // cout<<x<<" "<<y<<endl;
    if (x == y) puts("YES");
    else puts("NO");
  }
  return 0;
}






















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

const int maxn = 1e5+10;

const int inf = 1e8;

int nxt[maxn << 1][26];


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s ;
	string s1;
	cin >> s >> s1;
	int n = s.length();
	int n1 = s1.length();
	s += s;

	for(int i=0;i<n * 2;i++) {
		for(int j=0;j<26;j++) {
			nxt[i][j] = inf;
		}
	}
	for(int i=0;i<n * 2;i++) {
		char c = s[i] - 'a';
		for(int j=i-1;j>=0;j--) {
			nxt[j][c] = i < n ? i : i - n;
			if (s[i] == s[j]) break;
		}
	}

	int cur = -1;
	for(int i=0;i<n;i++) {
		if (s[i] == s1[0]) {
			cur = i;
			break;
		}
	}

	if (cur == -1) {
		cout << -1;
		return 0;
	}

	int cnt = 0;
	for(int i=1;i<n1;i++) {
		int t = nxt[cur][s1[i] - 'a'];
		if (t <= cur) cnt ++;
		cur = t;
		if (cur == inf) {
			cout << -1;
			return 0;
		}
	}
	cout << 1ll * cnt * n + cur + 1;
	return 0;
}


Measured memory_bytes: 20972
#include<stdio.h>
int main(void)
{
	int a,b,c,i,n;
	b=0;
	c=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(a==0){
			b=0;
		}
		if(a==1){
			b=b+1;
		}
		if(c<b){
			c=b;
		}
	}
	c=c+1;
	printf("%d\n",c);
	
	return 0;
}



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

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

    int ans = 0;
    if (a < 0) ans += abs(a) * c;
    if (a <= 0) ans += d;
    cout << ans + e * (b - max(a, 0)) << endl;

    return 0;
}


Measured memory_bytes: 3096
# include <bits/stdc++.h>
using namespace std;
namespace Base{
	# define mr make_pair
	typedef long long ll;
	typedef double db;
	const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
	const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
	template<typename T> void read(T &x){
    	x = 0; int fh = 1; double num = 1.0; char ch = getchar();
		while (!isdigit(ch)){ if (ch == '-') fh = -1; ch = getchar(); }
		while (isdigit(ch)){ x = x * 10 + ch - '0'; ch = getchar(); }
	    if (ch == '.'){
	    	ch = getchar();
	    	while (isdigit(ch)){num /= 10; x = x + num * (ch - '0'); ch = getchar();}
		}
		x = x * fh;
	}
	template<typename T> void chmax(T &x, T y){x = x < y ? y : x;}
	template<typename T> void chmin(T &x, T y){x = x > y ? y : x;}
}
using namespace Base;

const int N = 5010, P = 1e9 + 7;
int mul[N], f[N][N], n, m;
int main(){
	read(n); read(m);
	for (int i = 0; i <= m; i++) f[0][i] = 1;
	for (int i = 1; i <= n; i++){
		int tot = 0;
		for (int j = 1; j <= m; j++){
			f[i][j] = (j + 1ll) * f[i - 1][j] % P;
			tot = (tot * 2ll + f[i - 1][j - 1] * (j - 1ll)) % P;
			f[i][j] = (f[i][j] + tot) % P;
		}
	}
	printf("%d\n", f[n][m]);
	return 0;
}



Measured memory_bytes: 101524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        ll n; cin >> n;
        vll x(n);
        ll tot =0;
        rep(i,n){
            cin >> x[i];
            tot +=x[i];
        }
        tot /=n;
        ll mn = 1000000000;
        for(ll k:{0,1}){
            ll temp=0;
            rep(i,n){
                temp += (x[i]-tot-k)*(x[i]-tot-k);
            }
            mn = min(mn,temp);
        }
        cout << mn << endl;

    }
}


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

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(a) (a).begin(),(a).end()
#define CHMIN(a, b) a = min((a),(b))
#define CHMAX(a, b) a = max((a),(b))
const int INF = 1e9;
const int MOD = 1e9 + 7;

string ZeroPadding(int a, int len) {
    string s = to_string(a);
    string res(len - s.length(), '0');
    res += s;
    return res;
}

signed main() {
    int n;
    cin >> n;
    cout << "ABC" << ZeroPadding(n, 3) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		
		if (S[i]== '1') {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}


int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

//#############################
const int MAXN = 1000005;

int main() {
    string s = "abcdefghijklmnopqrstuvwxyz";
    char c = getchar();
    for (int i = 0; i < s.size(); i++)
        if (c==s[i])
            cout << s[i+1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std ; 
int main() {
	string s;
	
	getline(cin,s);
	
	int n = s.size();
	
	for (int i = 0; i < n; i++)
	{
		if(i == 5  || i == 13)
		{
			s.replace(5,1," ");
			s.replace(13,1," ");
		}
	}
	
	cout << s << endl;
	
}

Measured memory_bytes: 2936
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <numeric>
#define ll long long 
#define Y "YES"
#define N "NO"
#define elif else if
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define rep(i,a,n) for(int i=a; i<n; i++)
#define per(i,a,n) for(int i=n; i>=0; i--)
#define pii pair<int,int>
#define wolfe ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
int main () { 
    wolfe;
    int n,x,t;
    cin >> n >> x >> t;
    int cnt=0;
    if(n%x==0) cnt = n/x;
    else cnt = (n/x)+1;
    cout << cnt*t << endl;
    return 0;
}

Measured memory_bytes: 3624
import math
K = int(input())
A = list(map(int,input().split()))
a = 1
L,S = 2,2 

while a <= K:
    if math.ceil(S/A[-a])*A[-a] < S or L < math.ceil(S/A[-a])*A[-a]:
        print('-1')
        exit()
    S = math.ceil(S/A[-a])*A[-a]
    L = math.floor(L/A[-a])*A[-a] + A[-a] -1
    a += 1
print(S,L)

    


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

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

  string subS;
  string leftS, rightS;
  int maxLength = 1;

  for (int i = 1; i < S.size() - 1; i++)
  {
    subS = S;
    for (int j = 0; j < i; j++)
    {
      subS.erase(subS.end() - 1);
    }
    
    if (subS.size() % 2 == 0){
      leftS = subS.substr(0, subS.size() / 2);
      rightS = subS.substr(subS.size() / 2, subS.size() / 2);
      if (leftS == rightS){
        maxLength = subS.size();
        break;
      }
    }
    
    
  }

  cout << maxLength << endl;  
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	string s;
	cin>>s;
	vector <int> a(4);
	rep(i,4)a.at(i)=s.at(i)-'0';
	vector<int> op(3);
	bool flag = false;
	for(int i=-1;i<3;i+=2){
		for(int j=-1;j<3;j+=2){
			for(int k=-1;k<3;k+=2){
				op.at(0)=i;
				op.at(1)=j;
				op.at(2)=k;
				if(a.at(0)+a.at(1)*i+a.at(2)*j+a.at(3)*k==7)flag=true;
				if(flag)break;
			}
			if(flag)break;
		}
		if(flag)break;
	}
	rep(i,3)cout<<a.at(i)<<(op.at(i)==1?"+":"-");
	cout<<a.at(3)<<"=7"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

int main(void) {
    int g;
    constexpr int D = 365;
    cin >> g;
    // int D; cin >> D;
    vector<int> c(26);
    for(int i=0; i<26; i++) {
        cerr << i << endl;
        cin >> c[i];
    }
    vector< vector<int> > s(D, vector<int>(26));
    for(int i=0; i<D; i++) {
        for(int j=0; j<26; j++) {
            cerr << i << ' ' << j << endl;
            cin >> s[i][j];
        }
    }

    for(int i=0; i<D; i++) {
        cerr << i << endl;
        cout << distance(s[i].begin(), max_element(s[i].begin(), s[i].end())) + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3680
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    a, b, c, d = map(int, rl().split())
    ans = max(a * c, a * d, b * c, b * d)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 61740
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    
    print(a[0]+1-a[1])

Measured memory_bytes: 3828
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, x = map(int, input().split())
    A = sorted(list(map(int, input().split())))

    res = 0
    for i in range(n):
        if i == n - 1 and A[i] < x:
            continue

        if A[i] <= x:
            x -= A[i]
            res += 1

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 38256
#include <stdio.h>

int main(){
	int a1, a2, a3;
	
	scanf("%d %d %d", &a1, &a2, &a3);
	if (a1 + a2 + a3 >= 22){
		printf("bust\n");	
	}
	else {
		printf("win\n");
	}
	return 0;
}

Measured memory_bytes: 3124
#include <stdio.h>
 
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
int pre[45], ind[45];
int post[45], sz, pos;
int idx[45];
 
void rebuild(int l, int r)
{
    int c, m;
 
    if (l >= r) return;
    c = pre[pos++];
    m = idx[c];
    rebuild(l, m);
    rebuild(m+1, r);
    post[sz++] = c;
}
 
int main()
{
    int n, i;
 
    n = in();
    for (i = 0; i < n; i++) pre[i] = in();
    for (i = 0; i < n; i++) idx[in()] = i;
 
    sz = 0, pos = 0;
    rebuild(0, n);
     
    printf("%d", post[0]);
    for (i = 1; i < n; i++) {
        putchar(' '), printf("%d", post[i]);
    }
    putchar('\n');
    return 0;
}



Measured memory_bytes: 2096
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;


for pair in listA:
	n = pair[0]
	x = pair[1]
	
	if n == 0 and x == 0:
		break
	
	result = 0
	for a in range(1, n-1):
		for b in range(a+1, n):
			for c in range(b+1, n+1):
				if a + b +c == x:
					result+=1
	print(result)


Measured memory_bytes: 5600
#ifdef __GNUC__
#include <bits/stdc++.h>
#endif // __GNUC_

int main() {

    int r, D, x2000;
    std::cin >> r >> D >> x2000;
    int x200i = x2000;
    for (int i = 0; i < 10; ++i) {
        x200i = r * x200i - D;
        std::cout << x200i << std::endl;
    }

}

Measured memory_bytes: 256
N = int(input())
T = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        x -= 1
        T[i].append((x, y))

ans = 0
for i in range(1 << N):
    isPossible = True
    bit = [0] * N
    for k in range(N):
        if (i >> k) & 1:
            bit[k] = 1
    for idx, b in enumerate(bit):
        if b == 1:
            for x, y in T[idx]:
                isPossible &= (bit[x] == y)
    if isPossible:
        ans = max(ans, bit.count(1))
print(ans)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {
        public class TXY
        {
            public int T;
            public int X;
            public int Y;
        }

        public void Calc()
        {
            var NK = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var H = Console.ReadLine().Split().Select(x => long.Parse(x)).OrderByDescending(x => x).ToArray();

            Console.WriteLine(H.Where((x, i) => i >= NK[1]).Sum());


        }
    }
}

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

int main() {
  int A,B,C,K;
  int score = 0;
  cin >> A >> B >> C >> K;
  
  for (int i = 0; i < A; i++) {
    if (K == 0) break;
    else {
      score++;
      K--;
    }
  }
  
  for (int i = 0; i < B; i++) {
    if (K == 0) break;
    else {
      K--;
    }
  }
  
  for (int i = 0; i < C; i++) {
    if (K == 0) break;
    else {
      score--;
      K--;
    }
  }
  
  cout << score << endl;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back

typedef long long ll;
typedef pair<int,int> P;

//-----------------------------------------------------------------------

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

    int n,m;
while(cin>>n>>m,n|m)
{
    int cnt[11]={0};
    int sum=0;
    REP(i,n){
        int d,p; cin>>d>>p;
        cnt[p]+=d; sum+=d;
    }

    if(m>=sum) cout<<0<<endl;
    else{
        int ans=0;
        int rest=sum-m;
        for(int i=0;i<=10;i++){
            if(rest>cnt[i]) rest-=cnt[i],ans+=i*cnt[i];
            else{
                ans+=i*rest;
                break;
            }
        }
        cout<<ans<<endl;
    }
}
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
typedef long long ll;
#define min(a, b) ((a) < (b) ? (a) : (b))
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数
long long gcd(long long a, long long b)
{
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	// cout << std::fixed << std::setprecision(15);
	long N;
	cin >> N;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	long long res = A.at(0);
	for (int i = 1; i < N; i++) {
		res = gcd(res, A.at(i));
	}
	cout << res << endl;
	
}


Measured memory_bytes: 1152
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	vector<ll>abc(3); REP(i, 3)abc[i] = in();
	ll k = in();
	sort(ALL(abc));
	cout << abc[0] + abc[1] + abc[2] * [k]() {ll ans = 1; REP(i, k)ans *= 2; return ans; }() << endl;
}

Measured memory_bytes: 256
using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            
            string input = Console.ReadLine();
            int a = int.Parse(input);
            string s = Console.ReadLine();

            if(a >= 3200)
                Console.WriteLine(s);
            else
                Console.WriteLine("red");
    
        }
    }

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

int main(){
    string A;
    cin >> A;
    A = "!" + A;
    int N = A.size();
    set<char> st;
    int num = 1;
    vector<vector<int>> nxt(N, vector<int>(26, N));
    vector<int> now(26, N);
    vector<int> len(N+2);
    len[N] = 1;
    for(int i=N-1; i>=0; i--){
        st.insert(A[i]);
        if(st.size() == 26){
            num++;
            st.clear();
        }
        len[i] = num;
        for(int c=0; c<26; c++) nxt[i][c] = now[c];
        if(i) now[A[i]-'a'] = i;
    }
    int L = len[1];
    int pt = 0;
    string ans;
    while(pt < N){
        for(char i=0; i<26; i++) if(ans.size() + 1 + len[nxt[pt][i] + 1] == L){
            ans.push_back('a'+i);
            pt = nxt[pt][i];
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 27968
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var nd = ReadLine().Split().Select(int.Parse).ToArray();
        int n = nd[0], d = nd[1];
        int ans = n / (d * 2 + 1);
        if (n % (d * 2 + 1) > 0) ans++;
        WriteLine(ans);
    }
}


Measured memory_bytes: 28276
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
using namespace std;

#define DOT 0
#define SHARP 1
#define NONE 2
int trout[400][400];
int mv[4][2] = {{0, 1}, {0, -1}, {-1, 0}, {1, 0}};
unsigned long long cntdot = 0;
unsigned long long cntsharp = 0;

void countroute(int h, int w, int hmax, int wmax, int targetcolor)
{
    int targ = targetcolor;

    //上下左右に進んで、
    for (int i = 0; i < 4; i++)
    {
        int hnow = h + mv[i][0];
        int wnow = w + mv[i][1];

        //別の色であること、エリア内であること、
        if (0 <= hnow && hnow < hmax && 0 <= wnow && wnow < wmax && trout[hnow][wnow] != NONE)
        {

            if (trout[hnow][wnow] == targ)
            {
                //printf("hnow%d,wnow%d, color%d",hnow,wnow,trout[hnow][wnow]);
                if (trout[hnow][wnow] == DOT)
                {
                    targetcolor = SHARP;
                    cntdot++;
                }else {
                    targetcolor = DOT;
                    cntsharp++;
                }
                trout[hnow][wnow] = NONE;
                countroute(hnow, wnow, hmax, wmax, targetcolor);
            }
        }
    }
}

int main()
{

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

    for (int i = 0; i < H; i++)
    {
        string tmp;
        cin >> tmp;
        for (int j = 0; j < W; j++)
        {
            if (tmp[j] == '.')
            {
                trout[i][j] = DOT;
            }
            else
            {
                trout[i][j] = SHARP;
            }
        }
    }

    unsigned long long sum = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if(trout[i][j] != NONE){
            int targcolor;
            if (trout[i][j] == DOT){
                cntdot++;
                targcolor = SHARP;
            }else{
                cntsharp++;
                targcolor = DOT;
            }
            trout[i][j] = NONE;
            countroute(i, j, H, W, targcolor);
            sum += cntdot * cntsharp;
            cntdot = 0;
            cntsharp = 0;
            }
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 13312
open System

let s = Console.ReadLine()

let cindex = Seq.tryFindIndex (fun x -> x = 'C') s
match cindex with
| None -> printfn "No"
| Some i -> begin
              match Seq.tryFindIndex (fun x -> x = 'F') (s.[i..Seq.length s-1]) with
              | None -> printfn "No"
              | _ -> printfn "Yes"
            end

Measured memory_bytes: 13648
import java.util.Scanner;
class Main{
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		int students = sc.nextInt();
		int total=0;
		for(int i=1;i<=students;i++) {
			total+=i;
		}
		System.out.println(total);
	}
}

Measured memory_bytes: 21076
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;
 
void main()
{
    int n;
    long k;
    readVars(n, k);

    auto bkt = new long[](10^^5 + 1);

    int ai, bi;

    foreach(i ; 0 .. n){
        readVars(ai, bi);
        bkt[ai] += bi;
    }

    long cnt;

    foreach(i ; 1 .. 10^^5 + 1) {
        cnt += bkt[i];

        if (cnt >= k) {
            writeln(i);
            return;
        }
    }
}
 
void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}

Measured memory_bytes: 4092
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		String str=s.next();
		int n=str.length();
		
		int c=0;
		
		if(check(str))
			c++;
		if(check(str.substring(0,(n-1)/2)))
		{
			c++;
		}
		if(check(str.substring(((n+3)/2)-1,n)))
		{
			c++;
		}
		
		if(c==3)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
	
	public static boolean check(String str)
	{
		int p=0;
		
		for(int i=0;i<str.length();i++)
		{
			if(str.charAt(i)!=str.charAt(str.length()-1-i))
			{
				p=1;
				break;
			}
		}
		
		if(p==1)
			return false;
		else
			return true;
	}
	
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int  n, k;
  cin >> n >> k;
  vector<double> p(n), ans(n);
  double max;
  for(int i=0; i<n;i++){
    double q;
    cin >> q;
    p[i] = (q + 1)/2;
  }
  for(int i=0;i<k;i++){
    ans[0] += p[i];
  }
  for(int i=1; i+k-1<n;i++){
    ans[i] = ans[i-1] - p[i - 1] + p[i-1+k];
  }
  
  
  sort(ans.begin(), ans.end());
  
  printf("%8.6lf\n", ans[n-1]);
  
}

Measured memory_bytes: 3328
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

// ref:https://naoyat.hatenablog.jp/entry/k-dimension-manhattan-distance

int main()
{
	int N; cin >> N;	// N <= 2e5 当然ながら全組み合わせは計算できない
	vector<int> f0s(N), f1s(N);
	REP(i, N)
	{
		int xi, yi; cin >> xi >> yi;
		f0s[i] = xi - yi;
		f1s[i] = xi + yi;
	}
	int max0 = *max_element(f0s.begin(), f0s.end());
	int min0 = *min_element(f0s.begin(), f0s.end());
	int max1 = *max_element(f1s.begin(), f1s.end());
	int min1 = *min_element(f1s.begin(), f1s.end());
	cout << max(max0 - min0, max1 - min1) << endl;
}


Measured memory_bytes: 4788