akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 2020;
int a[N][N];
int m, n;
int ans = 0;

int getSum(int x1, int y1, int x2, int y2) {
	return a[x2][y2] + a[x1][y1] - a[x2][y1] - a[x1][y2];
}

int solve(int x, int y) {
	if (x <= n)
		return getSum(x, y, x + n, n) + getSum(0, 0, x, y) + getSum(x + n, 0, 2 * n, y);
	else
		return getSum(0, y, x - n, n) + getSum(x - n, 0, x, y) + getSum(x, y, 2 * n, n);
}

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

	scanf("%d%d", &m, &n);
	while(m--) {
		int x, y;
		char c;
		scanf("%d%d %c", &x, &y, &c);
		if (c == 'W')
			x += n;
		x %= 2 * n;
		y %= 2 * n;
		if (y >= n) {
			x += n;
			y -= n;
		}
		x %= 2 * n;
		a[x + 1][y + 1]++;
	}

	for (int x = 1; x < N; x++)
		for (int y = 1; y < N; y++)
			a[x][y] += a[x - 1][y] + a[x][y - 1] - a[x - 1][y - 1];

	for (int x = 0; x < 2 * n; x++)
		for (int y = 0; y < n; y++) {
			ans = max(ans, solve(x, y));
		}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 16128
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,m,q[501],dp[1<<23],num[501],t[1<<23];
bool ch[30];
string s[501];
int B(){
  r(i,n){
      int x=0;
      for(int j=m-1,k=0;j>=0;j--,k++)if(s[i][j]=='1')x+=(1<<k);
      num[i]=x;
    }
  memset(dp,-1,sizeof(dp));
  dp[0]=0;
  memset(t,-1,sizeof(t));
  r(i,n){
    r(j,(1<<m))if(dp[j]>=0)t[j^num[i]]=max(t[j^num[i]],dp[j]+1);
    r(j,(1<<m))dp[j]=max(dp[j],t[j]);
  }
  return dp[0];
}
int A(int d,int x){
  int res=0;
  if(d==n){
    r(i,m){
      int c=0;
      r(j,n)if(ch[j]&&s[j][i]=='1')c++;
      if(c%2)return 0;
    }
    return x;
  }
  res=max(res,A(d+1,x));
  ch[d]=1;
  res=max(res,A(d+1,x+1));
  ch[d]=0;
  return res;
}
main(){
  while(cin>>n>>m,n){
    r(i,n)cin>>s[i];
    if(n<m)cout<<A(0,0)<<endl;
    else cout<<B()<<endl;
  }
}

Measured memory_bytes: 68716
#include <climits>
#include <map>
#include <iostream>
#include <queue>

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

using namespace std;

int main(){
  int n;
  while(cin >> n, n){
    map<string,int> named;
    vector<string> name(n);
    map<int, vector<int> > tt;
    vector<int> point(n);

    REP(i,n){
      string nm; int m;
      cin >> nm >> m;

      named[nm] = i;
      name[i] = nm;

      REP(j,m){
	int t; cin >> t;
	tt[t].push_back(i);
      }
    }

    FOR(it, tt){
      vector<int> &pp = it->second;
      FOR(it2, pp){
	point[*it2] += n - pp.size() + 1;
      }
    }

    pair<int, string> ans = make_pair(INT_MAX, "");

    REP(i,n){
      ans = min(ans, make_pair(point[i], name[i]));
    }

    cout << ans.first << " " << ans.second << endl;
  }

  return 0;
}

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

const int MAX_SOMMETS = pow(10, 5), MOD = pow(10, 9) + 7, INDEFINI = -1;

int dpBlack[MAX_SOMMETS], dpWhite[MAX_SOMMETS];
bool fait[MAX_SOMMETS];

vector<int> entree[MAX_SOMMETS];
vector<int> graphe[MAX_SOMMETS];

void defineOrder(int id_sommet)
{
    fait[id_sommet] = true;
    
    for (int voisin : entree[id_sommet])
    {
        if (!fait[voisin])
        {
            graphe[id_sommet].push_back(voisin);
            defineOrder(voisin);
        }
    }
}

int nbPos(bool black, int id_sommet)
{
    if (black  && dpBlack[id_sommet] != INDEFINI) return dpBlack[id_sommet];
    if (!black && dpWhite[id_sommet] != INDEFINI) return dpWhite[id_sommet];
    
    
 //   cout << 42 << endl;
    if (black) dpBlack[id_sommet] = 1;
    else dpWhite[id_sommet] = 1;
    
    for (int voisin : graphe[id_sommet])
    {
            if (black)
            {
                dpBlack[id_sommet] *= nbPos(false, voisin);
                dpBlack[id_sommet] %= MOD;
            }
            else
            {
                dpWhite[id_sommet] *= (nbPos(true, voisin) + nbPos(false, voisin));
                dpWhite[id_sommet] %= MOD;
                dpWhite[id_sommet] %= MOD;
            }
    }
    
    if (black) return dpBlack[id_sommet];
    else return dpWhite[id_sommet];
}

signed main()
{
   int nb_sommets;
   cin >> nb_sommets;
   
   for (int id_arete = 0; id_arete < nb_sommets - 1; ++ id_arete)
   {
       int sommet1, sommet2;
       cin >> sommet1 >> sommet2;
       --sommet1;
       --sommet2;
       
       entree[sommet1].push_back(sommet2);
       entree[sommet2].push_back(sommet1);
   }
   
   defineOrder(0);
   for (int id_sommet = 0; id_sommet < nb_sommets; ++ id_sommet)
   {
       dpWhite[id_sommet] = INDEFINI;
       dpBlack[id_sommet] = INDEFINI;
       fait[id_sommet] = false;
   }
   
   cout << (nbPos(true, 0) + nbPos(false, 0))%MOD << endl;
   
   return 0;
}

Measured memory_bytes: 19840
#include<bits/stdc++.h>
using namespace std;
const int N=3005,mod=998244353;
typedef long long ll;
int dp[N][N][2];
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(c>a) dp[c][d][0]=1;
    if(d>b) dp[c][d][1]=1;
    ll ans=0;
    for(int i=c;i>=a;i--)
        for(int j=d;j>=b;j--)
    {
        dp[i][j-1][0]=(dp[i][j-1][0]+(ll)dp[i][j][1]*i)%mod;
        dp[i][j-1][1]=(dp[i][j-1][1]+(ll)dp[i][j][1]*i)%mod;
        dp[i-1][j][0]=(dp[i-1][j][0]+(ll)dp[i][j][0]*j)%mod;
        dp[i-1][j][1]=(dp[i-1][j][1]+(ll)dp[i][j][0])%mod;
        if(i==a&&j-1==b)
            ans=(ans+(ll)dp[i][j][1]*i)%mod;
        if(i-1==a&&j==b)
            ans=(ans+(ll)dp[i][j][0]*j)%mod;
    }
    if(a==c&&b==d) ans=1;
    printf("%lld\n",ans);
}


Measured memory_bytes: 74204
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n=0;
    scanf("%d",&n);
    char s[n]={0};
    scanf("%s",s);
    int c=1;
    for(int i=0;i<n-1;i++){
        if(s[i]!=s[i+1]){
            c++;
        }
    }
    printf("%d",c);
    return 0;
}

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

const int MAX_N = 200100;
int N; ll K;
ll A[MAX_N];
const ll INF = (ll)1e18 + 1LL;

bool cmp(ll a, ll b, ll X) {
    return a*b < X;
}

int b_search(ll key, ll X, bool right_true, bool (*isOK)(ll, ll, ll)) {
    int ng = right_true ? N : -1;
    int ok = right_true ? -1 : N;

    while(abs(ok - ng) > 1) {
        int mid = (ok + ng)/2;
        if(isOK(key, A[mid], X)) ok = mid;
        else ng = mid;
    }
    return ok;
}

ll order_ascending(ll X) { // 積がX未満になるのが何個あるか
    ll res = 0;
    for(int i = 0; i < N; ++i) {
        if(A[i] >= 0){
            int candidate = b_search(A[i], X, true, cmp);
            if(i <= candidate) --candidate;
            res += (ll)candidate + 1;
        } else {
            int candidate = b_search(A[i], X, false, cmp);
            if(candidate <= i) ++candidate;
            res += (ll)N - candidate;
        }
    }
    return res/2LL;
}

int main()
{
    scanf("%d %lld", &N, &K);
    for(int i = 0; i < N; ++i) scanf("%lld", &A[i]);
    sort(A, A + N);

    ll low = -INF, high = INF;
    while(abs(high - low) > 1) {
        ll mid = (low + high)/2;
        if(order_ascending(mid) < K) low = mid;
        else high = mid;
    }
    printf("%lld\n", low);
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i=0;i<N;i++) cin >> a[i];

  int ans = 0;
  int ind = 0;
  while(1){
    int key = 0;//-1:現象　0:未定　1:増加
    while(1){
      if(ind == N-1){
        ans++;
        break;
      }
      if(key == 0){
        if(a[ind] == a[ind+1]) ind++;
        else if(a[ind] < a[ind+1]){
          key = 1;
          ind++;
        }
        else if(a[ind] > a[ind+1]){
          key = -1;
          ind++;
        }
      }

      else if(key == 1){
        if(a[ind] <= a[ind+1]) ind++;
        else{
          ans++;
          break;
        }
      }

      else if(key == -1){
        if(a[ind] >= a[ind+1]) ind++;
        else{
          ans++;
          break;
        }
      }
    }

    if(ind == N-1){
      break;
    }
    ind++;
  }

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


Measured memory_bytes: 640
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint zyo[200100],rz[200100];
lint nz[200100];
lint db[200100],dw[200100];//n回目までで黒/白が無くなる確率
	lint mo=1000000007;
lint extgcd(lint a, lint b, lint &x, lint &y) {
  lint g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
lint invMod(lint a, lint m) {
  lint x, y;
  if (extgcd(a, m, x, y) == 1) return (x + m) % m;return 0;
}
lint co(int a,int b){
	if(a<0 || b<0 || a<b) return 0;
	return (zyo[a]*rz[b])%mo*rz[a-b]%mo;
}
int main()
{
	int b,w;cin>>b>>w;
	zyo[0]=1;rep(i,200050) zyo[i+1]=(zyo[i]*(i+1))%mo;
	rep(i,200050) rz[i]=invMod(zyo[i],mo);
	nz[0]=1;rep(i,200050) nz[i+1]=(nz[i]*2)%mo;
	db[0]=dw[0]=0;
	rep(i,b+w){
		db[i+1]=db[i]+invMod(nz[i+1],mo)*co(i,b-1);
		db[i+1]%=mo;
		dw[i+1]=dw[i]+invMod(nz[i+1],mo)*co(i,w-1);
		dw[i+1]%=mo;
		//cout<<db[i+1]<<' '<<dw[i+1]<<endl;
	}
	rep(i,b+w){
		lint ret=dw[i]+(1-db[i]-dw[i])*invMod(2,mo);
		//if(i==1) cout<<db[i]<<" "<<dw[i]<<"a"<<(1-db[i]-dw[i]+mo)%mo<<endl;
		ret%=mo;ret+=mo;ret%=mo;
		cout<<ret<<endl;
	}
}


Measured memory_bytes: 9984
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int doub(int a) {
	int res = 0;
	while (a % 2 == 0) {
		res++;
		a /= 2;
	}
	return res;
}

int main() {
	IOS;
	int n, x = 0;
	cin >> n;
	vector<int> a(n), b(n), cnt(30, 0);
	REP(i, n) {
		cin >> a[i];
		b[i] = doub(a[i]);
		cnt[b[i]]++;
		x ^= a[i];
	}
	vector<int> c,d;
	while (x) {
		c.push_back(x % 2);
		x /= 2;
	}
	if (c.size() == 0) {
		put(0);
		return 0;
	}
	d.push_back(c.size()-1);
	RREP(i, c.size()) {
		if (i > 0) {
			if (c[i] != c[i - 1]) {
				d.push_back(i - 1);
			}
		}
	}
	REP(i, d.size()) {
		if (cnt[d[i]] == 0) {
			put(-1);
			return 0;
		}
	}
	put(d.size());
	return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define int long long
signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    int cur = 100;
    int ans = 0;
    while (cur < x) {
        ++ans;
        cur = (int)((double)cur + (double)cur * 0.01);
    }
    cout << ans;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string S,T;
    cin >> S >> T;
    pr(T+S);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n;
  int t[n],o=0;
  for(int i=0;i<n;i++){
    cin >> t[i];
    o+=t[i];
  }
  cin >> m;
  int a[m],b[m];
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
      cout << o-t[a[i]-1]+b[i] << endl;
  }
}

Measured memory_bytes: 256
import collections
h = collections.Counter([0])
cumul,m,ans = 0,2019,0
pt = 1
for j,u in enumerate(map(int,list(raw_input()))[::-1]):
	cumul += u * pt
	cumul %= m
	pt *= 10
	pt %= m
	ans += h[cumul]
	h[cumul]+=1
print ans



Measured memory_bytes: 90116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = scan[0];
            var k = scan[0];
            var x = scan[0];
            var t = scan[0];
            long ans = 0;
            for (int i = 0; i < n; i++)
            {
                if (i < k) ans += x;
                else ans += t;
            }
            Console.WriteLine(ans);
        }

        static int[] scan { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } }
    }
}


Measured memory_bytes: 2776
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1000000010
#define N 2010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n,p[N],a[N],t,deep[N],size[N],sigmadeep[N],f[N],root,ans=inf;
struct data{int to,nxt;
}edge[N<<1];
void addedge(int x,int y){t++;edge[t].to=y,edge[t].nxt=p[x],p[x]=t;}
void dfs(int k,int from)
{
	size[k]=a[k];sigmadeep[k]=a[k]*deep[k];
	for (int i=p[k];i;i=edge[i].nxt)
	if (edge[i].to!=from)
	{
		deep[edge[i].to]=deep[k]+1;
		dfs(edge[i].to,k);
		size[k]+=size[edge[i].to];
		sigmadeep[k]+=sigmadeep[edge[i].to];
	}
}
void work(int k,int from)
{
	int son=0;f[k]=0;
	for (int i=p[k];i;i=edge[i].nxt)
	if (edge[i].to!=from) son++,work(edge[i].to,k);
	if (son==0) f[k]=0;
	else
	{
		for (int i=p[k];i;i=edge[i].nxt)
		if (edge[i].to!=from) sigmadeep[edge[i].to]+=size[edge[i].to],f[edge[i].to]+=size[edge[i].to];
		if (son==1) 
		{
			int s=0;
			for (int i=p[k];i;i=edge[i].nxt)
			if (edge[i].to!=from) s=f[edge[i].to];
			f[k]=s;
		}
		else
		{
			int mx1=-1,mx2=-1;
			for (int i=p[k];i;i=edge[i].nxt)
			if (edge[i].to!=from)
				if (sigmadeep[edge[i].to]>mx1) mx2=mx1,mx1=sigmadeep[edge[i].to];
				else mx2=max(mx2,sigmadeep[edge[i].to]);
			for (int i=p[k];i;i=edge[i].nxt)
			if (edge[i].to!=from) mx2=max(mx2,f[edge[i].to]);
			f[k]=mx2*2;
			for (int i=p[k];i;i=edge[i].nxt)
			if (edge[i].to!=from) f[k]-=min(mx2,sigmadeep[edge[i].to]);
		}
		f[k]=max(f[k],sigmadeep[k]&1);
	}
}
//若干个f[]~sigmadeep[]之间的变量，最小化max{x}*2-Σx 
//枚举maxx 后，后一部分即Σmin(x,sigmadeep) 
//x应取次大deep 
signed main()
{
	n=read();
	for (int i=1;i<=n;i++) if (getc()=='0') a[i]=0;else a[i]=1;
	for (int i=1;i<n;i++)
	{
		int x=read(),y=read();
		addedge(x,y),addedge(y,x);
	}
	for (int i=1;i<=n;i++)
	{
		memset(deep,0,sizeof(deep));
		memset(size,0,sizeof(size));
		memset(sigmadeep,0,sizeof(sigmadeep));
		memset(f,42,sizeof(f));
		dfs(i,i);
		for (int j=1;j<=n;j++) sigmadeep[j]-=size[j]*deep[j];
		if (sigmadeep[i]&1) continue;
		work(i,i);
		/*for (int j=1;j<=n;j++) cout<<deep[j]<<' ';cout<<endl;
		for (int j=1;j<=n;j++) cout<<size[j]<<' ';cout<<endl;
		for (int j=1;j<=n;j++) cout<<sigmadeep[j]<<' ';cout<<endl;
		for (int j=1;j<=n;j++) cout<<f[j]<<' ';cout<<endl;cout<<endl;*/
		if (f[i]==0) ans=min(ans,sigmadeep[i]/2);
	}
	if (ans==inf) cout<<-1;else cout<<ans;
	return 0;
	//NOTICE LONG LONG!!!!!
}
//假设确定根
//f[i]将i子树内的点都移到lca的最小深度之和
// 

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ll long long
#define all(a) a.begin(), a.end() 
using namespace std;

int main() {
  ll int n;
  cin >> n;
  cout << (n-1)*n/2 << endl;
  
  return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	string s;
	cin>>s;
	fo(i,0,s.size())cout<<'x';
	return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

int N, W;
int value[110], weight[110];
int dp[110][10010];

int main() {
   cin >> N >> W;
   rep (i, 0, N) {
      cin >> value[i] >> weight[i];
   }
   rep (w, 0, W+1) {
      dp[0][w] = 0;
   }
   rep (i, 0, N) {
      rep (w, 0, W+1) {
         if (w >= weight[i]) {
            dp[i+1][w] = 
               max(dp[i][w-weight[i]] + value[i], dp[i][w]);
         } else {
            dp[i+1][w] = dp[i][w];
         }
      }
   }
   cout << dp[N][W] << endl;

   return 0;
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;

        static void Solve()
        {
            string o = Console.ReadLine();
            string e = Console.ReadLine();
            int n = o.Length + e.Length;
            StringBuilder sb = new StringBuilder(n);
            for(int i=0;i<n;++i)
            {
                sb.Append(0);
            }
            for(int i=0;i<o.Length;++i)
            {
                sb[i * 2] = o[i];
            }
            for(int i=0;i<e.Length;++i)
            {
                sb[i * 2 + 1] = e[i];
            }
            Console.WriteLine(sb.ToString());
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13140
#include<cstdio>
#define min(a,b) (a<b?a:b)
#include<cstring>
#define mod 1000000007
using namespace std;

char s[300005];
int f[300005][3][3]; //Dp到第i个，当前栈中有j个1，k个0 

int main() {
	scanf("%s", s);
	f[0][0][0] = 1;
	int n = strlen(s);
	for(register int i = 0; i < n; i++) 
		for(register int j = 0; j <= 2; j++) 
			for(register int k = 0; k <= 2; k++) {
				if(s[i] != '1') {
					if(k == 2) f[i + 1][j][1] += f[i][j][k], f[i + 1][j][1] %= mod;
					else f[i + 1][j][k + 1] += f[i][j][k], f[i + 1][j][k + 1] %= mod;
				}
				if(s[i] != '0') {
					if(!k) f[i + 1][min(j + 1, 2)][k] += f[i][j][k], f[i + 1][min(j + 1, 2)][k] %= mod;
					else f[i + 1][j][k - 1] += f[i][j][k], f[i + 1][j][k - 1] %= mod;
				}
			}
	int ans = 0;
	for(register int i = 0; i <= 2; i++)
		for(register int j = 0; j <= i; j++)
			ans = (ans + f[n][i][j]) % mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {
    public static void main(String[] arg) {

        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();

        int len = s.length();
        String s1, s2;
        if (len % 2 == 0) {
            // 割り切れる
            s1 = s.substring(0, len / 2);
            s2 = s.substring(len / 2);
        } else {
            // 割り切れない
            s1 = s.substring(0, len / 2);
            s2 = s.substring(len / 2 + 1);
        }

        StringBuffer sb = new StringBuffer(s2);
        s2 = sb.reverse().toString();

        int cnt = 0;
        for (int i=0; i < len/2; i++) {
            if (!s1.substring(i, i+1).equals(s2.substring(i, i+1)))  {
                cnt++;
            }
        }

        System.out.println(cnt);


    }
}

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

int main(void){
    int N; cin >> N;
    int start=1000, end=0;

    for(int i=0; i<N; i++){
        int a; cin >> a;
        end=max(end,a); start=min(start,a);
    }

    cout << end-start << endl;
    return 0;
}

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

int main(void){
  int n;
  int h[20];
  int max=0;
  int ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    
	cin>>h[i];
    if(h[i]>=max){
     ans++;
      max=h[i];
    }
  }
  cout<<ans<<endl;
  

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
long long int N, M;
int main(void) {


	cin >> N >> M;

	if (N == 1 && M == 1) { cout << 1 << endl; }
	else if (N == 1) { cout << M - 2 << endl; }
	else if (M == 1) { cout << N - 2 << endl; }
	else if (N == 2 || M == 2) { cout << 0 << endl; }
	else { cout << (N - 2)*(M - 2) << endl; }

	//system("pause");
	return 0;
}

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

int main() {
  int N, X; cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++) cin >> L[i];


  int sum = 0;
  int cnt = 1;
  for (int i = 0; i < N; i++) {
    sum += L[i];
    if (sum > X) break;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
nums = input()
nums = nums.split(' ')
n = int(nums[0])
a = int(nums[1])
b = int(nums[2])
if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
    exit(0)
if a > b:
    print(0)
    exit(0)
num = b*(n-2) - a*(n-2) + 1
print(num)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main() {
    ll n, q;
    cin >> n;
    ll sum = 0;
    ll a = 0;
    vll num (100001, 0);
    rep (i, n) {
        cin >> a;
        sum += a;
        num[a]++;
    }
    
    cin >> q;
    ll b, c;
    rep (i, q) {
        cin >> b >> c;
        sum += (c-b) * num[b];
        num[c] += num[b];
        num[b] = 0;
        
        
        cout << sum << endl;
    }
    
    
    
    return 0;
}



Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int S[3];
    REP(i,3){cin >> S[i];}
    sort(S,S+3);
    Yes(S[0]==S[2]);
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b;
    if( (a==3 && b==1) || (a==1 && b==3) )
        cout<<2;
    if( (a==2 && b==1) || (b==2 && a==1) )
        cout<<3;
    if( (a==2 && b==3) || (a==3 && b==2) )
        cout<<1;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var a = cin.ArrayLong(n);

            var ans = 0L;
            var mae = a[0];
            for (int i = 1; i < a.Length; i++)
            {
                if(mae > a[i])
                {
                    ans += (mae - a[i]);
                    mae = a[i] + (mae - a[i]);
                }
                else
                {
                    mae = a[i];
                }
            }
            
            
            Console.WriteLine(ans);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 46756
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cstring>
#include<functional>

#define vec2c vector<vector<char>>
#define vec2i vector<vector<int>>
#define vecc vector<char>
#define vecs vector<string>
#define veci vector<int>
#define vecd vector<double>
#define rep(i, n) for(int i=0; i < (int)(n); i++)
#define rrep(i, n) for(int i=(int)(n); i>=0;i--)

using namespace std;

int main() {

  int A, B, cnt = 0;
  cin >> A >> B;
  int output = 1;

  while(output < B) {
    output--;
    output += A;
    cnt++;
  }

  cout << cnt << endl;
  return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli num ;
    cin >> num ;
    cout << (num / 2.0 + 0.5) * num ;
    //cout << num / 1.5 * num ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep (i, n) cin >> a[i];
	a[0]--;
	FOR (i, 1, n) {
	  if (a[i] > a[i - 1]) {
		a[i]--;
	  } else if (a[i] < a[i - 1]) {
		cout << "No" << endl;
		return 0;
	  }
	}
	cout << "Yes" << endl;
    
    return 0;
}



Measured memory_bytes: 3728
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

cnt = 0
#c_ = 0

for i in range(n):
    if b[i] >= a[i]:
        cnt += a[i]
        b[i] -= a[i]
        if a[i+1] > b[i]:
            cnt += b[i]
            a[i+1] -= b[i]

        else:
            cnt += a[i+1]
            a[i+1] = 0

    else:
        cnt += b[i]
     # if i == n:
    #     c = c_ - a[i]
    #     if c > 0:
    #         cnt += a[i]
    #     else:
    #         cnt += c_
    #
    # else:
    #     c = c_ + b[i] - a[i]
    #     if c > 0:
    #         c_ = c
    #         cnt += a[i]
    #     else:
    #         cnt += b[i] + c_
    #         c_ = 0

print(cnt)


Measured memory_bytes: 18624
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

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

int main() {
    long double res = 0;
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) {
        int a;
        long double value = 1;
        scanf("%d", &a);
        value = value / a;
        res += value;
    }
    printf("%Lf\n", 1 / res);
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string s;
int n;
int main(){
    cin>>n;
    cin>>s;
    for(int i=0;i<s.size();i++){
        s[i] += n;
        if(s[i] > 'Z')s[i] -= 26;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
// Indrajeet Mishra

/*#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")*/
 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define test(s) if (!(s)) { cout << __LINE__ << " " << #s << endl; exit(-1); }
#define debug(x) do { std::cerr << x; } while (0)
#define endl "\n"
#define pb push_back
#define pf push_front
#define vll vector<ll>
#define dll deque<ll>
#define sll set<ll, greater <ll>>
#define mll map<ll, ll>
#define vii vector<int>
#define dii deque<int>
#define sii set <int, greater <int>>
#define mii map<int, int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define inv2 500000004
#define inv6 166666668
#define N 1000005
#define inf 200000000
#define eps 1e-10
#define PI 3.14159265359
#define all(v) (v).begin(),(v).end()
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define gcd(a,b) __gcd(a,b)


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=0,dp[1000000]={0};cin>>n;
    vll v;
    rep(i,0,n){
        ll temp=0;cin>>temp;
        v.pb(temp);
    }
    dp[1]=abs(v[1]-v[0]);
    rep(i,2,n){
        dp[i]=min((dp[i-1]+abs(v[i]-v[i-1])),(dp[i-2]+abs(v[i]-v[i-2])));
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 12084
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// your code goes here
		
		string iti = Console.ReadLine();
		string ni = Console.ReadLine();
		string sann = Console.ReadLine();
		
		string a = iti.Substring(0,1);
		string b = ni.Substring(1,1);
		string c = sann.Substring(2,1);
		
		Console.WriteLine(a+b+c);
		
	}
}

Measured memory_bytes: 13140
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;
 
int main(){
  double N;
  cin >> N;
  for(int i=sqrt(N);i>0;i--){
    double n=N/i;
    if(ceil(n)==floor(n)){
      int ans=(int)log10(n)+1;
      cout<<ans<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
	char a, b;

	scanf("%c %c", &a, &b);

	if (a == 'H') {
		if (b == 'H') printf("H\n");
		else printf("D\n");
	}
	else {
		if (b == 'H') printf("D\n");
		else printf("H\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
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; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
typedef long long ll;
const int mod = 1e9 + 7;

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

  if(x < a) cout << '0' << endl;
  else cout << "10" << endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		int a;
		int b;
		a = sc.nextInt();
		b = sc.nextInt();
		
		System.out.println((a*b)+" "+((a+b)*2));
	}
	public static void main(String[] args){
		Main obj = new Main();
		obj.solve();
	}
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n = 3;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    // 処理
    sort(a, a + 3);

    // 出力
    cout << a[0] + a[1] << endl;

    return 0;
}


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

int main() {
	int n; cin >> n;
	int a[100000];
	for (int i = 0; i < n; i++) cin >> a[i];

	int count = 1;
	int num = a[0];
	if (a[0] == 2) {
		cout << 1 << endl;
		return 0;
	}

	for (int i = 0; i < n; i++) {
		count++;
		if (a[num - 1] == -1) {
			cout << -1 << endl;
			return 0;
		}else if(a[num - 1] == 2) break;

		int tmp = num - 1;
		num = a[num - 1];
		a[tmp] = -1;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct Bomb {
  int x, on;
};

struct Switch {
  int l, r;
};

struct Edge {
  int from, to, iSwitch;
};

int main() {
  int N, M;
  cin >> N >> M;
  vector<Bomb> bombs(N);
  for (int i = 0; i < (int)N; ++i) cin >> bombs[i].x >> bombs[i].on;

  auto lessX = [](const Bomb& a, const Bomb& b) { return a.x < b.x; };

  sort((bombs).begin(), (bombs).end(), lessX);

  vector<Switch> switches(M);
  for (int i = 0; i < (int)M; ++i) {
    int L, R;
    cin >> L >> R;
    switches[i].l =
        distance(bombs.begin(), lower_bound((bombs).begin(), (bombs).end(), Bomb{L, 0}, lessX));
    switches[i].r =
        distance(bombs.begin(), upper_bound((bombs).begin(), (bombs).end(), Bomb{R, 0}, lessX)) - 1;
  }

  vector<int> diff(N + 1, 0);
  for (int i = 0; i < (int)N + 1; ++i) {
    diff[i] = (i == 0 ? 0 : bombs[i - 1].on) ^ (i == N ? 0 : bombs[i].on);
  }

  vector<vector<Edge>> G(N + 1);
  for (int i = 0; i < (int)M; ++i) {
    int u = switches[i].l, v = switches[i].r + 1;
    G[u].push_back(Edge{u, v, i});
    G[v].push_back(Edge{v, u, i});
  }

  vector<bool> used(N + 1, false);
  vector<int> ans;

  function<bool(int)> leftOne = [&](int u) {
    used[u] = true;

    bool res = diff[u];
    for (Edge& e : G[u]) {
      if (used[e.to]) continue;
      if (leftOne(e.to)) {
        ans.push_back(e.iSwitch);
        res ^= 1;
      }
    }
    return res;
  };

  for (int i = 0; i < (int)N + 1; ++i) {
    if (used[i]) continue;
    if (leftOne(i)) {
      cout << -1 << endl;
      return 0;
    }
  }

  int k = ans.size();
  cout << k << endl;
  sort((ans).begin(), (ans).end());
  for (int i = 0; i < (int)k; ++i) {
    if (i) cout << " ";
    cout << ans[i] + 1;
  }
  cout << endl;

  return 0;
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define MAXN 100002
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second 
#define FAIL {printf("-1\n"); return 0;}

int N;
int A[MAXN], B[MAXN], C[MAXN];
int dp[MAXN][3];


int main(int argc, char **argv)
{
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif

    scanf("%d", &N);
    for (int i = 0; i < N; i++) scanf("%d%d%d",&A[i],&B[i],&C[i]);

    dp[0][0] = A[0];
    dp[0][1] = B[0];
    dp[0][2] = C[0];

    for (int i = 1; i < N; i++) {
        dp[i][0] = A[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = B[i] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = C[i] + max(dp[i-1][0], dp[i-1][1]);
    }

    printf("%d\n", max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2])));
    return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong N;
	cin >> N;
	bool check = false;
	for (int i = 0; i < N; ++i)
		for (int j = 0; j < N; ++j)
			check |= i*4 + j*7 == N;

	cout << (check ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
S = input()


s = S[0]

i = 0
char2 = 0 # 最大で長さが2文字にしかならないのでその分を引いてやる
while i <= len(S)-2:
    #隣と同じ場合くっつける。
    if s == S[i+1]:
        s += S[i+1]
        i += 2
        char2 += 1
    else:
        s = S[i+1]
        i += 1

print(len(S)-char2)

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

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 2e3 + 3;

int A[N],B[N],n,k,q,i,j,ans;

int f(int b, int e){
    int i,las,t,x;
    las = t = x = 0;
    for(i=1;i<=n+1;i++){
        if(A[i] < b) { x += max(0, min(t , i-las-k)); las = i; t = 0; }
        else if(A[i] <= e) t++;
    }
    return x;
}

int main(){
    cin >> n >> k >> q;
    for(i=1;i<=n;i++) { cin >> A[i]; B[i] = A[i]; }
    sort(B+1 , B+n+1);
    ans = mod;
    for(i=j=1; i<=n; i++){
        for(; j <= i && f(B[j],B[i]) >= q ; j++)
            ans = min(ans , B[i]-B[j]);
    }

    if(ans == mod) assert(0);
    cout << ans << endl;
    return 0;
}   

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 10e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int R = in();
  if(R < 1200)
  {
    cout << "ABC" << endl;
  }
  else if(R < 2800)
  {
    cout << "ARC" << endl;
  }
  else{
    cout << "AGC" << endl;
  }
  
}


Measured memory_bytes: 256