akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int B = 55556;
  vector<int> V(B,1);
  vector<int> P;
  //vector<int> R(5,0);
  V[0] = 0;
  for(int i=2;i<B;i++){
    if(V[i]==1){
      for(int k=2;k*i<B;k++){
        V[k*i]=0;
      }
      P.push_back(i);
      //R[i%5] ++;
    }
  }
  int N;cin >> N;
  int count = 0;
  for(int i=0;i<P.size();i++){
    if(P[i]%5==1){
      cout << P[i];
      count ++;
      if(count < N){
        cout << " ";
      }else{
        cout << endl;
        return 0;
      }
    }
  }
  //for(int r=0;r<5;r++){
  //  cout << r << " " << R[r] << endl;
  //}
}

Measured memory_bytes: 3644
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
using pll = pair<ll, ll>;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using ti3 = tuple<int, int, int>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
#pragma warning(disable:4996)
#define INF 1000000000000000.0
int main() {
	while (1) {
		int d, e;
		scanf("%d %d", &d, &e);
		if (d == 0 && e == 0)break;
		double ans = INF;
		for (int x = 0; x <= d; x++) {
			int y = d - x;
			double distance = sqrt(x*x + y*y);
			if (abs(e - distance) < ans)ans = abs(e - distance);
		}
		printf("%.6lf\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3232
open System

// prelude
let readStr () = stdin.ReadLine()

let read f () = readStr() |> f
let reads f () = readStr().Split() |> Array.map f

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let readPair f g () =
  let (a,b) = readStr().Split() |> pair
  (f a, g b)

let readTriple f g h () =
  let (a,b,c) = readStr().Split() |> triple
  (f a, g b, h c)

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let N = read int ()

seq { for _ in 1..N -> read string ()}
|> Set.ofSeq
|> Set.count
|> printfn "%d"

Measured memory_bytes: 62044
#include <iostream>
#include <string>

using namespace std;

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

    string s;
    cin >> s;
    char last = s.back();
    if (last == 's')
        s += "e";
    s += "s";
    cout << s;

    return 0;
}

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

int main(){
    const int mod = 1000000007;
    int H, W, K; cin >> H >> W >> K;
    vector<vector<int>> dp(H+1, vector<int>(W));
    dp[0][0] = 1;
    rep(h, H){
        rep(p, pow(2,W-1)){
            bool judge = true;
            rep(j, W-2){
                if((p>>j)&1 && (p>>(j+1))&1) judge = false;
            }
            if(!judge) continue;
            rep(j, W){
                if((p>>j)&1){
                    dp[h+1][j+1] += dp[h][j];
                    dp[h+1][j+1] %= mod;
                }
                else if(j > 0 && (p>>(j-1))&1){
                    dp[h+1][j-1] += dp[h][j];
                    dp[h+1][j-1] %= mod;
                }
                else{
                    dp[h+1][j] += dp[h][j];
                    dp[h+1][j] %= mod;
                }
            }
        }
    }
    cout << dp[H][K-1] << endl;
    return 0;
}


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

int main(){
    int n, y;cin>>n>>y;
    for (int i=0;i<=n;i++){
        int temp_1 = y - 10000 * i;
        for (int j=0;j<=n-i;j++){
            int temp_2 = temp_1 - 5000 * j;
            if (1000 * (n-i-j) == temp_2){
                cout << i << " " << j << " " << n-i-j << endl;
                return 0;
            }

        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;

}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
l=[False]*9
for i in a:
    if i<3200:
        l[i//400]=True
    else:
        l[8]+=1
if sum(l[:8])>0:
    print(sum(l[:8]),sum(l))
else:
    print(1,sum(l))

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main()
{
    long long n,c[5];
    
    for(int i=0;i<5;i++){c[i]=0;}
    char name[11];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%s",name);
        if(name[0]=='M')c[0]++;
        else if(name[0]=='A')c[1]++;
        else if(name[0]=='R')c[2]++;
        else if(name[0]=='C')c[3]++;
        else if(name[0]=='H')c[4]++;
    }
    long long x=0;
    for(int i=0;i<5;i++)
    {
        for(int j=0;j<5;j++)
        {
            for(int k=0;k<5;k++)
            {
                if(i!=j&&j!=k&&k!=i)
                    x+=c[i]*c[j]*c[k];
            }
        }
    }
    cout<<x/6<<endl;
    return 0;
}


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

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> color(N);
    for (int i = 0; i < N; i++) {
        cin >> color[i];
    }
    
    vector<vector<int>> ans(H, vector<int>(W));
    
    int i = 0;
    for (int h = 0; h < H; h++) {
        if (h % 2 == 0) {
            for (int w = 0; w < W; w++) {
                ans[h][w] = i + 1;
                color[i]--;
                if (color[i] <= 0) {
                    i++;
                }
            }
        } else {
            for (int w = W - 1; w >= 0; w--) {
                ans[h][w] = i + 1;
                color[i]--;
                if (color[i] <= 0) {
                    i++;
                }
            }
        }
    }
    
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            cout << ans[h][w] << " ";
        }
        cout << endl;
    }
    return 0;
}
    

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back

#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const double pi=acos(-1);
void solve()
{
    double r;
    cin>>r;
    double ans=pi*2*r;
    printf("%.2f\n",ans);
}
int main()
{
	//int _;cin>>_;while(_--)
	solve();
}


Measured memory_bytes: 3712
N = int(input())
l_p = list(map(int,input().split()))
count=0
for n in range(N-2):
    if (l_p[n]< l_p[n+1] and l_p[n+1]<l_p[n+2]) or (l_p[n+2]<l_p[n+1] and l_p[n+1]<l_p[n]):
        count += 1
print(count)

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

const int dx[] = {0, 0, -1, 1};
const int dy[] = {1, -1, 0, 0};
int W, H;
char board[30][30];

int dfs(int y, int x) {
   board[y][x] = '#';
   int ret = 1;
   for (int i = 0; i < 4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx >= 0 && nx < W && ny >= 0 && ny < H && board[ny][nx] == '.') {
         ret += dfs(ny, nx);
      }
   }
   return ret;
}

int main() {
   while (cin >> W >> H, W) {
      for (int i = 0; i < H; i++) {
         cin >> board[i];
      }
      for (int i = 0; i < H; i++) {
         for (int j = 0; j < W; j++) {
            if (board[i][j] == '@') {
               cout << dfs(i, j) << endl;
            }
         }
      }
   }

   return 0;
}


Measured memory_bytes: 2984
program task_C;
    const A='dream';
    const B='dreamer';
    const C='erase';
    const D='eraser';
    var S:Ansistring;
    function delete(_:Ansistring;_l:longint):boolean;
    begin
        if _l=0 then exit(true);
        if Copy(_,_l-4,5)=A then exit(delete(_,_l-5));
        if Copy(_,_l-4,5)=C then exit(delete(_,_l-5));
        if Copy(_,_l-5,6)=D then exit(delete(_,_l-6));
        if Copy(_,_l-6,7)=B then exit(delete(_,_l-7));
        exit(false);
    end;
begin
    readln(S);
    if delete(S,length(S))=true then writeln('YES') else writeln('NO');
end.

Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;



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

	if ( n % k == 0 )
	{
		cout << 0 << endl;
	}
	else
	{
		cout << 1 << endl;
	}

	return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    const int p = 2019;

    vector<int> modcnt(p, 0);
    int cur = 0, coef = 1;
    modcnt[cur]++;
    for (int i = 0; i < n; i++) {
        cur = (cur + coef * (s[n - i - 1] - '0') % p) % p;
        coef = coef * 10 % p;
        modcnt[cur]++;
    }

    int ans = 0;
    for (int i = 0; i < p; i++) {
        ans += modcnt[i] * (modcnt[i] - 1) / 2;
    }
    cout << ans << endl;
}


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

int main() {
    long long N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i], --A[i];

    deque<int> a; // 繰り返しの部分
    vector<bool> seen(N, false); // 一度見たかどうか
    int cur = 0;
    while (true) {
        // 一度通った頂点を見つけたときの処理
        if (seen[cur]) {
            while (a[0] != cur) {
                // 最初の余計な数手分を除去する
                --K;
                a.pop_front();

                // 繰り返す前に K が限界になったらリターン
                if (K == 0) {
                    cout << a[0]+1 << endl;
                    return 0;
                }
            }
            break;
        }
        // 最初は愚直にシミュレーションしつつ、履歴をメモしていく
        a.push_back(cur);
        seen[cur] = true;
        cur = A[cur];
    }
    cout << a[K % a.size()]+1 << endl;
}

Measured memory_bytes: 4772
module AtCoder

    export readline

    function readline(T)
        return Base.parse(T, Base.readline(Base.stdin))
    end

end


module ABC162

    import Main.AtCoder
    export task_a

    function evaluate_task_a(target_integer::Core.Int64)
        return Base.in( target_integer, Base.digits( AtCoder.readline(Core.Int64) ) ) ? "Yes" : "No"
    end
    
    function execute_task_a()
        Base.println(evaluate_task_a(7))
    end

end


ABC162.execute_task_a()

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

#define deb(x)        cerr << #x << " = " << x << "\n";
#define deb2(x, y)    cerr << #x << " = " << x << ", " << #y << " = " << y << "\n";
#define deb3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << "\n";

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F  first
#define S  second

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;  

void solve() {
    int n;
    cin >> n;
    while (n--) {
        cout << "ACL";
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    ll tc = 1;
    //cin >> tc;

    while(tc--) {
        solve();
        cout << '\n';
    }

    return 0;
}



Measured memory_bytes: 3652
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int s = b / a;
	if (s >= c)
		cout << c << endl;
	else
		cout << s << endl;
}

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

typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
  
ll N,M;
ll A;

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

    rep(i,0,M){
        cin>>A;
        N-=A;
        if(N<0)break;
    }
    if(N<0)cout<<"-1";
    else cout<<N;
    return 0;
}

Measured memory_bytes: 3636
import java.util.*;
import java.math.*;
public class Main{

	static int INF = 2 << 27;
	static int m;
	static int n;
	static int k;
	static int d;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if(n == 0) break;
			Data[] data = new Data[n];
			for(int i = 0; i < n; i++) {
				data[i] = new Data(sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt());
			}
			for(int i = 0; i < n; i++) {
				for(int j = i + 1; j < n; j++) {
					boolean check = check(data,i,j);
					if(check) data[j].up |= (1 << i);
				}
			}
			boolean[] dp = new boolean[1 << n];
			dp[0] = true;
			for(int i = 0; i < dp.length; i++) {
				if(!dp[i]) continue;
				ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>();
				for(int j = 0; j < 5; j++) {
					list.add(new ArrayList<Integer>());
				}
				for(int j = 0; j < n; j++) {
					if((i & (1 << j)) != 0 || (i & data[j].up) != data[j].up) continue;
					list.get(data[j].c).add(j);
				}
				for(int j = 1; j < 5; j++) {
					ArrayList<Integer> lX = list.get(j);
					for(int k = 0; k < lX.size()-1; k++) {
						for(int l = k + 1; l < lX.size(); l++) {
							int next = i | (1 << lX.get(k) | (1 << lX.get(l)));
							dp[next] = true;
						}
					}
				}
			}
			int max = 0;
			for(int i = 0; i < dp.length; i++) {
				if(dp[i]) max = Math.max(max, Integer.bitCount(i));
			}
			System.out.println(max);
			
		}
	}
	static boolean check(Data[] data, int a, int b) {
		int dis = (data[a].x - data[b].x) * (data[a].x - data[b].x) + (data[a].y - data[b].y) * (data[a].y - data[b].y);
		return dis < (data[a].r + data[b].r) * (data[a].r + data[b].r);
	}
	static class Data {
		int up = 0;
		int x;
		int y;
		int r;
		int c;
		Data(int a, int b, int c, int d) {
			this.x = a;
			this.y = b;
			this.r = c;
			this.c = d;
		}
	}
}

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

int main() {

  string S; cin >> S;

  int startFromZero = 0; int startFromOne = 0;

  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 0 && S.at(i) == '1') startFromZero++;
    if (i % 2 == 1 && S.at(i) == '0') startFromZero++;
  }

  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 0 && S.at(i) == '0') startFromOne++;
    if (i % 2 == 1 && S.at(i) == '1') startFromOne++;
  }

  cout << min(startFromZero, startFromOne) << endl;

}

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

int main()
{
	int n;
  string s;
  cin>>n>>s;
  int a[3010], b[3010];
  int ia=0, ib=0;
  for(int i=0; i<2*n; i++){
    if(s[i]=='a'){
      a[ia]=i;
      ia++;
    }else{
      b[ib]=i;
      ib++;
    }
  }
  vector<int> ind;
  for(int i=0; i<n; i++){
    ind.push_back(i);
    if(a[i]<b[i]){
      while(i<n-1 && b[i]>a[i+1]) i++;
    }else{
      while(i<n-1 && a[i]>b[i+1]) i++;
    }
  }
  //for(auto x:ind) cerr<<x<<endl;
  string ans;
  ind.push_back(n);
  for(int t=ind.size()-2; t>=0; t--){
    int i=ind[t];
    string ans0;
    if(a[i]<b[i]){
      //continue;
      int r=-1;
      for(int j=i; j<ind[t+1]; j++){
        if(a[j]<r) continue;
        ans0+='a'; ans0+='b';
        r=b[j];
      }
    }else{
      for(int j=i; j<ind[t+1]; j++){
        vector<int> v;
        for(int k=j; k<ind[t+1]; k++){
          v.push_back(a[k]);
          v.push_back(b[k]);
        }
        sort(v.begin(), v.end());
        string ans1;
        for(auto x:v) ans1+=s[x];
        if(ans0<ans1) ans0=ans1;
      }
    }
    ans=max(ans, ans0+ans);
  }
  cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
L=input()
length=len(L)
inf=10**9+7
a=2
b=1
for i in range(1,len(L)):
	if L[i]=="0":
		b=b*3%inf
		continue
	else:
		b=(b*3+a)%inf
		a=a*2%inf
print((a+b)%inf)

Measured memory_bytes: 3188
#include <stdio.h>

char draw(int h, int w) {
  char a = '.';
  if ((h % 2) && (w % 2)) a = '#';
  if ((h % 2 == 0) && (w % 2 == 0)) a = '#';
  return (a);
}

int main(void) {
  int H,W;
  int h,w;

  while (1) {
    scanf("%d %d", &H, &W);
    if (H == 0 && W == 0) break;

    for (h = 0; h < H; h++) {
      for (w = 0; w < W; w++) {
        printf("%c", draw(h, w));
      }
      printf("\n");
    }
    printf("\n");
  }
  return (0);
}



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

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
static long ModInv(long a,long m){return Modpow(a,m-2,m);}
static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
static long[] f;
static long mod=(long)1e9+7;
//......................................@uthor_Alx..............................................

   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  	int n=int_v(read()),n1=n;
	        		  	n%=1000;
	        		  	if(n==0){
	        		  		out.write("0");
	        		  	}
	        		  	else{
	        		  		out.write((1000-n)+"");
	        		  	}
	        		  	
                      	out.flush();
	        		 
	}
}
	       


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

const int MAX_N = 100000;
int h[MAX_N + 1];
int n;
int dp[MAX_N + 1];

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

  dp[n - 1] = 0;
  dp[n - 2] = abs(h[n - 1] - h[n - 2]);
  dp[n - 3] = abs(h[n - 1] - h[n - 3]);

  for (int i = n - 4; i >= 0; i--)
  {
    dp[i] = min(dp[i + 1] + abs(h[i] - h[i + 1]), dp[i + 2] + abs(h[i + 2] - h[i]));
  }

  printf("%d\n", dp[0]);

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;



int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    
    vector<int> ct(100001);
    for(int i=0; i<n; i++){
        int x;
        cin>>x;
        ct[x]++;
    }
    int ans=0;
    for(int i=1; i<100000; i++){
        ans=max(ans,ct[i-1]+ct[i]+ct[i+1]);
    }
    cout<<ans;
    
    
    
   
   
    
    return 0;
    
}

Measured memory_bytes: 640
#include <stdio.h>
 
#define N 100000
#define Q 50000
 
int BinarySearch();
 
int main() {
  
int n,q,S[N],T[Q];
int i,key,num,sum=0;
 
scanf("%d",&n);
for(i=0; i<n;i++)
  scanf("%d",&S[i]);
 
scanf("%d",&q); 
for(i=0; i<q;i++)
  scanf("%d",&T[i]);
 
for (i=0; i<q; i++){
 
num = BinarySearch(n,S,T[i]);
 if(num != 0)
   sum++;
}
 
printf("%d\n",sum);
 
 
return 0;
}
 
int BinarySearch(int n,int S[],int key){
 
  int left,mid,right;
   
  left = 0;
  right = n;
 
  while (left < right){
     
    mid = (left + right)/2;
     
    if( key == S[mid])
      return 1;
 
    if( key > S[mid] )
      left = mid +1;
     
    else if( key < S[mid] )
      right = mid;
  }
 
  return 0;
 
}

Measured memory_bytes: 1180
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final long T = sc.nextLong();
		
		long[] array = new long[N];
		for(int i = 0; i < N; i++){
			array[i] = sc.nextLong();
		}
		
		long[] max_profits = new long[N];
		max_profits[0] = 0;
		long min = array[0];
		
		for(int i = 1; i < N; i++){
			max_profits[i] = array[i] - min;
			min = Math.min(min, array[i]);
		}
		
		final long max = Arrays.stream(max_profits).max().getAsLong();
		
		int max_count = 0;
		for(int i = 0; i < N; i++){
			if(max_profits[i] == max){
				max_count++;
			}
		}
		
		System.out.println(max_count);
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 30656
// Problem : B - An Odd Problem
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		int arr[n+1];
		int ct = 0;
		for(int i=1;i<=n;++i)
		{
			cin>>arr[i];
			if(i&1 and arr[i]&1)
			++ct;
		}		
		cout<<ct;
    }
    return 0;
}


Measured memory_bytes: 3632
n = int(input())
s = list(input())
a = ord("A")

for i in range(len(s)):
	s[i] = (ord(s[i])-a+n)%26

moji = ""

for i in range(len(s)):
	s[i] =chr(s[i]+a)

	moji +=s[i]
print(moji)



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

using namespace std;

int main(){
        int N, M, X;
        cin>>N>>M>>X;
        vector <int> a(M);
        for(int i=0;i<M;i++){
                cin>>a[i];
        }
        int res=1e9;
        int nx=X;
        int vres=0;
        while(nx<N+1){
                nx++;
                for(int i=0;i<M;i++){
                        if(a[i]==nx){
                                vres++;
                                break;
                        }
                }
        }
        res=min(res, vres);
        nx=X;
        vres=0;
        while(nx>0){
                nx--;
                for(int i=0;i<M;i++){
                        if(a[i]==nx){
                                vres++;
                                break;
                        }
                }
        }
        res=min(res, vres);
        cout<<res<<endl;
        return 0;
}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(ull i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(ull j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*
    add utility Algorithm
*/



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

    ull N, M, K;
    cin >> N >> M >> K;

    vector<ull> A(N, 0);
    vector<ull> B(M, 0);

    vector<ull> a;
    a.push_back(0);
    vector<ull> b;
    b.push_back(0);
    
    REPinit(i, 0, N) {
        cin >> A[i];
        a.push_back(a.at(i) + A.at(i));
    }
    REPinit(i, 0, M) {
        cin >> B[i];
        b.push_back(b.at(i) + B.at(i));
    }


    ull ans = 0;
    ull j = M;

    REPinit(i, 0, N + 1) {
        if (a[i] > K) break;

        while (b[j] > K - a[i]) j--;
        ans = max(ans, i + j);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11004
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll n;
vll v;
ld ans;

int main() {
    fast_io; cout_precision;
    cin >> n;
    v.resize(n);
    for (ll i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    ans = v[0];
    for (ll i = 1; i < n; i++) {
        ans += v[i]; ans /= 2;
    }
    cout << ans << endl;
}

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

int main(void) {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> a(n,vector<int>(m));
    vector<int> b(m), c(n,0);
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i=0; i<m; i++) {
        cin >> b[i];
    }
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            c[i] += a[i][j]*b[j];
        }
        cout << c[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3168
from sys import stdin
from collections import Counter


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, K = list(map(int,_in[0].split(' ')))  # type:list(int)
    A_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    counter = Counter(A_arr)
    counter = list(counter.values())
    counter.sort(reverse=True)
    cnt = sum(counter[K:])
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 98012
#!/usr/bin/env python3
import sys


def solve(R: int):
    if R < 1200:
        print("ABC")
    elif R < 2800:
        print("ARC")
    else:
        print("AGC")

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  # type: int
    solve(R)

if __name__ == '__main__':
    main()


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


int GCD( int a, int b){
    if (b==0) return a;
    else return GCD(b,a%b);
}

int main(){
  int a,b,k;
  cin >> a >>b >> k;
  vector<int>ans(100);
  for(int i = 1;i<=GCD(a,b); ++ i){
       if(GCD(a,b)%i==0) ans.push_back(i);
  }
  sort(ans.rbegin(),ans.rend());
  cout << ans[k-1] << endl;
   }


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

void solve() {
    long long ar[4], n;
    long long br[] = {8, 4, 2, 1};
    FOR(i, 0, 4) cin >> ar[i], ar[i] *= br[i];
    cin >> n;
    pair<long long, int> best = mp(LINF, INF);
    FOR(i, 0, 4) chkmin(best, mp(ar[i], i));
    if (best.se < 3) {
        cout << n * best.fi / 2 << "\n";
        return;
    }
    best = mp(LINF, INF);
    FOR(i, 0, 3) chkmin(best, mp(ar[i], i));
    long long m = n - (n & 1);
    cout << m * ar[3] / 2 + (n & 1) * best.fi / 2 << "\n";
}

int main() {
    int JUDGE_ONLINE = 1;
    if (fopen("in.txt", "r")) {
        JUDGE_ONLINE = 0;
        assert(freopen("in.txt", "r", stdin));
        //assert(freopen("out.txt", "w", stdout));
    }
    else {
        ios_base::sync_with_stdio(0), cin.tie(0);
    }
    solve();
    if (!JUDGE_ONLINE) {
        //cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    }
    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 ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, m, X, Y; cin >> n >> m >> X >> Y;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    x.push_back(X);
    sort(RALL(x));
    vector<int> y(m);
    rep(i,m) cin >> y[i];
    y.push_back(Y);
    sort(ALL(y));
    if(x[0]+1 <= y[0]) cout << "No War" << endl;
    else cout << "War" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
   int n , i ;

   scanf("%d",&n);
   scanf("%d",&i);

   while(n>=500)
      n = n - 500 ;

   if(n <= i) printf("Yes\n");

   else if(n > i)printf("No\n");

   return 0;
}


Measured memory_bytes: 128
import collections
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)
ans=0
for i in c:
    ans+=c[i]*(c[i]-1)//2
for i in range(N):
    a=A[i]
    Ans=ans-c[a]+1
    print(Ans)

Measured memory_bytes: 26780
/* 
	Author: ankrypt
*/

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

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#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
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;
char alpha[4] = {'A', 'G', 'C', 'T'};

int main() {
	go;
    cin >> S;
    ll k = 0;
    ll maxAns = 0;
    fi(i, 0, S.size(), 1) {
    	// trace1(i);
    	fi(j, 0, 4, 1) {
    		// trace1(j);
    		if(S[i] == alpha[j]) {
    			k = i;
    			ll cnt = 0;
    			while(k < S.size()) {
    				// trace1(k);
    				int flag = 0;
    				fi(l, 0, 4, 1) {
    					if(S[k] == alpha[l]) {
    						flag = 1;
    						break;
    					}
    				}
    				if(!flag) {
    					break;
    				}
    				else {
    					cnt++;
    					maxAns = max(maxAns, cnt);
    				}
    				k++;
    			}
    			i += cnt - 1;
    		}
    	}
    }
    cout << maxAns << "\n";
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3620
use std::io::*;
fn main() {
    let n = read();
    let s = read();
    let t = read();
    println!(
        "{}{
    }{
    }",
        n[0], s[1], t[2]
    );
}

fn read() -> Vec<char> {
    let s = stdin();
    let b = s.bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<Vec<char>>();
    b
}



Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		Bit bit=new Bit(s[0]);
		var a=sc.Ia;
		for(int i = 0;i<s[0];i++) {bit.Ud(i,a[i]);}
		StringBuilder sb=new StringBuilder();
		for(int i = 0;i<s[1];i++) {
			var e=sc.Ia;
			if(e[0]==0){bit.Ud(e[1],e[2]);}
			else{sb.Append(bit.Get2(e[1],e[2]-1)+"\n");}
		}
		Console.Write(sb);
	}
}
public class Bit{
	private int n;
	private long[] bit;
	public Bit(int n){
		this.n=n;
		bit=new long[n+1];
	}
	public void Ud(int a,long p){a++;while(a<=n){bit[a]+=p;a+=a&-a;}}
	public long Get(int n){
		n++;
		long a=0;
		while(n>0){a+=bit[n];n-=n&-n;}
		return a;
	}
	public long Get2(int m,int n){
		long a=0,b=0;
		n++;
		while(n>m){a+=bit[n];n-=n&-n;}
		if(n==m){return a;}
		while(n!=m){b+=bit[m];m-=m&-m;}
		return a-b;
	}
	public void Clear(){bit=new long[n+1];}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 98508
n,k = map(int,input().split())
dp = [0]*k
mod = 10**9 + 7
ans = 0
for i in range(k,0,-1):
    dp[i-1] += pow(k//i,n,mod)
    for j in range(k//i,1,-1):
        dp[i-1] -= dp[i*j-1]
    ans += dp[i-1]*i
    ans %= mod
    
print(ans)

Measured memory_bytes: 11312
#include <iostream>
#include <string>

using namespace std;

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

  int N;
  string s, t;
  cin >> N >> s >> t;
  for (int i = 0; i < s.size(); ++i) {
    const auto sub = s.substr(i);
    if (sub == t.substr(0, t.size() - i)) {
      cout << s.size() + t.size() - sub.size() << endl;
      return 0;
    }
  }
  cout << s.size() + t.size() << endl;

  return 0;
}


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

int SumOfDigits(int n) {
    int sum = 0;
    while(n>0) {
        sum += n%10;
        n/=10;
    }
    return sum;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for(int i = 1; i <= n; ++i) {
        int sum = SumOfDigits(i);
        if(sum>=a && sum<=b) {
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring> 
#include <map>
#include <cmath>
#include <cstdio>
#include <sstream>
#include <stack>
#include <ctime>
#include <string.h>
#include <utility>
#include <cstdlib>
#include <functional>
#include <deque>
#include <list>
#define open_in(n) freopen("n","r",stdin)
#define open_out(n) freopen("n","w",stdout)
#define rep(i,n) for (int i=0;i<n;i++)
#define repw(i,w) for(int i=w;i>0;i--)
#define repn(i,m,n) for (int i=n;i<m;i++)
#define for_all(it,n) for(__typeof((n).begin()) it=(n).begin();it!=(n).end();it++)
#define IT iterator
#define Size(n) (int)((n).size()) 
#define pb push_back
#define mpa make_pair
#define pa pair
#define all(n) (n).begin(),(n).end
#define dump(n) cerr<<#n<<"="<<(n)<<endl 
#define _abs(a) ((a)>0?(a):-(a))
#define inf 1<<32
using namespace std;
template <class t>
	t abs2(const t &x){
		return (x<0?-x:x);
	}
template <class t>	
	t max2(const t &x,const t &y){
		return (x>y?x:y);
	}
template <class t>
	t min2(const t &x,const t &y){
		return (x<y?x:y);
	}
template <class t>
    t gcd(const t &x,const t &y){
	    return x ? gcd(y%x,x) : y;
    }
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef long long ll;
typedef map<int,int> mii;
typedef queue<int> qi;
typedef set<int> si;
string s;
bool f[27];
int main(){
	cin>>s;
	for(int i=0;i<s.length();i++) f[s[i]-'a']=true;
	for(int i=0;i<26;i++){
		if(!f[i]){
			cout<<(char)(i+'a')<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> H;
  vector<int> W;
  int cnt = 0, tmpH, tmpW;
  REP(i, 1e6){
    cin >> tmpH >> tmpW;
    if(tmpH == 0 && tmpW == 0){
      cnt = i;
      break;
    }
    H.push_back(tmpH);
    W.push_back(tmpW);
  }
  REP(i, cnt){
    REP(j, W.at(i)) cout << "#";
    cout << endl;
    REP(k, H.at(i)-2){
      cout << "#";
      REP(l, W.at(i)-2) cout << ".";
      cout << "#" << endl;
    }
    REP(m, W.at(i)) cout << "#";
    cout << endl << endl;
  }
}



Measured memory_bytes: 3224
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n,k,m; string s,t;
char maze[60][60];
int dis[101][101];
int nm[8][8];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
int gcd(int x, int y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
int main() {
	cin >> n; int cnt = 0; int res = 0;
	vector<int> a(n);
	vector<bool> col(8);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		if (1 <= a[i] && a[i] <= 399) col[0] = true;
		else if (400 <= a[i] && a[i] <= 799) col[1] = true;
		else if (800 <= a[i] && a[i] <= 1199) col[2] = true;
		else if (1200 <= a[i] && a[i] <= 1599) col[3] = true;
		else if (1600 <= a[i] && a[i] <= 1999) col[4] = true;
		else if (2000 <= a[i] && a[i] <= 2399) col[5] = true;
		else if (2400 <= a[i] && a[i] <= 2799) col[6] = true;
		else if (2800 <= a[i] && a[i] <= 3199) col[7] = true;
		else cnt++;
	}
	rep(i, 8) {
		if (col[i] == true) {
			res++;
		}
	}
	if (res == 0) { cout << 1 << " " << res + cnt << endl; return 0; }
	cout << res << " " << res + cnt << endl;
}




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

namespace AtCoderSolve
{
    class Solve
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            int N = int.Parse(Console.ReadLine());
            long ans = 0;
            for(var i = 0; i < N; i++)
            {
                var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
                ans += p[1] - p[0] + 1;
            }
            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }



    public class Calculation
    {
        
    }
}


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

int main()
{
    vector<int>prms;
    vector<int>v(100005,0);
    v[0]=1;
    for(int i=2;i<=100004;i++){
        if(v[i]==0){
            prms.push_back(i);
            for(int j=i+i;j<=100004;j+=i)
                v[j]=1;
        }
    }
    int x;
    cin>>x;

    cout<<*(lower_bound(prms.begin(),prms.end(),x));
    return 0;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    ll n,k;
    cin>>n>>k;
    ll a[n+1];
    a[0]=0;
    rep(i,n){
        cin>>a[i+1];
        a[i+1]+=a[i];
    }
    vector<ll> v;
    v.reserve(n*(n+1)/2);
    for(int i=0;i<n;i++){
        for(int j=i;j<n;++j){
            v.push_back(a[j+1]-a[i]);
        }
    }
    int sz=v.size();
    ll ans=0;
    for(int i=50;i>=0;--i){
        int cnt=0;
        rep(j,sz){
            if(v[j]&(1LL<<i)){
                ++cnt;
            }
        }
        if(cnt>=k){
            rep(j,sz){
                if(!(v[j]&(1LL<<i))){
                    v[j]=0;
                }
            }
            ans+=(1LL<<i);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4224