akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MAX / 2 - 1;
    ll h, w, d;
    cin >> h >> w >> d;
    map<ll, pair<ll, ll>> pos;
    rep(i, h) {
        rep(j, w) {
            ll a;
            cin >> a;
            pos[a] = make_pair(i, j);
        }
    }
    vector<ll> dist(h * w + 1, 0);
    reps(i, d + 1, sz(dist)) {
        dist[i] = dist[i - d] + abs(pos[i].first - pos[i - d].first) + abs(pos[i].second - pos[i - d].second);
    }
    ll q;
    cin >> q;
    rep(i, q) {
        ll l, r;
        cin >> l >> r;
        cout << (dist[r] - dist[l]) << endl;
    }
    return 0;
}


Measured memory_bytes: 7424
#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(){
	
	int N = 0, Nmax = 0;
	string S;
	
	cin >> S;
	
	for(int i = 0;i < S.length();i++){
		if( S.substr(i,1) == "R" ){
			N++;
		}
		else{
			N = 0;
		}
		if( N > Nmax ){
			Nmax = N;
		}
	}
	
	cout << Nmax;
	
	return 0;
	
}


Measured memory_bytes: 3584
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n,k,i,data;
	scanf("%d %d",&n,&k);
	int arr[n+1];
	for(i=0;i<=n;++i)
		arr[i]=0;
	while(k>0)
	{
		scanf("%d",&i);
		while(i>0)
		{
			scanf("%d",&data);
			arr[data]=data;
			i--;
		}
		k--;
	}
	for(i=1;i<=n;++i)
	{
		if(!arr[i])
			k++;
	}
	printf("%d\n",k);
	return 0;
}
	


Measured memory_bytes: 1736
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

void print_vector(const vector<int> v, int part)
{
    const int v_size = v.size();
    for (int i = 0; i < v_size; i++){
        if (i > 0) cout << " ";

        if (i == part) printf("[%d]", v[i]);
        else cout << v[i];
    }
    cout << endl;
}

int partition(vector<int>& A, int p, int r)
{
    int x = A[r];
    int i = p;
    for (int j = p; j < r; j++){
        if (A[j] <= x){
            int buf = A[i];
            A[i] = A[j];
            A[j] = buf;

            i++;
        }
    }

    int buf = A[i];
    A[i] = A[r];
    A[r] = buf;

    return i;
}

int main()
{
    int n;
    vector<int> A;

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

    int q = partition(A, 0, n - 1);

    print_vector(A, q);

    return 0;
}




Measured memory_bytes: 3464
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  vector<int> e(1e5 + 1);
  vector<int> o(1e5 + 1);
  int n;
  cin >> n;
  for(int i = 0; i < n; i++)
  {
    int temp;
    cin >> temp;
    if(i % 2 == 0)
    {
      e[temp]++;
    }
    else
    {
      o[temp]++;
    }
  }
  int maxe1 = 0;
  int maxe2 = 0;
  int maxe1idx;
  int maxo1 = 0;
  int maxo2 = 0;
  int maxo1idx;
  for(int i = 0; i < 1e5 + 1; i++)
  {
    if(e[i] > maxe1)
    {
      maxe2 = maxe1;
      maxe1 = e[i];
      maxe1idx = i;
    }
    else if(e[i] > maxe2)
    {
      maxe2 = e[i];
    }
    if(o[i] > maxo1)
    {
      maxo2 = maxo1;
      maxo1 = o[i];
      maxo1idx = i;
    }
    else if(o[i] > maxo2)
    {
      maxo2 = o[i];
    }
  }
  if(maxe1idx == maxo1idx)
  {
    cout << min(n - maxe1 - maxo2, n - maxo1 - maxe2);
  }
  else
  {
    cout << n - maxe1 - maxo1;
  }

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int A, B;
	cin >> A >> B;
	int ans = -1;
	for(int i = 0;i<B * 20;i++){
		if(i * 8 / 100 == A && i / 10 == B){
			ans = i;
			break; 
		}
	}
	cout << ans << endl;
}


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

using namespace std;
long long dp[3000][3000];

long long getlenlcs(long long i,long long j,string &s1,string &s2){
 if(i>=s1.size() || j>=s2.size()){
  return 0;
 }

 if(dp[i][j]!=(-1)){
  return dp[i][j];
 }else if(s1[i]!=s2[j]){
  long long pos1=getlenlcs(i,j+1,s1,s2);
  long long pos2=getlenlcs(i+1,j,s1,s2);

  return dp[i][j] = max(pos1,pos2);
 }else{
  return dp[i][j] = 1 + getlenlcs(i+1,j+1,s1,s2);
 }
}

string getlcs(string &s1,string&s2,long long len){
 string lcs="";
 long long i=0,j=0;

 while(len>0){
  if(s1[i]==s2[j]){
   lcs.push_back(s1[i]);
   i++;
   j++;
   len--;
  }else{
   if(dp[i][j+1]>dp[i+1][j]){
    j++;
   }else{
    i++;
   }
  }
 }

 return lcs;
}

int32_t main()
{
 string s1,s2;cin>>s1>>s2;
 memset(dp,-1,sizeof(dp));
 long long len=getlenlcs(0,0,s1,s2);

 string res=getlcs(s1,s2,len);
 cout<<res<<endl;
 return 0;
}



Measured memory_bytes: 74268
n=int(input())
x,k=map(int,input().split())
l=list(map(int,input().split()))
m=100000000000000
u=-1
for i in range(n):
    d=x-l[i]*0.006
    if(abs(d-k)<m):
        m=abs(d-k)
        u=i+1
print(u)


Measured memory_bytes: 62552
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <numeric>
#include <unordered_map>
#define REP(i, N) for(int i=0; i<N; i++)
using namespace std;

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	int N;

	cin >> N;

  	vector<int> a(N);
  
  int uso = 0;
  
    for (auto& i : a) {
      cin >> i;
      
      uso ^= i;
    }
  
  
  if (uso == 0)
	 cout << "Yes" << endl;
  else
     cout << "No" << endl;
  

	return 0;
}


Measured memory_bytes: 640
range = xrange
S = int(raw_input())
MOD = 10**9+7
ans = 0

# l has <= 7 digits
r = 1
tot = 1
for l in range(1, 10000000):
    while tot < S:
        r+= 1
        tot+= len(str(r))
    if tot == S: ans+= 1
    tot-= len(str(l))

# l has > 7 digits
for cnt in range(1, S+1):
    d, m = divmod(S, cnt)
    if d <= 7: break
    if m: ans+= 1
    else: ans+= pow(10, d, MOD) - pow(10, d-1, MOD) - cnt + 1
    ans%= MOD
print ans % MOD

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    vector<int> town(4,0);
    rep(i, 3) {
        int a, b;
        cin >> a >> b;
        town[--a]++, town[--b]++;
    }
    bool flg = true;
    rep(i, 4) if (town[i] > 2) flg = false;
    cout << (flg ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

int main(){
	
	string s;
	cin >> s;
	int cnt = 0;
	for(auto c : s) if(c == '1') cnt++;
	cout << cnt << endl;
	
	
	
	
	
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  ll n,m,val;
  cin>>n>>m;
  priority_queue<ll>fila;
  for(int i=0;i<n;i++){
  	cin>>val;
  	fila.push(val);
  }
  for(int i=0;i<m;i++){
  	ll k = fila.top()/2;
  	fila.pop();
  	fila.push(k);
  }
  ll ans = 0;
  int y = fila.size();
  for(int i=0;i<y;i++){
  	ans+=fila.top();
  	fila.pop();
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {

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

    }

}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    map<int,int> Map;
    FOR(x,1,100)FOR(y,1,100)FOR(z,1,100){
        Map[x*x+y*y+z*z+x*y+y*z+z*x]++;
    }
    FOR(i,1,N){
        cout<<Map[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 5416
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int a, b, c;

int main() {
    cin >> a >> b >> c;
    if (a == b && a == c) puts("Yes");
    else puts("No");
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

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

  //n > m とする
  if(n < m) swap(n,m); 
  //n,m < 3
  if(n < 3){
    vector<vector<bool>> a(n, vector<bool>(m, false));
    REP(i,n)REP(j,m){
      REP(dir,9){
        int ni = i + dx[dir];
        int nj = j + dy[dir];
        if(ni < 0 || nj < 0 || ni >= n || nj >= m) continue;
        a[ni][nj] = !a[ni][nj];
      }
    }

    int cnt = 0;
    REP(i,n)REP(j,m){
      if(a[i][j]) cnt++;
    }

    cout << cnt << endl;
    return 0;
  }
  
  //n >= 3
  ll ans = 0;
  //m = 1
  if(m == 1){
    ans = n - 2;
  }
  else if(m == 2){
    ans = 0;
  }
  else{
     ans = (ll)(n-2)*(m-2);
  }

  cout << ans << endl;

  return 0;
}

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

 
int main() {
    int n;
    cin>>n;
    vector<int> T(n+1);
    vector<int> X(n+1);
    vector<int> Y(n+1);
    T[0]=0;
    X[0]=0;
    Y[0]=0;
    

    for(int i=1;i<=n;i++){
        int t,x,y;
        cin>>t>>x>>y;
        T[i]=t;
        X[i]=x;
        Y[i]=y;
        t=T[i]-T[i-1];
        x=abs(X[i]-X[i-1]);
        y=abs(Y[i]-Y[i-1]);
        if(t<x+y||(t-(x+y))%2==1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long n, k;
long long a[105];
//           idx, num, xor
long long dp[105][105][260];

long long memo[200];

int main(){
	memo[0] = 1;
	for(int i = 1; i < 200; i++){
		memo[i] = memo[i-1] * i;
		memo[i] %= DIV;
	}

	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	dp[0][0][0] = 1;
	for(int i = 0; i < n; i++){
		for(int num = 0; num < 105; num++){
			for(int j = 0; j < 260; j++){
				if(dp[i][num][j]){
					/*
					cout << "dp[" << i + 1  << "][" << j << "] += " << dp[i][j] << endl;
					cout << "dp[" << i + 1  << "][" << (j^a[i]) << "] += " << dp[i][j] << endl;
					*/
					dp[i+1][num][j] += dp[i][num][j];
					dp[i+1][num+1][j^a[i]] += dp[i][num][j];
					dp[i+1][num][j] %= DIV;
					dp[i+1][num+1][j^a[i]] %= DIV; 

				}
			}
		}
	}
	/*
	for(int i = 0; i <= n; i++){
		for(int j = 0; j < 30; j++){
			cout << "dp[" << i << "][" << j << "]=" << dp[i][j] << endl;
		}
	}
	*/

	long long ans = 0;
	for(int num = 0; num < 105; num++){
		//cout << "num:" << dp[n][num][k] << endl;
		ans += (memo[num] * dp[n][num][k])%DIV ;
		ans %= DIV;
	}

	cout << ans << endl;



}


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

int main() {
	string s;
	cin >> s;
	if (s[0] == '9'||s[1]=='9') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Char (digitToInt)
import Test.HUnit

main :: IO ()
-- main = runTestTT (TestList tests) >> return ()
main = do
  n <- getl toInt
  when (n /= 0) $ do
    xs <- rgetl n $ map digitToInt
    print $ solve n xs
    main
    
solve :: Int -> [[Int]] -> Int
solve n xs = maximum [yoko, tate, nanamer, nanamel]
  where
    txs = transpose xs
    rxs = map reverse txs
    yoko = maximum . map maxSN $ xs
    tate = maximum . map maxSN $ txs
    nix = nanameIx n
    nanamel = maximum . map maxSN . map (map (\(i,j) -> xs !! i !! j)) $ nix
    nanamer = maximum . map maxSN . map (map (\(i,j) -> rxs !! i !! j)) $ nix
    
maxSN :: [Int] -> Int
maxSN = maximum . map (length . takeWhile (==1)) . tails

nanameIx :: Int -> [[(Int,Int)]]
nanameIx x = zipWith (\n ns -> [(i,n-i)| i <- ns]) [0..] (tail . inits $ [0..x-1]) ++ zipWith (\n ns -> [(i,n-i)| i <- ns]) [x..] (tails [1..x-1])

toInt :: String -> Int
toInt s = read s

getl :: (String -> a) -> IO a
getl f = f <$> getLine

rgetl :: Int -> (String -> a) -> IO [a]
rgetl n f = map f <$> replicateM n getLine

tests :: [Test]
tests = [
  "test1" ~: 5 ~=? maxSN [0,1,0,0,1,1,0,0,1,1,1,0,0,0,1,0,1,0,1,0,0,0,1,1,1,0,1,0,1,1,1,1,1,0,0,0,1],
  "test2" ~: 0 ~=? maxSN [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  "test3" ~: 3 ~=? solve 3 [[0,1,0],[1,1,1],[0,0,1]],
  "test4" ~: 3 ~=? solve 3 [[1,0,0],[1,1,0],[1,0,0]],
  "test5" ~: 3 ~=? solve 3 [[1,0,1],[0,1,0],[0,0,1]],
  "test6" ~: 3 ~=? solve 3 [[0,0,1],[0,1,1],[1,0,0]]
  ]

Measured memory_bytes: 19352
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 2000 + 100;
int A[Maxn][Maxn], Sum_node[Maxn][Maxn], Sum_edgex[Maxn][Maxn], Sum_edgey[Maxn][Maxn];
int N, M, Q;
inline int safe_read()
{
	char c;
	c = getchar();
	while (1) { if (c == '0' || c == '1')return c - '0'; c = getchar(); }
}
int Vis[Maxn][Maxn];
int main()
{
	scanf("%d%d%d", &N, &M, &Q);
	for (int i = 1; i <= N; ++i)
		for (int j = 1; j <= M; ++j)
			A[i][j] = safe_read();
	for (int i = 1; i <= N; ++i)
		for (int j = 1; j <= M; ++j)
			Sum_node[i][j] = Sum_node[i - 1][j] + Sum_node[i][j - 1] - Sum_node[i - 1][j - 1] + A[i][j];
	for (int i = 1; i <= N; ++i)
	{
		for (int j = 1; j <= M; ++j)
		{
			if (A[i][j] == A[i - 1][j] && A[i][j])
				Sum_edgex[i][j] ++;
			if (A[i][j] == A[i][j - 1] && A[i][j])
				Sum_edgey[i][j] ++;
			Sum_edgex[i][j] += Sum_edgex[i - 1][j] + Sum_edgex[i][j - 1] - Sum_edgex[i - 1][j - 1];
			Sum_edgey[i][j] += Sum_edgey[i - 1][j] + Sum_edgey[i][j - 1] - Sum_edgey[i - 1][j - 1];
		}
	}
	int x1, y1, x2, y2;
	while (Q--)
	{
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		int Ans_node, Ans_edgex, Ans_edgey;
		Ans_node = Sum_node[x2][y2] - Sum_node[x1 - 1][y2] - Sum_node[x2][y1 - 1] + Sum_node[x1 - 1][y1 - 1];
		Ans_edgex = Sum_edgex[x2][y2] - Sum_edgex[x1][y2] - Sum_edgex[x2][y1 - 1] + Sum_edgex[x1][y1 - 1];
		Ans_edgey = Sum_edgey[x2][y2] - Sum_edgey[x1 - 1][y2] - Sum_edgey[x2][y1] + Sum_edgey[x1 - 1][y1];
		printf("%d\n", Ans_node - Ans_edgex - Ans_edgey);
	}
	return 0;
}

Measured memory_bytes: 71424
N=int(input())
D,X=map(int,input().split())
ans=X
l=[]
for i in range(N):
  l.append(int(input()))
def f(n):
  ans=1
  if n>D:
    pass
  else:
    ans+=int((D-1)//n)
  return ans

for i in range(N):
  ans+=f(l[i])
    
print(ans)

Measured memory_bytes: 38256
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long a = n/k;
 
        if (k%2==1){
            System.out.println(a*a*a);
        }else {
            long b = (n+k/2)/k;
            System.out.println(a*a*a+b*b*b);
        }
    }
}

Measured memory_bytes: 21844
s = int(input())

numbers = []

for i in range(10000001):
    if i == 0:
        numbers.append(s)
    else:
        if numbers[-1] % 2 == 0:
            numbers.append(numbers[-1] // 2)
        else:
            numbers.append(3*numbers[-1]+1)
    if numbers.count(4) == 2 or numbers.count(2) ==2 or numbers.count(1) == 2:
        break

print(len(numbers))

Measured memory_bytes: 9196
n=gets.to_i
a=gets.split.map(&:to_i)
v=a.uniq
if v.length==1
    p a[0]
    exit
end

odd=0
even=0
result=[]
for i in 0..a.length-2
    first=a[i]
    second=a[i+1]
    
    result<<first.gcd(second)

end

p result.min

Measured memory_bytes: 24504
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/
int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 0;
    rep(i, n){
        ans = gcd(ans, a[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
# https://atcoder.jp/contests/abc078/tasks/arc085_a
# C - HSI

N, M = list(map(int, input().split()))
exp_v = 0

# 1回で全ケースが通る場合は、
# 1900 * M + 100 * (N - M)
# 必ず1回は提出する必要があるので、上記は固定値
# 追加でかかる時間をtと置くと
# 1900 * M + 100 * (N - M) + t
# 一つのケースが通る確率が、p = 1 / 2
# 全てのケースが1回で通る確率が、P = p ** M
# 全ケースが1回で通らない = 追加時間が発生する確率が 1 - P
# 追加でかかる時間を知りたい
# t = (1900 * M + 100 * (N - M)) + (1-P) * t
# C = (1900 * M + 100 * (N - M)) とすると
# t = C + (1-P) * t
# t - C = (1-P) * t
# 1 - C/t = 1 - P
# C / t = P
# t = C / P
# t =  (1900 * M + 100 * (N - M)) / (p ** M)

X = 1900 * M + 100 * (N-M)
t = X / ((1/2) ** M)

print(int(t))


Measured memory_bytes: 2940
from itertools import accumulate

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

num_fixed_b = [-1] * N
c_idx = 0
for b_idx, b in enumerate(B):
  while c_idx < N and C[c_idx] <= b:
    c_idx += 1
  num_fixed_b[b_idx] = N - c_idx

num_fixed_b = list(accumulate(num_fixed_b[::-1]))[::-1]
b_idx = 0
ans = 0
for a_idx, a in enumerate(A):
  while b_idx < N and B[b_idx] <= a:
    b_idx += 1
  if b_idx == N:
    print(ans)
    quit()
  ans += num_fixed_b[b_idx]

print(ans)

Measured memory_bytes: 31208
#include "bits/stdc++.h"

using namespace std;

int main() {
	int N;
	cin >> N;
	int ncopy = N;
	int f = 0; 
	while (0 != ncopy) {
		f += ncopy % 10;
		ncopy /= 10;
	}
	if (0 == N%f) {
		cout << "Yes"<<endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


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

ans1=0
ans2=0

now=0

for i in range(n):
    now+=a[i]
    if i%2==0:
        if now<=0:
            ans1+=1-now
            now=1
    else:
        if now>=0:
            ans1+=now+1
            now=-1

now=0

for i in range(n):
    now+=a[i]
    if i%2==1:
        if now<=0:
            ans2+=1-now
            now=1
    else:
        if now>=0:
            ans2+=now+1
            now=-1

#print(ans1,ans2)
print(min([ans1,ans2]))

Measured memory_bytes: 14468
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

string rep1(string& s)
{
	string res;
	REP(i, s.size())
	{
		if (i + 2 < s.size() && s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
		{
			res += 'X';
			i += 2;
		}
		else res += s[i];
	}
	return res;
}

string rep2(string& s, char c)
{
	string res = s;
	for (auto &t : res)
	{
		if (t == 'X') t = c;
	}
	return res;
}

string rep3(string &s, char c)
{
	string res;
	for (auto &t : s)
	{
		if (t == c) res += "ABC";
		else res += t;
	}
	return res;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	string s; cin >> s;
	if (s == "ABC")
	{
		cout << "Yes" << endl;
		return 0;
	}
	queue<pair<string, string>> que;
	que.emplace(s, "");
	vs ans;
	while (!que.empty())
	{
		string t = que.front().first;
		string op = que.front().second;
		que.pop();		
		string a = rep1(t);
		if (a.size() == t.size()) continue;
		for (char c = 'A'; c <= 'C'; c++)
		{
			string b = rep2(a, c);
			if (b == "ABC")
			{
				ans.push_back(op + c);
				continue;
			}
			que.emplace(b, op + c);
		}
	}
	for(auto t: ans)
	{
		string tmp = "ABC";
		for (int i = t.size() - 1; i >= 0; i--)
		{
			tmp = rep3(tmp, t[i]);
		}
		if (tmp == s)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3240
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  s[5] = ' ';
  s[13] = ' ';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args)throws Exception{
        FastReader scan=new FastReader(System.in);
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            int n=scan.nextInt();
            Map<String,Integer> m=new HashMap<>();
            m.put("AC",0);
            m.put("WA",0);
            m.put("TLE",0);
            m.put("RE",0);
            for(int i=0;i<n;i++){
                String s=scan.next();
                m.put(s,m.get(s)+1);
            }
            out.println("AC x "+m.get("AC"));
            out.println("WA x "+m.get("WA"));
            out.println("TLE x "+m.get("TLE"));
            out.println("RE x "+m.get("RE"));
        }
        out.flush();
        out.close();
    }
    static class FastReader {

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan()) ;
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}


Measured memory_bytes: 48700
#include<iostream>
#include<iomanip>
#define _USE_MATH_DEFINES
#include<math.h>
using namespace std;

int main() {
	double r;
	double a, b;
	cin >> r;
	a = r*r*M_PI;
	b = 2*r*M_PI;
	cout << fixed;
	cout << setprecision(6) << a << " " << b << endl;
}



Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
//Available in Snips
#define fi(i, x, y)   for (__typeof(x) i = x; i < y; i ++)
#define fir(i, x, y)  for (__typeof(x) i = x; i > y; i --)
#define fv(x)   for (auto itr = x.begin(); itr != x.end(); itr ++)
#define fvr(x)  for (auto itr = x.end() - 1; itr != x.begin() - 1; itr --)

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code here
	int d,n;
	cin >> d >> n;
	if(n<100)
	cout << (long) pow(100,d)*n;
	else
	{
		cout << (long) pow(100,d)*101;
	}
	

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

void solve(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];

    rep(i,n){
        if(a[i]%2)continue;
        if(a[i]%3&&a[i]%5){
            cout<<"DENIED"<<endl;
            return;
        }
    }
    cout<<"APPROVED"<<endl;
}

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


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

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


Measured memory_bytes: 3600
use std::io::stdin;
use std::str::FromStr;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn read_str_as_char_vec() -> Vec<char> {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().chars().collect()
}

fn read_str_as_T<T>() -> T
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().unwrap()
}

fn main() {
    let in_vec: Vec<usize> = read_line();
    let mut in_n = in_vec[0];
    let k = in_vec[1];

    let a: Vec<usize> = read_line();
    let mut a_accessed: Vec<usize> = vec![0; in_n];
    let mut a_bef_cnt: Vec<usize> = vec![0; in_n];

    let mut n = 1;
    let mut bef_n = 1;
    let mut cnt = 0;
    for i in 0..=k {
        bef_n = n;
        if a_accessed[n - 1] == 1 {
            let cnt_diff = cnt - a_bef_cnt[n - 1];
            let left = k - i;
            let left_iter = left % cnt_diff;
            for _j in 0..left_iter {
                n = a[n - 1];
            }
            println!("{}", n);
            return;
        } else {
            a_accessed[n - 1] = 1;
            a_bef_cnt[n - 1] = cnt;
            n = a[n - 1];
            cnt += 1;
        }
    }
    println!("{}", bef_n);
}


Measured memory_bytes: 6672
/**
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B
 */
#include <iostream>
#include <string>
#include <queue>

using namespace std;

int
main()
{
    int n, q;
    cin >> n >> q; cin.ignore();

    queue<pair<string, int> > jobq;
    for (int i = 0; i < n; i++) {
        string name;
        int time;
        cin >> name >> time; cin.ignore();
        jobq.push(decltype(jobq)::value_type(name, time));
    }
    int time = 0;
    while (jobq.size()) {
        pair<string, int> top = jobq.front();
        jobq.pop();
        if (top.second <= q) {
            time += top.second;
            cout << top.first << ' ' << time << endl;
        } else {
            jobq.push(decltype(jobq)::value_type(top.first, top.second - q));
            time += q;
        }
    }
    return 0;
}

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

int main(){
	string S, T;
	cin >> S >> T;
	vector<int> start(26, -1);
	vector<int> goal(26,-1);
	
	for(int i = 0; i < S.size(); i++){
		int a = S[i] - 'a';
		int b = T[i] - 'a';
		
		if(start[a] != -1 || goal[b] != -1){
			if(start[a] != b ||  goal[b] != a){
				cout << "No" << endl;
				return 0;
			}
		}
		
		start[a] = b;
		goal[b] = a;
	}
	
	cout << "Yes" << endl;
	return 0;
}

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

int main() {
int Total;
cin>>Total;
int h,m,s;
h = Total /3600;
Total = Total - h * 3600;
m = Total/60;
Total=Total - m * 60;
s=Total;
cout<<h<<":"<<m<<":"<<s<<endl;

	return 0;
}


Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int K; cin >> K;
    set<string> st;
    rep(i, S.length()) {
        string T;
        REP(j, i, i + 4) {
            if (j == S.length()) break;
            T += S[j];
            st.insert(T);
        }        
    }
    for(auto itr = st.begin(); itr != st.end(); itr++) {
        K--;
        if (K == 0) {
            cout << *itr << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define vector vector<int>
#define vectorp vector<pair<int,int>>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
   set<int>s;
   int x;
   int n;
   cin >> n;
   for(int i = 0 ; i < n ; i++ ){
   	cin >> x;
   	s.insert(x);
   }
   if(s.size()==n){
   	cout<<"YES";
   }
   else{
   	cout<<"NO";
   }
}



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

#define SE second
#define FI first
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int) (x).size())

#define _ << " " <<
#define TR(x) cout << #x _ x << endl

using namespace std;
const int INF = (int) 1e9 + 5;

bool isEven(string t, int n) {
    if (n & 1) return false;

    for (int i = 0, j = n / 2; i < n / 2; i++, j++) {
        if (t[i] != t[j])
            return false;
    }

    return true;
}

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

    int i = 0, j = SIZE(s) - 1, len = 1;

    while (j > 1) {
        if (isEven(s, j)) {
            len = j;
            break;
        }

        j--;
    } 

    cout << len << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#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(){
    int n;
    cin >> n;
    vector<int> a(n);
    int ans=0;
    int cnt=1;
    rep(i,n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    ans=a[0];
    for(int i=1;i<n;i++){
        if(ans>a[i]){
            ans=a[i];
            cnt++;
        }
    }
    cout << cnt <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
ll mod=1e9+7;
ll MOD=1e18;
using namespace std;
/*bool comp(pair<int,int>p,pair<int,int>q)
{
    if(p.first!=q.first)
    {
        return (p.first<q.first);
    }else
    {
        return (p.second<q.second);
    }
}
*/
int main()
{
    int n,i;
    cin>>n;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        s[i]=((s[i]-'A'+n)%26)+'A';
    }cout<<s;
}


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

import copy

def main(): 

    row = list(input().split())
    row = list(map(int,row[0]))

    S = copy.deepcopy(row)
    count = 0
    for i in range(1,len(S)):
        if S[i-1] == S[i]:
            if S[i-1] == 1: S[i] = 0
            else: S[i] = 1
            count+=1

    S = copy.deepcopy(row)
    count2 = 1
    if S[0] == 1: 
        S[0] = 0
    else: 
        S[0] = 1
    for i in range(1,len(S)):
        if S[i-1] == S[i]:
            if S[i-1] == 1: S[i] = 0
            else: S[i] = 1
            count2+=1
    print(min(count,count2))

if __name__ == "__main__":
    main()
    

Measured memory_bytes: 48604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int W = sc.nextInt();
			int a = sc.nextInt();
			int b = sc.nextInt();

			// 連結
			if ((a <= b && (a + W) >= b) || (a <= (b + W) && (a + W) >= (b + W))) {
				System.out.println(0);

				// b が大きい
			} else if ((a + W) < b) {
				System.out.println(b - (a + W));

				// a が大きい
			} else if (a > (b + W)) {
				System.out.println(a - (b + W));
			}

		}
	}
}

Measured memory_bytes: 21972
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<cassert>
#include<stack>
#include<fstream>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

int main(){
	char c[3];
	rep(i,3)cin>>c[i];
	sort(c,c+3);
	if(c[0]==c[2])cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
// const double PI = acos(-1);
const double PI = 3.14159;

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

namespace Comb{
inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int n, int m) {
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}
}

int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) std::swap(a, b);
    for (int i = 1; i <= b; i++) printf("%d", a);
    puts("");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int binary_search(int* A, int size, int n){
  int l = 0, r = size;
  while(l < r){
    int c = (l+r)/2;
    if(A[c] == n) return 1;
    if(A[c] < n) l = c+1;
    else r = c;
  }
  return 0;
}

int main(){
  int S[100000], T[50000], n, q, i, cnt = 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++) cnt += binary_search(S, n, T[i]);
  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 1184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();
			lineBC = scanner.nextInt();
			lineCA = scanner.nextInt();

			if (lineCA <= (lineAB + lineBC)) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

counter = [[0,0] for i in range(N)]
count = 0
for i in range(N):
    if S[i] == '#':
        count += 1
    counter[i][0] = count

count = 0
for i in range(N)[::-1]:
    if S[i] == '.':
        count += 1
    counter[i][1] = count

mini = N
for i in range(N-1):
    if mini > counter[i][0] + counter[i+1][1]:
        #print(i, counter[i][0] + counter[i+1][1])
        mini = counter[i][0] + counter[i+1][1]

white = S.count('.')
mini = 0 if white == 0 or white == N else mini
mini = white if white < mini else mini
white = S.count('#')
mini = white if white < mini else mini
print(mini)
#print(counter)


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

int main(){
	int n, p;
	std::cin >> n >> p;
	std::vector<int> v(n);
	int even = 0;
	int odd = 0;
	for(int i = 0; i < n; i++){
		std::cin >> v[i];
		if(v[i] % 2 == 0)even++;
		else odd++;
	}

	long long ans = 0;
	std::vector<long long> dp(50001, 0);
	

	dp[0] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 50000; j >= 0; j--){
			if(dp[j] > 0)dp[j + v[i]] += dp[j];
		}
	}

	for(int i = 0; i < 50001; i++){
		if(dp[i] && i % 2 == p)ans += dp[i];
	}
	std::cout << ans << std::endl;

}


Measured memory_bytes: 640
from collections import deque
deq = deque()
def check(f1, f2, f3):
    return (f2[0] - f1[0]) * (f3[1] - f2[1]) >= (f2[1] - f1[1]) * (f3[0] - f2[0])
def f(f1, x):
    return f1[0]*x + f1[1]
def add_line(a, b):
    f1 = (a, b)
    while len(deq) >= 2 and check(deq[-2], deq[-1], f1):
        deq.pop()
    deq.append(f1)
def query(x):
    while len(deq) >= 2 and f(deq[0], x) >= f(deq[1], x):
        deq.popleft()
    return f(deq[0], x)

N, C = map(int, input().split())
*H, = map(int, input().split())

add_line(-2*H[0], H[0]**2)
for i in range(1, N):
    y = H[i]**2 + C + query(H[i])
    add_line(-2*H[i], y + H[i]**2)
print(y)

Measured memory_bytes: 32360
using System;
using System.Collections.Generic;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            var hList = new List<int>();
            var wList = new List<int>();

            while (true)
            {
                String s = Console.ReadLine();
                String[] strInputList = s.Split();
                int h = int.Parse(strInputList[0]);
                int w = int.Parse(strInputList[1]);

                if (h == 0 && w == 0)
                {
                    break;
                }

                hList.Add(h);
                wList.Add(w);
            }

            for (int i = 0; i < hList.Count; i++)
            {
                int h = hList[i];
                for (int j = 0; j < h; j++)
                {
                    String simbol = null;

                    int w = wList[i];
                    for (int x = 0; x < w; x++)
                    {
                        simbol = simbol + "#";
                    }
                    Console.WriteLine(simbol);
                }
                Console.WriteLine("");
            }
        }
    }
}


Measured memory_bytes: 20016
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Water Pipe Construction (Warshall-Floyd)
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			StringTokenizer st = new StringTokenizer(line);
			int n = parseInt(st.nextToken());  // ??????????????¨???????????°?????° n (3 <= n <= 100)
			int m = parseInt(st.nextToken());  // ?????°????????¶???????????° m (2 <= m <= 1000)
			int s = parseInt(st.nextToken());  // ?°´?????¨???????????°????????? s
			int g1 = parseInt(st.nextToken()); // ?°??°´??????????????°??¨?????? 2 ?????????????????°????????? g1???g2
			int g2 = parseInt(st.nextToken()); // ????????????????????????

			if ((n | m | s | g1 | g2) == 0) break;

			s--;
			g1--;
			g2--;

			int[][] cost = new int[n][n];
			for (int i = 0; i < n; i++) {
				Arrays.fill(cost[i], 1 << 20);
				cost[i][i] = 0;
			}

			for (int i = 0; i < m; i++) {
				st = new StringTokenizer(br.readLine());
				int b1 = parseInt(st.nextToken()); // ??????????§????????????°?????????
				int b2 = parseInt(st.nextToken()); // ???????????????????????°?????????
				int c = parseInt(st.nextToken());  // ?????° b1 ???????????° b2 ?????????????°??°´??????????¨?????????????????????????????????? (1 <= c <= 1000)
				b1--;
				b2--;
				cost[b1][b2] = c;
			}

			// solve
			for (int k = 0; k < n; k++) {
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < n; j++) {
						cost[i][j] = Math.min(cost[i][j], cost[i][k] + cost[k][j]);
					}
				}
			}

			int min = cost[s][g1] + cost[s][g2];
			for (int i = 0; i < n; i++) {
				min = Math.min(min, cost[s][i] + cost[i][g1] + cost[i][g2]);
			}

			System.out.println(min);

		} // end while
	} // end main
}

Measured memory_bytes: 37740