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

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

    int x,n,a;
    cin >> x >> n;
    int _min = INT_MAX;
    int _min_ele = INT_MAX;

    unordered_map<int, bool> u;
    for (int i=0;i<n;i++) {
        cin >> a;
        u[a] = true;
    }

    int i=x;
    int j=x;
    while (i>=0) {
        while (i>=0 && u.find(i) != u.end()) i--;
        while (j<=x+abs(x-i) && u.find(j) != u.end()) j++;

        if (abs(x-i) <= abs(x-j)) {
            cout << i ;
            return 0;
        } else {
            cout << j;
            return 0;
        }
    }
    while (u.find(j) != u.end()) j++;
    cout << j;
    return 0;
}


Measured memory_bytes: 3652
# -*- coding: utf-8 -*-
# 整数の入力

A = int(input())
B = int(input())
C = int(input())
X = int(input())

i = 0
j = 0
k = 0
cnt = 0
sum = 0
while i <= A:
    j = 0
    if i>50:
        break
    while j <= B:
        k = 0
        if j>50:
            break
        while k <= C:
            if k>50:
                break
            else:
                sum = 500*i + 100*j + 50*k
                if X == sum:
                    cnt += 1
                k += 1
                sum = 0
        j += 1
    i += 1

print(cnt)

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

bool is_prime(int x) {
    if (x == 1)
        return true;

    for (int i = 2; i*i <= x; i++) {
        if (x % i == 0)
            return false;
    }

    return true;
}

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

    while(true) {
        if (is_prime(x))
            break;
        x++;
    }
    cout << x << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))

money=1000
stock=0

for i in range(N-1) :
    if A[i]<A[i+1] :
        stock=money//A[i]
        money-=stock*A[i]
        money+=stock*A[i+1]

    else :
        continue

print(money)


Measured memory_bytes: 9108
N, K = list(map(int,input().split()))
A = list(map(int,input().split()))
dic = {}
for i in range(N):
    data = A[i]
    if data in dic:  dic[data] += 1
    else:  dic[data] = 1
dic = sorted(dic.values())
ans = 0
l = len(dic)
for i in range(l - K):
    ans += dic[i]
print(ans)

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

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

typedef long long ll;

const int INF=1e9+7;

int pole[30];

int main(){
	int n;
	while(cin>>n && n){
		fill(pole,pole+30,0);
		int ans=0;
		char win;
		rep(i,n){
			char c;
			cin>>c;
			pole[c-'A']++;
			int m1=29,m2=29;
			rep(i,30){
				if(pole[i]>pole[m1]){
					m2=m1;
					m1=i;
				}
				else if(pole[i]>pole[m2])m2=i;
			}
			if(pole[m1]>pole[m2]+n-i-1&& ans==0){
				ans=i+1;
				win=m1+'A';
			}
		}
		if(ans!=0)cout<<win<<" "<<ans<<endl;
		else cout<<"TIE"<<endl;
	}
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e16;
template<class T> inline bool chmax(T &a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<long long> A(N);
    vector<long long> sum(N + 1, 0);
    vector<long long> plu(N + 1, 0);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        sum[i + 1] = sum[i] + A[i];
        plu[i + 1] = plu[i] + max(A[i], 0LL);
    }
    
    long long ans = -INF;
    
    for(int i = 0; i + K <= N; i++){
        long long res = plu[N];
        res += max(sum[i + K] - sum[i], 0LL);
        res -= plu[i + K] - plu[i];
        chmax(ans, res);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int   ull;
typedef long long int            ll;
int main()
{
    int n,a,b,i,s=0;
    cin>>n>>a;
    for(i=1;i<=a;i++)
    {
        cin>>b;
        s+=b;
    }
    if(s>n)
        cout<<-1<<endl;
    else
        cout<<n-s<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int k,x;
	cin >> k >> x;
	for(int i=x-k+1; i<=x+k-1; i++){
		cout << i;
		if(i==x+k-1){
			cout << endl;
		} else {
			cout << " ";
		}
	}
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,M;
	cin>>N>>M;
	vector< vector<int> > seg(M);
	vector<int> dat(2);//
	for(int i=0;i<M;++i){
		cin>>dat[0]>>dat[1];//A<B
		seg[i] = dat;
	}
	sort(seg.begin(),seg.end());
	int ans = 0;//最大N-1
	priority_queue<int,vector<int>,greater<int> > minpq,zero;
	int pos = 0;//pos位置までは条件を満たしている
	int index = 0;//次に見るクエリの番号
	
	for(int i=1;i<=N;++i){
		while(index<M && seg[index][0]==i){
			minpq.push( seg[index][1] );
			++index;
		}
		if(minpq.size() ){
			int next = minpq.top();
			if(i+1==next){
				//iの右側の辺を切る
				++ans;
				minpq = zero;//clear
			}
		}
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 6144
import sys

N = int(input())

def z(n):
    if n < 2:
        return 0
    elif n % 2 == 1:
        return 0
    else:
        m = n // 2
        return f(m)

def f(m):
    if m < 5:
        return 0
    a = m // 5
    return a + f(m // 5)
    
        
print(z(N))

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10**9)

n,e = [int(i) for i in input().split()]
mat = [[] for i in range(n)]
for i in range(e):
    a,b = [int(i) for i in input().strip().split()]
    mat[a-1].append(b-1)

dp=[-1 for i in range(n)]

def cal(i):  
    if mat[i]==[]:
        return 0
    else:
        if dp[i]==-1:
            nei = mat[i]
            dp[i] = max([1+cal(j) for j in nei])
        return dp[i]


m=0
for i in range(n):
    if dp[i]==-1:
        m=max(m,cal(i))
print(m)

                
    




Measured memory_bytes: 109924
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] w = new int[n];

    for (int i = 0; i < n; i++) {
      w[i] = sc.nextInt();
    }

    int gap = 0;
    int min = 100;


    for (int t = 1; t < n; t++) {
      int total1 = 0;
      int total2 = 0;
      for (int j = 0; j < t; j++) {
        total1 += w[j];
      }
      for (int k = t; k < n; k++) {
        total2 += w[k];
      }
      gap = Math.abs(total2 - total1);
      min = Math.min(min,gap);
    }
    System.out.println(min);
  }

}


Measured memory_bytes: 21972
#include<iostream>
using namespace std;
int main(){
int x;
cin>>x;
switch(x){
case 3:
 cout<<"YES";
 break;
case 5:
 cout<<"YES";
 break;
case 7:
 cout<<"YES";
 break;
 default:
    cout<<"NO";








    }
return 0;
}


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

typedef long long ll;
const ll INF = 1e12;

int main()
{
  std::string s;
  std::string::iterator it;
  std::cin >> s;

  ll ida = +INF;
  ll idb = 0;
  for (it = s.begin(); it != s.end(); it++) {
    ll idx = std::distance(s.begin(), it);
    if (ida == INF && *it == 'A') {
      ida = idx;
    }
    if (*it == 'Z') {
      idb = idx;
    }
  }

  std::cout << idb - ida + 1 << std::endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin>>N;
    string yomi;
    N=N%10;
    if(N==0 or N==1 or N==6 or N==8){
        cout<<"pon"<<endl;
    }
    else if(N==3){
        cout<<"bon"<<endl;
    }
    else{
        cout<<"hon"<<endl;
    }
    
    
}

Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm> // sort
#include <math.h>

#define DEBUG 0

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
                    //999999997000000003
                    //1000000000000000000

using namespace std;

int solve(){
    int N;
    cin >> N;
    vector <int> a(N);
    REP(i, N)cin >> a[i];
    sort(a.rbegin(),a.rend());
    //最初に来た人は、a[0]
    //適切に割り込む
    ll res = 0;
    for(int i = 1; i < N; ++i)
    {
        res += a[i/2];
    }
    cout << res << endl;

    return 0;

}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 4056
import numpy as np
N, K, Q = map(int, input().split())
A = np.zeros(N, dtype=np.int32)
for idx in range(Q):
    A[int(input())-1] += 1

A = A + K - Q
for i in A:
    if i <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 15504
#include<bits/stdc++.h>
using namespace std;
int main(){
 int N,M;
  cin>>N>>M;
  vector <int> A(N);
  for(int i=0;i<N;i++){
   cin>>A.at(i);
  }
    int sum=0;
  for(int i=0;i<N;i++){
  sum+=A.at(i);
  
  }
  sort(A.begin(),A.end());
  string s;
  if(sum%4*M==0){
    if(sum/(4*M)<=A.at(N-M)) s="Yes";else s="No";
  }else{
    if((sum/(4*M))+1<=A.at(N-M)) s="Yes"; else s="No";
  } cout<<s<<endl;
  
 

 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <numeric>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	int N,M;
	cin >> N >> M;
	vector<ll> A(N);
	vector<pair<ll,ll>> B(M);
	rep(i,0,N){
		cin >> A[i];
	}
	sort(A.begin(),A.end());
	
	rep(i,0,M){
		ll tmp1,tmp2;
		cin >> tmp1 >> tmp2;
		B[i].first = tmp2; B[i].second = tmp1;
	}
	sort(B.begin(),B.end(),greater<pair<ll,ll>>());
	int ptr=0;
	rep(i,0,M){
		rep(j,0,B[i].second){
			if(ptr > N-1){
				cout << (ll)(accumulate(all(A),(ll)0)) << endl;
				return 0;
			}
			if(A[ptr]<B[i].first){
				A[ptr] = B[i].first;
				ptr++;
			}else{
				break;
			}
		}
	}
	cout << (ll)(accumulate(all(A),(ll)0)) << endl;
}


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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c,d;

    cin >> a >> b >> c >>d;

    if( max(a, c) <=  min(b, d) ){
        cout << min(b, d) - max(a, c) << endl;
    }
    else{
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on June 15, 2018, 12:32 PM
 */

#include <stdio.h>
#include <stdlib.h>

/*
 * 
 */

int gcd(
    int x,
    int y
);

int main(int argc, char** argv) {
    int x, y, a;
    scanf("%d %d", &x, &y);
    a = gcd(x, y);
    printf("%d\n", a);
    return (EXIT_SUCCESS);
}

int gcd(int x, int y)
{
        while (x != y)
        {
                if (x > y)      x = x - y;
                else            y = y - x;
        }
        return x;
}



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

int main() {

    int N;
    cin >> N;

    vector<long> A(N, 0);

    for (int i = 0; i < N; i++) {
        long a;
        cin >> a;
        if (a == 0) {
            cout << 0;
            return 0;
        }
        A.at(i) = a;
    }

    long ans = 1;

    for (int i = 0; i < N; i++) {
        if (A.at(i) > 1000000000000000000 / ans) {
            cout << -1;
            return 0;
        }
        ans *= A.at(i);
    }

    cout << ans;

}

Measured memory_bytes: 4028
gets
a=gets.split.map &:to_i
puts _=(x=a.last
i=0
(0...a.size).map{|j|a[j]<=x&&(a[i],a[j]=a[j],a[i]
i+=1)}
a[0,i-1]<<"[#{x}]"<<a[i,1e5])*" "

Measured memory_bytes: 21832
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		String a = sc.next();
		String b = sc.next();

		boolean flg = false;

		String[] str = a.split("");



		for (int i = 0; i < str.length; i++) {

			StringBuffer sb = new StringBuffer();

			sb.append(str[str.length-1]);

			for(int j = 0; j < str.length-1; j++ ) {

				sb.append(str[j]);
			}

			if (String.valueOf(sb).equals(b)) {
				flg = true;
				break;
			}

			str = String.valueOf(sb).split("");

		}

		if (flg) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    ll N, M;
    cin >> N >> M;
    ll ans = min(N,M/2);
    N-=ans;
    M-=ans*2;
    cout << ans + M/4 << '\n';
}


Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

typedef pair<lli,int> mp;
int n;

#include<stack>

int main(void){
	scanf("%d",&n);
	lli ans=0;
	stack<mp> sta;
	sta.push(mp(-5,-1));
	reg(i,0,n){
		lli a=-1;
		if(i<n)scanf("%lld",&a);
		for(;;){
			mp tp=sta.top();
			if(tp.fir<a)break;
			sta.pop();
			int cp=tp.sec;
			int lp=sta.top().sec;
			
			ans += tp.fir * ((lli)(cp-lp)) * ((lli)(i-cp));
		}
		sta.push(mp(a,i));
	}
	printf("%lld\n",ans);
		
	return 0;
}






Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;


int main(){

    ll H, W;
    cin >> H >> W;

    vector<string> s(H);
    for(int i = 0; i < H; i++){
        cin >> s[i];
    }    
    
    vector<ll> cnt(26);
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cnt[ s[i][j] - 'a' ] ++;
        }
    }


    if(H % 2 == 0 && W % 2 == 0){
        for(int i = 0; i < 26; i++){
            cnt[i] = cnt[i] % 4;
        }
        ll ans = accumulate(all(cnt), 0ll);
        if(ans > 0){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
    }  
    else if(H % 2 == 0 || W % 2 == 0){

        ll min = 0;
        for(int i = 0; i < 26; i++){
            cnt[i] = cnt[i] % 4;
        }
        for(int i = 0; i < 26; i++){
            if(cnt[i] >= 2){
                min += 2;
            }
            cnt[i] = cnt[i] % 2;
        }
        ll ans = accumulate(all(cnt), 0ll);
        if(ans > 0){
            cout << "No" << endl;
        }
        else if(H % 2 == 0){
            if(min <= H){
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }
        else if(W % 2 == 0){
            if(min <= W){
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }
    }
    else{

        ll min = 0;
        for(int i = 0; i < 26; i++){
            cnt[i] = cnt[i] % 4;
        }
        for(int i = 0; i < 26; i++){
            if(cnt[i] >= 2){
                min += 2;
            }
            cnt[i] = cnt[i] % 2;
        }
        ll ans = accumulate(all(cnt), 0ll);
        if(ans != 1){
            cout << "No" << endl;
        }
        else if(H + W - 1 >= min){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }

}

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

int main(){
  int X;
  cin >> X;
  int Ans=0;
  int Y=X/500;
  Ans+=1000*Y;
  X-=Y*500;
  Y=X/5;
  Ans+=5*Y;
  cout << Ans << endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
array_a = gets.split(" ").map(&:to_i)
array_b = gets.split(" ").map(&:to_i)

result = 0
array_b.size.times do |i|
	if array_a[i] - array_b[i] < 0
		result += array_a[i]
		if array_a[i+1] - (array_b[i] - array_a[i]) >= 0
			result += array_b[i] - array_a[i]
			array_a[i+1] = array_a[i+1] - (array_b[i] - array_a[i])
		else
			result += array_a[i+1]
			array_a[i+1] = 0
		end
	else
		result += array_b[i]
	end
end

puts result


Measured memory_bytes: 16940
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

int main(){
  int N, M; cin >> N >> M;
  vector<pair<int, int>>key;
  rep(i, M){
    int a, b; cin >> a >> b;
    int S = 0;
    rep(j, b){
      int c; cin >> c; c--; S |= (1<<c);
    }
    key.push_back({a, S});
  }
  int dp[M+1][(1<<N)];
  rep(i, M+1){
    rep(j, (1<<N)){
      dp[i][j] = inf;
    }
  }
  rep(i, M+1){
    dp[i][0] = 0;
  }
  rep(i, M){
    rep(j, 1<<N){
      int t = j|(key[i].second);
      dp[i+1][t] = min(dp[i+1][t], dp[i][j]+key[i].first);
      dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
    }
  }
  int tmp = (1<<N)-1;
  int ans = dp[M][tmp];
  if(ans == inf) cout << -1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 16256
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500 + j*100 + k*50 == x:
                ans += 1
print(ans)

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll N,maxh,ans;
  vl H;
  cin >> N;
  REP(i,N){
		int x;
		cin >> x;
		H.push_back(x);
	}
  maxh = H[0];
  ans = 1;
  REP(i,N-1){
    if(H[i+1]>=maxh){
      ans = ans+1;
      maxh=H[i+1];
    }
  }
  cout << ans<< endl;
  return 0;
}

Measured memory_bytes: 256
N,T=map(int,input().split())

CT=[[0,0]]*N
i=0
while i<N:
    CT[i]=list(map(int,input().split()))
    i+=1

CT=sorted(CT)

ans='TLE'
for x,y in CT:
    if y<=T:
        ans=x
        break
print(ans)


Measured memory_bytes: 3060
def primefactor(x):
    fac=[]
    for i in xrange(2,int(x**0.5)+1):
        while x%i==0:
            fac+=[i]
            x=x/i
    if x!=1:
        fac+=[x]
    return fac
n=input()
anslist=list(set(primefactor(n)))
ans=n
for i in anslist:
    ans=ans*(1-1.0/i)
print(int(ans))

Measured memory_bytes: 6616
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("inp.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif

    int n;
    cin>>n;
    
    map<int,int> m;

    for(ll a=1;a<=10000;++a) {
        for(ll b=1;b<=10000;++b) {
            ll temp = a*a + a*b;
            if(temp > 1e4) break;
            
            for(ll c=1;c<=10000;++c) {
                ll ans = a*a + b*b + c*c;
                if(ans > 1e4) break;

                ans += a*b + b*c + a*c;
                if(ans > 1e4) break;

                m[ans] += 1;
            }
        }
    }

    for(int i=1;i<=n;++i) {
        cout<<m[i]<<"\n";
    }

    return 0;
}

Measured memory_bytes: 4076
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N = int(input())
    ans = N//3
            
    print(ans)
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  for(int i = 100; i >= 1; i--) {
    if(a % i == 0 && b % i == 0) k--;
    if(k == 0) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int A,B;
  cin >> A >> B ;
  
  if(max(A+B,A-B) > max(A+B,A*B)){
    cout << max(A+B,A-B) <<endl;
  }else{
    cout << max(A+B,A*B) << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		int K = sc.nextInt();
		
		int[] map = new int[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextInt();
		}
		
		int[] dp = new int[N];
		dp[0] = 0;
		dp[1] = Math.abs(map[1] - map[0]);
		for (int i = 2; i < N; i++) {
			
			int tmp = Integer.MAX_VALUE;
			for (int j = 1; j <= K; j++) {
				if (i - j < 0) {
					break;
				}
				
				tmp = Math.min(tmp, dp[i-j] + Math.abs(map[i-j] - map[i]));
			}
			
			dp[i] = tmp;
		}
		
		System.out.println(dp[N-1]);
	}
}

Measured memory_bytes: 52604
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string s1;cin>>s1;
    string s2;cin>>s2;
    string s3;cin>>s3;
    printf("%c%c%c",s1[0],s2[1],s3[2]);
    
    
}


Measured memory_bytes: 256
//2018-6-7
//miaowey
//
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)

#define N (4000 + 5)

int n, m, eu[N], ev[N], cnt[N];
int en, Begin[N], Nxt[N], To[N];

bool flag[N], use[N];
vector<int> P[N], cov[N];

inline void Add(int u, int v){
	To[++en] = v; Nxt[en] = Begin[u]; Begin[u] = en;
}

bool Dfs(int u, int F, int aim, vector<int> &s){
	if(u == aim) return true;
	
	for(int i = Begin[u]; i; i = Nxt[i]){
		int v = To[i];
		if(v == F) continue;
		if(Dfs(v, u, aim, s)) {s.pb(i); return true;}
	}

	return false;
}

int main(){	
	int u, v, ans = 0;
	en = 1;

	scanf("%d%d", &n, &m);
	For(i, 1, n - 1){
		scanf("%d%d", &u, &v);
		Add(u, v), Add(v, u);
	}

	For(i, 1, m){
		scanf("%d%d", &u, &v);
		eu[i] = u, ev[i] = v;

		Dfs(u, 0, v, P[i]);
		
		for(int t : P[i]) ++cnt[t >> 1], cov[t >> 1].pb(i);
	}

	For(i, 1, n - 1) ans += min(cnt[i], 2);
	
	while(true){
	
		int id = 0;
		For(i, 1, n - 1) if(cnt[i] == 1 && (flag[i << 1] ^ flag[i << 1 | 1])){
			id = flag[i << 1]? (i << 1 | 1): (i << 1);
			break;
		}

		if(!id){
			For(i, 1, n - 1) if(cnt[i]) id = i << 1;
			if(!id) break;
		}

		int o = id >> 1;
		while(use[cov[o].back()]) cov[o].pop_back();
		
		int y = cov[o].back();
		use[y] = true;
		
		bool rev = false;
		for(int t : P[y]) if((t >> 1) == o){
			if(id ^ t) rev = true;
			break;
		}

		if(rev){
			swap(eu[y], ev[y]);
			for(int &t : P[y]) t ^= 1;
		}

		for(int t : P[y]) --cnt[t >> 1], flag[t] = true;
	}

	printf("%d\n", ans);
	For(i, 1, m) printf("%d %d\n", eu[i], ev[i]);

	return 0;
}

Measured memory_bytes: 13952
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,m;
    cin>>n>>m;
    bool c[200010]={},d[200010]={};
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        if(a==1) c[b]=1;
        if(b==n) d[a]=1;
    }
    rep2(i,1,n){
        if(c[i]&&d[i]){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;

    int str_len = s.size();
    vector<int> ck_ac(str_len, 0);
    rep(i, str_len - 1)
    {
        if (s.substr(i, 2) == "AC")
        {
            ck_ac[i + 1]++;
        }
    }

    vector<int> cum(str_len + 1, 0);
    rep(i, str_len) cum[i + 1] = cum[i] + ck_ac[i];

    rep(i, q)
    {
        int l, r;
        cin >> l >> r;

        cout << cum[r] - cum[l] << endl;
    }

    return 0;
}

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

int main(){
    int K,N;
    cin >> K >> N;
    vector<int> A(N);
    rep(i,N){
        cin >> A.at(i);
    }
    sort(A.begin(),A.end());
    vector<int> ans(N);
    for(int i = 0; i < N; i++){
        if (i == (N - 1)){
            ans.at(N - 1) = abs(K - A.at(N - 1)) + abs(A.at(0));
        }
        else {
            ans.at(i) = A.at(i + 1) - A.at(i);
        }
    }
    sort(ans.begin(),ans.end());
    reverse(ans.begin(),ans.end());
    cout << K - ans.at(0) << endl;
}

Measured memory_bytes: 1920
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(time(NULL));

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	ll h, w, a, b;
	cin >> h >> w >> a >> b;

	for(int i = 0; i < h; i++, cout << '\n')
		for(int j = 0; j < w; j++)
			cout << ((j >= a) ^ (i >= b));
}


Measured memory_bytes: 1280
A,B=map(int,input().split())
A0=[100*A/8,100*(A+1)/8]
B0=[100*B/10,100*(B+1)/10]
S0=max(A0[0],B0[0])
S1=min(A0[1],B0[1])
if int(S0)>=S0 and int(S0)<S1:
    print(int(S0))
elif int(S0)+1<S1:
    print(int(S0)+1)
else:
    print(-1)

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

using namespace std;

const int maxn = 1e5 + 30;
int freq[maxn];

int main(){
  int n; cin >> n;
  int m; cin >> m;
  for(int i=0;i<m;i++){
    int a,b; cin >> a >> b;
    freq[a] ++;
    freq[b] ++;
  }
  bool ok = true;
  for(int i=1;i<=n;i++){
    if(freq[i] % 2 == 0) continue;
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x, y;
    cin >> x >> y;
    if (y & 1 || y < (x << 1) || y > (x << 2))
    {
        puts("No");
    }
    else
    {
        puts("Yes");
    }
    return 0;
}

Measured memory_bytes: 3632
use std::io::stdin;

fn read() -> u32 {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn main() {
    let n = read();
    let n = format!("{:b}", n);
    println!("{}", 1 << n.len() - 1);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  vector<ll> x(n);
  rep(i, n) cin >> x[i];

  ll ans = 0;
  rep(i, n - 1) {
    ans += min(b, a * (x[i + 1] - x[i]));
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 1024
N,K = list(map(int,input().split()))

B = [[0]*(2*K) for i in range(2*K)]
W = [[0]*(2*K) for i in range(2*K)]

for i in range(N):
    x,y,c = input().split()
    x,y = int(x)%(2*K),int(y)%(2*K)
    if c=="B":
        B[x][y]+=1
    else:
        W[x][y]+=1

BS = [[0]*(2*K+1) for i in range(2*K+1)]
WS = [[0]*(2*K+1) for i in range(2*K+1)]

for i in range(2*K):
    for j in range(2*K):
        BS[i+1][j+1] = BS[i][j+1] + BS[i+1][j] - BS[i][j] + B[i][j]
        WS[i+1][j+1] = WS[i][j+1] + WS[i+1][j] - WS[i][j] + W[i][j]

def BOX(x1,y1,x2,y2,S):
    return S[x2][y2]-S[x1][y2]-S[x2][y1]+S[x1][y1]

def smax(a,b):
    if a<b:
        return b
    else:
        return a

ans = 0
for i in range(K):
    for j in range(K):
        count = 0
        count += BOX(0,0,i,j,WS) + BOX(i,0,i+K,j,BS) + BOX(i+K,0,2*K,j,WS)
        count += BOX(0,j,i,j+K,BS) + BOX(i,j,i+K,j+K,WS) + BOX(i+K,j,2*K,j+K,BS)
        count += BOX(0,j+K,i,2*K,WS) + BOX(i,j+K,i+K,2*K,BS) + BOX(i+K,j+K,2*K,2*K,WS)
        ans = smax(smax(count,N-count),ans)
print(ans)

Measured memory_bytes: 163976
using System;
using System.Linq;

class prog{
  static void Main(){
    int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int X = input[0];
    int Y = input[1];
    int Z = input[2];
    
    Console.WriteLine((X - Z) / (Y + Z));
  }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d,x;cin>>n>>d>>x;
    int a;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>a;
        for(int j=0;j<d;j++){
            if(j*a+1<=d){
                ans++;
            }
        }
    }
    ans+=x;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;



int32_t main(){
    FAST;

    int n,d;    cin >> n >> d;
    int i = d;
    int len = 2*i + 1;

    if(n % len == 0){
        cout << n/len;
    }else{
        cout << n/len +1;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cassert>
using namespace std;

struct LowestCommonAncestor {
    size_t n;
    size_t size() const { return n; }
    vector<int> color, parent, depth, topDepth, goUp, visited;
    vector<vector<int>> g;
    LowestCommonAncestor(size_t n_) : n(n_), g(n) {}
    void addEdge(int u, int v){
        g[u].push_back(v); g[v].push_back(u);
    }
    void decomp(int root = 0, int B = 500){
        parent.assign(n, -1); depth.assign(n, 0);
        topDepth.assign(n, 0); goUp.assign(n, -1); visited.assign(n, false);
        vector<int> tord;
        vector<int> q(n+1); int l = 0, r = 0;
        q[r++] = root;
        while(l != r){
            int v = q[l++]; visited[v] = true;
            tord.push_back(v);
            for(int c : g[v]){
                if(!visited[c]){ parent[c] = v; depth[c] = depth[v] + 1; q[r++] = c; }
            }
        }
        swap(color, visited); // ?????¢????????±??????
        color.assign(n, 0);
        int c = 0;
        for(int u : tord){
            if(color[u]) continue;
            c++;
            l = 0, r = 0;
            q[r++] = u;
            for(int i = 0; i < B && l != r; i++){
                int v = q[l++];
                color[v] = c; goUp[v] = parent[u]; topDepth[v] = depth[u];
                for(int c : g[v]) if(!color[c]) q[r++] = c;
            }
        }
    }
    int solve(int u, int v){
        while(topDepth[u] > topDepth[v]) u = goUp[u];
        while(topDepth[u] < topDepth[v]) v = goUp[v];
        while(depth[u] > depth[v]) u = parent[u];
        while(depth[u] < depth[v]) v = parent[v];
        while(u != v) u = parent[u], v = parent[v];
        return u;
    }
};

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

int main(){
    int n;
    cin >> n;
    LowestCommonAncestor g(n);
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int c;
            cin >> c;
            g.addEdge(i,c);
        }
    }
    g.decomp(0);
    int q;
    cin >> q;
    rep(i,q){
        int u,v;
        cin >> u >> v;
        cout << g.solve(u,v) << endl;
    }
}

Measured memory_bytes: 10028
def p_e():
    N = int(input())
    *C, = map(int, input().split())
    C.sort()
    mod = 10 ** 9 + 7
    ans = 0
    for i in range(N):
        ans += C[N - i - 1] * (i + 2)
        ans %= mod
    print((4 ** (N - 1)) * ans % mod)
    
p_e()

Measured memory_bytes: 96588
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007    //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

// debug
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v)   \
  cout << #v << ":";   \
  REP(i, v.size())     \
  cout << " " << v[i]; \
  cout << endl
#define DEBUG_ARR(v, n) \
  cout << #v << ":";    \
  REP(i, n)             \
  cout << " " << v[i];  \
  cout << endl

signed main()
{
  string S;
  cin >> S;
  if (S == "ABC")
  {
    cout << "ARC" << endl;
  }
  else
  {
    cout << "ABC" << endl;
  }
}

Measured memory_bytes: 3624
N = int(input())
A = input().split(' ')
A = [int(A[i]) for i in range(N)]
NN = 1
count = 0
check = []
for i in range(N):
  if not A[i] == NN:
    count += 1
  else:
    check.append(A[i])
    NN += 1
if not check:
  print(-1)
else:
  print(count)

Measured memory_bytes: 32220
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s,t; cin>>s>>t;

    vector<int> a(26),b(26);
    REP(i,s.size()) a[s[i]-'a']++;
    REP(i,t.size()) b[t[i]-'a']++;
    sort(ALL(a)); sort(ALL(b));

    cout<<(a==b? "Yes":"No")<<endl;
}


Measured memory_bytes: 776
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int n,k;
  scanf("%d%d",&n,&k);

  int ans=1;
  while(n/k>0){
    n/=k;
    ans++;}
  printf("%d\n",ans);

  return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,result="";
            boolean first=true;
            int n=0,i=0,taro=0,hana=0;
            while ((line = br.readLine()) != null) {
            	if(first){
            		n=Integer.parseInt(line);
            		first=false;
            	}else{
            		String[] str=line.split(" ");
            		if(str[0].compareTo(str[1])>0){
            			taro+=3;
            		}else if(str[0].compareTo(str[1])<0){
            			hana+=3;
            		}else{
            			taro+=1;
            			hana+=1;
            		}
            		i++;
            		if(i==n){
            			System.out.println(taro+" "+hana);
            		}
            	}
            	
            }
        }
    }


}

Measured memory_bytes: 25888
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N,M;
  cin>>N>>M;
  int max=N/2+1;
  int min=max-1;
  map<int,bool>mp;
  REP(i,M){
    if(2*max-2*min==N || mp[min+N-max] || mp[max-min])max++;
    cout<<max<<' '<<min<<endl;
    mp[min+N-max]=true;
    mp[max-min]=true;
    max++;min--;
  }
}


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

typedef long long ll;

int main(){
  int n; cin >> n;
  string s1, s2;
  cin >> s1 >> s2;

  ll ans=1;
  enum mode{NONE, X, Y};
  mode current = NONE;
  for(int i=0; i<n; i++){
    if(s1[i]==s2[i]){
      if(current==NONE){
        ans *= 3;
      }else if(current==X){
        ans *= 2;
      }else if(current==Y){
        ans *= 1;
      }
      current = X;
    }

    else if(s1[i]!=s2[i]){
      if(current==NONE){
        ans *= 6;
      }else if(current==X){
        ans *= 2;
      }else if(current==Y){
        ans *= 3;
      }
      current = Y;
      i++;
    }

  }

  cout << ans%1000000007 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	int width = 2 * d + 1;

	int ans = (n + width - 1) / width;

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define int long long
using namespace std;
signed main() {
	int N;
	cin >> N;

	cout << N/3 << endl;

	
}


Measured memory_bytes: 3576
#!/usr/bin/env python3
#ABC133 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

l,r = LI()
if r - l >= 2019:
    print(0)
else:
    ans = inf
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ans = min(ans,(i*j)%2019)
    print(ans)


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

const int N = 1e5 + 100;

int n, fa[N], fb[N], is_odd[2][N];

struct Edge {
    int e, *h, *nx, *to, V, E;
    Edge(int V, int E):V(V), E(E) {
        e = 0;
        h = new int [V];
        nx = new int [E];
        to = new int [E];
        memset(h, -1, 4 * V);
    }
    ~Edge() {
        delete h;
        delete nx;
        delete to;
    }
    void clear() {
        e = 0;
        memset(h, -1, 4 * V);
    }
    void add(int u, int v) {
        to[e] = v, nx[e] = h[u], h[u] = e++;
        to[e] = u, nx[e] = h[v], h[v] = e++;
    }
} *tr, *bi;

int dfs(int u, int f) {
    vector<int> odd_son;
    for (int i = tr->h[u]; i != -1; i = tr->nx[i]) {
        int v = tr->to[i];
        if (v != f) {
            v = dfs(v, u);
           // if (v != 0)
                odd_son.push_back(v);
        }
    }
    if (!is_odd[0][u])
        odd_son.push_back(u);
    for (int i = 0; i < (int)odd_son.size() - 1; i += 2) {
        bi->add(odd_son[i], odd_son[i + 1]);
    }
    return odd_son.size() % 2 == 0 ? 0 : odd_son.back();
}

bool vis[N], col[N];

void coloring(int u, int c) {
    vis[u] = true;
    col[u] = c;
    for (int i = bi->h[u]; i != -1; i = bi->nx[i]) {
        int v = bi->to[i];
        if (!vis[v])
            coloring(v, c ^ 1);
    }
}

int main() {
#ifdef lol
    freopen("f.in", "r", stdin);
    freopen("f.out", "w", stdout);
#endif

    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &fa[i]);
        if (fa[i] != -1) {
            is_odd[0][fa[i]] ^= 1;
        }
    }
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &fb[i]);
        if (fb[i] != -1)
            is_odd[1][fb[i]] ^= 1;
    }
    for (int i = 1; i <= n; ++i) {
        if (is_odd[0][i] ^ is_odd[1][i]) {
            puts("IMPOSSIBLE");
            return 0;
        }
    }
    tr = new Edge(n + 1, (n + 1) * 2);
    bi = new Edge(n + 10, (n + 10) * 4);
    int rt;
    for (int i = 1; i <= n; ++i) {
        if (fa[i] == -1) {
            rt = i;
            continue;
        }
        tr->add(i, fa[i]);
    }
    dfs(rt, -1);
    tr->clear();
    for (int i = 1; i <= n; ++i) {
        if (fb[i] == -1) {
            rt = i;
            continue;
        }
        tr->add(i, fb[i]);
    }
    dfs(rt, -1);
    for (int i = 1; i <= n; ++i)
        if (!vis[i]) {
            coloring(i, 1);
        }
    puts("POSSIBLE");
    for (int i = 1; i <= n; ++i) {
        if (is_odd[0][i]) {
            printf("%d ", 0);
        } else {
            printf("%d ", col[i] ? 1 : -1);
        }
    }
    puts("");

    return 0;
}

Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
main()
{
    int a;
    cin>>a;
    if(a<10)cout<<a;
    else if(a<100&&a>=10)cout<<9;
    else if(a<1000&&a>=100)
    cout<<9+a-100+1;
    else if(a<10000&&a>=1000)
    cout<<909;
    else if(a<100000&&a>=10000)
    cout<<909+a-10000+1;
    else if(a==100000)
    cout<<90909;
}

Measured memory_bytes: 256