akhauriyash/Code-Regression huggingface dataset:
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
using namespace std;
int fa[5];
int find(int x)
{
	while(fa[x])	x=fa[x];
	return x;
}
void merge(int x,int y)
{
	x=find(x),y=find(y);
	if(x!=y)	fa[x]=y;
}
int a[4],b[4],d[5];
int main()
{
	for(int i=1;i<=3;i++)
		scanf("%d%d",&a[i],&b[i]),merge(a[i],b[i]),d[a[i]]++,d[b[i]]++;
	int i,cnt=0;
	for(int i=1;i<=4;i++)
		if(d[i]==1) cnt++;
	if(cnt==2)	printf("YES\n");
	else	printf("NO\n");
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力
            var input = Console.ReadLine().Split(' ');
            var hp = int.Parse(input[0]);
            var count = int.Parse(input[1]);

            input = Console.ReadLine().Split(' ');
            var intArray = Array.ConvertAll<string,int>(input,delegate(string value){return int.Parse(value);});
            // 出力
            if(hp <= intArray.Sum()){
                Console.WriteLine("Yes");
            }else{
                Console.WriteLine("No");
            }
            
        }
    }
}

Measured memory_bytes: 16992
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int N;
    cin >> N;

    vector<int> a(N);
    for(int i = 0; i < N; i++)
    {
        cin >> a.at(i);
    }

    //aを降順にソート
    sort(a.begin(), a.end(), greater<int>());

    int Alice = 0;
    int Bob = 0;

    for(int i = 0; i < N; i++)
    {
        if( i % 2 == 0 )
        {
            Alice += a.at(i);
        }
        else
        {
            Bob += a.at(i);
        }
    }

    cout << (Alice - Bob);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] L = new int[N];
        for(int i = 0; i < N; i++){
            L[i] = sc.nextInt();
        }

        int ans = 0;
        Arrays.sort(L);
        for(int i = 0; i < N; i++){
            if(i == N - 2) break;
            for(int j = i + 1; j < N; j++){
                if(j == N - 1) break;
                for(int k = j + 1; k < N; k++){
                    if(L[k] < L[i] + L[j]) ans++;
                }
            }
        }

        System.out.println(ans);
    }
}

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

int main(){
	
    long long  H,ans=-1;
    long long attack=0;
    cin >> H;
    while(H!=0){
        H = H/2;
        ans += 1;
        long long d = 1;
        rep(i,ans)d *= 2;
        attack += d;
        
    }
    cout << attack;
	return 0;
}



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

#define MAXN 20
#define MAXD 105
#define int long long
#define LL long long
#define pii pair<long, long>
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
using namespace std;

string K;
int N;
int a[MAXN][MAXN];
int dp[1<<16];

signed main() {
    fastio;
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) cin >> a[i][j];
    }
    for (int state = 0; state < (1<<N); state++) {
        dp[state] = 0;
        for (int i = 0; i < N; i++) {
            if (!(state & (1 << i))) continue;
            for (int j = i+1; j < N; j++) {
                if (state & (1 << j)) dp[state] += a[i][j];
            }
        }
        for (int substate = 0; substate < state; substate++) {
            if ((substate & state) != substate) continue;
            int sub2 = state ^ substate;
            if (sub2 < substate) break;
            dp[state] = max(dp[state], dp[substate] + dp[sub2]);
        }
    }
    cout << dp[(1<<N)-1] << endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <stdlib.h>

using namespace std;

//int main(int argc, char *argv[]){
int main(){

	int x=0;
	int y=0;

	//input for x
	cin >> x;
	//input for y
	cin >> y;

	int t2 = y - 2*x;
	int c2 = 4*x - y;

	bool numcheck = (t2 >= 0) && (c2 >= 0);
	bool modcheck = (t2 % 2) || (c2 % 2); 

	if(numcheck && !modcheck){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

}

Measured memory_bytes: 3604
#include <stdio.h>

int main(void){
    // Your code here!
    int n;
    int a;
    int ans;

    ans = 0;
    scanf("%d", &n);
    a = 0;
    while (++a < n)
        ans = ans + n / a - !(n % a);
    printf("%d", ans);
}


Measured memory_bytes: 1732
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
sat = sum(B)
pre_a = A[0]
for a in A[1:]:
  if a == pre_a + 1:
    sat += C[pre_a-1]
  pre_a = a
  
print(sat)

Measured memory_bytes: 3064
use proconio::input;

fn d() {
    input! {
        n: usize,
        mut a: [i64; n],
        q: usize,
        mut bc: [(i32, i32); q],
    }
    let mut num = vec![0; (10_i32.pow(5) + 1) as usize];
    for i in &a {
        num[*i as usize] += 1;
    }
    let mut total: i64 = a.iter().sum();

    for (b, c) in bc {
        let bi = b as usize;
        let ci = c as usize;
        total += ((c - b) * num[bi]) as i64;
        num[ci] += num[bi];
        num[bi] = 0;
        println!("{}", total);
    }
}

fn main() {
    d();
}

Measured memory_bytes: 5728
#include <iostream>
#include <string>
#include <queue>
#include <utility>

using namespace std;

int main(){
  queue<pair<string, int> > Q;
  int n,q; cin >> n >> q;
  int elapsed=0;
  for(int i=0;i<n;i++){
    string nm;
    int t;
    cin >> nm >> t;
    Q.push(make_pair(nm,t));
  }
  while(Q.empty()==false){
    string nm=Q.front().first;
    int t=Q.front().second;
    if(t<=q){
      elapsed=elapsed+t;
      Q.pop();
      cout << nm << " " << elapsed << endl;
    }else{
      elapsed=elapsed+q;
      Q.pop();
      Q.push(make_pair(nm,t-q));
    }
  }
}

Measured memory_bytes: 6364
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n, k = 2;
vector< int > arr( 1e5 + 200 ), dp( 1e5 + 200, -1 );

int solve( int j )
{
	if( j > n )
	{
		return 1e9 + 9;
	}
	if( j == n )
	{
		return 0;
	}
	if( dp[ j ] != -1 )
	{
		return dp[ j ];
	}
	dp[ j ] = 1e9 + 2;
	for( int i = 1; i <= k; ++i )
	{
		dp[ j ] = min( dp[ j ], abs( arr[ j ] - arr[ j + i ] ) + solve( j + i ) );
	}
	return dp[ j ];
}

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> n;
	for( int i = 1; i <= n; ++i )
	{
		cin >> arr[ i ];		
	}
	cout << solve( 1 ) << "\n";
	return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int n; cin >> n;

    int temp6 = 6;
    int temp9 = 9;

    vector<int> pvec;

    while(temp6 <= n || temp9 <= n){
        if(temp6 < temp9){
            pvec.push_back(temp6);
            temp6 *= 6;
        }
        else{
            pvec.push_back(temp9);
            temp9 *= 9;
        }
    }

    sort(pvec.begin(), pvec.end(), greater<int>());

    // for(int i=0; i<pvec.size(); i++){
    //     cout << pvec[i] << endl;
    // }

    int dp[n+1];
    dp[0] = 0;
    dp[1] = 1;
    int pvsize = pvec.size();
    for(int i=2; i<=n; i++){
        int temp = 1e9;
        for(int j=0; j<pvsize; j++){
            if(i < pvec[j]) continue;

            temp = min(temp, dp[i - pvec[j]]+1);
        }
        temp = min(temp, dp[i-1]+1);
        dp[i] = temp;
    }

    cout << dp[n] << endl;
    

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <memory.h>
using namespace std;
typedef long long LL;

struct Mat
{
	LL a[3][3];
	Mat() {
		memset(a, 0, sizeof(a));
	}

}res, ori;

Mat multi(Mat x, Mat y) {
	Mat temp;
	memset(temp.a, 0, sizeof(temp.a));

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				temp.a[i][j] += x.a[i][k] * y.a[k][j];
			}
		}
	}
	return temp;
}

bool mat_exce = false, unfair = false;

Mat quick_exp(Mat x, LL y) {
	Mat ori = x, res;

	for (int i = 0; i < 3; i++) {
		res.a[i][i] = 1;
	}

	while (y) {
		if (1 & y) {
			res = multi(res, ori);
		}
		ori = multi(ori, ori);
		if (ori.a[0][1] >= 1e18 || ori.a[0][1] < 0)
			mat_exce = true;
		y >>= 1;
	}
	return res;
}

LL A, B, C, K;

int main()
{

	cin >> A >> B >> C >> K;
	if (K % 2) {
		cout << B - A << endl;
	}
	else
		cout << A - B << endl;
	return 0;
}

Measured memory_bytes: 256
a = list(map(int, input().split()))
bool = True
while bool:
    bool = False
    for i in range(len(a) - 1):
        if a[i] > a[i+1]:
            a[i], a[i+1] = a[i+1], a[i]
            bool = True

a,b,c = a
print("{} {} {}".format(a,b,c))



Measured memory_bytes: 5600
n,W=map(int,input().split())
wv=[[]for _ in range(4)]
for i in range(n):
	w,v=map(int,input().split())
	if i==0:
		r=w
		wv[0].append(v)
	else:
		wv[w-r].append(v)
for i in range(4):
	wv[i].sort(reverse=True)
	for j in range(len(wv[i])-1):
		wv[i][j+1]+=wv[i][j]
	wv[i].insert(0,0)
ans=0
for i in range(len(wv[0])):
	for j in range(len(wv[1])):
		for k in range(len(wv[2])):
			for l in range(len(wv[3])):
				p=wv[0][i]+wv[1][j]+wv[2][k]+wv[3][l]
				if i*r+j*(r+1)+k*(r+2)+l*(r+3)<=W:
					ans=max(ans,p)
print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var a1,a2,a3 int
	fmt.Scan(&a1,&a2,&a3)

	if a1 + a2 + a3 >= 22{
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}
}

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

using namespace std;

const int N=100010;

struct Job{
	int a,b;
	bool operator <(const Job &x)const{return b>x.b;}
}job[N];
int f[N];
int n,m;
int findf(int x){
    return f[x]==x?x:(f[x]=findf(f[x]));
}
int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d %d",&job[i].a,&job[i].b);
	sort(job+1,job+n+1);
	for(int i=0;i<=m;i++)f[i]=i;
	int tot=0;
	for(int i=1;i<=n;i++){
		int pos=m-job[i].a+1;
		if(pos<0)continue;
		pos=findf(pos);
		if(pos)tot+=job[i].b,f[pos]=findf(pos-1);
	}
	printf("%d\n",tot);
}


Measured memory_bytes: 1408
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n = sc.nextInt();
    static int m = sc.nextInt();
    //チェックされたら1,ベース0
    static int height[] = new int[n];
    static int road[][] = new int[m][2];

    public static void main(String[] args) {
        //高い方
        Set<String> set1 = new HashSet<String>();
        //低い方
        Set<String> set2 = new HashSet<String>();
        //選ばれてない確認
        Set<String> set3 = new HashSet<String>();
        //取得
        for (int i = 0; i < n; i++){
            height[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++){
            road[i][0] = sc.nextInt();
            road[i][1] = sc.nextInt();
            if (height[road[i][0] - 1] > height[road[i][1] - 1]){
                set1.add(String.valueOf(road[i][0]));
                set2.add(String.valueOf(road[i][1]));
            }else if (height[road[i][0] - 1] < height[road[i][1] - 1]){
                set1.add(String.valueOf(road[i][1]));
                set2.add(String.valueOf(road[i][0]));
            } else {
                set1.add(String.valueOf(road[i][1]));
                set1.add(String.valueOf(road[i][0]));
                set2.add(String.valueOf(road[i][1]));
                set2.add(String.valueOf(road[i][0]));
            }
            set3.add(String.valueOf(road[i][0]));
            set3.add(String.valueOf(road[i][1]));
        }
        Iterator ite = set2.iterator();
        while (ite.hasNext()){
            String it = (String) ite.next();
            if (set1.contains(it)){
                set1.remove(it);
            }
        }
        //1と2を比較して重複しないものと選ばれていないもの
        System.out.println(set1.size() + n - set3.size());
    }
}


Measured memory_bytes: 92744
#include <iostream>
#include <algorithm>
#include <cmath>
#define int long long
using namespace std;
const long long linf = (1LL<<60);

signed main() {
  int L, R; cin >> L >> R;
  if(R-L >= 2019) {
    cout << 0 << endl;
  } else {
    int ans = linf;
    for(int i = L; i <= R; ++i) {
      for(int j = i+1; j <= R; ++j) {
        ans = min(ans, i*j%2019);
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n, c;
    scan(n, c);

    auto w = new int[](n);
    auto v = new long[](n);

    foreach (i ; 0 .. n) {
        scan(w[i], v[i]);
    }

    auto b = w[0];
    w[] -= w[0];

    auto dp = new long[][][](n + 1, n + 1, 3*n + 1);
    fillAll(dp, -inf6);
    foreach (wi ; 0 .. 3*n + 1) {
        dp[0][0][wi] = 0;
    }

    foreach (i ; 0 .. n) {
        foreach (j ; 0 .. n) {
            foreach (wi ; 0 .. 3*n + 1) {
                if (dp[i][j][wi] == -inf6) continue;
                dp[i + 1][j][wi] = max(dp[i + 1][j][wi], dp[i][j][wi]);
                if (wi + w[i] <= 3*n) {
                    dp[i + 1][j + 1][wi + w[i]] = max(dp[i + 1][j + 1][wi + w[i]], dp[i][j][wi] + v[i]);
                }
                
            }
        }
    }

    long ans;
    foreach (j ; 1 .. n + 1) {
        foreach (wi ; 0 .. 3*n + 1) {
            if (1L * b * j + wi > c) break;
            ans = max(ans, dp[n][j][wi]);
        }
    }
    writeln(ans);
}









void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 43260
#include <iostream>

using namespace std;

int main() {
  int n, q;
  string name[100000];
  int time[100000];
  
  cin >> n >> q;
  for (int i=0; i<n; i++) cin >> name[i] >> time[i];
  
  int cnt = 0, t = 0;
  while (cnt < n) {
    for (int i=0; i<n; i++) {
      if (time[i] == 0) continue;
      else if (time[i] <= q) {
        t += time[i];
        time[i] = 0;
        cnt++;
        cout << name[i] << " " << t << endl;
      }
      else {
        t += q;
        time[i] -= q;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 6308
#include<stdio.h>

int main(void){
    long A=0;
    long B=0;
    long sa=0;
    scanf("%ld %ld",&A,&B);
    sa=A+B;
    if(sa<0){
        sa*=-1;
    }
    if(sa%2!=0){
        printf("IMPOSSIBLE\n");
        return 0;
    }
    printf("%ld\n",sa/2);
    
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main() {
    int a,b;
    cin>>a>>b;
    int c;
    if(b<10){
        c=a*10+b;
    }else if(b<100){
        c=a*100+b;
    }else{
        c=a*1000+b;
    }
    for(int i=1;i*i<=c;i++){
        if(c==i*i){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}   



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
using namespace std;

int main()
{
	int N;
  	string str;
  	
 	cin>>N;
 	char dummy_str[N];
  	cin>>str;
  	int i,j=0; 
  	for(i=0;i<N;)
    {
    	char x=str[i];
      	dummy_str[j]=x;
      	j++;
      	//cout<<j<<endl;
      	while(str[i]==x && i<N)
        {
        	
        	i++;
        }
    }
	cout<<j;
	return 0;
}

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

int main(){
	vector<int> bingo(9);
	for(int i=0;i<9;i++) cin >> bingo[i];
	int n;
	cin >> n;
	vector<int> flag(9,0); 
	for(int i=0;i<n;i++){
		int b;
		cin >> b;
		auto itr = find(bingo.begin(),bingo.end(),b);
		if(itr != bingo.end()){
			int index = distance(bingo.begin(),itr);
			flag.at(index) = 1;
		}
	}
	if((flag[0] && flag[1] && flag[2]) || (flag[3] && flag[4] && flag[5]) || (flag[6]&& flag[7] && flag[8]) || (flag[0] && flag[3] && flag[6]) || (flag[1] && flag[4] &&flag[7])||(flag[2] && flag[5] && flag[8])||(flag[0]&&flag[4]&&flag[8])||(flag[2]&&flag[4]&&flag[6])){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a[] = new int[6];
		int b[] = new int[6];
		int c[] = new int[6];
		int a2[] = new int[3];
		int b2[] = new int[3];
		int c2[] = new int[3];

		for (int i = 0; i < 6; i++) {
			a[i] = scanner.nextInt();
		}
		for (int i = 0; i < 6; i++) {
			b[i] = scanner.nextInt();
		}
		for (int i = 0; i < 6; i++) {
			c[i] = scanner.nextInt();
		}
		
		for (int i = 0; i < 3; i++) {
			a2[i] = a[i + 3] - a[i];
		}
		if (a2[2] < 0) {
			a2[2] += 60;
			a2[1]--;
		}
		if (a2[1] < 0) {
			a2[1] += 60;
			a2[0]--;
		}
		for (int i = 0; i < 3; i++) {
			b2[i] = b[i + 3] - b[i];
		}
		if (b2[2] < 0) {
			b2[2] += 60;
			b2[1]--;
		}
		if (b2[1] < 0) {
			b2[1] += 60;
			b2[0]--;
		}
		for (int i = 0; i < 3; i++) {
			c2[i] = c[i + 3] - c[i];
		}
		if (c2[2] < 0) {
			c2[2] += 60;
			c2[1]--;
		}
		if (c2[1] < 0) {
			c2[1] += 60;
			c2[0]--;
		}
		System.out.println(a2[0] + " " + a2[1] + " " + a2[2]);
		System.out.println(b2[0] + " " + b2[1] + " " + b2[2]);
		System.out.println(c2[0] + " " + c2[1] + " " + c2[2]);
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) int((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl '\n'
#define ff first
#define ss second
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v) cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clzll(x) - 1;	}

struct pair_hash{
	template<class T1, class T2>
	size_t operator() (const pair<T1, T2> &p) const {
		auto h1 = hash<T1>{}(p.first);
		auto h2 = hash<T2>{}(p.second);
		return h1 ^ h2;
	}
};

int fast_mod(int x, int m = MOD) {
	while(x <= m) x -= m;
	if(x < 0) x += m;
	return x;
}

int mod_add(int x, int y) {
	return fast_mod(x + y);
}

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

	ll n;
	cin >> n;

	if(n & 1 || n < 10) {
		cout << 0 << endl;
		return 0;
	}

	ll cnt = n / 10;

	n /= 10;

	ll x = 5;

	while(x <= n) {
		cnt += n / x;
		x *= 5;
	}

	cout << cnt  << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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; }
typedef pair <ll,ll> P;
ll MOD = 1000000007;

int main()
{
    ll N, x;
    cin >> N >> x;
    vector<ll> a(N, 0);
    vector<ll> b(N, 0);
    rep(i, N){
        cin >> a[i];
        b[i] = a[i];
    } 
    if (b[0] > x) b[0] = x;
    for(ll i = 1; i < N; ++i) {
        if (b[i-1] + b[i] <= x) continue;
        b[i] = x - b[i-1];
    }
    ll count = 0;
    rep(i, N) {
        count += a[i] - b[i];
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
typedef pair<ll,ll> P;

struct BIT{
  int size;
  vector<ll> dat;
  void init(int n){
    size=n;
    dat.clear();
    dat.resize(n+1);
  }
  void Add(int i,ll x){
    i+=2;
    
    x%=mod;
    
    while(0<i&&i<=size){
      dat[i]+=x;

      dat[i]%=mod;
      
      i+=(i&-i);
    }
  }
  
  ll Sum(int i){
    i+=2;
    
    ll res=0;
    while(0<i){
      res+=dat[i];

      res%=mod;
      
      i-=(i&-i);
    }
    return res;
  }
};
 
BIT A,B;

void Add(ll s,ll t,ll value){
  A.Add(s,value);
  A.Add(t,-value);
  B.Add(s,-value*(s-1));
  B.Add(t,value*(s-1) + value*(t-s+1) );
}

ll Sum(ll s,ll t){
  s--;
  ll f= ( A.Sum(t)*t+B.Sum(t) - A.Sum(s)*s-B.Sum(s) ) %mod;
  return (f+mod)%mod;
}


ll solve(vector<P> t){
  A.init(300000);
  B.init(300000);
  Add(0,0,1);

  vector<P> tmp;
  for(int i=0;i<=(int)t.size();i++){
    if(i==(int)t.size() || ( i>0 && t[i-1].first != t[i].first ) ){
      for(P p:tmp){
        Add(p.first, p.first, p.second);
      }
      tmp.clear();
    }
    if(i==(int)t.size())break;

    ll pos=t[i].second;
    ll value=Sum(0, pos-1);
    tmp.push_back( P(pos, value) );
  }

  return Sum(0, 300000-10);  
}

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


  const ll INF=(1LL<<60);
  
  set<ll> X;
  X.insert(INF);
  X.insert(-INF);

  vector<ll> px(n);
  for(int i=0;i<n;i++){
    cin>>px[i];
  }
  for(int i=0;i<m;i++){
    ll x;
    cin>>x;
    X.insert(x);  
  }

  vector<P> v;
  
  
  for(int i=0;i<n;i++){
    set<ll> :: iterator it;
    it=X.lower_bound( px[i] );
    ll right=*it;
    it--;
    ll left=*it;
    if( left == -INF || right==INF)continue;
    v.push_back( P( px[i]-left , right-px[i] ) );  
  }
  sort(v.begin(), v.end());
  v.erase( unique( v.begin(), v.end() ) , v.end() );


  vector<ll> Z;
  for(int i=0;i<(int)v.size();i++){
    Z.push_back( v[i].second );
  }
  sort(Z.begin(),Z.end());
  Z.erase( unique(Z.begin(), Z.end()) , Z.end() );
  for(int i=0;i<(int)v.size();i++){
    v[i].second = lower_bound(Z.begin(),Z.end(), v[i].second) - Z.begin() +1;

    //    cout<<v[i].first<<' '<<v[i].second<<endl;
    
  }
  cout << solve(v) <<endl;
  return 0;
}


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

#define N 100

void matrixChainMultiplication(int**,int*,int);
int min(int,int);

int main(void){
  int n,m[N+1][N+1],p[N+1];
  int i,j,k,l;

  scanf(" %d",&n);

  for(i = 1; i <= n; i++){
    scanf(" %d %d",&p[i-1],&p[i]);
  }

  for(i = 1; i <= n; i++){
    m[i][i] = 0;
  }

  for(l = 2; l <= n; l++){
    for(i = 1; i <= n-l+1; i++){
      j = i + l - 1;
      m[i][j] = (int)INFINITY;
      for(k = i; k < j; k++){
	m[i][j] = min(m[i][j],m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j]);
      }
    }
  }

  printf("%d\n",m[1][n]);
  
  return 0;
}

int min(int a, int b){
  if(a < b)return a;
  else return b;
}



Measured memory_bytes: 2108
#include <iostream>
#define llint long long

using namespace std;

llint a, b, c;
llint x, y;

int main(void)
{
	cin >> a >> b >> c >> x >> y;
	
	llint ans = 1e18;
	for(int i = 0; i <= max(x, y); i++){
		ans = min(ans, 2*c*i + max(0LL, (x-i))*a + max(0LL, (y-i))*b);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(){
    int h, w; cin >> h >> w;

    for(int i = 0; i <  w + 2; i++) cout << '#';
    cout << '\n';

    for(int i = 0; i < h; i++){
        cout << '#';
        for(int j = 0; j < w; j++){
            char c; cin >> c;
            cout << c;
        }cout << '#' << '\n';
    }
    for(int i = 0; i < w + 2; i++) cout << '#';
}


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>

#define SIZE 100001

typedef struct Process_
{
    char name[11];
    int time;
} Process;

Process Q[SIZE];
int head;
int tail;

static void enqueue(Process x)
{
    Q[tail] = x;
    tail = (tail + 1) % SIZE;
}

static Process dequeue()
{
    Process x = Q[head];
    head = (head + 1) % SIZE;
    return x;
}

static bool isEmpty()
{
    return head == tail;
}

static int min(int a, int b)
{
    return a < b ? a : b;
}

int main()
{
    int n, q;
    int elapsed = 0;

    scanf("%d %d", &n, &q);

    for (int i = 0; i < n; i++) {
        scanf("%s %d", Q[i].name, &Q[i].time);
    }
    head = 0;
    tail = n;

    while (!isEmpty()) {
        Process p = dequeue();
        int t = min(q, p.time);
        p.time -= t;
        elapsed += t;

        if (p.time > 0) {
            enqueue(p);
        } else {
            printf("%s %d\n", p.name, elapsed);
        }
    }

    return 0;
}


Measured memory_bytes: 3280
function main(s) {
	n = Number(s.split('\n')[0]);
	a = s.split('\n')[1].split(' ').map(x => Number(x))
	a.sort(
		function (a, b) {
			return (a < b ? 1 : -1);
		}
	)

	var x = 0;
	var y = 0;
	for (var i = 0; i < a.length; i++ ) {
		if (i%2 === 0) {x += a[i]} else {y += a[i]};
	}

	console.log(Math.abs(x - y));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21192
package main

import (
	"fmt"
)

func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func main() {
	var K, sum int
	fmt.Scan(&K)
	for a := 1; a <= K; a++ {
		for b := 1; b <= K; b++ {
			for c := 1; c <= K; c++ {
				sum += gcd(c, gcd(a, b))
			}
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1776
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main(){
    int a;
    cin >> a;
    if (a == 3 || a == 5 || a == 7) cout << "YES" << endl;
    else {
        cout << "NO" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
s = list(input())
s.append('end')
lst = ['A', 'T', 'G', 'C']
max_len = 0
cnt = 1
for i in range(len(s)-1):
    if s[i] in lst:
        if s[i+1] in lst:
            cnt += 1
        else:
            if max_len < cnt:
                max_len = cnt
            cnt = 1
print(max_len)

Measured memory_bytes: 3064
x, y = map(int, input().split())


ans = 0
if x == y :
    ans = 0
elif x == -y :
    ans = 1
elif x > 0 and y > 0 :
    if x > y :
        ans = x - y + 2
    elif x < y : 
        ans = y - x
elif x > 0 and y < 0 :
    if x > -y :
        ans = 1 + x + y
    elif x < -y :
        ans = 1 - y - x
elif x < 0 and y > 0 :
    if -x > y :
        ans = 1 - x - y
    elif -x < y :
        ans = 1 + y + x
elif x < 0 and y < 0 :
    if -x > -y :
        ans = -x + y
    elif -x < -y :
        ans = -y + x + 2
elif x == 0 :
    if y > 0 :
        ans = y
    elif y < 0 :
        ans = -y + 1
elif y == 0 :
    if x > 0 : 
        ans = 1 + x
    elif x < 0 :
        ans = -x

print(ans)

Measured memory_bytes: 3064
d , g = map(int, input().split())
p = [0] + [list(map(int, input().split())) for _ in range(d)]

def f(i,s):
    if i == 0: return 10**9
    cnt = min(s//(100 * i), p[i][0])
    score = 100*i*cnt
    if (cnt==p[i][0]):
        score += p[i][1]
    
    if (s > score):
        cnt += f(i-1,s-score)
    
    return min(cnt, f(i-1,s))

def main():
    print(f(d,g))
main()

Measured memory_bytes: 3064
def main():
    #input data
    import sys
    input = lambda:sys.stdin.readline().strip()
    N,K = map(int,input().split())
    
    #solve
    ans = 0
    for a in range(1,K+1):
        if a == K:
            b = K
            c = K
        else:
            b = K-a
            c = K-a
        if (a+b)%K == 0 and (b+c)%K == 0 and (a+c)%K == 0:
            ans+=((N-a)//K+1)*((N-b)//K+1)*((N-c)//K+1)
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 9092
#include<cstdio>
int main(){
    int n;
    char s[101];
    scanf("%d%s",&n,s);
    int r=0,b=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R')r++;
        else b++;
    }
    if(r>b)printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

using namespace std;

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

    for(int i=0;i<11;i++){
        if(100*i+10*i+i<N && N<=100*(i+1)+10*(i+1)+(i+1)){
            cout << 100*(i+1)+10*(i+1)+(i+1) << endl;
        }
    }
    

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,M;
  cin >> N >> M;
  vi a(M),b(M),c(M);
  rep(i,M) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }
  vvi G(N,vi(N,INF));
  rep(i,N) {
    G[i][i] = 0;
  }
  rep(i,M) {
    G[a[i]][b[i]]=c[i];
    G[b[i]][a[i]]=c[i];
  }
  rep(k,N) {
    rep(i,N) {
      rep(j,N) {
        if(G[i][j]>G[i][k]+G[k][j]) {
          G[i][j]=G[i][k]+G[k][j];
        }
      }
    }
  }
  int ans = 0;
  rep(i,M) {
    if(G[a[i]][b[i]]<c[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int count = 0;
        
        for(int x = a; x <= b; x++){
            if(c % x == 0){
                count++;
            }
        }
    System.out.printf("%d\n", count);    
    }
}



Measured memory_bytes: 26424
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		
		var moti = new int[n];
		for(int i = 0; i < n; i++)
			moti[i] = Console.ReadLine().ToInt();
		Array.Sort(moti);
		Array.Reverse(moti);
		long k = 0;
		long alt = 999;
		for(int i = 0; i < n; i++)
		{
			if(alt>moti[i])
			{
				alt=moti[i];
				k++;
			}
		}
		Console.WriteLine(k);
		
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



Measured memory_bytes: 11092
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;
    
    int hon[5] =  {2,4,5,7,9};
    int pon[4] = {0,1,6,8};
    int bon = 3;
    rep (i, 5)
    {
        if (hon[i] == n % 10)
        {
            cout << "hon\n";
            return 0;
        }
    }
    rep (i, 4)
    {
        if (pon[i] == n % 10)
        {
            cout << "pon\n";
            return 0;
        }
    }
    if (bon == n % 10)
    {
        cout << "bon\n";
        return 0;
    }

    return 0;
}



Measured memory_bytes: 3648
n = int(input())
a = [int(input()) for _ in range(n)]
a.sort()
s = sum(a)
if s % 10 == 0:
    for i in a:
        if i % 10 != 0:
            s -= i
            print(s)
            exit()
    print(0)
else:
    print(s)


Measured memory_bytes: 2940
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;++i){
    cin>>A[i];
  }
  sort(A.begin(), A.end());
  map<int, int> amap;
  int tmpA;
  bool ok[1000005];
  for(int i=0;i<1000005;++i){
    ok[i] = false;
  }
  for(int i=0;i<N;++i){
    tmpA = A[i];
    for(int j=1;j*j<=tmpA;++j){
      if(tmpA%j==0){
        if(amap[j]>0 || amap[tmpA/j]>0) {
          ok[tmpA] = true;
        }
      }
    }
    amap[A[i]]++;
  }
  int ans = 0;
  for(int i=0;i<N;++i){
    if(ok[A[i]]==false) {
      ans++;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 33816
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int main(){
	std::string s; cin >> s;
	std::vector<int> li(26, s.size() + 1);
	std::vector<int> dp(s.size() + 2, 1e9);
	std::vector<std::pair<char, int>> ans(s.size() + 1);
	dp[s.size() + 1] = 0; dp[s.size()] = 1;
	ans[s.size()] = {'a', s.size() + 1};
	
	for(int i = s.size() - 1; i >= 0; i--){
		li[s[i] - 'a'] = i + 1;
		
		for(int j = 0; j < 26; j++){
			if(dp[li[j]] + 1 < dp[i]){
				dp[i] = dp[li[j]] + 1;
				ans[i] = {'a' + j, li[j]};
			}
		}
	}
	
	int pos = 0;
	while(pos <= s.size()){
		cout << ans[pos].first;
		pos = ans[pos].second;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 2948
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MAX = 2100000;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main() { 
    COMinit();
    int n , k; cin >> n >> k;

    for(int i=1; i<=k; i++){
        ll res = COM(n-k+1, i) * COM(k-1, k-i) % MOD;
        cout << res << ln;
    } 
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1000000007;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

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

int N, K;

int main() {
  cin >> N >> K;

  vector<int> h(N);
  for(int i = 0; i < N; i++) {
    cin >> h[i];
  }

  vector<int> dp(N+1, INF);
  dp[0] = 0;

  for(int i = 0; i < N; i++) {
    for(int j = 1; j <= K; j++) {
      if(i+j == N) break;
      chmin(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
    }
  }

  cout << dp[N-1] << endl;
  return 0;
}


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

#define D_iN	200

int main (void) {
	int ii=0, iRetValue=0, iN=0, iA[D_iN], iCount=0;
	int	a=0, b=0, c=0;

	iRetValue = scanf ("%d", &iN);
	for (ii=0; ii < iN; ii++) {
		iRetValue = scanf ("%d", &iA[ii]);
	}

	while (1) {
		for (ii=0; ii < iN; ii++) {
			//c=a-(a/b)*b;
			a = iA[ii] >> 1;	// /2
			b = a << 1;			// *2
			c = iA[ii] - b;		// 1-

			if (c == 0) {
				iA[ii] = a;
			} else {
				goto l_Exit;
			}
		}
		iCount++;
	}

l_Exit:
	printf ("%d\n", iCount);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MAX_N 1000
#define MAX_H 10000

int dp[MAX_N+1][MAX_H+1];
const int INF=1e9+7;

int main() {
    int H,N;
    cin >> H >> N;
    vector<int> A(N),B(N);
    rep(i,N)
        cin >> A.at(i) >> B.at(i);

    rep(i,N+1)
        rep(j,H+1)
            dp[i][j] = INF;
    
    dp[0][0] = 0;
    rep(i,N)
        rep(j,H+1) {
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            dp[i+1][min(j+A.at(i), H)] = min(dp[i+1][min(j+A.at(i), H)], dp[i+1][j]+B.at(i));
        }
    
    cout << dp[N][H] << endl;
}

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

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	REP(i, N){
		cin >> A[i];
	}

	bool is_exiestsd_odd = false;
	int sum = 0;
	while(1){
		REP(i, N){
			if(A[i] % 2 != 0){
				is_exiestsd_odd = true;
				break;
			}
			A[i] = A[i] / 2;
		}
		if(is_exiestsd_odd)
			break;
		sum++;
	}
	cout << sum << endl;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000

int main(){
  char buf[1024];
  long N;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%ld", &N);

  int sq=(int)sqrt(N);

  long sum=0;

  srep(i,1,sq+1){
    if((N-i)%i==0 && (N-i)/i>i){
      sum+=(N-i)/i;
    }
  }

  printf("%ld\n", sum);


}


Measured memory_bytes: 128
n=input()
l=len(n)
n=int(n)
data=[["0"]*l for i in range(4**l)]
for i in range(4**l):
    k=i
    for j in range(l):
        a=k//4**(l-1-j)
        if a==1:
            data[i][j]="3"
        if a==2:
            data[i][j]="5"
        if a==3:
            data[i][j]="7"
        k%=4**(l-1-j)
ans=0
for u in data:
    num=int("".join(u))
    if num<=n:
        num=str(num)
        if "0" not in num and "3" in num and "5" in num and "7" in num:
            ans+=1
print(ans)

Measured memory_bytes: 84852
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    int x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<ll>a(x),b(y),c(z);
    rep(i,x) cin >> a[i];
    rep(i,y) cin >> b[i];
    rep(i,z) cin >> c[i];
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    sort(c.rbegin(),c.rend());
    priority_queue<pair<ll,vector<int>>> pq;
    pq.push(make_pair(a[0]+b[0]+c[0],vector<int>({0,0,0})));
    vector<ll>ans;
    set<vector<int>>s;
    while(ans.size()<k) {
        auto v = pq.top();pq.pop();
        ans.push_back(v.first);
        rep(i,3) {
            int A = v.second[0];
            int B = v.second[1];
            int C = v.second[2];
            if(i==0)A++;
            if(i==1)B++;
            if(i==2)C++;
            
            if(A==x || B == y || C==z) continue;
            if(!s.count(vector<int>({A,B,C}))) {
                s.insert(vector<int>({A,B,C}));
                pq.push(make_pair(a[A]+b[B]+c[C],vector<int>({A,B,C})));
            }
        }
    }
    rep(i,k) cout << ans[i] << endl;
}

Measured memory_bytes: 4464
use std::io::Read;

fn update_min<T: Ord>(x: &mut T, min: T){
    if *x > min {
        *x = min;
    }
}

fn lower_bound<T: Ord>(a: &Vec<T>, x: T) -> usize {
    let mut lower = 0;
    let mut upper = a.len();
    while lower + 1 < upper {
        let pos = (lower + upper) >> 1;
        if a[pos] <= x {
            lower = pos;
        } else {
            upper = pos;
        }
    }
    lower
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();
    let q: usize = iter.next().unwrap().parse().unwrap();
    let s: Vec<i64> = (0..a).map(|_| iter.next().unwrap().parse().unwrap()).collect();
    let t: Vec<i64> = (0..b).map(|_| iter.next().unwrap().parse().unwrap()).collect();

    let mut ns = vec![std::i64::MAX; a];
    let mut nt = vec![std::i64::MAX; b];

    let mut cursor = 0 ;

    for i in 0..a {
        while cursor + 1 < b && t[cursor + 1] < s[i] {
            cursor += 1;
        }
        let dist = (t[cursor] - s[i]).abs();
        ns[i] = dist;
        if cursor + 1 < b {
            let dist2 = (t[cursor+1] - s[i]).abs();
            ns[i] = std::cmp::min(ns[i], dist2);
        }
    }
    cursor = 0;
    for i in 0..b {
        while cursor + 1 < a && s[cursor + 1] < t[i] {
            cursor += 1;
        }
        let dist = (s[cursor] - t[i]).abs();
        nt[i] = dist;
        if cursor + 1 < a {
            let dist2 = (s[cursor+1] - t[i]).abs();
            nt[i] = std::cmp::min(nt[i], dist2);
        }
    }

    for _ in 0..q {
        let x: i64 = iter.next().unwrap().parse().unwrap();
        let p = lower_bound(&s, x) as i32;

        let mut ans = std::i64::MAX;

        for d in [-1i32,0,1].iter() {
            let q = p + d;
            if 0 <= q && (q as usize) < s.len() {
                let q = q as usize;
                update_min(&mut ans, (s[q] - x).abs() + ns[q]);
            }
        }
        
        let p = lower_bound(&t, x) as i32;

        for d in [-1i32,0,1].iter() {
            let q = p + d;
            if 0 <= q && (q as usize) < t.len() {
                let q = q as usize;
                update_min(&mut ans, (t[q] - x).abs() + nt[q]);
            }
        }
        
        println!("{}", ans);
    }
}


Measured memory_bytes: 15224
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
    
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
  int x,a,b;
  cin >> x >> a >> b;
  if (abs(x-a)>abs(x-b))
  {
      cout << 'B' << endl;
  }else
  {
      cout << 'A' << endl;
  }
  
    
  
  
    


//////////////////////////////////////////////////////
return 0;}

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

using namespace std;

int gcd(int m,int n)
{
  return n? gcd(n, m%n) : m;
}

int main()
{
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long e=c/gcd(c,d);
    e*=d;
    long long ans=(b-a+1)-(b/c+b/d-b/e)+((a-1)/c+(a-1)/d-(a-1)/e);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, a, i, ans = 0;

	scanf("%d", &n);

	for (i = 1; i <= n; i++)
	{
		scanf("%d", &a);
		if (i % 2 == 1 && a % 2 == 1)
			++ans;
	}

	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

#define NMAX 100
#define SQMAX 10
#define EPS 1e-7

struct S{
	double x, y, r;
};

/*点と円 true->点は円の内部*/
bool po_cr(double cx, double cy, double cr, double px, double py){
    return pow((cx - px), 2.0) + pow((cy - py), 2.0) <= pow(cr, 2.0);
}


int main(){

	int n;
	int cnt, ans;
	S seal[NMAX];
	char gav;

	while(1){

		cin >> n;
		if(n == 0) break;

		for(int i = 0; i < n; i++){
			cin >> seal[i].x >> gav >> seal[i].y;
			seal[i].r = 1.0;
		}

		ans = 0;
		for(int i = 0; i < 100; i++){
			for(int j = 0; j < 100; j++){
				cnt = 0;
				for(int k = 0; k < n; k++){
					if(po_cr(seal[k].x, seal[k].y, seal[k].r, (double)SQMAX*i/100, (double)SQMAX*j/100)){
						cnt++;
					}
				}
				ans = max(ans, cnt);
			}
		}

		cout << ans << endl;

	}
}

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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 300010, M = 2 * N, mod = 1e9 + 7;

int n, k;

int main()
{
	cin >> n >> k;
	
	if (!k)
	{
		cout << (LL)n * n << endl;
		return 0;
	}
	
	LL res = 0;
	for (int i = k + 1; i <= n; i ++ )
	{
		res += (i - k) * (n / i);
		// cout << i << ' ' << res << ' ';
		if (n % i) res += max(n % i - k + 1, 0);
		// cout << res << endl;
	}
	cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
char a[4];
int main(){
scanf("%s",&a);
  if(a[1]!=a[2])goto WA;
  if(a[1]!=a[0]&&a[1]!=a[3])goto WA;
  printf("Yes");
  return 0;
  WA:
  printf("No");
  return 0;
}


Measured memory_bytes: 128