akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<vector>

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

using namespace std;

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

class union_find{
	vector<int> a;
public:
	union_find(int n):a(n,-1){}
	int find(int x){
		if(a[x]<0) return x;
		return a[x]=find(a[x]);
	}
	void unite(int x,int y){
		x=find(x),y=find(y);
		if(x!=y){ a[x]+=a[y]; a[y]=x; }
	}
};

int main(){
	int w,h; scanf("%d%d",&w,&h);
	static char B[1000][1001];
	int gx,gy;
	rep(i,h){
		scanf("%s",B[i]);
		rep(j,w) if(B[i][j]=='t') gx=j, gy=i;
	}

	union_find U(h*w);
	rep(i,h) rep(j,w) if(B[i][j]!='#') {
		rep(k,2){
			int y=i+dy[k],x=j+dx[k];
			if(0<=y && y<h && 0<=x && x<w && B[y][x]!='#') U.unite(i*w+j,y*w+x);
		}
	}
	if(U.find(0)==U.find(gy*w+gx)){ puts("0"); return 0; }

	int n; scanf("%d",&n);
	rep(t,n){
		int i,j; scanf("%d%d",&j,&i);
		B[i][j]='.';
		rep(k,4){
			int y=i+dy[k],x=j+dx[k];
			if(0<=y && y<h && 0<=x && x<w && B[y][x]!='#') U.unite(i*w+j,y*w+x);
		}
		if(U.find(0)==U.find(gy*w+gx)){ printf("%d\n",t+1); return 0; }
	}

	puts("-1");

	return 0;
}

Measured memory_bytes: 5664
#include <bits/stdc++.h>
using namespace std;
int n,m;
void solve()
{
    int i,j,k,l;
    vector < vector < char > > a(n);
    for (i=0;i<n;i++)
    {
        vector < char > tmp(m,'.');
        a[i]=tmp;
    }
    for (i=0;i<n;i++)
        for (j=0;j<m;j++)
            cin>>a[i][j];
    for (i=0;i<n;i++)
        for (j=0;j<m;j++)
            if (a[i][j]=='.'||a[i][j]=='_')
            {
                int tag=0;
                for (k=0;k<n;k++)
                    if (a[k][j]=='.'||a[k][j]=='_') ;
                    else {tag=1;break;}
                if (!tag)
                {
                    for (k=0;k<m;k++)
                        if (a[i][k]=='.'||a[i][k]=='_') ;
                        else {tag=1;break;}
                    if (!tag)
                    {
                        for (k=0;k<n;k++)
                            a[k][j]='_';
                        for (k=0;k<m;k++)
                            a[i][k]='_';
                    }
                }
            }
    for (i=0;i<n;i++)
    {
        int tag=0;
        for (j=0;j<m;j++)
            if (a[i][j]!='_') {tag=1;cout<<a[i][j];}
        if (tag) cout<<endl;
    }
}
int main()
{
    while(cin>>n>>m)
        solve();
}

Measured memory_bytes: 256
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
        string s = ReadLine();
        string t = ReadLine();

        int n = s.Length;
        int m = t.Length;

        string ans = "";

        int[,] dp = new int[n+1, m+1];

        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= m; j++)
            {
                if (s[i-1] == t[j-1])
                {
                    dp[i,j] = Math.Max(dp[i, j], dp[i-1, j-1] + 1);
                }
                dp[i, j] = Math.Max(dp[i, j], dp[i, j-1]);
                dp[i, j] = Math.Max(dp[i, j], dp[i-1, j]);
            }
        }

        while (n > 0 && m > 0)
        {
            if (dp[n,m] == dp[n-1,m]) n--;
            else if (dp[n,m] == dp[n,m-1]) m--;
            else
            {
                ans = s[n-1] + ans;
                n--; m--;
            }
        }

        WriteLine(ans);
    }
}

Measured memory_bytes: 50136
#include<iostream>
#include<iomanip>
using namespace std;
main()
{
	int N,K;
	cin>>N>>K;
	double ans=0;
	for(int i=1;i<=N;i++)
	{
		int t=(K+i-1)/i;
		double now=1;
		for(int j=1;j<t;j<<=1)
		{
			now*=.5;
		}
		ans+=now/N;
	}
	cout<<fixed<<setprecision(9)<<ans<<endl;
}


Measured memory_bytes: 256
w, h, n = map(int, input().split())
ans_list = [0,0,w,h]
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1 and ans_list[0]<x:
        ans_list[0] = x
    elif a == 2 and ans_list[2]>x:
        ans_list[2] = x
    elif a == 3 and ans_list[1]<y:
        ans_list[1] = y
    elif a == 4 and ans_list[3]>y:
        ans_list[3] = y
    ans = (ans_list[2]-ans_list[0])*(ans_list[3]-ans_list[1])
    if ans <= 0:
        print(0)
        exit()
print(ans)

Measured memory_bytes: 62756
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	ll n, a[100000], b[100000], c[100000], ans=0;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i] >> b[i];
		ans-=b[i];
		c[i]=a[i]+b[i];
	}
	sort(c, c+n);
	reverse(c, c+n);
	for(int i=0; i<n; i+=2){
		ans+=c[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2688
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigInteger N = BigInteger.valueOf(Long.parseLong(sc.next()));
        BigInteger A = BigInteger.valueOf(Long.parseLong(sc.next()));
        BigInteger B = BigInteger.valueOf(Long.parseLong(sc.next()));
        BigInteger num = N.divide(A.add(B));
        BigInteger rem = N.mod(A.add(B));
        if(A.compareTo(rem) == -1){
            System.out.println(num.multiply(A).add(A));
        }else{
            System.out.println(num.multiply(A).add(rem));
        }
    }
}

Measured memory_bytes: 22868
from collections import deque

N, K = map(int, input().split())
X = list(map(int, input().split()))

q = deque(X[:K])
for i in range(K, N):
    u = q.popleft()
    if u < X[i]:
        print("Yes")
    else:
        print("No")
    q.append(X[i])


Measured memory_bytes: 95508
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
double dp[301][301][301];
bool check[301][301][301] = {0};

double solve(int c1 , int c2 , int c3 , int n){
    if(c1<0||c2<0||c3<0)return 0;
    if(c1 == 0 && c2 == 0 && c3 == 0)return 0;
    if(check[c1][c2][c3] == 1)return dp[c1][c2][c3];
    check[c1][c2][c3] = 1;
    dp[c1][c2][c3] = 1 + ((double)c1*solve(c1-1,c2,c3,n))/n + ((double)c2*solve(c1+1,c2-1,c3,n))/n 
       + ((double)c3*solve(c1,c2+1,c3-1,n))/n ;
    dp[c1][c2][c3] = dp[c1][c2][c3]*n/(c1+c2+c3) ;
    return dp[c1][c2][c3];
}
int main() {
    int n;
    cin >> n ;
    int c1 = 0 , c2 = 0 , c3 = 0;
    int t = n ;
    while(t--){
        int a;
        cin >> a;
        if(a == 1)c1++;
        else if(a == 2)c2++;
        else if(a == 3)c3++;
    }
    cout<< fixed << setprecision(25) << solve(c1,c2,c3,n) << endl ;;
}


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

#define S (ll)1e6 + 10

const ll MOD = 1e9 + 7;

ll fact[S] = {1};
ll pow(ll a, ll b){return b ? (b & 1 ? a : 1) * pow(a * a % MOD, b / 2) % MOD : 1;}
ll dp[1001][1001];

int main(){
    for(ll i = 1; i < S; i++) fact[i] = i * fact[i - 1] % MOD;
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    dp[0][0] = 1;
    for(ll i = 1;; i++){
        ll k = A + i - 1;
        if(B < k) break;
        for(ll j = 0; j <= N; j++){
            dp[i][j] = dp[i - 1][j];
            for(ll l = C; l <= D; l++){
                if(j < k * l) break;
                dp[i][j] += (dp[i - 1][j - k * l] * fact[N - j + l * k] % MOD * pow(fact[N - j] * fact[l] % MOD * pow(fact[k], l) % MOD, MOD - 2)) % MOD;
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[B - A + 1][N] << endl;
    return 0;
}


Measured memory_bytes: 15872
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    solve();
	}
    }
    
    static void solve(){
	long n = kbd.nextInt();
	long ans = fact(n);
	System.out.println(ans);
    }

    static long fact(long n){
	if(n==1) return 1;
	return n*fact(n-1);
    }
}

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

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

  vector<int> a(n), b(n), c(n-1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n-1; i++) {
    cin >> c[i];
  }

  int ans = b[0];
  for (int i = 1; i < n; i++) {
    ans += b[i];
    if (a[i] == a[i-1] + 1){
      ans += c[a[i-1]-1];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e17;
const ll BIG = 1000000007;

int main(){

	vector <int> od[200000];
	vector <int> ev[200000];

	int N;
	cin >> N;

	int u, v, w;

	for (int i = 0; i < N-1; i++) {
		cin >> u >> v >> w;
		if (w % 2 == 1) { 
			od[u].push_back(v); od[v].push_back(u);
		}

		else {
			ev[u].push_back(v); ev[v].push_back(u);
		}
	}

	int col[200000] = {};

	col[1] = 1;


	stack<int> T; //探索する頂点リスト

	
	T.push(1);

	while (!T.empty()) {

		int i = T.top();

		T.pop();

		
		
		for (int j = 0; j < od[i].size(); j++) {
			if (col[od[i][j]] == 0) {
				col[od[i][j]] = col[i] % 2 +1 ;
				T.push(od[i][j]);
			}
		}

		for (int j = 0; j < ev[i].size(); j++) {
			if (col[ev[i][j]] == 0) {
				col[ev[i][j]] = col[i];
				T.push(ev[i][j]);
			}
		}

	}

	for (int i = 1; i <= N; i++) {
		cout << col[i] - 1 << endl;
	}



	system("PAUSE");
}

Measured memory_bytes: 15104
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int r[100010][2],fa[100010];
ll ans[100010],b[100010];
int find(int x)
{
	if(fa[x]==x)
	{
		return x;
	}
	return fa[x]=find(fa[x]);
}
int main()
{
	int i,j,k,n,m,x,y;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++)
	{
		scanf("%d%d",&r[i][0],&r[i][1]);
	}
	for(i=1;i<=n;i++)
	{
		fa[i]=i;
		b[i]=1;
	}
	ll sum=1ll*n*(n-1)/2;
	for(i=m-1;i>=0;i--)
	{
		ans[i]=sum;
		x=r[i][0];
		y=r[i][1];
		find(x);
		find(y);
		if(fa[x]==fa[y])
		{
			continue;
		}
		sum-=((b[fa[x]]+b[fa[y]])*(b[fa[x]]+b[fa[y]]-1)/2-b[fa[x]]*(b[fa[x]]-1)/2-b[fa[y]]*(b[fa[y]]-1)/2);
		b[fa[y]]+=b[fa[x]];
		fa[fa[x]]=fa[y];
	}
	for(i=0;i<m;i++)
	{
		printf("%lld\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 4096
package main

import (
        "fmt"
        "sort"
)


func main() {
        var s []int
        var n int
        for i := 0; i < 5; i++ {
                fmt.Scanf("%d", &n)
                s = append(s, n)
        }
        sort.Ints(s)
        for i:= 1; i <= len(s); i++ {
                fmt.Printf("%d", s[len(s)-i])
                if i < len(s) {
                        fmt.Printf(" ")
                }
        }
        fmt.Printf("\n")
}



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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 500005
#define all(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define rt return;
using namespace std;

void test_case(){
  
  int a, b, c, d; cin >> a >> b >> c >> d;
  int res = b * d;
  res = max(res, a * d);
  res = max(res, a * c);
  res = max(res, b * c);
  
  cout << res;
  
}

int32_t main(){
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int tt = 1; 
  //cin >> tt;
  while(tt--){
    test_case();
    cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include<queue>

using namespace std;

int n;
int u[10010], k[10010],  v[10010][10010];
int answer[10010][10010];

int D[10010];
void bfs(int src){
	//cerr << "bfs root = " << src << endl;
	queue<int> Q;
	Q.push(src);
	D[src] = 0;
	//int cnt = 0;
	while(! Q.empty()){
		int cur = Q.front();
		Q.pop();
		//cerr << "visiting " << cur << " " << D[cur] << endl;
		
		for(int dst = 0; dst < 1001; ++dst){
			if(answer[cur - 1][dst - 1] == 1 && D[dst] > 10000){
				D[dst] = D[cur] + 1; 
				Q.push(dst);
			}
		}

	}
	for(int i = 1; i  < n + 1; ++i ){
		if(D[i] < 10000){
			cout << i << " " <<  D[i] << endl;
		}else{
			cout << i << " " << -1 << endl;
		}
	}

	
}

int main(){
	cin >> n;
	for(int i = 0; i < 1001; ++i){
		for(int j = 0; j < 1001; ++j)
			answer[i][j] = 0;
	}
	for(int i = 0; i < 10010; ++i){
		D[i] = 10010;
	}

	
	
	for(int i = 0; i < n; ++i){
		cin >> u[i] >> k[i];
		for(int j = 0; j < k[i]; ++j){
			cin >> v[i][j];
			answer[u[i] - 1][v[i][j] - 1] = 1;
		} 
	}
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			//cout << answer[i][j] << " ";
		} 
		//cout << endl;
	}
	bfs(1);
}


Measured memory_bytes: 11464
#include<stdio.h>
#define PMAX 1000000000
int wmax=0;
int n,k,w[100000];
 
int check(int P){
    int i;
    int count=1,now=P;
    if(P<wmax) return 0;
    for(i=0;i<n;i++){
        if(now>=w[i]){
           now-=w[i];
        }else{
            count++;
            now=P-w[i];
        }
    }
    if(count>k) return 0;
    else return 1;
}
 
int main(void){
    int i;
    int left,right,mid;
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++){
        scanf("%d",&w[i]);
        if(w[i]>wmax) wmax=w[i];
    }
 
    left=0,right=PMAX;
    while(right-left>1){
        mid=(left+right)/2;
        if( check(mid) ) right=mid;
        else left=mid;
    }
    printf("%d\n",right);
    return 0;
}


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

int main(){
  int n,x,sum=0,result,y=10000;
  cin >> n >> x;
  vector<int> m(n+1,0);
  for(int i=0;i<n;i++)cin >> m.at(i);
  for(int i=0;i<n;i++)sum += m.at(i);
  for(int i=0;i<n;i++){
    if(y>m.at(i))y=m.at(i);
  }
  result = n+(x-sum)/y;
  cout << result << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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

uintmax_t combination(unsigned int n, unsigned int r)
{
    if (r * 2 > n)
        r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor = 1;
    for (unsigned int i = 1; i <= r; ++i)
    {
        dividend *= (n - i + 1);
        divisor *= i;
    }
    return dividend / divisor;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(15);
    string S;
    cin >> S;
    for (int i = 0; i < S.size();i+=2)
    {
        cout << S[i];
    }
    cout << endl;
}


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

int main(){
  long long int a,b,c,abc;
  cin>>a>>b>>c;
  abc=c-a-b;
  
  if(abc<0){cout<<"No"<<endl;return 0;}
  if(4*a*b<abc*abc){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}

  return 0;
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	private static Scanner sc;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		LinkedList<String> name=new LinkedList<String>();
		LinkedList<Integer> time=new LinkedList<Integer>();
		int n=sc.nextInt();
		int q=sc.nextInt();
		int t=0;
		for(int i=0;i<n;i++){
			name.add(sc.next());
			time.add(sc.nextInt());
		}
		while(!name.isEmpty()){
			if(time.peek()<=q){
				System.out.print(name.poll()+" ");
				t=t+time.poll();
				System.out.println(t);
			}else{
				name.add(name.poll());
				time.add(time.poll()-q);
				t=t+q;
			}
		}
	}

}

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

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

ll N;
P A[500005];
vector<ll> dif;

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

	cin >> N;

	for (int i = 1;i <= N;i++){
		cin >> A[i].first >> A[i].second;
	}

	sort(A+1,A+N+1);

	A[0].first = A[1].first;

	for (int i = 1;i <= N;i++){
		dif.push_back(A[i].second-(A[i].first-A[i-1].first));
	}

	ll sum = 0;
	ll ans = -1;

	for (int i = 0;i < dif.size();i++){
		sum += dif[i];
		sum = max(sum,A[i+1].second);
		ans = max(ans,sum);
	}

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 14912
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
    int n,k,i,sum=0;cin>>n>>k;
    vector<int>v(n);
    fo(i,0,n)cin>>v[i];
    sort(all(v));
    for(i=0;i<min(n,k);i++)sum+=v[i];
    cout<<sum<<"\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//If wrong on pretest 2 means logically wrong


/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 3660
n, y = map(int, input().split())

summ = 0
flag = 0
for a in range(n+1):
    for b in range(n+1-a):
        if (10000 * a + 5000 * b + 1000 * (n-a-b)) == y:
            print(a, b, n-a-b)
            flag = 1
            break
    if flag == 1:
        break
if flag == 0:
    print("-1 -1 -1") 

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
//#define endl '\n'  
typedef long long ll; 
typedef unsigned long long ull; 
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=2019;
const ll inf=1e15+5;
const ll N=1e5+10;

int main()
{
	boost;
	ll n;
	cin>>n;
	std::vector<ll> a(n);
	ll sum=0;
	for(auto &i:a) cin>>i,sum+=i,i*=2;
	ll ans[n];
	ll curr=sum;
	for(ll i=2;i<n;i+=2) curr-=a[i];
	ans[0]=curr;	
	for(ll i=1;i<n;i++)
	{
		ans[i]=a[i]-curr;
		curr=ans[i];
	}	
	cout<<ans[n-1]<<" ";
	for(ll i=0;(i+1)<n;i++) cout<<ans[i]<<" ";
	

	return 0;
} 


Measured memory_bytes: 2944
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys
import itertools

import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K, X, Y = map(int, read().split())

print(N * X if N <= K else K * X + (N - K) * Y)


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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1e9
using namespace std;
typedef long long ll;

int d,n;

int main(){
  cin >>  d  >> n;
  vector <ll> v;
  rep(i,1,100){
    v.push_back(i*pow(100,d));
  }
  v.push_back(101*pow(100,d));
  std::cout << v[n-1] << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n,m;
    cin>>n>>m;
    int ans=0;
    REP(i,n){
        int a;
        cin>>a;
        ans+=min(a*2,(m-a)*2);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    string s; cin >> s;
    bool a[26];
    rep(i,26) a[i]=false;
    for(int i=0; s[i] != '\0'; ++i){
        a[s[i]-'a'] = true;
    }
    rep(i,26){
        if(!a[i]){
            cout << (char)(i+'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
import sys


if __name__ == '__main__':
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(2)]

    answer = - sys.maxsize
    for i in range(N):
        xi = 0
        yi = 0
        sum_candies = A[0][0]
        for j in range(N):
            if i == j:
                yi += 1
            else:
                xi += 1
            sum_candies += A[yi][xi]
        answer = max(answer, sum_candies)
    print(answer)

Measured memory_bytes: 3064
import numpy as np
def f(lst):
    return np.cumsum(lst)

n = int(input())
s = input()

res1 = s.count('.')
res2 = s.count('#')

a = [0]*n
b = [0]*n

for i in range(n):
    if s[i]=='.':
        a[i] += 1
    else:
        b[i] += 1
cum_a = f(a).tolist()
cum_b = f(b).tolist()
res3 = np.inf
for i in range(n):
    if a[i]==1:
        res3 = min(res3, cum_b[i]+(res1-cum_a[i]))

print(min(res1, res2, res3))

Measured memory_bytes: 33072
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S;
    cin >> S;

    if(S[0] == 'S')
        cout << "Cloudy" << endl;
    else if(S[0] == 'C')
        cout << "Rainy" << endl;
    else
        cout << "Sunny" << endl;

}

Measured memory_bytes: 256
import java.util.*;

 class Main
 {
   public static void main(String args[])
   { 
    comp();
   }
   static  void  comp()
   {
     Scanner sc = new Scanner(System.in);
     
     int a = sc.nextInt();
     
     int b = sc.nextInt();
     
     if (a < b)System.out.println("a < b");
     
     else if(a > b)System.out.println("a > b");
     
     else System.out.println("a == b");
   }
 }
    


Measured memory_bytes: 26336
n = gets.to_i
s = gets.chars
min = 1e6
left = Array.new(n+1,0)
right = Array.new(n+1,0)
(2..n).each do |i|
  if s[i-2] == "W"
    left[i] = left[i-1] + 1
  else
    left[i] = left[i-1]
  end
end
(1..n-1).reverse_each do |i|
  if s[i] == "E"
    right[i] = right[i+1] + 1
  else
    right[i] = right[i+1]
  end
end
(1..n).each do |i|
  sum = left[i] + right[i]
  min = sum if min > sum
end
p min


Measured memory_bytes: 34316
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int low=INF;
    int high=0;
    rep(i,n){
      int a,b,c,d,e;
      cin>>a>>b>>c>>d>>e;
      low=min(low,a+b+c+d+e);
      high=max(high,a+b+c+d+e);
    }
    cout<<high<<" "<<low<<endl;
  }
}

Measured memory_bytes: 2992
#include <iostream>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>

long long gcd(long long x, long long y)
{
	return y ? gcd(y, x % y) : x;
}

std::vector<std::pair<long long, long long>> factorize(long long n)
{
	std::vector<std::pair<long long, long long>> ans;
	for (long long i = 2; i * i <= n; ++i)
	{
		if (n % i != 0) continue;
		ans.emplace_back(i, 0);
		
		while (n % i == 0)
		{
			n /= i;
			ans.back().second++;
		}
	}
	if (n != 1)
	{
		ans.emplace_back(n, 1);
	}

	return ans;
}

int main()
{
	long long A, B;
	std::cin >> A >> B;

	long long g = gcd(A, B);
	auto f = factorize(g);

	std::cout << f.size() + 1;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
X = input()
popcount_X = X.count('1')
numX = int(X, 2)
a = numX % (popcount_X + 1)
b = numX % (popcount_X - 1) if popcount_X != 1 else 0
for i, x in enumerate(X, 1): #リストのインデクス，要素，第二引数に開始位置
    if x == '1' and popcount_X == 1:
        print(0)
        continue
    ans = 1
    if x == '1':
        temp = (b - pow(2, N - i, popcount_X - 1)) % (popcount_X - 1)
    else:
        temp = (a + pow(2, N - i, popcount_X + 1)) % (popcount_X + 1)
    while temp:
        p = format(temp, 'b').count('1') #2進数，1の個数
        temp %= p
        ans += 1
    print(ans)

Measured memory_bytes: 9468
import math
import heapq
import sys
from collections import Counter
import numpy as np
import datetime
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

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

N=int(input())
n=[]
n.append(int(input()))
n.append(int(input()))
n.append(int(input()))
n.append(int(input()))
n.append(int(input()))

print(4+math.ceil(N/min(n)))

Measured memory_bytes: 13500
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  auto S = readln.chomp;

  string solve(string input) {
    foreach(c; ['a','b','c']) {
      if (!input.canFind(c)) return "No";
    }
    return "Yes";
  }

  solve(S).writeln;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin >> n;
    vector<int> x(n);
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    int ans=1e9;
    for(int i=1;i<=100;i++){
        int sum=0;
        for(int j=0;j<n;j++){
            sum+=(x[j]-i)*(x[j]-i);
        }
        ans=min(ans,sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
int d[510][510];
bool ok[510][510];
int main(){
    int m;
    cin >> m;
    int n = m*m;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    int L = 1;
    int R = m;
    while(L<=R){
        for(int i=L;i<=R;i++){
            for(int j=L;j<=R;j++){
                d[i][j]++;
                ok[i][j] = 1;
            }
        }
        L++;
        R--;
    }
    ll res = 0;
    rep(i,n){
        int x = a[i]/m+1;
        int y = a[i]%m+1;
        res += d[x][y]-1;
        d[x][y]--;
        ok[x][y] = 0;
        queue<pair<int,int> > q;
        q.push(MP(x,y));
        while(!q.empty()){
            auto z = q.front();
            q.pop();
            int zx = z.first;
            int zy = z.second;
            if(d[zx+1][zy] > d[zx][zy]+ok[zx+1][zy]){
                d[zx+1][zy] = d[zx][zy]+ok[zx+1][zy];
                q.push(MP(zx+1,zy));
            }
            
            if(d[zx-1][zy] > d[zx][zy]+ok[zx-1][zy]){
                d[zx-1][zy] = d[zx][zy]+ok[zx-1][zy];
                q.push(MP(zx-1,zy));
            }
            
            if(d[zx][zy+1] > d[zx][zy]+ok[zx][zy+1]){
                d[zx][zy+1] = d[zx][zy]+ok[zx][zy+1];
                q.push(MP(zx,zy+1));
            }
            
            if(d[zx][zy-1] > d[zx][zy]+ok[zx][zy-1]){
                d[zx][zy-1] = d[zx][zy]+ok[zx][zy-1];
                q.push(MP(zx,zy-1));
            }
        }
        // for(int i=0;i<=m+1;i++){
        //     for(int j=0;j<=m+1;j++){
        //         cout << d[i][j] << " ";
        //     }
        //     cout << "\n";
        // }
        // cout << "\n";
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5068
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,b,i,j,k,l=0,m=0;
  cin>>n;
  vector<long long>v;
  for(i=0;i<n;i++)
  {
cin>>b;
    v.push_back(b);
  }
  for(i=0;i<n-1;i++)
  {
if(v[i]>=v[i+1])
{
l++;
}
    else if(l>m)
    {
m=l;l=0;}
    else
      l=0;
    
  }
  if(m<=l)
    cout<<l;
  else
    cout<<m;
}

Measured memory_bytes: 1400
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long
 
#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)
 
#define sl          cout<<' '
#define ps          printf(" ")
 
#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))
 
#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup     erase(unique(V.begin(),V.end()),V.end())
 
#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound
 
#define ALL(V)  V.begin(),V.end()
 
#define MX1     100000LL
#define MX2     1000000LL
#define Inf     1000000000000000LL
#define mod		1000000007LL
using namespace std;
 
lli Power(lli a,lli b)
{
    lli result=1;
 
    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }
 
        b=b>>1;
        a=(a*a)%mod;
    }
 
 return result;
}
 
int main()
{
    //opt;
 
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
 
    int N,i,Q;
    scanf("%d %d",&N,&Q);
 
    while(Q--)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        
        if(N==1)
        {
            printf("%d\n",min(a,b));
            continue;
        }

        while(a != b)
        {
            if(a>b)
            {
                a=(a+N-2)/N;
            }
            else
            {
                b=(b+N-2)/N;
            }
        }
 
        printf("%d\n",a);
    }
 
 
 
 
 
 
 
 return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#define rep(i,beg,end) for(int i=(beg);i<(end);i++)
typedef long long LL;
using namespace std;

int n;
double dp[3001][3001];
int main(){
	cin>>n;
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		double tmp;
		cin>>tmp;
		dp[i][0]=dp[i-1][0]*(1-tmp);
		for(int j=1;j<=n;j++){
			dp[i][j]=dp[i-1][j-1]*tmp;
			dp[i][j]+=dp[i-1][j]*(1-tmp);
			
		}
	}
	double ans=0;
	for(int i=n/2+(n%2);i<=n;i++){
		ans+=dp[n][i];
	}
	cout<<std::fixed<<setprecision(10)<<ans<<endl;
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  vector<vector<int>> vec(10, vector<int>(10));
  for(int i=1; i<N+1; ++i){
    if(i<10) ++vec.at(i).at(i);
    else if(i<100) ++vec.at(i/10).at(i%10);
    else if(i<1000) ++vec.at(i/100).at(i%10);
    else if(i<10000) ++vec.at(i/1000).at(i%10);
    else if(i<100000) ++vec.at(i/10000).at(i%10);
    else  ++vec.at(i/100000).at(i%10);
  }
  int ans=0;
  for(int i=0; i<10; ++i){
    int x=0;
    for(int j=0; j<10; ++j){
      x += vec.at(i).at(j) * vec.at(j).at(i);
      //cout << vec.at(i).at(j);
    }
    //cout << endl;
    ans += x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    double sum=0;
    for (int i=0; i<n; i++){
        cin >>a[i];
        sum+=a[i];
    }
    int x=0,y=0;
    int ave1=sum/n;
    int ave2=ceil(sum/n);
    for (int i=0; i<n; i++){
        x+=(a[i]-ave1)*(a[i]-ave1);
        y+=(a[i]-ave2)*(a[i]-ave2);
    }
    cout <<min(x,y)<<endl;
}

        
    

Measured memory_bytes: 256
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    # 
    a,b,h,m = map(int,input().strip().split())
    theta = abs(m * Fraction(1,60) * 2 * math.pi) - (2*math.pi * (Fraction(h,12)+Fraction(m,720)))
    c=math.sqrt(a**2 + b**2 - 2*a*b*math.cos(theta))
    print(c)


if __name__ == '__main__':
    main()

Measured memory_bytes: 78456
import copy
def main():
    n = int(input())
    h  = list(map(int, input().split()))
    
    tmp = 0
    max_len = 0

    for i in range(n-1):
        if h[i] >= h[i+1]:
            tmp += 1
        else:
            if tmp > max_len:
                max_len = copy.deepcopy(tmp)
            tmp = 0

    if tmp > max_len:
        max_len = copy.deepcopy(tmp)
        
    print(max_len)

    
    
if __name__ == '__main__':
    main()



Measured memory_bytes: 14784
#include <iostream>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;


int main() {
    int n;
    cin >> n;
    int a[n];
    REP(i, n) {
        cin >> a[i];
    }
    int sum = 0;
    sort(a, a+ n, [](const int & a, const int& b) {return b < a;});
    REP(i, n) {
        sum += (i %2 == 0) ? a[i] : -a[i];
    }
    cout << sum << endl;
}

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

using namespace std;

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N);
  vector<int> y(M);
  int x_max = X;
  int y_min = Y;
  for (int i = 0; i < N; i++) {
    cin >> x[i];
    x_max = max(x_max, x[i]);
  }
  for (int i = 0; i < M; i++) {
    cin >> y[i];
    y_min = min(y_min, y[i]);
  }
  if (x_max < y_min) {
    cout << "No War" << endl;
  } else {
    cout << "War" << endl;
  }
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (a); i > (b); i--)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

void solve() {
  string S;
  in(S);
  vi ans(S.length());
  int cnt = 0;
  rep(i, 0, (int)S.length() - 1) {
    if (S[i] == 'L') {
      cnt = 0;
      continue;
    }
    cnt++;
    if (S[i + 1] == 'L') {
      ans[i] += ((cnt - 1) / 2) + 1;
      ans[i + 1] += (cnt / 2);
    }
  }
  cnt = 0;
  rrep(i, (int)S.length() - 1, 0) {
    if (S[i] == 'R') {
      cnt = 0;
      continue;
    }
    cnt++;
    if (S[i - 1] == 'R') {
      ans[i] += ((cnt - 1) / 2) + 1;
      ans[i - 1] += (cnt / 2);
    }
  }

  each(x, ans) {
    cout << x << ' ';
  }
}


Measured memory_bytes: 1104
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    string S;
    cin >> S;
    REP(int,i,0,S.size()){
        cout << "x";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int t){
    if(t==0)return s;
    return gcd(t,s%t);
}
signed main(){
    int n,m;
    cin>>n>>m;
    int s,p,r;
    cin>>s>>p>>r;
    string t;
    int ans=0;
    cin>>t;
    rep(i,n-m){
        if(t[i]==t[i+m]){
            t[i+m]='1';
        }
        
    }
    rep(i,n){
        if(t[i]=='r'){
            ans+=r;
        }
        else if(t[i]=='s'){
            ans+=s;
        }
        else if(t[i]=='p'){
            ans+=p;
        }
    }
    cout<<ans<<endl;
}


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

int main()
{
    string s;
    cin >> s;
    int al[26] = {};
    for(int i=0;i<s.size();i++){
        int tmp = int(s[i]-'a');
        if(al[tmp] == 0) al[tmp] = 1;
    }
    int ans = -1;
    for(int t=0;t<26;t++){
        if(!al[t]) {
            ans = t;
            break;
        }
    }
    if(ans != -1) cout << char(ans+'a') << endl;
    else cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  vector<int> a(5);
  rep(i,5)
    cin>>a[i];
  int b=0;
  rep(i,5){
  if(a[i]==0)
    b=i+1;
  }
  out(b);
}

Measured memory_bytes: 3596
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7

s=input()
n=len(s)+1
ans=[0]*n
for i in range(n-1):
    if s[i]=='<':
        ans[i+1]=max(ans[i+1],ans[i]+1)
for i in range(n-2,-1,-1):
    if s[i]=='>':
        ans[i]=max(ans[i+1]+1,ans[i])
print(sum(ans))


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	4 * MAX5;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll t = 1;
ll n, x, k, q, m, y, r, l, c, a;
string s;

const int N = 2e4 + 10;

ll covered[N], dp[N], umbrella[N], cost[N];

// <------------- Implement Functions Here ----------> //

  

// <------------- Start of main() -------------------> //

void MAIN() {
	ll a,b,c;
	cin>>a>>b>>c;
	c -= (a-b);
	cout<<max(0ll,c);
}

int main() {
	fastio; randomINT;
	//cin >> t;
	while (t--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 12948
n = int(input())
k = 1
t = 0
while t < n:
    t += k
    k += 1

if t != n:
    print("No")
    exit(0)

print("Yes")
print(k)

a = [[] for _ in range(k)]
val = 1
for i in range(k-1):
    for j in range(i+1,k):
        a[i].append(val)
        a[j].append(val)
        val += 1

for aa in a:
    print(*([len(aa)] + aa))





Measured memory_bytes: 13924
Scanf.scanf "%d" (fun k ->
    let digits a =
        let rec loop i acc =
            if i = 0 then acc else loop (i / 10) ((i mod 10) :: acc)
        in
        loop a []
    in
    let count r =
        let rec loop prev edge inner = function
            | [] -> Array.fold_left (+) 0 inner + if edge then 1 else 0
            | hd :: tl -> (
                let newinner = Array.make 10 0 in
                for i = 0 to 9 do
                    if i > 0 then newinner.(i - 1) <- newinner.(i - 1) + inner.(i);
                    if i < 9 then newinner.(i + 1) <- newinner.(i + 1) + inner.(i);
                    newinner.(i) <- newinner.(i) + inner.(i);
                    if i > 0 then newinner.(i) <- newinner.(i) + 1;
                done;
                if edge && prev > 0 && prev - 1 < hd then newinner.(prev - 1) <- newinner.(prev - 1) + 1;
                if edge &&             prev     < hd then newinner.(prev)     <- newinner.(prev)     + 1;
                if edge && prev < 9 && prev + 1 < hd then newinner.(prev + 1) <- newinner.(prev + 1) + 1;
                let edge = edge && abs (hd - prev) <= 1 in
                loop hd edge newinner tl
            )
        in
        match digits r with
        | [] -> 0
        | hd :: tl -> (
            let inner = Array.make 10 0 in
            for i = 1 to hd - 1 do
                inner.(i) <- 1;
            done;
            loop hd true inner tl
        )
    in
    let rec bin left right =
        if left = right then left else
            let m = (left + right) / 2 in
            if count m < k then bin (m + 1) right
                           else bin left m
    in
    bin 1 3234566668 |> Printf.printf "%d\n"
)

Measured memory_bytes: 2432
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
 
const int inf=1<<28;

vector<int> weight;
int floors[10010];

int sum[1<<15];
int dp[1<<15];
 
int main(){
    int n,m,limit;
    cin >> n >> m >> limit;
    
    rep(i,n){
        int k;
        cin >> k;
        floors[i]=0;
        rep(j,k){
            int w;
            cin >> w;
            floors[i]|=(1<<int(weight.size()));
            weight.push_back(w);
        }
    }

    int k=weight.size();
    const int all=(1<<k)-1;
 
    if(floors[0]==all){
        puts("0");
        return 0;
    }
    
    rep(mask,1<<k) dp[mask]=inf;
    rep(mask,1<<k)rep(i,k)if(mask&(1<<i)) sum[mask]+=weight[i];
    
    dp[0]=0;
    rep(mask,1,1<<k){
        for(int smask=mask;smask>0;smask=(smask-1)&mask){
            int tmask=mask^smask;
            if(sum[smask]<=limit) chmin(dp[mask],dp[tmask]+1); 
        }
    }

    int ans=0,cmax=m;
    rep(i,n) if(floors[i]!=0) chmax(cmax,i+1);
    
    ans+=cmax-m;
    rrep(i,cmax,1){
        ans+=2*dp[floors[i]]-1,floors[i-1]|=floors[i];
    }
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 3424