akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N,X;
vector<int> L;

int solve(void) {
    int D = 0;
    int temp = 0;
    int ans = 1;

    for(int i = 1;i <= N;i++) {
        D = D + L[i-1];
        if(D <= X)
            ans++;
    }

    return ans;
}
int main(void) {
    cin>>N>>X;

    for(int i=0;i < N;i++) {
        int l;
        cin>>l;
        L.push_back(l);
    }

    cout<<solve()<<endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //c
  long long l, r;
  cin >> l >> r;
  if (r - l + 1 >= 3000) {
    cout << 0 << endl;
  } else {
    long long ans = 1 << 30;
    for (long long i = l; i <= r; i++) {
      for (long long j = i + 1; j <= r; j++) {
        ans = min(ans, i * j % 2019);
      }
    }
    cout << ans << endl;
  }

  return 0;
}

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

using std::cout;
using std::cin;
using std::endl;
using std::pow;
using std::vector;
using std::string;

int main(){
    long n,x,t,res;
    cin >> n >> x >> t;
    res = (n+x-1)/x*t;
    cout << res;
}

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

int main() {
    int N, K, X, Y, sum;
    cin >> N >> K >> X >> Y;
    if (N-K >= 0) {
        sum = K * X + (N-K) * Y;
    } else {
        sum = N * X;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define N 100
using namespace std;
int simple(int val,int year,double interest,int fee){
    //val gain gain_sum;
    int gain, gain_sum;
    for(int i=0;i<year;i++){
	gain=(int)val*interest;
	gain_sum+=gain;
	val-=fee;
    }
    return val+gain_sum;
}
int compound(int val, int year, double interest,int fee){
    int gain;
    for(int i=0;i<year;i++){
	gain=(int)val*interest;
	val+=gain;
	val-=fee;
    }
    return val;
}
    
int main(){
    int m;
    cin >>m;
    for(int i=0;i<m;i++){
	int M=0;
	int val,year,n;
	cin >> val>>year>>n;
	//how to manage asset
	for(int j=0;j<n;j++){
	    int type, fee;
	    double interest;
	    cin >> type >> interest >> fee;
	    if (type==0){
		int s=simple(val,year,interest,fee);
		if(s>M)M=s;
	    }
	    else{
		int c=compound(val,year,interest,fee);
		if (c>M)M=c;
	    }
	    
	}
	cout << M << endl;
    }
    
}

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

int main(){
	int a,b,p;
	a = b = 0;
	
	for(int i = 0; i < 4; i++){
		cin >> p;
		a += p;
	}
	
	for(int i = 0; i < 4; i++){
		cin >> p;
		b += p;
	}
		
	if(a > b){
		cout << a << endl;
	}else{
		cout << b << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
from collections import defaultdict


def solve():
    n = int(input())
    d = defaultdict(int)
    for i in range(n):
        s = input()
        d[s] += 1
    print('AC x', d['AC'])
    print('WA x', d['WA'])
    print('TLE x', d['TLE'])
    print('RE x', d['RE'])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9480
#include<bits/stdc++.h>
using namespace std;
int main() 
{
    int d,t,s;
    cin>>d>>t>>s;
    int ans=s*t;
    if(ans>=d)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000



int main(){
	
	string S;
	cin>>S;
	
	for(int i=0;i<S.size();i++){
		if(i%2==0&&S[i]=='L'){
			cout<<"No"<<endl;
			return 0;
		}
		if(i%2==1&&S[i]=='R'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	
	cout<<"Yes"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
bool prime[1000000];
int main()
{
	int n;
	prime[1] = true;
	for(int i = 2; i * i <= 105000; i++){
	    if(prime[i] == false){
            for(int j = i; j <= 105000; j+=i){
                prime[j] = true;
            }
            prime[i] = false;
	    }
	}
	int p[105000];
	for(int i = 2,j = 1; i <= 105000; i++){
        if(prime[i] == false){
            p[j] = i;
            j++;
        }
	}


	while(1){
	    int sum = 0;
        cin >> n;
        if(n == 0) break;
        for(int i = 1; i <= n; i++){
            sum += p[i];
        }
        cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1304
#include <stdio.h>

int N,M,R,r[8],cost[201][201];
int nest = 9;
char pad[]="               ";

int dfs(int now){
    int i,ret,rt,tmpcost,flag;
    flag = 0;
    ret = 1000000000;
    for(i=0;i<R;i++){
        if(r[i]>0){
            rt=r[i];
            r[i]=0;
            tmpcost = cost[now][rt] + dfs(rt);
            r[i]=rt;
            if(tmpcost<ret)ret=tmpcost;
            flag=1;
        }
    }
    return (flag?ret:0);
}

int main(){
    int a,b,c;
    int i,j,k;

    scanf("%d %d %d",&N,&M,&R);
    for(i=0;i<R;i++){
        scanf("%d",&r[i]);
    }

    for(i=1;i<=N;i++){
        for(j=1;j<=N;j++){
            cost[i][j]=100000000;
        }
        cost[0][i]=cost[i][0]=cost[i][i]=0;
    }

    for(i=0;i<M;i++){
        scanf("%d %d %d",&a,&b,&c);
        cost[a][b] = cost[b][a] = c;
    }

    /* ワーシャルフロイド */
    for(k=1;k<=N;k++){
        for(i=1;i<=N;i++){
            for(j=1;j<=N;j++){
                if(cost[i][j] > cost[i][k] + cost[k][j]){
                    cost[i][j] = cost[i][k] + cost[k][j];
                }
            }
        }
    }

    printf("%d\n",dfs(0));
    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        x: usize, y: usize,
    }


    println!("{}", x + y / 2);
}


Measured memory_bytes: 2100
#include<stdio.h>
#include<math.h>

struct Point{
    double x;
    double y;
};

void koch(int n,struct Point p1,struct Point p2){
    if(n == 0) return;
    struct Point s,t,u;
    double th = M_PI * 60.0 / 180.0;

    s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
    s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
    t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
    t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y -s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n-1,p1,s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(n-1,t,p2);
}

int main(){
    struct Point p1,p2;
    int n;

    scanf("%d",&n);

    p1.x = 0;
    p1.y = 0;
    p2.x = 100;
    p2.y = 0;

    printf("%.8f %.8f\n",p1.x,p1.y);
    koch(n,p1,p2);
    printf("%.8f %.8f\n",p2.x,p2.y);

    return 0;
}


Measured memory_bytes: 2112
#include<stdio.h>
#include<stdlib.h>

#define NUM  100000

int main()
{
    int input_len, output;
    int input;
    int a1_input_cnt[NUM];
    int a2_input_cnt[NUM];
    int a1_1st, a1_2nd, a1_val_1st, a1_val_2nd;
    int a2_1st, a2_2nd, a2_val_1st, a2_val_2nd;
    int num;
 
    for(int i= 0; i < NUM; i++)
    {
        a1_input_cnt[i] = 0;
        a2_input_cnt[i] = 0;
    }
    a1_1st = 0;
    a2_1st = 0;   
    a1_2nd = 0;
    a2_2nd = 0;
    a1_val_1st = 0;
    a1_val_2nd = 0;
    a2_val_1st = 0;
    a2_val_2nd = 0;
    
    //長さの取得
    scanf("%d", &input_len);
    
    if(input_len == 2)
    {
        printf("0");
        return (0);
    }
    
    for(int i = 0; i < input_len; i++)
    {
        scanf("%d", &input);
        num = i % 2;
        if(num == 0)
        {
            a1_input_cnt[input]++;
        }
        else
        {
            a2_input_cnt[input]++;
        }
            
    }

    
    for(int i = 0; i < NUM; i++)
    {
        //a1
        if(a1_input_cnt[i] != 0)
        {
            if(a1_1st < a1_input_cnt[i])
            {
                a1_2nd = a1_1st;
                a1_val_2nd = a1_val_1st;
                
                a1_1st = a1_input_cnt[i];
                a1_val_1st = i;
            }
            else if(a1_2nd <  a1_input_cnt[i])
            {
                a1_2nd = a1_input_cnt[i];
                a1_val_2nd = i;
            }
        }
        
        
        
        //a2
        if(a2_input_cnt[i] != 0)
        {
            if(a2_1st < a2_input_cnt[i])
            {
                a2_2nd = a2_1st;
                a2_val_2nd = a2_val_1st;
                
                a2_1st = a2_input_cnt[i];
                a2_val_1st = i;
            }
            else if(a2_2nd <  a2_input_cnt[i])
            {
                a2_2nd = a2_input_cnt[i];
                a2_val_2nd = i;
            }
        }      

    }
    
    if(a1_val_1st == a2_val_1st)
    {
        if((a1_1st + a2_2nd) >= (a1_2nd + a2_1st))
        {
            output = input_len - (a1_1st + a2_2nd);
        }
        else
        {
             output = input_len - (a1_2nd + a2_1st);
        }
        
    }
    else
    {
         output = input_len - ( a1_1st + a2_1st );
    }
    
    // 出力
    printf("%d\n", output);
    return 0;
}



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

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int[] DX8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, DY8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int d = fs.nextInt(), g = fs.nextInt();
		int q[][] = new int[d][2];
		for(int i=0;i<d;i++) {
			q[i][0] = fs.nextInt();
			q[i][1] = fs.nextInt();
		}
		long ans = LINF;
		for(int i=0;i<1<<d;i++) {
			int cnt = 0;
			long sum = 0;
			boolean used[] = new boolean[d];
			for(int j=0;j<d;j++) {
				if((i>>j&1)==1) {
					used[j] = true;
					cnt += q[j][0];
					sum += q[j][1];//ボーナス
					sum += (j+1) * 100 * q[j][0];
				}
			}
			
			if(sum<g) {
				for(int j=d-1;j>=0;j--) {
					if(used[j])continue;
					boolean ok = false;
					for(int k=0;k<q[j][0]-1;k++) {
						sum += (j+1) * 100;
						cnt ++;
						if(sum>=g) {
							ok = true;
							break;
						}
					}
					if(ok)break;
				}
			}
			if(sum>=g)ans = Math.min(ans, cnt);
		}
		System.out.println(ans);
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
using namespace std; typedef long long ll; const int INF=100; typedef pair<int,int> P;

int main() {
  int n,m; cin>>n>>m;
  int a[n]; int cnt=0;
  for(int i=0;i<n;i++) cin>>a[i];
  int sm=0;
  for(int i=0;i<n;i++) sm+=a[i];
  for(int i=0;i<n;i++) {
    if (4 * m * a[i] >= sm) cnt++;
    //cout<<4*m*a[i]<<" "<<sm<<" "<<cnt<<endl;
  }
  if (cnt>=m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
 ll n,a,b; cin>>n>>a>>b; ll k=(n/(a+b));
 if(n%(a+b)==0){cout<<k*a;}
 else {
    k=k*a; ll m=n%(a+b); m=min(a,m); cout<<k+m;
 }
}




Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std ;
int main(){
    int a,b,c,i,n;
    int d;
    int arr[500];
    cin>>n;
    cin>>d>>a;
    for(i = 0;i < n;i++){
        cin>>arr[i];
    }
    for(i = 0;i < n;i++){
        a = a+(d-1)/arr[i]+1;
    }
    cout<<a;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  unsigned long long num_0 = 0;
  unsigned long long num_1 = 0;
  char tmp;
  while (1) {
    tmp = getchar();
    if (tmp == EOF || tmp == '\n') break;
    if (tmp == '1') num_1++;
    else if (tmp == '0') num_0++;
  }
  printf("%llu", (num_0 > num_1 ? num_1 : num_0) * 2);
  return 0;
}


Measured memory_bytes: 128
#include <queue>
#include <tuple>
#include <cctype>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <functional>

#pragma warning(disable : 4996)

using namespace std;

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

int H, W, d[60][30][2]; char M[60][30];

int solve(int sx)
{
	memset(d, -1, sizeof(d));

	priority_queue<tuple<int, int, int, int>, vector<tuple<int, int, int, int> >, greater<tuple<int, int, int, int> > > que;

	que.push(make_tuple(0, sx, H - 1, 0)); d[H - 1][sx][0] = 0;
	que.push(make_tuple(0, sx, H - 1, 1)); d[H - 1][sx][1] = 0;

	while (!que.empty())
	{
		int x = get<1>(que.top());
		int y = get<2>(que.top());
		int s = get<3>(que.top());

		que.pop();

		if (s == 0)
		{
			for (int dir = 0; dir < 9; dir++)
			{
				int x2 = x - dx[dir];
				int y2 = y + dy[dir];

				if (0 <= x2 && x2 < W && 0 <= y2 && y2 < H)
				{
					if (M[y2][x2] != 'X' && d[y2][x2][1] == -1)
					{
						d[y2][x2][1] = d[y][x][s] + (isdigit(M[y2][x2]) ? M[y2][x2] - 48 : 0);

						que.push(make_tuple(d[y2][x2][1], x2, y2, 1));
					}
				}
			}
		}
		else
		{
			for (int dir = 0; dir < 9; dir++)
			{
				int x2 = x + dx[dir];
				int y2 = y + dy[dir];

				if (0 <= x2 && x2 < W && 0 <= y2 && y2 < H)
				{
					if (M[y2][x2] != 'X' && d[y2][x2][0] == -1)
					{
						d[y2][x2][0] = d[y][x][s] + (isdigit(M[y2][x2]) ? M[y2][x2] - 48 : 0);

						que.push(make_tuple(d[y2][x2][0], x2, y2, 0));
					}
				}
			}
		}
	}

	int ret = 999999999;

	for (int i = 0; i < W; i++)
	{
		if (M[0][i] == 'T')
		{
			if (d[0][i][0] != -1) ret = min(ret, d[0][i][0]);
			if (d[0][i][1] != -1) ret = min(ret, d[0][i][1]);
		}
	}

	return ret;
}

int main()
{
	while (true)
	{
		scanf("%d", &W);
		scanf("%d", &H);

		if (W == 0 && H == 0) break;

		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				cin >> M[i][j];
			}
		}

		int ret = 999999999;

		for (int i = 0; i < W; i++)
		{
			if (M[H - 1][i] == 'S')
			{
				ret = min(ret, solve(i));
			}
		}

		printf("%d\n", ret == 999999999 ? -1 : ret);
	}

	return 0;
}

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

int main(void){
    int N; cin >> N;
    int ans = 0;
    for(int i = 1; i < N; i++){
        int aite = N-i;
        if(i < N-i) ans++; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
 
int main(){
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  int ten = 1, sum = 0, cnt[2019] = {};
  long long ans = 0;
  for(int i = 0; i < s.size(); i++){
    cnt[sum]++;
    sum += (s[i] - '0') * ten;
    sum %= 2019;
    ans += cnt[sum];
    ten = (ten * 10) % 2019; 
  }
  cout << ans << endl;
}


Measured memory_bytes: 3708
import math
mod = (10**9) + 7

def kaijo(n):
    result = 1
    for i in reversed(range(1,n+1)):
        result = (result * i) % mod
    return result
def combinations_count(n, r):
    return (kaijo(n)) //(kaijo(n - r) * kaijo(r))

def nCk(n, k):
    ret = 1
    mo = 10**9 + 7
    for i in range(k):
        ret = ret * (n - i) * pow(i + 1, mo - 2, mo) % mo
    return ret


X,Y = map(int,input().split(' '))

if (X+Y)%3 == 0:
    flag = False
    if X > Y:
        diff = X - Y
        all_num = (X+Y)//3
        count_2 = Y - all_num
        if X > Y*2:
            flag = True
    elif Y > X:
        diff = Y - X
        all_num = (X+Y)//3
        count_2 = X - all_num
        if Y > X*2:
            flag = True
    else:
        all_num = (X+Y)//3
        count_2 = all_num//2
    if flag:
        print(0)
    else:
        print(nCk(all_num,count_2))
else:
    print(0)

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

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

using f64 = double;
using f128 = long double;

template <typename T> using Vec = vector<T>;
template <typename K, typename V> using HashMap = unordered_map<K, V>;
template <typename T> using HashSet = unordered_set<T>;

using StrView = string_view;

auto solve(i64 N, i64 K, Vec<i64> d, Vec<Vec<i64>> A) -> void {
  HashSet<i64> set;

  for (auto &v : A) {
    for (i64 a : v) {
      set.insert(a);
    }
  }

  i64 count = 0;
  for (i64 i = 1; i <= N; ++i) {
    if (set.find(i) == set.end()) {
      count += 1;
    }
  }
  cout << count << "\n";
}

auto main() -> int {
  i64 N;
  cin >> N;
  i64 K;
  cin >> K;

  Vec<i64> d(K);
  Vec<Vec<i64>> A;

  for (i64 i = 0; i < K; ++i) {
    i64 d;
    cin >> d;

    Vec<i64> &Ak = A.emplace_back(d);
    for (i64 j = 0; j < d; ++j) {
      cin >> Ak[j];
    }
  }

  solve(N, K, move(d), move(A));

  return 0;
}


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

typedef long long ll;
const int maxn=1e5+10;
int n,m,x;
char s[maxn],t[maxn];

int main(){
	cin>>n>>m>>s>>t;
	x=__gcd(n,m);
	for(int i=0;i<x;++i)
		if(s[n/x*i]!=t[m/x*i]){
			puts("-1");
			return 0;
		}
	printf("%lld\n",(ll)n*m/x);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define incant() cin.tie(0), ios::sync_with_stdio(false)
#define int long long
#define uint unsigned long long
#define double long double
using str = string;
template <class T> using vec = vector<T>;
template <class T> using vvec = vec<vec<T>>;
template <class T> using que = queue<T>;
template <class T> using pque = priority_queue<T>;
template <class... T> using tup = tuple<T...>;
using vint = vec<int>;
using vvint = vvec<int>;
using vstr = vec<str>;
using pint = pair<int, int>;
using vp = vec<pint>;
using tll = tup<int, int, int>;
using vt = vec<tll>;
using mint = map<int, int>;
using dict = map<str, int>;
using qint = que<int>;
using qp = que<pint>;
using pqint = pque<int>;
using pqp = pque<pint>;
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fir first
#define sec second
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define sz(x) x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define ms(v, x) memset(v, x, sizeof(v))
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload3(__VA_ARGS__, revi, _rev,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
#define print(x) out(x), indent()
#define debug(x) cerr << __LINE__ << ": " << #x << ": " << (x) << '\n'
#define YN(x) print((x) ? "YES" : "NO")
#define Yn(x) print((x) ? "Yes" : "No")
#define yn(x) print((x) ? "yes" : "no")
#define POS(x) print((x) ? "POSSIBLE" : "IMPOSSIBLE")
#define Pos(x) print((x) ? "Possible" : "Impossible")
#define pos(x) print((x) ? "possible" : "impossible")
const int INF = LLONG_MAX - INT_MAX, MOD = 1e9 + 7, LIMIT = 100001;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
// const int dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const double EPS = 1e-9;
int gcd(int a, int b){return b == 0 ? a : gcd(b, a % b);}
int lcm(int a, int b){return a / gcd(a, b) * b;}
int factorial(int a){return a < 2 ? 1 : factorial(a - 1) * a;}
int summation(int a){return a < 1 ? 0 : (a * a + a) / 2;}
int combination(int n, int r){int res = 1; rep(i, 1, r + 1) res *= n--, res /= i; return res;}
const str alphabet = "abcdefghijklmnopqrstuvwxyz";
int a, b, c, k, n, m, x, y, z, w, h;
str s, t;

signed main(){
    incant();
    while(cin >> a >> b >> c){
        int res = 0, cnt = 0, sum = 0, mx = -INF, mn = INF;
        bool flag = true;
        print(min(c, b / a));
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define P pair<int,int>
using namespace std;
 
P seg[2100000]{};
void kousin(int a){
    while(a){
	a=(a-1)/2;
	if(seg[a*2+2].first>seg[a*2+1].first)seg[a]=seg[a*2+2];
	else seg[a]=seg[a*2+1];
	}
    }
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
	int n=1;
	while(n<a)n<<=1;
	for(int c=n-1;c<n*2-1;c++)seg[c]=P(0,c-n+2);
	for(int d=0;d<b;d++){
	   int e,f;
	   scanf("%d%d",&e,&f);
	   seg[n+e-2].first+=f;
	   kousin(n+e-2);
	   printf("%d %d\n",seg[0].second,seg[0].first);
	    }
    }

Measured memory_bytes: 19632
#include <bits/stdc++.h>
using namespace std;
void dfs(int now, int parent, int d, vector<vector<int>> &children, vector<int> &distance) {
    distance.at(now) = d;
    for(int child : children.at(now)) {
        if(child == parent) continue;
        dfs(child, now, d+1, children, distance);
    }
}
int main() {
    int N;
    cin >> N;
    vector<vector<int>> children(N, vector<int>());
    for(int i = 0; i < N-1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        children.at(a).push_back(b);
        children.at(b).push_back(a);
    }
    
    vector<int> distanceF(N), distanceS(N);
    dfs(0, -1, 0, children, distanceF);
    dfs(N-1, -1, 0, children, distanceS);
    
    int F = 0, S = 0;
    for(int i = 0; i < N; i++) {
        if(distanceF.at(i)<=distanceS.at(i)) F++;
        else S++;
    }
    
    cout << (F>S ? "Fennec" : "Snuke") << endl;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) {
            par[i] = i;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        
        return par[x] = root(par[x]);
    }
    
    void merge(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        
        if (rx == ry) {
            return;
        }
        
        par[rx] = ry;
    }
    
    bool is_same(int x, int y) {
        return (root(x) == root(y));
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    vector<int> p(n);
    
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }
    
    UnionFind uf(n);
    int ans = 0;
    
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        uf.merge(x, y);
    }
    
    rep(i, n) {
        if (i == p[i]) {
            ans++;
        }
        else if (uf.is_same(i, p[i])) {
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int ans;
  long long K;
  string S;

  cin >> S;
  cin >> K;

  // for(int i = 0; i < S.length(); i++){
  //    cout << "S[" << i << "] = " << S[i] - '0' << endl;
  // }

  // vector<long long> a(10);
  // a[0] = 0;
  // a[1] = 1;
  // for(int i = 2; i < 10; i++){
  //    a[i] = log10((double) i) * 5.0 * pow(10.0, 15.0);
  //    cout << "a[" << i << "] = " << a[i] << endl;
  //    cout << log10((double) i) * 5.0 * pow(10.0, 15.0) << endl;
  // }

  // int Scnt = 0;
  // while( K > 0 ){
  //   // cout << "  S[" << Scnt << "] = " << S[Scnt] - '0' << endl;
  //   if(K > (a[S[Scnt] - '0'])){
  //     K -= a[S[Scnt] - '0'];
  //     Scnt++;
  //     // cout << "   if  " << K << endl;
  //   }else{
  //     ans = S[Scnt] - '0';
  //     // cout << "   else  " << K << endl;
  //     cout << ans << endl;
  //     return 0;
  //   }
  // } 

  // cout << S[Scnt] << endl;
  for(int i = 0; i < min((long long )S.length(), K ); i++){
    if((S[i] - '0') >= 2){
      cout << S[i] << endl;
      return 0;
    }
  }
  cout << '1' << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int c[2][4010][2010];
int p[2][2010];
int dp[2010][2010];
int main(){
    int n;cin>>n;
    vector<P> v(n*2+2);
    for(int i=1;i<=2*n;i++){
        char cc;cin>>cc>>v[i].second;
        if(cc=='B'){
            v[i].first=1;
        }else{
            v[i].first=0;
        }
        p[v[i].first][v[i].second]=i;
    }
    for(int i=1;i<=2*n;i++){
        for(int j=1;j<=n;j++){
            c[0][i][j]=c[0][i-1][j];
            c[1][i][j]=c[1][i-1][j];
            if(v[i].second<=j)c[v[i].first][i][j]++;
        }
    }
    for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)dp[i][j]=INF;
    dp[0][0]=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(i)dp[i][j]=min(dp[i][j],dp[i-1][j]+p[0][i]-c[0][p[0][i]][i-1]-c[1][p[0][i]][j]-1);
            if(j)dp[i][j]=min(dp[i][j],dp[i][j-1]+p[1][j]-c[0][p[1][j]][i]-c[1][p[1][j]][j-1]-1);
        }
    }
    cout<<dp[n][n]<<endl;
    return 0;
}


Measured memory_bytes: 78976
// Create your own template by modifying this file!
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cassert>
#include <deque>
#include <stack>
#include <functional>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x;  }
void _R(int &x) { scanf("%d", &x);  }
void _R(int64_t &x) { scanf("%lld", &x);  }
void _R(double &x) { scanf("%lf", &x);  }
void _R(char &x) { scanf(" %c", &x);  }
void _R(char *x) { scanf("%s", x);  }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...);  }
template<class T> void _W(const T &x) { cout << x;  }
void _W(const int &x) { printf("%d", x);  }
void _W(const int64_t &x) { printf("%lld", x);  }
void _W(const double &x) { printf("%.16f", x);  }
void _W(const char &x) { putchar(x);  }
void _W(const char *x) { printf("%s", x);  }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' ');  }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);  }
#ifdef DEBUG
 #define debug(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define debug(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;

void solve() {
    LL D, T, S;
    R(D, T, S);
    puts(D <= T * S ? "Yes" : "No");
}

int main() {
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}



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

typedef long long ll;

int N;
vector<int> A;

int main(void) {
	cin >> N;
	A.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i];

	ll ans = (ll)0;
	for (int i = 1; i <= N - 1; ++i) {
		if (A[i] < A[i - 1]) {
			ans += (ll)(A[i - 1] - A[i]);
			A[i] = A[i - 1];
		}
	}

	cout << ans << '\n';
	return 0;
}


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
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;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

ll n, m, k;

//根を求める
int root(int x, vector<int> &par)
{
    if(par[x]==x)return x;
    else return par[x]=root(par[x], par);
}

//xとyが同じ連結成分に含まれるかどうか
bool sameGroup(int x, int y, vector<int> &par)
{
    return root(x, par) == root(y, par);
}

//xとyの連結成分を併合
void unite(int x, int y, vector<int> &par, vector<int> &sizet)
{
    x=root(x,par);
    y=root(y,par);
    if(x==y)return;
    else if(x<y){par[y]=x;sizet[x]+=sizet[y];}
    else {par[x]=y;sizet[y]+=sizet[x];}
}

int main(){
    cin >> n >> m >> k;
    vector<int> uf(n+1);
    vector<int> sizet(n+1,1);
    FOR(i,1,n+1)uf[i]=i;
    vector<int> ans(n+1,-1);
    REP(i,m)
    {
        int a,b;
        cin >> a >> b;
        ans[a]--;
        ans[b]--;
        unite(a,b,uf, sizet);
    }
    REP(i,k)
    {
        int c,d;
        cin >> c >> d;
        if(sameGroup(c,d,uf))
        {
            ans[c]--;
            ans[d]--;
        }
    }
    FOR(i,1,n+1)ans[i]+=sizet[root(i,uf)];
    FOR(i,1,n+1)
    {
        cout << ans[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 2048
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 998244353;

//struct Robot
//{
//    int ID;
//    int X;
//    int L;
//
//    const bool operator<(const Robot &rhs) const
//    {
//        return X < rhs.X;
//    }
//};

int main()
{
    int N;
    cin >> N;
    multimap<int, int> leftToRightMap;
    for (int i = 0; i < N; ++i)
    {
        int Xi, Li;
        cin >> Xi >> Li;
        leftToRightMap.insert({ Xi - Li, Xi + Li });
    }
    int remNum = N;
    // itrが複数のnextと重なるとき，itrを消した方がよい場面に対応できない…
    for (auto itr = leftToRightMap.begin(); itr != leftToRightMap.end();)
    {
        auto next = itr;
        ++next;
        while (next != leftToRightMap.end())
        {
            if (itr->second > next->first)
            {
                --remNum;
                // itrがnextを包括するならば，大きい側のitrを消す
                if (itr->second >= next->second)
                {
                    break;
                }
                else
                {
                    ++next;
                }
            }
            else
            {
                break;
            }
        }
        itr = next;
    }
    cout << remNum << endl;

    //map<int, int> XtoLMap;
    ////vector<int> Xs(N), Ls(N);
    //for (int i = 0; i < N; ++i)
    //{
    //    //cin >> Xs[i] >> Ls[i];
    //    int Xi, Li;
    //    cin >> Xi >> Li;
    //    XtoLMap[Xi] = Li;
    //    //robots.insert({ i, Xi, Li });
    //}
    //int remNum = N;
    //for (auto itr = XtoLMap.begin(); itr != XtoLMap.end();)
    //{
    //    auto j = itr;
    //    ++j;
    //    for (; j != XtoLMap.end();)
    //    {
    //        if (itr->first + itr->second > j->first - j->second)
    //        {
    //            --remNum;
    //            j = XtoLMap.erase(j);
    //        }
    //        else
    //        {
    //        }
    //    }
    //}

    // 重複ペアを見つける
    //map<int, set<int>> adList;
    //for (auto itr = XtoLMap.begin(); itr != XtoLMap.end(); ++itr)
    //{
    //    auto j = itr;
    //    ++j;
    //    for (; j != XtoLMap.end(); ++j)
    //    {
    //        if (itr->first + itr->second > j->first - j->second)
    //        {
    //            adList[itr->first].insert(j->first);
    //            adList[j->first].insert(itr->first);
    //        }
    //    }
    //}
}


Measured memory_bytes: 4992
#include <fstream>
#include <sstream>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <functional>

using namespace std;

int main(void)
{
	int A,B;

	cin >> A >> B;

	int ans;

	ans = A + B;

	if (ans < A - B) { ans = A - B; }

	if (ans < A*B) { ans = A*B; }

	cout << ans<<endl;


	return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
ans = []
cou = 1
co = 0
 
def sossu(x):
  for i in range(2,math.ceil(math.sqrt(x))+1):
    if x % i == 0:
      return False
  return True
 
for i in range(n):
  while 1:
    cou += 1
    if sossu(5 * cou + 1):
      ans.append(str(5 * cou +1))
      break

      
print(" ".join(ans))

Measured memory_bytes: 3188
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
ll mod = 1000000007;
ll mod2 = 998244353;

int main(){
    int p,q,r;cin>>p>>q>>r;
    cout<<min({p+q,q+r,r+p})<<endl;
}

Measured memory_bytes: 256
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int A,B,K;
    vector<int> d;
    cin >> A >> B >> K;

    reprc(i, max(A,B) + 1, 0){
        if(A % i == 0 && B % i == 0){
            d.push_back(i);
        }
    }

    cout << d.at(K - 1) << endl;
}



Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents[i]: 要素iの親要素の番号
        # 要素iが根の場合、parents[i] = -(そのグループの要素数)
        self.parents = [-1] * n
    def find(self, x):
        if 0 > self.parents[x]:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    # 要素xが属するグループの要素数を返す
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    # 全ての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if 0 > x]
    # グループの数を返す
    def group_count(self):
        return len(self.roots())
    # 辞書{根の要素: [そのグループに含まれる要素のリスト], ...}を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    # print()での表示用
    # all_group_members()をprintする
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, Q = MAP()
tree = UnionFind(N)

for _ in range(Q):
	t, u, v = MAP()
	if t == 0:
		tree.union(u, v)
	else:
		if tree.same(u, v):
			print(1)
		else:
			print(0)


Measured memory_bytes: 12820
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=(1ll*ans*10+7)%n;
		if(ans==0){cout<<i<<endl;return 0;}
	}
	puts("-1");
}


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

using namespace std;

string S;
int main(void) {
	cin >> S;
	int ans = 0;

	int N = S.size();

	for (int i = 0; i < N / 2;i++) {
		if (S[i] != S[N - i - 1]) { ans++; }
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for a in range(0,A+1):
  for b in range(0,B+1):
    c = (X - 500 * a - 100 * b) // 50
    if 0 <= c and c <= C:
      cnt += 1
      
print(cnt)

Measured memory_bytes: 8964
#include<iostream>
using namespace std;
int main(){
  int b,r,g,c,s,t;
  int brg;//チャンスゲーム数
  int ct;//コインの使った数
  int cs;//コインを手にいれた数
  while(cin>>b>>r>>g>>c>>s>>t){
    if(b==0&&r==0&&g==0&&c==0&&s==0&&t==0) break;
    brg = b*5+r*3;
    ct = brg*2+(t-brg-s)*3;
    cs = b*15+r*15+c*2+brg*15+g*7;
    cout << 100+cs-ct << endl;
  }
  return 0;
}

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

int main()
{
    string s;
    cin >> s;
    vector<int> v(27, 0);
    for(int i = 0; i < s.size(); i++){
        v[s[i]-'a']++;
    }

    char ans = 'a';

    bool ex = true;

    for(int i = 0; i <= 26; i++){
        if(v[i] == 0 && i != 26){
            ans += i;
            break;
        }
        if(i == 26){
            ex = false;
        }
    }

    if(ex) cout << ans << endl;
    else cout << "None" << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int minn(int x,int y)
{
    return x<y?x:y;
}
int main()
{
    int p,q,r,a,b,c,ans;
    scanf("%d%d%d",&p,&q,&r);
    a=p+q;
    b=q+r;
    c=p+r;
    ans=minn(a,minn(b,c));
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 128
import Control.Applicative
import Control.Monad (unless)
import Data.Maybe
import qualified Data.Time as T

main = do
    list <- map read.words<$>getLine
    unless (any (<0) list) $ do
        let [y1,m1,d1,y2,m2,d2] = list
            day1 = T.fromGregorian (toInteger y1) m1 d1
            day2 = T.fromGregorian (toInteger y2) m2 d2
        print $ T.diffDays day2 day1
        main


Measured memory_bytes: 4096
import sys
sys.setrecursionlimit(100000)

def intinput(): return map(int,sys.stdin.readline().split())

n=int(input())
l=[list(intinput()) for i in range(n)]
l.sort(key=lambda x:x[1])
k=0
for i,j in l:
    k+=i
    if k>j:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 83244
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i,j;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  std::vector<PPI> vec(n);
  rep(i,n-1){
    cin>>vec[i].fi.fi>>vec[i].fi.se>>vec[i].se;
  }
  rep(i,n-1){
    ll ans = 0;
    repl(j,i,n-1){
      if(ans <= vec[j].fi.se){
        ans = vec[j].fi.se + vec[j].fi.fi;
      } else {
        ll cnt = ans - vec[j].fi.se;
        if(cnt % vec[j].se == 0) ans = vec[j].fi.se + vec[j].fi.fi + cnt;
        else ans = vec[j].fi.se + vec[j].fi.fi + vec[j].se * ((cnt  + vec[j].se)/ vec[j].se);
      }
    }
    cout<<ans<<endl;
  }
  cout<<0<<endl;
}

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


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

int main() {
  int n, K;
  cin >> n >> K;
  vector<int64_t> x(n), y(n), xs(n), ys(n);
  for (int i = 0; i < n; i++) {
    cin >> x.at(i) >> y.at(i);
  }
  xs = x;
  ys = y;
  sort(xs.begin(), xs.end());
  sort(ys.begin(), ys.end());
  int64_t ans = 5e18;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      int l = 0;
      for (int k = 0; k < n; k++) {
        for (l = max(l, k); l < n; l++) {
          int s = 0;
          for (int m = 0; m < n; m++) {
            if (xs.at(i) <= x.at(m) and x.at(m) <= xs.at(j)
                and ys.at(k) <= y.at(m) and y.at(m) <= ys.at(l)) {
              s++;
            }
          }
          if (s >= K) {
            ans = min(ans, (xs.at(j) - xs.at(i)) * (ys.at(l) - ys.at(k)));
            break;
          }
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    
    for n in range(6,0,-1):
        if N >= 10**(n-1):
            d=n
            break
    ans = 0
    while d > 0:
        if d%2:
            ans += N - 10**(d-1) + 1
        d -= 1
        N = 10**d - 1
    print(ans)

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc136","b",main)

Measured memory_bytes: 3060
n = int(input().strip())
h = list(map(int, input().split(" ")))

dp = [0] * n
dp[1] = abs(h[0] - h[1])

for i in range(2, n):
    dp[i] = min(abs(h[i]-h[i-1])+dp[i-1], abs(h[i]-h[i-2])+dp[i-2])

print(dp[n-1])

Measured memory_bytes: 13928
#include<stdio.h>
int main() {
  int data[200][3], data2[200] = {0}, n, i, k, j, flg;
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d %d %d", &data[i][0], &data[i][1], &data[i][2]);
  }
  for(i = 0; i < n; i++) {
    for(j = 0; j < 3; j++) {
      flg = 0;
      for(k = 0; k < n; k++) {
        if(i != k && data[i][j] == data[k][j]) {
          flg = 1;
        }
      }
      if(flg != 1) {
        data2[i] += data[i][j];
      }
    }
  }
  for(i = 0; i < n; i++) {
    printf("%d\n", data2[i]);
  }
  return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <cstdio>
using namespace std;
const int N = 3010;
const int mod = 1e9 + 7;
int n, m;
char s[N];
int f[N][N];
int mxr[N];
int add(int x, int y) {
    x+= y;
    return x >= mod ?x - mod : x;
}
int sub(int x, int y) {
    x -= y;
    return x < 0 ? x +mod : x;
}
int main() {
    scanf("%d %d", &n, &m);
    scanf("%s", s + 1);
    for (int i = 1; i <= n ; i++ )
        mxr[i] = i;
    for (int i = 1; i <= m; i ++) {
        int x, y;
        scanf("%d %d", &x, &y);
        mxr[x] = max(mxr[x], y);
    }
    f[0][0] = 1;
    for (int i = 0; i < n; i ++ ) {
        int ones = 0;
        mxr[i +1] = max(mxr[i+1], mxr[i]);
        if (mxr[i + 1] != mxr[i]) {
            for (int j = mxr[i]+ 1; j <= mxr[i + 1]; j ++)
                if (s[j] == '1')
                    ones ++;
        }
        int all = mxr[i + 1] - i;
        for (int j = 0; j <= n; j++)
            if (f[i][j]) {
                if (ones + j)
                    f[i + 1][ones + j -1] = add(f[i + 1][ones + j - 1], f[i][j]);
                if (ones + j != all)
                    f[i + 1][ones + j] = add(f[i + 1][ones + j], f[i][j]);
            }
    }
    printf("%d\n", f[n][0]);
    return 0;
}

Measured memory_bytes: 33792