akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int main() {
    while (1) {
        int n, m, h, k;
        cin >> n >> m >> h >> k;
        if (!n) return 0;
        vector<vector<pair<P, int>>> edge(n * (h + 1));
        for (int i = 0; i < m; ++i) {
            int a, b, c, d, e;
            cin >> a >> b >> c >> d >> e;
            --a;
            --b;
            --e;
            for (int j = 0; j + d <= h; ++j) {
                edge[a * (h + 1) + j].push_back(make_pair(P(c, b * (h + 1) + j + d), e));
                edge[b * (h + 1) + j].push_back(make_pair(P(c, a * (h + 1) + j + d), e));
            }
        }
        int s, t, p;
        cin >> s >> t >> p;
        --s;
        --t;
        vector<int> pass(1 << k, M);
        pass[0] = 0;
        for (int i = 0; i < p; ++i) {
            int l, d;
            cin >> l >> d;
            int a = 0;
            for (int j = 0; j < l; ++j) {
                int b;
                cin >> b;
                --b;
                a |= 1 << b;
            }
            pass[a] = min(pass[a], d);
        }
        for (int i = 1; i < (1 << k); ++i)
            for (int j = i + 1; j < (1 << k); ++j)
                pass[i | j] = min(pass[i | j], pass[i] + pass[j]);

        int ans = M;
        for (int i = 0; i < (1 << k); ++i) {
            if (pass[i] == M) continue;
            priority_queue<P, vector<P>, greater<P>> q;
            vector<int> dis(n * (h + 1), M);
            for (int j = 0; j <= h; ++j) {
                dis[s * (h + 1) + j] = 0;
                q.push(P(0, s * (h + 1) + j));
            }
            while (!q.empty()) {
                P pp = q.top();
                q.pop();
                for (auto a : edge[pp.second]) {
                    int d = pp.first;
                    if (!((i >> a.second) & 1))
                        d += a.first.first;
                    if (dis[a.first.second] > d) {
                        dis[a.first.second] = d;
                        q.push(P(d, a.first.second));
                    }
                }
            }
            ans = min(ans, dis[t * (h + 1) + h] + pass[i]);
        }
        cout << (ans == M ? -1 : ans) << "\n";
    }
}



Measured memory_bytes: 3484
import java.util.*;
import java.lang.*;

public class Main {
    static boolean isPrime(int x) {
        for(int i = 2; i <= Math.sqrt(x); i++) {
            if(x % i == 0) return false;
        }
        return true;
    }

    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n  = sc.nextInt();
        int flag = 0, sum = 0;
        while (flag  < n) {
            if(isPrime(sc.nextInt())) sum++;
            flag++;
        }
        System.out.println(sum);
    }
}

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

using namespace std;

typedef long long ll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 1; i < n; i++) a[i] += a[i - 1];
	ll ans1 = 0, d = 0;
	for (int i = 0; i < n; i++) {
		ll cur = a[i] + d, tmp;
		if (i % 2 == 0) {
			tmp = max(0LL, 1 - cur);
			ans1 += tmp;
			d += tmp;
		} else {
			tmp = max(0LL, cur + 1);
			ans1 += tmp;
			d -= tmp;
		}
	}
	ll ans2 = 0;
	d = 0;
	for (int i = 0; i < n; i++) {
		ll cur = a[i] + d, tmp;
		if (i % 2 == 1) {
			tmp = max(0LL, 1 - cur);
			ans2 += tmp;
			d += tmp;
		} else {
			tmp = max(0LL, cur + 1);
			ans2 += tmp;
			d -= tmp;
		}
	}

	cout << min(ans1, ans2) << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static String S;
    static int K;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        S = sc.next();
        K = sc.nextInt();

        System.out.println( solve() );
    }

    static String solve() {
        int rest = K;
        char[] chars = S.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            char c = chars[i];
            if( c == 'a' ) continue;

            int k = 26 - (c - 'a');
            if( rest >= k ) {
                rest -= k;
                chars[i] = 'a';
            }
        }

        char last = chars[chars.length - 1];
        chars[chars.length - 1] = (char)(last + (rest%26));
        return new String(chars);
    }

    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}



Measured memory_bytes: 23124
n, m = gets.chomp.split(' ').map(&:to_i)
xs = gets.chomp.split(' ').map(&:to_i)

if n >= m
  puts 0
elsif n == 1
  puts xs.max - xs.min
else
  xs = xs.sort
  ds = {}
  (m-1).times do |i|
    ds[i] = xs[i+1] - xs[i]
  end
  ds = ds.sort { |(k1, v1), (k2, v2)| v2 <=> v1 }
  ds = ds.slice(0, n-1).sort { |a, b| a[0] <=> b[0] }
  pre = 0
  res = 0
  n.times do |i|
    if i == 0
      res += xs.slice(pre..ds[i][0]).max - xs.slice(pre..ds[i][0]).min
      pre = ds[i][0]
    elsif i < n - 1
      res += xs.slice((pre + 1)..ds[i][0]).max - xs.slice((pre + 1)..ds[i][0]).min
      pre = ds[i][0]
    else
      res += xs.slice((pre + 1)..(xs.size - 1)).max - xs.slice((pre + 1)..(xs.size - 1)).min
    end
  end
  puts res
end

Measured memory_bytes: 26648
import collections
def main():

    S = list(input())[::-1]
    T = list(input())[::-1]
    ary = []


    c = collections.Counter(S)
    if len(S) < len(T):
        print('UNRESTORABLE')
        return

    # if c['?'] == len(S):
    #     if len(S) == len(T):
    #
    #         print(''.join(T))
    #         return
    #     else:
    #         print('UNRESTORABLE')
    #         return
    else:
        for s_left in range(len(S)):
            s_l = s_left
            flg = True
            tmp = S[::1]
            for t_left in range(len(T)) :
                if s_l < len(S) and (S[s_l] == T[t_left] or S[s_l] == '?'):
                    tmp[s_l] = T[t_left]
                    s_l += 1
                    continue
                else:
                    flg = False
                    break
            if flg:
                ans_t = tmp[::-1]
                ans = ''
                for i in range(len(S)):
                    if ans_t[i] == '?':
                        ans += 'a'
                    else:
                        ans += ans_t[i]
                # print(ans)
                # return
                ary.append(ans)

        if len(ary) == 0:

            print('UNRESTORABLE')
            return
        ary.sort()
        print(ary[0])

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>

int main(void){
  int x, y;
  int i, j;
  while(1){
    scanf("%d %d", &x, &y);
    if(x==0 && y==0)break;
    for(i=0; i<x; i++){
      for(j=0; j<y; j++){
        if(i==0 || i==x-1 || j==0 || j==y-1){
          printf("#");
        }else{
          printf(".");
        }
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2692
#include<cstdio>
#include<cmath>
using namespace std;
long long a[200001];
int main()
{
	int n,i;
	scanf("%lld",&n);
	long long sum2=0;
	for(i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		sum2+=a[i];
	}
	long long sum1=a[0];
	sum2-=a[0];
        long long x_y=abs(sum1-sum2);
	long long temp;
	for(i=1;i<n-1;i++)
	{
		sum1+=a[i];
		sum2-=a[i];
		temp=abs(sum1-sum2);
		if(temp<x_y)
			x_y=temp; 
	}
	printf("%lld",x_y);
	return 0;
}

Measured memory_bytes: 1664
N = int(input())
S = input()

rnum = 0
lnum = 0

for i in S:
  if i == ")":
    if lnum > 0:
      lnum -= 1
    else:
      rnum += 1
  
  else:
    lnum += 1
    
ans = ""

for i in range(rnum):
  ans += "("
ans += S

for i in range(lnum):
  ans += ")"
  
print (ans)

Measured memory_bytes: 3060
#include <stdio.h>


int main() {
	int r, g, b, c,d,e, n, j, k, l,z=0;

	scanf("%d %d %d %d", &r, &g, &b, &n);
	j = n / r;
	k = n / g;
	l = n / b;
	
	for (c = 0; c <= j;c++) {
		for (d = 0; d <= k;d++) {
			
				if ((n-r * c - g * d)%b==0 && (n-r * c - g * d)>=0)
					z++;
			
		
		}
	}



	printf("%d", z);

	return 0;

}

Measured memory_bytes: 128
// 2020-09-13 21:19:27
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
const ll inf = 1e18;
void answer() {
  int n;
  cin >> n;
  vector<ll> x(n), y(n);
  ll maxz = -inf, minz = inf, maxw = -inf, minw = inf;
  rep(i, n) {
    cin >> x[i] >> y[i];
    chmax(maxz, x[i] - y[i]);
    chmin(minz, x[i] - y[i]);
    chmax(maxw, x[i] + y[i]);
    chmin(minw, x[i] + y[i]);
  }
  ll ans = 0;
  chmax(ans, maxz - minz);
  chmax(ans, maxw - minw);
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;

void bfs(vector<vector<pll> > &G, vll &distW, vector<bool> &checked, ll s){
    queue<ll> que;
    que.push(s);
    distW[s] = 0;
    checked[s] = true;
    while(!que.empty()){
        ll cur;
        cur = que.front(); que.pop();
        for(ll i=0; i< G[cur].size(); i++){
            ll u = G[cur][i].first, val = G[cur][i].second;
            if(!checked[u]){
                checked[u] = true;
                distW[u] = distW[cur] + val;
                que.push(u);
            }
        }
    }
}

void solve(long long N, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c, long long Q, long long K, std::vector<long long> x, std::vector<long long> y){
    vector<vector<pll> > G(N);
    for(ll i=0; i< N-1; i++){
        G[a[i]-1].push_back(pll(b[i]-1, c[i]));
        G[b[i]-1].push_back(pll(a[i]-1, c[i]));
    }
    vll distW(N, 0);
    vector<bool> checked(N, false);
    bfs(G, distW, checked, K-1);
    for(ll i=0; i< Q; i++){
        cout << distW[x[i]-1] + distW[y[i]-1] << endl;
    }
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N-1);
    std::vector<long long> b(N-1);
    std::vector<long long> c(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
    }
    long long Q;
    scanf("%lld",&Q);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> x(Q);
    std::vector<long long> y(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(N, std::move(a), std::move(b), std::move(c), Q, K, std::move(x), std::move(y));
    return 0;
}


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

int main(){
    long long a, b, k;
    cin >> k;
    cin >> a >> b;
    if(a / k == b / k){
        if(a % k == 0 || b % k == 0) cout << "OK" << endl;
        else cout << "NG" << endl;
    }
    else cout << "OK" << endl;
    return 0;
}

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

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

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

  int n=s.size();
  int ans=1000;
  
  rep(i,n){
    char check = s.at(i);
    int maxstep = i;
    int last = i;
    for(int j=i; j<n; j++){
      if(s.at(j)==check){
        maxstep = max(maxstep, j-last-1);
        last = j;
      }
    }
    maxstep = max(maxstep, n-last-1);
    //cout << check << " "  << maxstep << " " << last << endl;
    ans = min(ans, maxstep);
  }

  cout << ans;
}

Measured memory_bytes: 3620
n=int(input())

lst=[0 for i in range(n+1)]

for x in range(1,int(n**0.5)):
    for y in range(1,x+1):
        if x**2+y**2+(x+y+1)**2+1>2*n : break
        for z in range(1,y+1):
            work=(x**2+y**2+z**2+(x+y+z)**2)//2
            if work>n: break
            if x==y and y==z : lst[work]+=1
            elif x==y or y==z or x==z : lst[work]+=3
            else : lst[work]+=6

for w in lst[1:]:
    print(w)

Measured memory_bytes: 9600
n = int(input())
h_list = [int(e) for e in input().split(' ')]

dp_list = []
dp_list.append(0)  # はじめは0
dp_list.append(abs(h_list[1] - h_list[0]))

for idx in range(2, n):
    d1 = abs(h_list[idx] - h_list[idx - 2]) + dp_list[idx - 2]
    d2 = abs(h_list[idx] - h_list[idx - 1]) + dp_list[idx - 1]
    dp_list.append(d2 if d1 > d2 else d1)

print(dp_list[-1])


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

bool is_prime(int k)
{
	for(int j=2;j*j<=k;j++){
		if(k%j==0) {
			return false;
		}
	}
    return true;
}


int main()
{
    stringstream ss;
    // 入力
    int N;
    cin>>N;
    ll a[N+1];
    ll ans=0;
    for(int i=1;i<=N;i++){
    	cin>>a[i];
    	// cout<<a[i]<<endl;
    	while(a[i]%2==0){
    		// cout<<"even"<<endl;
    		ans++;
    		a[i]=a[i]/2;
    	}
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ProblemA solver = new ProblemA();
		solver.solve(1, in, out);
		out.close();
	}

	static class ProblemA {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			long u = in.nextInt();
			long v = in.nextInt();
			for (int i = 1; i < n; i++) {
				int a = in.nextInt();
				int b = in.nextInt();
				BigInteger A = BigInteger.valueOf(a);
				BigInteger B = BigInteger.valueOf(b);
				BigInteger U = BigInteger.valueOf(u);
				BigInteger V = BigInteger.valueOf(v);
				long x = Math.max(0, A.multiply(V).add(B).subtract(BigInteger.ONE).divide(B).subtract(U).longValue());
				// long x = Math.max(0, (a * v + b - 1) / b - u);
				while ((u + x) % a != 0) {
					++x;
				}
				long y = b * ((u + x) / a) - v;
				u += x;
				v += y;
			}
			out.println(u + v);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(in.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 11572
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;

int main() {
	string s,t;
	cin >> s>>t;
	if (s[0]==t[2]&&s[1]==t[1]&&s[2]==t[0]) {
	cout << "YES" << endl;
	}
	else
	cout << "NO" << endl;

	return 0;
}


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


/********************************************************************/
#define M1 1000000007
#define M2 998244353
#define ll long long
#define pll pair<ll,ll>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPR(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
/********************************************************************/
// const int mx = 1e7 + 5;
const double pi = 3.1415926535;
/********************************************************************/
//FAST IO//
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
const int mx = 1e5 + 5;
ll freq[mx] = {};

/********************************************************************/
int main() {
	FAST();
	ll n;
	cin >> n;
	ll ar[n] = {};
	for (int i = 0; i < mx; ++i) {
		freq[i] = 0;
	}
	for (int i = 0 ; i < n; i++) {
		cin >> ar[i];
		freq[ar[i]]++;
	}
	ll b, c, q;
	cin >> q;
	ll sum = 0 ;
	for (int i = 0 ; i < mx; i++) {
		sum += freq[i] * i;
	}
	while (q--) {
		cin >> b >> c;
		sum -= freq[b] * b;
		freq[c] += freq[b];
		sum += freq[b] * c;
		freq[b] = 0;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 5216
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[200101];
long long l[201015];
long long j[200101][2];

long long x,y,z,mod=1000000007;
string r;
//char r[2];

P u[1];
queue<int> q;
stack<int> s;
//set<int> s;
map<int,int> p;

vector<int> v;


bool as(P a,P b)
{
  return a.x<b.x;
}

void g2(int n,int m,int k)
{
  l[n]+=k;
  l[m+1]-=k;
}

void f2(int n,int m,int k)
{
  if(n<=m) g2(n,m,k);
  else g2(n,m+a,k);//g2(n,a-1,k),g2(0,m,k);
}

void g1(int n,int m)
{
  l[n]+=m-n+2;
  l[m+1]-=m-n+2;
  j[n][0]--;
  j[m+1][0]++;
  j[m+1][1]+=m-n+1;
}

void f1(int n,int m)
{
  if(n<=m) g1(n,m);
  else
  {
    //g1(n,a-1);
    //g1(0,m);
    g1(n,m+a);
  }
}

int main()
{
  scanf("%d %d",&b,&a);
  
  for(int t=1;t<=b;o[t]--,t++)
    scanf("%d",&o[t]);
  for(int t=2;t<=b;t++)
  {
    if(o[t-1]!=o[t])
    {
      f1((o[t-1]+1)%a,o[t]);
      f2((o[t]+1)%a,o[t-1],(o[t]-o[t-1]+a)%a);
    }
  }
  x=mod*mod;
  j[0][1]+=j[0][0];
  for(int t=1;t<a*2;t++)
    l[t]+=l[t-1],j[t][0]+=j[t-1][0],j[t][1]=j[t][1]+j[t-1][1]+j[t][0];
  for(int t=0;t<a;t++)
  {
    //printf("%lld %lld\n",l[t],l[t+a]);
    x=min(x,l[t]+j[t][1]+l[t+a]+j[t+a][1]);
    //printf("%lld ",l[t]+j[t][1]+l[t+a]+j[t+a][1]);
    //printf("%lld ",j[t][1]+j[t+a][1]);
  }
  printf("%lld",x);
}
//14





Measured memory_bytes: 5376
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

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

int main()
{
    int n;
    cin >> n;
    cout << (int)sqrt(n) * (int)sqrt(n) << endl;
}

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

const int MAX = 510000;
const int mod = 1000000007;

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

// 二項係数計算
ll 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;
}

//a^n (mod m)
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//mod mでの a の逆元を求める
ll modinv(ll a) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod; 
    if (u < 0) u += mod;
    return u;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n,a,b;
    cin>>n>>a>>b;
    COMinit();
    ll ans = modpow(2,n);
    ans += mod - 1;
    ans %= mod;
    ll ret = 1;
    for(int i=1;i<=max(a,b);i++){
        ret *= (n-i+1);
        ret %= mod;
        ret *= inv[i];
        ret %= mod;
        if(i==a || i==b){
            ans += mod -ret;
            ans %= mod;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 12288
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++) a[i] = sc.nextInt();
        Arrays.sort(a);
        int ans = 0;
        for(int i=0;i<n;i++){
            x -= a[i];
            if(x<0) break;
            else ans++;
        }
        if(x>0) ans--;
        PrintWriter out = new PrintWriter(System.out);
        out.println(ans);
        out.flush();
    }
}


Measured memory_bytes: 22996
from math import sqrt

def g():
    _ = input()
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))

    f1 = lambda it: abs(it[0]-it[1])
    f2 = lambda it: (it[0]-it[1]) ** 2
    f3 = lambda it: abs(it[0]-it[1]) ** 3

    yield sum(map(f1, zip(x, y)))
    yield sqrt(sum(map(f2, zip(x, y))))
    yield sum(map(f3, zip(x, y))) ** (1/3)
    yield max(map(f1, zip(x, y)))

for n in g():
    print("{:.6f}".format(n))

Measured memory_bytes: 7912
#include <stdio.h>
#include <string.h>
#define max_order 500001
#define max_str 100

typedef struct{
  int key, left, right;
}Node;

Node tree[max_order];
int size;

void insert(int x){
  int p = 0;
  while(1){
    if(x < tree[p].key){
      if(tree[p].left == -1){
        tree[p].left = size;
        tree[size++].key = x;
        break;
      }else p = tree[p].left;
    }else{
      if(tree[p].right == -1){
        tree[p].right = size;
        tree[size++].key = x;
        break;
      }else p = tree[p].right;
    }
  }
}

void inorder(int p){
  if(tree[p].left != -1) inorder(tree[p].left);
  printf(" %d",tree[p].key);
  if(tree[p].right != -1) inorder(tree[p].right); 
}

void preorder(int p){
  printf(" %d",tree[p].key);
  if(tree[p].left != -1) preorder(tree[p].left);
  if(tree[p].right != -1) preorder(tree[p].right);
}

int find(int p, int x){
  if(tree[p].key == x) return 1;
  if(x < tree[p].key && tree[p].left != -1) if(find(tree[p].left, x)) return 1;
  if(tree[p].key < x && tree[p].right != -1) if(find(tree[p].right, x)) return 1;
  return 0;
}

int main(){
  int i;
  int n,sign;
  sign = 1;
  scanf("%d", &n);
  for(i=0;i<=n;i++) tree[i].key = tree[i].left = tree[i].right = -1;
  size = 0;
  while(n--){
    char str[max_str];
    scanf("%s", str);
    if(!strcmp(str, "insert")){
      int in;
      scanf("%d", &in);
      if(sign){
        tree[size++].key = in;
        sign = 0;
      }
      else insert(in);
    }else if(!strcmp(str, "find")){
      int in;
      scanf("%d", &in);
      printf("%s\n", (find(0, in) ? "yes" : "no"));
    }else{
      inorder(0);
      printf("\n");
      preorder(0);
      printf("\n");
    }
  }
  return 0;
}



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

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

const ll MOD = 1000000007;

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

    vector<vector<int>> dp(h+1, vector<int>(w, 0));

    dp[0][0] = 1;

    rep(i, h) rep(j, w) rep(l, 1<<(w-1)) {
        bool ok = true;
        rep(m, w-2) if ( ((l>>m) & 1) && ((l>>(m+1)) & 1) ) ok = false;
        if ( !ok ) continue;
        if ( j - 1 >= 0 && ((l>>(j-1)) & 1)  ) dp[i+1][j-1] = (dp[i+1][j-1] + dp[i][j]) % MOD; 
        else if ( j  < w - 1 && ((l>>j) & 1) ) dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j]) % MOD;
        else                                   dp[i+1][j]   = (dp[i+1][j]   + dp[i][j]) % MOD;
    }

    cout << dp[h][k-1] << endl;

    return 0;
}

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

using namespace std;
using int64 = long long;

int main() {
    string s, s_re = "";
    int q;
    cin >> s >> q;
    
    int d = 1;
    for (int i=0; i<q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            d *= -1;
            continue;
        }

        int f;
        char c;
        cin >> f >> c;
        f = f==1?-1:1;

        if (d*f > 0)
            s += c;
        else
            s_re += c;
    }

    string ans;
    if (d > 0) {
        reverse(s_re.begin(), s_re.end());
        ans = s_re + s;
    }
    else {
        reverse(s.begin(), s.end());
        ans = s + s_re;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1280
n = float(input())
a = []
a.append([0,0,0])
for i in range(int(n)):
    in1, in2, in3 = map(float, input().split())
    a.append([in1,in2,in3])

for j in range(int(n)):
    i = j+1
    point_dif = abs(a[i][1]-a[i-1][1]) + abs(a[i][2] - a[i-1][2])
    time_dif = a[i][0]-a[i-1][0]
    if time_dif %2 != point_dif % 2:
        print('No')
        exit()
    if point_dif > time_dif:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 22416
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        char[] T = sc.next().toCharArray();
        int ans = 0;
        for(int i = 0; i < S.length; i++) if(S[i] == T[i]) ans++;
        System.out.println(ans);
    }
}


Measured memory_bytes: 21588
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>

typedef long long int llint;
typedef std::pair<char, llint> charpos;

int main(void){

  std::string s, t;
  std::cin >> s >> t;

  std::set<charpos> database;
  for(int i=0; i<2; i++){
    for(int j=0; j<s.size(); j++){
      database.insert(std::make_pair(s[j], j+i*s.size()+1));
    }
  }

  llint search_start = 0;
  llint total = 0;
  for(int i=0; i<t.size(); i++){
    const auto next = database.upper_bound(std::make_pair(t[i], search_start));
    //std::cout << next->first << " " << next->second << std::endl;
    if(next->first != t[i]){
      std::cout << -1 << std::endl;
      return 0;
    }
    total += next->second - (search_start); 
    search_start = next->second % s.size();
  }
  std::cout << total << std::endl;

  return 0;
}


Measured memory_bytes: 12928
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "queue"

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

int main()
{
  int n;
  cin >> n;
  ll a[3010];
  ll ans = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    ans += a[i] - 1;
  }
  cout << ans << "\n";
}

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

def gcd(x, y):
    if x < y:
         x, y = y, x
    while x % y != 0:
        x, y = y, x % y
    return y

l = [0 for _ in range(n)]
r = [0 for _ in range(n)]
for i in range(0, n - 1):
    if i == 0:
        l[i] = a[0]
    else:
        l[i] = gcd(l[i - 1], a[i])

for i in range(n - 1, 0, -1):
    if i == n - 1:
        r[i] = a[i]
    else:
        r[i] = gcd(a[i], r[i + 1])

max = 0
for i in range(n):
    if i == 0:
        gcd_i = r[i + 1]
    elif i == n - 1:
        gcd_i = l[i - 1]
    else:
        gcd_i = gcd(l[i - 1], r[i + 1])
    if max < gcd_i:
        max = gcd_i

print(max)

Measured memory_bytes: 14488
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 100005;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* struct for mod Calculation*/
struct mint {
    ll x;
    mint(ll x = 0):x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
/* global variables */
/* function */
/* global variables */
/* function */
/* main */
int main(){
    string L;
    cin >> L;
    
    vector<vector<mint> > dp(2, vector<mint>(MAX, (mint)0));

    int upper = L.size();
    dp[0][0] = 1;
    dp[1][0] = 2;
    for (int k = 1; k < upper; k++) {
        dp[0][k] += dp[0][k - 1] * 3;
        if (L[k] == '1') {
            dp[0][k] += dp[1][k - 1];
            dp[1][k] += dp[1][k - 1] * 2;
        }
        else {
            dp[1][k] += dp[1][k - 1];
        }
    }

    cout << dp[0][upper - 1] + dp[1][upper - 1] << '\n';
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N, M; cin >> N >> M;
		vector<vector<UL>> E(N);
		rep(i, M) {
			UL a, b; cin >> a >> b; a--; b--;
			E[a].push_back(b);
			E[b].push_back(a);
		}
		vector<UL> F(N);
		vector<UL> P1, P2;
		UL p = 0; F[0] = 1;
		while (p != -1) {
			bool ok = false;
			for (UL e : E[p]) {
				if (F[e] == 0) { ok = true; p = e; }
			}
			if (!ok) break;
			P1.push_back(p); F[p] = 1;
		}
		p = 0;
		while (p != -1) {
			bool ok = false;
			for (UL e : E[p]) {
				if (F[e] == 0) { ok = true; p = e; }
			}
			if (!ok) break;
			P2.push_back(p); F[p] = 1;
		}
		reverse(P1.begin(), P1.end());
		cout << (P1.size() + P2.size() + 1) << endl;
		rep(i, P1.size()) { cout << (P1[i] + 1) << " "; }
		cout << 1;
		rep(i, P2.size()) { cout << " " << (P2[i] + 1); }
		cout << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 7160
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>

using namespace std;
using ll = long long;

int main()
{
	int N, M, C;
	cin >> N >> M >> C;
	int B[M];
	for (int i = 0; i < M; i++)
		cin >> B[i];
	int A[N][M];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			cin >> A[i][j];
	}

	int res = 0;
	for (int i = 0; i < N; i++) {
		int tmp = 0;
		for (int j = 0; j < M; j++) {
			tmp += A[i][j] * B[j];
		}
		if (tmp + C > 0)
			res++;
	}

	cout << res << endl;

}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main ()
{
    int H,W;
    
    for(int i=0; ;i++)
    {
        cin>>H>>W;
        if(H==0 && W==0)break;
        
        for(int h=0;h<H;h++)
        {
            //奇数段目
            if(h%2==0)
            {
                for(int w=0;w<W;w++){
                    //左から奇数番目
                    if(w%2==0)cout<<"#";
                    //左から偶数番目
                    else cout<<".";
                }
                cout<<endl;
            }
            
            //偶数段目
            if(h%2==1)
            {
                for(int r=0;r<W;r++){
                    //左から奇数番目
                    if(r%2==0)cout<<".";
                    //左から偶数番目
                    else cout<<"#";
                }
                cout<<endl;
            }
        }
        cout<<endl;
        
        
    }
    return 0;
}


Measured memory_bytes: 3080
//ΔAGC033B
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 222222;
int n,m,k;
char s[N],t[N];
int main()
{
	int i,x,y,l,r,o;
	scanf("%d%d%d%d%d",&n,&m,&k,&x,&y);
	scanf("%s%s",s+1,t+1);
	o=0;
	l=1,r=n;
	for(i=k;i;i=i-1){
		if(t[i]=='U')
			r=min(n,r+1);
		if(t[i]=='D')
			l=max(1,l-1);
		if(s[i]=='U')
			l++;
		if(s[i]=='D')
			r--;
		if(l>r)
			break;
	}
	if(l<=x&&x<=r)
		o++;
	l=1,r=m;
	for(i=k;i;i=i-1){
		if(t[i]=='L')
			r=min(m,r+1);
		if(t[i]=='R')
			l=max(1,l-1);
		if(s[i]=='L')
			l++;
		if(s[i]=='R')
			r--;
		if(l>r)
			break;
	}
	if(l<=y&&y<=r)
		o++;
	if(o==2)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}

Measured memory_bytes: 640
r,g,b,n = map(int,input().split(" "))
cnt = 0
for i in range(n // r + 1):
    for j in range(n // g + 1):
        c = n - i * r - j * g
        if c < 0:
            break
        if c % b == 0:
             cnt += 1
print(cnt)


Measured memory_bytes: 2940
#include<iostream>
#include<complex>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	char s[110];
	cin >> s;
	rep(i, strlen(s) - 1) {
		if (s[i] == 'A'&&s[i + 1] == 'C') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
N, s, t = gets.chomp.to_i, gets.chomp, gets.chomp
str = Array.new(N + 1)
(N+1).times do |i|
  str[i] = s + t.slice(- i, i)
  if str[i].slice(-N, N) == t
    puts str[i].size
    exit
  end
end


Measured memory_bytes: 1788
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let n = it.next().unwrap().parse::<usize>().unwrap();
    let s = (0..n).map(|_| it.next().unwrap()).collect::<Vec<_>>();
    let mut res = 0;
    let mut cnt_a = 0;
    let mut cnt_b = 0;
    let mut check_ab = false;
    for &c in &s {
        res += c.matches("AB").count();
        let start_b = c.starts_with("B");
        let end_a = c.ends_with("A");
        if start_b && end_a {
            if check_ab {
                res += 1;
            } else {
                check_ab = true;
            }
        } else if start_b {
            cnt_b += 1;
        } else if end_a {
            cnt_a += 1;
        }
    }
    if check_ab {
        if cnt_a > 0 {
            res += 1;
            cnt_a -= 1;
        }
        if cnt_b > 0 {
            res += 1;
            cnt_b -= 1;
        }
    }
    res += std::cmp::min(cnt_a, cnt_b);
    println!("{}", res);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int h,w,n;cin>>h>>w>>n,h|w|n;){
		vvi grid(h,vi(w));
		rep(i,h) rep(j,w) cin>>grid[i][j];
		
		vvi dp(h+1,vi(w+1));
		dp[0][0]=n-1;
		rep(i,h) rep(j,w){
			dp[i+1][j]+=(dp[i][j]+!grid[i][j])/2;
			dp[i][j+1]+=(dp[i][j]+grid[i][j])/2;
		}
		
		int i=0,j=0;
		while(i<h && j<w){
			int di[]={1,0},dj[]={0,1};
			int ni=i+di[grid[i][j]+dp[i][j]&1];
			int nj=j+dj[grid[i][j]+dp[i][j]&1];
			i=ni,j=nj;
		}
		cout<<i+1<<' '<<j+1<<endl;
	}
	
	return 0;
}

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

typedef complex<double> Pt;
struct less_c{
    bool operator() (const Pt& a, const Pt& b){
        return a.imag()!=b.imag() ? a.imag()<b.imag() : a.real()<b.real();
    }
};
double cross(Pt a, Pt b){ //外積
    return a.real()*b.imag()-a.imag()*b.real();
}

int main(){
	int n;  cin >> n;
    vector<Pt> p(n);
    for(int i=0; i<n; i++){
        double x, y;   cin >> x >> y;
        p[i]={x,y};
    }
    sort(p.begin(),p.end(),less_c());

    vector<Pt> ch(2);  //convex hull
    for(int i=0; i<2; i++) ch[i]=p[i];
    for(int i=2; i<n; i++){
        for(int j=ch.size()-1; j>0; j--){
            if(cross(p[i]-ch[j],ch[j-1]-ch[j])<0){
                ch.erase(ch.begin()+j);
            }else{
                break;
            }
        }
        ch.push_back(p[i]);
    }
    
    int half=ch.size()-1;
    ch.push_back(p[n-2]);
    for(int i=n-3; i>=0; i--){
        for(int j=ch.size()-1; j>half; j--){
            if(cross(p[i]-ch[j],ch[j-1]-ch[j])<0){
                ch.erase(ch.begin()+j);
            }else{
                break;
            }
        }
        ch.push_back(p[i]);
    }
    ch.pop_back();

	cout << ch.size() << endl;
    for(Pt i : ch) cout << i.real() << " " << i.imag() << endl;
}


Measured memory_bytes: 6228
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions 

#endif


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

    int N, M; cin >> N >> M;
    vi A(N), B(N); REP(i, N)cin >> A[i] >> B[i];
    vector<pll> c;
    REP(i, N)c.push_back(pll(A[i], B[i]));
    sort(c.begin(), c.end());

    ll sum = 0;
    ll ans = 0;
    REP(i, N) {
        if (sum + c[i].second >= M) {
            ans += c[i].first * (M - sum);
            sum += (M - sum);
            break;
        } else {
            ans += c[i].first * c[i].second;
            sum += c[i].second;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.Scanner;

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

        int a[] = new int[26];
        Arrays.fill(a, 0);

        for (int i = 0; i < s.length(); i++) {
            a[s.charAt(i) - 'a'] = 1;
        }

        for (int i = 0; i < 26; i++) {
            if (a[i] == 0) {
                System.out.println((char)('a' + i));
                return;
            }
        }

        System.out.println("None");
    }
}


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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define repl(n) for (int l = 0; l < (n); l++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

int main() {
  int x[3];
  repi(3) cin >> x[i];
  sort(x, x + 3);
  cout << x[2] * 10 + x[1] + x[0] << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean end = false;
        while(sc.hasNextLine()){
            String[] str = sc.nextLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[2]);

            switch(str[1]){
            case "+":
                System.out.println(a + b);
                break;
            case "-":
                System.out.println(a - b);
                break;
            case "*":
                System.out.println(a * b);
                break;
            case "/":
                System.out.println(a / b);
                break;
            case "?":
                end = true;
                break;
            }
            if(end) break;
        }
    }

}

Measured memory_bytes: 26068
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val one, two, three = sc.nextInt
  var ans:String = "No"
  
  if (one==two && two==three && three==one) {
    ans = "No"
  } else if (one!=two && two!=three && three!=one) {
    ans = "No"
  } else {
    ans = "Yes"
  }
  println(ans)
}


Measured memory_bytes: 25420
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    long long dp[n];
    long long h[n];
    for(long long i=0;i<n;i++)
        cin>>h[i];
    long long c=0;
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    dp[2]=abs(h[2]-h[0]);
    for(long long i=3;i<n;i++)
    {
       
            // if(c==0 && j>=2){
            //     dp[i][j]=min(dp[i-1][j],dp[i-2][j]);
            //     c++;}
            // else if(c==0 && j==1){
            //     dp[i][j]=dp[0][1];
            //     c++;}
            
               
                    dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
                
            
        
    }
   cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
N,A,B,K=map(int,input().split())


def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans=0
for i in range(N+1):
    if (K-(A*i))%B==0:
        ans+=cmb(N,i,mod)*cmb(N,(K-(A*i))//B,mod)
print(ans%mod)

Measured memory_bytes: 100208
mass = input()
mass = list(mass)
count = 0

for i in range(0, len(mass)):

    try:
        if(mass[i] == mass[i+1]):
            mass[i+1] = (int(mass[i+1]) + 1) % 2
            mass[i+1] = str(mass[i+1])
            count += 1
    except IndexError:
        print(count)


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



struct Restaurant{
    string S;
    int P;
    int order;
    bool operator<(const Restaurant& right) const {
        return S == right.S ? P > right.P : S < right.S;
    }
};

int main(void)
{
    int N;
    cin >> N;
    
    Restaurant RestaurantArray[N];
    for (int i = 0; i < N; i++) {
        cin >> RestaurantArray[i].S >> RestaurantArray[i].P;
        RestaurantArray[i].order = i+1;
    }

    sort(RestaurantArray, RestaurantArray + N);

    for (int i = 0; i < N; i++) {
        cout << RestaurantArray[i].order << endl;
    }
}

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

int main()
{

	long long N, A, B, C, D, E;
	cin >> N >> A >> B >> C >> D >> E;
	cout << max({ (N - 1) / A, (N - 1) / B, (N - 1) / C, (N - 1) / D, (N - 1) / E }) + 5 << endl;

return 0;
}



Measured memory_bytes: 256