akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdlib>
using namespace std;

void top3()
{
    int temp;
    int bil[10];
    int i = 0;

    while(i<10)
    {
        cin >> bil[i];
        if(bil[i] >=0 && bil[i] <= 10000)
            i++;
        else
            exit(1);
    }
    for(int i = 0; i < 10-1; i++)
    {
        for(int j = i+1; j < 10; j++ )
        {
            if(bil[j] > bil[i])
            {
                temp = bil[i];
                bil[i] = bil[j];
                bil[j] = temp;
            }
        }
    }
    for(int i = 0; i < 3; i++)
    {
        cout << bil[i]<< endl;
    }
}


int main () {

    top3();

return 0;

}

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

int main()
{
    char a[10] = "AKIHABARA";
    char b[50];
    int i, j = 0, n = 0,k = 1;
    gets(b);
    i = strlen(b);
    if(i>9)
    {
        printf("NO");
    }
    else
    {
        while(a[j]!='\0')
        {
            if(a[j]!=b[n]&&a[j]=='A')
            {
                j++;
                continue;
            }
            else if(a[j]==b[n])
            {
                j++;
                n++;
                continue;
            }
            else
            {
                k = 0;
                break;
            }
        }
        if(k==0||n!=i)
        printf("NO");
        else
        printf("YES");
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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; }
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string ans = "";
    if(sy < ty){
        rep(i, ty-sy) ans += 'U';
        if(sx < tx) rep(i, tx-sx) ans += 'R';
        else rep(i, sx-tx) ans += 'L';
        rep(i, ty-sy) ans += 'D';
        if(sx<tx) rep(i, tx-sx) ans += 'L';
        else rep(i, sx-tx) ans += 'R';
        if(sx<tx) ans += 'L';
        else ans += 'R';
        rep(i, ty-sy+1) ans += 'U';
        if(sx<tx) rep(i, tx-sx+1) ans += 'R';
        else rep(i, sx-tx+1) ans += 'L';
        ans += 'D';
        if(sx<tx) ans += 'R';
        else ans += 'L';
        rep(i, ty-sy+1) ans += 'D';
        if(sx<tx) rep(i, tx-sx+1) ans +='L';
        else rep(i, sx-tx+1) ans += 'R';
        ans += 'U';
    }else{
        rep(i, sy-ty) ans += 'D';
        if(sx < tx) rep(i, tx-sx) ans += 'R';
        else rep(i, sx-tx) ans += 'L';
        rep(i, sy-ty) ans += 'U';
        if(sx<tx) rep(i, tx-sx) ans += 'L';
        else rep(i, sx-tx) ans += 'R';
        if(sx<tx) ans += 'L';
        else ans += 'R';
        rep(i, sy-ty+1) ans += 'D';
        if(sx<tx) rep(i, tx-sx+1) ans += 'R';
        else rep(i, sx-tx+1) ans += 'L';
        ans += 'U';
        if(sx<tx) ans += 'R';
        else ans += 'L';
        rep(i, sy-ty+1) ans += 'U';
        if(sx<tx) rep(i, tx-sx+1) ans +='L';
        else rep(i, sx-tx+1) ans += 'R';
        ans += 'D';
    }

    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, x, y;
int ax[1000], ay[1000];
int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    cin >> n >> m >> x >> y;
    for (int i = 0 ; i < n; i++)
        cin >> ax[i];
    for (int i = 0 ; i < m; i++)
        cin >> ay[i];
    sort(ax, ax+n); sort(ay, ay+m);
    if (ax[n-1] >= ay[0]) {
        cout << "War\n";
        return 0;
    }
    else {
        for (int i = x+1; i <= y; i++) {
            if (i == ay[0]) {
                cout << "No War\n";
                return 0;
            }
        }
    }
    cout << "War\n";
    return 0;
}


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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define FF first
#define SS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXL = 91;
const int MOD = 1e9 + 7;

LL _f[MAXL+3], *f = _f + 3;
int q;
LL n, m;
int cl;
LL ans;

void init ();
void input ();
void inputq ();
void work ();

PII getans ();

void dfs ( LL x, LL y, int nl );



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
	
	f[-1] = 1, f[0] = 0, f[1] = 1;
	lp ( i, 2, MAXL ) f[i] = f[i-1] + f[i-2];
}

void input ()
{
	// input method
	
	scanf ( "%d", &q );
}

void inputq ()
{
	// input query
	
	scanf ( "%lld%lld", &n, &m );
}

void work ()
{
	// main work
	
	lp ( i, 0, q ){
		inputq ();
		
		if ( n > m ) swap ( n, m );
		if ( n == 1 ){
			printf ( "1 %d\n", SC ( int, m % MOD ) );
			continue;
		}else if ( n == 2 && m == 2 ){
			printf ( "1 4\n" );
			continue;
		}
		
		PII ans1 = getans ();
		swap ( n, m );
		PII ans2 = getans ();
		PII ans = qmax ( ans1, ans2 );
		if ( ans1.FF == ans2.FF ) ans.SS = ( ans1.SS + ans2.SS ) % MOD;
		printf ( "%d %d\n", ans.FF, ans.SS );
	}
}



PII getans ()
{
	lp ( i, 0, MAXL ){
		if ( f[i] > n || f[i+1] > m ){
			cl = i - 2;
			break;
		}
	}
	
	if ( cl == 1 ) return MP ( 1, qmin ( n, m ) );
	
	ans = 0;
	dfs ( 1, 2, 1 );
	dfs ( 1, 3, 1 );
	
	return MP ( cl, SC ( int, ans ) );
}



void dfs ( LL x, LL y, int nl )
{
	int dl = cl - nl;
	LL vx = x * f[dl-1] + y * f[dl], vy = x * f[dl] + y * f[dl+1];
	if ( vx > n || vy > m ) return;
	
	if ( nl == cl - 1 ){
		( ans += ( m - x ) / y ) %= MOD;
	}else{
		dfs ( y, x+y, nl+1 );
		
		LL vx = y, vy = x + ( y << 1 );
		int dl = cl - nl - 1;
		LL tx = vx * f[dl-2] + vy * f[dl-1], ty = vx * f[dl-1] + vy * f[dl];
		if ( ty <= n && tx + ty <= m ){
			( ans += ( m - tx ) / ty ) %= MOD;
		}
	}
}

Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <utility> // pairとか
#include <vector>
#include <array>
#include <list>
#include <deque>
#include <map>
#include <algorithm> // sortとか findとか
#include <functional> // algorithmに渡せる関数
#include <cmath>
#include <cstdio>
#include <numeric> // gcd,lcmとか
using namespace std;
#define rep(iter, beg, end, step) for (long(iter) = (beg); (iter) < (end); (iter) += (step))

int main() {
	int a,b,c;
	cin >> a;
	cin >> b;
	cin >> c;
	cout << (a + b < c ? "No\n" : "Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>
#define MAXN 1000
#define hlq 1000000007
#define pii pair<int,int>

using namespace std;
bool vis[MAXN+80];
int pri[MAXN];
int num[MAXN];
void chk(int x)
{
	int j=1;
	while(x>1)
	{
		while(x%pri[j]==0)
		{
			x/=pri[j];
			num[j]++;
		}
		j++;
	}
	return ;
}
int main()
{
	long long ans=1;
	int i,j,n;
	scanf("%d",&n);
	for(i=2;i<=n;i++)
		if(vis[i]==0)
		{
			pri[++pri[0]]=i;
			for(j=i*i;j<=n;j+=i)
				vis[j]=1;
		}
	for(i=1;i<=n;i++)
		chk(i);
	for(i=1;i<=pri[0];i++)
		ans=ans*(num[i]+1)%hlq;
	printf("%d",(int)ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

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

	long long ans = 0;

	while (n / k)
	{
		n %= k;
	}

	if (n < abs(n - k))	cout << n << endl;
	else cout << abs(n - k) << endl;

	return 0;
}

Measured memory_bytes: 3624
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let n: u32 = s.trim().parse().ok().unwrap();
    let ans: u32 = (n + 1) * 100 / 108;
    if ans * 108 / 100 == n {
        println!("{}", ans)
    } else {
        println!(":(")
    }
}

Measured memory_bytes: 4352
import sys

N=int(input())
if N==1:
  print("a")
  sys.exit()
  
old_list=[[0]]
for i in range(1,N):
  new_list=[]
  for l in old_list:
    maxl=max(l)
    for k in range(maxl+2):
      new_list.append(l+[k])
  old_list=new_list
    
#print(old_list)
llist=["a","b","c","d","e","f","g","h","i","j"]

for ll in old_list:
  #print(ll)
  str_list=[]
  for elm in ll:
    str_list.append(llist[elm])
  print("".join(str_list))

Measured memory_bytes: 27340
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e9 + 7;
int si[8] = {-1,0,1,-1,1,-1,0,1};
int sj[8] = {-1,-1,-1,0,0,1,1,1};

int main() {
  string s,t;
  cin >> s >> t;

  int ans = M;
  for (int i = 0; i < s.size()-t.size()+1; i++){
    int c = 0;
    for (int j = 0; j < t.size(); j++) if (s[i+j] != t[j]) c++;
    ans = min(ans, c);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

vector<P> g[100010];
int n;

int solve(){
	int min_cost[100010]; REP(i,0,n) min_cost[i] = INF;
	deque<P> qu; qu.push_front({1,1}); min_cost[1] = 0;
	
	while(!qu.empty()){
		auto p = qu.front(); qu.pop_front();
		
		for(auto e:g[p.second]){
			if(p.first + e.second >= min_cost[e.first]) continue;
			min_cost[e.first] = p.first + e.second;
			
			if(e.second) qu.push_back({min_cost[e.first], e.first});
			else qu.push_front({min_cost[e.first], e.first});
		}
	}
	
	return min_cost[0];
}

int main(){
	cin >> n;
	
	REP(i,0,n){
		g[i].push_back({(i+1)%n, 1});
		g[i].push_back({(i*10)%n, 0});
	}
	
	cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define eps 1e-9
#define oo 1e7+5

using namespace std;

typedef unsigned long long ull;
typedef vector<pair<int,pair<int,int>>> dirgraph;
typedef vector<vector<int>> graph;

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

	string s;
	cin>>s;
	int len=s.length();
	
	string ans="";
	for (int i = 0; i < len; i++)
	{
		if(i>0 && s[i]=='?' && ans[i-1]=='P')
			ans+='D';
		else if(i<len-1 && s[i]=='?' && (s[i+1]=='D'||s[i+1]=='?'))
			ans+='P';
		else if(s[i]=='?')
			ans+='D';
		else ans+=s[i];
	}
	
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3844
#include<stdio.h>

int main(){
  int n,q,i,j,count=0,l,m,r;

  scanf("%d",&n);
  int S[n];
  for(i=0 ; i<n ; i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  int T[q];
  for(j=0 ; j<q ; j++){
    scanf("%d",&T[j]);
  }

for(i=0 ; i<q ; i++){
  l=0;
  r=n;

  while(l<r){
    m=(l+r)/2;
if(T[i] == S[m]){
  count++;
  break;
}
if(T[i]>S[m]){
  l = m + 1;
}
if(T[i]<S[m]){
  r = m;
}
}
}
printf("%d",count);
printf("\n");

return 0;
}



Measured memory_bytes: 2272
from collections import defaultdict
from heapq import heappop, heappush
import sys
input = sys.stdin.readline


def dijkstra1(V, n, inf, source):
    # O(ElogV)

    dist = [inf] * (n+1)
    dist[source] = 0
    q = [(0, source)]

    while q:
        cost, u = heappop(q)
        if dist[u] < cost:
            continue
        for c, v in V[u]:
            if dist[v] > dist[u] + c:
                dist[v] = dist[u] + c
                heappush(q, (dist[v], v))

    return dist


def solve():
    n, m, s, t = map(int, input().split())
    V1 = defaultdict(list)
    V2 = defaultdict(list)
    INF = 10**20

    for _ in range(m):
        u, v, a, b = map(int, input().split())
        V1[u].append((a, v))
        V1[v].append((a, u))
        V2[u].append((b, v))
        V2[v].append((b, u))

    d1 = dijkstra1(V1, n, INF, s)
    d2 = dijkstra1(V2, n, INF, t)

    v = 0
    ans = []
    for i in range(1, n+1)[::-1]:
        v = max(v, 10**15-d1[i]-d2[i])
        ans.append(v)

    for i in ans[::-1]:
        print(i)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 119384
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 20 16:39:29 2018

@author: Yuya
"""

S = list(map(int, input()))

#max_S = 0
#count = 1
#flag = 0
#
#for i in range(1, len(S)):
#    if S[i-1]==S[i]:
#        count += 1
#    else:
#        if max_S < count:
#            max_S = count
#        count = 1
#        flag += 1
#
#if max_S < count:
#    max_S = count
#
#if flag < 2:
#    max_S -= 1

N = len(S)


min_T = N
for i in range(1, N):
    if S[i]!=S[i-1]:
        min_T = min(min_T, max(i, N-i))

print(min_T)





Measured memory_bytes: 3956
#include<stdio.h>
#define Min 1
#define Max 1000000000

int main(){
  int a,b,c,r;
  scanf("%d %d",&a,&b);
  if(Min<=a&&Max>=a){
    if(Min<=b&&Max>=b){ 
      if(a<b){
	c=a;
	a=b;
	b=c;}
      r=a%b;
      while(r!=0){
	a=b;
	b=r;
	r=a%b;
      }
      printf("%d\n",b);
    }
    else printf ("x,yの入力が範囲外です\n");
  }
  else printf ("x,yの入力が範囲外です\n");
  return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
const int maxn=5000001,INF=1e9;
int n,m,k,c,now,d,pos,siz,car,a[maxn];
int main() 
{
	cin>>n>>c>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	pos=a[1]+k;siz=1;
	for(int i=1;i<=n;)
	{
		//cout<<"in "<<i<<endl;
		while(a[i+1]<=pos&&i+1<=n&&siz+1<=c)
		{
			i++,siz++;
		//	cout<<i<<" "<<siz<<endl;
		}
		if(i>n)break;
		i++;car++;pos=a[i]+k;siz=1;
	//	cout<<i<<" "<<car<<" "<<pos<<endl;
	}
	cout<<car;
}
	
/*
意思就一堆线段，线段长度是k，然后每个点可以标记d个线段，求最少点数量
快快活活地贪心，总之总是要把人接上的，那么按照右端点排序，能接就接，不能接就走。

*/

Measured memory_bytes: 3952
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
const int MAXN=2e5+5;
int f[4000+3][4000+4];
int n;
const int MOD=1e9+7;
int mo(int x,int y)
{
    return x+y>=MOD?x+y-MOD:x+y;
}
int mu(int x,int y)
{
    return 1ll*x*y%MOD;
}
int sub(int x,int y)
{
    return x<y?x-y+MOD:x-y;
}
int ksm(int x,int y)
{
    int res=1;
    for(;y;y>>=1,x=mu(x,x))
    if(y&1) res=mu(res,x);
    return res;
}
int a[MAXN],b[MAXN];
int jc[MAXN],jcn[MAXN];
void init(int n)
{
    for(int i=jc[0]=1;i<=n;i++) 
    jc[i]=mu(jc[i-1],i);
    jcn[n]=ksm(jc[n],MOD-2);
    for(int i=n;i;i--)
    jcn[i-1]=mu(jcn[i],i);
}
int C(int n,int m)
{
    return n<m?0:mu(jc[n],mu(jcn[n-m],jcn[m]));
}

int main()
{
    init(8000);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
    scanf("%d%d",&a[i],&b[i]);
    f[2000-a[i]][2000-b[i]]++;
    }
    for(int i=0;i<=4000;i++)
    for(int j=0;j<=4000;j++)
    {
        if(i) f[i][j]=mo(f[i][j],f[i-1][j]);
        if(j) f[i][j]=mo(f[i][j],f[i][j-1]);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    ans=sub(ans,C((a[i]+b[i])<<1,a[i]+a[i]));
    for(int i=1;i<=n;i++)
    {
        ans=mo(ans,f[2000+a[i]][2000+b[i]]);
    }
    printf("%d\n",mu(ans,ksm(2,MOD-2)));
    return 0;
}

Measured memory_bytes: 64384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <iomanip>

using namespace std;

int main() {
    int n,m;
    cin>>n>>m;
    if (n>=m){
        cout << 0;
        return 0;
    }
    vector<int> x;
    int t;
    for(int i=0;i<m;++i){
        cin>>t;
        x.push_back(t);
    }
    sort(x.begin(),x.end());
    
    vector<int> a;
    for(int i=0;i<m-1;++i){
        a.push_back(x[i+1]-x[i]);
    }
    sort(a.begin(),a.end());
    int sum=0;
    for(int i=0; i<m-n;++i){
        sum+=a[i];
    }
    cout<<sum;
}

Measured memory_bytes: 1400
#include <stdio.h>
#include <vector>

int main() {
    int n, m, v, sum;
    scanf("%d %d", &n, &m);
    std::vector<int> mat(n*m), vec(m);
    for(int i=0; i<n; i++) {
        for(int j=0; j<m; j++) {
            scanf("%d", &v);
            mat[i*m+j] = v;
        }
    }
    for(int i=0; i<m; i++) {
        scanf("%d", &v);
        vec[i] = v;
    }
    for(int i=0; i<n; i++) {
        sum=0;
        for(int j=0; j<m; j++) {
            sum += (mat[i*m+j] * vec[j]);
        }
        printf("%d\n", sum);
    }
}


Measured memory_bytes: 2764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

double solve(double x, int y) {
	if (y == 1) return x;
	else {
		if (y % 2 == 0) return solve(x * 2, y / 2);
		else return solve(x * 2, y / 2) + x;
	}
}

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

	 int n, m, d; cin >> n >> m >> d;
	 double num = double(n - d);
	 if (d != 0) num *= 2;
	 num /= double(n);
	 num /= double(n);
	 cout << setprecision(15) << num * double(m - 1) << endl;

	return 0;
}

Measured memory_bytes: 256
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split('\n');
    for (var i = 0; i < inputs.length; i++) {
        if (inputs[i] === '0 0') {
            break;
        }
        var input = inputs[i].split(' ').map(Number).sort(function(a, b) {
            return a - b;
        }).join(' ');
        console.log(input);
    }
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 19412
def Reflection(point, begin, end):
	tmp = (point-begin) / (end-begin)
	return tmp.conjugate() * (end-begin) + begin

a, b, c, d = map(int, input().split())
q, r = complex(a, b), complex(c, d)
n = int(input())
for _ in range(n):
	x, y = map(int, input().split())
	p = complex(x, y)
	refl = Reflection(p, q, r)
	print(refl.real, refl.imag)


Measured memory_bytes: 5636
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    int A = 0, B = 0;
    for(int i = (int)Math.sqrt(N); i >= 1 ; i--){
      if(N%i == 0){
        A = i;
        B = (int)(N/i);
        break;
      }
    }
    System.out.println(calc(A,B));
  }
  public static int calc(int A, int B){
    int C = A > B ? A : B;
    int ans = 0;
    while(C > 0){
      C /= 10;
      ans++;
    }
    return ans;
  }
}

Measured memory_bytes: 24020
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    while 1:
        n = I()
        if n == 0:
            quit()
        a = LI()
        m = sum(a)/n
        c = 0
        for i in range(n):
            if a[i] <= m:
                c += 1
        print(c)
    return

#B
def B():
    while 1:
        n = I()
        if n == 0:
            quit()
        t = [0 for i in range(24*3600)]
        for i in range(n):
            x,y = input().split()
            x = list(map(int, x.split(":")))
            y = list(map(int, y.split(":")))
            l = x[0]*3600+x[1]*60+x[2]
            r = y[0]*3600+y[1]*60+y[2]
            t[l] += 1
            t[r] -= 1
        ans = 0
        for i in range(24*3600-1):
            t[i+1] += t[i]
            ans = max(ans, t[i])
        print(ans)
    return
#C
def C():
    n = I()
    if n == 0:
        print(1)
    elif n == 1:
        print(2)
    elif n == 2:
        print(1)
    else:
        print(0)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    C()



Measured memory_bytes: 8248
#include <stdio.h>
#include <limits.h>

int main(int argc, char** argv)
{
	int i, num;
	long  R[200000];

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

	long min_value = R[0];
	long max = LONG_MIN;

	for (i = 1; i < num; i++) {
		int val = R[i] - min_value;
		if (max < val) {
			max = val;
		}

		if (min_value > R[i]) {
			min_value = R[i];
		}
	}
	printf("%ld\n", max);
	return 0;
}

Measured memory_bytes: 2160
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int n;
  cin >> n;
  
  int a[n];
  REP(i,n){
    cin >>  a[i];
  }
  
  int ans = 0;
  REP(i,n-1){
    FOR(j,i+1,n){
      ans = max(ans,abs(a[j]-a[i]));
    }
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <stdint.h>
#define ll long long
#define oku7 1000000007
using namespace std;


//う ず ま き
int x=-1, y=0, d=1;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { -1, 0, 1, 0 };

const int MAXINT = 2147483647 / 3;
int G[201][201];

int main(){
	int N, M, R;
	cin >> N >> M >> R;
	vector<int> iku;
	for (int i = 0; i < R; i++){
		int tmp;
		cin >> tmp;
		iku.push_back(tmp);
	}
	for (int i = 0; i < 201; i++){
		for (int j = 0; j < 201; j++){
			G[i][j] = MAXINT;
		}
//      	G[i][i] = 0;
	}
	for (int i = 0; i < M; i++){
		int a, b, c;
		cin >> a >> b >> c;
		G[a][b] = G[b][a] = c;
	}


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

	sort(iku.begin(), iku.end());
	int ans = MAXINT;
  	do {
		int tmp = 0;
		for (int i = 0; i < (int)iku.size() - 1; i++){
			tmp += G[iku[i]][iku[i + 1]];
		}
		if (tmp < ans) ans = tmp;
	}
	while (next_permutation(iku.begin(), iku.end()));
	cout << ans << "\n";

	return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n;
    string s,t;
    cin >> n >> s >> t;
    rep(i,0,n+1){
        string u=s.substr(0,i)+t;
        bool ok=true;
        rep(j,0,n){
            if(s[j]!=u[j]){
                ok=false;
                break;
            }
        }
        if(!ok) continue;
        rep(j,0,n){
            if(t[n-j-1]!=u[u.size()-j-1]){
                ok=false;
                break;
            }
        }
        cout << u.size() << endl;
        return;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        l: u64, r: u64
    }
    let ll = ceil_div(l, 2019) * 2019;
    if l <= ll && ll <= r {
        println!("0");
    } else {
        let lm = l % 2019;
        let rm = r % 2019;
        let mut ret = 2018;
        for i in lm..rm+1 {
            for j in i+1..rm+1 {
                ret = std::cmp::min(ret, i * j % 2019);
            }
        }
        println!("{}", ret);
    }
}

#[allow(dead_code)]
fn ceil_div(x: u64, y: u64) -> u64 {
    (x + y - 1) / y
}

Measured memory_bytes: 4352
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    P, Q, R = LI()

    ans = P + Q + R - max(P, Q, R)
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10064
tile = list(input())

if len(tile) == 1:
  print(0)
else:
  tile_odd = tile[0::2]
  tile_odd_0 = tile_odd.count("0")
  tile_odd_1 = tile_odd.count("1")
  tile_even = tile[1::2]
  tile_even_0 = tile_even.count("0")
  tile_even_1 = tile_even.count("1")
  ans = min(tile_odd_0 + tile_even_1, tile_odd_1 + tile_even_0)
  print(ans)

Measured memory_bytes: 4652
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

template<int_fast64_t MOD> struct modint{
    using i64=int_fast64_t;
    i64 a;
    modint(const i64 a_=0): a(a_){
        if(a>MOD) a%=MOD;
        else if(a<0) (a%=MOD)+=MOD;
    }
    modint inv(){
        i64 t=1, n=MOD-2, x=a;
        while(n){
            if(n&1) (t*=x)%=MOD;
            (x*=x)%=MOD;
            n>>=1;
        }
        modint ret(t);
        return ret;
    }
    bool operator==(const modint x) const{return a==x.a;}
    bool operator!=(const modint x) const{return a!=x.a;}
    modint operator+(const modint x) const{
        return modint(*this)+=x;
    }
    modint operator-(const modint x) const{
        return modint(*this)-=x;
    }
    modint operator*(const modint x) const{
        return modint(*this)*=x;
    }
    modint operator/(const modint x) const{
        return modint(*this)/=x;
    }
    modint operator^(const lint x) const{
        return modint(*this)^=x;
    }
    modint &operator+=(const modint &x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint &operator-=(const modint &x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint &operator*=(const modint &x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint &operator/=(modint x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
    modint &operator^=(lint n){
        i64 ret=1;
        while(n){
            if(n&1) (ret*=a)%=MOD;
            (a*=a)%=MOD;
            n>>=1;
        }
        a=ret;
        return *this;
    }
    modint operator-() const{
        return modint(0)-*this;
    }
    modint &operator++(){
        return *this+=1;
    }
    modint &operator--(){
        return *this-=1;
    }
    bool operator<(const modint x) const{
        return a<x.a;
    }
};

using mint=modint<1000000007>;

vector<mint> fact;
vector<mint> revfact;

void setfact(int n){
    fact.resize(n+1); revfact.resize(n+1);
    fact[0] = 1;
    rep(i, n) fact[i+1] = fact[i] * mint(i+1);

    revfact[n] = fact[n].inv();
    for(int i=n-1; i>=0; i--) revfact[i] = revfact[i+1] * mint(i+1);
}

mint getC(int n, int r){
    if(n<r) return 0;
    return fact[n] * revfact[r] * revfact[n-r];
}

int main(){
    int n, m, K;
    scanf("%d%d%d", &n, &m, &K);
    setfact(n*m);
    mint N=n, M=m;
    mint ans = M * N * (M*N-1) * (M+N) / mint(6) * getC(n*m-2, K-2);
    printf("%lld\n", ans.a);
}

Measured memory_bytes: 3328
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

import numpy as np

N = int(readline())
LR = [tuple(int(x) for x in line.split()) for line in readlines()]

"""
・奇数個のとき：中央にどれかを固定。
・偶数のとき：原点で左右に分けるとしてよい。
・基本的に長さで内側から昇順（奇数のときの中央は謎）。→ソートしてdpできる。
・左に置いた個数をもってdp更新。また、中央を使ったかも同時に持って。
・偶数のときは、中央に1つ置いた状態から始める。
・大きい区間から外側に入れていく。
"""

LR.sort(key = lambda x: -x[1]-x[0])

INF = 10**18
dp_0 = np.full(N+1,INF,np.int64) # 左に置いた個数 → コスト。中央未確定。
dp_1 = np.full(N+1,INF,np.int64) # 左に置いた個数 → コスト。中央確定。
if N&1:
    dp_0[0] = 0
else:
    dp_1[0] = 0
for n,(L,R) in enumerate(LR):
    length = R + L
    prev_0 = dp_0
    prev_1 = dp_1
    dp_0 = np.full(N+1,INF,np.int64)
    dp_1 = np.full(N+1,INF,np.int64)
    x = np.arange(n+1,dtype=np.int64) # もともと左側にあった個数
    # 左側に置く場合
    np.minimum(prev_0[:n+1] + R + x * length, dp_0[1:n+2], out=dp_0[1:n+2])
    np.minimum(prev_1[:n+1] + R + x * length, dp_1[1:n+2], out=dp_1[1:n+2])
    # 右側に置く場合
    np.minimum(prev_0[:n+1] + L + (n-x) * length, dp_0[:n+1], out=dp_0[:n+1])
    np.minimum(prev_1[:n+1] + L + (n-x) * length, dp_1[:n+1], out=dp_1[:n+1])
    # 中央に置く場合
    np.minimum(prev_0[:n+1] + (N-1)//2 * length, dp_1[:n+1], out = dp_1[:n+1])

answer = dp_1[N//2]
print(answer)

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

using namespace std;
long long mas[200005];
int main()
{
    long long n,k;
    long long l=1,r=1e9;
    cin>>n>>k;
    for(long long i=0; i<n; i++) cin>>mas[i];
    while(l!=r){
        long long m=(l+r)/2;
        long long sk=0;
        for(long long i=0; i<n; i++){
            sk+=(mas[i]+m-1)/m-1;
        }
        if(sk>k){
            l=m+1;
        }else{
            r=m;
        }
    }
    cout<<l;
}


Measured memory_bytes: 5172
N = int(input())
A = list(map(int,input().split()))
B =[]
for i in range (N):
    B.append(abs(A[i]))
m = 0
for i in range (N):
    if A[i] < 0:
        m = m + 1
if m % 2 == 0:
    maxi = sum(B)
else:
    if 0 in A:
        maxi = sum(B)
    else:
        maxi = sum(B) - 2 * min(B)
print(maxi)

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

int main() {
    string s, s1, s2;
    cin >> s;
    string res;

    int num = s.size() -2;
    s1 = s[0];
    s2 = s[s.size() -1];

    cout << s1 + to_string(num) + s2 << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF 2000000000

typedef long long ll;

int main(){
    int yen = 0;
    INT(N);
    INT(K);
    INT(X);
    INT(Y);
    if (N > K) {
        REP1(i,K) yen += X;
        REP1(i,N-K) yen += Y;
    }else{
        REP1(i,N) yen += X;
    }
    cout << yen << endl;
    return 0;
}

Measured memory_bytes: 256
// :)
// "Khodaya, be man "Tagwaye setiz" biamooz ta
//  dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>

using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int64> pii64;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int maxn = 1e5+10;
const int64 MO = 1e9+7;
const int64 IN = 1e9;

int64 dp[maxn];

int N, W;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	// 
	cin >> N >> W;
	for (int i = 0; i < N; i++) {
		int w, v;
		cin >> w >> v;
		for (int t = W - w; t >= 0; t--)
			dp[t + w] = max(dp[t + w], dp[t] + v);
	}
	//
	int64 ans = 0;
	for (int i = 0; i <= W; i++)
		ans = max(ans, dp[i]);
	cout << ans << "\n";
	//
}



Measured memory_bytes: 1024
l,r = gets.split.map(&:to_i)

if r-l >= 2019
  puts 0
  exit
end

r%=2019
l%=2019

l,r = r,l if r<l

ans = 2500

l.upto r do |i|
  (i+1).upto r do |j|
    ans = [ans, i*j%2019].min
  end
end

puts ans


Measured memory_bytes: 1788
#include<iostream>
#include<string.h>
using namespace std;
int a,b,c,d,e,f,i,j;
string s[100];
int x[30]={1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47};
int y[30]={50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96};
int main()
{ 
  cin >> a >> b;
    c=(a-1)/24;
    d=(b-1)/24;
    e=(a-1)%24;
    f=(b-1)%24;
  for(i=0;i<49;i++){s[i]="#################################################";
                    }
  for(i=49;i<98;i++){s[i]=".................................................";
                     }
  for(i=0;i<c;i++){s[x[i]]="#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#";
                  }
  for(j=0;j<e;j++){s[x[i]].replace(x[j],1,".");
                  }
  for(i=0;i<d;i++){s[y[i]]=".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.";
                  }
  for(j=0;j<f;j++){s[y[i]].replace(x[j],1,"#");
                  }
  cout << 98 << " " << 49 << endl;
  for(i=0;i<98;i++){cout << s[i] << endl;
                   }
} 

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

using namespace std;

int N,A,B,C; vector<int> l;

int dfs(int depth, int La, int Lb, int Lc){
  if( depth == N + 1){
    if( La != 0 && Lb != 0 && Lc != 0){
      return abs( A - La) + abs( Lb - B) + abs( Lc - C) - 30;}
    else{return (1 << 29) ;}}
  
  int r1 = dfs(depth + 1, La + l[depth],Lb,Lc) + 10;
  int r2 = dfs(depth + 1, La, Lb + l[depth], Lc) + 10;
  int r3 = dfs(depth + 1, La, Lb, Lc + l[depth]) + 10;
  int r4 = dfs(depth + 1, La, Lb, Lc);
  
  return min(min(r1,r2),min(r3,r4));
}
      
    
    
    

int main(){
   cin >> N >> A >> B >> C;
  l.resize(N+1);
  for(int i = 1; i <= N; i++){ 
    cin >> l[i];} //1-indexed
  
  cout <<  dfs(1,0,0,0) << endl;
  
  return 0;}
  


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by yangyuyin on 16/10/23.
 */
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        boolean hasC=false;
        boolean result=false;
        for(int i=0;i<s.length;i++){
            if(s[i]=='C') hasC=true;
            else if(s[i]=='F'&&hasC) {
                result=true;
                break;
            }
        }
        if (result) System.out.print("Yes");
        else System.out.print("No");
    }
}


Measured memory_bytes: 10196
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N, X = 0;
    cin >> N;
    int M = N;
    while (M != 0) {
        X += M % 10;
        M /= 10;
    }
    if (N % X == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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


int main(){
    int x, y, z, k;
    cin >> x >> y >> z >> k;

    vector<ll> a(x), b(y), c(z);
    for(auto &v : a) cin >> v;
    for(auto &v : b) cin >> v;
    for(auto &v : c) cin >> v;
    
    vector<ll> s1;
    for(int i=0; i<x; i++){
        for(int j=0; j<y; j++){
            s1.push_back(a[i]+b[j]);
        }
    }
    sort(all(s1), greater<ll>{});
    vector<ll> s2;
    for(int i=0; i<min(k, (int)s1.size()); i++) s2.push_back(s1[i]);

    vector<ll> s3;
    for(int i=0; i<(int)s2.size(); i++){
        for(int j=0; j<z; j++){
            s3.push_back(s2[i]+c[j]);
        }
    }
    sort(all(s3), greater<ll>{});
    for(int i=0; i<k; i++) cout << s3[i] << endl;
    return 0;
}

Measured memory_bytes: 44192
#include <stdio.h>
#include <stdio.h>
  int S[3];
  int top=0;
  void push(int v){
      top++;
      S[top]=v;
  } 
  int pop(void){
      top--;
      return S[top+1];
  }
  int main(void){
      char s[100];
  while( scanf("%s", s) != EOF ){
      int c,d;
      if ( s[0] == '+' ){
          c=pop();
          d=pop();
          push(c+d);
      } else if ( s[0] == '-' ){
          c=pop();
          d=pop();
          push(d-c);
      } else if ( s[0] == '*' ){
          c=pop();
          d=pop();
          push(c*d);
      } else {
        push(atoi(s));

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


Measured memory_bytes: 1988
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b, d, r;
    double f;
    scanf("%d %d", &a, &b);
    d = a / b;
    r = a % b;
    f = 1.0 * a / b;
    printf("%d %d %lf\n", d, r, f);
    return 0;
}



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

int main(){
    string s;
    cin >> s;
    int begin = 0, end = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'A'){
        begin = i;
        break;
        }
    }
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'Z') end = i;
    }

    cout << end - begin + 1 << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
LL A[200011];
LL sums[200011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%lld", A+i);
    REP (i, N) sums[i+1] = sums[i] + A[i];

    LL best = sums[N];
    REP (i, N) {
	LL a = sums[i], b = sums[N] - a;
	amin(best, abs(a - b));
    }

    printf("%lld\n", best);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3328
import heapq
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
q = list(map(int, input().split()))
q.sort()
r = list(map(int, input().split()))
r.sort()
hq1 = []
hq2 = []
for i in range(x):
    heapq.heappush(hq1, p[a - i - 1])
for i in range(y):
    heapq.heappush(hq2, q[b - i - 1])
while r and (hq1[0] < r[-1] or hq2[0] < r[-1]):
    if hq1[0] < hq2[0]:
        heapq.heappop(hq1)
        heapq.heappush(hq1, r[-1])
        r.pop()
    else:
        heapq.heappop(hq2)
        heapq.heappush(hq2, r[-1])
        r.pop()
print(sum(hq1) + sum(hq2))


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

#define INF 90000000000000
typedef pair<int, int> P;

int n, m;


int main(){
while(true){
	cin >> n >> m;
	if(n==0&&m==0) return 0;
	int k[155] = {0};
	P stone[155][15];
	long long dp[155][15][155] = {0};
	for(int i = 1; i <= n; i++){
		cin >> k[i];
		for(int j = 0; j < k[i]; j++){
			cin >> stone[i][j].first >> stone[i][j].second;
		}
	}
	for(int i = 0; i < 155; i++){
		for(int j = 0; j < 15; j++){
			for(int p = 0; p < 155; p++){
				dp[i][j][p] = INF;
			}
		}
	}
	for(int j = 0; j < k[1]; j++){
		dp[1][j][0] = 0;
	}
	for(int j = 0; j < k[2]; j++){
		dp[2][j][1] = 0;
	}
	for(int i = 2; i <= n; i++){
		for(int j = 0; j < k[i]; j++){
			for(int p = 0; p <= m; p++){
				for(int l = 0; l < k[i-1]; l++){
					dp[i][j][p] = min(dp[i][j][p], dp[i-1][l][p] + (stone[i][j].second + stone[i-1][l].second)* abs(stone[i][j].first - stone[i-1][l].first));
				}
				if(i>=3&&p>=1){
					for(int l = 0; l < k[i-2]; l++){
						dp[i][j][p] = min(dp[i][j][p],dp[i-2][l][p-1] + (stone[i][j].second + stone[i-2][l].second)*abs(stone[i][j].first - stone[i-2][l].first));
					}
				}
			}
		}
	} 
    long long res = INF;
	for(int j = 0; j < k[n]; j++){
		for(int p = 0; p <= m; p++){
			res = min(res, dp[n][j][p]);
		}
	}
	for(int j = 0; j < k[n-1]; j++){
		for(int p=0;p<=m-1;p++){
			res=min(res, dp[n-1][j][p]);
		}
	}
	cout << res << endl;
}
	return 0;
}



Measured memory_bytes: 5904
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back

int n;
int w[330];
int dp[330][330];


int main() {
	while (cin >> n&&n) {
		for (int i = 0; i < 330; i++) {
			w[i] = 0;
			for (int j = 0; j < 330; j++)dp[i][j] = 0;
		}
		for (int i = 0; i < n; i++)cin >> w[i];
		for (int i = n - 1; i >= 0; i--) {
			dp[i][i] = 0;
			dp[i][i + 1] = 0;
			for (int j = i + 1; j <= n; j++) {
				if (i + 1 < j&&abs(w[i] - w[j - 1]) <= 1 && (dp[i + 1][j - 1] == j - i - 2)) {
					dp[i][j] = j - i;
				}
				for (int k = j + 1; k <= n; k++) {
					dp[i][k] = max(dp[i][k], dp[i][j] + dp[j][k]);
				}
			}
		}
		cout << dp[0][n] << endl;
	}
}

Measured memory_bytes: 3492
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()
A = LI()
B = LI()
if sum(A) > sum(B):
    print('No')
    exit()
ret = 0
for i in range(n):
    if B[i] > A[i]:
        ret += (B[i] - A[i] + 1) // 2

if ret > sum(B) - sum(A):
    print('No')
else:
    print('Yes')




Measured memory_bytes: 40560
#include <iostream>
#include <cstdio>
#define INF (1ll << 32)
#define int64 long long 
using namespace std;

long long dp[105][105];

void pre (int size) {
  for ( int i = 0 ;i < size; i++) {
    for ( int j = 0;j < size; j++) {
      dp[i][j] = ((i == j) ? 0 : INF );
    }
  }
}

main()
{
  int v, e;
  int s, t, d;
  int p = 0;

  scanf("%d %d", &v, &e);
  pre(v);
  for ( int i = 0; i < e; i++) {
    scanf("%d %d %d", &s, &t, &d);
    dp[s][t] = d;
  }

  // Warshall_Floyd
  for ( int i = 0; i < v ; i++) {
    for ( int j = 0; j < v ; j++) {
      for ( int k = 0; k < v ; k++) {
	if ( dp[j][i] != INF && dp[i][k] != INF ) {
	  dp[j][k] = min(dp[j][k], dp[j][i] + dp[i][k]);
	}
      }
    }
  }
  // Warshall_Floyd

  for (int i = 0; i < v; i++) {
    if ( dp[i][i] < 0 ) {
      p = 1;
    }
  }

  if (p) {
    cout << "NEGATIVE CYCLE" << endl;
  } else { 
  
    for ( int i = 0; i < v; i++) {
      for ( int j = 0; j < v; j++) {
	if (j) {
	  cout << " " ;
	}
	
	if ( dp[i][j] == INF ) {
	  cout << "INF";
	} else { 
	  cout << dp[i][j];
	}
      }
      cout << endl;
    }

  }

  return (0);
}



Measured memory_bytes: 3316