akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;

 
int main() {
	

	int N;
	ll T;
	vector<int> A;
	cin>>N>>T;
	fx(N){
		int a;
		cin>>a;
		A.push_back(a);
	}
	
	sort(A.begin(),A.end());
	ll ans=0,sub=0,i=0;
	while(i<A.size()&&sub<T){
		sub+=A.at(i++);
		ans++;
	}

if(sub<T){

ce(N-1)

}else{
if(i==1&&sub!=T){
ce("0")
}else{
if(sub==T){
	ce(ans)
}else{
ce(ans-1)
}
}
}

}

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

const int MIMAX = INT_MAX;
const int MIMIN  INT_MIN;
const long long MLMAX = LLONG_MAX;
const long long MLMIN = LLONG_MIN;

const int MAXNe5 = 1e5+10;
const int MAXNe9 = 1e9+10;


using mll = long long;

template <typename T>
using mstk = std::stack<T>;
template <typename T>
using mque = std::queue<T>;

template <typename T>
using mvec = std::vector<T>;

template <typename T>
using mset = std::set<T>;
template <typename T>
using mdset = std::multiset<T>;
template <typename T>
using muset = std::unordered_set<T>;
template <typename T>
using mudset = std::unordered_multiset<T>;

template <typename T1, typename T2>
using mmap = std::map<T1, T2>;
template <typename T1, typename T2>
using mdmap = std::multimap<T1, T2>;
template <typename T1, typename T2>
using mumap = std::unordered_map<T1, T2>;
template <typename T1, typename T2>
using mudmap = std::unordered_multimap<T1,T2>;


int main()
{
    std::ios::sync_with_stdio(false);	
    int n;
    cin>>n;
    mmap<int,int> num;
    int count = 0;
    
    for(int i = 0 ; i < n; i++)
    {
        int tmp;
        cin>>tmp;
        num[tmp]++;
    }
    
    auto l = num.begin();
    auto r = l;
    if(r!=prev(num.end()))
    {
        r++;
    }
    while(r!=prev(num.end()))
    {
        int nl = l->first;
        int nr = r->first;
        int n3 = next(r)->first;
        if(nl+1==nr && nr+1==n3)
        {
            count = max(count,l->second + r->second + next(r)->second );
        }
        l++;
        r++;
    }
    if(count==0)
    {
        if(l==r)//only one element
        {
            count = l->second;
        }
        else //two elements
        {
            int nl = l->first;
            int nr = r->first;
            if(nl+1==nr)
            {
                count = l->second + r->second ;
            }
            else
            {
                count = max( l->second , r->second );
            }
        }
    }
    cout<<count;
    return 0;
}

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

struct UnionFind{
    int num;
    vector<int> par,rank;
    UnionFind(int n):num(n),par(n),rank(n,1){
        iota(par.begin(),par.end(),0);
    }
    int root(int x){
        return (par[x]==x?x:par[x]=root(par[x]));
    }
    bool merge(int x, int y){
        x=root(x),y=root(y);
        if (x==y) return false;
        if (rank[x]<rank[y]) swap(x,y);
        par[y]=x;
        rank[x]+=rank[y];
        --num;
        return true;
    }
    bool same(int x, int y){return root(x)==root(y);}
    int size(int x){return rank[root(x)];}
    int count(){return num;}
};

const int MAX_N=1010;

int n,p1,p2;
int x[MAX_N],y[MAX_N];
string a[MAX_N];

void solve(){
    UnionFind uf(p1+p2);
    for (int i=0;i<n;++i){
        --x[i],--y[i];
        if (a[i]=="yes") uf.merge(x[i],y[i]);
    }
    vector<vector<int>> G(p1+p2);
    for (int i=0;i<n;++i){
        if (a[i]=="no"){
            int X=uf.root(x[i]),Y=uf.root(y[i]);
            G[X].emplace_back(Y);
            G[Y].emplace_back(X);
        }
    }
    vector<int> seen(p1+p2,0),point(2);
    auto dfs=[&](auto self,int v,int c)->void{
        seen[v]=1;
        for (int u:G[v]){
            if (seen[u]) continue;
            if (point[1]<0&&c==0) point[1]=u;
            uf.merge(u,(c==1?point[0]:point[1]));
            self(self,u,(c^1));
        }
    };
    vector<pair<int,int>> v;
    for (int i=0;i<p1+p2;++i){
        if (uf.root(i)==i&&!seen[i]){
            point[0]=i,point[1]=-1;
            dfs(dfs,i,0);
            v.emplace_back(uf.root(point[0]),(~point[1]?uf.root(point[1]):-1));
        }
    }
    int N=v.size();
    vector<vector<int>> dp(N+1,vector<int>(p1+1,0)),
                        pre(N+1,vector<int>(p1+1,-1));
    dp[0][0]=1;
    for (int i=0;i<N;++i){
        vector<int> add(2,0);
        add[0]=uf.size(v[i].first);
        if (~v[i].second) add[1]=uf.size(v[i].second);
        for (int j=0;j<=p1;++j){
            for (int k=0;k<2;++k){
                if (j+add[k]<=p1){
                    dp[i+1][j+add[k]]+=dp[i][j];
                    dp[i+1][j+add[k]]=min(2,dp[i+1][j+add[k]]);
                    if (dp[i][j]) pre[i+1][j+add[k]]=(!k?v[i].first:v[i].second);
                }
            }
        }
    }
    if (dp[N][p1]!=1){cout << "no" << '\n'; return;}
    set<int> s;
    int now=p1;
    for (int i=N;i>0;--i){
        s.emplace(pre[i][now]);
        if (~pre[i][now]) now-=uf.size(pre[i][now]);
    }
    vector<int> ans;
    for (int i=0;i<p1+p2;++i){
        if (s.count(uf.root(i))){
            cout << i+1 << '\n';
        }
    }
    cout << "end" << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> p1 >> p2,p1+p2){
        for (int i=0;i<n;++i) cin >> x[i] >> y[i] >> a[i];
        solve();
    }
}


Measured memory_bytes: 3364
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Mod=998244353;

int n,nn; char S[200010];
int ans[400010];
int solve(int x)
{
	x>>=1;
	int res=0;
	for (int i=1;i<=x;i++) res=(res*2+S[i]-'0')%Mod;
	bool flg=false;  //greater or not
	for (int i=x+1,j=1,k=1;i<=n;i++)
	{
		char t=S[j]^k;
		if (t!=S[i])
		{
			flg=S[i]<t; break;
		}
		if (j==x) j=1,k^=1;
		else j++;
	}
	
	//if (S[i]!=S[(i-1)%x+1]){flg=S[i]<S[(i-1)%x+1];break;}
	if (!flg) res=(res+1)%Mod;
	//printf("solve %d %d\n",x*2,res);
	return res;
}
int main()
{
	scanf("%d%s",&n,S+1); nn=n+n;
	for (int i=nn;i;i-=2)
		if (nn%i==0&&n%i==(i>>1))
			ans[i]=solve(i);
	//for (int i=1;i<=nn;i++) printf("ans %d: %d\n",i,ans[i]);
	for (int i=2;i<=nn;i+=2)
		if (nn%i==0&&n%i==(i>>1))
			for (int j=i+i;j<=nn;j+=i)
				if (nn%j==0&&n%j==(j>>1))
					ans[j]=(ans[j]-ans[i])%Mod;
	int res=0;
	for (int i=2;i<=nn;i+=2) res=(res+1LL*i*ans[i])%Mod;
	printf("%d\n",(res+Mod)%Mod);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int r = 0;
    for (int i = 1; i < n; i++) {
        r += (n - 1) / i;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
int main()
{
    char S[10];
    gets(S);
    char A[10]="Sunny";
    char B[10]="Cloudy";
    char C[10]="Rainy";
    if(strcmp(S,A)==0)
    {
        printf("Cloudy\n");
    }
    else if(strcmp(S,B)==0)
    {
        printf("Rainy\n");
    }
    else
    {
        printf("Sunny\n");
    }
}


Measured memory_bytes: 1860
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=[int(input()) for _ in range(n)]
for i in range(3):
    for j in range(3):
        if a[i][j] not in b:
            break
    else:
        print('Yes')
        exit()
for i in range(3):
    for j in range(3):
        if a[j][i] not in b:
            break
    else:
        print('Yes')
        exit()
for i in range(3):
    if a[i][i] not in b:
        break
else:
    print('Yes')
    exit()
for i in range(3):
    if a[2-i][i] not in b:
        break
else:
    print('Yes')
    exit()
print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL<<60;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++)
        cin >> h[i];

    vector<long long> cost(n+k);
    cost[0] = 0;
    for(int i = 1; i < n; i++) {
        long long c_min = INF;
        for(int j = max(0, i-k); j < i; j++)
            c_min = min(c_min, abs(h[j] - h[i]) + cost[j]);
        cost[i] = c_min;
    }
    cout << cost[n-1] << endl;
}

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

#include <bits/stdc++.h>

using namespace std;

class TaskI {
	int N;
	vector<double> p;
	vector<vector<double>> dp;
	vector<vector<bool>> vis;
public:
	void solve(std::istream& in, std::ostream& out) {
		in >> N;
		p.resize(N);
		vis.resize(N, vector<bool> (N, false));
		dp.resize(N, vector<double> (N));
		for (int i = 0; i < N; i++) in >> p[i];
		double ans = rec(0, 0);
		out << fixed << setprecision(12) << ans;
	}

	double rec(int c, int h) {
		if (c == N) {
			if (h >= (N + 1) / 2) return 1;
			return 0;
		}
		if (vis[c][h]) return dp[c][h];
		vis[c][h] = true;
		return dp[c][h] = p[c] * rec(c + 1, h + 1) + (1.0 - p[c]) * rec(c + 1, h);
	}
};


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	TaskI solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

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

	vector<double> x(n);
	vector<string> u(n);

	double ans = 0;

	for (int i = 0; i < n; i++) {
		cin >> x[i] >> u[i];
		if (u[i] == "JPY") ans += x[i];
		else ans += x[i] * 380000;
	}

	cout << fixed << setprecision(11) << ans << endl;

	return 0;
}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/g.in", "r", stdin);
//  freopen("../IO/g.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

const int md = (int) 1e9 + 7;

const int maxn = (int) 2e5 + 5;
int a[maxn];
int dp[maxn];

void solve(std::istream &in, std::ostream &out) {
  int n = 0;
  in >> n;
  for (int i = 1; i <= n; ++i) {
    in >> a[i];
  }
  dp[0] = 1;
  for (int i = 0; i <= n; ++i) {
    if (a[i] != a[i + 1]) {
      dp[a[i + 1]] = (dp[a[i + 1]] + dp[a[i]]) % md;
    }
  }
  out << dp[a[n]] << '\n';
}


Measured memory_bytes: 1792
def yumiri(L, n):
  for i in range(len(L)):
    if L[i] > n:
      return i - 1

def naobou(d, q):
  newans = ans

  rd = t[d - 1] - 1
  rq = yumiri(ZL[rd], d)
  newans += SUMD[ZL[rd][rq] - ZL[rd][rq - 1] - 1] * c[rd]
  newans += SUMD[ZL[rd][rq + 1] - ZL[rd][rq] - 1] * c[rd]
  newans -= SUMD[ZL[rd][rq + 1] - ZL[rd][rq - 1] - 1] * c[rd] 
  del ZL[rd][rq]

  nd = q - 1
  nq = yumiri(ZL[nd], d)
  newans += SUMD[ZL[nd][nq + 1] - ZL[nd][nq] - 1] * c[nd]
  newans -= SUMD[d - ZL[nd][nq] - 1] * c[nd]
  newans -= SUMD[ZL[nd][nq + 1] - d - 1] * c[nd]
  ZL[nd].insert(nq + 1, d)

  newans -= s[d - 1][rd]
  newans += s[d - 1][nd]

  if newans < ans:
    ZL[rd].insert(rq, d)
    del ZL[nd][nq + 1]
    return ans
  else:
    t[d - 1] = q
    return newans 

def rieshon():
  ans = 0
  for i in range(D):
    ans += s[i][t[i] - 1]
    for j in range(26):
      if t[i] - 1 == j:
        L[j] = 0
        ZL[j].append(i + 1)
      else:
        L[j] += 1
        ans -= L[j] * c[j]
  for i in range(26):
    ZL[i].append(D + 1)
  return ans

import time
import random
startTime = time.time()

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

L = [0] * 26
ZL = [[0] for _ in range(26)]
SUMD = [0] * (D + 1)
for i in range(1, D + 1):
  SUMD[i] = SUMD[i - 1] + i

t = [0] * D
for i in range(D):
  ma = s[i][0]
  man = 0
  for j in range(1, 26):
    if s[i][j] == ma:
      if c[j] < c[man]:
        ma = s[i][j]
        man = j
    elif s[i][j] > ma:
      ma = s[i][j]
      man = j
  t[i] = man + 1

ans = rieshon()
while time.time() - startTime < 1.8:
  d = random.randrange(D) + 1
  q = random.randrange(26) + 1
  if t[d - 1] == q: continue
  ans = naobou(d, q)

for i in range(D):
  print(t[i])


Measured memory_bytes: 9820
#include<iostream>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<queue>
#define f first
#define s second
using namespace std;
/* 
                            +777777777?
                           7$.I77777III777:
                           7:I?I777777777
                           777777777777,
                           $
                           $
               7$$$$$$7....$..,I$$$$$$$$I7
             7$$$$$$$$$$$$$$$$$$$$$$$$$$$$I
           I$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$I
          7$$$$$$$$$$$$$$$$$$$$$$$7$7$$$$$$$I
          I$$$$$$$$$$$$$$$$$$$$$$$$$7$$$$$$$$I
         I$$$OOOOOOOOZ$$$$$$$$$$$$OOOOOOOOZ$$I
         I$$$OOO$$$$$$$ZOOOOOOOOZ$$$$7$ZOO8$$I
         I$$$$O$$$O  O$$$OOZOO$$$$O  O$$$OO$$$I    $
          $$$$O$$$8OOO$$$O$$$O$$$ZOO$7$$O$$$$I   $$$$
          I$$$$Z$$$ZZ$$$$O$$$$O$$$ZZ$$$$O$$$$    $$$$7
          7$$$$ZO$$$$$$OO$$$$$$O$$$$$$$O$7$$I  I$
           I$$$$$ZZOOZZ$$$$$$$$$$ZOOZZZ7$$$$.I7
          I$$$$$$$$$$--$$OO:7O$$$$$--$$$$$$7$
        $$..:$$$$$$$$\$$$$$Z$$$$$$$/$$$$$$$
        $$ ...$$$$$$$$-------------$$$$$$I
         $+Z$$$7$$$$$$$$$$$$$$$$$$$$$$$$+
            $$$$,I$$$$$$$$$$$$$$$$$$$$$I
                  I$$$$$$$$$$$$$$$$$$~
                    I$$$$$$$$$$$$$$:
                       $        $
                       $        $
                      =,        :
                    ++77        77++
*/
int main(){
  int n;
  cin>>n;
  while(n--){
    unsigned long long a,b,c,d,now,x;
    cin>>a>>b>>c>>d;
    if(a<b || b>d){
      cout<<"No"<<endl;
    }
    else{
      x=__gcd(b,d);
      now=(a-b)-(a-b)%x+x;
      if(a-now<=c)
        cout<<"Yes"<<endl;
      else
        cout<<"No"<<endl;
    }
  }
  return 0;
}

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

typedef long long ll;
const int maxn = 2e5 + 3, mo = 1e9 + 7;
int n, frac[maxn];
char s[maxn];

int main() {
	frac[0] = 1;
	for(int i = 1; i < maxn; ++i)
		frac[i] = frac[i - 1] * (ll)i % mo;
	scanf("%d%s", &n, s);
	int l = 0, ans = 1;
	for(int i = 0; i < 2 * n; ++i) {
		if((s[i] == 'B') ^ (l & 1)) {
			++l;
		} else {
			ans = ans * (ll)l % mo;
			--l;
		}
		if(l < 0) {
			puts("0");
			return 0;
		}
	}
	if(l) {
		puts("0");
		return 0;
	}
	printf("%lld\n", ans * (ll)frac[n] % mo);
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
int n, m, x, a[20], b[20][20], c[20], res = INT_MAX;
bool flag = false;
int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m >> x;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        for(int j = 1; j <= m; j++)cin >> b[i][j];
    }
    for(int x_ = 1; x_ <= n; x_++){
        int N = n, K = x_;
        string bitmask(K, 1);
        bitmask.resize(N, 0);
        do {
            memset(c,0,sizeof(c));
            int sum = 0;
            for (int i = 0; i < N; ++i)
            {
                if (bitmask[i]){
                    sum += a[i];
                    for(int j = 1; j <= m; j++)c[j]+=b[i][j];
                }
            }
            bool f = true;
            for(int i = 1; i <= m; i++){
                if(c[i] < x)f = false;
            }
            if(f){
                flag = true;
                res = min(res,sum);
            }

        } while (prev_permutation(bitmask.begin(), bitmask.end()));
    }
    if(flag){
        cout << res << endl;
    }else cout << -1 << endl;
}


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

public class Main {

	static Scanner scanner;
	static int[] C;
	static int[][] A;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int a=gi();
	    
        //System.out.println(a[2]-a[0]);
        if (a<1200) {
        	System.out.print("ABC");
        }else if(a<2800){
        	System.out.print("ARC");
        } else {
        	System.out.print("AGC");
        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

int score[1000][1000];

int main(){
        int d[20],c[20];
        int n,m,t,p,height,width,ans,w,h;

        while(1) {
                height=0;
                width=0;
                ans=0;

                for(int i=0; i<400; i++) {
                        for(int j=0; j<400; j++) {
                                score[i][j]=0;
                        }
                }

                cin>>n>>m>>t>>p;

                if(n==0&&m==0&&t==0&&p==0) {
                        break;
                }

                for(int i=0; i<m; i++) {
                        for(int j=0; j<n; j++) {
                                score[i][j]=1;
                        }
                }

                for(int i=0; i<t; i++) {
                        cin>>d[i]>>c[i];

                        if(d[i]==2) {
                                height += c[i];
                                m += height;
                                for(int x=height; x<height+c[i]; x++) {
                                        for(int y=width; y<n; y++) {
                                                score[x][y]+=score[2*height-x-1][y];
                                                //  cout<<x<<':'<<y<<':'<<score[x][y]<<endl;
                                        }
                                }
                        }else{
                                width += c[i];
                                n += width;
                                for(int x=width; x<width+c[i]; x++) {
                                        for(int y=height; y<m; y++) {
                                                score[y][x]+=score[y][2*width-x-1];
                                                //      cout<<y<<':'<<x<<':'<<score[y][x]<<endl;
                                        }
                                }
                        }
                }

                for(int i=0; i<p; i++) {
                        cin>>w>>h;

                        ans = score[h+height][w+width];
                        cout<<ans<<endl;
                }
        }
}



Measured memory_bytes: 4780
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif

int dp[1001][1001]; 
void solve()
{	
	int n,m ;
	cin >> n >> m ;
	string s[n] ;
	rep(i,n) cin >> s[i]; 
	dp[0][0] = 1 ;
	rep(i,n)
		rep(j,m){
			if(i+1 < n && s[i+1][j] == '.') 
				dp[i+1][j] += dp[i][j], dp[i+1][j] %= mod ;

			if(j+1 < m && s[i][j+1] == '.') 
				dp[i][j+1] += dp[i][j], dp[i][j+1] %= mod;
		}
	cout << dp[n-1][m-1] ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int a,b;
  bool f=false;
  cin>>a>>b;
  int c,d;
  rep(i,1,10001){
    c=i*0.08;
    d=i*0.1;
    if(c==a && d==b){
      co(i);
      f=true;
      break;
    }
  }
  if(f==false) co(-1);
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
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++)
typedef long long ll;
typedef pair<int,int> Pii;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int main(){
	int n,T;
	cin>>n>>T;
	int min=10000;
	int c,t;
	for(int i=0;i<n;i++){
		cin>>c>>t;
		if(t<=T){
			min=min(min,c);
		}
	}
	if(min==10000){
		cout<<"TLE"<<endl;
	}else{
	cout<<min<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;
typedef pair<int,int> p;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
const ll big=998244353;
const ll bbig=1000000007;
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%bbig;
    ll t=exp(x,y/2);
    return (t*t)%bbig;
}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll in(ll x){
    return exp(x,bbig-2);
}
ll com(ll x,ll y){
    ll ans=1;
    rep(i,y){ans*=x-i;ans%=bbig;}
    rep(i,y){ans*=in(i+1);ans%=bbig;}
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(0);
    /*--------------------------------*/
    
    int n,a,b;cin >> n >> a >> b;
    ll ans=exp(2,n)-1;
    cout << ((ans-com(n,a)-com(n,b))%bbig+bbig)%bbig << '\n';
}

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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

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

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

int cnt[26];

int main(){

	string s,ori;
    cin>>s;

    ori=s;

    int l = s.length();
    int dis = 0;
    for(int i=0;i<l;i++){
        if(cnt[s[i]-'a']==0) dis++;
        cnt[s[i]-'a']++;
    }

    if(dis==1){
        cout<<0<<endl;
        return 0;
    }

    int ans = 1000000;

    for(int i=0;i<26;i++){

        if(cnt[i]){
            int tmp = 0;
            s=ori;
            while(1){

                tmp++;

                string s1;
                int cnt2[26]={0};
                for(int j=0;j<s.size()-1;j++){
                    if((s[j]-'a')==i) s1+=s[j];
                    else if((s[j+1]-'a')==i) s1+=s[j+1];
                    else s1+=s[j];
                }
                s=s1;
                int dis = 0;
                for(int j=0;j<s.size();j++){
                    if(cnt2[s[j]-'a']==0) dis++;
                    cnt2[s[j]-'a']++;
                }

                if(dis==1) break;

            }

            ans=min(ans,tmp);

            


        }

    }

    cout<<ans<<endl;




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// まずは全探索，次にDP
// 偶奇，逆から，ソート，出現回数，DP
// 存在判定：構成方法，入力の特徴
// 例外を十分に含む一般化．想像力の限界
int main() {
cin.tie(0);
ios::sync_with_stdio(false);

string S;
int64_t K, cnt = 0;
cin >> S >> K;

int len = 1;
rep(i, 1, S.size()){
    if (S[i] == S[i - 1]) ++len;
    else {
        cnt += len / 2;
        len = 1;
    }
}
if (len == S.size()){
    cout << len * K / 2 << "\n";
    return 0;
}

cnt += len / 2;
cnt *= K;

if (S[0] == S.back()){
    int f = 0, b = 0;
    while (S[f] == S[0]) ++f;
    while (S[S.size() - 1 - b] == S.back()) ++b;
    cnt -= (f/2 + b/2 - (f + b) / 2) * (K - 1);
}

cout <<  cnt << "\n";  

}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {

	if sc.Scan() {
		tmp := strings.Split(sc.Text(), " ")
		a, _ := strconv.Atoi(tmp[0])
		b, _ := strconv.Atoi(tmp[1])

		if a > b {
			fmt.Println("a > b")
		} else if a < b {
			fmt.Println("a < b")
		} else {
			fmt.Println("a == b")
		}

	}
}



Measured memory_bytes: 1068
n = int(input())
X = []
Y = []
for _ in range(n):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
    
dist = 0
import math 
for j in range(n):
    for k in range(n):
        dist += math.sqrt((X[j]-X[k])**2+(Y[j]-Y[k])**2)
        
print(dist/n)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1000000007;
constexpr int  mod = mo;
constexpr ll inf = 1ll<<62;
int main(){
    int n;
    cin>>n;
    vector<int> a(n+1),b(n);
    for(auto & t : a) cin>>t;
    for(auto & t : b) cin>>t;
    int x;
    ll ret = 0ll;
    for(int i=0;i<=n;++i){
        if(i){
            x = min(a[i],b[i-1]);
            a[i] -= x;
            b[i-1] -= x;
            ret += x;
        }
        x = min(a[i],b[i]);
        a[i] -= x;
        b[i] -= x;
        ret += x;
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

string s, t;
int a[26];
int b[26];

int main() {
	cin >> s >> t;
	rep(i, s.size())a[s[i] - 'a']++;
	rep(i, s.size())b[t[i] - 'a']++;
	sort(a, a + 26);
	sort(b, b + 26);
	rep(i, 26) {
		if (a[i] != b[i]) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 776
#include<stdio.h>
int main()
{
    int a[100001];
    int n,i,x;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&x);
        a[x]=i;
    }
    for(i=1;i<=n;i++)
    {
        printf("%d ",a[i]);
    }
    return 0;

}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
int main(){

int a,i,N,A=0,B=0,C=0,D=0;
int E=0,F=0,G=0,H=0,X=0,max,min;

cin >> N;

for(i=0;i<N;i++){
  cin >> a;

  if(a>=1 && a<=399){
    X=1;
  }
  else if(a>=400 && a<=799){
    A=1;
  }
  else if(a>=800 && a<=1199){
    B=1;
  }
  else if(a>=1200 && a<=1599){
    C=1;
  }
  else if(a>=1600 && a<=1999){
    D=1;
  }
  else if(a>=2000 && a<=2399){
    E=1;
  }
  else if(a>=2400 && a<=2799){
    F=1;
  }
  else if(a>=2800 && a<=3199){
    G=1;
  }
  else{
    H+=1;
  }
}

max=X+A+B+C+D+E+F+G+H;
min=X+A+B+C+D+E+F+G;

if(min==0){
  min=1;
}

cout << min << " " << max << endl;

}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		int combi = n * n - n;
		if (n < 3) {
			System.out.println("1");
			System.exit(0);
		}
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}

		int[] a = new int[combi];
		int[] b = new int[combi];
		int tmp = 0;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if(i == j) {continue;}
				a[tmp] = x[i] - x[j];
				b[tmp] = y[i] - y[j];
				tmp++;
			}
		}

		int maxCount = 0;
		for (int i = 0; i < combi; i++) {
			int count = 1;
			for (int j = i+1; j < combi; j++) {
				if (a[i] == a[j] && b[i] == b[j]) {
					count++;
				}
			}
			if (count > maxCount) {
				maxCount = count;
			}
		}

		System.out.println(n - maxCount);

	}
}

Measured memory_bytes: 24016
// フェルマーの小定理
package main

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

const (
	p = 1000000007
)

var (
	fac []int
)

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func mpow(x int, n int) int {
	ans := 1
	for n != 0 {
		if n&1 == 1 {
			ans = ans * x % p
		}
		x = x * x % p
		n = n >> 1
	}
	return ans
}

func mcomb(n int, k int) int {
	if n == 0 && k == 0 {
		return 1
	}
	if n < k || k < 0 {
		return 0
	}
	result := fac[n]
	result *= mpow(fac[n-k], p-2)
	result %= p
	result *= mpow(fac[k], p-2)
	result %= p
	return result
}

func main() {
	X := readInt()
	Y := readInt()

	if (X+Y)%3 != 0 {
		fmt.Println(0)
		return
	}

	a := (2*Y - X) / 3
	b := (2*X - Y) / 3

	if a < 0 || b < 0 {
		fmt.Println(0)
		return
	}

	n := a + b
	k := min(a, b)

	fac = make([]int, n+1)
	fac[0] = 1
	for i := 0; i < n; i++ {
		fac[i+1] = fac[i] * (i + 1) % p
	}

	fmt.Println(mcomb(n, k))
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 6016
n = int(input())
mod = int(1e9+7)
cnt = 1

if n == 1:
    print(1)
    exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

fd = dict()
for i in range(2, n+1):
    f = factorization(i)
    for j in f:
        if j[0] not in fd:
            fd[j[0]] = j[1]
        else:
            fd[j[0]] += j[1]
fd = list(fd.values())
for i in fd:
    cnt *= i+1
    cnt %= mod
print(cnt)



Measured memory_bytes: 41708
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll P = 1000000007;
  ll N, K;
  std::cin >> N >> K;
  std::vector<ll> A(N);
  for(int i=0;i<N;i++) std::cin >> A[i];
  std::vector<ll> count(N, 0), check(N, 0);
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(A[i]>A[j]) count[i]++;
    }
    for(int j=0;j<N;j++){
      if(A[i]>A[j]) check[i]++;
    }
  }
  //for(int i=0;i<N;i++) std::cout << count[i] << " " << check[i] << '\n';
  ll ans = 0;
  for(int i=0;i<N;i++) {
    ans = (ans + (count[i]*K)%P)%P;
    ans = (ans + (check[i] * ((((K*(K-1))/2))%P))%P)%P;
  }
  std::cout << ans << '\n';
  return 0;
}


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

int main(){
  int n;
  cin>>n;
  if(n%2==1){
    ll vec[n];
    ll vecb[n];
    for(int i=0;i<n;i++){
      cin>>vec[i]>>vecb[i];
    }
    sort(vec,vec+n);
    sort(vecb,vecb+n);
    cout<<vecb[(n-1)/2]-vec[(n-1)/2]+1<<endl;
    return 0;
  }
  ll vec[n];
  ll vecb[n];
  for(int i=0;i<n;i++){
    cin>>vec[i]>>vecb[i];
  }
  sort(vec,vec+n);
  sort(vecb,vecb+n);
  cout<<(vecb[n/2]+vecb[n/2-1])-(vec[n/2]+vec[n/2-1])+1<<endl;
}

Measured memory_bytes: 6752
n = int(input())
A = list(map(int,input().split()))
nums = {}

for a in A:
    if a in nums:
        nums[a]+=1
    else:
        nums[a] = 1
ans = 0

for a,amount in nums.items():
    if a==amount:
        continue
    else:
        if a>amount:
            ans += amount
        else:
            ans += amount - a
print(ans)

Measured memory_bytes: 18168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long int

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

Measured memory_bytes: 256
while true
  n, k, m, r = gets.split.map(&:to_i)
  break if n == 0
  x, y = 1, n
  x, y = (1...n).reduce([1, 1]){ |b, i| [b[0] * i + b[1], b[1] * i]}.zip([x, y]).map{ |a, b| a * b } if m == 1
  g = x.gcd y
  x /= g; y /= g
  x, mod = x.divmod y
  print x.to_s + "."
  x = mod * 10
  r.times.reduce(x){ |t, _| t, mod = t.divmod y; print t; mod * 10 }
  puts
end

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int arr[n][3];

    for(int i=0;i<n;i++){
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }

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

    }

    cout<<max({arr[n-1][0] , arr[n-1][1] , arr[n-1][2] })<<endl;
}


Measured memory_bytes: 1408
#include <iostream>
#define MAX 36

using namespace std;

void showArray(char C[][3], int N){
	int flag = 0;
	for (int p = 0; p < N - 1; p++){
		cout << C[p][0] << C[p][1] << " ";
		if (C[p][1] == C[p + 1][1] && C[p][2] > C[p + 1][2]){
			flag = 1;
		}
	}
	cout << C[N - 1][0] << C[N - 1][1]<< endl;
	if (flag == 0){
		cout << "Stable" << endl;
	}
	else{
		cout << "Not stable" << endl;
	}
}

void bubbleSort(char C[][3], int N){

	for (int i = 0; i < N; i++){
		for (int j = N - 1; j > 0; j--){
			if (C[j][1] < C[j - 1][1]){
				char temp[3];
				temp[0] = C[j][0];
				temp[1] = C[j][1];
				temp[2] = C[j][2];

				C[j][0] = C[j - 1][0];
				C[j][1] = C[j - 1][1];
				C[j][2] = C[j - 1][2];

				C[j - 1][0] = temp[0];
				C[j - 1][1] = temp[1];
				C[j - 1][2] = temp[2];
			}
		}
	}

	showArray(C, N);
}

void selectionSort(char C[][3], int N){
	for (int i = 0; i < N; i++){
		int min = i;
		for (int j = i; j < N; j++){
			if (C[min][1] > C[j][1]){
				min = j;
			}
		}
		char temp[2];
		temp[0] = C[i][0];
		temp[1] = C[i][1];
		temp[2] = C[i][2];

		C[i][0] = C[min][0];
		C[i][1] = C[min][1];
		C[i][2] = C[min][2];

		C[min][0] = temp[0];
		C[min][1] = temp[1];
		C[min][2] = temp[2];

	}
	showArray(C, N);
}

int main(){
	int N;
	char C1[MAX][3], C2[MAX][3];
	
	cin >> N;

	for (int i = 0; i < N; i++){
		cin >> C1[i];
		C2[i][0] = C1[i][0];
		C2[i][1] = C1[i][1];
		C1[i][2] = i;
		C2[i][2] = i;
	}

	bubbleSort(C1 , N);
	
	selectionSort(C2 , N);

	return 0;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

void we_r_done(){cout<<"NO"; exit(0);}

void debug(string mssg){cout<<mssg; exit(0);}

using minHeap = priority_queue< int, vector< int >, greater< int > >;



int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;

    int n;
    scn(n);
    int a[n+1];

    for(int i=1; i<=n; i++)scn(a[i]);

    lli cum[n+1];
    cum[0] = 0;

    for(int i=1; i<=n; i++) cum[i] = cum[i-1] + a[i];

    #define rsum(lo,hi) cum[hi]-cum[lo-1]
    lli dp[n+1][n+1];

    for(int L=1; L<=n; L++){

        for(int i=1 ; (i+L-1)<=n; i++){

            int j = i+L-1;

            if(L==1) dp[i][j] = 0;
            else{
                dp[i][j] = inf*1LL*inf;
                for(int k=i ; k<j; k++) dp[i][j] = min(dp[i][j] ,dp[i][k]+dp[k+1][j]+rsum(i,k)+ rsum(k+1,j));
            }
        }
    }
    cout<<dp[1][n];
    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


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

const int mxN = 100, mxW =1e5;
long long wt[mxN],v[mxN] ,n,W;
long long dp[mxN+1][mxW+1];


int main(){
    cin >> n >> W;
    for(int i=0 ; i< n ; ++i){
        cin  >> wt[i] >> v[i];
    } 

    for(int i=0; i < n+1 ; i++){
        for(int w=0 ; w<= W ; ++w){
            if(i==0|| w==0){
                dp[i][w]=0;
            }
            else if(wt[i-1]<=w){
                dp[i][w] = max(dp[i-1][w] , v[i-1]+dp[i-1][w-wt[i-1]]);
            }else{
                dp[i][w] = dp[i-1][w];
            }
        }

    }
    cout << dp[n][W];
    
       
}

Measured memory_bytes: 82536
max_n=10**5
mod=10**9+7

frac=[1]
for i in range(1,max_n+1):
  frac.append((frac[-1]*i)%mod)

inv=[1,1]
inv_frac=[1,1]
for i in range(2,max_n):
  inv.append((mod-inv[mod%i]*(mod//i))%mod)
  inv_frac.append((inv_frac[-1]*inv[-1])%mod)
  
def perm(m,n):
  if m<n:
    return 0
  if m==1:
    return 1
  return (frac[m]*inv_frac[m-n])%mod

def comb(m,n):
  if m<n:
    return 0
  if m==1:
    return 1
  return (frac[m]*inv_frac[n]*inv_frac[m-n])%mod

s=int(input())
c=0
for i in range(1,s//3+1):
  ss=s-i*3
  c=(c+comb(ss+i-1,i-1))%mod
print(c)

Measured memory_bytes: 87612
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,x = readInts()
    A = sorted(readInts())
    now = 0
    cnt = 0
    for i in range(n):
        if now + A[i] <= x:
            if i == n-1:
                if now + A[i]== x:
                    cnt += 1
                else:
                    pass
            else:
                now += A[i]
                cnt += 1
        else:
            break
    print(cnt)
if __name__ == '__main__':
  main()


Measured memory_bytes: 5148
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
string w="west";
string n="north";
// #define int ll
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm( int m, int n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}
signed main(){
    string s;
    while(cin>>s){
        vector<string>data;
        if(s=="#")break;
        map<string,int>mp;
        for(int i=0;i<s.size();i++){
            if(s[i]=='w'){
                i+=3;
                data.push_back("west");
            }else{
                data.push_back("north");
                i+=4;
            }
        }
        reverse(all(data));
        ll now=0;
        pii num=pii(0,1);
        rep(i,data.size()){
            if(!i){
                if(data[i]==w){
                    now=90;
                    //mp[w]++;
                }else{
                    now=0;
                    //mp[n]++;
                }
                continue;
            }
            if(data[i]==w){
                mp[w]++;
                now=now*2+90;
                cmax(now,0);
            }else{
                mp[n]++;
                now=now*2-90;
                cmax(now,0);
            }
        }
        int let=gcd((int)now,pow(2,mp[n]+mp[w]));
        if((int)pow(2,(mp[n]+mp[w]))/let==1)
            cout<<now/let<<endl;
        else
            cout<<(ll)now/let<<"/"<<(ll)pow(2,(mp[n]+mp[w]))/let<<endl;
        
    }
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#ifdef STOPIT
#define debug(...) 0
#else
#define debug(...)\
do {\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;\
} while (false)
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  lint n, q; std::cin >> n >> q;
  std::vector<int>a(n); std::cin>>a;
  loop(q){
    lint X; std::cin >> X;
    lint ans = 0, sum = 0;
    for(lint l=0,r=0;l<n;l++) {
      while(r<n && sum+a[r]<=X){
        sum+=a[r];
        r++;
      }
      // debug(sum,std::vector<int>(a.begin()+l,a.begin()+r));
      ans+=r-l;
      sum-=a[l];
    }
    std::cout << ans << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3384
var std = process.stdin;
std.resume();
std.setEncoding('utf8');

std.on('data', function(chunk){
    var data = chunk.split(/\n/g);

    for (var i = 0; i < data.length; i++){
        var
            line = data[i].replace(/\n/, '').split(' ').map(Number),
            h = line[0],
            w = line[1];
        
        if(h === 0 && w === 0) {break;}
        draw(h, w);
        console.log();  //??????
    }
});

var draw = function(h, w) {
    for (var i = 0; i < h; i++) {
        var line = '';
        for (var j = 0; j < w; j++) {
            if (i === 0 || i + 1 === h
             || j === 0 || j + 1 === w) {
                line += '#';
            }
            else {
                line += '.';
            }
                
        }
        console.log(line);
    }  
};

Measured memory_bytes: 17940
var n,m,i,j:longint;k:char;
a:array[0..1000,0..1000]of char;
begin
readln(n,m);
for i:=1 to n do
  begin
  for J:=1 to m do read(a[i,j]);
  readln;
  end;
for I:=1 to n do
  begin;
 for j:=1 to m do
   begin
   if a[i,j]='.' then
     begin
     k:='0';
     if a[i-1,j]='#'then k:=succ(k);
     if a[i+1,j]='#'then k:=succ(k);
     if a[i,j+1]='#'then k:=succ(k);
     if a[i,j-1]='#'then k:=succ(k);
     if a[i-1,j+1]='#'then k:=succ(k);
     if a[i-1,j-1]='#'then k:=succ(k);
     if a[i+1,j+1]='#'then k:=succ(k);
     if a[i+1,j-1]='#'then k:=succ(k);
     a[i,j]:=k;
     end;
   write(a[i,j]);
   end;
 writeln;
 end;
end.

Measured memory_bytes: 128
a=int(input())
b=0
c=0
d=0
e=0
for i in range(a):
  x=input()
  if x=="AC":
    b+=1
  elif x=="WA":
    c+=1
  elif x=="TLE":
    d+=1
  elif x=="RE":
    e+=1
print("AC x ",b)
print("WA x ",c)
print("TLE x ",d)
print("RE x ",e)

Measured memory_bytes: 9204
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){

	int n;
	cin >> n;
	map<int, int> even, odd;
	for(int i=0; i<n; i++){	
		int v;
		cin >> v;
		if(i%2 == 0) even[v]++;
		else 	odd[v]++;
	}

	typedef pair<int, int> P;
	vector<P> even2, odd2;
	for(P x : even){
		even2.emplace_back(x.second, x.first);
	}
	for(P x : odd){
		odd2.emplace_back(x.second, x.first);
	}

	sort(even2.rbegin(), even2.rend());
	sort(odd2.rbegin(), odd2.rend());
	int even_cnt = even2[0].first;
	int odd_cnt = odd2[0].first;
	if(even2[0].second != odd2[0].second){//一番多い数字の値がそれぞれ違うなら
		int ans = n - even_cnt - odd_cnt;
		cout << ans << endl;
		return 0;
	}
	if(even2.size() == 1 && odd2.size() == 1){
		cout << n/2 << endl;
		return 0;
	}

	if(even2.size() == 1){
		int ans = n - even_cnt - odd2[1].first;
		cout << ans << endl;
		return 0;
	}
	if(odd2.size() == 1){
		int ans = n - odd_cnt - even2[1].first;
		cout << ans << endl;
		return 0;
	}


	int even_cnt2 = even2[1].first;
	int odd_cnt2 = odd2[1].first;
	int ans;
	if(even_cnt + odd_cnt2 > even_cnt2 + odd_cnt) ans = n - even_cnt - odd_cnt2;
	else ans = n - even_cnt2 - odd_cnt;

	cout << ans << endl;

}



Measured memory_bytes: 8996