akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define pii pair<ll,ll>
#define pi pair<int ,int> 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i,a,n) for(int i=a;i>=n;i--)
#define F first
#define S second
int main()
{    
    
   int n;
   cin>>n;
   map<int,int>mp;int check=0;
   REP(i,0,n)
   {
       int x;
       cin>>x;
       
       if(mp.find(x)==mp.end()){mp[x]++;}
       else{check=1;}
   }
   if(check==0)
   {
       cout<<"YES";
   }
   else
   {
       cout<<"NO";
   }
    return 0;
}

Measured memory_bytes: 9600
#include <stdio.h>

int main(void)  {
  int i, j, k, n, x, ans = 0;
  while (1) {
    scanf("%d %d", &n, &x);
    if (n == 0 && x == 0) 
      break;
    for (i = 1; i <= n - 2; i++)  {
      for (j = i + 1; j <= n - 1; j++)  {
        for (k = j + 1; k <= n; k++)  {
          if (i + j + k == x)
            ans++;
        }
      }
    }  
    printf("%d\n", ans);
    ans = 0;
  }
}

Measured memory_bytes: 1824
#include<iostream>
using namespace std;
int main(){
  long long T,A,C;
  cin>>T>>A>>C;
  if(T<=C){
    C-=T;
    T=0;
    if(A<=C)A=0;
    else A-=C;
  }
  else T-=C;
  cout<<T<<' '<<A<<endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
import collections
c=collections.Counter(a)
ans=0
for i in c.items():
  if i[0]<i[1]:
    ans+=i[1]-i[0]
  elif i[0]>i[1]:
    ans+=i[1]
print(ans)

Measured memory_bytes: 18132
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;
  cout << (n+110)/111*111 << newl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



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

using namespace std;
int n,k;
int ans;
int main(){
  cin >> n >> k;
  ans = 1;
  REP(i,n){
    if(ans < k) ans *= 2;
    else ans += k;
  }
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int k;
    int a,b;
    cin>>k;
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
           cout<<"OK"<<endl;
           return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int INF = 114514810;
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
  }
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,K;
	cin >> N >> K;
	cout << (N%K!=0?"1":"0") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'

const ll MOD = 1e9 + 7;

map<ll,ll> pfmp; //各素因数の指数を格納
vector<ll> pfv(0); //異なる素因数を昇順に格納

void PF(ll N){
    ll n = N;
    if(n <= 0) return;
    ll exp;
    if(n % 2 == 0) {
        if (pfmp[2] == 0) pfv.push_back(2);
        exp = 0;
        while (n % 2 == 0) {
            n /= 2;
            exp++;
        }
        if (exp > pfmp[2]) pfmp[2] = exp;
    }
    if(n == 1) return;
    for(ll i = 3; i <= sqrt(N); i+=2){
        if(n % i == 0){
            if(pfmp[i] == 0) pfv.push_back(i);
            exp = 0;
            while(n % i == 0){
                n /= i;
                exp++;
            }
            if(exp > pfmp[i]) pfmp[i] = exp;
        }
    }
    //残った素数
    if(n != 1){
        if(pfmp[n] == 0){
            pfv.push_back(n);
            pfmp[n] = 1;
        }
    }
}

ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a,b);
        u -= t * v; swap(u,v);
    }
    u %= m;
    if(u < 0) u += m;
    return u;
}

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

    ll N;
    cin >> N;

    vector<ll> a(N);
    rep(i,N) cin >> a[i];
    rep(i,N) {
        PF(a[i]);
    }
    ll LCM = 1;
    rep(i,pfv.size()){
        rep(j,pfmp[pfv[i]]){
            LCM *= pfv[i] % MOD;
            LCM %= MOD;
        }
    }

    ll ans = 0;
    rep(i,N){
        ans += LCM * modinv(a[i],MOD) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

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

using namespace std;

const int N=1e5+10;

int p[N],d[N];

vector<int> G[N];

void init(int n)
{
    memset(p,-1,sizeof(p));
    memset(d,0,sizeof(d));

    for(int i=0;i<n;i++)
    {
        G[i].clear();
    }
}

void dfs(int root ,int depth)
{
    d[root]=depth;
    for(int i=0;i<G[root].size();i++)
    {
        dfs(G[root][i],depth+1);
    }

}

void display(int x)
{
    char s[100];

    if(p[x]==-1)
    {
        strcpy(s,"root");
    }else if(!G[x].size())
    {
        strcpy(s,"leaf");
    }else
    {
        strcpy(s,"internal node");
    }
    printf("node %d: parent = %d, depth = %d, %s, [",x,p[x],d[x],s);

    for(int i=0;i<G[x].size();i++)
    {
        if(i)
        {
            printf(", ");
        }
        printf("%d",G[x][i]);
    }
    printf("]\n");
}

int main()
{

    int n;

    while(scanf("%d",&n)!=EOF)
    {
        int a,b,c;

        init(n);
        for(int i=0;i<n;i++)
        {
            scanf("%d %d",&a,&b);

            for(int j=0;j<b;j++)
            {
                scanf("%d",&c);
                p[c]=a;
                G[a].push_back(c);
            }
        }

        int root;

        for(int i=0;i<n;i++)
        {
            if(p[i]==-1)
            {
                root=i;
            }
        }
        dfs(root,0);

        for(int i=0;i<n;i++)
        {
            display(i);
        }
    }



    return 0;
}



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

int main () {
  
  int a,b,A;
  cin >> a >> b;
  
  A = (a+b)/2;
    
  if((a+b)%2==1){
    cout << A+1 << endl;
  }
    
  if((a+b)%2==0){
    cout << A << endl;
  }
  
}

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

int main(){
    int N,M,A=0;
    cin >> N >>M;
    int C[2*M];
    int D[M];
    int E[M];
    for(int i=0;i<2*M;i++){
         cin >> C[i];
    }
    for(int i=0;i<M;i++){
        D[i]=C[i*2];
          E[i]=C[i*2+1];
    }
    sort(D,D+M,greater<int>());
     sort(E,E+M,greater<int>());
     
   for(int i=1;i<=N;i++){
       if(i>=D[0]&&i<=E[M-1])A++;
   }
 
  cout << A;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int llint;
int main() {
	int a, b, x;
	cin >> a >> b >> x;
	if (a <= x&&x <= a + b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<cstdio>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}

void solve(){
	ll x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	ll req=x/d;
	if(k<=req){cout<<x-k*d;return;}
	ll to=x-req*d;
	if(req%2ll==k%2ll){cout<<to;return;}
	else cout<<d-to;
	/*if(x<0){
		req=-x/k;
		ll to=x+d*k;
		if(to<=0)cout<<abs(to);
		else {
			to=x+req*k;
			to=abs(to);
			if((req+d)%2==0){cout<<abs(to);return;}
			req++;
			ll to1=x+req*k;
			to1=abs(to1);
			cout<<to1;
		}
	}
	else {
		req=x/k;
		ll to=x-d*k;
		if(to>=0)cout<<abs(to);
		else {
			to=x-req*k;
			to=abs(to);
			if((req+d)%2==0){cout<<abs(to);return;}
			req++;
			ll to1=x-req*k;
			to1=abs(to1);
			//cout<<min(to,to1);
			cout<<to1;
		}
	}*/
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll N;
pll A[30];

ll solve(vector<pll> v) {
    vector<ll> t;
    REP(i, N) {
        t.push_back(v[i].first);
    }
    sort(t.begin(), t.end());
    ll num = 0;
    REP(i, N) {
        ll p = -1;
        FOR(j, N, i) {
            if (t[i] == v[j].first && (j - i) % 2 == v[j].second) {
                p = j;
                break;
            }
        }
        if (p < 0)
            return INF;
        num += p - i;
        for (ll j = p - 1; j >= i; --j) {
            v[j + 1].first = v[j].first;
            v[j + 1].second = (v[j].second + 1) % 2;
        }
    }
    return num;
}

int main() {
    cin >> N;
    REP(i, N) {
        cin >> A[i].first;
    }
    REP(i, N) {
        cin >> A[i].second;
    }

    ll ans = INF;
    REP(i, pow(2LL, N)) {
        //! bitで裏表を表す
        //! 1の数が帰趨ならばむり
        ll n = 0;
        REP(j, N) {
            if (((i >> j) & 1) == 1)
                n++;
        }
        if (n % 2 == 1)
            continue;

        vector<pll> v;
        REP(j, N) {
            if (((i >> j) & 1) == 1)
                v.push_back(pll(A[j].second, 1));
            else
                v.push_back(pll(A[j].first, 0));
        }

        ll p = solve(v);
        ans = std::min(ans, p);
    }

    if (ans == INF)
        ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int y[3];
    cin>>y[0]>>y[1]>>y[2];
    sort(y,y+3);
    cout<<y[1]-y[0]+y[2]-y[1]<<endl;
    return 0;
}


Measured memory_bytes: 256
H,W = [int(i) for i in input().split()]
S = [list(input()) for i in range(H)]
box = [[1,0], [-1,0], [0,1], [0,-1]]
pos = True
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            for dx,dy in box:
                x,y = i+dx, j+dy
                if 0 <= x < H and 0 <= y < W and S[x][y] == "#":
                    break
            else:
                pos = False
print("Yes" if pos else "No")

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;

const int N = 1e5 + 5;

const int mod = 1e9 + 7;

const int M = 1e9;

int n, m, a[N], b[N], cnt = 1;

map<int, int> bit;

void update(int pos, int val) {
    while(pos <= M) {
        bit[pos] = (1ll * bit[pos] + val) % mod;
        pos += pos & (-pos);
    }
}

int get(int pos) {
    int ans = 0;
    while(pos > 0) {
        ans = (1ll * ans + bit[pos]) % mod;
        pos -= pos & (-pos);
    }
    return ans;
}

vector<ii> pos;

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 1; i <= m; i++)
        cin >> b[i];
    for(int i = 1; i <= n; i++) {
        while(cnt < m && b[cnt + 1] < a[i])
            cnt++;
        if(cnt < m && b[cnt] < a[i] && a[i] < b[cnt + 1])
            pos.pb({a[i] - b[cnt], b[cnt + 1] - a[i] + 1});
    }
    sort(pos.begin(), pos.end());
    update(1, 1);
    for(int i = 0; i < pos.size(); i++) {
        if(i > 0 && pos[i - 1] == pos[i])
            continue;
        int total = get(pos[i].se - 1);
        if(i > 0 && pos[i - 1].fi == pos[i].fi)
            total = (1ll * total - get(pos[i - 1].se - 1)) % mod;
        total = (1ll * total + mod) % mod;
        update(pos[i].se, total);
    }
    cout << get(M) << "\n";
}


Measured memory_bytes: 55156
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var ary = ReadLine().Split().Select(int.Parse).ToArray();
        WriteLine(ary[0] * ary[1] + 1 - ary[0] - ary[1]);
    }
}


Measured memory_bytes: 11220
import java.util.Scanner;

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

		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		System.out.println(Math.max(0, a - (2 * b)));
		sc.close();
	}
}

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

using bellman_cost = int;
template<class V, class E>
struct Graph
{
	int sz;
	vector<V> v;
	vector<vector<E>> e;
	Graph(int n) : sz(n), v(n), e(n) {}
	template<class... Args>
	inline void assign_vertex(int pos, Args... args) {
		v[pos] = V(args...);
	}
	template<class... Args>
	inline void add_edge(int pos, Args... args) {
		e[pos].emplace_back(args...);
	}
	inline int size() {
		return sz;
	}
};

template<class T>
struct Vertex_Cost
{
	T cost;
	bool valid = false;
	Vertex_Cost(T v1) : cost(v1) {}
	Vertex_Cost() {}
};
using vertex = Vertex_Cost<bellman_cost>;

template<class T>
struct Edge_Cost
{
	int to;
	T cost;
	Edge_Cost(int t, T c) : to(t), cost(c) {}
	Edge_Cost() {}
};
using edge = Edge_Cost<bellman_cost>;
using graph = Graph<vertex, edge>;

template<class T, class V, class E>
void Bellmanford(Graph<V, E>& G, int s, T INF_COST)
{
	auto &v = G.v;
	auto &e = G.e;
	for (auto& vv : v) vv.cost = INF_COST, vv.valid = false;
	v[s].cost = 0;
	v[s].valid = true;
	for (int i = 0; i + 1 < (int) v.size(); i++) {
		for (int j = 0; j < (int) v.size(); j++) {
			for (auto& x: e[j]) {
				if (v[j].cost == INF_COST) continue;
				v[x.to].cost = min(v[x.to].cost, v[j].cost + x.cost);
				v[x.to].valid = true;
			}
		}
	}
	auto valid_check = [&](auto f, int pos) {
		if (!v[pos].valid) return;
		v[pos].valid = false;
		for (auto& y: e[pos]) {
			f(f, y.to);
		}
	};
	for (int i = 0; i < (int) v.size(); i++) {
		for (auto& x: e[i]) {
			if (v[i].cost == INF_COST) continue;
			if (v[x.to].cost > v[i].cost + x.cost) {
				valid_check(valid_check, x.to);
			}
		}
	}
}


void solve(long long N, long long M, long long P, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C) {
	graph g(N);
	for (int i = 0; i < M; i++) {
		g.add_edge(A[i]-1, B[i]-1, -(C[i]-P));
	}
	Bellmanford(g, 0, INT_MAX);
	if (!g.v[N-1].valid) cout << -1 << endl;
	else cout << max(-g.v[N-1].cost, 0) << endl;
}

signed main() {
	long long N;
	scanf("%lld",&N);
	long long M;
	scanf("%lld",&M);
	long long P;
	scanf("%lld",&P);
	std::vector<long long> A(M);
	std::vector<long long> B(M);
	std::vector<long long> C(M);
	for(int i = 0 ; i < M ; i++){
		scanf("%lld",&A[i]);
		scanf("%lld",&B[i]);
		scanf("%lld",&C[i]);
	}
	solve(N, M, P, std::move(A), std::move(B), std::move(C));
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (200010)
#define P (1000000007)
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c){
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,m,f[N]; char s[N];
void spj(){
	int f[N][2];
	for(int i=1;i<=m;i++)if(s[i]=='R')return;
	int ans=0; f[1][0]=0,f[1][1]=1;
	for(int i=2;i<=n;i++){
		f[i][0]=f[i-1][1];
		f[i][1]=(f[i-1][0]+f[i-1][1])%P;
	}
	(ans+=(f[n][0]+f[n][1])%P)%=P;
	f[1][0]=1,f[1][1]=0,f[2][0]=0,f[2][1]=1;
	for(int i=3;i<=n;i++){
		f[i][0]=f[i-1][1];
		f[i][1]=(f[i-1][0]+f[i-1][1])%P;
	}
	(ans+=f[n][1])%=P;
	printf("%d\n",ans);
	exit(0);
}
int main(){
	read(n),read(m);
	for(int i=1;i<=m;i++)readc(s[i]);
	if(s[1]=='R'){for(int i=1;i<=m;i++)s[i]^='R'^'B';}
	spj(); int lst=m,lim=n,cnt=0; while(s[lst]=='B')lst--;
	for(int i=lst;~i;i--)
	if(!i||s[i]=='R'){
		if(cnt&1)lim=min(lim,cnt+1);
		else if((!i)&&cnt)lim=min(lim,cnt+2);
		cnt=0;
	}
	else cnt++;
//	cout<<lim<<endl; 
	f[0]=f[2]=1;
	for(int i=4;i<=n;i+=2){
		f[i]=1ll*f[i-2]*2%P;
		if(i-2>=lim)f[i]=(f[i]-f[i-lim-2]+P)%P;
	}
	int ans=0;
	for(int i=2;i<=lim;i+=2)
	(ans+=1ll*f[n-i]*i%P)%=P;
	cout<<ans;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  } 
  sort(d.begin(), d.end());
  int a;
  
 
    
  if(d.at(N/2-1)==d.at(N/2)){
    a=0;
  }
  if(d.at(N/2-1)!=d.at(N/2)){
    a=d.at(N/2)-d.at(N/2-1);
  }
         
  cout<<a<<endl;
}




Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for(int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clar(a, b) memset((a), (b), sizeof(a))
#define debug(...) fprintf(stderr, __VA_ARGS__)
typedef long long LL;
typedef long double LD;
const double pi = acos(-1);
const int BUF_SIZE = (int)1e6 + 10;
template <typename T> inline bool chkmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}
template <typename T> inline bool chkmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
LL read() {
	char ch = getchar();
	LL x = 0, flag = 1;
	for (;!isdigit(ch); ch = getchar()) if (ch == '-') flag *= -1;
	for (;isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
	return x * flag;
}

const int Maxn = 1e5 + 9;
set <int> G[Maxn];
map<pair<int, int>, int> buc;
queue <pair<int, int> > que;
int fa[Maxn], n;
int find(int u) { return (fa[u] ^ u) ? (fa[u] = find(fa[u])) : u; }
void add(int u, int v) { G[u].insert(v); }

void link(int u, int v) {
	add(u, v), add(v, u);
	if (u > v) swap(u, v);
	if (++buc[make_pair(u, v)] == 2) que.push(make_pair(u, v));
}

void Init() {
	n = read();
	rep (i, 1, n) fa[i] = i;
	rep (i, 1, n - 1) link(read(), read());
	rep (i, 1, n - 1) link(read(), read());
}

void Solve() {
	int cnt = 0;
	while (!que.empty()) {
		pair<int, int> p = que.front(); que.pop(); 
		p.first = find(p.first), p.second = find(p.second);
		if (p.first == p.second) continue;

		int u = p.first, v = p.second;
		
		if (G[u].size() > G[v].size()) swap(u, v);
		++cnt, fa[u] = v;

		for (set <int> :: iterator IT = G[u].begin(); IT != G[u].end(); ++IT) {
			int q = find(*IT);
			if (q != v) link(q, v);
		}
	}
	printf("%s\n", cnt == n - 1 ? "YES" : "NO");
}

int main() {

	Init();
	Solve();

#ifdef Qrsikno
	debug("\nRunning time: %.3lf(s)\n", clock() * 1.0 / CLOCKS_PER_SEC);
#endif
	return 0;
}



Measured memory_bytes: 54272
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int ans=0;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    if(x>=k) ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int main(){
  int a,b,c,i;
  scanf("%d %d %d",&a,&b,&c);
  for(i=gcd(a,b);c;i--){
    if(a%i==0&&b%i==0)c--;
  }
  printf("%d\n",i+1);
  return 0;
}


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

int main() {
  string s;
  cin >> s;

  int ans = 0;

  for (int k = 0; k < (int)s.size(); k++) {
    if (s[k] == '+') ans++;
    else ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

bool dp[3011][3011];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	dp[0][0]=1;
	ll a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	for(int i=1;i<=f;i++)
	{
		for(int j=0;j<=i;j+=100)
		{
			if(j-100*a>=0)
			{
				dp[i][j]|=dp[i-100*a][j-100*a];
			}
			if(j-100*b>=0)
			{
				dp[i][j]|=dp[i-100*b][j-100*b];
			}
			if(i-c>=0)
			{
				//if(dp[i-c][j]) cerr<<"F ; "<<i-c<<' '<<j<<'\n';
				dp[i][j]|=dp[i-c][j];
			}
			if(i-d>=0)
			{
				//if(dp[i-d][j]) cerr<<"F : "<<i-d<<' '<<j<<'\n';
				dp[i][j]|=dp[i-d][j];
			}
			//if(dp[i][j]) cerr<<i<<' '<<j<<'\n';
		}
	}
	ii bestfrac = mp(100*a,100*a);
	for(int i=1;i<=f;i++)
	{
		for(int j=0;j<=i;j+=100)
		{
			if(dp[i][j]&&(j*e>=100*(i-j)))
			{
				if(j*bestfrac.se<i*bestfrac.fi)
				{
					bestfrac=mp(j,i);
				}
			}
		}
	}
	cout<<bestfrac.se<<' '<<bestfrac.se-bestfrac.fi<<'\n';
}


Measured memory_bytes: 8704
#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 <climits>
#include <random>
#include <iomanip>

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

typedef long long int ll;

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

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

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

  int n;
  cin >> n;

  vector<long> c(n);

  rep(i, n) {
    int p;
    cin >> p;
    c[p-1] = i;
  }

  vector<long> asum(n+1);
  vector<long> bsum(n+1);

  asum[0] = 0;
  bsum[n] = 0;
  rep(i, n) {
    asum[i+1] = asum[i] + c[i];
  }
  rep(i, n) {
    bsum[n-i-1] = bsum[n-i] + c[n-i-1];
  }

  vector<long> a(n);
  vector<long> b(n);

  rep(i, n) {
    a[i] = i+1 + asum[i+1];
    b[n-i-1] = i+1 + bsum[n-i-1];
  }

  rep(i, n) {
    cout << a[i] << " ";
  }
  cout << endl;
  rep(i, n) {
    cout << b[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
    #include<iterator>
    #define HAR BAR LAGTA HAI APUN HI J BHAGWAAN HAI!!
    #define ll long long int
    #define MAX 1e9
    #define MIN -1e9
    #define mod 1000000007
    #define pb push_back
    #define all(x) (x).begin(), (x).end()
    #define debug(x) cerr<<#x<<'='<<(x)<<endl;
    #define output(x) cout << ( x ? "YES" : "NO" ) << '\n' ;
    #define mxn 100005
    using namespace std;
    int main()
    {
        string s;
        cin>>s;
        ll sum = 0;
        ll size = s.size();
        for(ll i=0;i<size;i++) sum = sum + (s[i]-48);
        if(sum%9==0) cout<<"Yes";
        else cout<<"No";
        return 0;
    }

Measured memory_bytes: 3680
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int v[210005];
int res[210000];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;

    for(int i=1;i<=n;i++){
        int a;
        cin>>a;
        v[i]=a;
    }
    for(int i=n;i>0;i--){
        int somme=0;
        for(int j=i+i;j<=n;j+=i){
            somme+=res[j];
        }
        if(somme%2==v[i])res[i]=0;
        else res[i]=1;
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(res[i]!=0)cnt++;
    }
    cout<<cnt<<endl;
    for(int i=1;i<=n;i++){
        if(res[i]==1)cout<<i<<" ";
    }
    return 0;
    }


Measured memory_bytes: 2560
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h> // sqrt
using namespace std;

long long divid(long long N, long long n) {
    long long ans = 0;
    while (true) {
        if (N % n != 0) {
            break;
        }
        ans++;
        N /= n;
    }
    return ans;
}

long long kaijo(long long n) {
    long long ans = 0;
    long long i = 1;
    while (true) {
        if (n < i) {
            break;
        }
        ans++;
        n -= i;
        i++;
    }
    return ans;
}

long long dividn(long long N, long long i, long long n) {
    for (long long j = 0; j < n; j++) {
        N /= i;
    }
    return N;
}

int main() {
    long long N, n;
    cin >> N;
    long long ans = 0;
    long long div, kai;
    long long i = 2;
    n = N;
    while (true) {
        if (sqrt(N) < i && sqrt(N) < n) {
            ans++;
            break;
        }
        if (sqrt(N) < i) {
            break;
        }
        div = divid(n, i);
        if (div == 0) {
            i++;
            continue;
        }
        kai = kaijo(div);
        ans += kai;
        n = dividn(n, i, div);
        i++;
    }
    cout << ans << endl;
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

  ll last = 1 << N;
  vector<ll> S(last);
  rep0(i, last) cin >> S[i];
  sort(S.begin(), S.end());

  string ans = "Yes";
  vector<ll> child;
  child.push_back(S[last - 1]);
  S[last - 1] = -1;

  rep(i, 1, N + 1) {
    vector<ll> parent = child;
    sort(parent.begin(), parent.end());

    ll idx = last - 1;
    while(parent.size() > 0 && idx >= 0) {
      if (S[idx] != -1 && S[idx] < parent.back()) {
        child.push_back(S[idx]);
        parent.pop_back();
        S[idx] = -1;
      } else {
        idx--;
      }
    }
    if (parent.size() > 0) {
      ans = "No";
      break;
    }
  }

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 5484
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline
n,m=map(int,input().split())
z=n*(n-1)//2
l=[-1]*n
a=[1]*n
b=[input().split() for _ in range(m)]
c=[0]*m+[z]
def r(s):
  t=l[s]
  if t<0:
    return s
  else:
    l[s]=r(t)
    return l[s]
def f(s):
  return r(int(s)-1)
for i in range(m-1,-1,-1):
  x,y=map(f,b[i])
  if x!=y:
    l[x]=y
    z-=a[x]*a[y]
    a[y]+=a[x]
  c[i]=z
for x in c[1:]:
  print(x)

Measured memory_bytes: 50028
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;
int x , y , a , b , c;
vector<pair<int , int>> p;
ll ans;
int main()
{
    abdelrahman010
    cin >> x >> y >> a >> b >> c;
    for(int i = 0;i < a;i++)
    {
        int x;
        cin >> x;
        p.push_back({x , 0});
    }
    for(int i = 0;i < b;i++)
    {
        int x;
        cin >> x;
        p.push_back({x , 1});
    }
    for(int i = 0;i < c;i++)
    {
        int x;
        cin >> x;
        p.push_back({x , 2});
    }
    sort(p.rbegin() , p.rend());
    int cnta = 0 , cntb = 0;
    vector<int> v;
    for(auto &i : p)
    {
        if(cnta < x && !i.second)
            v.push_back(i.first) , cnta++;
        else if(cntb < y && i.second == 1)
            v.push_back(i.first) , cntb++;
        else if((cnta < x || cntb < y) && i.second == 2)
            v.push_back(i.first);
    }
    for(int i = 0;i < x + y;i++)
        ans += 1ll * v[i];
    cout << ans;
    return 0;
}

Measured memory_bytes: 7148
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 10000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector

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

int N; cin >> N;
VI X(N), L(N); 
VP LR(N); 
rep(i, 0, N) {
    cin >> X[i] >> L[i];
    LR[i].first = X[i] - L[i];
    LR[i].second = X[i] + L[i];
}
sort(ALL(LR));
int cnt0 = 1, cnt1 = 1;
PII pre = LR[0];
rep(i, 1, N){
    if (pre.second <= LR[i].first) {
        ++cnt0;
        pre = LR[i];
    }
}
pre = LR[N-1];
Rrep(i, N-2, 0){
    if (pre.first >= LR[i].second) {
        ++cnt1;
        pre = LR[i];
    }
}

cout << max(cnt0, cnt1) << endl;

}
// 書いて考える．場合分け．情報整理．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



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

int main(void)
{
    long long N;
    cin >> N;
    vector<long long> a(N);
    vector<long long> b(N);
    vector<long long> c(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    for (long long i = 0; i < N; i++)
    {
        cin >> b[i];
    }
    for (long long i = 0; i < N; i++)
    {
        cin >> c[i];
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    long long ans = 0;
    for (long long i = 0; i < N; i++)
    {
        long long anum = 0;
        long long cnum = 0;
        long long min = -1;
        long long max = N;
        while(1)
        {
            if (max - min == 1)
            {
                anum = min + 1;
                break;
            }
            if (a[(min + max) / 2] < b[i])
            {
                min = (min + max) / 2;
            }
            else
            {
                max = (min + max) / 2;
            }
        }
        min = -1;
        max = N;
        while(1)
        {
            if (max - min == 1)
            {
                cnum = N - max;
                break;
            }
            if (c[(min + max) / 2] <= b[i])
            {
                min = (min + max) / 2;
            }
            else
            {
                max = (min + max) / 2;
            }
        }
        ans += anum * cnum;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String t = sc.nextLine();
		
		int count = 0;
		
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) != t.charAt(i) ) {
				count++;
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 42300
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B_fix_2
# CreatedDate:  2020-08-29 22:10:51 +0900
# LastModified: 2020-08-29 22:37:02 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    S = input()
    T = input()
#    if S==T:
#        print(0)
#        return
    ans = 0
    for i in range(len(S)-len(T)+1):
        stack = 0
        ans_tmp = 0
        for t in T:
            if t == S[i+stack]:
                ans_tmp += 1
            if ans_tmp > ans:
                ans = ans_tmp
            stack += 1
    print(len(T)-ans)


if __name__ == "__main__":
    main()


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

const int mnx = 3e5 + 9;
const int mod = 1e9 + 7;

ll n, mn;
ll sum, res;


int main() {

cin>>n;

mn = mnx;

for(int i=1; i<n; i++) {
    int a = i; sum = 0;
    int b = n - i; res = 0;
    while (a) {
        sum += (a % 10);
        a /= 10;
    }
    while (b) {
        res += (b % 10);
        b /= 10;
    }
    mn = min(mn, sum + res);
}

cout<<mn<<'\n';


    return 0;

}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"sort"
	"strconv"
)

func main() {
	n := readInt()
	a := make([]int, n)
	for i := range a {
		a[i] = readInt()
	}
	sort.Ints(a)

	ans := 0
	for i := range a {
		if i%2 == 0 {
			ans += a[n-1-i]
		} else {
			ans -= a[n-1-i]
		}
	}

	fmt.Println(ans)
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

int main()
{
  while(1){
    int n,k;
    cin>>n>>k;
    if(!n&&!k){break;}
    else{
      int *a;
      a=new int[k];
      for(int i=0;i<k;i++){
	cin>>a[i];
      }
      
      sort(a,a+k);
      int lx=0,l=1;
      
      if(a[0]){
	for(int i=0;i<k-1;i++){
	  if(a[i]+1==a[i+1]){l++;}
	  else{
	    lx=(l>lx)?l:lx;
	    l=1;
	  }
	}

	lx=(l>lx)?l:lx;
      }

      else{
	int m=0;
	for(int i=1;i<k-1;i++){
	  if(a[i]+1==a[i+1]){l++;}
	  else if(a[i]+2==a[i+1]){
	    lx=(lx<l+m)?l+m:lx;
	    m=l+1;l=1;
	  }
	  else{
	    lx=(lx<l+m)?l+m:lx;
	    m=0;l=1;
	  }
	}

	lx=(lx<l+m)?l+m:lx;
      }
      
      cout<<lx<<endl;
      delete []a;
    }
  }
  return 0;
}

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

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

def readInts():
  return list(map(int,input().split()))

def main():
    s = input()
    k = int(input())
    one = 0
    while s[one] == '1':
        one += 1
        if not one < len(s):
            break
    if one >= k:
        print(1)
    else:
        print(s[one])

if __name__ == '__main__':
  main()


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

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

  int n;
  cin >> n;

  int ans = n / 2;
  if(n%2 != 0) {
    ans++;
  }

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


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

void add(vector<int> &a, int i, int x) {
    a[i-1] += x;
}

int getSum(vector<int> &a, int s, int t) {
    int sum = 0;
    for(int i=s-1; i<=t-1; ++i) {
        sum += a[i];
    }
    return sum;
}

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n, 0);

    vector<int> com, x, y;
    for(int i=0; i<q; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        com.push_back(a);
        x.push_back(b);
        y.push_back(c);
    }

    for(int i=0; i<q; ++i) {
        if(com[i] == 0) {
            add(a, x[i], y[i]);
        } else if(com[i] == 1) {
            cout << getSum(a, x[i], y[i]) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4672
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(a.rbegin(),a.rend());
    ll ans=0;
    rep(i,n){
        if(i%2==0){
            ans+=a[i];
        }
        else{
            ans-=a[i];
        }
    }
    cout << ans << endl;
} 

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>

int main()
{
    char str[1001], buff[1001], command[100];
    int q, a, b;

    scanf("%s", str);
    scanf("%d", &q);

    for(int i = 0; i < q; i++){
        scanf("%s", command);
        if(strcmp(command, "print") == 0){
            scanf("%d", &a);
            scanf("%d", &b);
            for(int j = 0; j <= b - a; j++){
                buff[j] = str[a + j];
            }
            buff[b-a+1] = '\0';
            printf("%s\n", buff);
        }
        else if(strcmp(command, "reverse") == 0){
            scanf("%d", &a);
            scanf("%d", &b);
            strcpy(buff, str);
            for(int j = 0; j <= b - a; j++){
                str[a + j] = buff[b - j];
            }
        }
        else if(strcmp(command , "replace") == 0){
            scanf("%d", &a);
            scanf("%d", &b);

            char p[b - a + 1];
            scanf("%s", p);

            for(int j = 0; j <= b - a; j++){
                str[a + j] = p[j];
            }
        }
        else {
            printf("ERROR\n");
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], K = l[1];
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var dict = new Dictionary<int, int>();

            foreach (var a in array)
            {
                if (dict.ContainsKey(a))
                    dict[a]++;
                else
                    dict[a] = 1;
            }

            dict = dict.OrderBy(o => o.Value).ToDictionary(d => d.Key, e => e.Value);

            var count = dict.Count;
            var total = 0L;
            foreach (var d in dict)
                if (count-- > K) total += d.Value;

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 46692
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  int h, w, k;
  cin >> h >> w >> k;

  vector<string> c(h);
  rep(i, h) cin >> c.at(i);

  int ans = 0;
  for (int tmp_x = 0; tmp_x < (1 << h); tmp_x++) {
    bitset<6> row(tmp_x);
    for (int tmp_y = 0; tmp_y < (1 << w); tmp_y++) {
      bitset<6> col(tmp_y);

      int sum = 0;
      rep(i, h) {
        rep(j, w) {
          if (!row.test(i) && !col.test(j) && c.at(i).at(j) == '#') sum++;
        }
      }
      if (sum == k) ans++;
    }
  }

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

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

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

ll mypow(ll a, ll p){
	if(p == 0) return 1;
	if(p == 1) return (a % MOD);
	if(p & 1) return ((a % MOD) * (mypow(a, p - 1) % MOD)) % MOD;
	ll x = mypow(a, p / 2) % MOD;
	return (x * x) % MOD;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	unordered_map<int, int> superNum;
	rep(i, n){
		int num = a[i];
		for(int j = 2; (j * j) <= num; j++){
			int cnt = 0;
			while(num % j == 0){
				num /= j;
				cnt++;
			}
			if(cnt) superNum[j] = max(superNum[j], cnt);
		}
		if(num > 1) superNum[num] = max(superNum[num], 1);
	}
	ll ans = 0;
	rep(i, n){
		int num = a[i];
		ll cur = 1LL;
		for(int j = 2; (j * j) <= num; j++) if(num % j == 0){
			int cnt = 0;
			while(num % j == 0){
				num /= j;
				cnt++;
			}
			(cur *= mypow(j, superNum[j] - cnt)) %= MOD;
		}
		if(num > 1){
			(cur *= mypow(num, superNum[num] - 1)) %= MOD;
		}
		for(pi x : superNum){
			if(a[i] % x.fi != 0){
				(cur *= mypow(x.fi, x.se)) %= MOD;
			}
		}
		ans += cur;
	}
	cout << (ans % MOD) << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 768
#include<stdio.h>

int main(void){
   int set;
   int i;
   int r_sum,l_sum;
   
   for(;;){
      scanf("%d",&set);
      if(set == 0)
         break;
      
      int right[set],left[set];
      r_sum = 0;
      l_sum = 0;
      
      for(i=0;i<set;i++){
         scanf("%d%d",&right[i],&left[i]);
      }
      
      for(i=0;i<set;i++){
         if(right[i] > left[i])
            r_sum = r_sum + right[i] + left[i];
         
         else if(right[i] < left[i])
            l_sum = l_sum + right[i] + left[i];
         
         else if(right[i] == left[i]){
            r_sum = r_sum + right[i];
            l_sum = l_sum + left[i];
         }
      }
      printf("%d %d\n",r_sum,l_sum);
   }
   return 0;
}

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

int main() {
  char c;
  cin >> c;

  if (c == 'a' ||c == 'e' ||c == 'i' ||c == 'o' ||c == 'u'){
    string vowel = "vowel";
    cout << vowel << endl;
  } else {
    string consonant = "consonant";
    cout << consonant << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
A_list = list(map(int, input().split()))
B_list = [a - (i + 1) for i, a in enumerate(A_list)]
B_list.sort()
b = B_list[int(len(B_list) / 2)]
s = sum([abs(B - b) for B in B_list])
print(s)

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

int main() {
  int N;
  cin >> N;
  vector<pair<string, int>> restaurants(N), restaurants_copy(N);
  for (int i = 0; i < N; i++) {
    string S;
    int P;
    cin >> S >> P;
    restaurants.at(i).first = S;
    restaurants.at(i).second = 100 - P;
    restaurants_copy.at(i).first = S;
    restaurants_copy.at(i).second = P;
  }
  sort(restaurants.begin(), restaurants.end());
  for (int i = 0; i < N; i++) {
    restaurants.at(i).second = 100 - restaurants.at(i).second;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (restaurants.at(i) == restaurants_copy.at(j)) {
        cout << j + 1 << endl;
      }
    }
  }
}


Measured memory_bytes: 256