akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
        private static int s_maxWater;
        private static int s_maxSugar;
        private static double s_maxDensity = double.MinValue;
        static void SolveA()
        {
            int n = ReadAndParseInt();
            int[] a = new int[n];
            for(int i=0;i<n;++i)
            {
                a[i] = ReadAndParseInt();
            }
            var hash = new HashSet<int>();
            for(int i=0;i<a.Length;++i)
            {
                if( hash.Contains(a[i]))
                {
                    hash.Remove(a[i]);
                }else
                {
                    hash.Add(a[i]);
                }
            }

            Console.WriteLine(hash.Count);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 19804
#include<iostream>
#define I(i,n)for(int i=0,p=0;i<n;i++)
long long M=1e9+7,n,a[2],s[100000],w[2][100001],e[2],l[2][100000];
int main(){
	std::cin>>n>>*a>>a[1];
	I(i,n)std::cin>>s[i];
	I(k,2){p=0;w[k][0]=1;I(i,n){while(s[i]-s[p]>=a[k]&&p<i-1)p++;l[k][i]=p;}}
	I(i,n){if(i){
		I(k,2)w[k][i]=(e[!k]<=l[k][i])*w[!k][l[k][i]];
		I(k,2)if(s[i]-s[i-1]<a[k])e[k]=i;else(w[k][i]+=w[k][i-1])%=M;
	}}
	std::cout<<(w[0][--n]+w[1][n])%M;
	return 0;
}

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

int main(){
    int K = 26;
    int D;
    cin >> D;
    vector<ll> C(K);
    for (int i = 0; i < K; i++) cin >> C[i];
    vector<vector<ll>> s(D+1, vector<ll>(K, 0));
    for (int i = 1; i <= D; i++) {
        for (int j = 0; j < K; j++) {
            cin >> s[i][j];
        }
    }
    
    vector<int> ans(D+1, 0);
    
    vector<set<int>> day(K);
    for (int i = 0; i < K; i++) {
        day[i].insert(0);
        day[i].insert(D+1);
    }
    vector<int> cnt(K, 0);
    for (int i = 1; i <= D; i++) {
        int op = 0;
        int s_mx = 0;
        for (int j = 0; j < K; j++) {
            if (s_mx < s[i][j]) {
                s_mx = s[i][j];
                op = j;
            }
        }
        day[op].insert(i);
        ans[i] = op+1;
    }
    
    ll inf = 1e18;
    ll r = 123456789;
    ll mod = 1e9+7;
    for (int z_ = 0; z_ < 100000; z_++) {
        r = r*r%mod;
        int a = r%D+1;
        
        int def = ans[a]-1;
        
        ll pt_max = -inf; 
        ll op = 0;
        day[def].erase(day[def].find(a));
        for (int i = 0; i < K; i++) {
            auto it = day[i].lower_bound(a);
            ll nxt = (*it);
            it--;
            ll pre = (*it);
            ll pt = ((nxt-pre)*(nxt-pre+1)/2 - ((a-pre)*(a-pre+1)/2+(nxt-a)*(nxt-a+1)/2)) * C[i] + s[a][i];
            if (pt > pt_max) {
                pt_max = pt;
                op = i;
            }
        }
        day[op].insert(a);
        ans[a] = op+1;
    }
    
    for (int i = 1; i <= D; i++) cout << ans[i] << endl;
    
    return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define MP make_pair
#define llu unsigned long long
#define U unsigned int
#define ff first
#define ss second
#define SIZE 100005
#define pie 3.14159265358979323
#define minuss 1e-6
#define pair pair<ll,ll>
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define BIG 1000000000
#define INF 1000000000000005
#define N 10000
vector<ll>vec;
map<string,ll> mps;
map<ll,string> mpss;
set<ll>s1;
set<string>s2;
map<string,ll>::iterator str;
set<ll>::iterator itr;
/*
std::cout << std::fixed;
std::cout << std::setprecision(1);
std::cout << VALUE NAME<<endl;
*/
ll tra[100006],tra1[100006];


int main()
{

    map<ll,ll>mp;
    map<ll,ll>::iterator it;
    string s;
    ll n,m;
    cin>>n>>m;
    ll str[m+5];

    for(int i=0; i<m; i++)
    {
        cin>>str[i];
        mp[str[i]]++;
    }
    ll lock=0;
    ll save=n;
    ll save1=n;
    while(lock==0)
    {
        if(mp[save]==0)
        {
            lock=1;
            cout<<save<<endl;
            break;
        }
        save--;
        if(mp[save1]==0)
        {
            lock=1;
            cout<<save1<<endl;
            break;
        }
        save1++;
    }



}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int n, k;

int main()
{
    cin >> n >> k;
    if ((n-1)*(n-2)/2<k){
        cout << -1 << endl;
        return 0;
    }
    int m = (n - 1) * (n - 2) / 2 - k + n - 1;
    cout << m << endl;
    repf(i,2,n+1){
        cout << 1 << " " << i << endl;
    }
    m -= n - 1;
    repf(i,2,n){
        repf(j,i+1,n+1){
            if (m==0){
                return 0;
            }
            cout << i << " " << j << endl;
            m--;
        }
    }
}

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

long long dp[10][1024];
int main(){
	dp[0][0]=1;
	for(int i=0;i<=100;i++)
		for(int j=9;j--;)
			for(int k=0;k+i<=1000;k++)
				dp[j+1][k+i] += dp[j][k];
	int n,s;
	while(cin>>n>>s,n||s){
		cout<<dp[n][s]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>
#include<queue>
#include <string>
using namespace std;

int main()
{
	string s;
	cin >> s;
	int index = 0, max = 0;
    s += "E";
	for (int i = 0; i < s.length(); i++) {
		char cur = s[i];
		if (cur == 'A' || cur == 'C' || cur == 'G' || cur == 'T') {
			index++;
		}
		else {
			if (index > max) max = index;
			index = 0;
		}
	}
	cout << max;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
a=[list(map(int,input().split())) for i in range(N)]
a.sort()
m=0#お金
c=0#買った個数
for i in range(N):
    c+=a[i][1]
    if c<=M:
        m+=a[i][0]*a[i][1]
    else:
        c-=a[i][1]
        m+=a[i][0]*(M-c)
        break
print(m)

Measured memory_bytes: 27760
#include <iostream>
#include <iomanip>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void)
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    vector<int> A(N);
    int ans = 0;
    for (int k = 0; k < N ; k++)
    {
        int i = 1, j = 0;
        A[k] = N - k;
        while (k + i < N)
        {
            while (k + i + j < N && S[k + j] == S[ k + i + j]) j++;
            A[k + i] = j;
            ans = max(ans, min(j, i));
            if (j == 0) {i++; continue;}
            int t = 1;
            while (k + i + t < N && t + A[k + t] < j)
            {
                A[k + i + t] = A[k + t];
                ans = max(ans, min(i + t, A[k + t]));
                t++;
            }
            i += t;
            j -= t;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d", $A, $B, $C);
fscanf(STDIN, "%d", $K);
$cnt = 0;
while($B <= $A) {
    $cnt++;
    $B *= 2;
}
while($C <= $B) {
    $cnt++;
    $C *= 2;
}
echo $cnt > $K ? "No" : "Yes";


Measured memory_bytes: 16244
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  long long N;cin>>N;
  
  long long sum=N*(N+1)/2;
  
  for(int i=1;i<=N;i++){
    if(i%3==0||i%5==0){
      sum-=i;
    }
  }
  
  cout<<sum<<endl;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        new Program();
    }

    long result = long.MaxValue;

    Program()
    {
        var nmx = Console.ReadLine().Split(' ');
        var n = long.Parse(nmx[0]);
        var m = long.Parse(nmx[1]);
        var x = long.Parse(nmx[2]);

        var c = new long[n];
        var a = new long[n, m];

        for (var i = 0; i < n; i++)
        {
            var t = Console.ReadLine().Split(' ');
            c[i] = long.Parse(t[0]);

            for (var j = 0; j < m; j++)
            {
                a[i, j] = long.Parse(t[j + 1]);
            }
        }

        var syujukudo = new long[m];

        Sub1(n, m, x, c, a, 0, syujukudo, 0L);

        Console.WriteLine(result == long.MaxValue ? -1 : result);
    }

    void Sub1(long n, long m, long x, long[] c, long[,] a, int idx, long[] syujukudo, long kingaku)
    {
        if (idx == n)
        {
            var sum = 0L;

            for (var i = 0; i < m; i++)
            {
                if (syujukudo[i] < x) return;
            }

            result = Math.Min(result, kingaku);

            return;
        }

        for (var i = 0; i < m; i++)
        {
            syujukudo[i] += a[idx, i];
        }

        Sub1(n, m, x, c, a, idx + 1, syujukudo, kingaku + c[idx]);

        for (var i = 0; i < m; i++)
        {
            syujukudo[i] -= a[idx, i];
        }

        Sub1(n, m, x, c, a, idx + 1, syujukudo, kingaku);
    }
}


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

#define rep(i,n) for (int i=0; i< (n); i++)
typedef std::pair<int, int> P;
typedef long long int ll;

using namespace std;

int main(){
    int n;
    std::cin >> n;
    vector<int> d(n);
    rep(i, n) {
        cin >> d[i];
    }
    std::sort(d.begin(), d.end());

    int lowwer = d[n/2-1];
    int upper = d[n/2];
    printf("%d", upper - lowwer);
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
 
#define N 100000000
int a(void);
int b(char);
void insert(void);
int find(void);
 
char C[14];
int X[N];
int n;
int main() {
	char str[7];
	int i;
	
	scanf("%d",&n);
	
	for(i = 0; i<n; i++) {
		scanf("%s%s",str,C);
		if(str[0] == 'i') {
			insert();
		} else if(str[0] == 'f') {
			if(find())
			printf("yes\n");
			else
			printf("no\n");
		}
	}
	return 0;
}


int a(void) {
	int x =0,p=1,i;
	
	for(i = 0; i < strlen(C);i++) {
		x +=p*(b(C[i]));
		p*=5;
	}
	return x;
}

int b(char C) {
	if( C == 'A') {
		return 1;
	} else if(C=='C') {
		return 2;
	} else if(C =='G') {
		return 3;
	}
	else return 4;
}


void insert() {
	X[a()] = 1;
}

int find() {
	int key = a();
	
	if(X[key]) 	return 1;
	else return 0;
}
	
	
	


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

int main()
{
	int a = 0, b = 0;
	char op;

	cin >> a >> op >> b;

	while (op != '?') {
		switch (op) {
			case '+':
				cout << a + b << endl;
				break;
			case '-':
				cout << a - b << endl;
				break;
			case '*':
				cout << a * b << endl;
				break;
			case '/':
				if(b!= 0)
					cout << a / b << endl;
				break;
		}
		cin >> a >> op >> b;
	}
    return 0;
}

Measured memory_bytes: 3080
use std::io;


fn main() {
    let (n, k) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let mut pros = 0.0;
    for i in 1..n + 1 {
        let mut ans = i;
        let mut time = 1;
        while ans < k { time *= 2; ans *= 2; }
        pros += (1.0 / (time as f64)) / n as f64;
    }

    println!("{}", pros);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
n=int(input())
def f(s):
    m=ord(max(list(s))) - 97
    res = [s for _ in range(m+2)]
    for i in range(m+2):
        res[i] += chr(i+97)
    return res
def main(n):
    if n==1:
        return ["a"]
    else:
        ans = []
        for k in main(n-1):
            ans.extend(f(k))
        return ans

ans = main(n)
for i in ans:
    print(i)

Measured memory_bytes: 58076
N,M=map(int, input().split())
A=[list(map(int, input().split())) for _ in range(N)]

answer=[0]*M

for i in range(len(A)):
    for j in range(1, len(A[i])):
        answer[A[i][j]-1]+=1

count=0
for i in range(len(answer)): 
        if answer[i]/N==1:
            count+=1
print(count)

Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

constexpr ll mod = 1000000007;

int main() {
    int n = 0;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    
    int cnt0 = 0;
    for (int x : a) {
        if (x == 0) {
            cnt0++;
        }
    }
  
  	if (cnt0 > 3) {
      	cout << 0 << endl;
      	return 0;
    }

    ll color = 0;
    if (cnt0 == 1) {
        color = 3;
    } else {
        color = 6;
    }

    ll ans = 1;
    vector<int> cur(1e5);
    for (int i=0; i<n; i++) {
        if (a.at(i) == 0) {
            cur.at(0)++;
        } else {
            ans *= cur.at(a.at(i)-1);
            ans %= mod;
            cur.at(a.at(i))++;
            cur.at(a.at(i)-1)--;
        }
    }
    
    cout << ans * color % mod << endl;

    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    vector<int> cnt(10);
    for (int i = 0, n; i < 4; ++i) {
        cin >> n;
        ++cnt[n];
    }

    if (cnt[1] && cnt[4] && cnt[7] && cnt[9])
        cout << "YES\n";
    else
        cout << "NO\n";

    return 0;
}


Measured memory_bytes: 256
program sample
	implicit none
    integer(8) :: N,count,i
    integer,allocatable :: x(:)
    
    read(*,*) N
    
    allocate(x(N))
    
    read(*,*) x
    
    count =0
    
    !左より右が大きくなるところで区切りを入れ、左側の値から右側の値を引いたものを足し合わせていく
	do i=1,N-1
    	if (x(i) > x(i+1)) then
        	count = count + x(i) - x(i+1)
        end if
    end do
    
    !一番右端を足す。
	write(*,*) count+x(N)
    
    deallocate(x)
    
    stop
end program sample

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String a = s.next();
		String[] ac = a.split("");
		List<String> Ac = Arrays.asList(ac);
		String b = s.next();
		String[] bc = b.split("");
		List<String> Bc = Arrays.asList(bc);
		String c = s.next();
		String[] cc = c.split("");
		List<String> Cc = Arrays.asList(cc);
		Iterator ai = Ac.iterator();
		Iterator bi =Bc.iterator();
		Iterator ci = Cc.iterator();
		
		System.out.println(keisan(Ac, Bc, Cc, ai, bi, ci, "a"));
	}
	static char keisan(List a,List b,List c, Iterator ai, Iterator bi, Iterator ci, String next) {
		String n = null;
		switch(next) {
		case "a":
			if(ai.hasNext() == false) {
				return 'A';
			} else {
				n = (String)ai.next();
			}
			break;
		case "b":
			if(bi.hasNext() == false) {
				return 'B';
			} else {
				n = (String)bi.next();
			}
			break;
		case "c":
			if(ci.hasNext() == false) {
				return 'C';
			} else {
				n = (String)ci.next();
			}
			break;
		}
		return keisan(a,b,c,ai,bi,ci,n);
	}
}

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

int main()
{
	int S, h, m, s;
	
	scanf("%d", &S);
	
	h = S / 3600;
	m = S % 3600 / 60;
	s = S % 60;
	printf("%d:%d:%d\n", h, m, s);
	
	return 0;
}


Measured memory_bytes: 2080
#include <iostream>
using namespace std;
int main(void){
  int n,k,q,i,a,p[100010]={};
  cin >> n >> k >> q;
  for (i=0;i<q;i++){
    cin >> a;
    p[a]++;
  }
  for (i=1;i<=n;i++){
    if (p[i]>q-k) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool gd(int n) {
	return n % 7 == 1 || n % 7 == 6;
}
bool f(int n) {
	for (int i = 2; i*i <= n; ++i) {
		if (n % i == 0 && (gd(i) || gd(n/i))) return false;
	}
	return true;
}
int main() {
	int n;
	while ( cin >> n, n != 1 ) {
		vector<int> v;
		for (int i = 1; i*i <= n; ++i) {
			if (n % i == 0) {
				if (i != 1 && i != n/i) v.push_back(i);
				v.push_back(n/i);
			}
		}
		vector<int> vv;
		for (int i = 0; i < v.size(); ++i) {
			if ( gd(v[i]) && f(v[i]) ) {
				vv.push_back(v[i]);
			}
		}

		sort(vv.begin(), vv.end());

		cout << n << ":";
		for (int i = 0; i < vv.size(); ++i) {
			cout << " " << vv[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 1220
#include<iostream>
using namespace std;
#define li long long int



li min(li a,li b)
{
    if(a>b) a=b;
    return a;
}


li fun(int arr[],int i,int n)
{
    li dp[n+1];
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs( arr[1]-arr[0] );

    
for( int i=2 ;i<n;i++)
{
    
    dp[i+1]=  min( dp[i]+ abs(arr[i]-arr[i-1] ), abs(arr[i]-arr[i-2])+dp[i-1]  );
    
    
}

    return dp[n];
}




int main()
{
    int n;
    cin >> n;
    int arr[n];
    for(int i=0;i<n;i++) cin >> arr[i];
    
cout<<    fun(arr,0,n);
    
    return 0;
}



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

int main(){
    int y,m,d;
    char s1,s2;
    cin>>y>>s1>>m>>s2>>d;
    if (y<=2019){
        if (m>=5){
            cout<<"TBD"<<endl;
        }else{
            cout<<"Heisei"<<endl;
        }
    }else{
        cout<<"TBD"<<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() {
    string S;
    cin >> S;
    if ((S[0] == S[1] && S[1] != S[2] && S[2] == S[3]) || (S[0] == S[2] && S[2] != S[1] && S[1] == S[3]) || (S[0] == S[3] && S[3] != S[1] && S[1] == S[2])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

main() {
  int a, b, c; cin >> a >> b >> c;
  int ans = 3;
  if (a == b) ans--;
  if (a == c) ans--;
  if (b == c) ans--;
  if (a == b && b == c) ans = 1;
  cout << ans << endl;
}


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

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

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

    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    vector<int> left(N + 1), right(N + 1);
    left[0] = 0, right[N] = 0;
    for (int i = 0; i < N; i++)
        left[i + 1] = gcd(left[i], A[i]);
    for (int i = N; i > 0; i--)
        right[i - 1] = gcd(right[i], A[i - 1]);

    int res = 0;
    for (int i = 0; i < N; i++) {
        int l = left[i];
        int r = right[i + 1];

        res = max(res, gcd(l, r));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <set>
#include <vector>
using namespace std;

int main(){
    int N,K;

    cin >> N >> K;

    if( N % K == 0){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
    long long int N;
    cin >> N;
    if(N==0){
        cout << 0 << endl;
        return 0;
    }
    string S = "";

    for(long long int i=1;N!=0;i++){
        long long int div = pow(2,i);
        if(abs(N)%div != 0){
            if(i%2==1){
                N -= pow(2,i-1);
            }else{
                N += pow(2,i-1);
            }
            S += '1';
        }else{
            S += '0';
        }
    }

    reverse(S.begin(),S.end());

    cout << S << endl;
}

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

ll mod = 1000000007;

signed main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    ll ans=0;
    rep(i,60){
        ll x=0;
        rep(j,n) if(a[j]>>i&1) x++;
        ll now=x*(n-x)%mod;
        rep(j,i) now=now*2%mod;
        ans += now;
        ans%=mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2688
from operator import itemgetter
n, q = map(int, input().split())
abab = [list(map(int, input().split())) for _ in range(n-1)]
pxpx = [list(map(int, input().split())) for _ in range(q)]
abab.sort(key=itemgetter(0))

ans = [0 for _ in range(n)]
for p, x in pxpx :
    ans[p-1] += x
for a, b in abab :
    ans[b-1] += ans[a-1]
print(*ans)

Measured memory_bytes: 113628
#include <iostream>
using namespace std;
int main(void){
    int n, m, l;
    cin >> n >> m >> l;
    int a[n][m];
    int b[m][l];
    long c[n][l];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < l; j++) {
            cin >> b[i][j];
        }
    }
    for (int i = 0; i < n; i++)  {
        for (int j = 0; j < l; j++) {
            c[i][j] = 0;
            for (int k = 0; k < m; k++) {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            if (j != 0) cout << " ";
            cout << c[i][j];
        }
        cout << endl;
    }
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return abs(x-y)/gcd(x,y); }


int main() {
  int n; cin >> n;
  vector<string> s(n); for(int i=0;i<n;i++) { cin >> s[i]; }

  string march="MARCH";
  map<char,lint> map;
  lint ans=0;

  for(int i=0;i<n;i++) { map[s[i][0]]++; }

  for(int i=0;i<5;i++) {
    for(int j=i+1;j<5;j++) {
      for(int k=j+1;k<5;k++) {
        ans += map[march[i]]*map[march[j]]*map[march[k]];
      }
    }
  }

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


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

int main(){
	int pasta[3],juice[2];
	rep(i,3)cin>>pasta[i];
	rep(i,2)cin>>juice[i];
	vector<int> ans;
	rep(i,3)rep(j,2){
		ans.push_back(pasta[i]+juice[j]-50);
	}
	sort(ans.begin(),ans.end());
	cout<<ans[0]<<endl;
	return 0;
}

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

#define int long long
#define ld long double

#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()

#define debug1(a) cerr<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cerr<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cerr<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cerr<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

#define INF (int)10000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 998244353

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
    int a, b;
    cin>>a>>b;

    cout << (a^b) << "\n";
 	
    return 0;
}



Measured memory_bytes: 3664
var S:string;
    i:integer;
    ch:char;
    check:array['A'..'Z'] of integer;
    AZ:set of 'A'..'Z';
    flag:boolean;
begin
read(S);AZ:=[];flag:=false;
for i := 1 to 4 do begin
AZ:=AZ+[S[i]];inc(check[S[i]]);
end;

for ch := 'A' to 'Z' do
if ch in AZ then 
if check[ch]<>2 then flag:=true;
if flag then write('No') else write('Yes');
end.

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int A, B;

int main(){
    cin >> A >> B;
    if(A==1 && B==2)cout << 3 << endl;
    else if(A==1 && B==3)cout << 2 << endl;
    else if(A==2 && B==3)cout << 1 << endl;
    else if(A==2 && B==1)cout << 3 << endl;
    else if(A==3 && B==1)cout << 2 << endl;
    else if(A==3 && B==2)cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from itertools import accumulate
import sys
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    d = defaultdict(list)
    for _ in range(N):
        t, v = map(int, input().split())
        d[t].append(v)

    other = []
    vmax = []
    for nums in d.values():
        nums.sort(reverse=True)
        for i, j in enumerate(nums):
            if i == 0:
                vmax.append(j)
            else:
                other.append(j)

    vmax.sort(reverse=True)
    other.sort(reverse=True)
    sum_v = [0] + list(accumulate(vmax))
    sum_o = [0] + list(accumulate(other))
    ans = 0
    for i in range(K,0,-1):
        neta = min(i, len(vmax))
        base = neta * neta
        tmp = base + sum_v[neta]
        if K - neta > len(other):
            break
        tmp += sum_o[K-neta]
        ans = max(ans, tmp)
        


    print(ans)

    
    




if __name__ == "__main__":
    main()

Measured memory_bytes: 69212
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
LL fac[SIZE],inv[SIZE];
LL mypow(LL x,LL y){
    LL res=1;
    while(y){
        if(y&1)res=res*x%MOD;
        y>>=1;
        x=x*x%MOD;
    }
    return res;
}
LL C(int x,int y){
    if(y<0||y>x)return 0;
    return fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
void build(){
    assert(MOD>=SIZE);
    fac[0]=1;
    REPP(i,1,SIZE)fac[i]=fac[i-1]*i%MOD;
    inv[SIZE-1]=mypow(fac[SIZE-1],MOD-2);
    for(int i=SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%MOD;
}
int main(){
    build();
    DRII(N,M);
    if(abs(N-M)>1)return 0*puts("0");
    else printf("%lld\n",fac[N]*fac[M]%MOD*(2-abs(N-M))%MOD);
    return 0;
}


Measured memory_bytes: 16384
#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>;
const int mod = 1000000007;
const ll INF = 1001001001;
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 dp[3005][3005];

int main(){
  int n,t;
  cin >> n >> t;
  vector<P> a(n);
  rep(i,n) cin >> a[i].first >> a[i].second;
  sort(a.begin(),a.end());
  int ans = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<t;j++){
      if(j>=a[i].first){
        chmax(dp[i+1][j],dp[i][j-a[i].first]+a[i].second);
      }
      chmax(dp[i+1][j],dp[i][j]);
    }
    ans = max(ans,dp[i][t-1]+a[i].second);
  }
  cout << ans << endl;
}

Measured memory_bytes: 35456
#include <iostream>
using namespace std;
int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (a - b >= 0)
		cout << "delicious" << endl;
	else if (x + a - b >= 0)
		cout << "safe" << endl;
	else
		cout << "dangerous" << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] A = new int[3];
		for(int i = 0; i < 3; i++) A[i] = sc.nextInt();
		Arrays.sort(A);
		System.out.println(A[0] + " " + A[2]);
	}
}



Measured memory_bytes: 26420
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define dame {cout<< "No" <<"\n"; return;}
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {

    ll H,W,h,w; cin>>H>>W>>h>>w;
    if(h==1 and w==1) dame;
    ll a=4000;
    ll b=a*(h*w-1)+1;
    b=-b;
    ll ans[H][W];
    ll sum=0;
    rep(i,H){
        rep(j,W){
            if(i%h==h-1 and j%w==w-1) ans[i][j]=b;
            else ans[i][j]=a;
            sum+=ans[i][j];
        }
    }
    if(sum<=0) dame;
    cout<< "Yes" <<"\n";
    rep(i,H){
        rep(j,W){
            cout<< ans[i][j] <<" ";
        }
        cout<<"\n";
    }
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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


long long n,m;
cin>>n>>m;
long long arr[n];
for(long long i=0;i<=n;i++)
{
    arr[i]=-1;
}
bool hbe=true;
for(long long i=0;i<m;i++)
{
    long long k,l;
    cin>>k>>l;

    if((arr[k-1]!=-1 && arr[k-1]!=l)  )
    {
        hbe=false;
    }
    else
    {
        arr[k-1]=l;
    }
    if(k==1 && l==0 && n!=1)
    {
        hbe=false;
    }
}
if(!hbe)
{
    cout<<-1<<endl;
    return 0;
}
bool z=false;
long long ans[n];
if(arr[0]==-1)
{
    if(n==1)
    arr[0]=0;
    else
        arr[0]=1;

}
for(long long i=0;i<n;i++)
{
    if(arr[i]==-1)
    {
        cout<<0;
    }
    else
        cout<<arr[i];
}
cout<<endl;

}


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

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

  int len = s.length();
  for (int i = 0; i < len; ++i) {
    if ( i % 2 == 0 ) {
      std::cout << s[i];
    }
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 100005

int main(){

    int a,b,c;
    cin >> a >> b >> c;
    int tmp = a+b+c;
    int ans = 0;

    int maxi = max(a,max(b,c));
    int mini = min(a,min(b,c));
    int middle = tmp-mini-maxi;
    int tmp_maxi = maxi,tmp_mini = mini,tmp_middle = middle;
    
    //cout << maxi << " " << mini << " " << middle << endl;

    if(middle%2 == mini%2){
        ans+= (middle-mini)/2;
        ans+= (maxi-middle);
    }else{

        while(middle%2 != mini%2){
            middle++;
            maxi++;
            ans++;
        }
        ans+= (middle-mini)/2;
        ans+= (maxi-middle);

        /*while(tmp_mini != tmp_middle){
            tmp_mini++;
            tmp_maxi++;
        }*/
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
using namespace std;
 
int main() {

  int X,N;
  cin >> X >> N;
  set<int> S;
  for( int i=0; i<N; i++){
    int t;
    cin >> t;
    S.insert( t );
  }

  for( int i = 0; i < 110; i++){
  
    if( !(S.count( X-i )) ){
    cout << X-i << endl;
    return 0;
    }

    if(  !(S.count( X+i )) ){
    cout << X+i << endl;
    return 0;
    }
    
  }

  return 0;

}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main(){
    int a[4],b[4],hcount=0,bcount=0;
    while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
    hcount=0;
    bcount=0;
    for(int k=0;k<4;k++){
        for(int s=0;s<4;s++){
            if(a[k]==b[s]&&k==s)hcount++;
            else if(a[k]==b[s]&&k!=s)bcount++;
        }
    }
    cout<<hcount<<" "<<bcount<<endl;
    }
    return 0;
}

Measured memory_bytes: 3076
def examA():
    N, M = LI()
    ans = N*(N-1)//2 + M*(M-1)//2
    print(ans)
    return

def examB():
    def judge(A):
        #print(A)
        n = len(A)
        for i in range(n//2):
            if A[i]!=A[n-i-1]:
                return False
        return True
    S = SI()
    N = len(S)
    if not judge(S):
        print("No")
        return
    if judge(S[:(N-1)//2]) and judge(S[(N+1)//2:]):
        print("Yes")
    else:
        print("No")
    return

def examC():
    L = I()
    ans = (L/3)**3
    print(ans)
    return

def examD():
    N = I()
    A = LI()
    D = defaultdict(bool)
    C = Counter(A)
    M = 0
    for key,c in C.items():
        M += c*(c-1)//2
    #print(C)
    #print(M)
    ans = [0]*N
    for i in range(N):
        a = A[i]
        c = C[a]
        ans[i] = M -(c*(c-1)//2) + ((c-1)*(c-2)//2)
    for v in ans:
        print(v)
    return

def examE():
    H, W, K = LI()
    S = [SI()for _ in range(H)]
    SH = [[0] * (W + 1) for _ in range(H + 1)]
    for i in range(H):
        now = 0
        for j in range(W):
            now += int(S[i][j])
            SH[i + 1][j + 1] = SH[i][j + 1] + now

    def calc(a,b,c,d):
        return SH[c][d] - SH[a][d] - SH[c][b] + SH[a][b]

    ans = H+W-2
    mask = 2**(H-1)-1
    for i in range(mask+1):
        cut = [0]
        cur = 0
        for j in range(H-1):
            if i&(1<<j)==(1<<j):
                cut.append(j+1)
                cur += 1
        cut.append(H)
        L = [0]*(len(cut)-1)
        flag = True
        for w in range(W):
            now_L = [0]*(len(cut)-1)
            for s in range(len(cut) - 1):
                n = calc(cut[s], w, cut[s + 1], w + 1)
                now_L[s] = n
                if n+L[s]> K:
                    if n>K:
                        flag = False
                        cur = inf
                        break
                    cur += 1
                    L = [0] * (len(cut))
            if not flag:
                break
            for s in range(len(cut) - 1):
                L[s] += now_L[s]
        if not flag:
            continue
        ans = min(ans,cur)

    print(ans)
    return
"""
2 1 1
1
1
"""# 1

def examF():
    N, S = LI()
    A = LI()
    dp = [[0]*N for _ in range(S*2)]

    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examE()

"""

"""

Measured memory_bytes: 45148
#include <stdio.h>

int main() {
	int N;
	scanf("%d",&N);
	int a = N/100, b = N % 100, val_1 = 0, val_2 = 0;
	if (1 <= b && b <= 12) val_1++;
	if (1 <= a && a <= 12) val_2++;
	if (val_1 == 0 && val_2 == 0) printf("NA\n");
	else if (val_1 == 1 && val_2 == 0) printf("YYMM\n");
	else if (val_1 == 0 && val_2 == 1) printf("MMYY\n");
	else if (val_1 == 1 && val_2 == 1) printf("AMBIGUOUS\n");
	return 0;
}

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

static const int MAX_N = 1000;
static const u_short MAX_ELEM = 10000;

int costToSort(u_short In[], u_short Sorted[], u_short size) {
    int i;
    bool visited[size];
    int cost = 0;
    u_short all_min = *min_element(In, In + size);

    for (i = 0; i < size; i++)
    {
        visited[i] = false;
    }

    for (i = 0; i < size; i++)
    {
        auto elem = In[i];
        auto cycle_min = elem;
        int cycle_sum = elem;
        u_short cycle_size = 1;
        auto cycle_idx = i;

        if (visited[cycle_idx])
            continue;

        while(true) {      
            visited[cycle_idx] = true;
            cycle_idx = lower_bound(Sorted, Sorted + size, elem) - Sorted;

            if (visited[cycle_idx])
                break;

            elem = In[cycle_idx];
            cycle_min = min(cycle_min, elem);
            cycle_sum += elem;
            cycle_size += 1;
        }

        cost += cycle_sum + min((cycle_size - 2) * cycle_min, cycle_min + (cycle_size + 1) * all_min);
    }

    return cost;
}

int main() {
    int N;

    cin >> N;

    u_short A[N];
    u_short B[N];

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

    sort(B, B + N);

    auto cost = costToSort(A, B, N);

    cout << cost;
    cout << endl;

    return 0;
}



Measured memory_bytes: 3164
#include <cstdio>
typedef long long ll;

ll Gcd(const ll a,const ll b){return b?Gcd(b,a%b):a;}

int T;
ll A,B,C,D;

bool Limited()
{
    if(A<B)return true;
    if(B>D)return true;
    if(B-C<2)return false;
    ll Gs=Gcd(B,D),L=A-B+1,R=A-C-1;
    ll Boundary=(L+Gs-1)/Gs*Gs;
    return Boundary<=R;
}

int main()
{
    for(scanf("%d",&T);T--;)
    {
        scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
        puts(Limited()?"No":"Yes");
    }
    return 0;
}

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

int main()
{
	string str;
	cin >> str;
	
	int K;
	cin >> K;
	
	for (int i=0;i<str.length();++i){	
		if (str[i] == 'a'){
			continue;
		}	
		if ('z' - str[i] + 1 <= K){
			K -= 'z' - str[i] + 1;
			str[i] = 'a';			
		}
	}
	
	K = K%26;
	str[str.length()-1] += K;

	cout << str << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

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

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

using namespace std;
using Long = long long;

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

	vector<int> a(n);

	for (int& v : a)
		cin >> v;

	bool can = true;
	vector<int> boxes(n);

	for (int i = n - 1; i >= 0; --i)
	{
		int currBalls = 0;
		
		for (int j = 2 * (i + 1) - 1; j < n; j += (i + 1))
			currBalls += boxes[j];

		if (a[i] == (currBalls + 1) % 2)
		{
			boxes[i] = 1;
		}
	}

	cout << count(begin(boxes), end(boxes), 1) << "\n";


	for (int i = 0; i < n; ++i)
	{
		if (boxes[i] == 1)
			cout << i + 1 << " ";
	}

	return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define r(i,n) for(int i=0;i<n;i++)
//#define rep(i, n) for(int i = 0; i < n; i++)
int gcd(int a,int b){
  if(b==0)return a;
  return gcd(b,a%b);
}


int main(void){
  int n,s;
  cin>>n>>s;
  int tmp,ans;
  cin>>ans;
  ans=abs(ans-s);
  for(int i=1;i<n;i++){
    cin>>tmp;
    tmp=abs(tmp-s);
    //cout<<"tmp "<<tmp<<endl;
    ans=gcd(ans,tmp);
    //cout<<ans<<endl;
  }

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


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

namespace ABC100_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var DN = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var D = DN[0];
            var N = DN[1];
            
            Console.WriteLine(Math.Pow(100, D) * N + ((N==100) ? 1 * Math.Pow(100,D): 0));
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {

	ll h, w;
	std::cin >> h >> w;

	vector<string> s(h);
	rep(i, 0, h) {
		std::cin >> s[i];
		std::cout << s[i] << endl;
		std::cout << s[i] << endl;
	}

	return 0;
}

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

int main()
{
    int a,p; // 変数の宣言
    cin >> a >> p; // 入力

    int sum = 3*a + p; // リンゴを全て砕き、かけらの合計を求める
    int apple_pie; // 作れるアップルパイの数

    apple_pie = sum / 2; // 整数同士の割り算は、小数点以下を切り捨て

    cout << apple_pie << endl; // 出力
}

Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,m=parseMap(split(readline()))
    ai=parseMap(split(readline()))
    bi=parseMap(split(readline()))
    rei=[0 for i in 1:a]
    den=[0 for i in 1:b]
    for i in 1:a
        rei[i]=ai[i]
    end
    for i in 1:b
        den[i]=bi[i]
    end
    sort!(ai)
    sort!(bi)
    xyc=[parseMap(split(readline())) for i in 1:m]
    ans=ai[1]+bi[1]
    for (x,y,c) in xyc
        ans=min(rei[x]+den[y]-c,ans)
    end
    println(ans)
end
main()

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

using namespace std;

int main(){
    string s;
    cin >> s;
    int a,cnt = 1000;
    for(int i=0;i<s.size()-2;i++){
      a = atoi(s.substr(i,3).c_str());
      cnt = min(cnt,abs(a-753));
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;
string s;
int K;
ll dp[105][4][2];

int main(void) {
    cin >> s;
    scanf("%d", &K);
    int n = (int)s.size();


    ll x = s[0] - '0'; 
    dp[0][1][0] = 1; //未満フラグ0のとき、先頭の出現数1が先頭の数字そのもの１つ
    if (x > 1) dp[0][1][1] = x-1; //未満フラグ1では、出現数1が1〜x-1通り
    dp[0][0][1] =1; //未満フラグ1の出現数0は確実に1通り。先頭が1未満はありえない。

    rep(i, 1, n) {
        ll d = s[i] - '0';
        dp[i][0][1] = 1; //未満フラグ1でかつ、出現数0はi桁目まで全て0を採用したときの1通り
        rep(j, 1, 4) {
          
          /* --- 0→0の遷移 --- 
          桁の数字はNのi桁目に忠実　*/
            if (d > 0) { // i桁目が0でないとき
                dp[i][j][0] = dp[i-1][j-1][0]; //出現数は1増える
            } else {
                dp[i][j][0] = dp[i-1][j][0]; //出現数に変化なし
            }
            
            /* --- 1→1の遷移 --- 
             桁の数字はなんでもよい */
          
           //1桁前の出現数が、現在の出現数-1のものに対し、1〜9までの組み合わせが発生する
          dp[i][j][1] += dp[i-1][j-1][1] * 9;
          
          // 0のときは、i-1桁目から出現数が変化しない
          dp[i][j][1] += dp[i-1][j][1];
            
            
            /* ---  0→1の遷移 --- 
            Nのi桁目の数字未満となる必要がある
            */
            if (d > 0) { // 0より大きいときしか更新が発生しない
            // i-1桁目の出現数が、現在の出現数-1のものに関して、1〜d-1までの組み合わせが発生する
                dp[i][j][1] += dp[i-1][j-1][0] * (d-1) ;
                
                // 0のとき、同じ出現数のまま引き継ぐ
                dp[i][j][1] += dp[i-1][j][0];
                
            }
        }
    }

    printf("%lld\n", dp[n-1][K][0]+dp[n-1][K][1]);

    return 0;
}



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

mymusic = []
mytime = []

for n in range(N):
    m, t = map(str,input().split())
    mymusic += [m]
    mytime += [int(t)]
    
music = input()

myindex = mymusic.index(music)

print(sum(mytime[myindex+1:]))

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

int main(){
  	int N;
  	cin >> N;
  	map<string,int> m;
    for(int i = 0;i < N;i++){
      string s;
      cin >> s;
      m[s]++;
    }

    int ma = 0;      //文字列の最大の登場回数
    for(auto a : m){
        ma = max(ma,a.second);
    }
  
    for(auto b : m){
        if(b.second != ma){
            //m.erase(b.first);
            continue;
        }
      cout << b.first << endl;
    }

    //for(auto c : m){
    //    cout << c.first << endl;
    //}
}

Measured memory_bytes: 25216