akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

int main(){
    int N;
    while (cin >> N&& N){
        N--;
        int ans = N % 39 + 1;
        cout << "3C" << (ans < 10 ? "0" : "") << ans << endl;
    }
}

Measured memory_bytes: 1164
#include <iostream>

using namespace std;

int main(){
    int a[2];
    int tmp;
    
    while(1){
        cin >> a[0] >> a[1];
        
        if(a[0] == 0 && a[1] == 0){
            break;
        }
        
        if(a[0] > a[1]){
            tmp = a[0];
            a[0] = a[1];
            a[1] = tmp;
        }
        
        cout << a[0] << " " << a[1] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, x;
  int max, min;
  cin >> k >> x;
  max = x + k - 1;
  min = x - k + 1;
  for (int i=min; i<=max; i++) {
    cout << i << " ";
  }
  cout << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

bool compare (ll a, ll b)
{
    return a>b;
}

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

    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    ll red[a];
    ll green[b];
    ll colorless[c];

    for (ll i=0;i<=a-1;i++)
    {
        cin >> red[i];
    }   
    for (ll i=0;i<=b-1;i++)
    {
        cin >> green[i];
    }
    for (ll i=0;i<=c-1;i++)
    {
        cin >> colorless[i];
    }

    sort(red,red+a,compare);
    sort(green,green+b,compare);
    sort(colorless,colorless+c,compare);

    vector<ll> alpha;
    for (ll i=0;i<=x-1;i++)
    {
        alpha.push_back(red[i]);
    }
    for (ll i=0;i<=y-1;i++)
    {
        alpha.push_back(green[i]);
    }
    for (ll i=0;i<=c-1;i++)
    {
        alpha.push_back(colorless[i]);
    }

    sort(alpha.begin(),alpha.end(),compare);
    ll ans=0;
    for (ll i=0;i<=x+y-1;i++)
    {
        ans=ans+alpha[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8432
Table=[0,0,0,6,42,192,732,2538,8334,26484]
N=int(input())
K=len(str(N))
ans=Table[K-1]

import itertools
U=['3','5','7']
PRD = list(itertools.product(U, repeat=K))
for i in PRD:
    T=''.join(i)
    if int(T)>N:
        break
    if '3' in T and '5' in T and '7' in T:
        ans+=1

print(ans)

Measured memory_bytes: 5620
x=int(input())
d={}
for i in range(200):
    b=i**5
    c=(-i)**5
    d[b]=i
    d[c]=-i
for i in range(200):
    y=x+i**5
    try:
        print(d[y],i)
        break
    except:
        None
    z=x+(-i)**5
    try:
        print(d[z],-i)
        break
    except:
        None
    
    


Measured memory_bytes: 9216
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/8/ITP2/1/ITP2_1_D

#include <iostream>
#include <vector>

int main()
{
    int n, q;
    std::cin >> n >> q;
    std::vector<std::vector<int>> A(n, std::vector<int>(0));

    for (int i = 0; i < q; i++)
    {

        int m, t, x;
        std::cin >> m >> t;
        if (m == 0)
        {
            std::cin >> x;
            A.at(t).push_back(x);
        }
        else if (m == 1)
        {
            for (auto itr = A.at(t).begin(); itr != A.at(t).end(); itr++)
            {
                std::cout << *itr;
                if (next(itr) != A.at(t).end())
                    std::cout << " ";
            }
            std::cout << std::endl;
        }
        else if (m == 2)
        {
            if (A.at(t).size() > 0)
                A.at(t).clear();
        }
    }
    return 0;
}


Measured memory_bytes: 5864
n = int(input())
a = list(input().split())
b = list(a)

#bub sort
flag = True
while flag:
  flag = False
  for i in range(1,n)[::-1]:
    if a[i-1][1] > a[i][1]:
      a[i-1],a[i]=a[i],a[i-1]
      flag = True
print(" ".join(a))
def stable(b,a):
  for i in range(n):
    for j in range(i+1,n):
      if b[i][1] == b[j][1]:#i<j
        for k in range(n):
          for l in range(k+1,n):
            if a[k] == b[j] and a[l] == b[i]:
              print("Not stable")
              return
  print("Stable")
stable(b,a)
a = list(b)
#sel sort
for i in range(n):
    min_i = i
    for j in range(i+1,n):
        if a[j][1] < a[min_i][1]:
            min_i = j
    if i!= min_i:
        a[i],a[min_i]=a[min_i],a[i]
print(" ".join(map(str,a)))
stable(b,a)


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

using namespace std;

int c[300300];

int main() {
	int n;
	scanf("%d", &n);
	vector<int> a;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		a.push_back(x);
	}
	int l = 0, r = 0;
	int now = 0;
	long long ans = 0;
	while (l < n) {
		while (r < n && (now ^ a[r]) == now + a[r]) {
			now ^= a[r++], ans++;
		}
		now ^= a[l++];
		ans += r - l;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1400
A, B = list(map(int, input().split()))

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

print(len(set(prime_factorize(gcd(A, B))))+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = (a), i_len = (b); i < b; ++i)

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(A*B, C*D) << endl;
    return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "3 3" ].parse.expand.solve == 2 );
	assert( [ "2 2" ].parse.expand.solve == 0 );
	assert( [ "999999 999999" ].parse.expand.solve == 151840682 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto xy = input.front.split.to!( long[] );
	return tuple( xy[ 0 ], xy[ 1 ] );
}

auto solve( long x, long y )
{
	// 移動ステップ数を探索
	auto a = x;		// x++, y+=2 で移動した回数
	auto b = 0;		// x+=2, y++ で移動した回数
	for( ; 0 <= a; a -= 2, b++ )
	{
		if( a * 2 + b == y ) break;
	}
	if( a < 0 ) return 0;		// たどり着けなかった
	
	// 移動方法のパターン数を計算
	return ( a + b ).combinationMod( b );
}

// 掛け算
auto mulMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return x * y % MOD;
}

// 割り算
auto divMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return x * y.powMod!MOD( MOD - 2 ) % MOD;
}

// べき乗
auto powMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	auto a = 1L;
	for( ; 0 < y; y >>= 1 )
	{
		if( y & 1 ) a = a * x % MOD;
		x = x ^^ 2 % MOD;
	}
	return a;
}

// 階乗
auto factorialMod( long MOD = 10L ^^ 9 + 7 )( long x )
{
	static memo = [ 1L ];
	if( memo.length <= x )
	{
		auto i = memo.length;
		memo.length = x + 1;
		for( ; i <= x; i++ ) memo[ i ] = memo[ i - 1 ] * i % MOD;
	}
	return memo[ x ];
}

// 組み合わせ数
auto combinationMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return x.factorialMod!MOD.divMod!MOD( y.factorialMod!MOD.mulMod!MOD( ( x - y ).factorialMod!MOD ) );
}


Measured memory_bytes: 7548
#include <cstdio>
int n, m, x, y, s, a[100005], v[100005]={0,1};
int main() {
	int i;
	scanf("%d%d", &n, &m);
	for(i=n; i; i--) a[i] = 1;
	while(m--) {
		scanf("%d%d", &x, &y);
		if(v[x]) v[y] = 1;
		a[x]--, a[y]++;
		if(!a[x]) v[x] = 0;
	}
	for(i=n; i; i--) s += v[i];
	printf("%d", s);
	return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
int D[7][7]={{},
{0,0,4,2,5,3,0},
{0,3,0,6,1,0,4},
{0,5,1,0,0,6,2},
{0,2,6,0,0,1,5},
{0,4,0,1,6,0,3},
{0,0,3,5,2,4,0}},G[7],N,i,t,f;
int sc(int d)
{
	int i;
	for(i=1;i<=6;i++)
		if(G[i]==d)
			return i;
}
int main()
{
	for(i=1;i<7;i++)scanf("%d",G+i);
	scanf("%d",&N);
	for(;N--;)
	{
		scanf("%d%d",&t,&f);
		printf("%d\n",G[D[sc(f)][sc(t)]]);
	}
	return 0;
}



Measured memory_bytes: 2048
import sys
sys.setrecursionlimit(10**8)

def find(x):
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
        return par[x]

def union(a,b):
    a=find(a)
    b=find(b)
    if a==b:
        return
    
    if rank[a]<rank[b]:
        par[a]=b
        rank[b]+=rank[a]
        rank[a]=rank[b]
    else:
        par[b]=a
        rank[a]+=rank[b]
        rank[b]=rank[a]

    return

def chk(a,b):
    if par[a]==par[b]:
        print('Yes')
    else:
        print('No')

    return

N,M=map(int, input().split())

par=(list(range(N+1)))
rank=[1]*(N+1)

for _ in range(M):
    A,B=map(int, input().split())
    union(A,B)

print(max(rank))

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

int main() {
 int N,K;
 cin >> N >> K;
 
if((N - 1) % (K - 1) == 0) {
  cout << (N - 1) / (K - 1) << endl;
}else {
  cout << (N - 1) / (K - 1) + 1 << endl;
}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <array>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
int a[1000000] = {};

int main() {
	int n; CI n;
	VI h(n); CI h;

	int ans = 0;
	while (1) {
		if (*max_element(all(h)) == 0) { CO ans EN; return 0; }
		int i = 0;
		while (i < n) {
			if (h[i] == 0)i++;
			else {
				ans++;
				for (; i<n && h[i]>0; i++) {
					h[i]--;
				}
			}
		}
	}
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var h int
	fmt.Scan(&h)

	fmt.Println(attackCount(h))
}

func attackCount(h int) int {
	if h == 1 {
		return 1
	} else {
		return 2*attackCount(h/2) + 1
	}
}


Measured memory_bytes: 1772
n = int(input())
a = list(map(int, input().split()))
 
dp = [0]*(10**6)
count = [0]*(10**6)

for i in a:
  count[i-1] += 1
 
b = list(set(a))
for i in b:
  for j in range(i*2, 10**6+1, i):
    dp[j-1] = 1
    
ans = 0
for i in a:
  if count[i-1] == 1 and dp[i-1] == 0:
    ans +=1
    
print(ans)

Measured memory_bytes: 130336
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N;
    int F[110][5][2];
    int P[110][20];
    cin >> N;
    for (int i=0;i<N;i++) for (int j=0;j<5;j++) for (int k=0;k<2;k++) cin >> F[i][j][k];
    for (int i=0;i<N;i++) for (int j=0;j<=10;j++) cin >> P[i][j];

    vector<int> B(110,0);
    for (int i=0;i<N;i++) for (int j=0;j<5;j++) for (int k=0;k<2;k++) {
        B[i] = (B[i] << 1) + F[i][j][k];
    }
    int res = -1001001001;
    for (int X=1;X<(1<<10);X++) {
        int r = 0;
        for (int i=0;i<N;i++) {
            int Y = __builtin_popcount(X & B[i]);
            r += P[i][Y];
        }
        res = max(res,r);
    }
    cout << res << endl;

    return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    int n, m;
    cin >> n >> m;
    vs a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    bool ans = false;
    for (int i=0; i+m<=n; ++i) for (int j=0; j+m<=n; ++j) {
        vs temp(m);
        rep(i2, m) temp[i2] = a[i+i2].substr(j, m);
        if (temp == b) ans = true;
    }
    if (ans) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
const int maxn=100005;
const int inf=0x3f3f3f3f;
int n,m,a[maxn],minid[maxn],mmin[maxn],id[maxn],cc;
long long res;
vector<int> G[maxn];
void dfs(int u,int c) {
    id[u]=c;
    if (a[u]<mmin[c]) {
        mmin[c]=a[u];
        minid[c]=u;
    }
    for (int i=0;i<(int)G[u].size();++i) {
        int v=G[u][i];
        if (id[v]) continue;
        dfs(v,c);
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=0;i<n;++i)
        scanf("%d",&a[i]),mmin[i]=inf;
    while (m--) {
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    for (int i=0;i<n;++i)
        if (!id[i])
            dfs(i,++cc);
    if (cc==1) return 0*puts("0");
    int point=0;
    for (int i=1;i<=cc;++i)
        res+=a[minid[i]],a[minid[i]]=inf,++point;
    sort(a,a+n);
    for (int i=0;i<n;++i)
        if (a[i]!=inf&&cc+cc-2>point)
            ++point,res+=a[i];
    if (cc+cc-2>point) return 0*puts("Impossible");
    return cout<<res<<endl,0;
}


Measured memory_bytes: 6912
#include <iostream>
#include <cstdio>
using namespace std;
int main(int argc, char *argv[])
{
	int n,m,s;
	cin>>n>>m;
	if(n<2||m<2)s=0;
	else
	{
		s=(n-1)*(m-1);
	}
	cout <<s<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N = 50
    K = int(input())
    # K = 50 * int(1e16)
    tmp = K // N
    K %= N
    a = np.array([i for i in range(N)])
    for i in range(K):
        a -= 1
        a[i] += N + 1
    print(N)
    for i in range(N-1):
        print(a[i]+tmp, end=" ")
    print(a[N-1]+tmp)

if __name__ == "__main__":
    main()

Measured memory_bytes: 12388
#[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(std::io::BufReader::new(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, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      hs: [usize; n],
    }

    let mut ans = 0;
    let mut cur = 0;
    for i in 0..n-1 {
        if hs[i] >= hs[i+1] {
            cur += 1;
        } else {
            ans = max(ans, cur);
            cur = 0;
        }
    }
    ans = max(ans, cur);
    puts!("{}\n", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstring>

const int MOD=100000;

int dp[101][101][4];//たて　よこ 　０＝上向き曲がりおｋ　１＝上向き曲りだめ　２＝右向き曲りおｋ　３＝右向き曲りだめ

int main(){
	int w, h;

	while(std::cin >> w >> h, w * h){
		for(int i=1;i<=h;i++){
			dp[i][1][0]=1;
		}
		for(int i=1;i<=w;i++){
			dp[1][i][2]=1;
		}

		for(int i=2;i<=h;i++){
			for(int j=2;j<=w;j++){
				dp[i][j][0]=(dp[i][j][0]+dp[i-1][j][0]+dp[i-1][j][1])%MOD;
				dp[i][j][1]=(dp[i][j][1]+dp[i-1][j][2])%MOD;
				dp[i][j][2]=(dp[i][j][2]+dp[i][j-1][2]+dp[i][j-1][3])%MOD;
				dp[i][j][3]=(dp[i][j][3]+dp[i][j-1][0])%MOD;
				dp[i][j][0]%=MOD;
				dp[i][j][1]%=MOD;
				dp[i][j][2]%=MOD;
				dp[i][j][3]%=MOD;
			}
		}

		/*for(int i = 1; i <= h; ++i){
			for(int j = 1; j <= w; ++j){
				std::cout << "{";
				for(int k = 0; k < 4; ++k)
					std::cout << dp[i][j][k] << (k != 3 ? ", " : "");
				std::cout << "}, ";
			}
			std::cout << std::endl;
		}*/

		std::cout<<(dp[h][w][0]+dp[h][w][1]+dp[h][w][2]+dp[h][w][3])%MOD<<std::endl;
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				for(int k=0;k<4;k++)dp[i][j][k]=0;
			}
		}
	}
	return 0;
}

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


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int n = vals[0];
		//string res="";

		//int y = vals[0];
		//int x = vals[1];

		int n = int.Parse(Console.ReadLine());
		int[] vals = parseAry(Console.ReadLine().Split(cs));
		int[] vv = (int[])vals.Clone();

		Array.Sort(vals);

		//if (vals.Length == 2) { Console.WriteLine(vals[1] + " " + vals[0]);
			//return; }

		int res1 = vals[vals.Length - 1];
		vals[vals.Length - 1] = 0;
		Array.Sort(vals);
		int res2 = vals[Binary_Search(( 1.0 * res1) / 2.0 , vals)];
		//for (int i = 0; i < vals.Length; i++) {
		

		//}

			//deug
			Console.WriteLine(res1+" "+res2);

		return;
	}

	static private int Binary_Search(double x,int[] lis) {
		int Lower = 0;
		int Upper = lis.Length - 1;
		int bk = 0;
		while (Lower <= Upper) {
			int Center = ( Lower + Upper ) >> 1;
			if (x > lis[Center]) {
				bk = Lower;
				Lower = Center + 1;
			} else if (x < lis[Center]) {
				bk = Lower;
				Upper = Center - 1;
			} else {
				return Center;
			}
		}
		if (lis.Length > bk + 1) {
			if (Math.Abs(x - lis[bk]) > Math.Abs(x - lis[bk + 1])) {
				bk++;
			}
		}
		if ( bk-1 >= 0 ) {
			if (Math.Abs(x - lis[bk]) > Math.Abs(x - lis[bk - 1])) {
				bk--;
			}
		}
		return bk;
	}


	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryl(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}



	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}

Measured memory_bytes: 20064
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
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; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


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

int lcm(int a, int b){
    return a / gcd(a,b) * b;
}

int a, b, c, d;
void in(){
    cin >> a >> b >> c >> d;
}

int di(int n, int m){
    return n / m;
}

void solve(){

    int divc = di(b, c) - di(a - 1, c);
    int divd = di(b, d) - di(a - 1, d);
    int divx = di(b, lcm(c, d)) - di(a - 1, lcm(c, d));

    print(b - a + 1 - divc - divd + divx);



}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int	main(void)
{
	int k;
	cin >> k;
	long long all = 0;
	for (int i = 0; i < k; i++)
	{
		all *= 10;
		all %= k;
		all += 7;
		all %= k;
		if (all == 0)
		{
			cout << i + 1 << endl;
			return (0);
		}
	}
	cout << -1 << endl;
	return (0);
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=2e5+5;
const int mod=2019;
ll dp1[N],dp2[N];
char c[N];
int main()
{
	scanf("%s",c+1);
	int len=strlen(c+1);
	dp1[c[1]-'0']=1;
	ll ans=0;
	for(int i=2;i<=len;i++){
		if(i&1){
			for(int j=0;j<mod;j++){
				dp1[j]=0;
			}
			dp1[c[i]-'0']=1;
			for(int j=0;j<mod;j++){
				int pos=(j*10+c[i]-'0')%mod;
				dp1[pos]+=dp2[j];
			}
			ans+=dp1[0];
		}
		else{
			for(int j=0;j<mod;j++){
				dp2[j]=0;
			}
			dp2[c[i]-'0']=1;
			for(int j=0;j<mod;j++){
				int pos=(j*10+c[i]-'0')%mod;
				dp2[pos]+=dp1[j];
			}
			ans+=dp2[0];
		}
	}
	printf("%lld",ans);
}


Measured memory_bytes: 4056
let cmp a b =
    a - b;;

Printf.printf "%d\n" @@
Scanf.scanf "%d %d\n" @@ fun n k ->
    let a = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun i -> i in
    Array.sort cmp a;
    let ans = ref 0 in
    for i = 0 to k-1 do
        ans := !ans + a.(i)
    done;
    !ans;;


Measured memory_bytes: 4132
#include<stdio.h>
int main(void)
{
	int L,a,b,c,d,x,y,z;
	scanf("%d %d %d %d %d",&L,&a,&b,&c,&d);
	x=a/c;
	y=b/d;
	if(a%c>=1){
		x=x+1;
	}
	if(b%d>=1){
		y=y+1;
	}
	if(y<=x){
		z=x;
	}
	else{
		z=y;
	}
	printf("%d\n",L-z);
	return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int a, b;
    cin >> a >> b;
    if(a + b >= 10) cout << "error" << endl;
    else cout << a + b << endl;
}

Measured memory_bytes: 3596
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int add = A+B;
    int sub = A-B;
    int acc = A*B;
    int ans = Math.max(add,Math.max(sub,acc));
    System.out.println(ans);
    sc.close();
  }
}

Measured memory_bytes: 22612
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define BUF_SIZE 30

int get_int2(int *a1, uint64_t *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %llu", a1, a2);
#else
#error
#endif
  return 0;
}

#define WEIGHT_MAX 100000
#define NUM_MAX 100

struct product {
    int weight;
    uint64_t value;
};

#define max(a,b) ((a) > (b) ? (a) : (b))

int main(void) {
    int num;
    uint64_t wlimit;
    get_int2(&num, &wlimit);
    static uint64_t dp[NUM_MAX+1][WEIGHT_MAX+1];
    static struct product prods[NUM_MAX+1];

    int i, j;
    for(i = 1; i <= num; i++) {
        get_int2(&prods[i].weight, &prods[i].value);
    }

    for(i = 1; i <= num; i++) {
        uint64_t w = prods[i].weight;
        uint64_t v = prods[i].value;
        for(j = 1; j <= wlimit; j++) {
            dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
            if(j >= w) {
                dp[i][j] = max(dp[i][j], dp[i-1][j-w]+v);
            }
        }
    }
    printf("%llu\n", dp[num][wlimit]);
    return 0;
}

Measured memory_bytes: 78336
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var L = input[1].split(" ").map(i => parseInt(i)).sort((a,b) => a-b);
  var ans =0;
  for(var i=0;i<N;i++){
    for(var j=i;j<N;j++){
      for(k=j;k<N;k++){
        if(L[i]!=L[j]&&L[j]!=L[k]&&L[i]+L[j]>L[k]){
          ans++;
        }
      }
    }
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 32376
a, b, c = input().split()

a = int(a)
b = int(b)
c = int(c)

for i in range(c):
    if (a%2 == 1 and i %2 == 0):
        a = a - 1
    if (b%2 == 1 and i % 2 == 1):
        b = b - 1
    if(i%2 == 0):
        ac = a
        a = a/2 
        b = b + ac/2
    else:
        bc = b
        a = a+bc/2
        b = b/2 

print(int(a), int(b))




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

int main(){
     int n, k;
     cin >> n >> k;
     int a[n];
     for(int i = 0; i < n; i++){
          cin >> a[i];
     }
     for(int j = k; j < n; j++){
          if(a[j] > a[j - k]){
               cout << "Yes";
          }
          else{
               cout << "No";
          }
          cout << "\n";
     }
     return 0;
}

Measured memory_bytes: 4328
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
using namespace std;
const int maxn = 1e5 + 100;
char s[maxn];
int main(){
  scanf("%s",s);
  int len = strlen(s);
  int flag = 1;
  for (int i = 0; i < len; i++){
     if (s[i] == '1') flag = 0;
  }
  if (flag){
    printf("%d\n",len);
    return 0;
  }
  int res = 1e9 + 100;
  for (int i = len - 1; i >= 0; i--){
      if (s[i] != s[i - 1]){
         res = min(max(i, len - i),res);
      }
  }
  printf("%d\n",res);
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

#define EB emplace_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

void merge(vector<int> tree[], 
				int treeNode) 
{ 
	int len1 = 
	tree[2 * treeNode].size(); 
	int len2 = 
	tree[2 * treeNode + 1].size(); 
	int index1 = 0, index2 = 0; 

	while (index1 < len1 && index2 < len2) { 

		if (tree[2 * treeNode][index1] > 
			tree[2 * treeNode + 1][index2]) { 

			tree[treeNode].push_back( 
				tree[2 * treeNode + 1][index2] 
				); 
			index2++; 
		} 
		else { 
			tree[treeNode].push_back( 
				tree[2 * treeNode][index1] 
				); 
			index1++; 
		} 
	} 

	while (index1 < len1) { 
		tree[treeNode].push_back( 
			tree[2 * treeNode][index1] 
			); 
		index1++; 
	} 

	while (index2 < len2) { 
		tree[treeNode].push_back( 
			tree[2 * treeNode + 1][index2] 
			); 
		index2++; 
	} 
	return; 
} 

void build(vector<int> tree[], 
	int* arr, int start, int end, 
				int treeNode) 
{ 
	if (start == end) { 
		tree[treeNode].push_back( 
			arr[start]); 
		return; 
	} 
	int mid = (start + end) / 2; 

	build(tree, arr, start, 
		mid, 2 * treeNode); 

	build(tree, arr, mid + 1, end, 
				2 * treeNode + 1); 

	merge(tree, treeNode); 
	return; 
} 

int query(vector<int> tree[], 
	int treeNode, int start, int end, 
			int left, int right) 
{ 

	if (start > right || end < left) { 
		return 0; 
	} 

	if (start >= left && end <= right) { 
 
		return tree[treeNode].end() - 
		upper_bound(tree[treeNode].begin(), 
			tree[treeNode].end(), right); 
	} 

	int mid = (start + end) / 2; 

	int op1 = query(tree, 2 * treeNode, 
			start, mid, left, right); 

	int op2 = query(tree, 2 * treeNode + 1, 
			mid + 1, end, left, right); 
	return op1 + op2; 
} 

int main() 
{ 
	IOS;
	int n, m; cin >> n >> m;
	int arr[n];
	for(int i = 0; i < n; i++) cin >> arr[i];

	int next_right[n]; 
	
	vector<int> tree[4 * n]; 

	unordered_map<int, int> ump; 

	for (int i = n - 1; i >= 0; i--) { 
		if (ump[arr[i]] == 0) { 
			next_right[i] = n; 
			ump[arr[i]] = i; 
		} 
		else { 
			next_right[i] = ump[arr[i]]; 
			ump[arr[i]] = i; 
		} 
	} 

	build(tree, next_right, 0, n - 1, 1); 

	int ans; 
	while(m--){
	int left1, right1; cin >> left1 >> right1;
	left1--, right1--;
	ans = query(tree, 1, 0, n - 1, 
				left1, right1); 
		cout << ans << endl; 
	}
	return 0;
} 


Measured memory_bytes: 140176
main = do
    f <- getLine
    s <- getLine
    let (n,k) = parse1 f
    let d = parse2 s
    print $ solve n k d

parse1 :: String -> (Int, Int)
parse1 str = (w !! 0, w !! 1)
    where w = map read $ words str

parse2 :: String -> String
parse2 = concat . words

solve :: Int -> Int -> String -> Int
solve n k d = head $ filter out [n..9999999]
    where out k = let s = show k in all (\e -> e `notElem` s)  d

Measured memory_bytes: 892
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    map<int,int> P1,P2;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(i%2==0)P1[a]++;
        else P2[a]++;
    }
    int P11,P22;
    int MAX1=0,MAX11=0,MAX2=0,MAX22=0;
    for(auto x:P1){
        if(MAX1<x.second){
            MAX11=MAX1;
            MAX1=x.second;
            P11=x.first;
        }
        else if(MAX11<x.second){
            MAX11=x.second;
        }
    }
    
    for(auto x:P2){
        if(MAX2<x.second){
            MAX22=MAX2;
            MAX2=x.second;
            P22=x.first;
        }
        else if(MAX22<x.second){
            MAX22=x.second;
        }
    }
    
    if(P22!=P11)cout<<n-MAX1-MAX2<<endl;
    else{
        cout<<min(n-MAX1-MAX22,n-MAX11-MAX2)<<endl;
    }
}


Measured memory_bytes: 4992
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	#a = int(input())
	n , k = IN()
	el=set(IN())
	for i in range(n, 1000000):
		is_ok=True
		for v in list(str(i)):
			#print(v in el)
			#print(el, v)
			if int(v) in el:
				is_ok=False
				break
		if is_ok:
			return i
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<queue>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define pb push_back
using namespace std;
typedef pair<int, int>pii;

int main(){
	int a,b,c,d;
	cin >> a >> b>>c>>d;
	a=min(a,b);
	c=min(c,d);
	cout << a+c <<endl;
	return 0;
}

Measured memory_bytes: 256
import collections


def actual(N, S):
    c = collections.Counter(S)

    s = ''
    s += f'AC x {c["AC"]}\n'
    s += f'WA x {c["WA"]}\n'
    s += f'TLE x {c["TLE"]}\n'
    s += f'RE x {c["RE"]}'

    return s

N = int(input())
S = [input() for _ in range(N)]

print(actual(N, S))

Measured memory_bytes: 16620
#include <stdio.h>
#include <stdlib.h>
#define ABMAX 10001
#define CMAX 2000000

int main(){
  int i,j,n,k=0,*A,*B,C[CMAX];

  scanf("%d",&n);
  
  A=malloc(sizeof(int)*n+1);
  B=malloc(sizeof(int)*n+1);

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
    if(A[i]>k)
      k=A[i];
  }
  
  for(i=0;i<=k+1;i++)
    C[i]=0;

  for(j=1;j<=n;j++)
    C[A[j]]++;

  for(i=1;i<=k+1;i++)
    C[i]=C[i]+C[i-1];

  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  printf("%d",B[1]);
  for(i=2;i<=n;i++)
    printf(" %d",B[i]);
  printf("\n");

  return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

inline li divup(li x, li y){
    li res=x/y;
    return res+(x%y>0);
}

int main() {
    li n;
    cin>>n;
    li q[5];
    rep(i,5){
        cin>>q[i];
    }
    li m = q[0];
    repp(i,1,5){
        m=min(m,q[i]);
    }

    cout<<divup(n,m)+4<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>A;//きゅー
int digitsum(int n)
{
	//桁の総和を計算する
	int sum = 0;
	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}
	return sum;
}
int main(void)
{
	int N;
	scanf("%d", &N);
	if (N % digitsum(N) == 0) {
		printf("Yes");
		return 0;
	}
	printf("No");

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int N;
    int n;

    cin >> N;

    n = N / 2;

    if(N%2 == 1) {
        cout << n+1 << endl;
    } else {
        cout << n << endl;
    }

    return 0;
    
}

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

const int INF = 1e9;

int main() {
  int n;
  cin>>n;
  int a[n],b[n],c[n];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) cin>>b[i];
  for(int i=0;i<n;i++) cin>>c[i];

  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);

  long long cnt[n+1];
  for(int i=0;i<n+1;i++){
    cnt[i]=0;
  }
  for(int i=n-1;i>-1;i--){
    int idx_c=upper_bound(c,c+n,b[i])-c;
    cnt[i]=cnt[i+1]+n-idx_c;
  }
  long long ans=0;
  for(int ai: a){
    int idx_b=upper_bound(b,b+n,ai)-b;
    ans+=cnt[idx_b];
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int a[maxn] , last[maxn];
struct Node
{
    int l , r , pos;
    bool operator < (const Node & a){
        return r < a.r;
    }
}node[maxn];
int sum[maxn] , n , m;
int lowbit(int x) {return x & -x ;}
void add(int x , int c){
    while(x <= n){
        sum[x] += c;
        x += lowbit(x);
    }
}
int ask(int x){
    int ans = 0;
    while (x){
        ans += sum[x];
        x -= lowbit(x);
    }
    return ans;
}
int Ans[maxn];
int main()
{
    scanf("%d%d" , &n , &m);
    for (int i = 1 ; i <= n ; i++) scanf("%d" , a + i);
    for(int i = 1 ; i <= m ; i++){
        scanf("%d%d" , &node[i].l , &node[i].r);
        node[i].pos = i;
    }
    sort(node + 1 , node + 1 + m);
    int ptr = 1;
    memset(last , -1 , sizeof last);
    for (int i = 1 ; i <= m ; i++){
        for (int j = ptr ; j <= node[i].r ; j++){
            if (last[a[j]] != -1){
                add(last[a[j]] , -1);
            }
            last[a[j]] = j;
            add(j , 1);
        }
        Ans[node[i].pos] = ask(node[i].r) - ask(node[i].l - 1);
        ptr = node[i].r + 1;
    }
    for (int i = 1; i <= m ; i++) cout << Ans[i] << endl;
    return 0;
}


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

int main() {
  int N;
  cin>>N;
  vector<int> d(N);
  for(int i=0;i<N;i++) cin>>d[i];
  int M;
  cin>>M;
  vector<int> t(M);
  for(int i=0;i<M;i++) cin>>t[i];
  sort(d.begin(),d.end());
  sort(t.begin(),t.end());
  int idxm=0;
  int idxn=0;
  while(idxm<M&&idxn<N){
    if(d[idxn]==t[idxm]){
      idxn++,idxm++;
    }
    else{
      idxn++;
    }
  }
  if(idxm==M) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  }


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

int main() {
    int H, W;
    cin >> H >> W;

    vector<string> S(100);
    for (int i = 0; i < H; i++){
        cin >> S.at(i);
    }
    
    vector<int> dx = {-1, -1, 0, 1, 1, 1, 0, -1};
    vector<int> dy = {0, 1, 1, 1, 0, -1, -1, -1};

    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            if (S.at(i).at(j) == '.'){
                int counter = 0;
                for (int k = 0; k < 8; k++){
                    int x = i + dx.at(k);
                    int y = j + dy.at(k);
                    if (x >= 0 && x < H && y >= 0 && y < W && S.at(x).at(y) == '#'){
                        counter++;
                    }
                }   
                S.at(i).at(j) = '0' + counter;
            }
        }
    }
    
    for (int i = 0; i < H; i++){
        cout << S.at(i) << endl;
    }
    

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ri register int
#define fi first
#define se second
using namespace std;
const int rlen=1<<18|1;
inline char gc(){
	static char buf[rlen],*ib,*ob;
	(ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin));
	return ib==ob?-1:*ib++;
}
inline int read(){
	int ans=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return ans;
}
int n,m,k,fa[105];
typedef pair<int,int> pii;
typedef multiset<int>::iterator It;
typedef multiset<pii>::iterator Is;
inline bool check(int x){
	multiset<int>S;
	for(ri tmp,i=n;i;--i){
		if(!S.size()||*S.begin()+i>x){S.insert(i);continue;}
		It it=S.end(),ttmp;
		do{
			--it;
			tmp=i+*it;
			if(tmp<=x){
				S.erase(it);
				S.insert(tmp);
				break;
			}
		}while(it!=S.begin());
	}
	for(It it=S.begin();it!=S.end();++it)if(*it!=x)return 0;
	return 1;
}
inline int find(int x){return x^fa[x]?fa[x]=find(fa[x]):x;}
inline void merge(int x,int y){
	x=find(x),y=find(y);
	if(x^y)fa[x]=y;
}
inline void solve(int x){
	for(ri i=1;i<=n;++i)fa[i]=i;
	multiset<pii>S;
	for(ri tmp,i=n;i;--i){
		if(!S.size()||S.begin()->fi+i>x){S.insert(pii(i,i));continue;}
		Is it=S.end();
		do{
			--it;
			tmp=i+it->fi;
			if(tmp<=x){
				merge(i,it->se);
				S.erase(it);
				S.insert(pii(tmp,i));
				break;
			}
		}while(it!=S.begin());
	}
	vector<pii>ans;
	for(ri i=1;i<=n;++i)for(ri j=i+1;j<=n;++j)if(find(i)^find(j))ans.push_back(pii(i,j));
	cout<<ans.size()<<'\n';
	for(ri i=0;i<ans.size();++i)cout<<ans[i].fi<<' '<<ans[i].se<<'\n';
}
int main(){
	n=read(),m=n*(n+1)/2;
	for(ri i=n;i<m;++i)if(check(k=i))break;
	solve(k);
	return 0;
}

Measured memory_bytes: 384
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x)
#define debug(x)
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

int base = 25000;


bool match(char x, char y) {
    return x == '?' || y == '?' || x == y;
}

vint calc(string s, string t) {
    vint v(base*2, 1);
    int ss = s.size(), tt = t.size();
    rep(i, ss) rep(j, tt) {
        if (!match(s[i], t[j])) v[i-j+base] = 0;
    }

    return v;
};

void mainmain(){
    string a, b, c;
    cin >> a >> b >> c;


    auto calc = [&](string s, string t) {
        vint v(base*2, 1);
        int ss = s.size(), tt = t.size();
        rep(i, ss) rep(j, tt) {
            if (!match(s[i], t[j])) v[i-j+base] = 0;
        }

        return v;
    };

    vint ab = calc(a, b);
    vint bc = calc(b, c);
    vint ac = calc(a, c);

    int ans = INF;

    int n = 2000;
    rep(i, -2*n, 2*n+1) rep(j, -2*n, 2*n+1) {
        if (ab[i+base] && ac[j+base] && bc[j-i+base]) {
            int l = min(0, min(i, j));
            int r = max((int)a.size(), max(((int)b.size())+i, ((int)c.size())+j));
            mins(ans, r-l);
        }
    }

    cout << ans << endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m; 
  int k[m];
  vector<vector<int>> s(m);
  for(int i=0;i<m;i++){
    cin >> k[i];
    s[i].resize(k[i]);
    for(int j=0;j<k[i];j++){
      cin >> s[i][j];
      --s[i][j];
    }
  }
  int ans=0;
  vector<int> p(m);
  for(int i=0;i<m;i++)cin >> p[i];
  for(int i=0;i<(1<<n);i++){
    bool ok=true;
    for(int j=0;j<m;j++){
      int cnt=0;
      for(auto it:s[j]){
        if(i&(1<<it))cnt++;
      }
      cnt%=2;
      if(cnt!=p[j])ok=false;
    }
    if(ok)ans++;
  }
  cout << ans << endl;
}
      

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,i,j,s;
  int ans=1;
  int max=-1;
  cin >> N;
  for (i=1; i <=N; i++) {
        j=i;
        s=0;
        while(j%2<1){
            j=j/2;
            s++;
        }
    if (s> max) {
      max = s;
      ans =i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3576
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    string s, s2 = "keyence";
    cin >> s;
    int t = 0, u = 0;
    while(t <= 7 && s[t] == s2[t]){
        t++;
    }
    reverse(begin(s), end(s));
    reverse(begin(s2), end(s2));
    while(u <= 7 && s[u] == s2[u]){
        u++;
    }
    cout << (t + u >= 7? "YES":"NO") << endl;
    return 0;
}


Measured memory_bytes: 256