akhauriyash/Code-Regression huggingface dataset:
n = int(input())
sl = list(input())
s2 = input()

c = []
before = sl[0]
for s in sl[1:]:
   if before == s:
      c.append(1)
      before = ""
   elif before != s and before != "":
      c.append(0)
      before = s
   else:
      before = s
if before != "":
   c.append(0)

if c[0] == 1:
   ans = 6
else:
   ans = 3
for i in range(len(c)-1):
   if c[i] == 1 and c[i+1] == 0:
      pass
   elif c[i] == 1 and c[i+1] == 1:
      ans *= 3
      ans %= 1000000007
   else:
      ans *= 2
      ans %= 10**9 + 7

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cstdlib>
#include <stack>

using namespace std;

class c_polish
{
private:

public:
    c_polish();
    void f_input();
};

c_polish::c_polish()
{
    
}

void c_polish::f_input()
{
    string s[200];
    long i;
    long data0;
    stack<long> data1;
    long data2;
    long temp1;
    long temp2;
    long temp3;
    
    for (i=0; cin >> s[i]; ++i){
        if (s[i] == "+"){
            temp1 = data1.top();
            data1.pop();
            temp2 = data1.top();
            data1.pop();
            temp3 = temp1 + temp2;
            data1.push(temp3);
        }else if (s[i] == "-"){
            temp1 = data1.top();
            data1.pop();
            temp2 = data1.top();
            data1.pop();
            temp3 = temp2 - temp1;
            data1.push(temp3);
        }else if (s[i] == "*"){
            temp1 = data1.top();
            data1.pop();
            temp2 = data1.top();
            data1.pop();
            temp3 = temp1 * temp2;
            data1.push(temp3);
        }else{
            data0 = atol(s[i].c_str());
            data1.push(data0);
        }
    }
    
    cout <<  temp3 << endl;
    
}

int main(){
    
    c_polish polish01;
    polish01.f_input();
    
    return 0;
}

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

int main(){
    int A[3][3];
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;
    int B[N];
    for (int i = 0; i < N; i++){
        cin >> B[i];
    }
    int C[3][3] = {
            {0, 0, 0},
            {0, 0, 0},
            {0, 0, 0}
    };
    int X = 0;
    for (int i = 0; i < N; i++){
        X = B[i];
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < 3; k++){
                if (A[j][k] == X) C[j][k] = 1;
            }
        }
    }
    if (C[0][0] == 1 && C[1][0] == 1 && C[2][0] == 1) cout << "Yes" << endl;
    else if (C[0][1] == 1 && C[1][1] == 1 && C[2][1] == 1) cout << "Yes" << endl;
    else if (C[0][2] == 1 && C[1][2] == 1 && C[2][2] == 1) cout << "Yes" << endl;
    else if (C[0][0] == 1 && C[0][1] == 1 && C[0][2] == 1) cout << "Yes" << endl;
    else if (C[1][0] == 1 && C[1][1] == 1 && C[1][2] == 1) cout << "Yes" << endl;
    else if (C[2][0] == 1 && C[2][1] == 1 && C[2][2] == 1) cout << "Yes" << endl;
    else if (C[0][0] == 1 && C[1][1] == 1 && C[2][2] == 1) cout << "Yes" << endl;
    else if (C[0][2] == 1 && C[1][1] == 1 && C[2][0] == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
fn main() {
    let scan = std::io::stdin();
    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();

    let mut n: Vec<i64> = Vec::new();

    for x in vec {
        n.push(x.parse().unwrap());
    }

    let mut cnt: i32 = 0;

    let mut tmp: i64 = n[0];
    while tmp <= n[1]{
        cnt += 1;
        tmp *= 2;
    }

    println!("{}", cnt);

}


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


int main() {
	
  string a,b,c;
  cin>>a>>b>>c;
  if(a[a.length()-1]==b[0] && b[b.length()-1]==c[0])
      printf("YES");
  
  else
     printf("NO");
      
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

map<char,ll> t;
int main(){
    string s;
    cin>>s;
    ll n=s.size();
    rep(i,n) ++t[s[i]];
    ll ans=n*(n-1)/2;
    for(auto it:t){
        ans-=it.second*(it.second-1)/2;
    }
    cout<<ans+1<<endl;
    return 0;
}

Measured memory_bytes: 640
N = int(input())
l = list(map(int, input().split()))

first_half = l[0]
second_half = sum(l[1:])
diff = abs(first_half - second_half)

for i in l[1:len(l)-1]:
    first_half += i
    second_half -= i
    if abs(first_half - second_half) < diff:
        diff = abs(first_half - second_half)

print(diff)

Measured memory_bytes: 24832
N = int(input())

def check_divisor(number):
	divisors = 0
	for j in range(1, number+1, 2):
		if not (number%j):
			divisors += 1
			if divisors == 9: return False
	if divisors == 8: return True
	else: return False

count = 0
for i in range(1, N+1, 2):
	if check_divisor(i):
		count += 1
print(count)

Measured memory_bytes: 9000
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll n,m,cnt,ans;
int main()
{
	int i,s,a,b,j,k;
	scanf("%lld%lld",&n,&m);
	for(i=m;i<=n;i++)
	{
		a=n-i;
		for(s=i+1;s<=a;s=j+1)j=a/(a/s),ans+=(j-s+1)*(a/s+1);
		ans+=n-s+1;
	}
	if(!m)ans-=n;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
n = len(s)
x = []
y = []

for i in range(n):
    if s[i] not in x:
        x.append(s[i])
    if t[i] not in y:
        y.append(t[i])

for i in range(len(x)):
    s = s.replace(x[i], str(i))
for i in range(len(y)):
    t = t.replace(y[i], str(i))
print('Yes' if s == t else 'No')

Measured memory_bytes: 9692
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int MOD=1000000007;
signed main(){
    string s;cin>>s;
    int n=(int)s.length();
    int flag=0;
    rep(i,n){
        if(s[i]=='C'&&flag==0)flag++;
        if(s[i]=='F'&&flag==1)flag++;
    }
    if(flag==2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

for x in range(N+1):
    for y in range(N+1):
        z = N - x - y
        if 0 <= z <= 2000 and 10000*x + 5000*y + 1000*z == Y:        
            print(x, y, z )
            exit()

print('-1 -1 -1')

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

int main()
{
	ios_base::sync_with_stdio(false);
	string s;
	cin>>s;	
	int i, l = s.length();
	int k;
	cin>>k;
	for(i = 0; i < l; i++)	
	if(s[i] != '1')
	break;
	if(k <= i)
	cout<<"1\n";
	else
	cout<<s[i]<<"\n";
	return 0;
}
	

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;



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

	vector< vector<int> >v(n+1,vector<int>(3,0));
	rep(i, 1, n+1) {
		cin >> v[i][0] >> v[i][1] >> v[i][2];
	}


	rep(i, 1, n+1) {
		int dx = v[i][1] - v[i - 1][1];
		int dy = v[i][2] - v[i - 1][2];
		int dt = v[i][0] - v[i - 1][0];
		if (abs(dx)+abs(dy)<=dt) {
			if (abs(dx+dy)%2 == dt%2) {
				continue;
			}
			else {
				cout << "No" << endl;
				exit(0);
			}
		}
		else {
			cout << "No" << endl;
			exit(0);
		}
	}

	cout << "Yes" << endl;




	return 0;

}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] s = new int[m];
        int[] c = new int[m];

        for (int i = 0; i < m; i++) {
            s[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        int max = (int) Math.pow(10, n);
        for (int i = 0; i < max; i++) {
            boolean ok = true;
            for (int j = 0; j < m; j++) {
                int a = 0;
                if (n - s[j] == 0) {
                    a = i % 10;
                }
                if (n - s[j] == 1) {
                    a = i / 10;
                    a %= 10;
                }
                if (n - s[j] == 2) {
                    a = i / 10;
                    a /= 10;
                    a %= 10;
                }
                if (a != c[j]) {
                    ok = false;
                }
//                System.out.println(a);
            }
            if (ok) {
                if (String.valueOf(i).length() == n) {
                    System.out.println(i);
                    return;
                }
            }
        }
        System.out.println(-1);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define N 110000
int n,tot,root;
int a[N],head[N],nex[N<<1],to[N<<1];
int du[N],rem[N];
void add(int x,int y)
{
	tot++;
	nex[tot]=head[x];head[x]=tot;
	to[tot]=y;
}
void quit(){puts("NO");exit(0);}
void dfs(int x,int y)
{
	if(du[x]==1)
	{
		rem[x]=a[x];
		return;
	}
	int mx=0,sum=0;
	for(int i=head[x];i;i=nex[i])
		if(to[i]!=y)
		{
			dfs(to[i],x);
			sum+=rem[to[i]];
			mx=max(mx,rem[to[i]]);
		}
	int v1=sum-a[x],v2=a[x]-v1;
	if(v1<0||v2<0)quit();
	if(sum-mx<v1)quit();
	rem[x]=v2;
}
int main()
{
	//freopen("tt.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1,x,y;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		add(x,y);add(y,x);
		du[x]++;du[y]++;
	}
	if(n==2)return puts(a[1]==a[2] ? "YES" : "NO"),0;
	root=1;
	while(du[root]==1)root++;
	dfs(root,0);
	if(rem[root])quit();
	puts("YES");
	return 0;
}


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

int main(){
  string S;
  cin >> S;
  long long K;
  cin >> K;
  int N_S = S.length();
  if(N_S == 1){
    if(K>1){
      cout << K/2;
      return 0;
    }
  }
  
  string test;
  for(int i=0; i<4; i++){
    test.append(S);
  }
  
  int N = test.length();
  int cnt_1=0;
  int cnt_2=0;
  int cnt_3=0;
  int cnt_4=0;
  
  for(int j=0; j<N-1; j++){
    if(test[j] == test[j+1]){
      if(j+1 < N_S){
        cnt_1++;
      }else if(N_S <= j+1 && j+1 < N_S*2){
        cnt_2++;
      }else if(N_S*2 <= j+1 && j+1 < N_S*3){
        cnt_3++;
      }else{
        cnt_4++;
      }
      test[j+1] = 'A';
    }
  }

  if(K==1){
    cout << cnt_1;
  }else if(K==2){
    cout << cnt_1 + cnt_2;
  }else if(cnt_2 == cnt_3){
    cout << cnt_1 + cnt_2*(K-1);
  }else if((K-1)%2==0){
    cout << cnt_1 + (cnt_2 + cnt_3)*(K/2);
  }else{
    cout << cnt_1 + (cnt_2 + cnt_3)*(K/2) + cnt_4;
  }
  
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}

use std::cmp::{max, min};

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let mut ans: Vec<i64> = vec![1, 2, 3];
    let ans_f: Vec<&i64> = ans.iter().filter(|&x| *x != a && *x != b).collect();

    println!("{}", ans_f[0]);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;
//const int MOD=998244353;

priority_queue<pint,vector<pint>,greater<pint>> pq[100000];

int main(){
	int n,m; cin>>n>>m;
	FOR(i,0,m){
		int p,y; cin>>p>>y;
		pq[p-1].push(pint(y,i));
	}
	pint id[100000];
	FOR(i,0,n){
		int t=0;
		while(!pq[i].empty()){
			pint pi=pq[i].top(); pq[i].pop();
			id[pi.SE]=pint(i+1,++t);
		}
	}
	FOR(i,0,m){
		int p=id[i].FI,y=id[i].SE;
		int k1=6,k2=6;
		while(p){
			p/=10;
			k1--;
		}
		while(y){
			y/=10;
			k2--;
		}
		FOR(j,0,k1){
			cout<<"0";
		}
		cout<<id[i].FI;
		FOR(j,0,k2){
			cout<<"0";
		}
		cout<<id[i].SE<<endl;
		//cout<<id[i].FI<<" "<<id[i].SE<<endl;
	}
}


Measured memory_bytes: 8576
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
    int a, b, k;
    cin >> a >> b >> k;

    for (int i = a; i <= min(a + k - 1, b); i++) {
        cout << i << endl;
    }

    for (int i = max(a + k, b - k + 1); i <= b; i++) {
        cout << i << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=20;
pair<int,int> a[N][N];
int n,S,m[N],ans;

void solve(){
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>m[i];
        for(int j=0;j<m[i];++j)
            cin>>a[i][j].first>>a[i][j].second,a[i][j].first--;
    }
    S=1<<n;
    for(int i=0;i<S;++i){
        for(int j=0;j<n;++j)
            if((i>>j)&1){
                for(int k=0;k<m[j];++k)
                    if(((i>>a[j][k].first)&1)!=a[j][k].second)goto G;
            }
        ans=max(ans,__builtin_popcount(i));
        G:;
    }
    printf("%d\n",ans);
}
int main(){
    solve();

    return 0;
}

Measured memory_bytes: 256
<?php


class Solver{
    private $x;
    private $nums;
    
    private $plus = null;
    private $minus = null;

    function __construct($x,$nums){
        $this->x = $x;
        $this->nums = $nums;
        
        $this->plus = $x; //$x自体をみるためにプラス１しないでスタート
        $this->minus = $x-1;
        
    }
    
    function solve(){
        if($this->check_plus()){
            echo $this->plus;
            exit;
        }
        if($this->check_minus()){
            echo $this->minus;
            exit;
        }
        
        $this->solve();
    }
    
    function check_minus(){
        if(in_array($this->minus,$this->nums)){
            $this->minus --;
            return false;
        }
        return true;
    }
    
    function check_plus(){
        if(in_array($this->plus,$this->nums)){
            $this->plus ++;
            return false;
        }
        return true;
    }
    
}

list($x,$length) = explode(' ',trim(fgets(STDIN)));
$nums = explode(' ',trim(fgets(STDIN)));

if($length == 0){
    echo $x;
    exit;
}

(new Solver($x,$nums))->solve();


?>


Measured memory_bytes: 16128
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include <stack>
#include<set>
#include<cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <string.h>
#include<iterator>
#include <map>
using namespace std;
// bool cmp(long long a, long long b){
//     return a > b;
// }
int used[205000];
set<long long> sets[205000];
queue<long long> q;
int n;
int a[100500];
int tree[405004];
long long u = 0, d = 0, r = 0, l = 0;
void build_tree(int v, int tl, int tr) {
    if (tl == tr) {
        tree[v] = a[tl];
    } else {
        int tm = (tl + tr) / 2;
        build_tree(v * 2, tl, tm);
        build_tree(v * 2 + 1, tm + 1, tr);
        tree[v] = tree[v * 2] + tree[v * 2 + 1];
    }
}
int get_sum(int l, int r, int v, int tl, int tr) {
    //вариант 1
    if (l <= tl && tr <= r) {
        return tree[v];
    }
    if (tr < l || r < tl) {
        return 0;
    }
    int tm = (tl + tr) / 2;
    return get_sum(l, r, v * 2,     tl,     tm)
           + get_sum(l, r, v * 2 + 1, tm + 1, tr);
}
void update(int idx, int val, int v, int tl, int tr) {
    //вариант 1
    if (idx <= tl && tr <= idx) {    //То же, что и idx == tl == tr
        a[idx] = val;
        tree[v] = val;
        return;
    }
    if (tr < idx || idx < tl) {
        return;
    }
    int tm = (tl + tr) / 2;
    update(idx, val, v * 2,     tl,     tm);
    update(idx, val, v * 2 + 1, tm + 1, tr);
    tree[v] = (tree[v * 2] + tree[v * 2 + 1]) % (long long)(1e9 + 7);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    long long t, ch, i, curr, p = 1, x, y, weight, j, k = 0, n, m = 1, ch1, count, ans = 0;
   // long long a, b;
    int fl, fl1, fl2, fl3;
    string s;
//    cin >> t;
    long long c, e, f;
    long long time;
//    for (auto test_case = 0; test_case < t; test_case++) {
        cin >> s;
        ans = 0;
        for (i = 0; i < s.length(); i++)
            ans += int(s[i] - '0');
        if (ans % 9 == 0)
            cout << "Yes";
        else
            cout << "No";
//    }

    return 0;
}
/*2
5
1 1 1 1 1
1
10
 1
 7
5 6 6 1 3 5 4

 */

Measured memory_bytes: 13400
#include <cstdio>
#include <algorithm>
using std::max;
const int maxn = 100003;
int d[maxn][3],a[maxn][3];
int main() {
	int i,n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
	scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
    }
    d[0][0] = a[0][0];
	d[0][1] = a[0][1];
	d[0][2] = a[0][2];
	for(int i = 1; i < n; i++) {
		d[i][0] = a[i][0] + max(d[i-1][1],d[i-1][2]);
		d[i][1] = a[i][1] + max(d[i-1][0],d[i-1][2]);
		d[i][2] = a[i][2] + max(d[i-1][1],d[i-1][0]);
	}
	printf("%d\n",max(d[n-1][0],max(d[n-1][1],d[n-1][2])));
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	int dp[n];
	dp[0] = 0, dp[1] = abs(a[0] - a[1]);
	for(int i = 2; i < n; i++){
		dp[i] = min(dp[i-1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i - 2] - a[i]));
	}
	cout << dp[n - 1] << "\n";
	return 0;
}

Measured memory_bytes: 4412
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<Int, P> T;
#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))


Int n, k, a[54][54];
Int dp[208][54][54];

Int solve(Int k, Int x, Int y, Int pos = 200){
  Int &res = dp[pos][x][y];
  if(res != -1)return res;
  res = 0;
  if(k == 1){
    return res = a[x][y];
  }
  if(k % 2 == 0){
    for(int i = 0;i < n;i++)
      res = (res + solve(k/2, x, i, pos-1) * solve(k / 2, i, y, pos-1) % MOD) % MOD;
  }
  else{
    for(int i = 0;i < n;i++)
      res = (res + solve(k-1, x, i, pos-1) * solve(1, i, y, 0  ) % MOD) % MOD;
  
  }
  return res;
}

int main(){
  cin >> n >> k;
  for(int i = 0;i < n;i++)
    for(int j = 0;j < n;j++){
      cin >> a[i][j];
      for(int pos = 0;pos < 208;pos++)
	dp[pos][i][j] = -1;
    }
  
  
  Int res = 0;
  for(int i = 0;i < n;i++)
    for(int j = 0;j < n;j++)
      res = (res + solve(k, i, j)) % MOD;

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4992
# 末尾の0の数 =　n!は5で何回割れるか?
until (num = gets.chomp.to_i) == 0
  cnt = 0
  for i in 1..num do
    while (i % 5) == 0
      cnt = cnt + 1
      i = i / 5
    end
  end
  puts cnt
end

Measured memory_bytes: 8488
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b + 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int t[128];
int get(int a, int n){
	a --;
	int c = 0;
	for(int i = 2; i<= n; i++)
		if(t[i] >= a)
			c++;
	return c;
}
int main(){
	int n;
	cin >> n;
	for(int i = 2; i <= n; i++){
		int cur = i;
		for(int j = 2; j <= i; j++){
			while(cur % j == 0){
				t[j] ++;
				cur /= j;
			}
		}
	}
	int ans = 0;
	ans = get(75, n) + get(25, n) * (get(3, n) - 1) + get(15, n) * (get(5, n) - 1) + get(5, n) * (get(5, n) - 1) * (get(3, n) - 2) / 2;
	cout << ans;
}

Measured memory_bytes: 256
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def digits(n):
    count = 1
    while n > 9:
        n //= 10
        count += 1
    return count


def solve():
    N = read_int()
    low, high = 0, 10**5+1
    while high-low > 1:
        mid = low+(high-low)//2
        if mid*mid > N:
            high = mid
        else:
            low = mid
    min_f = math.inf
    for i in range(1, low+1):
        if N%i == 0:
            min_f = min(min_f, max(digits(i), digits(N//i)))
    return min_f


if __name__ == '__main__':
    print(solve())


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll h, w;
	vector<string> v, red, blue;

	cin >> h >> w;

	REP(i, h) {
		string s;
		cin >> s;
		v.push_back(s);
	}

	string sw = "";
	string sp = "";

	REP(i, w - 1) {
		sw += "#";
		sp += ".";
	}

	REP(i, h) {
		if (i % 2 == 0) {
			red.push_back(sw + ".");
			blue.push_back(sp + "#");
		}
		else {
			red.push_back("#" + sp);
			blue.push_back("." + sw);
		}
	}

	REP(i, h) {
		REP(j, w) {
			if (v[i][j] == '#') {
				red[i][j] = '#';
				blue[i][j] = '#';
			}
		}
	}

	REP(i, h) {
		cout << red[i] << endl;
	}

	cout << endl;

	REP(i, h) {
		cout << blue[i] << endl;
	}
}

Measured memory_bytes: 1664
// Shinchan Loves Coding :)))
#include<bits/stdc++.h>
#include<map>
#include<set>
#include<stack>
using namespace std;

#define night_rider ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define double long double
#define en "\n"
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define toUpper(x) transform(x.begin(), x.end(), x.begin(),::toupper);
#define toLower(x) transform(x.begin(), x.end(), x.begin(),::tolower);
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> pii;
bool secdes(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi>b.fi;}else{return a.se>b.se;}}//second descending !
bool sir(const pair<int,int>&a , const pair<int,int>&b){if(a.fi==b.fi){return a.se>b.se;}else{return a.first>b.first;}}//first descending !
bool bysec(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi<b.fi;} else{return a.se<b.se;}}//second ascending !

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/

const int no=3e6+5;
const int modulo=1e9+7;
const int inf=1e18+9;
const int N=1001;
int a[no]={},b[no]={},cc[no]={},suma[no]={},mat[N][N]={{0}};
stack<int> S;
stack<int> ma;

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/

int poww(int x, int y, int modulo) { int res=1;while(y) { if(y%2!=0) { res*=x;res%=modulo;y--; } else { x*=x;x%=modulo;y/=2; } } return res; }  //MODULAR EXPONENTIATION
bool comp(int a, int b) {
    return (a < b);   // MAXIMUM
    return (a > b);   // MINIMUM
}

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/

vi adj[no],prime;
int used[no]={},q=1,t=1;
int dist[no]={},c_comp[no]={},siz;

void dfs(int node,int d) {
    used[node]=1;
    dist[d]+=1;
    for(int v : adj[node]) {
        if(!used[v]) {
            dfs(v,d+1);
        }
    }
}

/**/
void solve (){
    int n,x,m;
    cin>>n;
    for(int i=0 ; i<n ; i++) cin>>a[i];
    int maxi=-1,ans=0;
    for(int i=0 ; i<n ; i++) {
        maxi=max(maxi,a[i]);
        ans+=(maxi-a[i]);
    }
    cout<<ans<<en;
}

void runn(){
        #ifndef ONLINE JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif
    }

signed main()
{
    night_rider
    //runn();
    t=1;
    //cin>>t;
    q=t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 75452
#import <stdio.h>
int main() {
	char c[4];
	scanf("%c%c%c%c",c,c+1,c+2,c+3);
	int ans=0;
	for(int i=0;i<4;i++){
		if(c[i]=='2') ans++;
	}
	printf("%d\n",ans);
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

template<typename T>
struct Bit2D {
  int h, w; // 2のべき乗でなくてもOK
  vector<vector<T>> node;
  Bit2D(int h, int w) : h(h), w(w), node(h + 1, vector<T>(w + 1, 0)) {}
  void add(int y, int x, T z) { // node[y][x] += w
    ++y, ++x;
    for (int j = y; j <= h; j += j & -j)
      for (int i = x; i <= w; i += i & -i) node[j][i] += z;
  }
  T sum(int y, int x) { // return sum [0, 0] x (y, x)
    T ans = 0;
    for (int j = y; j > 0; j -= j & -j)
      for (int i = x; i > 0; i -= i & -i) ans += node[j][i];
    return ans;
  }
  T sum(int y1, int x1, int y2, int x2) { // return sum [y1, x1] x (y2, x2)
    return sum(y2, x2) - sum(y1, x2) - sum(y2, x1) + sum(y1, x1);
  }
};

void solve() {
  int n, m, q;
  cin >> n >> m >> q;
  Bit2D<int> bit(n, n);
  rep(i, m) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    bit.add(l, r, 1);
  }
  rep(i, q) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    int sum = bit.sum(l, l, r + 1, r + 1);
    cout << sum << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int K = scan.nextInt();
  long A[]=new long[N];
  for(int i=0;i<N;i++){A[i]=scan.nextLong();}

  for (int i=K;i<N;i++){
      if (A[i-K]<A[i]){System.out.println("Yes");}
      else{System.out.println("No");}

  }

}
    }


Measured memory_bytes: 72796
import sys
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def factorize_dict(n):
    b = 2
    fct = defaultdict(lambda: 0)
    while b ** 2 <= n:
        while n % b == 0:
            n //= b
            fct[b] += 1
        b += 1
    if n > 1:
        fct[n] += 1
    return fct


def main():

    N = in_n()

    if N == 1:
        print(0)
        exit()

    prime = defaultdict(int)
    for i in range(1, N + 1):
        for k, v in factorize_dict(i).items():
            prime[k] += v

    n2, n4, n14, n24, n74 = 0, 0, 0, 0, 0
    for k, v in prime.items():
        if v >= 2:
            n2 += 1
        if v >= 4:
            n4 += 1
        if v >= 14:
            n14 += 1
        if v >= 24:
            n24 += 1
        if v >= 74:
            n74 += 1

    ans = n74
    if n24 >= 1:
        ans += n24 * (n2 - 1)
    if n14 >= 1:
        ans += n14 * (n4 - 1)
    if n4 >= 2:
        ans += n4 * (n4 - 1) // 2 * (n2 - 2)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9492
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define endl  '\n'
using namespace std;
const int mod=1e9+7;
const int MAX=1e6+7;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0), cout.tie(0);
   	int sum=15,x;
   	for(int i=0;i<5;i++)
   	{
   		cin>>x;
   		sum-=x;
	}
	cout<<sum;
    return 0 ;
}


Measured memory_bytes: 3608
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
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; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
ll GetDigit(ll num){ 
    ll digit=0; 
    while(num!=0){num/=10;digit++;} 
    return digit; 
} 


using namespace std;
//-------------------------------------------
int main(){
  ll X,Y,A,B,C;cin>>X>>Y>>A>>B>>C;
  vi p(A),q(B),r(C);
  REP(i,A)cin>>p[i];
  REP(i,B)cin>>q[i];
  REP(i,C)cin>>r[i];
  
  sort(ALLv(p),greater<ll>());
  sort(ALLv(q),greater<ll>());
  sort(ALLv(r),greater<ll>());
  
  vi s;
  REP(i,X)s.push_back(p[i]);
  REP(i,Y)s.push_back(q[i]);
  REP(i,min(C,X+Y))s.push_back(r[i]);
  
  sort(ALLv(s),greater<ll>());
  
  ll ans=0;
  REP(i,X+Y){
    ans+=s[i];
  }
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 8432
N,K=map(int,input().split())
arr=[]
for i in range(N):
    a,b=map(int,input().split())
    arr.append([a,b])
arr.sort()
x=0
for i in range(N):
    x+=arr[i][1]
    if x>=K:
        print(arr[i][0])
        break

Measured memory_bytes: 20104
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
ll INF = 1000000000000000001; //10^18+1
ll MOD = 1000000007; //10^9+7
//cout << fixed << setprecision(15); (小数点以下表示)


int main() {
  ll H,W,K,ans,cnt,score,ma=0,mab;
  char ch;
  bool a;
  cin >> H >> W >> K;
  ans=H+W-2;
  ll S[H][W],c[H],b[H];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> ch;
      S[i][j]=ch-'0';
    }
  }
  for(int T=0;(T>>(H-1))==0;T++){
    ll c[H]={};
    ll b[H]={};
    ma=0;
    score=__builtin_popcount(T);
    for(int i=0;i<W;i++){
      cnt=0;
      ma=0;
      ll b[H]={};
      for(int j=0;j<H-1;j++){
        b[cnt]+=S[j][i];
        c[cnt]+=S[j][i];
        ma=max(ma,c[cnt]);
        if((T>>j)&1) cnt++;
      }
      b[cnt]+=S[H-1][i];
      c[cnt]+=S[H-1][i];
      ma=max(ma,c[cnt]);
      if(ma>K){
        if(i>0){
          score++;
          ma=0;
          for(int j=0;j<H;j++){
            c[j]=b[j];
            ma=max(ma,c[j]);
          }
        }else{
          score=INF;
          break;
        }
      }
    }
    ans=min(ans,score);
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
lol abs(lol x,lol y){return(x>y?x-y:y-x);}
lol max(lol x,lol y){if(x>y)return x;return y;}
lol min(lol x,lol y){if(x<y)return x;return y;}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin >>n>>k;
  int a[100001];
  int pos;
  for(int i=0;i<n;i++){
    cin >>a[i];
    if(a[i]==1) pos=i;
  }
  int ans=0;
  n--,k--;
  ans=n/k;
  if(n%k!=0) ans++;
  cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define INF 2e9
#define IMAX 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long llong;

int main() // 140-A
{
	int i;
	cin >> i;

	cout << i*i*i << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n;
  cin>>n;
  string s;
  cin>>s;
  long long count=1;
  for(int i=1;i<n;i++)
  {
    if(s[i]!=s[i-1])
        count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
signed main(){
int a,b;
  cin>>a>>b;
  if(a==1 && b==2 || a==2 && b==1){
    cout<<"3\n";
  }else if(a==2 && b==3 || a==3 && b==2){
cout<<"1\n";
  }else if(a==3 && b==1 || a==1 && b==3){
cout<<"2\n";
  }
  return(0);
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static int MOD = 1000000007;
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var sL = s.Length;
        var dp = new long  [sL + 1, 4];
        dp[0, 0] = 1;
        for (int i = 0; i < sL; i++)
        {
            if (s[i] == 'A' | s[i] == '?')
            {
                for (int j = 0; j < 4; j++)
                {
                    dp[i + 1, j] += dp[i, j];
                    dp[i + 1, j] %= MOD;
                }
                dp[i + 1, 1] += dp[i, 0];
                dp[i + 1, 1] %= MOD;
            }
            if (s[i] == 'B' | s[i] == '?')
            {
                for (int j = 0; j < 4; j++)
                {
                    dp[i + 1, j] += dp[i, j];
                    dp[i + 1, j] %= MOD;
                }
                dp[i + 1, 2] += dp[i, 1];
                dp[i + 1, 2] %= MOD;
            }
            if (s[i] == 'C' | s[i] == '?')
            {
                for (int j = 0; j < 4; j++)
                {
                    dp[i + 1, j] += dp[i, j];
                    dp[i + 1, j] %= MOD;
                }
                dp[i + 1, 3] += dp[i, 2];
                dp[i + 1, 3] %= MOD;
            }
        }
        Console.WriteLine(dp[sL,3]);
    }
}

Measured memory_bytes: 14432
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
const int MAXN = 1e5+7;
typedef pair<int,int> pii;
vector<pii> G[MAXN];
int n,col[MAXN];
void dfs(int u, int fa, int tocol){
    int cnt = G[u].size()-(fa!=0);
    stack<int> stk;
    for(int i = 1; cnt; i++){
        if(i!=tocol){
            stk.push(i);
            cnt--;
        }
    }
    for(auto p : G[u]){
        int v = p.first;
        if(v==fa) continue;
        col[p.second] = stk.top();
        stk.pop();
        dfs(v,u,col[p.second]);
    }
}
int main(){
    ____();
    cin >> n;
    for(int i = 1; i < n; i++){
        int u,v;
        cin >> u >> v;
        G[u].push_back(make_pair(v,i));
        G[v].push_back(make_pair(u,i));
    }
    dfs(1,0,0);
    cout << *max_element(col+1,col+n) << endl;
    for(int i = 1; i < n; i++) cout << col[i] << endl;
    return 0;
}

Measured memory_bytes: 54016
n = int(input())

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

q = int(input())

m = dict(zip(range(q), list(map(int, input().split()))))

ans = ["no"] * q

for i in range(2**n):
    now = 0
    for j in range(n):
        if i >> j & 1:
            now += a[j]

    if now in m.values():
        key_lst = [key for key, value in m.items() if value==now]
        for key in key_lst:
            ans[key] = "yes"

for i in range(q):
    print(ans[i])



Measured memory_bytes: 5636
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    m1, d1 = LI()
    m2, d2 = LI()
    if m1 != m2:
        print("1")
    else:
        print("0")
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

int n;
string s;

void solve(){
	cin>>n;
	cin>>s;
	map<int,char> huh;
	huh[0] = 'S';
	huh[1] = 'W';

	for(int i=0;i<=1;i++){
		for(int j=0;j<=1;j++){
			string ans;
			ans += huh[i];
			ans += huh[j];
			int pprev = i;
			char pprevc = s[0];
			int prev = j;
			char prevc = s[1];

			for(int p=2;p<n+2;p++){
				int k = p%n;
				int my;
				char myc = s[k];
				if(prev == 0){
					if(prevc == 'o'){
						my = pprev;
					}
					else{
						my = 1-pprev;
					}
				}
				if(prev == 1){
					if(prevc == 'o'){
						my = 1-pprev;
					}
					else{
						my = pprev;
					}
				}
				
				if(k == 0){
					// cout<<my<<" "<<i<<endl;
					if(my != i) break;
					else{
						pprev = prev;
						pprevc = prevc;
						prev = my;
						prevc = myc;
					}
				}
				else if(k == 1){
					// cout<<my<<" "<<j<<endl;
					if(my != j) break;
					else{
						cout<<ans<<endl;
						return;
					}
				}
				else{
					pprev = prev;
					pprevc = prevc;
					prev = my;
					prevc = myc;
					
					ans += huh[my];
				}
			}
		}
	}

	cout<<-1<<endl;
}

int main(){
	fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


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

  int A,B,C;
  cin >> A >> B >> C;
  int counter = 0;
  double ans = A ;
  while( ans <= C ){
  ans += A ;
  counter += B;
 }
cout << counter << endl;
}

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

using namespace std;

int main()
{
    #define ll long long
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string arr[7]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string x;
    cin>>x;
    int cnt=0,ans;
    for(int i=0;i<7;i++)
        {
            if(x==arr[i]){ans=i;break;}
        }


       cout<<7-ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio   ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll        long long
#define yes       printf("YES\n")
#define no        printf("NO\n")
#define pb        push_back
#define srtd(x)   sort(x.begin(),x.end())
#define rvsd(x)   reverse(x.begin(),x.end())
#define scn(n)    scanf("%lld",&n)
#define scab(a,b) scanf("%lld %lld",&a,&b)
#define pn(n)     printf("%lld\n",n)
#define pab(a,b)  printf("%lld %lld",a,b)
#define nl        cout<<endl
#define MAX       1000011
#define PI        acos(-1.0)
#define mmst(a,b) memset(a,b,sizeof(a));
#define FOR(i,n)  for(ll i=1;i<=n;i++)
#define LOP(i,n)  for(ll i=0;i<n;i++)
//Emama_ Nahid//
using namespace std;

int main()
{
    fastio;
    ll n,m,i,j,k,t,r,p;
    cin>>t;
    n=t/1000;
    if(t%1000>0)
        n++;
    n=n*1000;
    m=n-t;
    cout<<m<<endl;



    return 0;
}













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

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

Measured memory_bytes: 3856
import math
X = int(input())
res = 0
for b in range(1, int(math.sqrt(X))+1): # sqrt(X)付近まで探索
    for p in range(2, int(math.sqrt(X))+2): # sqrt(X)付近まで探索
        val = b**p
        if (val <= X) and (val > res): # X以下かつその値が最大値なら値を更新
            res = val
print(res)

Measured memory_bytes: 3060
#include <stdio.h>
int main(){
	int n,c[4]={};
  	char s[4];
  	char a[4][4]={"AC","WA","TLE","RE"};
  
  	scanf("%d",&n);
  	for(int i=0;i<n;i++){
    	scanf("%s",s);
      	if(s[0]=='A')
          	c[0]+=1;
      	else if(s[0]=='W')
          	c[1]+=1;
      	else if(s[0]=='T')
          	c[2]+=1;
      	else
          	c[3]+=1;
    }
  	for(int i=0;i<4;i++)
      printf("%s x %d\n",a[i],c[i]);
}

Measured memory_bytes: 2140
#include <iostream>
#define MAX 50000

using namespace std;

bool is_prime[MAX];

void tenes(void){

  for( int i = 0 ; i < MAX ; i++ ){
    is_prime[i] = true; 
  }
  is_prime[0] = is_prime[1] = false;

  for( int i = 2 ; i*i < MAX ; i++ ){
    if( is_prime[i] ){
      for( int j = i + i ; j < MAX ; j += i ){
	is_prime[j] = false;
      }
    }
  } 
}

int main(void){
  
  tenes();
  
  int n;
  while( cin >> n ){
    if( n == 0 )break;
    
    int cnt = 0;
    for( int i = 2 ; i <= n/2 ; i++ ){
      if( is_prime[i] && is_prime[n-i] ){
	cnt++;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
import java.util.*;

import java.io.*;
public class Main {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;
       public static long knapSack(int W,  int n,object[]objects) { 
		 
	long K[][] = new long[n+1][W+1];
	for (int i = 0; i <= n; i++) {
	 
		for (int w = 0; w <= W; w++) { 
			if (i==0 || w==0) 
				K[i][w] = 0; 
			else if (objects[i-1].weight <= w) 
				K[i][w] = Math.max(objects[i-1].value + K[i-1][w-objects[i-1].weight], K[i-1][w]); 
			else
				K[i][w] = K[i-1][w]; 
		} 
	} 
	
	return K[n][W]; 
	} 
	public static void main(String[] args) throws IOException{
       int n = readInt(), h[] = new int[n+1],dp[] = new int[n+1];
       for(int i=1;i<=n;i++)h[i]=readInt();
       dp[2] = Math.abs(h[2]-h[1]);
       for(int i=3;i<=n;i++)dp[i]= Math.min(Math.abs(h[i]-h[i-1])+dp[i-1], dp[i-2]+ Math.abs(h[i]-h[i-2]));
       System.out.println(dp[n]);
       
        }
	static String next () throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine().trim());
		return st.nextToken();
	}
	static long readLong () throws IOException {
		return Long.parseLong(next());
	}
	static int readInt () throws IOException {
		return Integer.parseInt(next());
	}
	static double readDouble () throws IOException {
		return Double.parseDouble(next());
	}
	static char readCharacter () throws IOException {
		return next().charAt(0);
	}
	static String readLine () throws IOException {
		return br.readLine().trim();
	}static class object{
        int weight; long value;
        object(int s, long d){ weight = s; value = d;}
    }
}

Measured memory_bytes: 33600
# Date [ 2020-08-29 21:30:11 ]
# Problem [ d.py ]
# Author Koki_tkg

import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            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
 
    def size(self, x):
        return -self.parents[self.find(x)]

def Main():
    n, m = read_ints()
    
    uf = UnionFind(n)
    for _ in range(m):
        a, b = read_ints()
        a -= 1; b -= 1
        uf.union(a, b)
    
    ans = 0
    for i in range(n):
        ans=max(ans,uf.size(i))
    
    print(ans)

if __name__ == '__main__':
    Main()

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

using namespace std;

const int N = 300000 + 5;

int n, cnt[N], sum[N], tcnt[N];

inline int check (int l, int k)
{
	return ( (cnt[n] - cnt[k]) * k + sum[k] ) >=  l * k;
}

int main ()
{
	scanf ("%d", &n);
	for (int i = 1; i <= n; ++i)
	{
		int x; scanf ("%d", &x);
		tcnt[x]++;
	}
	for (int i = 1; i <= n; ++i) sum[ tcnt[i] ] += tcnt[i], cnt[ tcnt[i] ] ++;
	for (int i = 1; i <= n + 1; ++i) cnt[i] += cnt[i - 1], sum[i] += sum[i - 1];
	int now = n + 1;
	for (int i = 1; i <= n; ++i)//bottom length
	{
		while (now && !check(i, now)) now--;
		printf ("%d\n", now);
	}
	return 0;
}




































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

int main(){
    int r, d, x;
    cin >> r >> d >>x;
    rep(i, 10){
        x = r * x - d;
        cout << x <<endl;
    }
    return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  int count = 0;
  rep(i,10) {
    rep(j,10){
      rep(k,10){
        int x = 10001*i+1010*j+100*k;
        if(x >= a && x <= b) ++count;
      }
    }
  }
  cout << count << endl;
  return 0;
}

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

vector<vector<int>> graph;
int DFS(int s, int t, int v, int previous_v){
    if(v == t) return 1;
    if(v == s) return 0;

    int flag = 0;
    for(int next_v : graph[v]){
        if(next_v == previous_v) continue;
        flag |= DFS(s, t, next_v, v);
    }
    return flag;
}

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

    graph.resize(n);
    vector<int> degree(n);
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;

        graph[a].push_back(b);
        graph[b].push_back(a);
        degree[a] += 1;
        degree[b] += 1;
    }

    vector<int> degree4;
    int degree6 = 0;
    for(int i=0; i<n; i++){
        if(degree[i] % 2 != 0){ cout << "No"  << endl; return 0; }
        if(degree[i] >= 6) degree6 += 1;
        if(degree[i] == 4) degree4.push_back(i);
    }

    if(degree6 >= 1){ cout << "Yes" << endl; return 0; }
    if((int)degree4.size() <= 1){ cout << "No"  << endl; return 0; }
    if((int)degree4.size() >= 3){ cout << "Yes" << endl; return 0; }
    
    // if((int)degree4.size() == 2)
    int s = degree4[0];
    int t = degree4[1];
    int count = 0;
    for(int i=0; i<4; i++){
        count += DFS(s, t, graph[s][i], s);
    }
    if(count == 4) cout << "No"  << endl;
    if(count != 4) cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 11096