akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
vector<int> k[5000+2],ans[5000+2],out;
int r[5000+2],n,m;

int s(int x){
	int ans=10000;
	if(r[x]!=NULL)return r[x];
	else {
		int a=k[x].size();
		if(a==0){r[x]=n; return n;}
		else {
			for(int i=0;i<a;i++){
				if(ans>s(k[x][i]))ans=r[k[x][i]];
			}
		}
	}
	r[x]=ans-1;
	return ans-1;
}

int main(){
	int a,b;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d",&a,&b);
		k[a].push_back(b);
	}
	for(int i=1;i<=n;i++){
		if(r[i]==NULL){
			a=s(i);
		}
		ans[r[i]].push_back(i);
	}
	int c=0;
	for(int i=1;i<=n;i++){
		int d=ans[i].size();
		for(int j=0;j<d;j++){
			printf("%d\n",ans[i][j]);
		}
		if(d>1)c=1;
	}
	printf("%d\n",c);
}

Measured memory_bytes: 2320
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>

using namespace std;

#define rep(i,n,m) for(int i=n;i<(int)(m);i++)

unsigned long long int  mmm = (unsigned long long int)pow(10, 9) + 7;

unsigned long long int calc(unsigned long long int x) {
	
	if (x == 1)return 1;
	else {
		return ( (x*calc(x - 1)) % mmm) ;
	}

}



int main() {
	
	unsigned long long int mus,ans;
	
	cin >> mus;
	ans = calc(mus) % mmm;

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair < ll, ll > PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main() {
    int a, b;
    cin >> a >> b;
    if ( (a*b)%2 ==0 ) cout << "Even" << endl;
    else               cout << "Odd" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD ((ll)1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)
template<class F,class S>void add(map<F,S>&mp,F f,S s){if(mp.find(f)==mp.end())mp[f]=F();mp[f]+=s;}
 
int main(){
    ll a,b;
    cin>>a>>b;
    if(a>b)swap(a,b);
    if(a==1){
        if(b==1){
            cout<<1<<endl;
        }else{
            cout<<b-2<<endl;
        }
    }else if(a==2){
        cout<<0<<endl;
    }else{
        cout<<(a-2)*(b-2)<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    long a, b, c, d;
  	long x[4];
    cin >> a >> b >> c >> d;
    x[0] = a*c;
  	x[1] = a*d;
  	x[2] = b*c;
  	x[3] = b*d;
  	
    cout << max(max(x[0], x[1]), max(x[2], x[3])) << endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long int ll;

const ll mod=1e9+7;

int N;
char c[5]={' ','A','G','C','T'};

ll mem[110][5][5][5];

bool check(string s){
    if(s.find("AGC")!=string::npos)return false;
    for(int j=0;j<s.size();++j){
        string t=s;
        swap(t[j],t[j+1]);
        if(t.find("AGC")!=string::npos)return false;
    }
    return true;
}

//A=1,G=2,C=3,T=4;
ll calc(int n,int pc,int ppc,int pppc){
    if(mem[n][pc][ppc][pppc]!=-1)return mem[n][pc][ppc][pppc];
    if(n==N)return 1;
    ll res=0;
    string s="";
    if(pppc!=0)s+=c[pppc];
    if(ppc!=0)s+=c[ppc];
    if(pc!=0)s+=c[pc];
    for(int i=1;i<=4;++i){
        string t=s+c[i];
        if(check(t))res+=calc(n+1,i,pc,ppc)%mod;
    }
    return mem[n][pc][ppc][pppc]=res%mod;
}

int main(){
    for(int i=0;i<110;++i)for(int j=0;j<5;++j)for(int k=0;k<5;++k)for(int l=0;l<5;++l)mem[i][j][k][l]=-1;
    cin>>N;
    cout<<calc(0,0,0,0)<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
const int MOD=998244353;
#define SZ 2333333
ll fac[SZ],rfac[SZ];
inline ll qp(ll a,ll b)
{
    ll ans=1; a%=MOD;
    while(b)
    {
        if(b&1) ans=ans*a%MOD;
        a=a*a%MOD; b>>=1;
    }
    return ans;
}
ll C[SZ];
int main()
{
	fac[0]=1;
	for(int i=1;i<SZ;++i) fac[i]=fac[i-1]*i%MOD;
	rfac[SZ-1]=qp(fac[SZ-1],MOD-2);
	for(int i=SZ-1;i>=1;--i) rfac[i-1]=rfac[i]*i%MOD;
	int n,g;
	cin>>g>>n;
	int h=n-1;
	for(int i=0;i<=h;++i)
		C[i]=fac[h]*rfac[i]%MOD*rfac[h-i]%MOD;
	ll ans=0;
	for(int i=g;i<=n;++i)
		(ans+=C[i-1])%=MOD;
	printf("%d\n",int(ans));
}


Measured memory_bytes: 42624
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
typedef long long int LL;
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="ABC")
        cout<<"ARC"<<endl;
    else
        cout<<"ABC"<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main()
{
  int l,r,d;
  cin>>l>>r>>d;
  
  if(l%d==0)
  {
    cout<<(r/d) - (l/d) + 1 <<endl;
  }
  else
    cout<<(r/d)-(l/d)<<endl;

}

Measured memory_bytes: 3600
import Data.Functor( (<$>))
import Data.Char( toLower, isSpace)

main = do
    w <- getLine
    t <- unlines . takeWhile ("END_OF_TEXT"/=) . lines <$> getContents
    let
	wsize = length w

	prematch con pre = (and $ zipWith (==) w con) && case pre	of
				Nothing -> True
				Just c	-> isSpace c

	search [] hit 0	_	    = hit
	search content@(c:cs) hit numRemain lastChar
	    | numRemain < wsize		    	= hit
	    | prematch content lastChar	&& isSpace (content!!wsize)
					=
						search cs (hit+1) (numRemain-1) (Just c)
	    | otherwise			    	= search cs hit (numRemain-1) (Just c)

	lt = toLower <$> t

    print $ search lt 0 (length lt) Nothing



Measured memory_bytes: 4012
#include<iostream>
#include<algorithm>
#include<utility>


using namespace std;

int main() {
	int n, a[100],count=0;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		int MIN = i;
		for (int j = i; j < n; j++) {
			if (a[j] < a[MIN]) {
				MIN = j;
			}
		}
		if (i != MIN) {
			swap(a[i], a[MIN]);
			count++;
		}
	}
	for (int i = 0; i < n; i++) {
		if (i != 0)cout << " ";
		cout << a[i];
	}
	cout << endl << count << endl;
	return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=405;

int n,m,now;
bool vis[N][N],pos[N];
struct data{int x,y;}a[100005];

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

bool dfs(int t)
{
	if (!t) return 1;
	if (vis[now][a[t].x]&&vis[now][a[t].y]) return 0;
	if (vis[now][a[t].x]) vis[now][a[t].y]=1;
	if (vis[now][a[t].y]) vis[now][a[t].x]=1;
	return dfs(t-1);
}

bool check(int x,int y)
{
	if (!pos[x]||!pos[y]) return 0;
	for (int i=1;i<=n;i++) if (vis[x][i]&&vis[y][i]) return 0;
	return 1;
}

int main()
{
	n=read();m=read();
	for (int i=1;i<=m;i++) a[i].x=read(),a[i].y=read();
	for (int i=1;i<=n;i++) now=i,vis[i][i]=1,pos[i]=dfs(m);
	int ans=0;
	for (int i=1;i<n;i++)
		for (int j=i+1;j<=n;j++)
			if (check(i,j)) ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1152
/**
 * @author      : omgursocute
 * @created     : 23/02/2020
 * @task        : A
 */

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main() {
	// freopen("A.inp", "r", stdin);
	// freopen("A.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	int n, r;
	cin >> n >> r;
	if(n >= 10) cout << r;
	else cout << r + 100*(10-n);

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <functional>
#include <map>
#include <cmath>
#include <deque>
#include <string>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main()
{
	int n;
	scanf("%d",&n);
	vector <P> ans;
	if(n%2==0)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=i+1;j<=n;j++)
			{
				if(i+j==n+1) continue;
				ans.push_back(P(i,j));
			}
		}
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=i+1;j<=n;j++)
			{
				if(i+j==n) continue;
				ans.push_back(P(i,j));
			}
		}
	}
	printf("%d\n",ans.size());
	for(int i=0;i<ans.size();i++) printf("%d %d\n",ans[i].first,ans[i].second);
	return 0;
}


Measured memory_bytes: 384
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        scanner.useDelimiter("");
        int a = scanner.nextInt(), b = scanner.nextInt(), c = scanner.nextInt(), d = scanner.nextInt();
        if (a + b + c + d == 7) System.out.printf("%d+%d+%d+%d=7\n", a, b, c, d);
        else if (a + b + c - d == 7) System.out.printf("%d+%d+%d-%d=7\n", a, b, c, d);
        else if (a + b - c + d == 7) System.out.printf("%d+%d-%d+%d=7\n", a, b, c, d);
        else if (a + b - c - d == 7) System.out.printf("%d+%d-%d-%d=7\n", a, b, c, d);
        else if (a - b + c + d == 7) System.out.printf("%d-%d+%d+%d=7\n", a, b, c, d);
        else if (a - b + c - d == 7) System.out.printf("%d-%d+%d-%d=7\n", a, b, c, d);
        else if (a - b - c + d == 7) System.out.printf("%d-%d-%d+%d=7\n", a, b, c, d);
        else if (a - b - c - d == 7) System.out.printf("%d-%d-%d-%d=7\n", a, b, c, d);
    }
}

Measured memory_bytes: 23252
#!/usr/bin/env/ python3
#S = input()
#R = int(input())
#A, B, C = input().split()
N, M = map(int, input().split())

#N = int(input())
A = [int(x) for x in input().split()]

#H, W = map(int, input().split())
#S = [input() for _ in range(H)]
#print(2*R*3.14159265)

tmp = sum(A)
if(N>=tmp): print(N-tmp)
else: print('-1')


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

using namespace std;

int solve(const int n, const int c, const vector<int>& v, const vector<int>& w) {
    vector<int> dp(c + 1);
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= c; j++) {
            if (j >= w[i]) {
                dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
            }
        }
    }
    return dp[c];
}

int main() {
    int n, c;
    cin >> n >> c;
    
    vector<int> v(n);
    vector<int> w(n);
    
    for (int i = 0; i < n; i++) {
        cin >> v[i] >> w[i];
    }
    int ans = solve(n, c, v, w);
    cout << ans << endl;
    return 0;
}

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

int main(){
    int A,B,K;
    cin >>A>>B>>K;
    int count = 0;

    int m = min(A,B);

    for(int i = m; 0 < i; i-- ){
        //iは変数、mは定数だという認識をちゃんと持っていないと
        //ここをmにしてしまう。
        if(A % i == 0 && B % i == 0){
            count++;
        }
        if(count == K){
            cout << i << endl;
            return 0;
        }
    }
    cout << count << endl;

}

Measured memory_bytes: 256
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    int S,W; scanf("%d %d",&S ,&W);
    if(W >= S) cout<<"un";
    cout<<"safe"<<endl;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    int num, Min = INT_MAX, Max = INT_MIN;
    
    rep(i, n) {
        cin >> num;
        Min = min(Min, num);
        Max = max(Max, num);
    }
    cout << abs(Max - Min) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
 
using namespace std;
 
int dp[1<<14][14];
bool oks[1001];
const int INF=1<<30;
int matrix[101][101];
 
int match(string s1,string s2){
  int res=0;
  for(int i=0;i<(int)min(s1.size(),s2.size());i++){
    //cout<<s2.substr(0,i+1)<<" "<<s1.substr((int)s1.size()-1-i,i+1)<<endl;
    if(s2.substr(0,i+1)==s1.substr((int)s1.size()-1-i,i+1)){
      res=max(res,i+1);
    }
  }
  return res;
}
 
int main(){
  int N;
  while(cin>>N&&N){
    vector<string> vs;
    for(int i=0;i<N;i++){
      string s;
      cin>>s;
      vs.push_back(s);
    }
    memset(oks,0,sizeof(oks));
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
    if(i==j)continue;
    if((int)vs[i].find(vs[j])!=-1){
      oks[j]=true;
    }
      }
    }
    memset(matrix,0,sizeof(matrix));
    vector<string> ss;
    for(int i=0;i<N;i++)
      if(!oks[i])ss.push_back(vs[i]);
    N=ss.size();
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++)
    if(i!=j)
      matrix[i][j]=match(ss[i],ss[j]);
    // for(int i=0;i<N;i++){
    //   for(int j=0;j<N;j++)
    //  cout<<matrix[i][j]<<" ";
    //   cout<<endl;
    // }
    for(int mask=(1<<N)-1;mask>=1;mask--){
      for(int j=0;j<N;j++){
    int res=INF;
    if(mask==(1<<N)-1)res=0;
    for(int k=0;k<N;k++){
      if((mask>>k)&1)continue;
      int nmask=mask|(1<<k);
      res=min(res,dp[nmask][k]-matrix[j][k]+(int)ss[k].size());
    }
    dp[mask][j]=res;
      } 
    }
    int ans=INF;
    for(int i=0;i<N;i++){
      int mask=(1<<i);
      ans=min(ans,dp[mask][i]+(int)ss[i].size());
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1864
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	int n, m, a;

	while(cin >> n >> m >> a, n, m, a) {
		vvi amida(m, vi(3, 0));
		vi player(n, 0);

		REP(i, n) {
			player[i] = i+1;
		}

		REP(i, m) {
			int h, p, q;
			cin >> h >> p >> q;

			amida[i][0] = h;
			amida[i][1] = p;
			amida[i][2] = q;
		}

		sort(RALL(amida));
	
		REP(i, m) {
			int p = amida[i][1];
			int q = amida[i][2];
			int player1 = player[p-1];
			int player2 = player[q-1];

			player[p-1] = player2;
			player[q-1] = player1;
		}	
	
		REP(i, n) {
			if(player[i] == a) {
				cout << i+1 << endl;
				break;
			}
		}	
	}
}

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;

typedef long long ll;

class ModInt{
public:
    long long n;
    int p;

    ModInt(){
    }

    //値と割る値を受け取って、オブジェクトを返す
    ModInt(long long _n, int _p){
        p = _p;
        n = _n % _p;

        //負の値を受け取ったときには正の値に戻す
        if(n < 0){
            n += p;
        }
    }

    ModInt operator+(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n += a.n;

        if(tmp.n > tmp.p){
            tmp.n -= tmp.p;
        }
        
        return tmp;
    }

    ModInt operator-(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n -= a.n;

        if(tmp.n < 0){
            tmp.n += tmp.p;
        }

        return tmp;
    }

    ModInt operator*(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n = (tmp.n * a.n) % tmp.p;

        return tmp;
    }

    int modpow(int b, int k){
        if(k == 0){
            return 1;
        }else if(k % 2 == 1){
            long long tmp = b;
            tmp = tmp * modpow(b, k - 1) % p;
            
            return tmp;
        }else{
            long long tmp = modpow(b, k / 2);
            return tmp * tmp % p;
        }
    }

    int modinv(int b){
        return modpow(b, p - 2);
    }

    ModInt operator/(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n = tmp.n * modinv(a.n) % tmp.p;
        return tmp;
    }
};

ModInt mypow(ModInt a, int k){
    if(k == 0) return ModInt(1, MODN);

    if(k % 2 == 1){
        ModInt tmp = mypow(a, (k - 1) / 2);
        return tmp * tmp * a;
    }else{
        ModInt tmp = mypow(a, k / 2);
        return tmp * tmp;
    }
}

int main(){

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

    vector<ModInt> fact(n + 1, ModInt(1, MODN));

    rep(i, n){
        fact[i + 1] = fact[i] * ModInt(i + 1, MODN);
    }

    function<ModInt(int,int)> combi = [&](int l, int r) -> ModInt{

        return fact.at(l) / fact.at(r) / fact.at(l - r);
    };

    vector<ModInt> v(2 * 100000 + 1, ModInt(0, MODN));

    for(int i = n; i > 0; i--){

        int notexist = n - i;
        if(notexist > k) break;

        if(n < i || n - 1 < notexist){
            cerr << i << " " << notexist << endl;
        }

        v[i] = combi(n, i) * combi(n - 1, notexist);
    }

    ModInt ans = ModInt(0, MODN);

    rep(i, 2 * 100000 + 1){
        ans = ans + v[i];
    }

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


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

int main() {
	static long long dp[2020][2020];

	int n;
	long long x;
	cin >> n >> x;

	vector<long long> a(n);
	static long long cost[2020][2020];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cost[0][i] = a[i];
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j > 0) {
				cost[i][j] = min(cost[i - 1][j], cost[i - 1][j - 1]);
			} else {
				cost[i][j] = min(cost[i - 1][j], cost[i - 1][n - 1]);
			}
		}
	}

	long long ans = 1e18;
	for (int i = 0; i < n; i++) {
		long long cand = 0;
		for (int j = 0; j < n; j++) {
			cand += cost[i][j];
		}
		ans = min(ans, cand + i * x);
	}
	cout << ans << endl;
}

Measured memory_bytes: 31872
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
  
void colorEdges(int ptr, vector<vector<pair<int, int> > >& gra, 
                vector<int>& edgeColors, bool isVisited[]) 
{ 
    queue<int> q; 
    int c = 0; 
  
    set<int> colored;
    
    if (isVisited[ptr]) 
        return; 

    isVisited[ptr] = 1; 
  
    for (int i = 0; i < gra[ptr].size(); i++) { 

        if (edgeColors[gra[ptr][i].second] != -1) 
            colored.insert(edgeColors[gra[ptr][i].second]); 
    } 
  
    for (int i = 0; i < gra[ptr].size(); i++) { 

        if (!isVisited[gra[ptr][i].first]) 
            q.push(gra[ptr][i].first); 
  
        if (edgeColors[gra[ptr][i].second] == -1) { 

            while (colored.find(c) != colored.end()) 

                c++; 

            edgeColors[gra[ptr][i].second] = c; 

            colored.insert(c); 
            c++; 
        } 
    }
    
    while (!q.empty()) { 
        int temp = q.front(); 
        q.pop(); 
  
        colorEdges(temp, gra, edgeColors, isVisited); 
    } 
  
    return; 
} 
 
int main() 
{ 
    int n,a,b;
    cin>>n;
    
    set<int> empty;
    vector<vector<pair<int, int> > > gra; 
  
    vector<int> edgeColors; 
  
    bool isVisited[100001] = { 0 }; 
  
    int ver = n; 
    int edge = n-1; 
  
    gra.resize(ver); 
    edgeColors.resize(edge, -1); 

    for(int i=0;i<n-1;i++){
        cin>>a>>b; a--,b--;
        gra[a].push_back(make_pair(b, i)); 
        gra[b].push_back(make_pair(a, i)); 
    }
  
    colorEdges(0, gra, edgeColors, isVisited);
    int m=0;
    for (int i = 0; i < edge; i++) 
        m = max(m,edgeColors[i] + 1);
    cout<<m<<"\n";
    for (int i = 0; i < edge; i++) 
        cout << edgeColors[i] + 1 << "\n"; 
  
    return 0; 
} 

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

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}


void solve(long long n){
    cout << 1110-n<<endl;
}

int main(){
    long long n;
    scanf("%lld",&n);
    solve(n);
    return 0;
}


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

using namespace std;

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

#define pb push_back
#define ff first
#define ss second
#define SIZE 1000001
#define INF int(2e9 + 9)
#define BIG_INF ll(4e18 + 9)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define _sz(v) int((v).size())
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

//#pragma GCC optimize("Ofast")

ll binpow(ll a, ll b, ll mod = BIG_INF)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res *= a;
        a *= a;
        b >>= 1;
        a %= mod;
        res %= mod;
    }
    res %= mod;
    return res;
}




int T = 1, n, a, b, c, d;
string s;

map<string, bool> used;


void solve()
{
    cin >> n;
    while(n--)
    {
        cin >> s;
        used[s] = 1;
    }

    cout << _sz(used);

}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

//    cin >> T;

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




    return 0;
}


Measured memory_bytes: 19236
#include<stdio.h>
int bubbleSort(int[], int);
int main(){
  int N, i, con;
  int A[100];

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

  con = bubbleSort(A, N);

  printf("%d",A[0]);
  for( i = 1 ; i < N ; i++ ){
    printf(" %d",A[i]);
  }
  printf("\n%d\n",con);
  return 0;
}

int bubbleSort(int A[], int N){
  int j, tmp, con=0;
  int flag=1;
  while( flag ){
    flag = 0;
    for( j = N-1 ; j > 0 ; j-- ){
      if( A[j] < A[j-1] ){
	con++;
	tmp = A[j];
	A[j] = A[j-1];
	A[j-1] = tmp;
	flag = 1;
      }
    }
  }
  return con;
}



Measured memory_bytes: 2140
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);

  int a,b,h; cin >> a >> b >> h;
  cout << (a+b)*h/2.0;

  return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.buffer.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
N,K,Q = map(int,input().split())
points = [K-Q]*N
for _ in range(Q):
    a = int(input())
    points[a-1] += 1
for i in points:
    if i > 0:
        print("Yes")
    else:
        print("No")

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

int main()
{
    int c[4] {0};
    for(int i = 0; i < 3; i++){
        int a, b;
        cin >> a >> b;
        c[a - 1]++;
        c[b - 1]++;
    }
    int r = 0;
    for(int i = 0; i < 4; i++) r += c[i] % 2;
    if(r == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdlib;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;

    auto K = N % 2 ? 2 : 1;
    auto dp = new long[][](N + 5, K + 1);
    foreach (ref d; dp) d[] = -(1L << 59);
    dp[0][0] = 0;
    dp[1][1] = 0;
    if (K == 2) dp[2][2] = 0;

    foreach (i; 0..N) foreach (k; 0..K+1) {
        dp[i + 2][k] = max(dp[i + 2][k], dp[i][k] + A[i]);
        if (k + 1 <= K) dp[i + 3][k + 1] = max(dp[i + 3][k + 1], dp[i][k] + A[i]);
        if (k + 2 <= K) dp[i + 4][k + 2] = max(dp[i + 4][k + 2], dp[i][k] + A[i]);
    }

    long ans = -(1L << 59);

    foreach (i; N..N+5) ans = max(ans, dp[i][K]);
    ans.writeln;
}

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

int main (){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r ;
    
    if(0<x && 0<y && r<=x&&x<=W-r && r<=y&&y<=H-r ){
        cout << "Yes" << endl;
    }
    else{ cout << "No" << endl;}
    
    return 0;
    
        
}

Measured memory_bytes: 3092
let inputs = readLine()!.split(separator: " ").map { Int($0)! }

let X = inputs[0]
let N = inputs[1]

if N == 0 {
  print(X)
} else {
	let banned = Set(readLine()!.split(separator: " ").map { Int($0)! })
  	var lessThan = X
  	var graterThan = X
  	for num in X...101 {
      if !banned.contains(num) {
        graterThan = num
        break
      }
    }
  	for num in (0...X).reversed() {
      if !banned.contains(num) {
        lessThan = num
        break
      }
    }
  	if (graterThan - X) * (graterThan - X) > (lessThan - X) * (lessThan - X) {
      print(lessThan)
    } else if (graterThan - X) * (graterThan - X) < (lessThan - X) * (lessThan - X) {
      print(graterThan)
    } else {
      print(lessThan)
    }
}

Measured memory_bytes: 8436
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   long long N;
   long long K;
   cin >> N >> K;
   cout << min(N%K, K-N%K) << endl;;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define LLI long long int
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void cout_join(I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)cout<<d;cout<<*i;}cout<<endl;}

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

  LLI N,Q;
  string S;
  cin >> N >> S >> Q;

  REP(_,Q){
    LLI k; cin >> k;

    LLI sum_m = count(ALL(S), 'M');

    vector<LLI> count_m(N+1, 0);
    REP(i,N) if(S[i] == 'M') count_m[i+1]++;
    REP(i,N) count_m[i+1] += count_m[i];

    vector<LLI> count_d(N+1, 0);
    REP(i,N) if(S[i] == 'D') count_d[i+1]++;
    REP(i,N) count_d[i+1] += count_d[i];
    //    cout_join(ALL(count_d));

    vector<LLI> count_dm(N+1, 0);
    REP(i,N){
      if(S[i] == 'D'){
	count_dm[i] = sum_m - count_m[i];
      }
    }
    REV(i,N-1,0) count_dm[i] += count_dm[i+1];
    //    cout_join(ALL(count_dm));
    
    LLI ans = 0;
    REP(i,N){
      if(S[i] == 'C'){
	LLI temp = count_dm[max(0LL,i-k+1)] - count_dm[i] - (sum_m - count_m[i]) * (count_d[i] - count_d[max(0LL,i-k+1)]);
	//cerr << temp << endl;
	ans += temp;
      }
    }
    
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 25288
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
using namespace std;
int main() {
    int  time = 0;
    int temp  = 0;
    int t2 = 0;
    vector <pair<int, int>> p;
    for(int i = 0; i < 5; i++){
        cin >> temp;
        if (temp % 10 == 0)
            t2 = 0;
        else
            t2 = 10 - temp % 10;
        p.emplace_back(make_pair(t2, temp));
    }
    sort(p.begin(), p.end());
    for(int i = 0; i < 5; i++){
        if (time % 10 != 0)
            time = time + 10 - time % 10;
        time += p[i].second;
    }
    cout << time;
    return 0;
}


Measured memory_bytes: 888
/*
 * author :Sadik Hassan(_sad_)
 *
*/
#include "bits/stdc++.h"
using namespace std;
using   ll       =    long long;
using   ld       =    long double;
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define MP            make_pair
#define PI            (acos(-1.0))
#define rep1(i,n)     for(int i=1;i<=n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         (int)s.size()
#define all(x)        (x).begin(), (x).end()
#define rall(x)       (x).rbegin(), (x).rend()
#define w(t)          int t;cin>>t;while(t--)
#define TSU(s)        transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSL(s)        transform(s.begin(),s.end(),s.begin(),::tolower);
#define _SAD()     	  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cout<<fixed<<setprecision(15);

typedef vector<int>vi;
typedef vector<ll>vii;
typedef set<int>si;
typedef set<ll>sii;
/*---------------------------------------------------------------------*/

const int N = (int)1e6+1;
const ll MOD =(ll)1e9+1147483647;
const ll INF = (ll)1e18+5;

int main()
{
    _SAD()
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    while(k--)
    {
        if(b<=a)
        {
            b*=2;
        }
        else if(c<=b)c*=2;
    }
    if(c>b&&b>a)cout<<"Yes"<<nl;
    else cout<<"No"<<nl;
    return 0;
}


Measured memory_bytes: 3644
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    int n;cin>>n;
    vector<int> a(n);
    rep(i, n) {
        cin>>a[i];
    }
    sort(all(a), greater<int>());
    dump(a);

    priority_queue<int> pq;
    pq.push(a[0]);

    ll ans = 0;
    rep(i, 1, n){
        int v = pq.top();pq.pop();
        ans += v;
        pq.push(a[i]);
        pq.push(a[i]);
        dump(ans);
    }
    cout << ans << endl;

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 5060
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long n, a[200009];

long long fun(int x)
{
	long long retval = 0;
	for (int i = 1; i <= n; i++) {
		retval += abs(a[i] - x);
	}
	return retval;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] -= i;
	}
	int l = -2e5, r = 1e9 + 1;
	while (l + 1 < r) {
		int mid = (l + r) / 2;
		int L = mid - 1;
		if (fun(L) > fun(mid)) l = mid;
		else r = mid;
	}
	cout << fun(l) << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define fish        push_front
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Deque       std::deque
#define PQueue      std::priority_queue
#define Set         std::set
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B, class C> A power ( A x, B n, C mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A> A lcm ( A x, A y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A> inline boolean chmax ( A &a, const A &b ) { return b > a ? a = b, true : false; }
    template<class A> inline boolean chmin ( A &a, const A &b ) { return b < a ? a = b, true : false; }
    inline boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    int ans[100100];

    signed call_of_Cthulhu( signed datum ) {

        int n;
        read n;

        for ( int i = 0; i < n; i++ ) {
            int a;
            read a;
            ans[a]++;
            ans[a+1]++;
            ans[a+2]++;
        }
        int a = 0;
        for ( int i = 0; i < 100100; i++ ) {
            chmax(a, ans[i]);
        }
        echo a fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    string N;
    cin >> N;
    cout << "ABC" + N << endl;
    
    
    return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int N, A, B; cin >> N >> A >> B;
	string S; cin >> S;

	int num = 0;
	int ab = 0;
	REP(i,N){
		if(S[i] == 'a'){
			if(num < A+B){
				cout << "Yes" << endl;
				num++;
			}else{
				cout << "No" << endl;
			}
		}else if(S[i] == 'b'){
			if(num < A+B and ab < B){
				cout << "Yes" << endl;
				ab++;
				num++;
			}else{
				cout << "No" << endl;
			}
		}else{
				cout << "No" << endl;
		}
	}

	return 0;

}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	int a,b,c,t[105]={};
	cin>>a>>b>>c;
	for(int i=1;;i++)
	{
		int k=a*i;
		if(t[k%b]==0)
		{
			t[k%b]++;
		}
		else break;
	}
	for(int i=0;i<b;i++)
	{
		if(t[i]&&i-c==0)
		{
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}
	

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<limits>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define clr(a,v) memset((a),(v),sizeof(a))

const int MAX_N = 100, INF = std::numeric_limits<int>::max()>>2;

int n;
int r[MAX_N], c[MAX_N];
std::vector<std::vector<int> > dp( MAX_N, std::vector<int>( MAX_N, INF ) );

/*int rec( int b, int e )
{
    if( b == e )
        return dp[b][e] = 0;

    if( ~dp[b][e] )
        return dp[b][e];

    int ret = INF;

    rep( i, e-b )
        ret = std::min( ret, rec( b, b+i )+rec( b+i+1, e )+r[b]*c[b+i]*c[e] );

    return dp[b][e] = ret;
}*/

int main()
{
    scanf( "%d", &n );
    rep( i, n )
        scanf( "%d%d", r+i, c+i );

    rep( i, n )
        dp[i][i] = 0;

    repi( w, 1, n ) rep( i, n ) if( i+w < n ) repi( j, i, i+w )
        dp[i][i+w] = std::min( dp[i][i+w], dp[i][j]+dp[j+1][i+w]+r[i]*c[j]*c[i+w] );

    printf( "%d\n", dp[0][n-1] );

    return 0;
}

Measured memory_bytes: 2824
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  Graph train(N, vi(N, 0));
  rep(i,M) {
    int L, R;
    cin >> L >> R;
    ++train[--L][--R];
  }

  for (int i=1; i<N; ++i) {
    for (int j=0; i+j<N; ++j) {
      train[j][i+j] += train[j][i+j-1] + train[j+1][i+j] - train[j+1][i+j-1];
    }
  }

  rep(i,Q) {
    int p, q;
    cin >> p >> q;
    cout << train[--p][--q] << endl;
  }
  return 0;
}


Measured memory_bytes: 1920
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
    return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
    for (const vector<T> &x : v)
        out << x << '\n';
    return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
    for (const T &x : v)
        out << x << ' ';
    return out;
}

long long gcd (long long a, long long b)
{
    if (b > a)
        swap(a, b);
    return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
    ios::sync_with_stdio(false);
    #ifdef ONLINE_JUDGE
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.setstate(ios::failbit);
    #endif

    int n, k;
    cin >> n >> k;
    vi a(n);
    cin >> a;
    rep(i,k,n)
    {
        cout << (a[i] > a[i-k] ? "Yes" : "No") << '\n';
    }
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


const int MAX_N = 2000000;
ll inv[MAX_N + 10];
ll fac[MAX_N + 10], facInv[MAX_N + 10];
class MATH{
public:
	MATH(){
		inverse();
		factroial();
	}
	ll nCk(ll n, ll k){// n! / k!*(n-k)!
		if(k < 0 || k > n) return 0;
		ll ret = fac[n];
		(ret *= facInv[k]) %= MOD;
		(ret *= facInv[n - k]) %= MOD;
		return ret;
	}
	ll nHk(ll n, ll k){// nHk = n+k-1 C k = (n+k-1)! / k! * (n-1)!
		if(n == 0 && k == 0) return 1;
		ll ret = fac[n + k - 1];
		(ret *= facInv[k]) %= MOD;
		(ret *= facInv[n - 1]) %= MOD;
		return ret;
	}
	ll nPk(ll n, ll k){//nPk = n! / (n-k)!
		if(k < 0 || k > n) return 0;
		ll ret = fac[n];
		(ret *= facInv[n - k]) %= MOD;
		return ret;
	}
private:
	void inverse(void){
		inv[1] = 1;
		for (int i = 2; i <= MAX_N; ++i){
			// inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
			inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		}
	}
	void factroial(void){
		fac[0] = facInv[0] = 1;
		for (int i = 1; i <= MAX_N; ++i){
			fac[i] = (fac[i - 1] * i) % MOD;
			facInv[i] = (facInv[i - 1] * inv[i]) % MOD;
		}
	}
};

vector<pair<int, int>> factorization(ll x) {
	vector<pair<int, int>> v;
	for (int i = 2; i * i <= x + 1; ++i) {
		int cnt = 0;
		while(x % i == 0) {
			x /= i;
			cnt++;
		}
		if (cnt == 0) continue;
		v.push_back(make_pair(i, cnt));
	}
	if (x != 1) v.push_back(make_pair(x, 1));
	return v;
}

int main() {
	int n; ll m; cin >> n >> m;
	auto p = factorization(m); {
		// for (auto u : p) printf("%d %d\n", u.first, u.second);
	}

	ll ans = 1;
	MATH ma;
	for (auto u : p) {
		int b = u.second;
		ans *= ma.nCk(b + n - 1, n - 1);
		// printf("b %d b+n-1 %d n %d %lld\n", b, b+n-1, n, ma.nCk(b + n - 1, n - 1));
		ans %= MOD;
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int ans = 0;
    double heikin = 0;
    int uwara = 0;
    vector<int>usi(N);
    sort(usi.begin(), usi.end());
        for(int i = 0; i < N; i++){
        cin >> usi[i];
        heikin += usi[i];
        uwara += usi[i];
        }
    int X = 0;
        if(heikin/N-uwara/N < uwara/N+1-heikin/N){
          X = uwara/N;
        }
        else{
          X = uwara/N+1;
        }
        for(int i = 0; i < N; i++){
            if(X > usi[i]){
              ans+=(X-usi[i])*(X-usi[i]);
            }
            else {
              ans+=(usi[i]-X)*(usi[i]-X);
            }
        }
    cout << ans << endl;
}


Measured memory_bytes: 256