akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FASTIO ios_base::sync_with_stdio(false);cout.tie(NULL);cout.tie(NULL);
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<ll>
const ll MAX=1e6;
const ll mod=1e9+7;
const ll inf=1e18+12;
set< pair<ll,ll> >ss;

ll arr[MAX];
                                                              //SAMEER KUMAR SINGH//
//================================================================================================================================//

int main(){
   FASTIO;
   ll tt=1;
   //cin>>tt;

   while(tt--){
        ll n;cin>>n;
        ll a[3][n];
        for(ll i=0;i<n;i++){
           cin>>a[0][i]>>a[1][i]>>a[2][i];
        }

        ll ans[3][n];

        ans[0][0]=a[0][0];
        ans[1][0]=a[1][0];
        ans[2][0]=a[2][0];

        for(ll i=1;i<n;i++){
          for(ll k=0;k<3;k++){
              ll ele=INT_MIN;
              for(ll j=0;j<3;j++){
              if(j!=k)
               ele=max(ele,ans[j][i-1]);
              }
              ans[k][i]=ele+a[k][i];
          }
        }

        cout<<max(max(ans[0][n-1],ans[1][n-1]),ans[2][n-1])<<"\n";

   }

   return 0;
}


Measured memory_bytes: 4992
A,B,K = map(int,input().split())
cnt=0

ans_list = []
for i in range(1,min(A,B)+1):
  if (A%i==0) and (B%i==0):
    ans_list.append(i)
ans_list = ans_list[::-1]
print(ans_list[K-1])

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

using namespace std;

int N, M, mx;
vector<int> v;

bool can(int K)
{
    mx = -1;
	for(int i = 0; i < K / 2; i++)
        mx = max(mx, v[i] + v[K - i - 1]);
    for(int i = K; i < K + (2 * N - K) / 2; i++)
    {
        if(v[i] + v[2 * N - (i - K) - 1] < M)
            return false;
        mx = max(mx, v[i] + v[2 * N - (i - K) - 1] - M);
    }
    return true;
}

int main()
{
	//freopen("1.in", "r", stdin);

	scanf("%d%d", &N, &M);
	for(int i = 1; i <= 2 * N; i++)
	{
		int x;
		scanf("%d", &x);
		v.push_back(x);
	}
	sort(begin(v), end(v));

	int p = 0, u = N;
	int ans = N;
	while(p <= u)
	{
		int mij = p + (u - p) / 2;
		if( can(2 * mij) )
		{
			ans = mij;
			u = mij - 1;
		}
		else
			p = mij + 1;
	}
	can(2 * ans);
	printf("%d\n", mx);
}


Measured memory_bytes: 1400
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <complex>
#include <stdio.h>
#include <unordered_set>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 2e9 + 1;
const LL LINF = 1e12;
const LL MAXN = 5e3 + 1;
const LD EPS = 1e-6;

int gcd(int x, int y)
{
	if (!y)
		return x;
	return gcd(y, x%y);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

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

	if (n > m)
		swap(n, m);

	if (n == 1)
	{
		cout << "Yes";
		return 0;
	}

	FOR(a, 0, m + 1)
		FOR(b, 0, n + 1)
	{
		int x = a * n + b * m - 2 * a * b;
		if (x == k || x == n*m - k)
		{
			cout << "Yes";
			return 0;			
		}
	}

	cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void trace(int A[], int N) {
	for ( int i = 0; i < N; i++) {
		if ( i>0 ) printf(" "); 
		printf("%d", A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N) {
	int i, j, v;
	for( i = 1; i < N; i++ ){
		v = A[i];
		j = i - 1;
		while( A[j] > v && j>=0 ) {
			 A[j + 1] = A[j];
		     j--;
		}
	    A[j + 1] = v;
		trace(A, N);	  
   }
}


int main () {
	int N, i, j;
	int A[100];
	scanf("%d", &N);
	for( i=0; i<N; i++) scanf("%d", &A[i]);
	trace(A,N);
	insertionSort(A,N);
	return 0; 	
}

Measured memory_bytes: 2700
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;

int main(){
  int a,b;
  cin >> a >> b;
  cout << a*b -a-b+1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>

using namespace std;

int main(){
	
	while(true){
		
		double a, b, c, d;;
		
		cin >> a >> b >> c >> d;
		
		if(b < 0 || d < 0){
			break;
		}
		
		a = a * M_PI / 180;
		b = b * M_PI / 180;
		c = c * M_PI / 180;
		d = d * M_PI / 180;
		
		double x1, y1, z1, x2, y2, z2;
		
		x1 = cos(a) * cos(b);
		y1 = sin(a);
		z1 = cos(a) * sin(b);
		x2 = cos(c) * cos(d);
		y2 = sin(c);
		z2 = cos(c) * sin(d);
		
		double dist_linear_2 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2);
		
		double dist_rad = acos((2 - dist_linear_2) / 2);
		
		int dist = (int)(dist_rad * 6378.1 + 0.5);
		
		cout << dist << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
#include <map>
#include <math.h>
#include <list>

using namespace std;

int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	string s;
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '7') {
			cout << "Yes" << endl;
			return 0;

		}

	}

	cout << "No" << endl;


	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
int main() {
    ll n;
    ll ans  = -15*1e8;
    cin >> n;
    vector<int>b(n, 0);
    rep(i, n - 1){
        int a;
        cin >> a;
        b[a - 1] ++;
    }
    rep(i, n) cout << b[i] << endl;
    
    return 0;
}


Measured memory_bytes: 4048
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var [n,m]=arr.shift().split(" ").map(Number);
var lane=[];
for(var i=0;i<n;i++)lane[i]=[];
arr.forEach(v=>{
   var [a,b]=v.split(" ").map(Number);
   if(a==0)console.log(lane[b-1].shift());
   else if(a==1){
      var m=lane.map(v=>v.length);
      var s=m.indexOf(Math.min(...m));
      lane[s].push(b);
   }
});



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

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

using namespace std;
using graph=vector<vector<int>>;

int MOD;
class mint{
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

graph T;
mint dp1[100000],dp2[100000];

void dfs1(int u,int p){
	dp1[u]=1;
	for(int v:T[u]) if(v!=p) {
		dfs1(v,u);
		dp1[u]*=dp1[v]+1;
	}
}

void dfs2(int u,int p){
	vector<mint> C;
	for(int v:T[u]) if(v!=p) C.emplace_back(dp1[v]+1);

	int k=C.size();
	vector<mint> rprod(k+1);
	rprod[k]=1;
	for(int i=k-1;i>=0;i--) rprod[i]=rprod[i+1]*C[i];

	mint lprod=1;
	int idx=0;
	for(int v:T[u]) if(v!=p) {
		dp2[v]=dp2[u]*lprod*rprod[idx+1]+1;
		dfs2(v,u);
		lprod*=C[idx];
		idx++;
	}
}

int main(){
	int n; scanf("%d%d",&n,&MOD);
	T.resize(n);
	rep(i,n-1){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		T[u].emplace_back(v);
		T[v].emplace_back(u);
	}

	dp2[0]=1;
	dfs1(0,-1);
	dfs2(0,-1);

	rep(u,n) printf("%d\n",(dp1[u]*dp2[u]).to_int());

	return 0;
}


Measured memory_bytes: 22144
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main() {
  long n,i,t,p,j,l;
  int q;
  scanf("%ld %d", &n, &q);

  long *time,*order,*finish,*half;
  char **name;
  time = (long*)malloc(sizeof(long)*n);
  finish = (long*)malloc(sizeof(long)*n);
  name = (char**)malloc(sizeof(char*)*n);
  order = (long*)malloc(sizeof(long)*n);
  for(i = 0; i < n; i++) {
    name[i] = (char*)malloc(sizeof(char)*11);
    scanf("%s %ld", name[i], time+i);
  }
  t = 0;
  p = 0;
  while(t < n/2) {
    for(i = 0; i < n; i++) {
      if(time[i] > 0) {
	time[i] -= q;
	p += q;
	if(time[i] <= 0) {
	  p += time[i];
	  finish[t] = p;
	  order[t] = i;
	  t++;
	}
      }
    }
  }
  j = 0;
  l = n - n/2;
  half = (long*)malloc(sizeof(long)*l);
  for(i = 0; i < n; i++) {
    if(time[i] > 0) {
      half[j] = i;
      j++;
    }
  }
  while(t < n) {
    for(i = 0; i < l; i++) {
      if(time[half[i]] > 0) {
	time[half[i]] -= q;
	p += q;
	if(time[half[i]] <= 0) {
	  p += time[half[i]];
	  finish[t] = p;
	  order[t] = half[i];
	  t++;
	}
      }
    }
  }
  

  for(i = 0; i < n; i++) {
    printf("%s %ld\n", name[order[i]], finish[i]);
  }
  
  return 0;
}

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

using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define per(i,n) for(int i=(n)-1; i>=0; i--)
using namespace std;
using vi = vector<int>;
using vv = vector<vi>;
const int MOD = 1000000007;

int main(){
    int n,m;cin>>n>>m;
    
    vi a(n,0);
    rep(i,m){
        int b;cin>>b;
        a[b]++;
    }
    
    vector<long long> dp(n+2,0);
    dp[0] = 1;
    
    for(int i=0; i<n; i++){
        if(a[i])continue;
        
        dp[i+2] += dp[i];
        dp[i+2] %= MOD;
        dp[i+1] += dp[i];
        dp[i+1] %= MOD;
    }
    
    cout << dp[n] << endl;
    
    return 0;
}

Measured memory_bytes: 4548
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N,M;
    cin>>N>>M;
    vector<int> p(M);
    vector<string> S(M);
    rep(i,M){
        cin>>p[i]>>S[i];
        p[i]--;
    }

    vector<bool> ACed(N,false);
    vector<int> pena(N,0);
    rep(i,M){
        if(ACed[p[i]])continue;
        if(S[i] == "AC"){
            ACed[p[i]] = true;
        }
        if(S[i] == "WA")pena[p[i]]++;
    }
    int penasum = 0;
    int acsum = 0;
    rep(i,N){
        if(ACed[i]){
            acsum++;
            penasum += pena[i];
        }
    }
    cout<<acsum<<" "<<penasum<<endl;
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
long long  int a, b,n,x,y;
int main()
{
    cin >> a >> b >> n;
    /* for (int i = 1; i <= n; i++)
    {
     //   cout << i << " ";
        x = (a * i) / b;
        y = i / b;
        y *= a;
       // cout << "x=" << x << " " << "y=" << y << endl;
        cout << x - y << endl;
    }*/
    if (n < b)
    {
        x = (a * n)/b;
        y = n / b;
        y *= a;
        cout << x - y << endl;
    }
    else
    {
        n = b - 1;
        x = (a * n) / b;
        y = n / b;
        y *= a;
        cout << x - y << endl;
    }
}

Measured memory_bytes: 3192
#include<stdio.h>
#include<string.h>
int main(void){
    char s[200];
    int k;
    scanf("%d",&k);
    scanf("%s",s);
    if(strlen(s)<=k){
        printf("%s",s);
    }
    else{
        for(int i=0;i<k;i++){
            printf("%c",s[i]);
            
        }
        printf("...");
    }
    return 0;

}

Measured memory_bytes: 1732
var x,y,i,j,cou,k:integer;
m:array[1..100,1..100]of char;
begin 
  readln(x,y);
  for i:=1 to x do 
  begin 
    cou:=0;
    for j:=1 to y do 
       begin read(m[i,j]);if m[i,j]='.' then inc(cou);end;
    if cou=y then for k:=1 to y do m[i,k]:='*';
    readln;
  end;
  for i:=1 to y do
  begin
    cou:=0;
    for j:=1 to x do 
      if m[j,i]='#' then inc(cou);
    if cou=0 then for k:=1 to x do m[k,i]:='*';
  end;
  for i:=1 to x do 
    begin
		cou:=0;
		for j:=1 to y do
		if m[i,j]<>'*' then begin write(m[i,j]);cou:=1;end;
		if cou=1 then writeln; 
    end;
end.

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

struct DSU{
	int S;
	struct node{
		int parent; ll sum;
	};
	vector<node> dsu;
	DSU(int n){
		S = n;
		rep(i, n){
			node tmp;
			tmp.parent = i; tmp.sum = 1;
			dsu.pb(tmp);
		}
	}
	int root(int u){
		if(dsu[u].parent == u) return u;
		dsu[u].parent = root(dsu[u].parent);
		return dsu[u].parent;
	}
	void merge(int u, int v){
		u = root(u); v = root(v);
		if(u == v) return;
		if(getsum(u) < getsum(v)) swap(u, v);
		dsu[v].parent = u;
		dsu[u].sum += dsu[v].sum;
	}
	bool sameset(int u, int v){
		if(root(u) == root(v)) return true;
		return false;
	}	
	ll getsum(int u){
		return dsu[root(u)].sum;
	}
};

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, m;
	cin >> n >> m;
	DSU dsu(n);
	rep(i, m){
		int a, b;
		cin >> a >> b;
		a--, b--;
		dsu.merge(a, b);
	}
	int tot = 0;
	rep(i, n) if(dsu.root(i) == i) tot++;
	cout << tot - 1 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 5340
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>

#define PI 3.14159265359

#define INF 1000000;

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

using namespace std;


/*
class ElectronicPetEasy
{
public:
	string isDifficult(int st1, int p1, int t1, int st2, int p2, int t2)
	{
		
	}
};
*/


int main()
{
	int N, M, P, a[101] = {0}, s = 0;
	
	while (cin >> N >> M >> P, N)
	{
		s = 0;
		for (int i=1; i<=N; i++)
		{
			cin >> a[i];
			s += a[i];
		}
		if (a[M])
		{
			cout << s*(100-P)/a[M] << endl;
		} else {
			cout << 0 << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int x;
  cin >> x;
  if(x==0) cout << 1 << endl;
  else if(x==1) cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3548
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=10007
//Tuvshee
 
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cctype>
#include<vector>
#include<queue>
using namespace std;
#define I int
#define D double
#define F float
#define C char
#define S string
#define B bool
#define L long long
#define rep(n) for(int i=0;i<n;i++)
#define reps(m,n,c) for(int c=m;c<n;c++)
#define repd(m,n,j) for(int j=n;j>m;j--)
#define whL while
#define eL endl
#define oR ||
#define anD &&
#define rtn return
#define pause system("PAUSE")
#define Max 300
#define max(m,n) ((n<m)?m:n)
#define min(m,n) ((n>m)?m:n)
 
int main()
{
	I m,n;
	for(int i=1;;i++){
		cin>>m>>n;
		if(m==0 anD n==0)break;
		cout<<min(m,n)<<' '<<max(m,n)<<eL;
	}
	rtn 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;



int main(){
  double N;
  cin >> N;
  vector<int> data(N);
  rep(i,0,N){
      cin >> data.at(i);
  }
  double sum;
  double ave;
  rep(i,0,N){
      sum += data.at(i);
  }
  ave = sum/N;
  int point;
  if(ave-(int)ave>0.5){
      point=int(ave)+1;
  }else{
      point= int(ave);
  }
  int ans=0;

  rep(i,0,N){
      ans+=(data.at(i)-point)*(data.at(i)-point);
  }
 // cout << ave << endl;
 // cout << point << endl;
  cout << ans << endl;
  


  return 0;
}

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

int main(){
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		
		vector<int> w(n+1);
		for(int i=0; i<n; i++) cin >> w[i];
		
		vector<vector<int> > dp(n+1, vector<int>(n+1, 0));
		for(int i=2; i<=n; i++){
			for(int j=0; j+i<=n; j++){
				for(int k=1; k<i; k++){
					dp[j][i] = max(dp[j][i], dp[j][k] +dp[j+k][i-k]);
				}
				if(dp[j+1][i-2]==i-2 && abs(w[j]-w[j+i-1])<=1){
					dp[j][i] = i;
				}
			}
		}
		cout << dp[0][n] << endl;
	} 
	return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

void read() {
vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;
cin >> k;
k--;
cout << a[k];
}

void run() {

}

void write() {

}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
} 

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

using namespace std;

int main (void) {
    int n;
    cin >> n;
    vector<vector<int>> s_chars(n, vector<int>(26, 0));
    for ( int i = 0; i < n; i++ ) {
        string s;
        cin >> s;
        for ( auto itr : s )
            s_chars.at(i).at(itr - 'a')++;
    }

    /* 各文字を使える回数は s_chars の最小値分 */
    vector<int> ans(26, INT_MAX);
    for ( int alpha = 0; alpha < 26; alpha++ ) {
        for ( int i = 0; i < n; i++ )
            ans.at(alpha) = min(ans.at(alpha), s_chars.at(i).at(alpha));
    }

    for ( int alpha = 0; alpha < 26; alpha++ ) {
        for ( int i = 0; i < ans.at(alpha); i++ ) {
            cout << (char)('a' + alpha);
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int dp[5005][5005]; // グローバルで定義すると0で初期化される

int main() {
  // dp[i][j] i文字目とj文字目から連続する文字列の長さ
  // 重なった分は最後に考慮、0-indexed
  int N;
  cin >> N;
  string S;
  cin >> S;
  for (int j = N-1; j >= 0; j--) {
    for (int i = j; i >= 0; i--) {
      if (S[i] != S[j]) dp[i][j] = 0;
      else dp[i][j] = dp[i+1][j+1] + 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      int temp = min(dp[i][j], j-i);
      ans = max(ans, temp);
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 70408
import itertools
def solve():
    N = int(input())

    dict = {'M': [],
    'A': [],
    'R': [],
    'C': [],
    'H': []}

    for i in range(N):
        name = input()
        if name[0] in list(dict.keys()):
            dict[name[0]].append(name)
    
    comb = itertools.combinations(dict.keys(), 3)
    count = 0
    for c in comb:
        count += len(dict[c[0]])*len(dict[c[1]])*len(dict[c[2]])
    
    print(count)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 56584
n,m=gets.chomp.split(" ").map{|s| s.to_i}
s=gets.chomp.split("")
l,r=[],[]
for t in 0..m-1
  l[t],r[t]=gets.chomp.split(" ").map{|k| k.to_i}
end

q=[]
q[0]=0
p=0
for k in 0..n-2
  if s[k]=="A" && s[k+1]=="C"
    p+=1
    q[k+1]=p
  else
    q[k+1]=p
  end
end
for t in 0..m-1
  puts q[r[t]-1]-q[l[t]-1]
end

Measured memory_bytes: 13200
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> A(3),B(3);
    for(int i = 0; i < 3;i++){
        cin >> A[i];
    }
    for(int i = 0; i < 3;i++){
        cin >> B[i];
    }

    res = N; // Aで完結

    { // A - B - A
        vector<ll> dp(N+1,-INF); // dp[使用料] = 増分
        dp[0] = 0;
        for(int i = 0; i < N; i++){
            if(dp[i] == -INF) continue;
            for(int j = 0; j < 3;j++){
                if(i+A[j] > N) continue;
                dp[i+A[j]] = max(dp[i+A[j]],dp[i]+B[j]);
            }
        }
        ll MAXN = 0;
        for(int i = 0; i <= N;i++){
            MAXN = max(MAXN,(N-i)+dp[i]);
            res = max((ll)res,(N-i)+dp[i]);
        }

        vector<ll> dp2(MAXN+1,-INF); // dp[使用料] = 増分
        dp2[0] = 0;
        for(int i = 0; i < MAXN; i++){
            if(dp2[i] == -INF) continue;
            for(int j = 0; j < 3;j++){
                if(i+B[j] > MAXN) continue;
                dp2[i+B[j]] = max(dp2[i+B[j]],dp2[i]+A[j]);
            }
        }
        for(int i = 0; i <= MAXN;i++){
            res = max((ll)res,(MAXN-i)+dp2[i]);
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 195584
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬╬╬██╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓▓█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef pair<int,int> P;
typedef vector<vector<P>> Graph;

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

  int n;
  cin >> n;

  if(n == 22) cout << "Christmas Eve Eve Eve"  << endl;
  if(n == 23) cout << "Christmas Eve Eve"  << endl;
  if(n == 24) cout << "Christmas Eve"  << endl;
  if(n == 25) cout << "Christmas"  << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<set>
using namespace std;
const int N=100000+10;
int a[N],b[N],n,m;
int main()
{

    while(~scanf("%d%d",&n,&m)){
        printf("%d\n",2*m-n);

    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int H,W,i,j;
  
  while(1)
  {
    scanf("%d %d",&H,&W);
    
    if(H == 0 && W == 0) break;

    for(i = 0; i < H; i++)
    {
      for(j = 0; j < W; j++)
      {
        if(i % 2 == 0 && j % 2 == 0) printf("#");
        if(i % 2 == 0 && j % 2 == 1) printf(".");
        if(i % 2 == 1 && j % 2 == 0) printf(".");
        if(i % 2 == 1 && j % 2 == 1) printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[110][100100];

int main(){
    const ll MOD = pow(10,9)+7;
    int N, K; cin >> N >> K;
    int a[110];
    for(int i=0; i<N; i++){
        cin >> a[i+1];
    }


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

    for(int i=1; i<=N; i++){
        for(int j=1; j<=K; j++){
            if(j-a[i]>=1){
                dp[i][j] = MOD + dp[i-1][j] + dp[i][j-1] - dp[i-1][j-a[i]-1];
            }
            else{
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
            }
            dp[i][j] %=MOD;
        }
    }
/*
    for(int i=1; i<=N; i++){
        for(int j=0; j<=K; j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
*/
    cout << dp[N][K] << endl;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A+B >= C) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
 
bool dp[100100];
 
 
int main () {
    int A,B,C,D;
    scanf("%d%d%d%d",&A,&B,&C,&D);

    while(true){
        C -= B;
        if(C <=0){
            printf("%s\n","Yes");
            return 0;
        }
        A -= D;
        if(A <= 0){
            printf("%s\n","No");
            return 0;
        }

    }



}

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

using namespace std;

//引数nまでの素数列挙
//prime 素数格納
//is_prime 各数字が素数かどうかを格納

int prime[100000];
bool is_prime[100001];

int sieve(int n){
    int p=0;
    for(int i=0;i<=n;i++){
        is_prime[i] = true;
    }
    is_prime[0] = is_prime[1] = false;
    for(int i=0;i<=n;i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j=2*i;j<=n;j+=i){
                is_prime[j] = false;
            }
        }
    }
    return p;
}

int main(){
    int Q;
    sieve(100001);
    vector<bool> l2017(100001,false);
    int sum[100001],add=0;
    sum [0] = sum[1] = sum[2] = 0;
    cin >> Q;
    for(int i=3;i<=100000;i++){
        if(is_prime[i] && is_prime[(i+1)/2]){
            l2017[i] = true;
            add++;
        }
        sum[i] = add;
    }

    for(int i=0;i<Q;i++){
        int l,r;
        cin >> l >> r;
        if(l2017[r] && r==l){
            cout << 1 << endl;
        }else if(l2017[l]){
            cout << sum[r]-sum[l]+1 << endl;
        }else{
            cout << sum[r]-sum[l] << endl;
        }
    }
}

Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    string s,t;
    cin >> s >> t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    if(s < t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
	
	int N;
	cin >>N;
	
	if(N<=111){
		
		cout <<111 <<endl;
		
	}
	else if(N<=222){
		
		cout <<222 <<endl;
		
	}
	else if(N<=333){
		
		cout <<333 <<endl;
		
	}
	else if(N<=444){
		
		cout <<444 <<endl;
		
	}
	else if(N<=555){
		
		cout <<555 <<endl;
		
	}
	else if(N<=666){
		
		cout <<666 <<endl;
		
	}
	else if(N<=777){
		
		cout <<777 <<endl;
		
	}
	else if(N<=888){
		
		cout <<888 <<endl;
		
	}
	else if(N<=999){
		
		cout <<999 <<endl;
		
	}
	
}



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

int main() {
	int a, b;
	cin >> a >> b;

	stringstream sa;
	stringstream sb;
	for (int i = 0; i < b; i++) {
		sa << a;
	}
	for (int i = 0; i < a; i++) {
		sb << b;
	}

	if (sa.str() < sb.str()) {
		cout << sa.str() << endl;
	} else {
		cout << sb.str() << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;
using P = pair<ll, ll>;

int main() {
	const ll INF = 1e18;
	ll N, K;
	cin >> N >> K;
	vector<P> sushi(N);
	for (int i = 0; i < N; ++i) {
		int t;
		ll d;
		cin >> t >> d;
		sushi[i] = P(d, t - 1);
	}
	sort(sushi.begin(), sushi.end(), greater<P>());

	stack<ll> rmv;
	set<ll> st;
	ll sum = 0;
	for (int i = 0; i < K; ++i) {
		sum += sushi[i].first;
		if (st.count(sushi[i].second)) {
			rmv.push(sushi[i].first);
		}
		st.insert(sushi[i].second);
	}

	ll res = sum + (ll)(st.size()) * (st.size());
	for (int i = K; i < N; ++i) {
		if (rmv.empty()) { break; }
		if (st.count(sushi[i].second)) { continue; }

		sum = sum - rmv.top() + sushi[i].first;
		rmv.pop();
		st.insert(sushi[i].second);
		ll X = st.size();
		ll tmp = sum + X * X;
		res = max(res, tmp);
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    int sharp = 0;
    vector<vector<char>> A(10, vector<char>(10));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
            if (A[i][j] == '#') {
                sharp++;
            }
        }
    }

    int x = 0;
    int y = 0;
    int move = 0;
    bool flag = true;
    while (x != H - 1 || y != W - 1) {
        if (A[x + 1][y] == '#' && A[x][y + 1] != '#') {
            x++;
        }
        else if (A[x + 1][y] != '#' && A[x][y + 1] == '#') {
            y++;
        }
        else {
            flag = false;
            break;
        }
    }

    if (flag) {
        if (sharp - 1 == x + y) {
            cout << "Possible" << endl;
        }
        else {
            cout << "Impossible" << endl;
        }
    }
    else {
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
import itertools,numpy as np,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
A = LI()
sum_A = sum(A)
accumulate_A = np.array(list(itertools.accumulate(A)))
sub_A1 = sum_A-accumulate_A
sub_A2 = sum_A-sub_A1
print(np.abs(sub_A1-sub_A2).min())


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

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){


			int N = scan.nextInt();
			long C = scan.nextLong();
			long K = scan.nextLong();
			long[]T = new long[N];
			for(int i = 0;i<N;i++) {
				T[i] = scan.nextLong();
			}
			Arrays.sort(T);


			long count = 0;
			long num = 0;
			long hani = 0;
			int ok = 0;
			for(int i = 0;i<N;i++) {
				if(ok==0) {
					hani = T[i];
					ok=1;
				}

				if(hani<=T[i]&&T[i]<=hani+K) {
					num++;

					if(num==C) {
						count++;
						num=0;
						ok=0;
						//if(i==N-1)count++;
					}else {
						if(i==N-1)count++;
					}

				}else {
					count++;
					hani = T[i];
					num=1;
					ok=1;

					if(i==N-1)count++;
				}




			}


			System.out.println(count);



		}


	}


}


Measured memory_bytes: 60740
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(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(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _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(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(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); }

#define divceil(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 vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
  #define cerrendl 42
#endif
//}}}

signed main() {
  int n;cin>>n;
  vector<int> x(n);
  rep(i, n) {
    cin>>x[i];
  }
  sort(all(x));
  dump(x);

  int ans = INF;

  rep(p, 0, 101){
    int res = 0;
    rep(i, n){
      res += (x[i]-p)*(x[i]-p);
    }
    chmin(ans, res);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
  unsigned long long k,blue,red;
  cin>>k>>blue>>red;
  if(blue == 0 ) cout<<0;
  else if(red == 0 ) cout<<k;
  else{
    unsigned long long sum=0;
    sum+=k/(blue+red)*blue;
    k%=(blue+red);
    if(k<=blue) sum+=k;
    else sum+=blue;
    cout<<sum;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;



int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	c *= 2;
	if (c == min(min(a, b), c)) cout << max(x, y) * c;
	else if (c < a)cout << x * c + max(0, y - x) * b;
	else if (c < b)cout << y * c + max(0, x - y) * a;
	else if (a + b < c)cout << x * a + y * b;
	else if (x > y) cout << y * c + (x - y) * a;
	else cout << x * c + (y - x) * b;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N,M;
  cin>>N>>M;
  vector<ll> value(N);
  vector<ll> omosa(N);
  FOR(i,0,N){
    cin>>value[i]>>omosa[i];
  }
  VEC2(dp,N+1,M+1);
  FOR(i,1,N+1){
    FOR(j,1,M+1){
      if(j-omosa[i-1]>=0)dp[i][j]=max(dp[i-1][j-omosa[i-1]]+value[i-1],dp[i-1][j]);
      else dp[i][j]=dp[i-1][j];
    }
  }
  //FOR(i,0,N+1){
  //  FOR(j,0,M+1){
  //    cout<<dp[i][j]<<" ";
  //  }
  //  cout<<endl;
  //}

  cout<<dp[N][M]<<endl;
}



Measured memory_bytes: 10676
from math import factorial as fact
import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(n,r))

def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets


def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)



n=input1()
A=input_array()

result=[0 for _ in range(n)]
for i in range(n):
	result[A[i]-1]=str(i+1)
print(" ".join(result))




Measured memory_bytes: 25500
#include<stdio.h>

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



Measured memory_bytes: 2132
#coding:utf-8

n = int(input())
nums = list(map(int,input().split(' ')))

def calc():
  cnt = 0
  while True:
    for i in range(len(nums)):
      num = nums[i]
      if num % 2 == 0 and num != 0:
        nums[i] = num / 2
      else:
        return cnt
    else:
      cnt += 1

print(calc())

Measured memory_bytes: 3060
from collections import defaultdict

def get_keys_of_max_value(d):
    v_max = 0
    keys = []
    for k, v in d.items():
        if v_max < v:
            v_max = v
            keys = [k]
        elif v_max == v:
            keys.append(k)
    return keys, v_max

h, w, m = map(int, input().split())
targets = {tuple(map(int, input().split())) for _ in range(m)}
n_r = defaultdict(int)
n_c = defaultdict(int)
for x, y in targets:
    n_r[x] += 1
    n_c[y] += 1

rows, n_r_max = get_keys_of_max_value(n_r)
columns, n_c_max = get_keys_of_max_value(n_c)

for r in rows:
    for c in columns:
        if (r, c) not in targets:
            print(n_r_max + n_c_max)
            break
    else:
        continue
    break
else:
    print(n_r_max + n_c_max - 1)


Measured memory_bytes: 87644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, FN) for(int i = 0; i < ( FN ); i++)

int main() {
    ll n;
    ll m = 0, a = 0, r = 0, c = 0, h = 0;
    cin >> n;
    for(int i = 0; i < n; i++) {
        string name;
        cin >> name;
        if(name[0] == 'M') m++;
        else if(name[0] == 'A') a++;
        else if(name[0] == 'R') r++;
        else if(name[0] == 'C') c++;
        else if(name[0] == 'H') h++;
    }
    ll ans = m * (a * (r + c + h) + r * (c + h) + c * h) + a * (r * (c + h) + c * h) + r * c * h;
    cout << ans << endl;

    return 0;
}


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


int main(){
    int N;
    string s;
    cin >> N >> s;
    int count = 0;
    for(int i = 0; i <= N -3;i++){
        if(s.substr(i,3) == "ABC") count++;
    }
    cout << count << endl;
}


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

int main(){
    //inport
    int N;
    cin >> N;

    //process
    int max=0;
    int num=0;
    for(int i=0;i<N;i++){
        int in;
        cin >> in;
        if(in>=max){
            max=in;
            num++;
        }
    }

    //output
    cout << num << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 1e18
#define five 100005;
#define six 1000005;
#define prllclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
int main()
{
       ll n;
       cin>>n;
       ll xx = (n*(n-1))/2;
       cout<<xx<<endl;
}


Measured memory_bytes: 256
H,W,N = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(N)]
objs = [[] for i in range(H)]
for y,x in src:
    objs[y-1].append(x-1)

maxx = 0
for i,row in enumerate(objs[1:]):
    if row and min(row) <= maxx:
        print(i+1)
        exit()
    if maxx == W-1: continue
    if maxx+1 not in row:
        maxx += 1
print(H)

Measured memory_bytes: 61484