akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;


int much(int i, int n, vector< pair<int, int> >& c){
    int temp = 0;
    int j;
    for (j=0; j<n; j++){
        if (c[j].second == i){
            return j;
        }
    }
    return -1;
}

int main() {
    int n, i, j;
    cin >> n;

    int e, o, temp;
    vector< pair<int, int> > evenList(0); // appearence, num
    vector< pair<int, int> > oddList(0); // appearence, num
    
    // divide even and odd
    for (i=0; i<n; i++){
        if (i % 2 == 0){
            cin >> e;
            // check if the num appeared before
            temp = much(e, evenList.size(), evenList);
            if (temp >= 0){
                evenList[temp].first--;
            }
            else {
                evenList.push_back(make_pair(-1, e));
            }
        }
        if (i % 2 != 0) {
            cin >> o;
            // check if the num appeared before
            temp = much(o, oddList.size(), oddList);
            if (temp >= 0){
                oddList[temp].first--;
            }
            else {
                oddList.push_back(make_pair(-1, o));
            }
        }
    }

    sort(evenList.begin(), evenList.end());
    sort(oddList.begin(), oddList.end());
    
    if (evenList[0].second != oddList[0].second) cout << n + evenList[0].first + oddList[0].first << '\n';
    else if (evenList[0].first == -n/2 && oddList[0].first == -n/2) cout << n / 2 << '\n';
    else if (evenList.size() > 1 && oddList.size() > 1){
        cout << n + min(evenList[1].first + oddList[0].first, evenList[0].first + oddList[1].first) << '\n';
    }
    else if (evenList.size() == 1){
        cout << n + evenList[0].first + oddList[1].first << '\n';
    }
    else if (oddList.size() == 1){
        cout << n + evenList[1].first + oddList[0].first << '\n';
    }
    // for debug
    // cout << evenList[0].first << ' ' << evenList[0].second << '\n';
    // cout << oddList[0].first << ' ' << oddList[0].second << '\n';
}


Measured memory_bytes: 1276
#include <iostream>

using namespace std;

int main(){
    int D;
    cin >> D;
    switch(D){
        case 22:
            cout << "Christmas Eve Eve Eve\n";
            break;
        case 23:
            cout << "Christmas Eve Eve\n";
            break;
        case 24:
            cout << "Christmas Eve\n";
            break;
        case 25:
            cout << "Christmas\n";
            break;
        default:
            break;
    }
}

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

vector<int> px = {0,1,0,-1};
vector<int> py = {1,0,-1,0};

int main() {
        int h,w,numBlackGrids=0,ans;
        cin >> h >> w;
        vector<string> s(h);
        for(int i=0; i<h; i++) cin >> s[i];
        // #が書かれたマスの数を数える
        for(auto v:s) {
          for(auto elem:v) if(elem=='#') numBlackGrids++;
        }
        // 最短ルートを見つけ出して、その長さを求める
        vector<vector<int> > dist(h,vector<int>(w,-1));
        dist[0][0] = 0;
        queue<pair<int,int> > que;
        que.push({0,0});
        while(!que.empty()) {
                auto v = que.front();
                que.pop();
                int x = v.first;
                int y = v.second;
                for(int i=0; i<4; i++) {
                        int nx = x+px[i];
                        int ny = y+py[i];
                        if(nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
                        if(s[nx][ny]=='#') continue;
                        if(dist[nx][ny]==-1) {
                                dist[nx][ny] = dist[x][y]+1;
                                que.push({nx,ny});
                        }
                }
        }
        if(dist[h-1][w-1]==-1) ans = -1;
        else {
          ans = h*w-(dist[h-1][w-1]+1)-numBlackGrids;
        }
        cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int N;
	scanf("%d",&N);
	char S[100];
	int total;
	scanf("%s",&S);
		for (int i=0;i< N/2;i++){
    		if (S[i] == S[i + N/2]){
			total++;
			}	
		}
		if (N % 2 == 1) {
        printf("No");
        return 0;
    }

    
    total == N/2 ? printf ("Yes\n") : printf ("No\n");
return 0;
}

Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std;
int arr[105];

int main(){
	int n;
	cin>>n;
	for(int i=1; i<n; i++) cin>>arr[i];
	int ret = 0;
	arr[0] = 10000000;
	for(int i=1; i<n; i++){
		ret+=min(arr[i-1],arr[i]);
	}
	cout<<ret+arr[n-1];
}

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


int main(){
  ll n;cin >> n;
  vector<ll> a(n*3);
  rep(i,n*3) cin >> a.at(i);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  ll ans = 0;
  ll cnt = 0;
  for(ll i=1;i<2*n;i+=2){
    ans += a.at(i);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5588
#include <iostream>
using namespace std;
int main(){
	int n, a[150];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n - 1; i++)
		cout << a[n - i - 1] << " ";
		cout << a[0];
		cout << endl;

	return 0;
}


Measured memory_bytes: 3104
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int mod = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
struct edge { int to, cost; };

signed main() {
	int n;
	cin >> n;
	if (n == 100000) {
		cout << 90909 << endl;
	}
	elif (n > 9999) {
		cout << 909 + n - 9999 << endl;
	}
	elif(n > 999) {
		cout << 909 << endl;
	}
	elif(n > 99) {
		cout << 9 + n - 99 << endl;
	}
	elif(n > 9) {
		cout << 9 << endl;
	}
	else cout << n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll MAXN=3e3+51,MOD=998244353;
ll n,s,res;
ll num[MAXN],dp[MAXN];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
} 
int main()
{
	n=read(),s=read();
	for(register int i=1;i<=n;i++)
	{
		num[i]=read();
	}
	for(register int i=1;i<=n;i++)
	{
		for(register int j=s;j>num[i];j--)
		{
			dp[j]=(dp[j]+dp[j-num[i]])%MOD;
		}
		dp[num[i]]=(dp[num[i]]+i)%MOD,res=(res+dp[s]*(n-i+1)%MOD)%MOD,dp[s]=0;
	}
	printf("%lld\n",res);
}

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

int n;
vector<double> x;
vector<string> u;

void solve() {
  int i;
  double ans = 0;

  for (i = 0; i < n; i++) {
    if (u[i] == "BTC") {
      x[i] *= 380000.0;
    }
    ans += x[i];
  }

  cout << ans << "\n";
}

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

  x.resize(n);
  u.resize(n);
  for (i = 0; i < n; i++) {
    cin >> x[i] >> u[i];
  }

  solve();

  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main{


	public static void main(String[] a){

		Scanner sc = new Scanner(System.in);
		
		List <String> senro = new ArrayList<String>();
		
		
		
		while(sc.hasNext()) {
			
			String num = sc.next();	
			
			if(num.equals("0")) {
				int index = senro.size() -1;
				System.out.println(senro.get(index));
				senro.remove(index);
				
			}else{
				senro.add(num);
			}
			
			
		}
		
	
		
	}
}

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

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

  vector<int> x(n), y(n), h(n);
  rep(i, n) cin >> x[i] >> y[i] >> h[i];

  rep(cx, 101) rep(cy, 101) {

    int before = -1;
    rep(i, n) {
      if (h[i] > 0) {
        int tmp= h[i] + abs(x[i] - cx) + abs(y[i] - cy);
        if(before == -1){
          before = tmp;
        } else if(before != tmp){
          before =-1;
          break;
        }
      }
    }
    if (before == -1) continue;

    rep(i, n) {
      if (h[i] == 0 && before > abs(x[i] - cx) + abs(y[i] - cy)) {
        before = -1;
        break;
      }
    }
    if (before == -1) continue;

    printf("%d %d %d", cx, cy, before);
    return 0;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        long N = scan.nextLong();
        long A = scan.nextLong();
        long B = scan.nextLong();
        if(N < 2 && A != B) {
            System.out.println(0);
            return;
        }
        long answer = 0;
        
        if(A < B) answer = (N-2)*(B-A)+1;
        else if(A == B) answer = 1;
        else answer = 0;
        System.out.println(answer);
    }
}


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

int N, MA, MB;
int a[41], b[41], c[41];

/* dp[i][ca][cb]を、1~iからの薬品からタイプAがcaグラム、タイプBがcbグラムとなる時の最小コスト */
int dp[41][412][412];
static const int INF = 40000000;
int main(void){
    // Your code here!
    
    cin >> N >> MA >> MB;
    for(int i = 0; i < N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    for(int i = 0; i <= 40; i++) for(int ca = 0; ca <= 411; ca++) for(int cb = 0; cb <= 411; cb++) dp[i][ca][cb] = INF;
    
    dp[0][0][0] = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= 400; j++){
            for(int k = 0; k <= 400; k++){
                if(dp[i][j][k] >= INF) continue;
                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
                dp[i+1][j + a[i]][k + b[i]] = min(dp[i+1][j+a[i]][k + b[i]], dp[i][j][k] + c[i]);
            }
        }
    }
    
    int res = INF;
    for(int j = 1; j <= 400; j++) {
        for(int k = 1; k <= 400; k++){
            if(j * MB != k * MA) continue;
            res = min(res, dp[N][j][k]);
        }
    }
    
    if(res != INF) cout << res << endl;
    else cout << -1 << endl;
    
}


Measured memory_bytes: 27520
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;

ll a, b;
ll f(ll x){
	return (a*x)/b - a*(x/b);
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 
	cin >> a >> b;
	ll x; cin >> x;


	if(x < b){
		cout << f(x) << '\n';
	}else{
		cout << f(b-1) << '\n';
	}
	

	return 0;
}

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

namespace Sort_I
{
    class Bubble_Sort
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var A = Console.ReadLine().Split(' ').Select(s=>int.Parse(s)).ToArray();
            var n=BubbleSort(A);
            for (int i = 0; i < A.Length-1; i++)
            {
                Console.Write(A[i] + " ");
            }
            Console.WriteLine(A.Last());
            Console.WriteLine(n);
        }

        static int BubbleSort(int[] A)
        {
            bool flag = true;
            var n = 0;
            while (flag)
            {
                flag = false;
                for(int j = A.Length - 1; j > 0; j--)
                {
                    if(A[j]<A[j-1])
                    {
                        var temp = A[j];
                        A[j] = A[j - 1];
                        A[j - 1] = temp;
                        n++;
                        flag = true;
                    }
                }
            }
            return n;
        }
    }
}

Measured memory_bytes: 9536
n = int(input())
A = map(int, input().split())
count = 0
B = []
for i in A:
    if(i<0):
        count += 1
    B.append(abs(i))
if(count % 2 == 0):
    print(sum(B))
else:
    print(sum(B) - 2*min(B))

Measured memory_bytes: 64880
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		int N =sc.nextInt();



		List<Integer>list=new ArrayList<Integer>();
		for(int i=0;i<N;i++) {
			int aa=sc.nextInt();
                        int bb=sc.nextInt();

			list.add(bb-aa);
			//System.out.println(a);
		}
		int ans=0;
		for(int i=0;i<list.size();i++){
			ans+=list.get(i)+1;
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 28088
from fractions import gcd

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

# ans = lcm(a) - 1
# lcm(a, b) = (a * b) // gcd(a, b)

LCM = a[0]
for i in range(1, n):
    LCM = (LCM*a[i]) // gcd(LCM, a[i])
LCM -= 1

ans = 0
for i in a:
    ans += LCM % i
print(ans)

Measured memory_bytes: 5688
N=int(input())
for i in range(N):
    S=input()
    stack=[]
    num=[0]
    st=""
    N=len(S)
    for j in range(N):
        i=S[j]
        #print(num)
        #print(stack)
        #print('"'+i+'"',st)
        if i=="[":
            stack.append(0)
            num.append(0)
        elif i=="]":
            n=num.pop()
            num[-1]+=1
            if st!="":
                stack[-1]+=((int(st)+1)//2)
            else:
                tmp=[]
                for k in range(n):
                    tmp.append(stack[-1])
                    stack.pop()
                tmp.sort()
                stack[-1]+=sum(tmp[:(len(tmp)+1)//2])
            st=""
        else:
            st=st+str(i)
    #print(num)
    #print(stack)
    print(stack[0])


Measured memory_bytes: 5688
#include<iostream>
#include<algorithm>
#define wh 0
#define gr 1
#define bl 2
#define inf 2001
#define null (-1)
#define Max 100 
using namespace std;
int color[Max],m[Max][Max];
int d[Max],p[Max],n;
void prim(){
int i,j,u;
	for(i=0;i<n;i++){
	color[i]=wh;
		d[i]=inf;
	}
	d[0]=0;
	p[0]=-1;
	while(true){
	int mincost=inf;
		for(i=0;i<n;i++){
			if(color[i]!=bl && d[i]<mincost){
			mincost=d[i];
				u=i;
			}
		}
		if(mincost==inf)
		break;
		color[u]=bl;
		for(int v=0;v<n;v++){
			if(color[v]!=bl && m[u][v]!=null){
				if(m[u][v]<d[v]){
				d[v]=m[u][v];
					p[v]=u;
					color[v]=gr;
				}
			}
		}
	}
}

main(){
	int i,j;
	cin>>n;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
	cin>>m[i][j];
			m[j][i]=m[i][j];
		}
	}
	prim();
	int ans=0;
	for(i=0;i<n;i++)
	ans+=d[i];
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n= scan.nextInt();
		int a[]=new int[n];
		int min=0,max=0;
		for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
			if(i==0) {
				min=a[i];
				max=a[i];
			}else {
				if(min>a[i])min=a[i];
				if(max<a[i])max=a[i];
			}
		}
		scan.close();
		System.out.println(max-min);
	}
}


Measured memory_bytes: 23380
# input
N, A, B = map(int, input().split())

# check
if A == 0:
    print(0)
else:
    cnt = int(N / (A + B))
    amr = N % (A + B)
    ans = A * cnt
    if amr >= A:
        ans += A
    else:
        ans += amr
        
    print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#define ll long long
#define MAX 1000003
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define all(a) (a).begin(),(a).end()
#define input(a) for(int i=0;i<n;i++) cin>>a[i];
using namespace std;

int main(){
	IOS;
	ll num; cin>>num;
	ll ans=1e17+9;
	for(ll i=1;i*i<=num;i++){
		if(num%i==0){
			ans=min(ans,i+num/i-2);
		}
	}	

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int N, count = 0; cin >> N;
  string S; cin >> S;
  for (int i = 0; i < N - 2; i++) {
  	if (S.substr(i, 3) == "ABC") {
    	count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val x = (1..6).map { readLine()!!.toInt() }
    val array = intArrayOf(x[1] - x[0], x[2] - x[0], x[3] - x[0], x[4] - x[0],
        x[2] - x[1], x[3] - x[1], x[4] - x[1],
        x[3] - x[2], x[4] - x[2],
        x[4] - x[3])
    if (array.all { it <= x[5] }) println("Yay!") else println(":(")
}

Measured memory_bytes: 33608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

str s;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s;
    sort(s.begin(),s.end());
    if(s=="abc"){cout<<"Yes\n";}
    else cout<<"No\n";
}



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

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> H(N);
    vector<ll> A(M);
    vector<ll> B(M);

    vector<ll> cost(N + 1, -2);

    rep(i, N) {
        cin >> H[i];
    }
    rep(i, M) {
        cin >> A[i] >> B[i];
    }
    rep(i, M) {
        ll maxValue = max(H[A[i] - 1], H[B[i] - 1]);
        if(H[A[i] - 1] == H[B[i] - 1]) maxValue = LONG_LONG_MAX;
        if(cost[A[i]] < maxValue) cost[A[i]] = maxValue;
        if(cost[B[i]] < maxValue) cost[B[i]] = maxValue;
    }
    ll cnt = 0;
    rep(i, N) {
        if(cost[i + 1] <= H[i]) cnt++;
    }

    cout << cnt << endl;
    return 0;
}

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

#define ll long long

#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define output_s(a) printf("%s\n",(a).c_str())

//library----------------------------------------------


int main(){
    int a; cin>>a;
    string s; cin>>s;
  	if(a>=3200) {output_s(s);}
  	else{printf("red");}
    return 0;  
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException{
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int h = Integer.parseInt(str[0]);
    int a = Integer.parseInt(str[1]);
    System.out.println((h+a-1)/a);
  }
}

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

#define MOD 1000000007
#define INF (1<<30)
#define INFL (1LL<<62)
#define pe(str) return cout<<(str)<<endl,0
#define px(str) cout<<(str)<<endl,exit(0)
#define accu(ac,v) cout<<setprecision(ac)<<v<<endl
#define bpc(a) __builtin_popcount(a)
#define pr(str) cout<<(str)<<endl
#define prpr(str) cout<<str<<endl
#define db(str) cerr<<"debug:"<<(str)<<endl
#define dbdb(str) cerr<<"debugs:"<<str<<endl
#define re(i,n) for(int i=0;i<(n);i++)
#define rre(i,n) for(int i=(n);i>=0;i--)
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b);i>=(a);i--)
#define bw(a,b,c) (((a)<=(b))&&((b)<=(c)))
#define hello cout<<"hello"<<endl
#define spre(a) setprecision(a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define IF(C,T,F) ((C)?(T):(F))
#define max3(a,b,c) max((a),max((b),(c)))
#define min3(a,b,c) min((a),min((b),(c)))
#define max4(a,b,c,d) max((a),max((b),max((c),(d))))
#define min4(a,b,c,d) min((a),min((b),min((c),(d))))
#define enl cout<<endl
#define declare(t,n) t n;cin>>n
#define EPS 1e-6
#define EPSIN(a,b) ((b)-EPS<=(a)&&(a)<=(b)+EPS)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef complex<int> point;

template<class InputIterator>
void dump(InputIterator first,InputIterator last,char delim=' '){
	for(InputIterator it=first;it!=last;it++){
		if(it!=first)cout<<delim;
		cout<<*it;
	}
}

ull p(ull x,ull y){
	if(y==0) return 1;
	ull A=p(x,y/2)%MOD;
	// return (y&1?((A*A)%MOD*x)%MOD: (A*A)%MOD);
	return (y&1?((A*A)*x):(A*A));
}

template<class T>
void swp(T &a,T &b){
	T t=a; a=b; b=t;
}

template<class T>
int h(T first,string t){
	T it=first;
	int c=0;
	for(int i=0;i<t.size();i++){
		if(*it!=t[i]) c++;
		it++;
	}
	return c;
}

const int M=100001;
int m[M][30];
int main(void){
	int n,a;
	cin>>n>>a;
	int s,c,t;
	re(i,n){
		cin>>s>>t>>c;
		rep(j,s,t+1) m[j][c-1]=1;
	}
	int z=0;
	re(i,M){
		z=max(z,(int)count(m[i],m[i]+a,1));
	}
	cout<<z<<endl;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define mset(arr, val) memset((arr), (val), sizeof(arr))
#define For(i, init, n) for (int64_t (i) = (init); (i) < (n); (i)++)
#define ___ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

// const double PI = acos(-1.0), E = exp(1.0), EPS = 1e-9;
const int MOD = (int)1e9 + 7, N = (int)1e5;

int main()
{   
#ifdef MY_PREPROCESSOR
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ___
    
    string s;
    cin >> s;
    int cnt = 0, tmp = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] != 'R')
        {
            cnt = max(cnt, tmp);
            tmp = 0;
        }
        else
        {
            tmp++;
        }
    }
    cnt = max(cnt, tmp);
    cout<< cnt;
    
    return 0;
}

Measured memory_bytes: 3644
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
input = sys.stdin.readline
 
# bisect_left(lists, 3)
# bisect_right(lists, 3)
 
def main():
	R, G, B, N = map(int, input().split(" "))
	
	ans = 0
	for i in range(N+1):
		r = i * R
		for j in range(N+1):
			g = j * G
			if N - r - g < 0:
				continue
			if (N - r - g) % B != 0:
				continue
			#k = (N - r - g) // B
			#print("{} {} {}".format(i, j, k))
			ans += 1
			

	print(ans)

	
	
if __name__ == "__main__":
	main()

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

  public static void main (String[] args) {
	
    Scanner scanner = new Scanner(System.in);
    
    int A = scanner.nextInt();
    int B = scanner.nextInt();

    scanner.close();

    if((A + B) % 2 == 0){
      System.out.println((A + B) / 2 );
    }else {
      System.out.println("IMPOSSIBLE");
    }
    
  }

}

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

using namespace std;
typedef long long ll;
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
vector<ll> divisor(ll x){
	vector<ll> div;
	for(int i=1;i*i<=x;i++){
		if(i*i!=x && x%i==0){
			div.pb(i);
			div.pb(x/i);
		}
		else if(x%i==0) div.pb(i);
	}
	return div;
}
vector<ll> vectorprime(ll x){
	vector<bool> is_prime(x+1);
	vector<ll> prime;
	rep(i,x+1) is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=x;i++){
		if(is_prime[i]){
			prime.pb(i);
		}
		for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
	}
	return prime;
}

//a,b x
int main(){
	string s; cin>>s;
	ll a=0,b=0;
	if(s[0]==s[s.sz-1]) a=1;
	if(s.sz%2==0) b=1;
	
	if((a^b)==0) cout<<"First";
	else cout<<"Second";
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

ll a[200000];
ll sum[200000], n, s;

// ?????????????????????x??\?????§3????????????????????¨?????§?????????
bool solve(ll x) {
	REP(i, n) {
		bool flag = true;
		int pos = i;
		REP(j, 2) {
			pos = lower_bound(sum + i, sum + i + n, sum[pos] + x) - sum;
			if (pos == i + n) { flag = false; break; }
		}
		if (flag && s - (sum[pos] - sum[i]) >= x) return true;
	}
	
	return false;
}

int main() {
	cin >> n;
	
	REP(i, n) {
		scanf("%lld", &a[i]);
		a[n + i] = a[i];
		s += a[i];
	}
	sum[0] = a[0];
	FOR(i, 1, 2*n) sum[i] = sum[i - 1] + a[i];
	
	ll l = -1, r = n * 1000000000;
	while (r - l > 1) {
		ll m = (l + r) / 2;
		if (solve(m)) l = m;
		else r = m;
	}
	
	cout << l << endl;
	
	return 0;
}

Measured memory_bytes: 6352
import java.nio.file.*;
import java.nio.charset.*;
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int l = n.length();
        System.out.println(n.substring(0, 1) + Integer.toString(l-2) + n.substring(l - 1, l));
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
  string s="NG";
  int k, a, b;
  //cin >> s;
  cin >> k >> a >> b;
  //cin >> s >> t >> u;
  for (int i = a; i <= b; i++) {
        if(i%k==0) s = "OK";
  }
  
  cout << s << endl; 
  
}

Measured memory_bytes: 3624
n, m, x = map(int, input().split())
c = [list(map(int, input().split())) for i in range(n)]
ans = float("INF")

for i in range(1 << n):
    costs = 0
    understand = [0] * m
    for j in range(n):
        if i >> j & 1:
            costs += c[j][0]
            for k in range(m):
                understand[k] += c[j][k + 1]
    if min(understand) >= x:
        ans = min(ans, costs)
    
print(ans) if ans != float("INF") else print(-1)

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const ll MOD = (ll)(1e9 + 7);
const int MAX_N = 112345;

struct Edge{
  int to;
  ll d;
  bool operator<(const Edge& o) const {
    return d > o.d; // reverse order
  }
};
vector<Edge> g[MAX_N];

const ll INF = (1LL << 60);

void build(int s, int t, ll d[MAX_N], ll f[MAX_N]) {
  REP(i, MAX_N) d[i] = INF;
  priority_queue<Edge> pq;
  d[s] = 0;
  f[s] = 1;
  pq.push({s, 0}); 
  while (!pq.empty()) {
    const Edge cur = pq.top(); pq.pop();
    if (cur.d != d[cur.to]) continue;
    for (const Edge &e : g[cur.to]) {
      if (d[e.to] > cur.d + e.d) {
        d[e.to] = cur.d + e.d;
        pq.push({e.to, d[e.to]});

        f[e.to] = f[cur.to];
      } else if (d[e.to] == cur.d + e.d) {
        (f[e.to] += f[cur.to]) %= MOD;
      }
    }
  }

}
ll d0[MAX_N], d1[MAX_N]; // 最短距離
ll f0[MAX_N], f1[MAX_N]; // 経路の総数

bool overlap(ll a, ll b, ll c, ll d) {
  if (b < c) return false;
  if (d < a) return false;
  return true;
}
int main2() {
  REP(i, MAX_N) g[i].clear();
  CLR(d0, 0);
  CLR(f0, 0);
  CLR(d1, 0);
  CLR(f1, 0);
  int N = nextInt();
  int M = nextInt();
  int S = nextInt() - 1;
  int T = nextInt() - 1;
  REP(i, M) {
    int A = nextInt() - 1;
    int B = nextInt() - 1;
    int C = nextInt();
    g[A].push_back({B, C});
    g[B].push_back({A, C});
  }

  build(S, T, d0, f0);
  build(T, S, d1, f1);

  // pv(d0, d0 + 8);

  ll ans = (f0[T] * f1[S]) % MOD;

  ll D = d0[T];

  // cout << "all=" << ans << endl;
  REP(i, N) {
    if (i == S || i == T) continue;
    if (d0[i] == d1[i] && d0[i] + d1[i] == D) {
      ll add = (f0[i] * f1[i]) % MOD;
      add = (add * add) % MOD;
      ans -= add;
      ans = (ans % MOD + MOD) % MOD;
    }
  }
  // cout << "p=" << ans << endl;
  REP(v1, N) {
    for (const Edge& e: g[v1]) {
      const int v2 = e.to;
      if (d0[v1] + e.d == d0[v2] && d0[v2] + d1[v2] == D) {
        // cout << "e.." << v1+1 << " " << v2+1 << " " << e.d << " " << d0[v1] << "->" << d0[v2] << " " << endl;
        if (overlap(d0[v1]+1, d0[v2]-1, d1[v2]+1, d1[v1]-1)) {
          ll add = (f0[v1] * f1[v2]) % MOD;
          add = (add * add) % MOD;
          ans -= add;
          // cout << "sub=" << add << endl;
          ans = (ans % MOD + MOD) % MOD;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 19412
#include<iostream>
#include<iomanip>
#include<sstream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<numeric>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;
typedef map<string,int> dict;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
double eps = 1e-10 ;

template <typename T>
void out(vector < T > v)
{
  for(size_t i = 0; i < v.size(); i++)
  {
    debug(v[i]);
  }
}

template<typename T>
string ntos( T i ) {
  ostringstream s ;
  s << i ;
  return s.str() ;
}

template<typename T>
T ston(string str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}


double EPS = 1e-10;
double add(double a, double b){
  if(abs(a+b) < EPS* (abs(a) + abs(b))) return 0;
  return a+b;
}

struct P{
  double x,y;
  P(){}
  P(double _x,double _y):x(_x),y(_y){}
  P operator + (P p){
    return P(add(x,p.x) ,add(y,p.y));
  }
  P operator - (P p){
    return P(add(x,-p.x) ,add(y,-p.y));
  }
  P operator * (double d){
    return P(x * d,y * d);
  }
  double dot(P p){
    return add(x * p.x,y*p.y);
  }
  double det(P p){
    return add(x*p.y,-y*p.x);
  }
};
//???????????????????????¨?????????
bool on_seg(P p1,P p2,P q){
  return (p1-q).det(p2-q) == 0 && (p1-q).dot(p2-q) <= 0;
}
//???????°????
P intersection(P p1, P p2, P q1,P q2){
  return p1 + (p2-p1) * ((q2 - q1).det(q1-p1) / (q2 - q1).det(p2-p1)) ;
}

bool cmp_x(const P& p, const P& q){
  if(p.x != q.x) return p.x < q.x;
  return p.y < q.y;
}
int ans = 0;
vector<P> convex_hull(P *ps,int n){
  sort(ps,ps+n,cmp_x);
  int k = 0;
  vector<P> qs(n*2);
  rep(i,n){
    while(k > 1 && (qs[k-1] -qs[k-2]).det(ps[i] - qs[k-1]) <= 0){
      k--;
    }
    qs[k++] = ps[i];
  }
  for(int i = n-2,t = k; i >= 0; i--){
    while(k>t && (qs[k-1] - qs[k-2]).det(ps[i]-qs[k-1]) <= 0){
      k--;
    }
    qs[k++] = ps[i] ;
  }
  qs.resize(k-1);
  cout << n-qs.size() << endl;
  return qs;
}

double dist(P p,P q){
  return (p - q).dot(p - q);
}

constexpr int MAX_N = 100000;
int N;
P ps[MAX_N];

void Solve(){
  vector<P> qs = convex_hull(ps,N);
  double res = 0;
  rep(i,qs.size()){
    rep(j,i){
      res = max(res,dist(qs[i],qs[j]));
    }
  }
  cout << res << endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double x,y;
  char c;
  while(cin >> N){
    if(N == 0){
      break;
    }
    rep(i,N){
      cin >> x >>c >> y;
      ps[i] = P(x,y);
    }
    convex_hull(ps,N);
  }
  return 0;
}

Measured memory_bytes: 3248
mod = 10 ** 9 + 7

g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

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

def calc(x, y):
	a = 2 * y - x
	
	if a < 0 or a % 3 != 0:
		return 0
	
	a //= 3
	b   = y - 2 * a
	
	if b < 0:
		return 0
		
	for i in range( 2, a + b + 1 ):
		g1.append( ( g1[-1] * i ) % mod )
		inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
		g2.append( (g2[-1] * inverse[-1]) % mod )
		
	return cmb(a + b, a, mod)

x, y = [int(x) for x in input().split()]

print(calc(x, y))


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, C, K;
  cin >> N >> C >> K;
  vector<ll> T(N);
  for (int i = 0; i < N; i++) {
    cin >> T[i];
  }
  sort(T.begin(), T.end());
  ll res = 1, cnt = 0;
  ll minn = T[0] + K;
  for (int i = 0; i < N; i++) {
    if (cnt < C && minn >= T[i]) {
      cnt++;
    } else {
      res++;
      cnt = 1;
      minn = T[i] + K;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	int n, m;
	cin >> n >> m;
	int dp[3] = {};
	dp[2] = -1;
	dp[1] = -1;
	dp[0] = -1;
	for (int i = 0; i < m; i++) {
		int s, c;
		cin >> s >> c;
		if (n == 3) {
			if (dp[3-s] == -1) {
				dp[3-s] = c;
			}
			else if (dp[3-s] != c) {
				cout << -1;
				return 0;
			}
		}
		else if (n == 2) {
			if (dp[2 - s] == -1) {
				dp[2 - s] = c;
			}
			else if (dp[2 - s] != c) {
				cout << -1;
				return 0;
			}
		}
		else {
			if (dp[1 - s] == -1) {
				dp[1 - s] = c;
			}
			else if (dp[1 - s] != c) {
				cout << -1;
				return 0;
			}
		}
	}
	for (int i = n-1; i >= 0; i--) {
		if (i == n - 1) {
			if (dp[i] == -1) {
				if (n == 1) {
					cout << 0;
					return 0;
				}
				dp[i] = 1;
			}
			else if(dp[i] == 0){
				if (n == 1) {
					cout << 0;
					return 0;
				}
				cout << -1;
				return 0;
			}
		}

		if (dp[i] == -1) {
			dp[i] = 0;
		}
		cout << dp[i];
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int a, b;
  cin >> a >> b;
  if (a<=9 && b<=9) cout << a*b << endl;
  else cout << -1 << endl;
  return 0;
}

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

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

ll N, W;
constexpr ll maxN = 100;
vector<ll> val[4], acc[4];
ll wn[4];


int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif
  cout << setprecision(20);

  cin >> N >> W;
  ll w0;
  ll w;
  ll v;
  cin >> w0 >> v;
  val[0].push_back(v);
  for (ll i = 1; i < N; i++) {
    cin >> w >> v;
    val[w - w0].push_back(v);
  }
  for (ll j = 0; j < 4; j++)  {
    sort(val[j].begin(), val[j].end(), greater<ll>());
  }
  for (ll j = 0; j < 4; j++) {
    acc[j].push_back(0);
    for (size_t i = 1; i <= val[j].size(); i++) {
      acc[j].push_back(acc[j][i-1] + val[j][i-1]);
    }
  }
  ll answer = 0;
  for (size_t i0 = 0; i0 <= val[0].size(); i0++) {
    for (size_t i1 = 0; i1 <= val[1].size(); i1++) {
      for (size_t i2 = 0; i2 <= val[2].size(); i2++) {
	for (size_t i3 = 0; i3 <= val[3].size(); i3++) {
	  ll curW = i0 * w0 + i1 * (w0+1) + i2 * (w0+2) + i3 * (w0+3);
	  if (curW > W) continue;
	  ll total = acc[0][i0] + acc[1][i1] + acc[2][i2] + acc[3][i3];
	  answer = max(answer, total);
	}
      }
    }
  }
  cout << answer << endl;

  return 0;
}



Measured memory_bytes: 256
def main():
    A_list = [A for A in input().split()]
    A_list = list(map(int, A_list))
    if A_list[0] == 0 :
        print("1")
    elif A_list[1] == 0 :
        print("2")
    elif A_list[2] == 0 :
        print("3")
    elif A_list[3] == 0 :
        print("4")
    else :
        print("5")



if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
#include<cmath>
#include<iostream>

using namespace std;

#define PONTA true
#define GONTA false

int n;
int getMin(bool* cmb, bool party, int i, int* pows);
int getDiff(bool* cmb, int* pows);

int main(){
	while(cin >> n && n){
		int pows[n];
		bool cmb[n];
		for(int i = 0; i < n; i++) cin >> pows[i];
	
		cout << min( getMin(cmb, PONTA, 0, pows), getMin(cmb, GONTA, 0, pows) ) << endl;
	}
	return 0;
}

int getMin(bool* cmb, bool party, int i, int* pows){
	cmb[i] = party;
	return (i == n-1)? getDiff(cmb, pows):
		min( getMin(cmb, PONTA, i+1, pows), getMin(cmb, GONTA, i+1, pows) );
}

int getDiff(bool* cmb, int* pows){
	int p = 0, g = 0;
	for(int i = 0; i < n; i++){
		if(cmb[i] == PONTA) p += pows[i];
		else g += pows[i];
	}
	return abs(p-g);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

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

  int ans=0;
  
  rep(i,6) {
    if (s[i]=='1') ans++;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
	string s; cin >> s; int n = s.size();
	int ans = 0;
	rep(i,n){
		if(i > n-1-i) break;
		if(s[i] != s[n-1-i]) ans++;
	}
	cout<<ans<<endl;
}

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

void output(vector<int> a)
{
    for (int i = 0; i < a.size() - 1; i++)
    {
        cout << a[i] << " ";
    }
    cout << a[a.size() - 1] << endl;
}

int main()
{
    int N, S = 0;
    cin >> N;
    vector<int> a(N);
    vector<int> b(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        S ^= a[i];
    }
    for (int i = 0; i < N; i++)
    {
        b[i] = S ^ a[i];
    }
    output(b);
}

Measured memory_bytes: 5520
//1.read question_2.read I/O_3.read test cases_4.read constraints(to decide TC of solution)_5.decide method_6.dry run_
//7.code_8.test_9.submit
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mod 1000000007
#define F first
#define S second
#define _READ freopen("input.txt","r", stdin);
#define pb push_back
#define MP make_pair
#define _FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main()
{
    //freopen("input.txt","r", stdin);
    _FAST
    lli n,t,i,j,k,ans=0,flag=0,a,b,m;
    cin>>n>>k;vector<lli> ar(n);
    for(auto &i:ar)
        cin>>i;
    vector<lli> dp(n,INT_MAX);
    dp[0]=0;
    for(i=1;i<n;i++)
    {
        for(j=1;j<=k;j++)
            dp[i]=min(i-j<0?dp[i]:abs(ar[i-j]-ar[i])+dp[i-j]
                  ,dp[i]);
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main() {
  string s;
  cin >> s;
  int a = s.find('A');
  int z = s.rfind('Z');
  P(z - a + 1);
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>  
#include <stdio.h>  
#include <stdlib.h>  
using namespace std;

long long int max(long long int x, long long int y){
  if(x > y)
    return x;
  return y;
}

long long int min(long long int x, long long int y){
  if(x < y)
    return x;
  return y;
}

int main(void){
  long long int n; 
  cin >> n;
  long long int res = n;
  for (long long int i= 1; i <= sqrt(n); i++){
    if(n%i !=0)
      continue;
    res = min(res, max(i, n/i));
  }
  int ans;
  long long int num = 10;
  for(int i = 0; i < 10; i++){
    if (res < num){
      ans = i + 1;
      break;
    }
    num *= 10;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter

import sys

readline = sys.stdin.buffer.readline

N = int(readline())
A = tuple(map(int, readline().split()))

Q = int(readline())
BC = [list(map(int, readline().split())) for _ in range(Q)]

d = Counter(A)

sub_s = sum(A)

for b, c in BC:
    sub_s += d[b] * (c - b)
    d[c] += d[b]
    d[b] = 0

    print(sub_s)


Measured memory_bytes: 40280
#include<cstdio>
#include<algorithm>
#define _rep(i,s,t) for(register int i=s;i>=t;--i)
#define rep(i,s,t) for(register int i=s;i<=t;++i)
using namespace std;
int ans;
const int N=5e5+11;
int n;
int a[N];
inline bool check(int x){
	rep(i,0,n-2){
		if(a[n+i]>=x&&a[n+i+1]>=x||a[n-i]>=x&&a[n-i-1]>=x)return 1;
		if(a[n+i]<x&&a[n+i+1]<x||a[n-i]<x&&a[n-i-1]<x)return 0;
	}
	return a[n+n-1]>=x;
}
int main(){
	scanf("%d",&n);
	rep(i,1,n+n-1)
		scanf("%d",a+i);
	_rep(i,30,0)
		if(check(ans|(1<<i)))
			ans|=(1<<i);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896