akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 
//なんかむずいんだけどw
signed main(){
	int a,b;cin>>a>>b;
	if(a>8 || b>8) cout<<":("<<endl;
	else cout<<"Yay!"<<endl;
	
	return 0;
}

Measured memory_bytes: 3620
N = int(input())
A = list(map(int, input().split(' ')))
sorted_A = sorted(A)
before = -1
pair = []
for a in sorted_A[::-1]:
    if a != before:
        before = a
    elif a == before:
        pair.append(a)
        if len(pair) == 2:
            break
        before = -1
ans = 0
if len(pair) == 2:
    ans = pair[0]*pair[1]
print(ans)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define EPS (1e-7)
#define INF 1000000009
#define PI (acos(-1))
typedef long long ll;

ll n,a,b;

int main(){
    cin >> n >> a >> b;
    ll full_count = n/(a+b);
    ll rest = min(n % (a+b),a);
    cout << (full_count * a + rest) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
const ll inf=(1e18);
const ll mod=1000000007;
int n,m;
vector<int> v,w;
int main(){
    int n,m;
vector<int> v(n),w(n);
cin>>n>>m;
vector<vector<int>> dp(110,vector<int>(10100,0));
for(int i=0;i<n;i++)cin>>v.at(i)>>w.at(i);
for(int i=n-1;i>=0;i--){
    for(int j=0;j<=m;j++){
        if(j<w.at(i)){
            dp.at(i).at(j)=dp.at(i+1).at(j);
        }
        else {
            dp.at(i).at(j)=max(dp.at(i+1).at(j),dp.at(i+1).at(j-w.at(i))+v.at(i));
        }
    }
}
cout<<dp.at(0).at(m)<<endl;
}





Measured memory_bytes: 7616
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long s, c;
  cin >> s >> c;
  long long ans = 0;
  while (c >= 4 || s >= 1 && c >= 2) {
    long long scc = min(s, c / 2);
    ans += scc;
    s -= scc;
    c -= scc * 2;
    long long makes = c / 4;
    s += makes;
    c -= makes * 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a[10]={1,3,5,7,8,10,12};
    int b[10]={4,6,9,11};
    int c[10]={2},x,y,i,count=0,count2=0;
    scanf("%d %d",&x,&y);
    if(x,y>=1&&x,y<=12){
        for(i=0;i<7;i++){
            if(a[i]==x|a[i]==y){
                count++;
            }
        }
        for(i=0;i<4;i++){
            if(b[i]==x|b[i]==y){
                count2++;
            }
        }
        if(count==2|count2==2){
            printf("Yes");
        }
        else{
            printf("No");
        }
    }
    return 0;
}

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

int main() {
    long long N;
    cin >> N;
    long long sum=0;
    for (long long i=1; i<=N; i++){
        if (i%3!=0 && i%5!=0) sum+=i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			String s = sc.next();
			String t = sc.next();
			StringBuilder result = new StringBuilder();

			for (int i = 0; i < n; i++) {
				result.append(s.charAt(i));
				result.append(t.charAt(i));
			}
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 21716
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    ll N;
    ll ans=0, Y;

    cin >> N;

    for(int j=1; j<=N; j++) {
        Y = N/j;
        ans += Y*(Y+1)*j/2;
    }

    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;


int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	double r; cin>>r;
	cout<<setprecision(10)<<fixed<<2*2*acos(0)*r<<endl;
	return 0;
}

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

#define vi vector<int>
#define ii pair<int,int>
#define vii vector<pair<int,int>>

typedef long long ll;
typedef unsigned long long ull;

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

using namespace std;

string s,t;
map<char, char> m;
bool mapped[256];

int main (void) {
    ios_base::sync_with_stdio(false);

    cin >> s >> t;
    int length = s.length();
    for (int i = 0; i < length; i++) {
        if (m.count(s[i]) == 0) {
            m[s[i]] = t[i];
            if (mapped[t[i]]) {
                cout << "No" << endl;
                return 0;
            }
            mapped[t[i]] = true;
        } else {
            if (t[i] != m[s[i]]) {
                cout << "No" << endl;
                return 0;
            }
        }
//        printf("%c %c %c\n", s[i], t[i], m[s[i]]);
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 916
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	int a,b;
	cin>>a>>b;
	while (b--){
		int y;
		cin>>y;
		a-=y;
	}
	if (a<0)  a=-1;
	cout<<a;
	re 0;
}

Measured memory_bytes: 3632
def main():
    n, *a = map(int, open(0).read().split())

    c = 1
    f = 0
    d = {True: 1, False: -1}
    for i, j in zip(a, a[1:]):
      if i == j:
        continue
      else:
        g = d[i < j]
        if f * g == -1:
          f = 0
          c += 1
        else:
          f = g
    
    print(c)


if __name__ == '__main__':
    main()


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

int main(){
    long long  n, k;
    cin >> n >> k;
    vector<long long> h(n);
    for(int i = 0; i< n; i++) cin >> h[i];

    int ans = 0;
    for(int i = 0; i< n; i++){
        if(h[i] >= k) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3868
def water(h):
    if len(h) == 0:
        #print("A0")
        return  0
    
    elif len(h) == 1:
        #print("A1")
        return h[0]
    
    elif R0(h) + 1:
        #print("B")
        #print(h[0: R0(h)],h[R0(h): len(h)])
        return water(h[0: R0(h)]) + water(h[R0(h) + 1: len(h)])
    
    else:
        #print("C")
        for i in range(len(h)):
            h[i] -= 1
        #print(h)
        return water(h) + 1

def R0(l):
    if 0 in l:
        return l.index(0)
    else:
        return -1

N = int(input())
h = [int(i) for i in input().split()]

print(water(h))

Measured memory_bytes: 3188
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
#define N 100005
#define ll long long
int t,n;
ll a[N];
struct node
{
	ll x;
	int k;
}b[5];
int main()
{
	//freopen("circle.in","r",stdin);
    //freopen("circle.out","w",stdout);
    //scanf("%d",&t);
    //while(t--)
    //{
    	int r=0;
    	scanf("%d",&n);
    	for(int i=1;i<=n;i++)
    		scanf("%lld",&a[i]),r^=a[i];
    	if(r!=0)
    	{
    		printf("No\n");
    		return 0;//continue;
		}
		sort(a+1,a+n+1);
		int cnt=0,f=0;
		a[0]=-1;
		for(int i=1;i<=n;i++)
			if(a[i]!=a[i-1])
			{
				b[++cnt].x=a[i];
				b[cnt].k=1;
				if(cnt>3)
				{
					printf("No\n");
					f=1;
					break;
				}
			}
			else b[cnt].k++;
		if(!f)
		{
			if(cnt==1)
			{
				if(b[1].x==0)printf("Yes\n");
				else printf("No\n");
			}
			else if(cnt==2)
			{
				/*if(b[1].k==b[2].k)
				{
					if(b[1].x==b[2].x^b[2].x&&b[2].x==b[1].x^b[1].x)
						printf("Yes\n"),f=1;
				}
				if(!f&&b[1].k>1&&b[1].k%2==0)
				{
					if(b[1].k/2==b[2].k&&b[1].x==b[1].x^b[2].x&&b[2].x==b[1].x^b[1].x)
						printf("Yes\n"),f=1;
				}
				if(!f&&b[2].k>1&&b[2].k%2==0)
				{
					if(b[2].k/2==b[1].k&&b[2].x==b[2].x^b[1].x&&b[1].x==b[2].x^b[2].x)
						printf("Yes\n"),f=1;
				}*/
				if(b[1].x==0&&b[1].k*2==b[2].k)printf("Yes\n");
				else printf("No\n");
			}
			else
			{
				if(b[1].k==b[2].k&&b[2].k==b[3].k)
				{
					if(b[1].x^b[3].x^b[2].x==0)
						printf("Yes\n");
					else printf("No\n");
				}
			}
		}
	//}
}

Measured memory_bytes: 896
//
//  main.cpp
//  ProblemSolving
//
//  Created by Mac mini on 1/7/20.
//  Copyright © 2020 Mac mini. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <cstring>
using namespace std;

int main() {
	stack<char> A, B, C;
	string a, b, c;
	
	cin >> a >> b >> c;
	
	for(int i = a.size() - 1; i >= 0; i--) A.push(a[i]);
	for(int i = b.size() - 1; i >= 0; i--) B.push(b[i]);
	for(int i = c.size() - 1; i >= 0; i--) C.push(c[i]);
	
	int nextMove = 1;
	
	while(1) {
		char x;
		if(nextMove == 1) {
			if(A.empty()) {
				return cout << "A", 0;
			}
			x = A.top(); A.pop();
			nextMove = x == 'a' ? 1 : (x == 'b' ? 2 : 3);
		} else if (nextMove == 2) {
			if(B.empty()) {
				return cout << "B", 0;
			}
			x = B.top(); B.pop();
			nextMove = x == 'a' ? 1 : (x == 'b' ? 2 : 3);
		} else {
			if(C.empty()) {
				return cout << "C", 0;
			}
			x = C.top(); C.pop();
			nextMove = x == 'a' ? 1 : (x == 'b' ? 2 : 3);
		}
	}
}


Measured memory_bytes: 3548
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

constexpr int P = 1000000007;

vector<int> balls[200001];
int minWeight[200001], connected[200001];
int inv[200001], fac[200001], invFac[200001];

int main() {
	int n, x, y;

	cin >> n >> x >> y;
	memset(minWeight, 0x3f, sizeof minWeight);
	for (int i = 1; i <= n; ++i) {
		int c, w;
		cin >> c >> w;
		balls[c].push_back(w);
		minWeight[c] = min(minWeight[c], w);
	}

	int m1 = 0, m2 = 0;
	for (int i = 1; i <= n; ++i)
		if (minWeight[i] < minWeight[m1]) {
			m2 = m1;
			m1 = i;
		} else if (minWeight[i] < minWeight[m2]) {
			m2 = i;
		}

	int sum = 0;
	for (int i = 1; i <= n; ++i) {
		int cx = 0, cy = 0;
		for (int o: balls[i]) {
			if (minWeight[i] + o <= x) ++cx;
			if ((i != m1 && minWeight[m1] + o <= y) || minWeight[m2] + o <= y) ++cy;
		}
		connected[i] = cy != 0 ? max(cx, cy) : 0;
		sum += connected[i];
	}

	inv[1] = 1;
	for (int i = 2; i <= n; ++i)
		inv[i] = static_cast<long long>(P - P / i) * inv[P % i] % P;
	
	fac[0] = invFac[0] = 1;
	for (int i = 1; i <= n; ++i) {
		fac[i] = static_cast<long long>(fac[i - 1]) * i % P;
		invFac[i] = static_cast<long long>(invFac[i - 1]) * inv[i] % P;
	}

	int ans = fac[sum];
	for (int i = 1; i <= n; ++i)
		ans = static_cast<long long>(ans) * invFac[connected[i]] % P;
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 13184
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    ans = []
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            m = n if n & 1 else n + 1
            if i + j != m:
                ans.append((i, j))
    print(len(ans))
    for i, j in ans:
        print(i, j)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
if N == K:
    print(1)
elif (N-1)%(K-1) == 0:
    print((N-1)//(K-1))
elif K == 2:
    print(N-1)
else:
    ans = ceil(N/(K-1))
    print(ans)


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int h,w;
string s[55];
map<char,bool> able;

bool check(char c){
	int mini=INF,minj=INF,maxi=-1,maxj=-1;
	rep(i,h)rep(j,w){
		if(s[i][j]==c){
			minch(mini,i);
			minch(minj,j);
			maxch(maxi,i);
			maxch(maxj,j);
		}
	}
	repl(i,mini,maxi+1)repl(j,minj,maxj+1){
		if(s[i][j]=='.'||!able[s[i][j]])return false;
	}
	return true;
}

int main(){
	cin.sync_with_stdio(false);
	int cases;
	cin>>cases;
	while(cases--){
		cin>>h>>w;
		rep(i,h)cin>>s[i];
		vector<char> cs;
		rep(i,h)rep(j,w){
			if(s[i][j]!='.'&&(cs.size()==0||!exist(cs,s[i][j])))cs.pb(s[i][j]);
		}
		if(cs.size()==0){
			cout<<"SAFE"<<endl;
			continue;
		}
		sort(all(cs));
		bool ok;
		do{
			ok=true;
			rep(i,cs.size())able[cs[i]]=false;
			able[cs[0]]=true;
			rep(i,cs.size()){
				if(!check(cs[i])){
					ok=false;break;
				}
				if(i<cs.size()-1)able[cs[i+1]]=true;
			}
			if(ok)break;
		}while(next_permutation(all(cs)));
		if(ok)cout<<"SAFE"<<endl;
		else cout<<"SUSPICIOUS"<<endl;
	}
	return 0;
}

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

ll n;

inline ll rd()
{
	ll x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

int main()
{
	n=rd();
	ll ans=0;
	for (ll i=1,j;i<=n;i=j+1)
	{
		j=n/(n/i);
		ll hh=n/i;
		ll res=n-hh;
		if (res%hh!=0) continue;res/=hh;
		if (res>=i&&res<=j) ans+=res;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int K = sc.nextInt();
		// 文字列の入力
		String S = sc.next();
      	String output = "";
      for(int i = 0; i < S.length(); i++) {
        if (i == K - 1) {
          output += String.valueOf(S.charAt(i)).toLowerCase();
        } else {
          output += S.charAt(i);
        }
      }
      System.out.println(output);
	}
}

Measured memory_bytes: 22868
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    A, B = inputIntList()
    ans = 0
    step = max(A, B)
    another = min(A, B)
    for i in range(step, A * B+1, step):
        if i % another == 0:
            ans = i
            break
    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define lf long double
#define F first
#define S second
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <pair <ll,ll> >vii;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
#define mod 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c;
    cin>>a>>b>>c;
    ll left=a-b;
    ll filled=min(left,c);
    c-=filled;
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int A, B;
scanf("%d%d", &A, &B);
if(A>B){
printf("%d",2*A-1);
}else if(A==B){
printf("%d",2*B);
}else{
printf("%d",2*B-1);
}
return 0;
}

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

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

    int h, w;
    cin >> h >> w;

    char s[h+2][w+2];
    for (int i = 0; i < h+2; ++i) {
        for (int j = 0; j < w+2; ++j) {
            s[i][j] = '.';
        }
    }

    for (int i = 1; i < h+1; ++i) {
        for (int j = 1; j < w+1; ++j) {
            cin >> s[i][j];
        }
    }

    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if (s[i][j] == '#' && !(s[i][j+1] == '#' ||
                                    s[i+1][j] == '#' ||
                                    s[i][j-1] == '#' ||
                                    s[i-1][j] == '#')) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
ans = ''
if len(s) >= len(t):
    for i in range(len(s)-len(t), -1, -1):
        s_tmp = s[i:i+len(t)]
        flag = 0
        for j in range(len(t)):
            if s_tmp[j] == '?':
                s_tmp = t[:j+1] + s_tmp[j+1:]
            elif s_tmp[j] != t[j]:
                flag = 1
                break
        if flag == 0:
            ans = s[:i] + t + s[i+len(t):]
            break
else:
    flag = 1

if flag == 0:
    for i in range(len(ans)):
        if ans[i] == '?':
            ans = ans[:i] + 'a' + ans[i+1:]
    print(ans)
else:
    print('UNRESTORABLE')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;

/***************/
 #define amin main
/***************/

ll exp(ll x, ll n)
{if(n==0) return 1;if(n==1) return x%INF;if(n%2==0) return exp((x*x)%INF,n/2); else return(x*exp((x*x)%INF,n/2))%INF;}


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j;
	ll n;
	cin>>n;
	ll k = n/1000;
	ll a = 0;
	if(n%1000!=0)
	 a  =(k+1)*1000 -n;
	else
		a= 0;

	cout<<a<<endl;


	


	
	

	
	


	
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll x;
  cin >> x;
  ll ng = 0, ok = x;
  while (ng + 1 < ok) {
    ll m = (ok + ng) / 2;
    (m * (m + 1) / 2 >= x ? ok : ng) = m;
  }
  cout << ok << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: u64
    }
    println!("{}",
        (x / 11 * 2) + match x % 11 {
            0 => 0,
            m => if m <= 6 {1} else {2}
        });
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

bool find_contradiction(vector<vector<pair<int, int>>> &G) {
    int N = G.size();

    const int INF = numeric_limits<int>::max();
    vector<int> d(N, INF);

    repeat(s, N) {
        if (d[s] != INF) continue;
        d[s] = 0;
        // sから幅優先探索
        queue<pair<int, int>> que;
        que.emplace(s, 0);
        while (!que.empty()) {
            int v = que.front().first;
            int C = que.front().second;
            que.pop();
            if (d[v] < C) continue;
            for (auto edge : G[v]) {
                int to = edge.first;
                int cost = edge.second;
                if (d[to] == INF) {
                    d[to] = C + cost;
                    que.emplace(to, C + cost);
                } else {
                    if (d[to] != C + cost) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}

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

    auto G = vectors(pair<int, int>(0, 0), N, 0);
    repeat(i, M) {
        int L, R, D;
        cin >> L >> R >> D;
        --L, --R;
        G[L].emplace_back(R, D);
        G[R].emplace_back(L, -D);
    }

    if (find_contradiction(G)) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 12676
import java.io.*
import java.util.*

fun solve(N: Int, M: Int, A: IntArray) {
    val matchMap = mapOf(
        1 to 2,
        2 to 5,
        3 to 5,
        4 to 4,
        5 to 5,
        6 to 6,
        7 to 3,
        8 to 7,
        9 to 6
    )
    // ちょうどi本使って作れる最大の桁数
    val dp = IntArray(N + 1){ -1 }
    dp[0] = 0
    for (i in 1..N) {
        for (a in A){
            val m = matchMap[a]!!
            if (i - m < 0) continue
            if (dp[i-m] < 0) continue
            dp[i] = Math.max(dp[i], 1 + dp[i - m])
        }
    }
    // println(dp.contentToString())
    val ans = mutableListOf<Int>()
    val digit = dp[N]
    var rest = N
    val matcheDigits = A.sortedDescending()
    for (i in 0 until digit) {
        for (matchDigit in matcheDigits){
            val matchNum = matchMap[matchDigit]!!
            if (dp.getOrNull(rest - matchNum) == dp[rest] - 1) {
                ans.add(matchDigit)
                rest -= matchNum
                break
            }
            // println(rest)
        }
    }
    println(ans.joinToString(separator = ""))
    return
}
fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val M = sc.next().toInt()
    val A = IntArray(M)
    for (i in 0 until M) {
        A[i] = sc.next().toInt()
    }
    solve(N, M, A)
}


Measured memory_bytes: 36316
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;

using namespace std;
const int MAX = 1000005;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    COMinit();
    int N;
    cin >> N;
    vector<ll> A(N);
    map<int,int> mp;
    vector<vector<pair<int,int>>> p(N);
    //p[i][j] == pair<int,int>(a,b) :=  i番目の数のj番目の素因数の数はaでその数はb個
    rep(j,N){
        cin >> A[j];
        //ここでA[i]を素因数分解して集合を作る
        ll t = A[j];
        for(ll i=2;i*i<=A[j];i++){
            if(t%i==0){
                int cnt = 0;
                while(t%i==0){
                    cnt++;
                    t/= i;
                }
                p[j].push_back({i,cnt});
                //p[0] := {i,cnt}; 
                //i:= 素因数
                //cnt:= 何個その素因数を含むか
            }
        }
        if(t&&t!=1){
            p[j].push_back({t,1});
            //tを1つ素因数として含む
        }
        for(auto x:p[j]){
            //cout << "Prime factor = " << x.first << " nums = " << x.second << endl;
            if(mp.count(x.first)==0){
                //もしも今までにその素因数を含んでいなかったら
                //集合の中にその素因数を入れる
                mp[x.first] = x.second;
            }else{
                //もしもその素因数を含んでいたが、
                //数が少なかったら大きい奴に合わせる
                if(mp[x.first]<x.second)mp[x.first] = x.second;
            }
        }
    }

    ll ans = 0;
    /*
    for(auto x:mp){
        cout << "Prime factor = " << x.first << " nums = " << x.second << endl;
        //
        // こいつらの値を掛け算した奴が最小公倍数lcmになる
        // つまり lcm *= pow(x.first,x.second);
        // だから各A[i]について、求めたい値は lcm/A[i] であるので
        // ans += lcm/A[i];
    }*/
    ll L = 1;
    for(auto x:mp){
        L *= pow(x.first,x.second);
        L%= mod;
    }
    
    for(int i=0;i<N;i++){
        ans += L*inv[A[i]];
        ans %= mod;
    }
    
    cout << ans%mod << endl;
}

Measured memory_bytes: 24832
#include <stdio.h>

int main(void)
{
	char s[99];
	int n;
	int i;

	scanf("%s", s);

	n = 0;

	/* 文字数を数える。 */
	while (s[n] != '\0')
	{
		n++;
	}
	
	/* sが回文であるかどうか調べる。 */
	for (i = 0; i  < n / 2; i ++)
	{
		if (s[i] != s[n -1 - i])
		{
			printf("No\n");
			return 0;
		}
	}

	/* s全体が回文なので、前半のみ回文かどうか調べる。 */
	for (i = 0; i < (n - 1) / 4; i++)
	{
		if (s[i] != s[n / 2 - 1 - i])
		{
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

	return 0;
}

Measured memory_bytes: 128
<?php

function change_alpha($n)
{
    for($r = ""; $n >= 0; $n = intval($n / 26) - 1)
        $r = chr($n%26 + 0x41) . $r;
    return $r;
}


fscanf(STDIN, "%d", $n);
$ans = change_alpha($n-1);
$ans = strtolower($ans);
echo $ans."\n";

?>

Measured memory_bytes: 16156
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
lights = [lr() for _ in range(M)]
P = lr()
answer = 0
for bit in range(2 ** N):
    bl = True
    for i in range(M):
        p = P[i]
        result = 0
        for s in lights[i][1:]:
            s -= 1
            if (bit >> s) & 1:
                result += 1
        if result % 2 != p:
            bl = False
    if bl:
        answer += 1
print(answer)


Measured memory_bytes: 3064
n,m=map(int,input().split())

a=[0]*n
w=[0]*n

ac=0
wa=0

for i in range(m):

  p,s=map(str,input().split())
  p=int(p)

  if a[p-1]==0:
    if s=="AC":
      ac+=1
      wa+=w[p-1]
      a[p-1]=1
    else:
      w[p-1]+=1

print(ac,wa)

Measured memory_bytes: 51672
import sys
sys.setrecursionlimit(10**8)
stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N = ni()

a_array = na()
sum_array = [0]
slime = 0
for a in a_array:
    slime += a
    sum_array.append(slime)

INF = 10 ** 15
ans = [[INF] * N for _ in range(N)]


def solve(l, r):
    # print(l,r)
    if ans[l][r] != INF:
        return ans[l][r]
    if l == r:
        ans[l][r] = 0
        # print(l,r,ans[l][r])
        return 0
    slime_sum = sum_array[r+1] - sum_array[l]
    # print(l,r,"slime",slime_sum)
    for i in range(l, r):
        ans[l][r] = min(ans[l][r], solve(l, i) + solve(i+1, r) + slime_sum)
    # print(l,r,ans[l][r])
    return ans[l][r]


print(solve(0, N-1))


Measured memory_bytes: 75960
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	string s;
	cin>>s;
	string t="keyence";
	int n=s.size();
	int i1=7;
	for(int i=0; i<7; i++){
		if(t[i]!=s[i]){
			i1=i;
			break;
		}
	}
	int i2=7;
	for(int i=0; i<7; i++){
		if(t[6-i]!=s[n-1-i]){
			i2=i;
			break;
		}
	}
	if(i1+i2>=7){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	string N;
	int S = 0;
	cin >> N;
	/*
	N = "123456789";
	N = "123";
	*/

	for (int i = 0; i < N.size(); i++)
		S += N[i] - '0';
	cout << ((S % 9 != 0) ? "No" : "Yes") << endl;

	return (0);
}


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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

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

  ll n, m;
  cin >> n >> m;

  vector<vector<ll>> f(n);
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    f[a].push_back(h[b]);
    f[b].push_back(h[a]);
  }
  int ans = 0;
  rep(i, n) {
    // ここらへん面倒
    if (f[i].empty()) {
      ans++;
      continue;
    }
    ll index = max_element(f[i].begin(), f[i].end()) - f[i].begin();
    if (f[i].size() > index && h[i] > f[i][index]) ans++; //ここらへん面倒
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9764
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;
using namespace __gnu_pbds;

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long n;
	cin >>n;
	cout <<n / 2 + n % 2;
	return 0;
}


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
const int maxn = 100050;

int x, a, b, c;

int main()
{
	cin >> x;
	c = x%10; x/=10;
	b = x%10; x/=10;
	a = x%10;
	if(a==c) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int h,w;
    while(cin>>h>>w,1){
        if(h==0&&w==0)return 0;
        for(int i=1;i<=h;i++){
            for(int n=1;n<=w;n++){
                if(i==1||i==h||n==1||n==w)cout<<"#";
                else cout<<".";
            }cout<<endl;
        }cout<<endl;
    }
}


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

#define ll long long int

int main()
{
    ll S;
    cin >> S;
    int res = 1000;
    while (S >= 100)
    {
        int cur = abs(S % 1000 - 753);
        if (cur < res) res = cur;
        S /= 10;
    }
    cout << res << '\n';
    return(0);
}

Measured memory_bytes: 256
<?php
	fscanf(STDIN, "%d", $N);

    $P = trim(fgets(STDIN));
    $PArray = explode(' ', $P);

	$count = 0;
	$min = $PArray[0];

	for ($i = 0; $i < $N-1; $i++) {
      if ($PArray[$i] >= $PArray[$i+1] && $min > $PArray[$i+1]) {
        $count++;
        $min = $PArray[$i+1];
      }
    }

	echo ($count+1);
?>

Measured memory_bytes: 41732
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int n, t;
  cin >> n >> t;
  vector<int> a(n);
  for(auto &i : a){
    cin >> i;
  }
 
  int ans = 0;
  int g = 0;
  vector<int> ga;
  int root = a[0];
  for(int i = 1;i < n;i++){
      if(root >= a[i]){
        root = a[i];
        continue;
      }
      if(g <= a[i] - root){
        g = a[i] - root;
        ga.push_back(g);
        ans++;
      }
  }
 
  for(auto i : ga){
    if(i != g)ans--;
    else break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1276
K1 = 1
K2 = 27
K3 = 703
K4 = 18279
K5 = 475255
alpha = "abcdefghijklmnopqrstuvwxyz"

n = int(input())

a = ""

def func(n,k):
	global a
	a=alpha[n%26]+a
	if(k>1):
		func(n//26,k-1)

sum = 0
for i in range(1,15):
	sumb = sum
	sum += 26**i
	if(sum >= n):
		#print(n-sumb-1,i)
		func((n-sumb-1),i)
		break
print(a)


Measured memory_bytes: 61956
#include <stdio.h>

int main(void)
{
	int x, y, n;
	while(1)
	{
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0)
		{
			break;
		}
		if (x > y)
		{
			n = x, x = y, y = n;
		}
		printf("%d %d\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define ll long long
#define INF 2000000000
#define INF2 2000000000000000000
 
using namespace std;

int main() {
    
    IOS;

   	int n;
   	cin >> n;
   	ll tot = 0;
   	for(int i = 1; i <= n; i++) {
   		tot += (n/i);
   		if(n%i == 0)
   			tot--;
   	}
   	cout << tot;

}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

vector<int> d;
int n, k;
bool check(int x){
	while(x > 0){
		int a = x % 10;
		for(int i=0; i<k; i++){
			if(a == d[i]) return false;
		}
		x /= 10;
	}
	return true;
}

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	cin >> n >> k;
	
	for(int i=0; i<k; i++){
		int t;
		cin >> t;
		d.pb(t);
	}

	for(int i=n; ; i++){
		if(check(i)){
			cout << i << endl;
			break;
		}
	}


	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String [] args){
    Scanner sc = new Scanner(System.in);
    int count,i,j,length;
    String ans;
    double[] length_pow = new double[3];
    count = sc.nextInt();
    for(i =0;i < count;i++){
      for(j = 0;j < 3;j++){
        length = sc.nextInt();
        length_pow[j] = Math.pow(length,2);
      }
      Arrays.sort(length_pow);
      if(length_pow[0] + length_pow[1] == length_pow[2]) ans = "YES";
      else ans = "NO";
      System.out.println(ans);
    }
  }
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N, L;
int x[330000], t[330000];
bool l[330000], r[330000];

signed main() {
    cin >> N >> L;
    for (int i = 0; i < N; i++)cin >> x[i];
    for (int i = 0; i < N; i++)cin >> t[i];
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int pc, lc, rc;
        pc = t[i] - t[i] % (2 * L);
        if (pc < t[i])pc += 2 * L;

        lc = 2 * x[i];
        if (lc < t[i])lc = t[i] - (t[i] - lc) % (2 * L);
        if (lc < t[i])lc += 2 * L;
        lc -= 2 * x[i];

        rc = 2 * (L - x[i]);
        if (rc < t[i])rc = t[i] - (t[i] - rc) % (2 * L);
        if (rc < t[i])rc += 2 * L;
        rc += 2 * x[i];

        ans += pc;
        if (lc < pc)l[i] = true;
        if (rc == pc)r[i] = true;

    }

    if (!r[N - 1])ans += 2 * L;

    vint stk;
    for (int i = 0; i < N - 1; i++) {
        if (l[i] && !r[i])stk.push_back(i);
        if (!l[i] && r[i] && !stk.empty()) {
            l[stk.back()] = r[i] = false;
            stk.pop_back();
            ans -= 2 * L;
        }
    }
    stk.clear();
    for (int i = 0; i < N - 1; i++) {
        if (l[i] && !r[i])stk.push_back(i);
        if (l[i] && r[i] && !stk.empty()) {
            l[stk.back()] = l[i] = r[i] = false;
            stk.pop_back();
            ans -= 2 * L;
        }
    }
    stk.clear();
    for (int i = N - 2; i >= 0 ; i--) {
        if (!l[i] && r[i])stk.push_back(i);
        if (l[i] && r[i] && !stk.empty()) {
            r[stk.back()] = l[i] = r[i] = false;
            stk.pop_back();
            ans -= 2 * L;
        }
    }
    stk.clear();
    for (int i = 0; i < N - 1; i++) {
        if (l[i] && r[i])stk.push_back(i);
    }
    ans -= stk.size() / 2 * 2 * L;

    cout << ans << endl;
}


Measured memory_bytes: 11888
import java.util.*;

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

Measured memory_bytes: 21716
#include <iostream>
#include <vector>

using namespace std;

struct Edge {
    int src, dst;
    Edge() {}
    Edge(int a, int b) : src(a), dst(b) {}
};

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

    vector<Edge> Graph;

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        Graph.push_back(Edge(a, b));
    }

    for (int i = 1; i <= n; i++) {
        int cnt = 0;
        for (int j = 0; j < m; j++) {
            if (Graph[j].src == i || Graph[j].dst == i) {
                cnt++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

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

int main(){
    long long n,m;
    long long ans=0;
    cin>>n>>m;
    map<long long,long long> c;
    long long s=0;
    for (int i = 0; i < n; ++i) {
        int t;
        cin>>t;
        s+=t;
        ++c[s%m];
    }
    for (auto i:c) {
        long long t=i.second;
        ans+=t*(t-1)/2;
    }
    ans+=c[0];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>
#include <stdlib.h>

#define MAXLEN 2*10000


int mycmp(const void* aa, const void* bb) {
	const int* a = aa;
	const int* b = bb;
	if (*a > *b) {
		return 1;
	} else if (*a < *b) {
		return -1;
	} else {
		return 0;
	}
}

int main(void) {
	unsigned int n;
	scanf("%u", &n);

	/* 以下はstack overflow を起こすのでmallocで動的に確保しよう*/
	/*
	unsigned int as[MAXLEN], bs[MAXLEN];
	for (size_t i = 0; i < MAXLEN; i++) {
		as[i] = -1;
		bs[i] = -1;
	}
	*/

	unsigned int* as = malloc(sizeof(unsigned int) * n);
	unsigned int* bs = malloc(sizeof(unsigned int) * n);

	for (unsigned int i = 0; i < n; i++) {
		scanf("%u %u", as+i, bs+i);
	}

	qsort(as, n, sizeof(unsigned int), mycmp);
	qsort(bs, n, sizeof(unsigned int), mycmp);

	unsigned int ans;
	
	if (n % 2 == 1) {
		unsigned int a, b;
		a = as[(n-1)/2];
		b = bs[(n-1)/2];
		ans = b - a + 1;
	} else {
		unsigned int a0, a1, b0, b1;
		a0 = as[(n-1)/2];
		a1 = as[n/2];
		b0 = bs[(n-1)/2];
		b1 = bs[n/2];
		ans = b0 - a0 + b1 - a1 + 1;
	}
	
	printf("%u\n", ans);
	//fprintf(stderr, "OK!\n");
	return 0;
}


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

int main(){
  string S;
  cin>>S;
  int count=0,tmp=0,ans=0;
  for(int i=0;i<S.size();i++){
    if(S[i]=='A' || S[i]=='T' || S[i]=='C' || S[i]=='G'){
      tmp++;
      count=max(tmp,count);
    }
    else{
      tmp=0;
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String args[]){
      Scanner s=new Scanner(System.in);
      String a=s.next();
      String b=s.next();
      if(a.equals(b.substring(0,a.length())))
        System.out.println("Yes");
    else
        System.out.println("No");
  }
}

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

#define o(output) cout << output << endl
#define priolity_queue pq
#define push p
#define top t

using namespace std;

string s,t;
int a,b,c,d;

int main(){
  cin >> s;
  if(s[0]==s[2])o("Yes");
  else o("No");
}

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

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

    if (k <= a) {
        cout << k << endl;
    }
    else if (k <= a + b) {
        cout << a << endl;
    }
    else {
        int n = k - (a + b);
        cout << a - n << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
import sys
input = sys.stdin.readline

_n = int(input())
_s = input()[:-1]


def chker(n, s):
    flg = [0] * 1000
    for i in range(1000):
        password = str(i).zfill(3)
        digit = 0
        for num in s:
            if password[digit] == num:
                digit += 1

            if digit == 3:
                flg[i] = 1
                break

    print(sum(flg))


chker(_n, _s)


Measured memory_bytes: 40924
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_map>
#include <iomanip>

using namespace std;

using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int s = 0;
        for (int j = 0; j < m; j++) {
            int x;
            cin >> x;
            s += x * a[j];
         }
        s += c;
        if (s > 0) ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
ll n, x;

ll f(ll p, ll q) {
	if(q==0) return 0;
	if(p==0) return 1;
	ll m = 1LL << p;
	if(q<2*m-1) return f(p-1, q-1);
	return m + f(p-1, q-2*m+1);
}

int main() {
	cin>>n>>x;
	cout<<f(n, x);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <string>
#include <vector>

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

using namespace std;
int N;
int a[200001], b[200001];

int main() {
  scanf("%d", &N);
  REP(i, N)
    scanf("%d ", &a[i]);
  REP(i, N)
    scanf("%d ", &b[i]);
  int ans = 0;
  REP(i, 30) {
    int mod = pow(2, i + 1);
    int tmpb[200001];
    REP(j, N)
      tmpb[j] = b[j] % mod;
    sort(tmpb, tmpb + N);
    long long int cnt = 0;
    REP(j, N) {
      int tmpa = a[j] % mod;
      cnt += N -
             distance(tmpb, lower_bound(tmpb, tmpb + N, mod / 2 * 3 - tmpa)) +
             distance(tmpb, lower_bound(tmpb, tmpb + N, mod - tmpa)) -
             distance(tmpb, lower_bound(tmpb, tmpb + N, mod / 2 - tmpa));
    }
    if (cnt % 2 == 1)
      ans += mod / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mod=1000000007;
int main()
{
	ll i,a,n,c=0;
	map<ll,ll> m;
	cin>>n;
	for(i=0;i<n;i++)
	{
	 cin>>a; 
	 if(i>a && m[i-a]!=0)
	{
//	  cout<<i<<" ";
	   c+=m[i-a];
	}
	 m[i+a]++;
}
//cout<<m[0]<<" ";
//	 map<ll,ll> :: iterator it;
//	for(it=m.begin();it!=m.end();it++) cout<<(*it).first<<" "<<(*it).second<<"\n";
	cout<<c;
	
	return 0;
}

Measured memory_bytes: 17384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,q,time = 0;
    cin >> n >> q;
    queue<pair<string, int>> que;
    for(int i=0;i<n;i++){
        string s;
        int t;
        cin >> s >> t;
        que.push(make_pair(s, t));
    }

    while(!que.empty()){
        time += min(q, que.front().second);
        if(q >= que.front().second){
            cout << que.front().first << " " << time << endl;
            que.pop();
        }
        else {
            que.push(make_pair(que.front().first, que.front().second - q));
            que.pop();
        }
    }

    return 0;
}


Measured memory_bytes: 6244
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
const int MAX = 1000001; 
  
// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    // initialising bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
  
// driver code 
int main() 
{ 
    int n,q;
    cin>>n>>q;
    int a[n];
    input(a,n);
    Query queries[q];
    f(q)
    {
        int x,y;
        cin>>x>>y;
        y--,x--;
        queries[i].l=x;
        queries[i].r=y;
        queries[i].idx=i;
    }
    sort(queries, queries+q, cmp); 
    answeringQueries(a, n, queries, q); 
    return 0; 
} 

Measured memory_bytes: 19356
n = int(input())
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

output = num2alpha(n)
print(output.lower())


Measured memory_bytes: 9172