akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <stack>
#include <functional>
#include <ctime>
#include <queue>
#include <string>
#include <map>
#include <utility>
#include <sstream>
#include <cmath>
#define MAX_U   10
#define MIN_U   0
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define form(i,a,b) for(int i=(a);i<(b);i++)
#define sz(x) ((int)(x).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
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 long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<char> vc;
typedef vector<string> vs;
typedef queue<int> qi;
const int INF=numeric_limits<int>::infinity();
void printa(){cout<<"\n";}
template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
template<class... A>void printa(const A&... rest){printa(rest...);}
void prints(){cout<<" ";}
template<class T, class... A>void prints(const T&first,const A&... rest){cout<<first;prints(rest...);}
template<class... A>void prints(const A&... rest){prints(rest...);}
int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
int middle(int x){if(x%2==0)return x/2;else return x/2+1;}
double heron(int a,int b,int c){double s;s=(a+b+c)/2;return sqrt(s*(s-a)*(s-b)*(s-c));}
double trapezium(int a,int b,int h){return (a+b)*h/2;}
double triangle(int a,int h){return a*h/2;}
void sorm(vector<int> vec){sort(vec.begin(),vec.end());}
void sorg(vector<int> vec){sort(vec.begin(),vec.end(),greater<int>());}
int cmp( const void *p, const void *q ) {if( *(double*)p > *(double*)q ) return 1;if( *(double*)p < *(double*)q ) return -1;return 0;}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    //vi ad,bd,cd,dd;
    //vs as,bs,cs,ds;
    cin>>a>>b>>c;
    if(a*b>c)printa(c);
    else if(a*b<c)printa(a*b);
    else if(a*b==c)printa(c);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)

int main(){
	int n,alp[30],alpmin[30];
	char s[51],num;

	scanf("%d",&n);

	FOR(i,0,n){

		scanf("%s",s);
		memset(alp,0,sizeof(alp));

		//各アルファベットの個数をalpに入力
		FOR(j,0,strlen(s)){
			num = s[j] - 'a';
			alp[num]++;
		}

		//alpmin更新
		if(i == 0){
			FOR(j,0,30) alpmin[j] = alp[j];
		}else{
			FOR(j,0,30) if(alpmin[j] > alp[j]) alpmin[j] = alp[j];
		}
	}

	//a~zをそれぞれalpminの数だけ出力
	FOR(i,'a','z'+1){
		while(alpmin[i-'a']--){
			printf("%c",i);
		}
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

// 二つの値の最小値を求める関数
Int Min(const Int a, const Int b) {
    if (a <= b) {
        return a;
    } else {
        return b;
    }
}

int main(void) {
    Int l, r;
    cin >> l >> r;
    const Int MOD = 2019;

    Int result = MOD;
    if (r - l >= 2019) {
        result = 0;
    } else {
        l = (l % MOD);
        r = (r % MOD);
        if (l >= r) {
            r += MOD;
        }

        for (Int i = l; i <= r; ++i) {
            for (Int j = i + 1; j <= r; ++j) {
                result = Min(result, (i * j) % MOD);
            }
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
int main(){
  int i,l,a,f[100010];
  char s[100010];
  scanf("%s",s);
  l=strlen(s)-1;
  if(s[0]==s[l])l++;
  printf("%s\n",l%2==0?"First":"Second");
  return 0;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */

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; }

int main() {
  int N, M; cin >> N >> M;

  //隣接リスト
  vector<vector<int>> edge(N);
  //入次数を管理
  vector<int> indeg(N, 0);

  REP(i, M){
    int x,y;
    cin >> x >> y;
    x--; y--;
    edge[x].push_back(y);
    indeg[y]++;
  }

  //入次数0のノード集合
  stack<int> st;
  REP(i, N) if(indeg[i] == 0) st.push(i);

  //トポロジカルソート
  vector<int> topo;

  vector<int> dp(N);

  while(st.size()){
    int i = st.top(); st.pop();
    topo.push_back(i);

    FOREACH(j, edge[i]){
      indeg[j]--;
      chmax(dp[j], dp[i] + 1);
      if(indeg[j] == 0) st.push(j);
    }
  }

  cout << *max_element(ALL(dp)) << endl;
}


Measured memory_bytes: 7164
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, 0, n) cin >> s[i];
    sort(s.begin(), s.end());
    for (auto ss: s)
        cout << ss;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// Problem : D - Road to Millionaire
// Contest : AtCoder - M-SOLUTIONS Programming Contest 2020
// URL : https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int n;
	cin >> n;
	int arr[n];
	vector<pp> vect;
	int x = -1, y = -1;
	rep(i,0,n)
	{
		cin >> arr[i];
		if( i== 0)
		continue;
		if(x == -1)
		{
			if(arr[i] > arr[i-1])
				x = arr[i-1];
		}
		else if(y == -1)
		{
			if(arr[i] < arr[i-1])
			{
				y = arr[i-1];
				vect.pb({x,y});
				x = -1;
				y = -1;
			}
		}
	}
	if(x != -1)
		vect.pb({x,arr[n-1]});
	int st = 1000;
	rep(i,0,vect.size())
	{
		int cnt = st/vect[i].ff;
		//cout << vect[i].ff <<" "<< vect[i].ss <<"\n";
		st  = (st%vect[i].ff);
		st += cnt*(vect[i].ss);
	}
	cout << st ;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,m,f[1005][1005];
char b[1005][1005];
void add(int &x,int v)
{
	x+=v;
	if(x>=mod) x-=mod;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",b[i]+1);
	}
	f[1][1]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(b[i][j]=='.')
			{
				add(f[i][j],f[i-1][j]);
				add(f[i][j],f[i][j-1]);
			}
		}
	}
	printf("%d\n",f[n][m]);
	return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int N = 1e6 + 50;
cs int INF = 1e9 + 7;
char S[N]; int n, a[N];
int chk(int lm){
	static int sf[N];sf[n+1]=-INF;
	for(int i=n; i>=0; i--)
	sf[i]=max(sf[i+1],a[i]);
	static bool o[N]; int t=0;
	for(int i=1;i<=n;i++){
		if(S[i]=='?'&&sf[i]+t+2<=lm)t+=2,o[i]=true;
		else o[i]=false;
	} int mn=0;
	for(int i=1,sm=0;i<=n;i++){
		if(S[i]=='?')sm+=o[i]?1:-1;
		else sm+=(S[i]=='0')?-1:1;
		mn=min(mn,sm);
	} return lm-mn;
}
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%s",S+1);n=strlen(S+1);
	for(int i=1; i<=n; i++)
	a[i]=a[i-1]+((S[i]=='1')?1:-1);
	int mx=-INF;
	for(int i=0; i<=n; i++)
	mx=max(mx,a[i]);
	cout<<min(chk(mx),chk(mx+1));
	return 0;
}

Measured memory_bytes: 13504
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
//#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 3000000;
int mod = 1000003;
int f[N], invf[N], lg[N], d[N], a[N];
int cnt;
vector < int > g[N];
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
int cnk(int n, int k){
    return f[n] * invf[n - k] % mod * invf[k] % mod;
}
void dfs(int v, int p = -1){
    cnt++;
    d[v] = a[cnt];
    for (auto u: g[v]){
        if (u != p) dfs(u, v);
    }
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    int ans = 0;
    int z, x, y;
    z = x = y = 0;
    for (int i = 1; i <= n; i++){
        string s;
        cin >> s;
        int m = s.length();
        if (s[0] == 'B' && s[m - 1] == 'A') z++; else
        if (s[0] == 'B') x++; else
        if (s[m - 1] == 'A') y++;
        for (int j = 0; j < m - 1; j++){
            if (s[j] == 'A' && s[j + 1] == 'B') ans++;
        }
    }
    if (z != 0) ans +=   (z - 1);
    if (z > 1) z = 1;
    if (z == 1){
        if (x != 0 && y != 0){
            ans += 2;
            x--;
            y--;
            ans += min(x, y);
        } else
        if (x != 0 || y != 0){
            ans++;
        }
    } else{
        ans += min(x, y);
    }
    cout << ans;
}


Measured memory_bytes: 71936
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;


void solve(long long N, long long M, std::vector<long long> A){
    vec(sum,N+1);
    map<ll,ll> a;
    rep(i,N){
        sum[i+1]=sum[i]+A[i];
        a[sum[1+i]%M]++;
    }
    
    ll ans=0;
    repf(i,1,N+1){
        if(sum[i]%M==0)ans+=a[sum[i]%M];
        else ans+=a[sum[i]%M]-1;
        a[sum[i]%M]--;
    }
    op(ans);
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, q;
  ll k;
  cin >> n >> k >> q;
  VI a(n, 0);
  rep(i, q) {
    int b;
    cin >> b;
    a[--b]++;
  }
  rep(i, n) {
    puts(k > q - a[i] ? "Yes" : "No");
  }

  return 0;
}


Measured memory_bytes: 1024
import math
import heapq
import sys
from collections import Counter

#N,K=map(int, input[0].split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input[1].split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

N=int(input())
a=list(map(int,input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

cnt=0
for i in range(len(a)-1):
    if a[i]==a[i+1]:
        a[i+1]=-1
        cnt+=1
        #print(a)


print(cnt)


Measured memory_bytes: 3316
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    s1[0] -= 32;
    s2[0] -= 32;
    s3[0] -= 32;
    cout << s1[0] << s2[0] << s3[0] << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
    int q, com, x;
    string key;
    map<string, int> M;
    cin >> q;
    
    rep(i, q)
    {
        cin >> com >> key;
        
        if (com == 0)
        {
            cin >> x;
            M[key] = x;
        }
        else
        {
            cout << M[key] << endl;
        }
    }
}



Measured memory_bytes: 27852
from collections import Counter
s=list(input())
k=int(input())
n=len(s)
s_c=sorted(Counter(s).items())

ans=[]
for i in s_c:
    for j in range(n):
        if s[j]==i[0]:
            ans.append(s[j])
            if j+1<=n-1:
                ans.append("".join([s[j],s[j+1]]))
                if j+2<=n-1 :
                    ans.append("".join([s[j],s[j+1],s[j+2]]))
                    if j+3<=n-1:
                        ans.append("".join([s[j],s[j+1],s[j+2],s[j+3]]))
                        if j+4<=n-1:
                            ans.append("".join([s[j],s[j+1],s[j+2],s[j+3],s[j+4]]))

b=list(set(ans))
b.sort()
print(b[k-1])

Measured memory_bytes: 75300
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define N 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))
#define cio ios::sync_with_stdio(false);

int main()
{
    int k;
    scanf("%d", &k);
    int a,  b;
    cin >> a >> b;
    int flag = 0;
    for(int i = a; i <= b; i++){
        if(i%k==0){
            flag = 1;
            break;
        }
    }
    if(flag){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

template<class V, int ME> class BIT {
public:
	V bit[1<<ME],val[1<<ME];
	V total(int e) {V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
	V add(int e,V v) { val[e++]+=v; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
	V set(int e,V v) { add(e,v-val[e]);}
	int lower_bound(V val) {
		V tv=0; int i,ent=0;
		for(i=ME-1;i>=0;i--) if(tv+bit[ent+(1<<i)-1]<val) tv+=bit[ent+(1<<i)-1],ent+=(1<<i);
		return ent;
	}
};

int N,Q;
ll A,B;
BIT<ll,20> bit;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Q;
	bit.add(N,2LL*10000000000000LL);
	FOR(i,Q) {
		cin>>A>>B;
		x=N-A;
		while(B) {
			ll xv=bit.total(x);
			y = bit.lower_bound(xv+1);
			ll yv=bit.total(y);
			
			
			if(B>=(yv-xv)*(y-x)) {
				B -= (yv-xv)*(y-x);
				bit.add(x,yv-xv);
				bit.add(y,-(yv-xv));
			}
			else {
				bit.add(x,B/(y-x));
				bit.add(y,-B/(y-x));
				B %= (y-x);
				bit.add(y-B,1);
				bit.add(y,-1);
				break;
			}
		}
	}
	
	FOR(i,N) cout<<bit.total(N-1-i)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 3200
import sys
if sys.version_info[0]>=3: raw_input=input
cross=lambda a1, b1, a2, b2: a1*b2-a2*b1
try:
	T=0
	while True:
		T+=1
		n=int(raw_input())
		if n==0: break
		a=[[float(e) for e in raw_input().split()] for i in range(n)]
		s=0
		t=0
		for i in range(n-1):
			x=cross(a[i][0],a[i][1],a[i+1][0],a[i+1][1])
			if x>0: s+=abs(x)/2
			else: t+=abs(x)/2
		x=cross(a[n-1][0],a[n-1][1],a[0][0],a[0][1])
		if x>0: s+=abs(x)/2
		else: t+=abs(x)/2
		print('%d %.1f'%(T,abs(s-t)))
		raw_input()
except EOFError:
	pass

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

const long long MOD = 1e9 + 7;

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

    vector<long long> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    long long ans = 0, mul = a[0];
    for (int i = 1; i < n; i++){
        ans += (mul * a[i]) % MOD;
        ans %= MOD;
        mul += a[i];
        mul %= MOD;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4796
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  string ans = "";
  for(int i=0;i<(int)s.size();i+=2){
    ans += s[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,M,TT;
  cin >> N >> M;
  vector<long long> T(M,0);
  for (int i=0;i<N;i++) {
    long long K;
	cin >> K;
	for (int j=0;j<K;j++) {long long A;cin >> A;T[A-1]++;}
  }
  TT=0;
  for (int i=0;i<M;i++) {if (T[i]==N) {TT++;}}
  cout << TT << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    stack<int> stk;
    string s;
    while(cin >> s){
        int a,b;
        if(s=="+"){
            a=stk.top();
            stk.pop();
            b=stk.top();
            stk.pop();
            stk.push(a+b);
        }else if(s=="-"){
            a=stk.top();
            stk.pop();
            b=stk.top();
            stk.pop();
            stk.push(b-a);
        }else if(s=="*"){
            a=stk.top();
            stk.pop();
            b=stk.top();
            stk.pop();
            stk.push(a*b);
        }else{
            stk.push(stoi(s));
        }
    }

    cout << stk.top() << endl;
    
    return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,ans=0;
    cin>>n;
    vector<pair<int,int> > a;
    vector<pair<int,int> > c;
    int b,d;
    for(int i=0;i<n;i++){
        cin>>b>>d;
        a.pb(make_pair(d,b));
    }
    for(int i=0;i<n;i++){
        cin>>b>>d;
        c.pb(make_pair(b,d));
    }
    sort(be(a));
    for(int i=0;i<a.size();i++){
        swap(a[i].first,a[i].second);
    }
    sort(be(c));
    for(int i=0;i<n;i++){
        for(int j=n-1;j>=0;j--){
            if(a[j].first<c[i].first && a[j].second<c[i].second){
                ans++;
                a.erase(a.begin()+j);
                c.erase(c.begin()+i);
                n--;
                i--;
                break;
            }
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<vector<int>> G;
void input(){
    fast_io();
    cin >> N;
    G.resize(N+1);
    for (int i = 2; i <= N; i++)
    {
        int a; cin >> a;
        G[i].push_back(a);
        G[a].push_back(i);
    }
}

// int depth[110000];
vector<int> depth;
int dfs(int s, int p=-1){
    if(depth[s]!=-1) return depth[s];
    
    vector<int> dp;
    for(auto u:G[s]){
        if(u==p) continue;
        dp.push_back(dfs(u,s));
    }
    sort(dp.begin(),dp.end(),greater<int>());
    vector<int> ans;
    for (int i = 0; i < dp.size(); i++)
    {
        ans.push_back(i+1+dp[i]);
    }
    int ret = 0;
    if(!ans.empty()) ret = *max_element(ans.begin(),ans.end());
    return depth[s] = ret;
}

int solve(){
    // memset(depth,-1,sizeof(depth));
    depth.assign(N+1,-1);
    cout << dfs(1) << endl;
    DBG(depth)
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

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

using namespace std;
using ll = long long;

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

int main() {
  int x, n;
  cin >> x >> n;
  set<int> p;
  rep(i, n) {
    int x;
    cin >> x;
    p.insert(x);
  }

  int ans = -1;
  for (int i = -200; i <= 200; ++i) {
    if (p.find(i) != p.end()) continue;
    if (abs(x - i) < abs(x - ans)) ans = i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
import java.io.*;
import java.util.*;

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long D = sc.nextLong();
		long A = sc.nextLong();
		long[][] XH = new long[N][2];
		for (int i = 0; i < N; i++) {
			XH[i][0] = sc.nextLong();
			XH[i][1] = sc.nextLong();
		}

		Arrays.sort(XH, (a, b) -> Long.compare(a[0], b[0]));

		long[] B = new long[N];
		long currentBomb = 0;
		long answer = 0;
		for (int i = 0; i < N; i++) {
			if (i > 0) currentBomb -= B[i - 1];

			if (XH[i][1] <= 0) continue;

			long nBomb = (XH[i][1] / A) + ((XH[i][1] % A > 0) ? 1 : 0);
			if (currentBomb >= nBomb) continue;
			answer += (nBomb - currentBomb);

			int l = i;
			int r = N;
			while (r - l > 1) {
				int m = (l + r) / 2;
				if (XH[m][0] <= 2 * D + XH[i][0]) {
					l = m;
				} else {
					r = m;
				}
			}
			B[l] += (nBomb - currentBomb);
			currentBomb = nBomb;
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 119932
def main():
    buf = input()
    buflist = buf.split()
    X = int(buflist[0])
    Y = int(buflist[1])
    Z = int(buflist[2])
    K = int(buflist[3])
    buf = input()
    buflist = buf.split()
    A = list(map(int, buflist))
    buf = input()
    buflist = buf.split()
    B = list(map(int, buflist))
    buf = input()
    buflist = buf.split()
    C = list(map(int, buflist))
    A = list(sorted(A, reverse=True))
    B = list(sorted(B, reverse=True))
    C = list(sorted(C, reverse=True))
    cakelist = [(A[0]+B[0]+C[0], 0, 0, 0)]
    hashtable = {(A[0]+B[0]+C[0], 0, 0, 0)}
    tastiness = []
    while len(tastiness) < K:
        current = cakelist.pop()
        tastiness.append(current[0])
        if current[1] < len(A)-1:
            if (A[current[1]+1]+B[current[2]]+C[current[3]], current[1]+1, current[2], current[3]) not in hashtable:
                cakelist.append((A[current[1]+1]+B[current[2]]+C[current[3]], current[1]+1, current[2], current[3]))
                hashtable.add((A[current[1]+1]+B[current[2]]+C[current[3]], current[1]+1, current[2], current[3]))
        if current[2] < len(B)-1:
            if (A[current[1]]+B[current[2]+1]+C[current[3]], current[1], current[2]+1, current[3]) not in hashtable:
                cakelist.append((A[current[1]]+B[current[2]+1]+C[current[3]], current[1], current[2]+1, current[3]))
                hashtable.add((A[current[1]]+B[current[2]+1]+C[current[3]], current[1], current[2]+1, current[3]))
        if current[3] < len(C)-1:
            if (A[current[1]]+B[current[2]]+C[current[3]+1], current[1], current[2], current[3]+1) not in hashtable:
                cakelist.append((A[current[1]]+B[current[2]]+C[current[3]+1], current[1], current[2], current[3]+1))
                hashtable.add((A[current[1]]+B[current[2]]+C[current[3]+1], current[1], current[2], current[3]+1))
        cakelist = list(sorted(cakelist))
    for i in tastiness:
        print(i)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5648
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdlib>
using namespace std;

int main()
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    char c1, c2, c3;
    c1 = (char)toupper(s1[0]);
    c2 = (char)toupper(s2[0]);
    c3 = (char)toupper(s3[0]);
    cout << c1 << c2 << c3 << endl;
    return 0;

}

Measured memory_bytes: 256
import fractions

A,B=map(int,input().split())
gcd_AB=fractions.gcd(A,B)

set_fact={1}
for i in range(2,gcd_AB+1):
  if i**2>gcd_AB:
    break
  
  while(True):
    if gcd_AB%i==0:
      gcd_AB//=i
      set_fact.add(i)
    else:
      break
      
if gcd_AB!=1:
  set_fact.add(gcd_AB)

print(len(set_fact))
 


Measured memory_bytes: 5048
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;
int MOD = 1000000007;

signed main(){
    int n;
    cin >> n;
    int ans = 0;
    int h[101];
    rep(i,n) cin >> h[i];

    int s = 0;
    for(int j = 0;j < 100;j++){
        s = 0;
  
        for(int i = 0;i < n;i++){
            if(h[i] != 0){
                if(s == 0){
                    ans++;
                    s = 1;
                }
                h[i]--;
            }else{
                s = 0;
            }
        }
    }

    cout << ans << endl;

    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://ddcc2019-final.contest.atcoder.jp/tasks/ddcc2019_final_a
// rm -r -f test;oj dl http://arc060.contest.atcoder.jp/tasks/arc060_a

Measured memory_bytes: 256
S=input()

if (int(S[:2])>12 or int(S[:2])==0) and 0<int(S[2:])<=12:
    print("YYMM")
elif 0<int(S[:2])<=12 and (int(S[2:])>12 or int(S[2:])==0):
    print("MMYY")
elif 0<int(S[:2])<=12 and 0<int(S[2:])<=12:
    print("AMBIGUOUS")
else:
    print("NA")

Measured memory_bytes: 3064
#include <algorithm>
#include <stdio.h>

using ll = long long;
using namespace std;
int main() {
	ll n, a[50];
	scanf("%lld", &n);
	for (int i = 0; i < n; i++)
		scanf("%lld", a + i);

	ll K = 0;
	while (true) {
		ll Total = 0, time[50];
		for (int i = 0; i < n; i++) {
			time[i] = (max(0ll, a[i] - (n - 1)) + (n - 1)) / n;
			Total += time[i];
		}

		if (!Total)
			break;

		K += Total;
		for (int i = 0; i < n; i++) {
			a[i] -= time[i] * n;
			a[i] += Total - time[i];
		}
	}
	printf("%lld\n", K);
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**5+5)
from collections import defaultdict,deque
input = sys.stdin.readline

def bfs():
    q = deque([1])
    while q:
        now = q.popleft()
        for nex,c,w in e[now]:
            if depth[nex]>= 0:
                continue
            depth[nex] = depth[now]+1
            dis[nex] = dis[now]+w
            lca[0][nex] = now
            q.append(nex)

def dfs1(now,p,count1,count2):
    for cou in dcount[now]:
        dcount[now][cou] = count1[cou]
    for wei in dweight[now]:
        dweight[now][wei] = count2[wei]

    for nex,c,w in e[now]:
        if nex == p:
            continue
        count1[c] += 1
        count2[c] += w
        dfs1(nex,now,count1,count2)
        count1[c] -= 1
        count2[c] -= w
n,q = map(int,input().split())
e = [[] for i in range(n+1)]

for i in range(n-1):
    a,b,c,d = map(int,input().split())
    e[a].append((b,c,d))
    e[b].append((a,c,d))
size = n+1
bitlen = 19
lca = [[0]*size for i in range(bitlen)]
depth = [-1]*size
dis = [-1]*size
depth[1] = 0
dis[1] = 0

bfs()
for i in range(1,bitlen):
    for j in range(1,size):
        if lca[i-1][j] > 0:
            lca[i][j] = lca[i-1][lca[i-1][j]]
    
def search(x,y):
    if depth[x] > depth[y]:
        x,y = y,x
    for i in range(bitlen):
        if ((depth[y]-depth[x])>>i) & 1:
            y = lca[i][y]
    if x == y:
        return x
    for i in range(bitlen-1,-1,-1):
        if lca[i][x] != lca[i][y]:
            x = lca[i][x]
            y = lca[i][y]
    return lca[0][x]


Q = []
dcount = defaultdict(lambda : defaultdict(int))
dweight = defaultdict(lambda : defaultdict(int))
for i in range(q):
    x,y,u,v = map(int,input().split())
    a = search(u,v)
    dcount[u][x] = 0
    dcount[v][x] = 0
    dcount[a][x] = 0
    dweight[u][x] = 0
    dweight[v][x] = 0
    dweight[a][x] = 0
    Q.append((x,y,u,v,a))

    
dfs1(1,0,defaultdict(int),defaultdict(int))

for x,y,u,v,a in Q:
    cal = dis[u]+dis[v]-2*dis[a]
    cal += y*(dcount[u][x]+dcount[v][x]-2*dcount[a][x]) - dweight[u][x]-dweight[v][x]+2*dweight[a][x]
    print(cal)

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

typedef pair<int, int> P;

int main(){
	// #ifndef ONLINE_JUDGE
    	// freopen("input.txt", "r", stdin);
    	// freopen("output.txt", "w", stdout);
	// #endif
	int n, x, l;
	cin>> n;
	P rng[n];
	for(int i = 0;i < n; ++i){
		cin>> x>> l;
		rng[i] = P(x+l, x-l);
	}
	sort(rng, rng+n);
	int cur = -2e9;
	int ans = 0;
	for(int i = 0; i < n; ++i){
		if(cur <= rng[i].second){
			ans++;
			cur = rng[i].first;
		}
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1532
def d_fennec_vs_snuke(N, E):  # N:マスの個数, E:道の情報
    # 隣接リストの作成
    edge = [[] for _ in range(N)]
    for a, b in E:
        a -= 1
        b -= 1
        edge[a].append(b)
        edge[b].append(a)

    # 幅優先探索
    def bfs(N, adjacent, V):
        # 木のある頂点Vからの距離を求める
        dist = [0 for i in range(N)]  # 頂点Vからの距離
        isVisit = [False for i in range(N)]  # ある頂点が探索済か
        queue = [V - 1]  # 幅探索用キュー(配列が0-indexedのため-1する)
        isVisit[V - 1] = True

        while queue:
            u = queue.pop()
            for p in adjacent[u]:
                if not isVisit[p]:
                    isVisit[p] = True
                    dist[p] = dist[u] + 1
                    queue.append(p)
        return dist

    fennec_dist = bfs(N, edge, 1)  # フェネック(頂点1スタート)から各頂点の距離
    snuke_dist = bfs(N, edge, N)  # すぬけ(頂点Nスタート)
    fennec_point, snuke_point = 0, 0  # 自分が色を塗れたマスの数

    for idx in range(N):
        if fennec_dist[idx] <= snuke_dist[idx]:
            fennec_point += 1
        else:
            snuke_point += 1
    if fennec_point > snuke_point:
        return 'Fennec'
    else:
        return 'Snuke'
    return None
N = int(input())
E = [[int(i) for i in input().split()] for j in range(N-1)]
print(d_fennec_vs_snuke(N, E))

Measured memory_bytes: 47988
#include<stdio.h>

int main() {
    char S[101], T[101];
    int N;

    scanf("%d", &N);
    scanf("%s %s", S, T);

    for (int i = 0; i < N; i++) {
        printf("%c%c", S[i], T[i]);
    }

    return 0;
}

Measured memory_bytes: 128
// C
 #ifndef _GLIBCXX_NO_ASSERT
 #include <cassert>
 #endif
 #include <cctype>
 #include <cerrno>
 #include <cfloat>
 #include <ciso646>
 #include <climits>
 #include <clocale>
 #include <cmath>
 #include <csetjmp>
 #include <csignal>
 #include <cstdarg>
 #include <cstddef>
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
 #include <ctime> 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
 #include <ccomplex>
 #include <cfenv>
 #include <cinttypes>
 #include <cstdbool>
 #include <cstdint>
 #include <ctgmath>
 #include <cwchar>
 #include <cwctype>
 #endif
 
 // C++
 #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> 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
 #include <array>
 #include <atomic>
 #include <chrono>
 #include <condition_variable>
 #include <forward_list>
 #include <future>
 #include <initializer_list>
 #include <mutex>
 #include <random>
 #include <ratio>
 #include <regex>
 #include <system_error>
 #include <thread>
 #include <tuple>
 #include <typeindex>
 #include <type_traits>
 #include <unordered_map>
 #include <unordered_set>
 #endif
using namespace std;
int dp[310][310];

int main(){
    while(1){
        int n; cin >> n;
        if(!n) break;
        vector<int> w(n);
        for(int i=0;i<n;++i) cin >> w[i];
        for(int i=0;i<n;++i){
            for(int j=0;j<n;++j){
                dp[i][j] = 0;
            }
        }
        //for(int i=0;i<n;++i) dp[i][i] = 0;

        for(long long W=2;W<=n;++W){
            for(int i=0;i<n;++i){
                int j = i+W-1;
                if(j>=n) continue;
                if(dp[i+1][j-1]==W-2 && abs(w[j] - w[i])<=1){
                    dp[i][j] = W;
                }
                for(int k=i;k<j;++k){
                    dp[i][j] = max(dp[i][k] + dp[k+1][j],dp[i][j]);
                }
            }
        }
        cout << dp[0][n-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3444
N = int(input())

AB = []
for i in range(N):
    tmp = list(map(int, input().split()))
    AB.append(tmp)

CD = []    
for i in range(N):
    tmp = list(map(int, input().split()))
    CD.append(tmp)
    
AB = sorted(AB, key=lambda x: x[1], reverse=True)
CD = sorted(CD)

ans = 0
for cd in CD:
    for ab in AB:
        if cd[0] > ab[0] and cd[1] > ab[1]:
            ans += 1
            AB.remove(ab)
            break
        
print(ans)

Measured memory_bytes: 3064
n,x,y=map(int,input().split())
ct=[0 for i in range(n)]
for i in range(n):
  for j in range(i+1,n):
    ct[min(j-i,abs(j-y+1)+abs(i-x+1)+1)]+=1
for i in range(1,n):
  print(ct[i])

Measured memory_bytes: 46300
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

const int Maxn = 200005;

int n, m;
bool fir[Maxn], sec[Maxn];

int main()
{
	scanf("%d %d", &n, &m);
	while (m--) {
		int a, b; scanf("%d %d", &a, &b);
		if (a == 1) fir[b] = true;
		if (b == n) sec[a] = true;
	}
	for (int i = 1; i <= n; i++)
		if (fir[i] && sec[i]) { printf("POSSIBLE\n"); return 0; }
	printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <complex>
#include <cmath>
#include <algorithm>
using namespace std;


struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }//最初は全て-1 :-1なら根なので全て根:木のサイズが増えると-2-3-4となる
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);//両方のルートを出して、それをつなげる
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }

  bool findSet(int x, int y) {//要素xとyが同じ集合か　→　rootを調べれば解決
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);//-1なら根、そうでないなら配列が指す場所へ移動
  }
  int size(int x) {
    return -data[root(x)];
  }
};


int main()
{
    long x,y;
    // string s;
    cin  >> x >> y;
    // {1,3,5,7,8,10,12}
    // {4,6,9,11}
    // {2}
    struct UnionFind uftree1(12);//全部で12こ//最初は全部が根
    uftree1.unionSet(1,3);
    uftree1.unionSet(1,5);
    uftree1.unionSet(1,7);
    uftree1.unionSet(1,8);
    uftree1.unionSet(1,10);
    uftree1.unionSet(1,12);
    uftree1.unionSet(4,6);
    uftree1.unionSet(4,9);
    uftree1.unionSet(4,11);

    //cout << "size"<<endl;

    //cout << uftree1.size(7) <<endl;
    //cout << uftree1.root(7) <<endl;



    bool isSameGroup=uftree1.findSet(x,y);

    cout << (isSameGroup?"Yes":"No");
    
    return 0;
}

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

void main() {
    int n;
    scan(n);

    auto tree = new int[][](n);

    foreach (i ; 1 .. n) {
        int ai;
        scan(ai);
        tree[ai-1] ~= i;
    }

    int dfs(int v) {
        if (tree[v].empty) {
            return 0;
        }

        auto d = new int[](tree[v].length);

        foreach (i, ch ; tree[v]) {
            d[i] = dfs(ch);
        }

        d.sort!"a > b"();

        int res;

        foreach (int i, di; d) {
            res = max(res, di + i + 1);
        }

        return res;
    }

    writeln(dfs(0));
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 27388
import sys

input = sys.stdin.readline


def main():
    x, y = map(int, input().split())

    X = abs(x)
    Y = abs(y)
    d = abs(X - Y)
    if x >= 0 and y >= 0 and X > Y:
        ans = min(1 + d + 1, 1 + (x + y))
    elif x >= 0 and y >= 0:
        ans = d
    elif x >= 0 and y <= 0 and X > Y:
        ans = 1 + d
    elif x >= 0 and y <= 0:
        ans = d + 1
    elif x <= 0 and y >= 0 and X > Y:
        ans = min(d + 1, y - x)
    elif x <= 0 and y >= 0:
        ans = min(1 + d, y - x)
    elif x <= 0 and y <= 0 and X > Y:
        ans = d
    elif x <= 0 and y <= 0:
        ans = 1 + d + 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
s = input()
t = input()
ans = "No"

for s_index  in range(len(s)):
    for t_index in range(len(t)):
        flag = True
        index = (s_index + t_index) % len(s)
        if s[index] != t[t_index]:
            flag = False
            break
    if flag:
        ans = "Yes"
        break

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define INF LLONG_MAX 
#define dd double 
#define fi first
#define se second
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define dll deque<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define vvll vector<vector<ll>>
#define vpll vector<pair<long long,long long>>
#define vpcl vector<pair<char,long long>>
#define vpsl vector<pair<string,long long>>
#define stll stack<long long>
#define stc stack<char>
#define mll map<long long,long long>
#define pll pair<long long,long long>
#define psl pair<string,long long>
#define mcl map<char,long long>
#define msl map<string,long long>
#define pcl pair<char,long long>
#define mmll multimap<long long,long long> 
#define mmcl multimap<char,long long>
#define mmsl multimap<string,long long>
#define sll set<long long>
#define sc  set<char>
#define ss  set<string>
#define msll multiset<long long>
#define msc  multiset<char>
#define mss  multiset<string>
#define lb lower_bound
#define up upper_bound
#define lt length
#define clr clear
#define ap append
#define sz size
#define sub substr
#define ull unsigned long long int
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int; 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

ll modexp(ll x,ll n,ll p){    //modular exponential function
  if(n==0){return 1;}
  ll u = modexp(x,n/2,p);
  u = u*u%p;
  if(n%2==1){u=(u*x)%p;}
  return u;
}

ll gcd (ll a, ll b) {     //Eulers algorithm
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n,k; cin>>n>>k;
    ll arr[n]; rep(i,0,n-1){cin>>arr[i];}
    bool dp[k+1];
    rep(i,0,k){dp[i]=false;}
    rep(i,1,k){
        bool ans = true;
        rep(j,0,n-1){
            if(arr[j]<=i){
            ans = ans && dp[i-arr[j]];}
        }
        dp[i] = !ans;
    }
    // rep(i,0,k){cout<<i<<" ";}cout<<"\n";
    // rep(i,0,k){cout<<dp[i]<<" ";}cout<<"\n";
    if(dp[k]==1){cout<<"First";}
    else{cout<<"Second";}
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
vector<ll> divisor(ll x){vector<ll> div;
	for(int i=1;i*i<=x;i++){if(i*i!=x && x%i==0){div.pb(i);div.pb(x/i);}else if(x%i==0) div.pb(i);}
	sort(div.bg,div.ed);return div;}
vector<ll> vectorprime(ll x){vector<bool> is_prime(x+1);vector<ll> prime;
	rep(i,x+1) is_prime[i]=true;is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=x;i++){if(is_prime[i]){prime.pb(i);}for(int j=i*2;j<=x;j+=i) is_prime[j]=false;}
	return prime;}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}

//a,b x
int main(){
	//rep1(i,50) pw2[i]=2*pw2[i-1];
	//rep1(i,18) pw10[i]=10*pw10[i-1];
    ll N,M; cin>>N>>M;
	if(N==1 && M==1){
		cout<<1;
	}
	else if(N==1 || M==1){
		ll tmp=max(N,M);
		cout<<tmp-2;
	}
	else{
		cout<<(N-2)*(M-2);
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define MAXN 1000002
using namespace std;
int n,m;
int tx,ty,tz;
int dp[1<<13];
int main()
{
    scanf("%d%d",&n,&m);
    memset(dp,63,sizeof(dp));
    dp[0]=0;
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&tx,&ty);
        int tmp=0;
        for(int j=1;j<=ty;j++)
        {
            scanf("%d",&tz);
            tmp|=(1<<(tz-1));
        }
        for(int i=0;i<(1<<n);i++)
        {
            dp[i|tmp]=min(dp[i|tmp],dp[i]+tx);
        }
    }
    if(dp[(1<<n)-1]==dp[1<<n])dp[(1<<n)-1]=-1;
    cout<<dp[(1<<n)-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<long>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  int j=n-k;
  for(int i=0;i<j;i++){
    if(a[i]<a[i+k])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 4836
fun main(args : Array<String>) {
    val (m, d) = readLine()!!.split(" ").map { it.toInt() }

    var cnt = 0

    for (i in 4..m) {
        for (j in 22..d) {
            val d1 = j % 10
            val d2 = j / 10
            if (d1 >= 2 && d2 >= 2 && i == d1 * d2) cnt++
        }
    }

    println(cnt)
}

Measured memory_bytes: 37884
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;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 dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc103/tasks/abc103_d

int main() {
    int N, M; cin >> N >> M;
    vector<P> ab(M);
    int a, b;
    REP(i, M) {
        cin >> a >> b;
        ab[i] = {b,a};
    }

    sort(ab.begin(), ab.end());

    int now = 0;
    int ans = 0;
    for (P p : ab) {
        if (p.second >= now) {
            now = p.first;
            ans++;
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 1024