akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define pb push_back
#define fi first
#define se second
#define Mod 1000000007



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

    ll a[n][n];

    for(i=0;i<n;i++){
        for(j=0;j<n;j++) cin>>a[i][j];
    }

    

    ll q=pow(2,n);

    vector<ll> dp(q);
    for(i=0;i<q;i++) dp[i]=0;
    dp[0]=1;

    for(i=1;i<q;i++){
        ll cnt=0;
        vector<ll> v;
            for(j=0;j<n;j++){
            if(1 & i>>j) {
                cnt++;
                v.pb(j);
            }
        }

        for(j=0;j<v.size();j++){
            if(a[cnt-1][v[j]]==1) dp[i]+=dp[i^(1<<v[j])];
        }
        dp[i]%=Mod;
    }

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

Measured memory_bytes: 16640
#include<stdio.h>

int main(void){


    long long int a[10000], min=1000000, max=-1000000, sum=0;
    int n, i;
    scanf("%d",&n);


    for(i=0;i<n;i++){
    	
    	scanf("%lld",&a[i]);


        if(a[i] >= max){


            max = a[i];


        }


        if(a[i] <= min){


            min = a[i];


        }


        sum+=a[i];


    }


    printf("%lld %lld %lld\n",min, max, sum);


    return 0;


}

Measured memory_bytes: 680
#![allow(non_snake_case)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        n: u32,
        dn: [u32; n]
    );
    let mut dn = Vec::from(dn);
    // println!("{:?}", dn);
    dn.sort();
    // println!("{:?}", dn);
    let h: usize = (n as usize) / 2;
    let kotae = dn[h] - dn[h-1];
    println!("{}", kotae);
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=200005,p=1000000007;
int l[N],d[N];
inline int add(int a){return a<p?a:a-p;}
int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,i,a,b=0,m=0;
    scanf("%d",&n);
	d[0]=1;
    rep(i,1,n){
		scanf("%d",&a);
		if(a!=b){
			d[m+1]=(l[a]?add(d[m]+d[l[a]]):d[m]);
			l[b=a]=++m;
		}
	}
	printf("%d",d[m]);
    return 0;
}

Measured memory_bytes: 1792
N, K = map(int, input().split())
h_list = list(map(int, input().split()))

dp = [float("inf")] * N
dp[0] = 0

for i in range(N):
    for k in range(1, min(K+1, N-i)):
        dp[i + k] = min(dp[i + k], dp[i] + abs(h_list[i + k] - h_list[i]))
print(dp[N - 1])


Measured memory_bytes: 55008
from collections import deque
K = int(input())
que = deque(list(range(1, 10)))
for i in range(K):
    x = que.popleft()
    last = x % 10
    if last != 0:
        que.append(x*10 + last-1)
    que.append(x*10 + last)
    if last != 9:
        que.append(x*10 + last+1)
print(x)


Measured memory_bytes: 40688
function Main(input) {
const info = input.trim().split('\n');
const cr = info[0].split(' ').map(Number);
row = cr[0];
col = cr[1];
info.shift();

let arryA = [];
for (let i = 0; i <= row; i++){
arryA.push([]);
for (let j = 0; j <= col; j++){
arryA[i].push([]);
}
}

let arryB = [];
for (let i = 0; i < row; i++){
arryB.push(info[i].trim().split(' ').map(Number));
}

for (let i = 0; i < row; i++){
for (let j = 0; j < col; j++){
arryA[i][j] = arryB[i][j];
}
}

for (let i = 0; i < row; i++){
let colsum = 0;
for (let j = 0; j < col; j++){
colsum += arryA[i][j];
}
arryA[i][col] = colsum;
}

for (let i = 0; i <= col; i++){
let rowsum = 0;
for (let j = 0; j < row; j++){
rowsum += arryA[j][i];
}
arryA[row][i] = rowsum;
}

for (let i = 0; i < row + 1; i++){
result = arryA[i].join(' ');
console.log(result);
}


}

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


Measured memory_bytes: 19196
n = gets.chomp.to_i
a = []
a = gets.split.map(&:to_i)
a.sort!
cnt = 0
t = 0
#p a
for i in 0..a.length-2
    cnt += a[i]
   # p cnt
    if 2*cnt<a[i+1]
        t = i+1
    end
end
puts n-t

Measured memory_bytes: 9336
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <list>

using namespace std;

using lint = long long;
using ldouble = long double;

struct Data {
    int id, L, R;
    Data(int id, int L, int R) : id(id), L(L), R(R) {}
};

bool solve() {
    int N;
    cin >> N;
    if (N == 0) return false;

    list<Data> li;
    for (int i = 0; i < N; ++i) {
        char Q;
        cin >> Q;

        if (Q == 'W') {
            int id, l;
            cin >> id >> l;

            int pre = 0;
            for (auto itr = li.begin(); itr != li.end() && l > 0; ++itr) {
                if (itr->L > pre) {
                    int len = min(l, itr->L - pre);
                    li.emplace(itr, id, pre, pre + len);
                    l -= len;
                }
                pre = itr->R;
            }

            if (l > 0) li.emplace_back(id, pre, pre + l);
        } else if (Q == 'D') {
            int id;
            cin >> id;
            for (auto itr = li.begin(); itr != li.end();) {
                if (itr->id == id) {
                    itr = li.erase(itr);
                } else {
                    ++itr;
                }
            }
        } else {
            int pos;
            cin >> pos;

            bool judge = false;
            for (auto itr = li.begin(); itr != li.end(); ++itr) {
                if (itr->L <= pos && pos < itr->R) {
                    cout << itr->id << endl;
                    judge = true;
                    break;
                }
            }

            if (!judge) cout << -1 << endl;
        }
    }
    cout << endl;
    return true;
}

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



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rem(i, s, n) for (int i = (s); i >= (n); --i)
using ll = long long;
const int MOD = 1e9 + 7;

int main(){
    int n; cin >> n;
    vector<int> p(n), q(n);
    rep(i, 0, n) cin >> p[i];
    rep(i, 0, n) cin >> q[i];

    vector<int> vec(n);
    rep(i, 0, n) vec[i] = i+1;
    int a, b, i = 0;
    do{
        i++;
        if(vec == p) a = i;
        if(vec == q) b = i;
    }while(next_permutation(vec.begin(), vec.end()));

    cout << abs(a - b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int a,b;
  scanf("%d",&a);
  if(a>=1 && a<=9)
  {
   b=a-0;
   printf("%d",b);
  }
  else if(a>=10 && a<=99)
  {
    b=9;
    printf("%d\n",b);
  }
  else if(a>=100 && a<=999)
  {
    b=(a-100)+1+9;
    printf("%d\n",b);
  }
  else if(a>=1000 && a<=9999)
  {
    b=(999-100)+1+9;
    printf("%d\n",b);
  }
  else if(a>=10000 && a<=99999)
  {
    b=(999-100)+1+9+(a-10000)+1;
    printf("%d\n",b);
  }
  else if(a>=100000 && a<=999999)
  {
    b=(999-100)+1+9+(99999-10000)+1;
    printf("%d\n",b);
  }
  return 0;
}

Measured memory_bytes: 1704
#import math

N = int(input())
A = list(map(int, input().split()))

max_h = -1
ans = 0

for i in range(N):
    # 踏み台を設置する場合
    if max_h > A[i]:
        ans += max_h - A[i]
    elif max_h < A[i]:
        max_h = A[i]

print(ans)

Measured memory_bytes: 32192
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
using namespace std;

int main() {
	int n;
	vector<vector<char>>boad(10);
	boad[1] = { '.',',','!','?',' ' };
	char c = 'a';
	for (int i = 2; i < 10; ++i) {
		if (i != 7 && i != 9) {
			for (int j = 0; j < 3; ++j) {
				boad[i].push_back(c++);
			}
		}
		else for (int j = 0; j < 4; ++j)boad[i].push_back(c++);
	}
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		char b,pre='0';
		int count = 1;
		int sup = s.length();
		for (int l = 0; l < sup; ++l) {
			b = s[l];
			if (pre != b) {
				int num = pre - '0';
				if (num) printf("%c", boad[num][(count - 1) % boad[num].size()]);
				count = 1;
				pre = b;
			}
			else count++;
		}
		printf("\n");
	}
}

Measured memory_bytes: 3164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int N = sc.nextInt();
        int L = sc.nextInt();
        sc.nextLine();
        String s = sc.nextLine();
        String[] sp = s.split(" ");
        int[] arr = new int[N];
        for(int i = 0; i<N; i++) arr[i] = Integer.parseInt(sp[i]);

        int left = -1;
        int right = -1;
        boolean possible = false;
        for(int i = 1; i<N; i++){
            int sum = arr[i] + arr[i-1];
            if(sum >= L){
                possible = true;
                left = i-1;
                right = i;
                break;
            }
        }
        if(!possible){
            System.out.println("Impossible");
        }
        else{
            System.out.println("Possible");
            StringBuilder sb = new StringBuilder();
            for(int i = 1; i<=left; i++){
                sb.append(i);
                sb.append("\n");
            }
            for(int i = N-1; i>=right+1; i--){
                sb.append(i);
                sb.append("\n");
            }
            sb.append(right);
            System.out.println(sb);
        }
    }
}

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

int main(void){
	double a, b, c, d, dis;
	scanf("%lf %lf %lf %lf", &a, &b, &c, &d);
	dis = sqrt((a-c)*(a-c) + (b-d)*(b-d));
	printf("%.4f\n", dis);
	
	return 0;
}

Measured memory_bytes: 656
N, K, Q = map(int, input().split())
A = []
for i in range(Q):
    A.append(int(input()))
score = [0]*N
init_score = [K]*N
for i in A:
    score[i-1] += 1
final_score = [init_score[i]-Q+score[i] for i in range(N)]
for i in final_score:
    print("Yes") if i > 0 else print("No")

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

int main()
{
    int ans = 0;
    for (int i = 1; i <= 5; i++)
    {
        int x;
        cin >> x;
        if (x == 0)
            ans = i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
import sys
from collections import deque
stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


def make_tree_0index(N):
    edge_dic = {}
    for _ in range(N-1):
        x, y = na()
        x -= 1
        y -= 1
        if x in edge_dic:
            edge_dic[x].append(y)
        else:
            edge_dic[x] = [y]
        if y in edge_dic:
            edge_dic[y].append(x)
        else:
            edge_dic[y] = [x]
    return edge_dic


N = ni()
if N == 1:
    print(2)
    exit()
edge_dic = make_tree_0index(N)
ans = [[0] * 2 for _ in range(N)]
mod = 10 ** 9 + 7

parent_array = [-2] * N
parent_array[0] = -1
node1 = deque([0])
node2 = deque([0])

while(len(node1)):
    n = node1.popleft()
    for v in edge_dic[n]:
        if parent_array[v] == -2:
            parent_array[v] = n
            node1.append(v)
            node2.append(v)

while(len(node2)):
    n = node2.pop()
    white = 1
    black = 1
    for v in edge_dic[n]:
        if parent_array[n] == v:
            continue
        white = (white * (ans[v][0] + ans[v][1])) % mod
        black = black * ans[v][0] % mod
    ans[n][0] = white
    ans[n][1] = black


print((ans[0][0] + ans[0][1]) % mod)


Measured memory_bytes: 114024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n, k; cin >> n >> k;
    ll a[n]; zep(i, 0, n)cin >> a[i];
    
    ll ok = 1e9, ng = 0;
    while(ok - ng > 1){
    	ll mid = (ok + ng) / 2;
    	
    	ll cnt = 0;
    	zep(i, 0, n){
	    	cnt += (a[i] + mid - 1) / mid - 1;
    	}
    	
    	if(cnt <= k){
    		ok = mid;
    	}else{
    		ng = mid;
    	}
    }
    print(ok)
    
    return 0;
}

Measured memory_bytes: 5100
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b,c;
    cin>>a>>b>>c;
    if(a.back()==b[0]&&b.back()==c[0])YES;
    else NO;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b;
	vector<ll> c(4,0);
	FOR(i,0,3){
		cin>>a>>b;
		a--;b--;
		c[a]++;
		c[b]++;
	}
	SORT(c);
	vector<ll> v={1,1,2,2};
	if(c==v){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}

}


Measured memory_bytes: 256
import math

def isPrime(y):
  if y == 2 or y == 3:
    return True
  for i in range(2, int(math.sqrt(x) + 2)):
    if y % i == 0:
      return False
  return True

x = int(input())
while not isPrime(x):
  x += 1
print(x)

Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define N 222
int a[3][N],dp[3][N];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=1; i<=2; i++)
            for(int j=1; j<=n; j++)
                scanf("%d",&a[i][j]);
        memset(dp,0,sizeof dp);
        for(int i=1; i<=2; i++)
            for(int j=1; j<=n; j++)
            {
                dp[i][j]=max(dp[i-1][j]+a[i][j],dp[i][j-1]+a[i][j]);
            }
            printf("%d\n",dp[2][n]);
    }
    return 0;
}


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

#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<algorithm> 

using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) std::cout << (j ? s1 : s2) << endl;
# define YES(j) std::cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define rep(n,i) for(i = 0 ; i < n ; i++)

long long int pow(long long int i){
    if(i == 1) return 1;
    else return i*(pow(i-1)%((int)1e9+7));
}

int main()
{
    int n;cin >> n ;
    p(pow(n)%((int)1e9+7))
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
int n,q;
main()
{
	cin>>n>>q;
	vector<stack<int> >s(n);
	for(int i=0;i<q;i++)
	{
		int c;cin>>c;
		if(c==0)
		{
			int t,x;cin>>t>>x;
			s[t].push(x);
		}
		else if(c==1)
		{
			int p;cin>>p;
			if(!s[p].empty())cout<<s[p].top()<<endl;
		}
		else
		{
			int t;cin>>t;
			if(!s[t].empty())s[t].pop();
		}
	}
}


Measured memory_bytes: 4116
import sys

def judge(numbers):
  if sum(numbers) == 17:
    numbers.sort()
    if numbers[0] == 5 and numbers[0] == numbers[1]:
      return 'YES'

  return 'NO'

  
if __name__ == '__main__':
  numbers_str = input()
  print(judge([int(n) for n in numbers_str.split(' ')]))


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

int main() {
    int n,a;
    cin >> n >> a;
    n %= 500;
    if(n <= a) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main()
{
	vector<int>v(3);

	for (vector<int>::iterator it = v.begin(); it != v.end(); ++it)
		cin >> *it;
	sort(v.begin(), v.end());
	
	cout << v[2] * 10 + v[1] + v[0];

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		boolean check = false;
		for (int i = 0; i <= 9; i++) {
			int a = i;
			for (int j = 1; j <= 9; j++) {
				int b = j;
				if (a * b == N) {
					check = true;
					break;
				}
			}
		}
		if (check) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 27056
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
int main(void){
    // Your code here!
    string S;
    cin >> S;
    //0101
    int a = 0, b = 0;
    for(int i = 0; i < S.size(); i++){
        if(i % 2 == 0){
            if(S.at(i) == '0'){
                a++;
            }
        }else{
            if(S.at(i) == '1'){
                b++;
            }
        }
    }
    int ans = a + b;
    a = 0;
    b = 0;
    //1010
    for(int i = 0; i < S.size(); i++){
        if(i % 2 == 0){
            if(S.at(i) == '1'){
                a++;
            }
        }else{
            if(S.at(i) == '0'){
                b++;
            }
        }
    }
    
    ans = min(ans, a + b);
    
    cout << ans << endl;
}



Measured memory_bytes: 512
#include <stdio.h>

int main(){
    int n;
    
    scanf("%d",&n);
    
    if(n>=1 && n<=999){
        printf("ABC\n");
    }
    
    else if(n>999 && n<=1998){
        printf("ABD\n");
    }
    
    
    
    
    return 0;
}

Measured memory_bytes: 128
s = str(input())
n = int(len(s))
out = 'Yes' if s == s[::-1] and s[:int((n - 1)/2)] == s[:int((n - 1)/2)][::-1] \
               and s[int((n + 3)/2) - 1:n] == s[int((n + 3)/2) - 1:n][::-1] else 'No'
print(out)

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

int A[110000];
int B[110000];
int C[110000];
int dp[110000][3];

int main(){
    int n; cin>>n;
    for(int i = 0; i<n; ++i){
        scanf("%d%d%d", A+i, B+i, C+i);
    }
    for(int i = 0; i<n; i++){
        for(int j = 0; j < 3; j++){
            if(i == 0){
                if(j == 0) dp[i][j] = A[i];
                else if(j == 1) dp[i][j] = B[i];
                else dp[i][j] = C[i];
            }else{
                for(int k = 0; k < 3; k++){
                    if(j == k) continue;
                    if(j == 0) dp[i][j] = max(dp[i][j], dp[i-1][k] + A[i]);
                    else if(j == 1) dp[i][j] = max(dp[i][j] , dp[i-1][k] + B[i]);
                    else dp[i][j] = max(dp[i][j], dp[i-1][k] + C[i]);
                }
            }
        }
    }
    int ret = 0;
    ret = max(ret, dp[n-1][0]);
    ret = max(ret, dp[n-1][1]);
    ret = max(ret, dp[n-1][2]);
    cout<<ret;

}



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

#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    int x;
    cin >> x;
    string ans;
    if (x < 1200) {
    	ans = "ABC";
    }
    else {
    	ans = "ARC";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  int n,k;
  cin >> n >> k;
  if(2*k-1>n){
    cout << -1 << endl;
    return 0;
  }
  vector<int> a(n),b(n),c(n);
  for(int i=0;i<n;i+=2){
    a[i]=k; k++;
  }
  for(int i=1;i<n;i+=2){
    a[i]=k; k++;
  }
  for(int i=1;i<n;i+=2){
    b[i]=k; k++;
  }
  for(int i=0;i<n;i+=2){
    b[i]=k; k++;
  }
  for(int i=0;i<n;i++){
    c[i]=k; k++;
  }
  for(int i=0;i<n;i++){
    cout << a[i] << ' ' << b[i] << ' ' << c[i] << endl;
  }
}

Measured memory_bytes: 3456
#import sys
#input = sys.stdin.readline

n,q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(n-1)]
PX = [[int(x) for x in input().split()] for _ in range(q)]

Graph = [[] for _ in range(n+1)]
for a,b in AB:
    Graph[a].append(b)
    Graph[b].append(a)

#print(Graph)
Value = [0]*(n+1)
for p,x in PX:
    Value[p] += x
#print(Value)

q = [(1,0)]
while q:
    x,parent = q.pop()
    Value[x] += Value[parent]  #親の値を子に入れる
    for y in Graph[x]:
        if y == parent:
            continue
        q.append((y,x))
print(*Value[1:])

Measured memory_bytes: 116496
#!/usr/bin/env python3
#C
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a

N = int(input())
A = list(map(int,input().split()))
L=[0]*(N+2)
R=[0]*(N+2)
L[0] = A[0]
R[N-1] = A[N-1]
for i in range(1,N):
    L[i] = gcd(L[i-1],A[i])
for i in range(N-2,-1,-1):
    R[i] = gcd(R[i+1],A[i])

ans = 0
for i in range(N):
    ans = max(ans,gcd(L[i-1],R[i+1]))
print(ans)


Measured memory_bytes: 14436
import java.util.Scanner;

 class Main {
	static int[] aArrays = new int[30];
	static int gIndex = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			aArrays[i] = sc.nextInt();
			gIndex++;
		}
		int q = sc.nextInt();
		int[] mArrays = new int[300];
		int index = 0;
		for (int i = 0; i < q; i++) {
			mArrays[i] = sc.nextInt();
			index++;
		}
		
		for (int i = 0; i < index; i++) {
			if (isMatch(0, 0, mArrays[i])) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
		
	}
	
	public static boolean isMatch(int j, int S, int T) {
			if (S == T) {
				return true;
			}
			for (int i = j; i < gIndex; i++) {
				if (S + aArrays[i] == T) {
					return true;
				}
				if (isMatch(i + 1, S + aArrays[i], T)) {
					return true;
				}
			}
			return false;
		}
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

set<string> s;
int dp[1 << 16];
int place;
char sstr[20];

int dfs2(){
	if(sstr[place] == '-'){
		place++;
		return 1 - dfs2();
	}
	else if(sstr[place] == '('){
		place++;
		int a = dfs2();
		char c = sstr[place];
		place++;
		int b = dfs2();
		place++;
		if(c == '^')return a ^ b;
		else return a & b;
	}
	else{
		return sstr[place++] - '0';
	}
}

int f(){
	place = 0;
	return dfs2();
}

int investigate(string str){
	int ret = 0;
	REP(i,(1<<4)){
		REP(j,str.size()){
			if(str[j] >= 'a' && str[j] <= 'd'){
				sstr[j] = (char)('0' + ((i & (1 << (str[j] - 'a')))>0));
			}
			else{
				sstr[j] = str[j];
			}
		}
		ret |= (f() << i);
	}
	return dp[ret] = min(dp[ret],(int)str.size());
}


void check(string str){
	int cou = 0;
	REP(i,str.size()){
		if(str[i] == 'X')cou++;
	}
	int num = 1;
	REP(i,cou)num *= 6;
	REP(i,num){
		string now = "";
		int tmp = i;
		REP(j,str.size()){
			if(str[j] == 'X'){
				int seica = tmp % 6;
				if(seica < 4){
					now += (char)('a' + seica);
				}
				else{
					now += (char)('0' + (seica - 4));
				}
				tmp /= 6;
			}
			else{
				now += str[j];
			}
		}
		investigate(now);
	}
}

void dfs(string str){
	if(str.size() > 15 || s.count(str))return;
	s.insert(str);
	check(str);
	REP(i,str.size()){
		if(str[i] == 'X'){
			dfs(str.substr(0,max(0LL,i)) + "(X*X)" + str.substr(i+1));
			dfs(str.substr(0,max(0LL,i)) + "(X^X)" + str.substr(i+1));
			if(!(i > 0 && str[i-1] == '-'))dfs(str.substr(0,max(0LL,i)) + "-X" + str.substr(i+1));
		}
	}
}	
	

int main(){
	REP(i,1<<16)dp[i] = INF;
	dfs("X");
	string str;
	while(cin >> str,str[0] != '.'){
		cout << investigate(str) << endl;
	}
	return 0;
}



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

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        if(s.charAt(2)==s.charAt(3)&&s.charAt(4)==s.charAt(5)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 25300
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s1="CODEFESTIVAL2016";
  string s2; cin>>s2;
  int ans;
  for(int i=0;i<16;i++)
    if(s1.at(i)!=s2.at(i))ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int b1,b2,b3;
    cin >> b1 >> b2 >> b3;
    if(b1 == 1 && b2 == 1){
        cout << "Open" << endl;
    }else{
        if(b3 == 1){
            cout << "Open" << endl;
        }else{
            cout << "Close" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3088
// Last Change: 01/20/2019 21:02:12.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}

int main() {
  int AB, BC, CA;
  cin >> AB >> BC >> CA;

  ll ans = AB * BC / 2;
  cout << ans << endl;

  //LoopUntilZeroInpput();
}


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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  string a, b;
  cin >> a >> b;
  
  int al = a.size();
  int bl = b.size();
  if(al > bl) {
    cout << "GREATER" << endl;
    return 0;
  }
  else if(bl > al) {
    cout << "LESS" << endl;
    return 0;
  }
  else {
    if(a > b) {
      cout << "GREATER" << endl;
      return 0;
    }
    else if(b > a) {
      cout << "LESS" << endl;
      return 0;
    }
    else {
      cout << "EQUAL" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3656
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>

typedef long long ll;

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	string a;
	cin>>a;
	
	stack<char> s;
	int len = a.size();
	
	for(int i = 0 ;i<len ;i++){
		if(a[i] == '1'){
			s.push('1');
		}
		else if(a[i] == '0'){
			s.push('0');
		}
		else if(a[i] == 'B'){
			if(s.size() > 0){
				s.pop();
			}
		}
	}
	
	stack<char> s1;
	while(s.size()){
		s1.push(s.top());
		s.pop();
	}
	while(s1.size()){
		cout<<s1.top();
		s1.pop();
	}
	cout<<endl;
	return 0;
}




Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cmath>

using namespace std;
int P=998244353;
int main(){
	int N, M;
	cin >> N >> M;
	vector<vector<int>> v(N+1, vector<int>());
	for(int i=0;i<M;++i) {
		int v1, v2;
		cin >> v1 >> v2;
		v[v1].push_back(v2);
		v[v2].push_back(v1);
	}
	vector<int> res(N+1, 0);
	queue<int> s;
	s.push(1);
	while(!s.empty()) {
		int l = s.size();
		while(l--) {
			int dest = s.front();
			s.pop();
			for(auto& u:v[dest])
				if(res[u]==0) {
					res[u]=dest;
					s.push(u);
				}
		}
	}
	for(int i=2;i<=N;++i)
		if(res[i]==0) {cout << "No" << endl;}
	cout << "Yes\n";
	for(int i=2;i<=N;++i)
		cout << res[i] << '\n';
	return 0;
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	vector<VI> x(n, VI(2));
	rep(i,n) cin >>x[i][0] >>x[i][1];
	
	sort(all(x));

	map<pii, int> mp;
	rep(i, n) rep2(j,i+1,n){
		mp[pii(x[j][0]-x[i][0], x[j][1]-x[i][1])]++;
	}
	//for(auto x :mp) printf("%d:%d:%d, ",x.first.first,x.first.second,x.second); puts("");
	
	int mx=0;
	for(auto x :mp) mx = max(mx, x.second);
	cout << n -mx <<"\n";

}


Measured memory_bytes: 384
<?php
fscanf(STDIN, "%d %d", $n, $a);
$x = explode(' ', trim(fgets(STDIN)));

for ($i = 0; $i < $n; $i++) {
	$x[$i] -= $a;
}
$sum = array(0 => 0, $x[0] => 1);
for ($i = 1; $i < $n; $i++) {
	$tmp = array();
	foreach ($sum as $k => $v) {
		$tmp[$k + $x[$i]] = $v;
	}
	if (isset($tmp[$x[$i]])) {
		$tmp[$x[$i]]++;
	} else {
		$tmp[$x[$i]] = 1;
	}
	foreach ($tmp as $k => $v) {
		if (isset($sum[$k])) {
			$sum[$k] += $v;
		} else {
			$sum[$k] = $v;
		}
	}
}
echo $sum[0], "\n";

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

  struct input{
   public long N;
   public long M;
  }
  struct Cake{
   public long x;
   public long y;
   public long z;
   public Cake(long _x, long _y, long _z) { x = _x; y = _y; z = _z;}
  }

class MainClass {

  public static void Main (string[] args) {
    //var temp = Console.ReadLine().Split(' ').Select(int.Parse);
    var N = Console.ReadLine();
    var NChar = N.ToCharArray();
    if(int.Parse(N) % NChar.Select(x => Convert.ToInt32(x.ToString())).Sum() == 0){
      Console.WriteLine("Yes");
    }else{
      Console.WriteLine("No");
    }
  }
}

Measured memory_bytes: 11220
import sys
from collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f
from copy import *
from bisect import *	
from heapq import *
from math import *
from itertools import permutations 
 
def eprint(*args):
    print(*args, file=sys.stderr)
zz=1
 
#sys.setrecursionlimit(10**6)
if zz:
	input=sys.stdin.readline
else:	
	sys.stdin=open('input.txt', 'r')
	sys.stdout=open('all.txt','w')
def li():
	return [int(x) for x in input().split()]
def fli():
	return [float(x) for x in input().split()]	
def gi():	
	return [x for x in input().split()]
def fi():
	return int(input())
def swap(a,i,j):
	a[i],a[j]=a[j],a[i]	
def si():
	return list(input().rstrip())	
def mi():
	return 	map(int,input().split())	
def gh():
	sys.stdout.flush()
def graph(n,m):
	for i in range(m):
		x,y=mi()
		a[x].append(y)
		a[y].append(x)
def bo(i):
	return ord(i)-ord('a')
		


tt=1


while tt>0:
	tt-=1
	n=fi()
	p=n//1000*1000
	if p<n:
		p+=1000
	print(p-n)	
					






Measured memory_bytes: 77560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    public Program() { }


    Scanner cin;

    void myon()
    {
        cin = new Scanner();
        int D = cin.nextInt();
        Console.Write("Christmas");
        for (int i = D; i < 25; i++)
        {
            Console.Write(" Eve");
        }
        Console.WriteLine();
    }

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


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}


Measured memory_bytes: 11092
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int a,b,ans=0;
    scanf("%d %d",&a,&b);
    ans=a+b;
    ans=max(a+a-1,ans);
    ans=max(ans,b+b-1);
    printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 M = 1000000007;
ll mpow(ll a,ll b){ll res=1;while(b!=0){if(b&1)res=res*a%M;a=a*a%M;b=b>>1;}return res;}
ll mcomb(ll n,ll k){if(k>n/2)return mcomb(n,n-k);ll res=1;for(ll i=0;i<k;i++){res=res*(n-i)%M;res=res*mpow(k-i,M-2)%M;}return res;}
/*template*/

int main()
{
  ll a,b,h,m;cin>>a>>b>>h>>m;
  double ans=sqrt(a*a+b*b-2*a*b*cos(h*2*M_PI/12+m*2*M_PI/(12*60)-m*2*M_PI/60));
  printf("%.10lf",ans);
  return 0;
}


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

int main() {
	int N,b,c;
	cin >>N;
	vector<int> a(N);
	for(int i=0;i<N;i++){
		cin >>a[i];
	}
	c=0;
	b=1;
	for(int i=0;i<N;i++){
		if(a[i]==b){
			b++;
		}
		else{
			c++;
		}
	}

	if(b==1){
		cout <<-1<<endl;
	}
	else{
		cout <<c<<endl;
	}




}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

using namespace std;
int s;

int main() {
  cin >> s;
  if (s < 1200) {
    cout << "ABC" << endl;
  } else {
    cout << "ARC" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

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

int main(){
    int k;cin>>k;
    vector<int> v(k);
    for(int i=0;i<k;i++)v[i]=i+1;
    ll ans=0;int l=v.size();
    for(int i=0;i<l;i++)for(int j=0;j<l;j++)for(int k=0;k<l;k++){
       // if(i==j||i==k||j==k)continue;
        ans+=__gcd(v[i],__gcd(v[j],v[k]))*1ll;
    }
    cout<<ans;
}

Measured memory_bytes: 3632
#include <iostream>
#include <math.h>

using namespace std;

bool IsPrime(int num)
{
    if (num < 2)
        return false;
    else 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;
}

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

    while (IsPrime(X) == 0)
    {
        X++;
    }
    cout << X << endl;
}

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

int main()
{
    
    char s1;
    cin >> s1;
    if( isupper(s1) ){
        cout << "A" << endl;
    }
    else{
        cout << "a" << endl;
    }
    
      
    return 0;
}


Measured memory_bytes: 3620
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x=0,maxx=0;
		char I = 'I';
		char D = 'D';
		int a = sc.nextInt();
		String s = sc.next();
		char sa[] = s.toCharArray();
		for(int i=0;i<a;i++) {
			if(sa[i]==I) {
				x++;
			}
			else if(sa[i]==D) {
				x--;
			}
			if(x>maxx) {
				maxx = x;
			}
		}
		System.out.print(maxx);
		sc.close();
	}

}


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

int N;
int A[4];

int main(void) {
	cin >> N;

	int m = 1000;
	for (int i = 0; i < 4; ++i) {
		A[i] = N / m;
		N %= m;
		m /= 10;
	}

	string sig;
	if (A[0] + A[1] + A[2] + A[3] == 7)
		sig = "+++";
	else if (A[0] + A[1] + A[2] - A[3] == 7)
		sig = "++-";
	else if (A[0] + A[1] - A[2] + A[3] == 7)
		sig = "+-+";
	else if (A[0] + A[1] - A[2] - A[3] == 7)
		sig = "+--";
	else if (A[0] - A[1] + A[2] + A[3] == 7)
		sig = "-++";
	else if (A[0] - A[1] - A[2] + A[3] == 7)
		sig = "--+";
	else if (A[0] - A[1] + A[2] - A[3] == 7)
		sig = "-+-";
	else if (A[0] - A[1] - A[2] - A[3] == 7)
		sig = "---";

	for (int i = 0; i < 3; ++i)
		cout << A[i] << sig[i];
	cout << A[3] << "=7\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
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; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

ll a[220000];
ll ppp[1100000],ch[1100000];
int main(){
    ll n;
    cin>>n;
    rep(i,0,n){cin>>a[i];ppp[a[i]]++;ch[a[i]]++;}
    //sort(a,a+n);
    rep(i,0,n){
        if(ppp[a[i]]&&ch[a[i]]){
            ch[a[i]]=0;
            for(ll j=2*a[i];j<=1e6;j+=a[i])ppp[j]=0;
        }
    }
    ll ans=0;
    rep(i,0,1e6+1){
        if(ppp[i]==1)ans++;
    }
    cout<<ans;
}



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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  

double eps = .000000001;
const long long maxx = 1000000000000000000LL;
int main(){
  prep();
  int n;
  cin >> n;
  int arr[n];
  long long sums[n];
  for (int i=0; i<n; i++){
      cin >> arr[i];
      sums[i] = arr[i];
      if (i > 0){
          sums[i] += sums[i-1];
      }
  }
  long long minnest = maxx;
  for (int i=0; i<n; i++){
      long long suma, sumb;
      suma = sums[i];
      sumb = sums[n-1]-sums[i];
      minnest = min(minnest, abs(suma-sumb));
      
  }
  cout << minnest;
  return 0; 
}

Measured memory_bytes: 2560
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 16
using namespace std;
char str[MAXN+5];
int sum[MAXN+5];
int main()
{
	scanf("%s",str);
	int len=strlen(str);
	sum[0]=str[0]-'0';
	for(int i=1;i<len;i++)
		sum[i]=sum[i-1]+str[i]-'0';
	int ans=0;
	if(str[len-1]-'0'!=0)
		ans=sum[len-1];
	for(int i=len-1;i>=0;i--)
		if(str[i]!='0')
			ans=max(ans,sum[i]+9*(len-i-1)-1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var arg string
	_, err := fmt.Scan(&arg)

	if err != nil {
		panic(err)
	}

	number := 0

	for _, v := range []rune(arg) {
		switch v {

		case '+':
			number++
		case '-':
			number--
		}
	}

	fmt.Println(number)

}


Measured memory_bytes: 512
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;

typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

//constexpr long long MOD = (ll) 1e9+7;
constexpr long long MOD = 998244353;

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;
}

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}


void solve() {
	ll n, m;
	cin >> n >> m;
	Array a(n);
	REP(i, n)cin >> a[i];
	sort(all(a), greater<ll>());
	ll sum = 0;
	REP(i, n) sum += a[i];
	REP(i, m) {
		if (a[i] * m * 4 < sum) {
			cout << "No" << en;
			return;
		}
	}
	cout << "Yes" << en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 256
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <iterator>
#include <locale>
#include <memory>
#include <stdexcept>
#include <utility>
#include <string>
#include <fstream>
#include <ios>
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <streambuf>
#include <complex>
#include <numeric>
#include <valarray>
#include <exception>
#include <limits>
#include <new>
#include <typeinfo>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdlib>
#include <cstddef>
#include <cstdarg>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <cwchar>
#include <cwctype>
using namespace std;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
using ll = long long;
using ull = unsigned long long;

#define ALL(c) (c).begin(), (c).end()
#define CLEAR(v) memset(v,0,sizeof(v))
#define MP(a,b) make_pair((a),(b))
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ABS(a) ((a)>0?(a):-(a))
template<class T> T MIN(const T& a, const T& b) { return a < b ? a : b; }
template<class T> T MAX(const T& a, const T& b) { return a > b ? a : b; }
template<class T> void MIN_UPDATE(T& a, const T& b) { if (a > b) a = b; }
template<class T> void MAX_UPDATE(T& a, const T& b) { if (a < b) a = b; }

constexpr int mo = 1000000007;
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	std::ios::sync_with_stdio(false);
	char ch;
	cin >> ch;
	cout << char(ch + 1) << endl;
}


Measured memory_bytes: 636
import sys
import math

n = int(input())

# str_n = str(n)

# harshad = 0
# for i in range(len(str_n)):
#     harshad += int(str_n[i])

# print("Yes") if n%harshad == 0 else print("No")

harshad = 0
num = n
for i in range(len(str(n))):
    harshad += num % 10
    num = math.floor(num / 10)

print("Yes") if n%harshad == 0 else print("No")

Measured memory_bytes: 3060
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

n = int(readline())
a = sorted(map(int, readline().split()))
ans = 1
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        quit()
print(ans)

Measured memory_bytes: 21772