akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    string r,g,b;
    cin>>r>>g>>b;
    string t=r+g+b;
    cout<<(stoi(t)%4==0?"YES":"NO")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

// combination

const ll MOD = 1e9 + 7;
const ll max_n = 3030303;
ll fact[max_n];
bool fact_init = false;

ll pow(ll a, ll b){
	if(b == 0) return 1;
	if(b % 2 == 1) return a * pow(a, b - 1) % MOD;

	ll d = pow(a, b / 2) % MOD;
	return d * d % MOD;
}

ll comb(ll n, ll k){
	if(!fact_init){
		fact[0] = 1;
		fact[1] = 1;

		for(ll i = 2; i < max_n; i++){
			fact[i] = fact[i-1] * i;
			fact[i] %= MOD;
		}

		fact_init = true;
	}

	ll ret = fact[n];
	ret *= pow(fact[k],MOD-2);
	ret %= MOD;
	ret *= pow(fact[n-k],MOD-2);
	ret %= MOD;
	return ret;

	// X^(-1) = X^(p-2) (mod p) (Fermat's little theorem)
}

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

	ll x, y;
	cin >> x >> y;

	ll sm = x + y;
	if(sm % 3 != 0 || min(x, y) < sm / 3){
		cout << 0 << endl;
		return 0;
	}

	cout << comb(sm / 3, x - sm / 3) << endl;

}


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

using namespace std ;

int n, mx1, mx2 ;
string s ;

int main() {
    cin >> s ;
    n = s.size() ;
    for( int i = 0 ; i < n ; i ++ ) {
        if( i % 2 && s[i] == '0' ) mx1 ++ ;
        else if( i % 2 == 0 && s[i] == '1' ) mx1 ++ ;
    }
    for( int i = 0 ; i < n ; i ++ ) {
        if( i % 2 == 0 && s[i] == '0' ) mx2 ++ ;
        else if( i % 2 && s[i] == '1' ) mx2 ++ ;
    }
    cout << min( mx1, mx2 ) << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

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

		while(true){
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			int check = m+f;

			if(m==-1&&f==-1&&r==-1){
				break;
			}

			if(m==-1||f==-1){
				System.out.println("F");
			}else if(check>=80){
				System.out.println("A");
			}else if(check>=65&&check<80){
				System.out.println("B");
			}else if(check>=50&&check<65){
				System.out.println("C");
			}else if(check>=30&&check<50){
				if(r>=50){
					System.out.println("C");
				}else{
					System.out.println("D");
				}
			}else if(check<30){
				System.out.println("F");
			}
		}
	}
}


Measured memory_bytes: 26336
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, 0, n) { cin >> a[i]; }
  sort(a.begin(), a.end());
  rep(i, 0, n - 1)
  {
    if (a[i] == a[i + 1])
    {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

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

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

  int cnt = 1;
  for(int i=0; i<n; ++i){
    if(a[i]==cnt) cnt++;
  }
  if(cnt==1){
    cout << "-1";
    return 0;
  }
  else cout << n-(cnt-1);
}

Measured memory_bytes: 4044
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main(){
	int n,a,b;
	vector<int>p;
	cin>>n>>a>>b;
	int aa=0,bb=0,cc=0;
	int pp;
	for(int i=0;i<n;i++){
		cin>>pp;
		if(pp<=a)aa++;
		else if(a<pp&&pp<=b)bb++;
		else if(pp>b)cc++;
	}
	int ans=min(aa,bb);
	ans=min(ans,cc);
	cout<<ans<<endl;
}


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

using namespace std;

typedef long long ll;

string trans(string t) {
    for(int i = 0; i < t.size(); i++) {
        if(t[i] == 'r'){
            t[i] = 'p';
            continue;
        }
        if(t[i] == 's'){
            t[i] = 'r';
            continue;
        }
        if(t[i] == 'p'){
            t[i] = 's';
            continue;
        }
    }
    return t;
}

int main() {
    int n,k,r,s,p; cin >> n >> k >> r >> s >> p;
    string t; cin >> t;
    ll sum = 0;
    string my = trans(t);
    for(int i = 0; i < t.size(); i++) {
        if(i < k) {
            if(my[i] == 'r'){
                sum += r;
            }
            if(my[i] == 's'){
                sum += s;
            }
            if(my[i] == 'p'){
                sum += p;
            }
        } else {
            if(my[i] != my[i-k]) {
                if(my[i] == 'r'){
                    sum += r;
                }
                if(my[i] == 's'){
                    sum += s;
                }
                if(my[i] == 'p'){
                    sum += p;
                }
            } else {
                if(i+k >= t.size()) {
                    continue;
                } else {
                    my[i] = 'r' ^ 's' ^ 'p' ^ my[i-k] ^ my[i+k];
                }
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>

using namespace std;
#define ll long long

int main(){
  ll N;
  cin >> N;
  vector<ll> A;
  ll x = 0, y = 0;
  for(int i=0; i<N; i++){
    ll a;
    cin >> a;
    A.push_back(a);
    if(i == 0)
      x += a;
    else
      y += a;

  }
  ll min = 100000000000;
  ll tmp;
  for(int i=1; i<N; i++){
    tmp = abs(x - y);
    // cout << x << ' ' << y << ' ' << tmp << endl;                                     
    if(tmp < min){
      min = tmp;
    }
    x += A[i];
    y -= A[i];
  }
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 2420
import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            String s = scanner.next();
            Stack<Boolean> stack = new Stack<>();
            int removed = 0;
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                stack.push(c != '0');
                while(stack.size() > 1) {
                    boolean top = stack.pop();
                    boolean second = stack.pop();
                    if (top != second) {
                        removed+=2;
                    } else {
                        stack.push(second);
                        stack.push(top);
                        break;
                    }
                }
            }
            System.out.println(removed);
        }
    }
}


Measured memory_bytes: 25988
while True:
    n = int(input())
    if n == 0:
        break
    f = 1
    for i in range(n):
        f *= i + 1
    i = 0
    f_str = str(f)
    while True:
        if f_str[-1] == "0":
            i += 1
            f_str = f_str[:-1]
        else:
            break
    print(i)



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

int main(){
  string s; cin >> s;
  if(s.size()%2 ==0){
   for(int i=0;i<s.size()/2;i++){
     if(s.at(2*i) == 'h' && s.at(2*i+1) == 'i'){
       if(i == s.size()/2-1){
         cout << "Yes" << endl;
         break;
       }
      continue;
     }
     else{
       cout << "No" << endl;
       break;
     }
   }
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;

int main() {
  INCANT;
  int a,b,c;
  cin >> a >> b >> c;
  int ret = a+b+c;
  if (a>b) {
    if (a>c) ret+=9*a;
    else ret+=9*c;
  } else {
    if (b>c) ret+=9*b;
    else ret+=9*c;
  }
  cout << ret << endl;
  
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

int main() {
    string s; cin >> s;
    s.push_back('x');
    loop (4, i) {
        if (s[i] == s[i + 1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}



Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    vec ra(n+1); // 数字はどのIndexにあるか 
    rep(i,n) ra[a[i]]=i;
    // これ以降aは使わない

    ll ans=0;

    set<int> s; // ｘより小さいもののindexが入っている
    s.insert(-1); s.insert(n); // ストッパー
    for(int d=1;d<=n;d++){ // 1から小さい順にみてみる
        int i=ra[d]; // dのindexを代入
        auto it=s.lower_bound(i); // indexでみてsのiよりも大きな場所である最小を求める（ｄ＝＝1ならnとなる）
        int r=*it;
        it--; // iよりも大きな場所である最小から-1すると、小さな最大が出る
        int l=*it;
        ans+=ll(d)*(i-l)*(r-i);
        s.insert(i);
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 12800
N = int(input())
X = []
Y = []
P = []
for _ in range(N):
    x, y, p = map(int, input().split())
    X.append(x)
    Y.append(y)
    P.append(p)

DX = [[0] * (1 << N) for _ in range(N)]
DY = [[0] * (1 << N) for _ in range(N)]

for i, x in enumerate(X):
    for k in range(1 << N):
        d = abs(x)
        for j, xx in enumerate(X):
            if k & (1 << j):
                d = min(d, abs(xx - x))
        DX[i][k] = d * P[i]
for i, y in enumerate(Y):
    for k in range(1 << N):
        d = abs(y)
        for j, yy in enumerate(Y):
            if k & (1 << j):
                d = min(d, abs(yy - y))
        DY[i][k] = d * P[i]

ANS = [1 << 100] * (N + 1)
PC = [0] * (1 << N)
for i in range(1, 1 << N):
    PC[i] = PC[i^1] + 1 if i % 2 else PC[i//2]

RA = []
for i in range(1 << N):
    t = []
    for j in range(N):
        if i & (1 << j):
            t.append(j)
    RA.append(t)

mm = (1 << N) - 1
for i in range(1 << N):
    m = i ^ mm
    j = m
    while 1:
        ans = 0
        for k in RA[i^j^mm]:
            ans += min(DX[k][i], DY[k][j])
        
        pc = PC[i] + PC[j]
        ANS[pc] = min(ANS[pc], ans)
        
        if not j:
            break
        j = m & (j - 1)

print(*ANS, sep = "\n")


Measured memory_bytes: 83756
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

const long long MOD = 1000000007;

int n;
int a[100010];
int dCount[100010];

long long getC(int n, int m)
{
	long long num = 1;
	int p = n;
	for (int i = 0 ; i < n ; i++)
	{
		num = num * p;
		p--;
	}
	
	for (int i = n - m ; i >= 1 ; i--)
		num = num / i;
		
	for (int i = m ; i >= 1 ; i--)
		num = num / i;
		
	return num;
}

int main()
{
//	printf("%d\n", getC(4, 2));
//	printf("%d\n", getC(5, 2));
	
	scanf("%d\n", &n);
	
	for (int i = 0 ; i < n ; i++)
		scanf("%d", &(a[i]));
	
	long long count = 1;

	memset(dCount, 0, sizeof(dCount));
	for (int i = 0 ; i < n ; i++)
	{
		int curA = a[i];
		long long choiceCanDo;
		if (curA > 0)
			choiceCanDo = dCount[curA - 1] - dCount[curA];	//可以有几个选择 - 已经做了几个选择 
		else
			choiceCanDo = 3 - dCount[curA];	//可以有几个选择 - 已经做了几个选择 
		dCount[curA]++;
			
		count = (count * choiceCanDo) % MOD;
	}
	
//	count = count * getC(3, dCount[0]) % MOD;
	
	printf("%I64d\n", count);
		
	return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
int main(){
    int i,k,ame;
    while(scanf("%d",&ame)!=EOF){
        ame=ame%39;
        if(ame==0){
            puts("3C39");
        }else{
        if(ame<10){
            printf("3C0%d\n",ame);
        }else{
            printf("3C%d\n",ame);
        }
        }
    }
    return 0;
}

Measured memory_bytes: 1036
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;


int par[100005];//master
int rnk[100005];//depth
int siz[100005];//size!

//initialization
void init(int n) {
	FOR(i, 0, n) {
		par[i] = i;//master is itself
		rnk[i] = 0;
		siz[i] = 1;
	}
}

//search for root
int find(int x) {
	if (par[x] == x)return x;
	else return par[x] = find(par[x]);
}

//union
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rnk[x] < rnk[y]) {
		siz[find(y)] += siz[find(x)];
		par[x] = y;
	}
	else {
		siz[find(x)] += siz[find(y)];
		par[y] = x;

		if (rnk[x] == rnk[y])rnk[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}

ll N,M,a[100005],b[100005],ans[100001];

int main() {
	cin >> N >> M;
	ans[M] = N * (N - 1) / 2;


	FOR(i, 0, M) {
		cin >> a[i] >> b[i];
	}


	init(N);


	REP(i, M - 1, -1) {
		ans[i] = ans[i+1];
		if (!same(a[i] - 1, b[i] - 1)) {
			ans[i] -= siz[find(a[i] - 1)] * siz[find(b[i] - 1)];
			
		}
		unite(a[i] - 1, b[i] - 1);
		if (ans[i] == 0)break;
	}
	
	FOR(i, 1, M+1)ct(ans[i]);

	return 0;
}

Measured memory_bytes: 4864
#include <cstdio>
#include <algorithm>
#include <queue>
#include <utility>
#include <unordered_map>
#include <vector>

using edge = std::pair<int, int>;
#define N 10000

int main(){
    int n;
    std::scanf("%d", &n);
    std::vector<edge> a[N];
    for(int i = 0; i < n; ++i){
        int id;
        int num;
        std::scanf("%d", &id);
        std::scanf("%d", &num);
        for(int j = 0; j < num; ++j){
            edge e;
            std::scanf("%d", &e.second);//id                                                                                                                                                                                        
            std::scanf("%d", &e.first);//weight                                                                                                                                                                                     
            a[id].emplace_back(e);
        }
    }
    std::priority_queue<edge, std::vector<edge>, std::greater<edge> > que;
    std::unordered_map<int, int> checked;
    checked.emplace(std::make_pair(0, 0));
    for(auto &x: a[0]){
        que.emplace(x);
    }
    while(checked.size() != n){
        while(checked.find(que.top().second) != checked.end()){
            que.pop();
        }
        edge e = que.top();
        que.pop();
        checked.emplace(std::make_pair(e.second, e.first));
        for(auto &x: a[e.second]){
            if(checked.find(x.second) == checked.end()){
                x.first += e.first;
                que.emplace(x);
            }
        }
    }

    for(int i = 0; i < n; ++i){
        auto x = checked.find(i);
        std::printf("%d %d\n", x->first, x->second);
    }

    return 0;
}



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

int main() {
    int n;
    int res = 0;
    cin >> n;
    set< int > s;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        decltype(s)::iterator it = s.find(a);
        if (it != s.end()) {
            s.erase(a);
        } else {
            s.insert(a);
        }
    }
    cout << s.size();
    return 0;
}


Measured memory_bytes: 4864
import java.util.*;

public class Main {
	static int []a=new int [10];
	static int []b=new int [10];
	public static void main(String[]args)
	{
		Scanner in=new Scanner(System.in);
		int count=0,j=0;
		int n=in.nextInt();
		char []b= {'A','B','C'};
		char []a=in.next().toCharArray();
		for(int i=0;i<n;)
		{
			if(a[i]==b[j])
			{
				i++;
				j++;
			}
			else
			{
				i=i-j+1;
				j=0;
			}
			if(j==3)
			{
				count++;
				j=0;
			}
				
		}
		System.out.println(count);
	}
}


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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n; i >= a; i--)
#define pb              push_back
#define lb              lower_bound		// first element >= val(itr) 
#define ub              upper_bound		// first element >  val(itr)
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))	//x can be 0 or -1

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

#ifdef LOCAL_TEST
	#include"/home/shrey/debug.h"
#endif

const ll inf = 1e18;
const int nax = 1e5 + 5;
ll dp[10][20][10][2];
ll k,n;
vector<ll>digits;

void pre(ll x)
{
	digits.clear();
	while(x)
	{
		digits.pb(x%10);
		x /= 10;
	}
	
	reverse(all(digits));
	n = digits.size();
	
	forn(i,0,10)
	{
		forn(j,0,20)
		{
			forn(k,0,10)
			{
				forn(p,0,2)
				{
					dp[i][j][k][p] = -1;
				}
			}
		}
	}
}

ll count(ll idx,ll len,ll prev,bool allow)
{
	if(prev < 0 || prev>=10)
	{
		return 0;
	}
	
	if(idx == len)
	{
		return 1;
	}
	
	if(dp[idx][len][prev][allow] != -1)
	{
		return dp[idx][len][prev][allow];
	}
	
	ll ans = 0;
	if(allow)
	{
		ans += count(idx+1,len,prev-1,1);
		ans += count(idx+1,len,prev,1);
		ans += count(idx+1,len,prev+1,1);
	}
	else
	{
		forn(i,prev-1,prev+2)
		{
			if(i > digits[idx])
			{
				continue;
			}
			if(i == digits[idx])
			{
				ans += count(idx+1,len,i,0);
			}
			else
			{
				ans += count(idx+1,len,i,1);
			}
		}
	}
	
	return dp[idx][len][prev][allow] = ans;
}

bool ok(ll x)
{
	pre(x);
	
	ll cnt = 0;
	forn(i,1,19)	//length of numbers
	{
		forn(j,1,10)	//first number
		{
			if(i<n)
			{
				cnt += count(1,i,j,1);
			}
			else if(i == n)
			{
				if(j == digits[0])
				{
					cnt += count(1,i,j,0);
				}
				else if(j<digits[0])
				{
					cnt += count(1,i,j,1);
				}
			}
		}
	}
	//cout<<cnt<<endl;
	return cnt>=(k);
}

void SolveTestCase()
{
	cin>>k;
	
	ll lo = -1, hi = 1e18;
	ll ans = 0;
	//bool t = ok(3234566667);
	while(hi-lo>1)
	{
		ll mid = (lo+hi)/2;
		//cout<<mid<<endl;
		if(ok(mid))
		{
			ans = mid;
			hi = mid;
		}
		else
		{
			//ans = mid;
			lo = mid;
		}
	}
	cout<<ans;
}

int main()
{
	speedup_IO;

	int t = 1;
	//cin >> t;
	forn(i,0,t)
	{
		SolveTestCase();
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)

using namespace std;

string str[41];
int k;
int n;

bool check(int p, int c)
{
	int cnt =0;
	for(int i=p;i<n;i++){
		cnt += str[i].length();
		k++;
		if(cnt == c) return true;
		else if(cnt > c)return false;
	}
	return false;
}

int main(){
	while(cin>>n, n){
		rep(i,n) cin >> str[i];
		rep(i,n){
			k = i;
			if(check(k,5) && check(k,7) && check(k,5) && check(k,7) && check(k,7)) {
				cout << i+1 << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3176
import sys
x=int(input())
if x==2 or x==3:
    print(x)
    sys.exit()
while 1:
    i=2
    c=False
    while i*i<=x:
        if x%i==0:
            c=True
            break
        i+=1
    if c:
        x+=1
        continue
    else:
        print(x)
        break


Measured memory_bytes: 2940
object Main extends App {
  import scala.io.StdIn._

  val Array(h, w) = readLine.trim.split(' ').map(_.toInt)
  val state = Array.tabulate(h){_ ⇒ readLine.trim.split(' ').map(_.toLong)}

  println(
    (0 until h).map(y ⇒ (0 until w).map(x ⇒ (y + 1).toLong * (h - y) * (x + 1) * (w - x) * state(y)(x)).sum).sum
  )
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 85368
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;cin >> n >> k;
    ll a[n];
    for (int i = 0; i < n; ++i)
    {
    	cin >> a[i];
    }
    sort(a,a+n);
    ll ans=0;
    for (int i = 0; i < k; ++i)
    {
    	ans+=a[i];
    }
    cout << ans;
    }

Measured memory_bytes: 3652
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

class Main{
	static	ArrayList<HashMap<Integer, Integer>> graph ;
	static long ans = 100000000000L;
	static long first = 100000000000L;
	static long second = 100000000000L;
	static boolean[] used;
	static long[] depth;




	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();

		used = new boolean[n+1];
		depth = new long[n+1];
		graph =new ArrayList<HashMap<Integer,Integer>>();				//arraylistの番号は始点



		for(int i = 0; i <= n;i++){

			HashMap<Integer, Integer> zero = new HashMap<Integer,Integer>();
			zero.put(0, 0);

			graph.add(i, zero);					//getで始点を指定、putで<隣接点、距離>を入れていく
		}

		for(int i = 0;i < n-1;i++){
			int a = sc.nextInt();			
			int b = sc.nextInt();
			int c = sc.nextInt();

			//getで始点を指定、putで<隣接点、距離>を入れていく

			graph.get(a).put(b, c);					//getで始点を指定、putで<隣接点、距離>を入れていく
			graph.get(b).put(a, c);					//getで始点を指定、putで<隣接点、距離>を入れていく


		}







		int q = sc.nextInt();				//問題数
		int k = sc.nextInt();				//通らなきゃいけない場所

		used[0] = true;
		used[k] = true;

		dfs(k,0);


		for(int i = 0;i <q;i++){


			int x = sc.nextInt();			//始点
			int y = sc.nextInt();			//終点
		
			System.out.println(depth[x]+depth[y]);
		}



	}

	static void dfs(int p,long d){
		depth[p] = d;

		for(int i:graph.get(p).keySet()){
			if(!(used[i])){
				used[i] = true;
				dfs(i,  d + graph.get(p).get(i));
			}
		}

		return ;


	}


}




Measured memory_bytes: 210816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }





void solve() {
    string s; ll k;
    cin >> s >> k;
    
    int id = -1;
    rep(i, sz(s)) {
        if (s[i] != '1') {
            id = i;
            break;
        }
    }
    // cout << id << endl;
    
    if (id == -1 || k - 1 < id) cout << 1 << endl;
    else cout << s[id] << endl;
}
// 5000000000000000
// 5 * 10^15

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}





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

int main(){
  ll n;
  cin>>n;
  ll res=1;
  ll ar[n];
  ll k=0;
  for(ll i=0;i<n;i++){
    cin>>ar[i];
    if(ar[i]==0){
    	k++;
    }
  }
  if(k>0){
  	cout<<0<<endl;
  }
  else{
  for(ll i=0;i<n;i++){
    if(ar[i]<=1000000000000000000/res){
      res*=ar[i];
    }
    else{
    	cout<<-1<<endl;
    	return 0;
    }
  }
   cout<<res<<endl;
  }
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    for(size_t i = 0; i < N; i++)
    {
        cin >> X[i];
    }
    vector<int> x_sorted = X;
    sort(x_sorted.begin(), x_sorted.end());
    int upper = x_sorted[N/2];
    int lower = x_sorted[N/2-1];
    for(size_t i = 0; i < N; i++)
    {
        if (X[i] >= upper)
            cout << lower << endl;
        else
            cout << upper << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3712
n = int(input())
R,F,B = 10,3,4

Status = [[[0 for x in range(R)] for y in range(F)] for z in range(B)]

for i in range(n):
    (b,f,r,v) = map(int,input().split())
    Status[b-1][f-1][r-1]+=v

for m in range(4):
    for n in range(3):
        for k in range(10):
            print(" {}".format(Status[m][n][k]),end="")
        print()
    if m+1 in range(4):
        print("#"*20)


Measured memory_bytes: 5624
# Problem D - Hand

# input
N = int(input())

# initialization
nums = [[0]*10 for i in range(10)]
ans = 0

# count check
for n in range(1, N+1):
    tmp = list(str(n))
    tmp = list(map(int, tmp))
    sento = tmp[0]
    ichi = tmp[-1]
    nums[sento][ichi] += 1

# count
for i in range(1, 10):
    for j in range(1, 10):
        ans += nums[i][j] * nums[j][i]

# output
print(ans)


Measured memory_bytes: 40940
# coding: utf-8
# Your code here!

a = list(map(int, input().split()))
a.sort()

if a[0] % 2 == 0 or a[1] % 2 == 0 or a[2] % 2 == 0:
    print(0)
else:
    print(a[0] * a[1])

Measured memory_bytes: 2940
#include<stdio.h>
#include<math.h>
#define EPS 1e-10
int main()
{
  double a, b, c, d, e, f, x, y;
  while(scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f) != EOF)
    {
      x = (b*f - c*e) / (b*d - a*e);
      y = (c*d - a*f) / (b*d - a*e);
      // if(abs(x) < 0.000001 && x < 0)
      //x = 0.0;
      // if(abs(y) < 0.000001 && y < 0)
      //	y = 0.0;
      printf("%.3f %.3f\n", x+EPS, y+EPS);
    }
  return 0;
}

Measured memory_bytes: 656
#90 b-palindromic numbers 
a,b=input().split()
num=[str(i) for i in range(int(a),int(b)+1)]
ans=0
for x in num:
    flag=True
    for i in range(int(len(x)/2)):
        if x[i]!=x[-1*i-1]:
            flag=False
            break
    if flag:
        ans+=1
print(ans)

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

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

    int cost0 = 0;
    int costN = 0;
    vector<int> A(M);
    for (int i = 0; i < M; i++)
    {
        cin >> A[i];
        if (A[i] < X)
        {
            cost0++;
        } else if(A[i] > X)
        {
            costN++;
        }
    }

    cout << min(cost0, costN) << endl;
    return 0;
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(true){
			int n = stdIn.nextInt();
			int m = stdIn.nextInt();
			int p = stdIn.nextInt();
			if(n==0&&m==0&&p==0){
				return;
			}
			int h = 0;
			int w = 0;
			for(int i=1;i<=n;i++){
				int tmp = stdIn.nextInt();
				h += tmp;
				if(m==i){
					w = tmp;
				}
			}
			int ans = h*100;
			ans = ans*(100-p)/100;
			if(w!=0){
				ans /= w;
			}
			else{
				ans = 0;
			}
			System.out.println(ans);
		}
	}
}

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

int main()
{

        int N, A, B;
        cin >> N >> A >> B;

        long long ans = 0;
        for (int i = 1; i < N + 1; ++i) {

                std::string s = to_string(i);

                int len = s.length();
                long long sum = 0;
                for (int j = 0; j < len; ++j) {
                        char c = s[j];
                        sum += (c - '0');

                }
                if (sum >= A && sum <= B) {
                        ans += i;
                }


        }
        cout << ans << endl;


}


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

int main(){

ios_base::sync_with_stdio(false);

long long n;

cin>>n;

long long a[n],b[n],c[n],i,j;

for(i=0;i<n;i++)
	cin>>a[i];

b[0]=a[0];

for(i=1;i<n;i++)
	b[i]=max(b[i-1],a[i]);

c[n-1]=a[n-1];

for(i=n-2;i>=0;i--)
	c[i]=max(c[i+1],a[i]);

for(i=0;i<n;i++){
	
	if(i==0)
	cout<<c[1]<<endl;

else if(i==n-1)
	cout<<b[n-2]<<endl;

else
cout<<max(b[i-1],c[i+1])<<endl;}

return 0;}
	

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

snuke = [0 for i in range(N)]

for i in range(K):
    number = int(input())
    menber = [int(x) for x in input().split()]
    for j in range(number):
        snuke[menber[j]-1] += 1

cnt = 0    
for k in range(N):
    if snuke[k] == 0 :
        cnt += 1

print(cnt)

Measured memory_bytes: 9216
#include <stdio.h>

int Judge(int a, int b){
    if( a>b ) return 1;
    else return 0;
    
}


int main(void){
    // Your code here!
    //A,B,C,K   red gree blue  K is multiple 2 
    //success B>A and C>B  so C>B>A is confition of clear
    
    int a,b,c,k;
    int flag=0;//magic=0;//help=0; 
    
    scanf("%d %d %d",&a,&b,&c);
    scanf("%d",&k);
    

if( b>a && c>b ){
    
puts("Yes"); 
return 0;

}

while(1){ //while( !(b>a) || flag>=k ){
    
    //if( (b>a) ) break;
    
    if( (b>a) ) break;
    if( flag>=k ) break;
    
    b*=2;
    flag++;
    /*
    if( (b>a) ) break;
    if( flag>=k ) break;
    */
}
while(1){ //while( !(c>b) || flag>=k  ){

    if( (c>b) ) break;
    if( flag>=k ) break;    
    c*=2;
    flag++;

    
}


if( b>a && c>b ) puts("Yes"); //if( B>A && C>B ) puts("Yes");//printf();
else puts("No");

/*
if( B>A && C>B ) puts("Yes");//printf();
else puts("No");
*/

return 0;     
    
}


Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a,b;
  cin>>a>>b;
  if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]){
    cout<<"YES"<<endl;
  }else cout<<"NO"<<endl;
  return 0;
}
  

Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int Na, Nt, Ng, Nc;
ll dp[64][64][64][64];
int M;
vector<string>nonterms;
map<string, vector<string> >rules;
vector<string>R;

stringstream ss;

ll dfs(int a, int t, int g, int c){
  if(a < 0 || t < 0 || g < 0 || c < 0) return 0;
  //  cout << a << " " << t << " " << g << " " << c << endl;
  if(a == 0 && t == 0 && g == 0 && c == 0) return 1;
  int n = (Na+Nt+Ng+Nc) - (a+t+g+c);
  if(n == R.size()) return 0;
  ll &ret = dp[a][t][g][c];
  if(ret != -1) return ret;
  ret = 0;
  for(int i=0;i<R[n].size();i++){
    char s = R[n][i];
    //    ret = (ret + dfs(a - (s=='A' && a), t - (s=='T' && t), g - (s=='G' && g), c- (s=='C' && c))) % MOD;
    //    cout << s << " " << ret << endl;
    if(s=='A'  && a ){
      ret += dfs(a-1, t, g, c);
    }else if(s=='T' && t){
      ret += dfs(a, t-1, g, c);
    }else if(s=='G' && g){
      ret += dfs(a, t, g-1, c);
    }else if(s=='C' && c){
      ret += dfs(a, t, g, c-1);
    }
    ret %= MOD;
  }
  return ret;
}

int dfs1(vector<string>& vs){
  if(R.size() >Na + Nt + Ng + Nc) return -1;
  //  cout << "ok" << endl;
  //  cout << vs.size() << endl;
  //  vector<string> ret;
  for(auto &s: vs){
    //    cout << s << endl;
    if(s[0] == '['){
      R.push_back(s.substr(1, s.size()-2));
    }else{
      //      cout << s << " "  << endl;
      if(dfs1(rules[s]) < 0) return -1;
      //      vector<string> tmp = dfs1(rules[s]);
      //      copy(tmp.begin(), tmp.end(), back_inserter(R));
    }
  }
  //  return &ret;
  return 0;
}

int main()
{
  cin >> Na >> Nt>>Ng>>Nc;
  cin >> M;
  cin.ignore();
  
  rep(i, M){
    string str;
    getline(cin, str);
    ss.clear();
    ss.str(str);
    string nonterm;
    vector<string>terms;
    ss >> nonterm; ss.ignore();
    nonterm = nonterm.substr(0, nonterm.size()-1);
    while(!ss.eof()){
      string term;
      ss >> term ;
      terms.push_back(term);
      ss.ignore();
    }
    rules[nonterm] = terms;
    // cout << nonterm << " " << terms.size() << endl;
    nonterms.push_back(nonterm);
  }
  
  if(dfs1(rules[nonterms[0]]) < 0){
    cout << 0 << endl;
  }else{
    //  for(auto &r: R) cout << r << endl;
    memset(dp, -1, sizeof(dp));
    cout << dfs(Na, Nt, Ng, Nc) << endl;
  }
  return 0;
}

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

long char2long(char c) {
  return (long)(int(c) - int('0'));
}

long string2long(string target) {
  int n = target.size();
  long value = 0;
  for(int i = 0; i < n; i++) {
    value = 10 * value + char2long(target.at(i));
  }
  return value;
}

long split_sum(string target, int delim_count, long offset) {
  int n = target.size();
  if ( delim_count >= n ) {
    return 0;
  }
  if ( delim_count == 0 ) {
    return string2long(target) + offset;
  }
  long value = 0;
  for(int i = 1; i < n; i++) {
    long base = string2long(target.substr(0,i));
    string rest = target.substr(i,n-i);
    value += split_sum(rest, delim_count-1, base+offset);
  }
  return value;
}

long solve(string S) {
  int N = S.size();
  long sum = 0;
  for(int i = 0; i < N; i++) {
    sum += split_sum(S, i, 0);
  }
  return sum;
}

int main() {
  //input
  string S;
  cin >> S;
  cout << solve(S) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <set>
#include <numeric>
#include <limits>
#include <vector>
#include <math.h>
#include <string>
#include <set>
#include <locale>
#include <ctype.h>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <array>
#include <unordered_set>
#include <list>
#include <iterator>
using namespace std;
int main()
{
	int x, y, arr[100000], dp[100000];
	cin >> x >> y;
	for (size_t i = 0; i < x; i++)
	{
		cin >> arr[i];
	}
	dp[0] = 0;
	for (int i = 1; i < x; i++) {
		int mn = (int) 1e9;
		int xx = y;
		for (int j = i - 1; j >= 0 && xx--; j--) {
			mn = min(mn, dp[j] + abs(arr[i] - arr[j]));
		}
		dp[i] = mn;
	}
	
	cout << dp[x - 1];	
}

/*
#define INT_MAX  999999

int n = 4;
int dp[16][4];
int dist[10][10] = {
	{ 0, 20, 42, 25 },
	{ 20, 0, 20, 34 },
	{ 42, 30, 0, 10 },
	{ 25, 34, 10, 0 },
};
int VISITED_ALL = (1 << n) - 1;

int tsp(int mask, int pos){
	if (mask == VISITED_ALL){
		return dist[pos][0];
	}
	if (dp[mask][pos] != -1)
	{
		return dp[mask][pos];
	}
	int ans = INT_MAX;
	for (int city = 0; city<n; city++)
	{
		if (mask&(1 << city) == 0)
		{
			int newAns = dist[pos][city] + tsp(mask | (1 << city), city);
			ans = min(ans, newAns);
		}
	}
	return dp[mask][pos] = ans;
}
int min(int a, int b)
{
	int p, q;

	if (p<q){
		printf("p");
	}
	else{
		printf("q");
	}
}

int main()
{
	for (int i = 0; i<(1 << n); i++){
		for (int j = 0; j<n; j++)
		{
			dp[i][j] = -1;
		}
	}
	cout << tsp(1, 0) << endl;
	return 0;
}
*/


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
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; }
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    int r,g;
    cin >> r >> g;
    PRINT(2*g-r);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
typedef long long lint;
using namespace std;

int main()
{
	const int mod=1e9+7;
	int N;
	map<int,int> m;
	int tmp;
	lint ans=1;
	
	cin >> N;
	
	for(int i=2;i<=N;i++)
	{
		tmp=i;
		for(int j=2;j<=tmp;j++)
		{
			while(tmp%j==0)
			{
				tmp/=j;
				m[j]++;
			}
		}
	}
	
	for(auto&& i:m)
	{
		ans*=(i.second+1);
		ans%=mod;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
k = int(input())
ans_list = []

for i in range(5):
    s_list = [s[j:j+i+1] for j in range(len(s)-i)]
    s_set_list = list(set(s_list))
    for m in range(len(s_set_list)):
        ans_list.append(s_set_list[m])

ans_list.sort()
print(ans_list[k-1])

Measured memory_bytes: 4208
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t y=0;
  int m,x,z,j;
  cin>>m>>x;
  vector<int> b(m);
  for(j=0;j<m;j++) cin>>b.at(j);
  for(j=1;j<m;j++){
    z=b.at(j-1)+b.at(j)-x;
    if(z>0){
      y+=z;
      if(b.at(j)>=z) b.at(j)-=z;
      else if(b.at(j)<z){
        b.at(j)=0;
        b.at(j-1)=x;
      }
    }
  }
  cout<<y<<endl;
}

Measured memory_bytes: 3788
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
long long a[100005],side[5];
int main()
{
	long long n,b;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+1+n);
	int sum=0;
	int cnt=0;
	a[0]=1000000009;
	for(int i=n;i>=0;i--)
	{
		if(a[i]==b) sum++;
		else 
		{
			if(sum>=2)
			{
				side[++cnt]=a[i+1];
			}
			if(sum>=4)
			{
				side[++cnt]=a[i+1];
			}
			sum=1;
		}
		b=a[i];
		if(cnt>=2) break;
	}
	cout<<side[1]*side[2];
	return 0;
}

Measured memory_bytes: 1024
<?php
/**
 * ABC123
 * C - Five Transportations
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d", $n);
for ($i = 0; $i < 5; $i++) {
    fscanf(STDIN, "%d", $d[$i]);
}

echo 4 + (int) ceil($n / min($d)), PHP_EOL;


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

using namespace std;

int main() {
	int a, b, c, k;
	scanf("%d%d%d%d", &a, &b, &c, &k);
	
	int res = 0;
	
	int v = min(a, k);
	res += v;
	k -= v;
	
	v = min(b, k);
	k -= v;
	
	v = min(c, k);
	res -= v;
	
	printf("%d\n", res);
}


Measured memory_bytes: 3708
#include <vector>
#include <sstream>
#include <algorithm>
#include <fstream>
#include <list>
#include <map>
#include <istream>
#include <bitset>
#include <sstream>
#include <unordered_map>
#include <stack>
#include <set>
#include <cmath>
#include <random>
#include <iostream>
#include <bitset>
#include <iomanip>
#include <queue>
#include <string>

#define int long long
#define endl "\n"
#define all(x) x.begin(),x.end()
#define rr return 0
#define xx first
#define yy second
#define pii pair<int,int>

using namespace std;

typedef long long ll;
typedef long double ld;


signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, wg;
    cin >> n >> wg;
    vector<int> w(n + 1);
    vector<int> v(n + 1);
    int sum = 0;
    for(int i = 1;i <= n;i++){
        cin >> w[i] >> v[i];
        sum += v[i];
    }
    int dp[n + 1][sum + 1];
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= sum;j++){
            dp[i][j] = 1e18;
        }
    }
    dp[1][v[1]] = w[1];
    dp[1][0] = 0;
    for(int i = 2;i <= n;i++){
        for(int j = 0;j <= sum;j++){
            if(dp[i - 1][j] == 1e18){
                continue;
            }
            dp[i][j + v[i]] = min(dp[i][j + v[i]], dp[i - 1][j] + w[i]);
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
        }
    }
    int ans = 0;
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= sum;j++){
            if(dp[i][j] <= wg){
                ans = max(ans, j);
            }
        }
    }
    cout << ans;
    rr;
}



Measured memory_bytes: 79232
MOD = 998244353
N, K = gets.split.map(&:to_i)
Q = K.times.map { gets.split.map(&:to_i) }
DP = Array.new(N + 1, 0)
DP[1] = 1

def sum(x)
  res = 0

  Q.each do |l, r|
    a = (x - r - 1 >= 0) ? DP[x - r - 1] : 0
    b = (x - l >= 0) ? DP[x - l] : 0

    res += b - a
    res %= MOD
  end

  res
end

2.upto(N) do |x|
  DP[x] = DP[x - 1] + sum(x)
  DP[x] %= MOD
end

puts sum(N)


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

int main(){
    int n, m; cin >> n >> m;
    long long ans = 0;
    vector<pair<int, int> > a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i].first >> a[i].second;
    }
    sort(a.begin(), a.end());
    for(int i = 0; m > 0 && i < n ;i++){
        long long c = min(a[i].second, m); m -= c;
        ans += c * a[i].first;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
	string example;
	cin>>example;
	bool can1=false,can2=false;
	for (int i=0;i<example.size();i++)
		if (example[i]=='C')
		{
			can1=true;
			for (int j=i+1;j<example.size();j++)
			{
				if (example[j]=='F')
				{
					can2=true;
					break;
				}
			}
			if (can2)
				return cout<<"Yes"<<endl,0;
		}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//ll dp[110][11100];

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

    vector<ll> dp(h + 1, INF);
    dp[0] = 0;

    rep(i, n)
    {
        rep(j, h + 1)
        {
            dp[min(j+a[i], h)] = min(dp[min(j+a[i], h)], dp[j] + b[i]);
            //chmin(dp[min(j+a[i], h)], dp[j] + b[i]);
            //if (j == 0) cout << dp[j + a[i]] << endl;
        }
    }
    cout << dp[h] << endl;

    // rep(i, h + 1)
    // {
    //     cout << dp[i] << " ";
    // }
}

Measured memory_bytes: 384