akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main p = new Main();
	}

	public Main() {
		Scanner sc = new Scanner(System.in);
		alphav = new boolean[11];
		while(true){
			String s = sc.next();
			if(s.equals("#"))
				break;
			solve(s);
		}
		
	}

	public void solve(String s) {
		String[] fs = s.split("=");
		boolean res = true;
		for(int i=0;i<(1<<11);i++){
			for(int j=0;j<alphav.length;j++)
				alphav[j] = (i&(1<<j)) > 0;
				
			cur = 0;
			f = fs[0];
			boolean r0 = fomula();
			cur = 0;
			f = fs[1];
			boolean r1 = fomula();
			if(r0 != r1){
				res = false;
				break;
			}
		}
		System.out.println(res? "YES" : "NO");
	}

	boolean[] alphav;
	String f;
	int cur = 0;
	private boolean fomula() {
		boolean ret = false;
		char nc = nextc();
		
		if('a' <= nc && nc <= 'k')
			return alphav[nc-'a'];
		
		switch(nc){
		case 'T':
			ret = true;
			break;
		
		case 'F':
			ret = false;
			break;
			
		case '-':
			ret = !fomula();
			break;
			
		case '(':
			ret = fomula();
			nc = nextc();
			switch(nc){
			case '*':
				ret &= fomula();
				break;
			case '+':
				ret |= fomula();
				break;
			case '-':
				nextc();
				// fomulaを評価する必要がある
				// 逆にしたらだめ・・・
				ret = !(!fomula() && ret);
				break;
				
			}
			nextc();
			break;
		}
		
		return ret;
	}
	
	private char nextc(){
		char c = f.charAt(cur);
		cur++;
		return c;
	}
}

Measured memory_bytes: 44060
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
#define min(x,y) ((x)>(y) ? (y) : (x))
#define max(x,y) ((x)<(y) ? (y) : (x))
#define abs(x) ((x)<0 ? ((-1)*(x)) : (x))
#define rep(i,start,end) for(int i=(start);i<=(end);i++)
const int inf=0x3f3f3f3f;
const ll INF=0xffffffffffffff;

const int N = 1e6 + 5 ;
const int mod = 998244353 ;

int main() {
    //freopen("C:/Users/dell/Desktop/in.txt","r+",stdin);
    string s;
    cin>>s;
    s[1]=s[1]=='R' ? 'B' : 'R';
    cout<<s<<endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

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

    vector <int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    int ans = 1, flag = 0;

    for (int i = 0; i < N - 1; i++){
        if (i == 0 || flag == 2){
            if (A[i] < A[i + 1]){
                flag = 0;
            }else if(A[i] > A[i + 1]){
                flag = 1;
            }else{
                flag = 2;
            }
        }else if(flag == 0){
            if (A[i] > A[i + 1]){
                ans++;
                flag = 2;
            }
        }else{
            if (A[i] < A[i + 1]){
                ans++;
                flag = 2;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
n, m = list(map(int, input().split()))
hs =  list(map(int, input().split()))
ans = [1]*n
roads = []
for i in range(m):
    roads += [list(map(int, input().split()))]
for road in roads:
    if hs[road[0]-1] <= hs[road[1]-1]:
        ans[road[0]-1] = 0
    if hs[road[0]-1] >= hs[road[1]-1]:
        ans[road[1]-1] = 0
print(ans.count(1))


Measured memory_bytes: 31888
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {
	
	int N; cin >> N;

	double sum = 0;
	for (int i = 0; i < N; i++) {
		double a; cin >> a;
		a = 1 / a;
		sum += a;
	}
	cout << setprecision(10) << 1 / sum << endl;

	return 0;
}


Measured memory_bytes: 3772
/*
 *  Lang    : C++
 *  Author  : little_angel
 */
#include <bits/stdc++.h>

using namespace std;
#define int long long

const int mod = 1e9 + 7;

void add(int &a, int b) {
    a += b;
    if (a >= mod)a -= mod;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<vector<int>> dp(n + 1, vector<int>(n + 1));
    // len, last number

    dp[1][1] = 1;

    // .......b op a
    //  for dp use the above seq

    for (int len = 2; len <= n; ++len) {
        for (int i = 1; i <= n; ++i) dp[len - 1][i] = (dp[len - 1][i] + dp[len - 1][i - 1]) % mod;
        for (int a = 1; a <= len; ++a) {
            int l = (s[len - 2] == '<' ? 1 : a);
            int r = (s[len - 2] == '<' ? a - 1 : len - 1);
            if (l <= r)dp[len][a] = (dp[len][a] + (dp[len - 1][r] - dp[len - 1][l - 1] + mod) % mod) % mod;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) ans = (ans + dp[n][i]) % mod;
    cout << ans << endl;
}

Measured memory_bytes: 70784
#include <stdio.h>
#include <iostream>
using namespace std;

int N;
int A[18];

long long rec(int l, int r, long long xl, long long xr) {
    if (r - l == 1) {
        return 0;
    }
    
    long long ret = (long long) 1e18;
    for (int i = l + 1; i < r; i++) {
        long long tmp = A[i] * (xl+xr) + rec(l, i, xl, xl+xr) + rec(i, r, xl+xr, xr);
        ret = min(ret, tmp);
    }
    return ret;
}

int main() {    
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    cout << rec(0, N - 1, 1, 1) + A[0] + A[N - 1];
    
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
int power(int x,int k,int p){
	int res=1;
	for(;k;k>>=1,x=1ll*x*x%p)if(k&1)res=1ll*res*x%p;
	return res;
}
const int maxn=1e6+5,mod=924844033,G=5;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int n,tot,l,N,bitl;
int bitrev[maxn],cnt[maxn];
int head[maxn],des[maxn<<1],nxt[maxn<<1];
int sz[maxn],fac[maxn],ifac[maxn];
int a[maxn],b[maxn],c[maxn];
void adde(int x,int y){
	des[++tot]=y;nxt[tot]=head[x];head[x]=tot;
}
void init(int n,int m){
	n++;m++;l=n+m-1;
	for(N=1,bitl=0;N<l;N<<=1,bitl++);
	rep2(i,0,N)bitrev[i]=(bitrev[i>>1]>>1)|((i&1)<<(bitl-1));
}
void ntt(int *a,int n,int flag){
	rep2(i,0,n)if(i<bitrev[i])swap(a[i],a[bitrev[i]]);
	for(int i=1;i<n;i<<=1){
		int wn=power(G,(mod-1)/(i<<1),mod);
		if(flag==-1)wn=power(wn,mod-2,mod);
		for(int j=0;j<n;j+=i<<1){
			int w=1;
			rep2(k,0,i){
				int x=a[j+k],y=1ll*w*a[j+k+i]%mod;
				a[j+k]=add(x,y);
				a[j+k+i]=sub(x,y);
				w=1ll*w*wn%mod;
			}
		}
	}
	if(flag==-1){
		int inv=power(n,mod-2,mod);
		rep2(i,0,n)a[i]=1ll*a[i]*inv%mod;
	}
}
void dfs(int x,int fa){
	sz[x]=1;
	cnt[n]=add(cnt[n],1);
	Rep(p,x)if(des[p]!=fa){
		dfs(des[p],x);
		sz[x]+=sz[des[p]];
		cnt[sz[des[p]]]=sub(cnt[sz[des[p]]],1);
	}
	cnt[n-sz[x]]=sub(cnt[n-sz[x]],1);
}
int main(){
	read(n);
	fac[0]=1;rep(i,1,n)fac[i]=1ll*fac[i-1]*i%mod;
	rep(i,0,n)ifac[i]=power(fac[i],mod-2,mod);
	rep(i,1,n-1){
		int x,y;read(x);read(y);
		adde(x,y);adde(y,x);
	}
	dfs(1,0);
	rep(i,1,n)a[i]=1ll*cnt[i]*fac[i]%mod;
	rep(i,0,n)b[i]=ifac[n-i];
	init(n,n);
	ntt(a,N,1);ntt(b,N,1);
	rep2(i,0,N)c[i]=1ll*a[i]*b[i]%mod;
	ntt(c,N,-1);
	rep(i,1,n)printf("%lld\n",1ll*c[i+n]*ifac[i]%mod);
	return 0;
}

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

int main(){
    string str1,str2;
    cin>>str1>>str2;
    for(int i=0;i<str1.size();i++){
        if(i!=str1.size()-1)cout<<str1[i]<<str2[i];
        else{
            if(str1.size()!=str2.size())cout<<str1[i]<<endl;
            else cout<<str1[i]<<str2[i]<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int v[55], c[55];

int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    Yes((a <= c && c <= b) || (a >= c && c >= b));

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>

using namespace std;

int main(void) {
  int n;
  cin>>n;
  for(int i=0; i<2*n-1; i+=2) {
    if('Y'==getchar()) {
      cout<<"Four"<<endl;
      return 0;
    }
  }
  cout<<"Three"<<endl;
  return 0;
}


Measured memory_bytes: 256
import statistics
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n):
    b[i]=a[i]-(i+1)
b.sort()
if n%2==1:
    m=statistics.median(b)
    b=list(map(lambda x:abs(x-m),b))
    ans=0
    for i in range(n):
        ans+=b[i]
else:
    m1=b[n//2]
    m2=b[n//2+1]
    k=list(map(lambda x:abs(x-m1),b))
    l=list(map(lambda x:abs(x-m2),b))
    ans1=0
    ans2=0
    for i in range(n):
        ans1+=k[i]
        ans2+=l[i]
    ans=min(ans1,ans2)
print(ans)

Measured memory_bytes: 36908
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<57;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

int a,b;

int main(){
	cin>>a>>b;
	cout<<(a+b)%24<<endl;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<double> vs(n);
  for (int i = 0; i < n; ++i) {
    cin >> vs[i];
  }

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

  double ans = (vs[0]+vs[1])/2;
  for (int i = 2; i < n; ++i) {
    ans = (ans + vs[i])/2;
  }

  cout << scientific << setprecision(8) << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


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

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


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
  
using namespace std;
  
double EPS = 1e-10;
  
double add(double a,double b){
  if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0;
  return a+b;
}
  
struct point{
  double x,y;
  point() {}
  point(double x,double y):x(x),y(y){
  }
  point operator + (point p){
    return point(add(x,p.x),add(y,p.y));
  }
  point operator - (point p){
    return point(add(x,-p.x),add(y,-p.y));
  }
  point operator * (double d){
    return point(x*d,y*d);
  }
  point operator / (double d){
    return point(x/d,y/d);
  }
};
  
double dist(point a,point b){
    return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}

int main(void){
    int n,x,y,v;
    vector<point>P;
    vector<double>V;
     
    while(cin >> n,n){
        P.clear();
        V.clear();
         
        for(int i=0;i<n;i++){
            cin >> x >> y >> v;
            P.push_back(point(x,y));
            V.push_back(v);
        }
        
        double r=0.98;
        point now(0,0);
         
        for(double d=10;d>EPS;d*=r){
            int mx=0;
            double mxd=0;
             
            for(int j=0;j<P.size();j++)
                if(dist(now,P[j])/V[j]>mxd)
		  mx=j,mxd=dist(now,P[j])/V[j];
             
            now=now+((P[mx]-now)/dist(P[mx],now)*d);
        }
         
        double ans=0;
        for(int i=0;i<P.size();i++){
	  ans=max(ans,dist(now,P[i])/V[i]);
        }
        printf("%.8f\n",ans);
    }
    return 0;
}

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

int main()
{ 
  string s ;
  cin >> s ;
  for(int i = 0 ; i < s.size() ; i++)
  {
    if(i == 4)
    {
      cout << " " ;
    }

    cout << s.at(i) ;
  }

  cout << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
/// khodaya komak kon
/// ya navid navid
const int N=2e5+1000,mod=1e9+7;
vector <int> g[N];
pii b[N];
vector <pair <pii,int> > a[N],q;
ll power(ll n,ll k){
    if (k==0) return 1;
    if (k%2==1){
        ll x=power(n,k/2);
        return x*x%mod*n%mod;
    }
    ll x=power(n,k/2);
    return x*x%mod;
}
ll fac[N];
ll cnt[N];
ll vis[N];
vector <int> ras;
ll dfs(ll v){
    vis[v]=1;
    ras.pb(v);
    cnt[b[v].S]++;
    for (int i=0;i<g[v].size();i++){
        ll u=g[v][i];
        if (vis[u]) continue;
        dfs(u);
    }
}
int32_t main(){
    fac[0]=1;
    for (int i=1;i<N;i++){
        fac[i]=fac[i-1]*i%mod;
    }
    ll n,x,y;
    cin >> n >> x >> y;
    for (int i=1;i<=n;i++){
        cin >> b[i].S >> b[i].F;
        q.pb({b[i],i});
        a[b[i].S].pb({b[i],i});
    }
    sort(q.begin(),q.end());
    ll o=-1;

   // if (y<x) cout << 1/0;
    for (int i=1;i<q.size();i++){
        if (q[i].F.F+q[0].F.F<=y && q[0].F.S!=q[i].F.S){
            g[q[i].S].pb(q[0].S);
            g[q[0].S].pb(q[i].S);
        }
        if (q[0].F.S!=q[i].F.S && o==-1){
            o=i;
            continue;
        }
        if (o!=-1 && q[i].F.F+q[o].F.F<=y && q[o].F.S!=q[i].F.S){
            g[q[i].S].pb(q[o].S);
            g[q[o].S].pb(q[i].S);
        }

    }
    for (int i=1;i<q.size();i++){
        if (q[i].F.F+q[0].F.F<=y && q[0].F.S!=q[i].F.S){
            g[q[i].S].pb(q[0].S);
            g[q[0].S].pb(q[i].S);
        }
        if (q[0].F.S!=q[i].F.S && o==-1){
            o=i;
            continue;
        }
        if (o!=-1 && q[i].F.F+q[o].F.F<=y && q[o].F.S!=q[i].F.S){
            g[q[i].S].pb(q[o].S);
            g[q[o].S].pb(q[i].S);
        }

    }
    for (int i=0;i<N;i++){
        sort(a[i].begin(),a[i].end());
        for (int j=1;j<a[i].size();j++){
            if (a[i][j].F.F+a[i][0].F.F<=x){
                g[a[i][j].S].pb(a[i][0].S);
                g[a[i][0].S].pb(a[i][j].S);
            }
        }
    }
    ll ans=1;
    for (int i=1;i<=n;i++){
        if (vis[i]) continue;
        dfs(i);
        ll z=ras.size();
        ans*=fac[z];
        ans%=mod;
        for (int j=0;j<ras.size();j++){
            ll v=ras[j];
            ll z=cnt[b[v].S];
            cnt[b[v].S]--;
            ans*=power(z,mod-2);
            ans%=mod;
        }
        ras.clear();
    }
    cout << ans << endl;

}




Measured memory_bytes: 53804
import sys
import numpy as np
import random
import math
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	a, b, c = LI()
	if a+b == c or a+c == b or b+c == a:
		print('Yes')
	else:
		print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 27144
H, W = map(int, input().split(" "))
N = int(input())
a = list(map(int, input().split(" ")))


c = 1

for height in range(1,H+1):
    colors=[]
    for width in range(1, W+1):
        if a[c-1]>0:
            a[c-1] = a[c-1]-1
        else:
            c = c+1
            a[c-1] = a[c-1]-1
        if height%2 == 0:
            colors = [c] + colors
        else:
            colors = colors + [c]
    else:
        for width in range(1, W+1):
            print(colors[width-1], end=" ")
        else:
            print("")



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

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var k = cin.nextInt();
            Console.WriteLine(k * Math.Pow(k - 1, n - 1));
        }
    }

    class Scanner
    {
        string[] s;
        int i;

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

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

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

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

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

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

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

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

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


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

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


Measured memory_bytes: 11092
#include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>
using namespace std;
#define P(x) cout << x << endl
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n;
    cin>>n;
    int ans =n/3;
    if(n<3) P(0);
    else P(ans);
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a[3][6],i,j,sum[3];
  int x[3][3];
  for(i=0;i<3;i++){
    sum[i]=0;
    for(j=0;j<6;j++)
      scanf("%d",&a[i][j]);
  }
  for(i=0;i<3;i++)
    sum[i]=a[i][2]+(a[i][0]*3600)+(a[i][1]*60);
  for(i=0;i<3;i++)
    sum[i]=(a[i][5]+(a[i][3]*3600)+(a[i][4]*60))-sum[i];
  for(i=0;i<3;i++)
      x[0][i]=sum[i]/3600;
  for(i=0;i<3;i++)
    x[1][i]=(sum[i]%3600)/60;
  for(i=0;i<3;i++)
    x[2][i]=(sum[i]%3600)%60;
  for(j=0;j<3;j++){
      printf("%d %d %d",x[0][j],x[1][j],x[2][j]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>

int main() {
	int n;
	double debt=100000;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		debt = debt + debt*0.05;
		if ((int)debt % 1000 > 0) {
			debt = debt - (int)debt % 1000;
			debt += 1000;
		}
	}
	printf("%d\n", (int)debt);

	return 0;
}


Measured memory_bytes: 2100
class UnionFind:

    def __init__(self, n):
        self.parents = [i for i in range(n)]
        self.ranks = [0 for _ in range(n)]
        self.sizes = [1 for _ in range(n)]

    def find_root(self, node):
        parent_node = self.parents[node]
        if parent_node == node:
            return node
        else:
            root_node = self.find_root(parent_node)
            self.parents[node] = root_node  # reduction
            return root_node

    def is_same_group(self, one_node, other_node):
        one_root = self.find_root(one_node)
        other_root = self.find_root(other_node)
        return one_root == other_root

    def union(self, one_node, other_node):
        one_root = self.find_root(one_node)
        other_root = self.find_root(other_node)
        if one_root == other_root:
            return
        one_rank = self.ranks[one_root]
        other_rank = self.ranks[other_root]
        if one_rank < other_rank:
            self.parents[one_root] = other_root
            self.sizes[other_root] += self.sizes[one_root]
        else:
            self.parents[other_root] = one_root
            self.sizes[one_root] += self.sizes[other_root]
            if one_rank == other_rank:
                self.ranks[one_root] += 1

    def group_size(self, node):
        root_node = self.find_root(node)
        return self.sizes[root_node]


def main():
    N, M, K = list(map(int, input().split(' ')))
    non_suggested_users = [[] for _ in range(N)]
    friend_tree = UnionFind(N)
    for _ in range(M):
        a, b = list(map(int, input().split(' ')))
        one_user = a - 1
        other_user = b - 1
        friend_tree.union(one_user, other_user)
        non_suggested_users[one_user].append(other_user)
        non_suggested_users[other_user].append(one_user)
    for _ in range(K):
        c, d = list(map(int, input().split(' ')))
        one_user = c - 1
        other_user = d - 1
        if friend_tree.is_same_group(one_user, other_user):
            non_suggested_users[one_user].append(other_user)
            non_suggested_users[other_user].append(one_user)
    answer_list = list()
    for user in range(N):
        ans = friend_tree.group_size(user) - len(non_suggested_users[user]) - 1
        answer_list.append(str(ans))
    print(' '.join(answer_list))


if __name__ == '__main__':
    main()

Measured memory_bytes: 45112
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

int main(){
    int a[3];
    for(int i = 0;i<3;i++){
        cin>>a[i];
    }
    sort(a,a+3);
    cout<< a[0]+a[1]+a[2] - a[2] <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
vector<int> match(string &t,string &p) {
  //cout<<t<<" "<<p<<endl;
  using BS = bitset<100>;
  int n = t.length(), m = p.length();
  vector<BS> M(100);
  vector<int> res(n,0);
  for (int i=0;i<m;i++){
    if(p[i]=='?') for(int j=0;j<100;j++) M[j][i]=1;
    if(isdigit(p[i])) M[p[i]-'0'][i]=1;
    if(islower(p[i])) M[10+p[i]-'a'][i]=1;
    if(isupper(p[i])) M[36+p[i]-'A'][i]=1;
  }
  BS S(0);
  for (int i = 0; i < n; i++) {
    S=((S<<1)|BS(1));
    if(isdigit(t[i])) S&=M[t[i]-'0'];
    if(islower(t[i])) S&=M[10+t[i]-'a'];
    if(isupper(t[i])) S&=M[36+t[i]-'A'];
    
    if((S&(BS(1)<<(m-1))).count()) res[i]=1;
  }
  //for(int i=0;i<n;i++) cout<<res[i];cout<<endl;
  return res;
}

signed main(){
  int aw,ah,bw,bh;
  cin>>aw>>ah>>bw>>bh;
  string a[ah],b[bh];
  for(int i=0;i<ah;i++) cin>>a[i];
  for(int i=0;i<bh;i++) cin>>b[i];
  //for(int i=0;i<ah;i++) cout<<a[i]<<endl;;
  //for(int i=0;i<bh;i++) cout<<b[i]<<endl;;
  vector<int> G[ah][bh];
  for(int i=0;i<ah;i++)
    for(int j=0;j<bh;j++)
      G[i][j]=match(a[i],b[j]);
  
  int ans=0;
  for(int i=0;i<=ah-bh;i++){
    for(int j=0;j<aw;j++){
      int res=1;
      for(int k=0;k<bh;k++)
	res&=G[i+k][k][j];
      ans+=res;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 229096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

double dp[3005][3005];

int main() {
    int n;
    double p[3005];
    cin >> n;
    REP(i,n) cin >> p[i];
    dp[0][0] = 1.0;
    REP(i,n){
        REP(j,n+1){
            dp[i+1][j] = dp[i][j]*(1-p[i]) + dp[i][j-1]*p[i];
        }
    }
    double ans=0;
    for(int i=n/2+1;i<=n;i++){
        ans += dp[n][i];
    }
    printf("%.12lf\n",ans);
    return 0;
}


Measured memory_bytes: 70656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>

int main() {
	int N; std::cin >> N;
	std::vector<int>A(N);
	std::vector<int>B(N);
	for (auto& r : A)
		std::cin >> r;
	for (auto& r : B)
		std::cin >> r;
	int max = 0;
	for (int p = 0; p < N; ++p) {
		int ans = 0;
		for (int i = 0; i <= p; ++i)
			ans += A[i];
		for (int j = p; j < N; ++j)
			ans += B[j];
		max = std::max(max, ans);
	}
	
		std::cout << max << std::endl;
}


Measured memory_bytes: 3564
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x)  if(DEBUG_Switch) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
void pvarr_int(int *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%d%c", arr[i], i == n ? '\n' : ' ');}}
void pvarr_LL(ll *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%lld%c", arr[i], i == n ? '\n' : ' ');}}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
int n;
ll a[maxn];
int main()
{
#if DEBUG_Switch
    freopen("C:\\code\\input.txt", "r", stdin);
#endif
    //freopen("C:\\code\\output.txt","w",stdout);
    cin >> n;
    repd(i, 1, n)
    {
        cin >> a[i];
    }
    ll x = a[1];
    ll ans = 0ll;
    repd(i, 2, n)
    {
        ans += max(0ll, x - a[i]);
        x = max(x, a[i]);
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 5136
#include<stdio.h>
int main(){
	int i,n;
	long a[10000],min,max,sum;

	min=1000000;
	max=-1000000;
	sum=0;

	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%ld",&a[i]);
		if(a[i]<min)min=a[i];
		if(a[i]>max)max=a[i];
		sum+=a[i];
	}
	printf("%ld %ld %ld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 676
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll power(ll A,ll B,ll M){
    if(B==0){
        return 1;
    }
    else if(B%2==0){
        ll s=power(A,B/2,M);
        return (s*s)%M;
    }
    else{
        return ((A%M)*power(A,B-1,M))%M;
    }
}

ll MOD=998244353;

int main(){
    ll N;
    cin>>N;
    Graph G(N);
    bool flag=true;
    rep(i,N){
        int a;
        cin>>a;
        if(i==0){
            if(a!=0){
                flag=false;
            }
        }
        if(i!=0){
            if(a==0){
                flag=false;
            }
        }
        G[a].push_back(i+1);
    }
    vector<ll>GN(N);
    rep(i,N){
        GN[i]=G[i].size();
    }
    for(int i=1;i<N;i++){
        if(GN[i-1]==0&&GN[i]!=0){
            flag=false;
        }
    }
    if(flag){
        //前の枝にどのようにくっつけるか
        ll Ans=1;
        for(int i=2;i<N;i++){
            ll P=GN[i];
            if(P==0){
                break;
            }
            ll Q=GN[i-1];
            Ans=(Ans*power(Q,P,MOD))%MOD;
        }       
        cout<<Ans<<endl;
    }
    else{
        cout<<0<<endl;
    }
}



Measured memory_bytes: 6528
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()
X = sorted(LIST())

if N >= M:
	print(0)
else:
	L = [0] * (M-1)
	for i in range(M-1):
		L[i] = X[i+1]-X[i]
	L.sort()
	print(sum(L[:(M-N)]))


Measured memory_bytes: 15044
s=list(input())
m=642
for i in range(len(s)-2):
    if abs(100*int(s[i])+10*int(s[i+1])+int(s[i+2])-753) < m:
        m=abs(100*int(s[i])+10*int(s[i+1])+int(s[i+2])-753)

print(m)
        


Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

int main() {
  ll n;
  cin >> n;
  map<ll,ll> odd;
  map<ll,ll> even;
  for(ll i=0;i<n;i++) {
    ll temp;
    cin >> temp;
    if(i%2) {
      odd[temp]++;
    }
    else {
      even[temp]++;
    }
  }
  priority_queue<pll> o,e;
  o.push(pll(0,0));
  e.push(pll(0,0));
  for(auto p:odd) {
    o.push(pll(p.second,p.first));
  }
  for(auto p:even) {
    e.push(pll(p.second,p.first));
  }
  ll ans=n;
  if(o.top().second==e.top().second) {
    ll o1=o.top().first,e1=e.top().first;
    o.pop();e.pop();
    ll o2=o.top().first,e2=e.top().first;
    ans=min(ans-o1-e2,ans-o2-e1);
  }
  else {
    ans-=o.top().first+e.top().first;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8824
#include <bits/stdc++.h>
using namespace std;
int main(){
    char c;
    cin>>c;
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')
        cout<<"vowel"<<"\n";
    else
        cout<<"consonant"<<"\n";
    return 0;
}



Measured memory_bytes: 256
s=input()
n=len(s)
a=[]
b=[]
for i in range(n//2):
    a.append(s[i])
i=0
for i in range(n//2):
    b.append(s[n-1-i])
c=0
for i in range(n//2):
    if a[i]==b[i]:
        pass
    else:
        c+=1
print(c)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    int A[3][3],n,a;
    bool X[3][3];
    REP(i,3)REP(j,3){X[i][j]=false; cin>>A[i][j];}
    cin>>n;
    REP(i,n){
        cin>>a;
        REP(i,3){
            REP(j,3){
                if(a==A[i][j]) X[i][j]=true;
            }
        }
    }
    string ans="No";
    REP(i,3) if(X[i][0]&&X[i][1]&&X[i][2]) ans="Yes";
    REP(i,3) if(X[0][i]&&X[1][i]&&X[2][i]) ans="Yes";
    if(X[0][0]&&X[1][1]&&X[2][2]) ans="Yes";
    if(X[0][2]&&X[1][1]&&X[2][0]) ans="Yes";
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int i,a=0;
    int sample[28];
    int flag[31];
    int ans[2];
    for(i=0;i<31;i++){
        flag[i]=0;
    }
    for(i=0;i<28;i++){
        scanf("%d",&sample[i]);
        flag[sample[i]]=1;
    }

    for(i=1;i<31;i++){
        if(flag[i]==0){
            ans[a]=i;
            a++;
        }
    }

    printf("%d\n%d\n",ans[0]<ans[1]?ans[0]:ans[1],ans[0]<ans[1]?ans[1]:ans[0]);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define maxn 202333
using namespace std;
char a[maxn];
int main() {
	int n;
	scanf("%d", &n);
	scanf("%s", a + 1);
	int ans = 0;
	{
		int i = 1, j = n;
		while(i < j) {
			while(a[i] == 'R') ++i;
			while(a[j] == 'W') --j;
			if(i < j) {
				swap(a[i], a[j]);
				++ans;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

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


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

   int n; cin >> n;
   int ans=0;
   rep(i,1,(n+1))ans+=i;
   cout << ans << endl;
}






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


int main() {
    int n, d, x,z;
    cin >> n >> d >> x;
    int a[ n ];
    for (int i = 0; i < n; i++)cin >> a[i];
    for (int j = 0; j < n; j++) {
        int k = 0;
        while (k*a[j] + 1 <= d) {
            z++;
            k++;

        }
    }
    cout << z+x << endl;
    return 0;
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  char c;cin >> c;
  c = c+1;
  cout << c << endl;
  return 0;
}


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

int main() {
  long N, M, cnt, price;
  cin >> N >> M;
  pair<long, long> AB[N];
  for(int i = 0; i < N; i++) {
    cin >> AB[i].first >> AB[i].second;
    AB[i].second *= -1;
  }
  sort(AB, AB + N);
  for(int i = 0; i < N; i++) AB[i].second *= -1;
  
  for(int i = 0; i < N; i++) {
    cnt += AB[i].second;
    price += AB[i].first * AB[i].second;
    if(cnt == M) break;
    else if(cnt > M) {
      price -= (cnt - M) * AB[i].first;
      break;
    }
  }
  cout << price;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 12800;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)
#define all(x) x.begin(), x.end()

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int k, x;
	cin >> k >> x;
	cout << (k * 500 >= x ? "Yes" : "No") << endl;
}		


Measured memory_bytes: 384
#pragma GCC optimize "trapv"
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,a,n) for(int i=a;i<n;i++)
#define all(v) v.begin(),v.end()
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
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)
int minimumChar(string S1, string S2) 
{ 
    // Get the sizes of both strings 
    int n = S1.size(), m = S2.size(); 
  
    int ans = INT_MAX; 
  
    // Traverse the string S2 
    for (int i = 0; i < m - n + 1; i++) { 
        int minRemovedChar = 0; 
  
        // From every index in S2, check the number of 
        // mis-matching characters in substring of 
        // length of S1 
        for (int j = 0; j < n; j++) { 
            if (S1[j] != S2[i + j]) { 
                minRemovedChar++; 
            } 
        } 
  
        // Take minimum of prev and current mis-match 
        ans = min(minRemovedChar, ans); 
    } 
  
    // return answer 
    return ans; 
} 
int main()
{
    fio;
    int t=1;
    //cin>>t;
    while(t--)
    {
        string s,t;
        cin>>s>>t;
        cout<<minimumChar(t,s)<<endl;
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  st S;
  ll k;
  cin >> S >> k;
  ll z=S.size();
  vector<st> s(k);
  bool b;
  rep(i,z){
    st t="";
    rep(j,min(k,z-i)){
      t+=S[i+j];
      b=false;
      rep(x,k){
        if(t==s[x]){
          b=true;
        }
      }
      if(!b){
        if(s[0]==""||s[0]>t){
          if(k!=1){
            per(i,k-2){
              s[i+1]=s[i];
            }
          }
          s[0]=t;
        }
        else if(k>=2&&(s[1]==""||s[1]>t)){
          if(k!=2){
            per(i,k-3){
              s[i+2]=s[i+1];
            }
          }
          s[1]=t;
        }
        else if(k>=3&&(s[2]==""||s[2]>t)){
          if(k!=3){
            per(i,k-4){
              s[i+3]=s[i+2];
            }
          }
          s[2]=t;
        }
        else if(k>=4&&(s[3]==""||s[3]>t)){
          if(k!=5){
            per(i,k-5){
              s[i+4]=s[i+3];
            }
          }
          s[3]=t;
        }
        else if(k>=5&&(s[4]==""||s[4]>t)){
          s[4]=t;
        }
      }
    }
  }
  cout << s[k-1] << endl;
}

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

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

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

def main():
    n,k = readInts()
    sum_ = 0
    l = []
    for i in range(n):
        a,b = readInts()
        l.append([a,b])
    l = sorted(l,key = lambda x:x[0])
    for a,b in l:
        sum_ += b
        if sum_ >= k:
            print(a)
            exit()


if __name__ == '__main__':
  main()


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

using ll=long long;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
  int n=in(),r=0;
  char s;
  for (int i=0;i<n;i++){
    cin >> s;
    if (s=='R') r++;
  }
  if (r>n-r) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int H[300],W[300],sum=0,i,j,k;

  while(1){
    scanf("%d %d",&H[sum],&W[sum]);

    if(H[sum] == 0 && W[sum] == 0)
      break;
    sum++;
  }

  for(i=0; i<sum; i++){
    for(j=0; j<H[i]; j++){
      for(k=0; k<W[i]/2; k++){
	if(j % 2 == 0)
	  printf("#.");
	else
	  printf(".#");
      }
      if(W[i] % 2 != 0 && j % 2 == 0)
	printf("#\n");
      else if(W[i] % 2 != 0 && j % 2 != 0)
	printf(".\n");
      else
	printf("\n");
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , K;
  cin >> N;
  cin >> K;
  int num = 1;
  for (int i = 0; i < N; i++) {
    if (num * 2 <= num + K) {
      num *= 2;
    } else {
      num += K;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 3568
import java.util.*
import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 1000000007L

fun main() {
	abc000X()
}

fun abc000X() {
	val n = int()
	val a = list {toLong()}
	val b = LongArray(n) {a[it]}
	for(i in 1 until n)
		b[i] += b[i-1]

	(0..n-2).map {(b[n-1]-b[it])%mod*a[it]%mod}
			.reduce {o,p-> (o+p)%mod}
			.let {println(it)}
}


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

using namespace std;

int main() {
	int n, w;
	cin >> n >> w;
	int* value = new int[n];
	int* weight = new int[n];
	int** scoa = new int*[n+1];
	for (int i = 0;i <= n;i++) {
		scoa[i] = new int[w + 1];
	}
	for (int i = 0;i < w + 1;i++) {
		scoa[0][i] = 0;
	}
	for (int i = 0;i < n + 1;i++) {
		scoa[i][0] = 0;
	}

	for (int i = 0;i < n;i++) {
		cin >> value[i] >> weight[i];
	}
	for (int i = 1;i <= n;i++) {
		for (int j = 1;j <= w;j++) {
			if (j - weight[i - 1] >= 0) {
				scoa[i][j] = max(scoa[i - 1][j], value[i - 1] + scoa[i - 1][j - weight[i - 1]]);
			}
			else {
				scoa[i][j] = scoa[i - 1][j];
			}
			
		}
	}
	cout << scoa[n][w] << endl;
}


Measured memory_bytes: 7040