akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define de(x) cout << #x << "=" << x << ", "
#define dd cout << '\n';
#define XinAi ios::sync_with_stdio(0), cin.tie(0);
#define F first
#define S second
#define int long long
using namespace std;
typedef pair<int,int> pii;

string s;
int res = 0;

signed main()
{
    cin >> s;
    for (int i=0; i<s.size(); i++)
    {
        res += s[i] - '0';
        res %= 9;
    }
    cout << (res==0? "Yes" : "No") << '\n';
}

Measured memory_bytes: 3656
#include <stdio.h>
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==5&&b==5&&c==7 || a==5&&c==5&&b==7 || b==5&&c==5&&a==7)printf("YES\n");
    else printf("NO\n");
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
INF = float("inf")
import numpy as np

MOD = 1000000007  # type: int


def solve(N: int, K: int, a: "List[List[int]]"):
    a = np.asarray(a, dtype=object)
    ans = np.identity(N, dtype=object)
    while K > 0:
        if K & 1:
            ans = np.mod(np.dot(ans, a), MOD)
        a = np.mod(np.dot(a, a), MOD)
        K >>= 1
    print(ans.sum() % MOD)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [[int(next(tokens)) for _ in range(N)]
         for _ in range(N)]  # type: "List[List[int]]"
    solve(N, K, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14448
N = int(input())
a_list = list(map(int, input().split()))

a_sum = sum(a_list)
l_a_sum = a_list[0]
min_diff = abs(a_sum - 2 * l_a_sum)
for i in range(1, N-1):
    l_a_sum += a_list[i]
    min_diff = min(min_diff, abs(a_sum - 2 * l_a_sum))
print(min_diff)




Measured memory_bytes: 24832
#include <stdio.h>
#define MAX 101

int A[MAX][MAX], B[MAX], C[MAX];

void serch(int x, int y){
  int i;
  C[x] = y;
  for(i=1; i<=B[x]; i++){
    if(C[A[x][i]] > y)
      serch(A[x][i], y+1);
  }
}

int main(){
  int i,j;
  int a,b;
  
  scanf("%d", &a);
  for(i=1; i<=a; i++){
    C[i] = 10000;
    for(j=1; j<=a; j++)
      A[i][j] = 0;
  }
  
  for(i=1; i<=a; i++){
    scanf("%d", &b);
    scanf("%d", &B[b]);
    for(j=1; j<=B[b]; j++)
      scanf("%d", &A[b][j]);
  }
  
  serch(1,0);
  
  for(i=1; i<=a; i++){
    if(C[i] == 10000)
      C[i] = -1;
    printf("%d %d\n", i, C[i]);
  }
  return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin>>s;
    int n = sz(s);
    const ll MOD=998244353;
    vector<vector<vector<ll>>> dp(n+1,vector<vector<ll>>(n+1,vector<ll>(n+1)));
    dp[0][0][0]=1;
    rep(i,0,n+1) rep(j,0,n+1) {
        if(i>0) dp[0][i][j]=dp[0][i-1][j];
        if(j>0) dp[0][i][j]=(dp[0][i][j]+dp[0][i][j-1])%MOD;
    }
    rep(i,1,n+1) {
        dp[i]=dp[i-1];
        if(s[n-i]=='0') {
            rep(j,0,n+1) {
                ll acc = 0;
                rep(k,0,n+1) {
                    dp[i][j][k]=(dp[i][j][k]+acc)%MOD;
                    acc=(acc+dp[i-1][j][k])%MOD;
                }
            }
        }
        else {
            rep(k,0,n+1) {
                ll acc = 0;
                rep(j,0,n+1) {
                    dp[i][j][k]=(dp[i][j][k]+acc)%MOD;
                    acc=(acc+dp[i-1][j][k])%MOD;
                }
            }
        }
    }
    // rep(i,0,n+1) {
    //     rep(j,0,n+1) {
    //         cerr<<dp[n][i][j]<<" ";
    //     }
    //     cerr<<endl;
    // }
    vector<vector<vector<bool>>> pos(n+1,vector<vector<bool>>(n+1,vector<bool>(n+1)));
    pos[0][0][0]=true;
    ll ans = 1;
    rep(i,1,n+1) {
        if(i-1>=0) {
            rep(j,0,n+1) rep(k,0,n+1) if(pos[i-1][j][k]) {
                if(j+k>0) pos[i][j][k] = true;
                if(s[i-1]=='0' && j<n && k>0) pos[i][j+1][k-1]=true;
                if(s[i-1]=='1' && k<n && j>0) pos[i][j-1][k+1]=true;
            }
        }
        if(i-2>=0) {
            rep(j,0,n+1) rep(k,0,n+1) if(pos[i-2][j][k]) {
                if(s[i-2]=='0') pos[i][j+1][k]=true;
                else pos[i][j][k+1]=true;
                
                if(s[i-1]=='0') pos[i][j+1][k]=true;
                else pos[i][j][k+1]=true;
            }
        }
        for(int j=n;j>=0;--j) for(int k=n;k>=0;--k) if(pos[i][j][k] && j+k>=2) {
                    if(j>0) pos[i][j-1][k]=true;
                    if(k>0) pos[i][j][k-1]=true;
                }
    }
    vector<vector<vector<bool>>> mark(n+1,vector<vector<bool>>(n+1,vector<bool>(n+1)));
    for(int i=n;i>0;--i) {
        rep(j,0,n+1) rep(k,0,n+1) if(mark[i][j][k] || pos[i][j][k]) {
            if(s[i-1]=='0' && j>0) mark[i-1][j-1][k] = true;
            if(s[i-1]=='1' && k>0) mark[i-1][j][k-1] = true;
        }
    }
    rep(i,1,n+1) {
        rep(j,0,n+1) rep(k,0,n+1) if(pos[i][j][k] && !mark[i][j][k]) {
            //cerr<<n-i<<" "<<j<<" "<<k<<endl;
            ans=(ans+dp[n-i][j][k])%MOD;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 234676
#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    int N; cin >> N;

    int x = 0;
    for (int i = 1; i <= N; i++)
    {
        int k; cin >> k;
        if (i != k) x++;
    }
    if (x <= 2)
    {
        cout << "YES\n";
    }
    else
        cout << "NO\n";
}

Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
	dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 13980
n,k = map(int, input().split())
d=[]
a=[]
for i in range(k):
    tmp = int(input())
    a.append(input().split())

flag=1
ans=0
for i in range(n):
    for j in a:
        if str(i+1) in j:
            flag=0
    if flag==1:
        ans+=1
    flag=1
print(ans)

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

struct UnionFind
{
  vector< int > par,rnk;
  UnionFind(int n){
    par.assign(n,0);
    rnk.assign(n,0);
    for(int i=0;i<n;i++){
      par[i] = i;
      rnk[i] = 0;
    }
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(rnk[x] < rnk[y]) par[x] = y;
    else par[y] = x;
    if(rnk[x] == rnk[y]) rnk[x]++;
  }
  int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
  }
  bool same(int x,int y){
    return find(x) == find(y);
  }
};

typedef pair< int , int > P;
struct Edge {
  int from,to,cost;
  Edge(){}
  Edge(int from,int to,int cost):from(from),to(to),cost(cost){};
  bool operator<(const Edge& e) const {
    return cost < e.cost;
  }
};
vector< Edge > Graph;
int V,E;

int kruskal(){
  sort(Graph.begin(),Graph.end());
  UnionFind uf(V+1);
  int total = 0;
  for(int i=0;i<Graph.size();i++){
    Edge e = Graph[i];
    if(uf.find(e.from) != uf.find(e.to)){
      uf.unite(e.from,e.to);
      total += e.cost;
    }
  }
  return total;
}

int main(){
  cin >> V >> E;
  for(int i=0;i<E;i++){
    int s,t,d;
    cin >> s >> t >> d;
    Graph.push_back(Edge(s,t,d));
  }
  cout << kruskal() << endl;
}

Measured memory_bytes: 2704
N=int(input())
S=input()
Q=int(input())
K=list(map(int,input().split()))

for k in K:
    ANS=0
    D=M=DM=0
    
    for i in range(N):
        if i-k>=0:
            if S[i-k]=="D":
                D-=1
                DM-=M
            elif S[i-k]=="M":
                M-=1

        if S[i]=="D":
            D+=1
        elif S[i]=="M":
            DM+=D
            M+=1
        elif S[i]=="C":
            ANS+=DM

    print(ANS)

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

using ll = long long;
using pii = pair<int, int>;
using graph = vector<set<pii>>;

void compress_graph(graph& g, int& uid) {
    const int n = g.size();
    queue<int> que;

    // remove leaves
    for(int v = 0; v < n; ++v) {
        if(g[v].size() == 1u) {
            que.push(v);
        }
    }
    while(!que.empty()) {
        const int v = que.front();
        que.pop();
        if(g[v].size() != 1u) continue;
        const auto e = *g[v].begin();
        g[v].clear();
        g[e.first].erase(make_pair(v, e.second));
        if(g[e.first].size() == 1u) {
            que.push(e.first);
        }
    }

    // constraction
    for(int v = 0; v < n; ++v) {
        if(g[v].size() == 2u) {
            que.push(v);
        }
    }
    while(!que.empty()) {
        const int v = que.front();
        que.pop();
        if(g[v].size() != 2u) continue;
        const int a = g[v].begin()->first, a_uid = g[v].begin()->second;
        const int b = next(g[v].begin())->first, b_uid = next(g[v].begin())->second;
        if(a == b) continue; // self-loop
        g[v].clear();
        g[a].erase(make_pair(v, a_uid));
        g[b].erase(make_pair(v, b_uid));
        ++uid;
        g[a].emplace(b, uid);
        g[b].emplace(a, uid);
        if(g[a].size() == 2u) {
            que.push(a);
        }
        if(g[b].size() == 2u) {
            que.push(b);
        }
    }

    map<int, int> eidx;
    graph tg(n);
    for(int v = 0; v < n; ++v) {
        for(auto& e : g[v]) {
            if(eidx.count(e.second) == 0) {
                const int id = eidx.size();
                eidx[e.second] = id;
            }
            tg[v].emplace(e.first, eidx[e.second]);
        }
    }
    g = move(tg);
}

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

    int n, m; cin >> n >> m;
    graph g(n);
    int uid = 0;
    for(int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        a--, b--;
        g[a].emplace(b, uid);
        g[b].emplace(a, uid);
        uid += 1;
    }
    compress_graph(g, uid);

    set<ll> cycles;
    for(int s = 0; s < n; ++s) {
        if(g[s].empty()) continue;
        vector<bool> used_v(n);
        function<void(int, ll)> dfs = [&] (int v, ll used_edge) {
            used_v[v] = true;
            for(auto const& e : g[v]) {
                if(used_edge & (1LL << e.second)) continue;
                used_edge ^= 1LL << e.second;
                if(e.first == s) {
                    cycles.insert(used_edge);
                    used_edge ^= 1LL << e.second;
                    continue;
                }
                if(!used_v[e.first]) {
                    dfs(e.first, used_edge);
                }
                used_edge ^= 1LL << e.second;
            }
            used_v[v] = false;
        };
        dfs(s, 0);
    }

    cout << cycles.size() << endl;
}



Measured memory_bytes: 22140
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=100000007;
const ll INF=1000000101001;
int main(){
 string s;cin>>s;
 int size=s.size();
 int n=(size+1)/2;
 int cnt=0;
 rep(i,n){
     if(s[i]!=s[size-1-i])cnt++;
 }
 cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    long long x; cin >> x;
    ll a = 100;
    int ptr = 0;
    for(;a<x;ptr++){
        a = a*1.01;
    }
    cout << ptr << endl;
    return 0;
}


Measured memory_bytes: 3640
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
 
  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));
  $a[] = PHP_INT_MAX;
  sort($a);
 
  $C = [];
  $ans=0;
  $ok = false;
  for ($i=0; $i<$n; $i++) {
    if(isset($C[$a[$i]])){
      $ok = true;
    }
    if($ok == false){
      $x = $a[$i];
      while($x <= 1000000){
        $C[$x] = true;
        $x += $a[$i];
      }
      if($a[$i+1] != $a[$i]){
        $ans++;
      }
    }
    $ok = false;
  }
 
  echo $ans;


Measured memory_bytes: 66520
#include<stdio.h>
int main()
{
	int a[3]={0};
	int i,j,x;
	int k=0;
	for(i=0;i<3;i++)
	{
	scanf("%d",&x);
	a[i]=x;
	}
	for(i=0;i<2;i++)
	{
		for(j=i+1;j<3;j++)
		{
			if(a[0]==a[1]&&a[1]==a[2])
			k=1;
		 	else if(a[i]!=a[j])
			k++;
			
		}
	}
	printf("%d\n",k);
	return 0;
}

Measured memory_bytes: 128
import io
import sys
from math import ceil


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
20 1
'''


def MAIN():
  # T_IN()
  A()


def A():
  n, d = IN_L_I()

  print(ceil(n / (d * 2 + 1)))

  return None


def B():
  return None


def C():
  return None


MAIN()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long MOD = 1000000007;
const long long INF = 0x3f3f3f3f;
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int l, r;
	cin >> l >> r;
	r = min(r, l + 4038);
	int ans = 2018;
	for (int i = l; i <= r; i++) {
		for (int j = i + 1; j <= r; j++) {
			int x = i * j % 2019;
			ans = min(ans, x);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n,capacity,time_limit=map(int,input().split())
a=sorted([int(input()) for _ in range(n)])
c=0
start_num=0

while True:
    if start_num>=n:break
    start_time=a[start_num]
    for x in range(start_num,start_num+capacity):
        if x>=n:break
        if start_time+time_limit>=a[x]:start_num+=1
        else:break
    c+=1

print(c)

Measured memory_bytes: 14048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n,m;
    cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
	// your code goes here
	int n,k;
	cin >> n >> k;
	vector<int> p(n);
	for(int i = 0; i< n; i++) cin >> p[i];
	sort(p.begin(),p.end());
	int ans = 0;
	for(int i= 0; i < k; i++) ans += p[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
#include<deque>
#include<cstdio>
using namespace std;
deque<int> q;
int n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		int x; scanf("%d",&x);
		if(i%2) q.push_back(x); else q.push_front(x);
	}
	if(n%2)
		for(;!q.empty();q.pop_back()) printf("%d ",q.back());
	else for(;!q.empty();q.pop_front()) printf("%d ",q.front());
	return 0;
}

Measured memory_bytes: 2944
n = int(input())
s = input()
m = n

w = [s[0].count('W')]
e = [s[0].count('E')]

for i in range(1, n):
    if s[i] == 'W':
        w.append(w[i-1]+1)
        e.append(e[i-1])
    else:
        w.append(w[i-1])
        e.append(e[i-1]+1) 

for i in range(n):
    if i > 0:
        cnt = w[i-1] + e[-1] - e[i]
    else:
        cnt = e[-1] - e[0]
    m = min(cnt, m)
print(m)
    


Measured memory_bytes: 18196
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma warning (disable:4996)
#include"bits/stdc++.h"
#define int long long
#define MRE assert(0);
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const long long mod = 998244353;
const long long inf = 1e17;
const int maxN = 1000005;
typedef pair<int, int> P;
int isprime[1000008];
int keisu[1000008];
int inv[1000008];
int a[200006];
int facsum[1000008];
vector<int>fact[1000006];
vector<int>primes;
int modpow(int a, int x) {
	int res = 1;
	while (x) {
		if (x & 1)res = res*a%mod;
		a = a*a%mod; x >>= 1;
	}
	return res;
}
int frac(int a, int b) {//a/b
	return inv[b]*a%mod;
}
void furui() {
	for (int i = 2; i < maxN; i++) {
		if (isprime[i]==-1)continue;
		isprime[i] = 1;
		primes.push_back(i);
		for (int j = i + i; j < maxN; j += i) {
			isprime[j] = -1;
		}
	}
}
void setkeisu() {
	rep(i, maxN)keisu[i] = 1;
	for (int p : primes) {
		int now = p;
		while (now < maxN) {
			if (p == now) {
				for (int i = now; i < maxN; i += now) {
					keisu[i] *= inv[p] - 1;
					keisu[i] %= mod;
				}
			}
			else {
				for (int i = now; i < maxN; i += now) {
					keisu[i] *= inv[p];
					keisu[i] %= mod;
				}
			}
			now *= p;
		}
	}
}

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

	int n; cin >> n;
	rep(i, n)cin >> a[i];
	inv[1] = 1;
	for (int i = 2; i < maxN; i++) {
		inv[i] = mod - (inv[mod%i] * (mod / i)) % mod;
	}
	furui();
	setkeisu();
	int res = 0;

	rep(i, n) {
		if (fact[a[i]].size() == 0) {
			for (int j = 1; j*j <= a[i]; j++) {
				if (a[i] % j == 0) {
					fact[a[i]].push_back(j);
					if (j*j != a[i])fact[a[i]].push_back(a[i] / j);
				}
			}
		}
		for (int e : fact[a[i]])facsum[e] = (a[i] + facsum[e]) % mod;
	}

	rep(i, n) {
		for (int e : fact[a[i]]) {
			res += a[i] * facsum[e] % mod*keisu[e] % mod;
			res %= mod;
		}
	}

	rep(i, n)res = (res + mod - a[i]) % mod;
	res = res*inv[2] % mod;
	cout << res << '\n';
}

Measured memory_bytes: 94836
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int main(){
    int n;
    scanf("%d",&n);
    vector<int> p(n+1,0);
    int i;
    int max=0;
    int ans=0;
    for(i=1;i<=n;i++){
        scanf("%d",&p[i]);
        if(max<p[i]){
            max=p[i];
        }
        ans=ans+p[i];
    }
    printf("%d\n",ans-max/2);
    return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
        String s=br.readLine();
        for(int i=0;i<s.length();i++){
          if(Character.isUpperCase(s.charAt(i))){
            sb.append(s.substring(i,i+1).toLowerCase());
          }else{
            sb.append(s.substring(i,i+1).toUpperCase());
          }
        }
        System.out.println(sb);
	}
}

Measured memory_bytes: 24804
N = int(input())
Num = list(map(int,input().split()))
ki = []
count = 0
for i in range(N):
    if Num[i] in ki:
        pass
    elif Num[i] > 100000:
        count+=1
    else:
        c = Num.count(Num[i])
        if c > Num[i]:
            count+=(c-Num[i])
        elif c < Num[i]:
            count+=c
        else:
            pass
        ki.append(Num[i])
print(count)

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

int main() {
  int a,b;
  cin>>a>>b;
  int d=b;
  int c=0;
  while(b>0){
    b=b/10;
    c++;
  }
  for(int i=0;i<c;i++){
    a=a*10;
  }
  for(int i=0;i<1000;i++){
    if(i*i==a+d){
      cout<<"Yes"<< endl;
      return 0;
    }
  }
  cout<<"No"<< endl;
}



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


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = long.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

        long[] B = new long[n];
        for (int i = 0; i < n; i++)
        {
            B[i] = a[i] - (i + 1);
        }

        Array.Sort(B);

        //中央値を求める
        long ans1 = 0;
        long b1 = B[(B.Length) / 2];
        for (int i = 0; i < n; i++)
        {
            ans1 += Math.Abs(a[i] - (b1 + i + 1));
        }

        long ans2 = 0;
        long b2 = B[(B.Length - 1) / 2];
        for (int i = 0; i < n; i++)
        {
            ans2 += Math.Abs(a[i] - (b2 + i + 1));
        }

        // 出力
        Console.WriteLine(Math.Min(ans1, ans2));
    }
}

Measured memory_bytes: 33796
#include <iostream>
#include <algorithm>

#define N 105000

using namespace std;

int main()
{
  int n = 0;
  bool prime[N];

  fill(prime, prime+N, true);

  for(int i = 2; i < N; ++i){
    if(prime[i])
      for(int j = i+i; j < N; j += i)
	prime[j] = false;
  }

  while(cin>>n && n){
    int sum = 0;

    for(int i = 2; i < N; ++i){
      if(prime[i]){
	sum += i;
	if(--n == 0) break;
      }
    }

    cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 1260
using System;

namespace B_1
{
    class Program
    {
        static void Main(string[] args)
        {
            int year = 0;
            double ans = 100;
            var x = long.Parse(Console.ReadLine());

            while (x > ans)
            {
                ans = ans * 1.01;
                ans = Math.Floor(ans);
                //Console.WriteLine(ans);
                year++;
            }

            //Console.WriteLine(ans);
            Console.WriteLine(year);
        }
    }
}


Measured memory_bytes: 27556
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  int n;
  cin>>n;
  int ans=0,idx=0;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    if(idx<a){
      idx=a;
      ans=a+b;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	static long fac[];
	static long finv[];
	static int mod = 1000000007;

	public static void main(String[] args) {
      
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		
		fac = new long [n+1];
		finv = new long [n+1];
		
		Cominit(n);
		
		int B = k;
		int R = n-k;

		
		for(int i = 1 ;  i <= k ; i++) {
			long ans = COM(R+1,i);
			ans = ans * COM(B-1,i-1) % mod;
			System.out.println(ans);
		}
		
		
		
	}
	
	
	static void Cominit(int n) {
	    fac[0] = fac[1] = 1;
	    finv[0] = finv[1] = 1;;
	    for (int i = 2; i <= n; i++){
	       fac[i] = fac[i-1] * i % mod;
	       finv[i] = finv[i-1] * Modinv(i) % mod;
	    }
	}

	// 二項係数計算
	static long COM(int n, int k){
	    if (n < k) return 0;
	    if (n < 0 || k < 0) return 0;
	    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
	}
	
	//a^n mod
	static long Modpow(long a, long n) {
			long res = 1;
			while(n > 0) {
				if((n & 1) == 1) {
					res = res * a % mod;
				}
				a = a * a % mod;
				n >>= 1;
			}
			return res;
		}
		
		//a^-1
	static long Modinv (long a) {
			return Modpow(a,mod-2);
		}


}


Measured memory_bytes: 21716
program main
  implicit none
  integer :: i, j, n, res
  character(10) :: s
  read (*, *) s
  n = len(trim(s))

  res = 0
  outer: do i = 1, n
    do j = i, n
      if (.not. (s(j:j) == "A" .or. s(j:j) == "C" .or. s(j:j) == "G" .or. s(j:j) == "T")) cycle outer
      res = max(res, j - i + 1)
    end do
  end do outer

  write (*, "(i0)") res
end program main


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Here your code !
    char s[100000];
    
    scanf("%s",s);
    
    int i = 0;
    
    while(s[i]!='\0'){
        if(i%2 == 0){
            printf("%c",s[i]);
        }
        i++;
    }
    printf("\n");
    return 0;
}


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

#define pb push_back
#define F first
#define S second

#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define int long long
#define ll long long

		
const int N = 2e5 + 5;
vector<vector<int>> v(N);
bool visited[N];
int dp[N], ans;
		
void dfs(int n){
	visited[n] = true;
	for(auto it : v[n]){
		if(!visited[it]){
			dfs(it);
		}
		dp[n] = max(dp[it] + 1, dp[n]);
	}
	ans = max(ans, dp[n]);
}

	
void solve(){
	int n, m;
	cin >> n >> m;
	while(m--){
		int x, y;
		cin >> x >> y;
		v[x].pb(y);
	}	
	for(int i = 1 ; i <= n ; i++){
		if(!visited[i])
			dfs(i);
	}
	cout << ans ;
}

signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T>
vector<T> compress(vector<T> v){
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  return v;
}

template<typename T>
map<T, Int> dict(const vector<T> &v){
  map<T, Int> res;
  for(Int i=0;i<(Int)v.size();i++)
    res[v[i]]=i;
  return res;
}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> ds(n);
  for(Int i=0;i<n;i++) cin>>ds[i];

  cout<<compress(ds).size()<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 123456789
//0x3f3f3f3f
#define INFL 10000000000000000
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<int,pii> pdii;
long long int MOD = 1000000007;
vector<pii> graph[2525];
int N;
ll L,T;
int main(){
	int n,m;
	cin>>n>>m;
	vector<ll>x(n),y(m),newx,newy;
	rep(i,n)cin>>x[i];
	rep(i,m)cin>>y[i];
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	for(int i=1;i<n;i++){
		newx.pb(x[i]-x[i-1]);
	}
	for(int i=1;i<m;i++){
		newy.pb(y[i]-y[i-1]);
	}
	ll sumx=0,sumy=0;
	ll now=0,temp=(ll)n-1;
	for(int i=0;i<n-1;i++){
		now=(now+temp)%MOD;
		temp=(temp-(ll)2);
		sumx = (sumx + (newx[i]*now)%MOD )%MOD;
	}
	now=0,temp=(ll)m-1;
	for(int i=0;i<m-1;i++){
		now=(now+temp)%MOD;
		temp=(temp-(ll)2);
		sumy = (sumy + (newy[i]*now)%MOD )%MOD;
	}
	ll ans=(sumx*sumy)%MOD;
	cout<<ans<<endl;
}



Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007
vi adj[123456];
bool vis[123456];
int parent[123456];

void dfs(int u, int p)
{
	vis[u] = true;
	//parent[u] = p;
	for (int x : adj[u])
	{
		if (!vis[x])
		{
			dfs(x, u);
		}
	}

}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n, m;
	cin >> n >> m;
	zip(i, 0, m)
	{
		int a, b;
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	// int con_component = 0;
	// rep(i, 1, n)
	// {
	// 	if (!vis[i])
	// 	{
	// 		dfs(i, 0);
	// 		con_component++;
	// 	}
	// }

	// if (con_component > 1)
	// {
	// 	cout << "No" << en;
	// 	return 0;
	// }
	queue<int>q;
	q.push(1);
	while (!q.empty())
	{
		int node = q.front();
		q.pop();
		for (auto it : adj[node])
		{
			if (!vis[it])
			{
				vis[it] = true;
				parent[it] = node;
				q.push(it);
			}
		}
	}
	cout << "Yes" << en;
	rep(i, 2, n)
	{
		cout << parent[i] << en;
	}



	return 0;
}



Measured memory_bytes: 13608
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int maxn=2009;
const int maxk=10009;
int n,K,len[maxn];
char s[maxn][maxk];
bitset<maxk> bit[maxn];
pii v[2][maxk];
int main()
{
    scanf("%d%d",&n,&K);
    for (int i=1;i<=n;++i) {
        scanf("%s",s[i]);
        len[i]=strlen(s[i]);
    }
    bit[n+1][0]=1;
    for (int i=n;i>=1;--i)
        bit[i]=bit[i+1]|(bit[i+1]<<len[i]);
    int c1=0;
    for (int i=1;i<=n;++i)
        if (bit[i+1][K-len[i]])
            v[1][++c1]=pii(i,0);
    for (int o=1;o<=K;++o) {
        char mmin='z';int c2=0;
        for (int i=1;i<=c1;++i)
            mmin=min(mmin,s[v[o&1][i].first][v[o&1][i].second]);
        putchar(mmin);
        int ID=n+1;
        for (int i=1;i<=c1;++i) {
            int id=v[o&1][i].first,pos=v[o&1][i].second;
            char ch=s[id][pos];
            if (ch!=mmin) continue;
            if (pos+1==len[id]) ID=min(ID,id);
            else v[(o+1)&1][++c2]=pii(id,pos+1);
        }
        for (int i=ID+1;i<=n;++i)
            if (K-o-len[i]>=0&&bit[i+1][K-o-len[i]])
                v[(o+1)&1][++c2]=pii(i,0);
        c1=c2;
    }
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
      cin >> vec.at(i);
  }
  int min1 = pow(10,8);
  for(int k=1;k<101;k++){
    int ans =0;
    for(int i:vec){
      ans += pow(k-i,2);
    }
    min1 = min(min1,ans);
  }
  cout << min1 <<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigInteger;
 
public class Main {
	public static String toFour(int x){
		String S = Integer.toString(x, 4);
		for(int i = S.length(); i <= 7; i++){
			S = "0" + S;
		}
		return S;
	}
	
	public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	int N = s.nextInt();
	int K = s.nextInt();
	int[] A = new int[N];
	for(int i = 0; i < N; i++){
		A[i] = s.nextInt();
	}

	for(int i = K; i < N; i++){
		if(A[i-K] < A[i]){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
    
  }
}

Measured memory_bytes: 60672
#include <bits/stdc++.h>
using namespace std;
int main(){
  int ans = 0;
  int n; cin >> n;
  string s; cin >> s;
  for(int i = 0; i < n; i++){
  	int msk1 = 0, msk2 = 0;
    for(int j = 0; j <= i; j++) msk1 |= 1<<(s[j] - 'a');
    for(int j = i + 1; j < n; j++) msk2 |= 1<<(s[j] - 'a');
    ans = max(ans, __builtin_popcount(msk1&msk2));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = []
for i in range(N):
    a = int(input())
    A.append(a)

x = dict()
for i in range(N):
    if A[i] in x:
        if x[A[i]] == 1:
            x[A[i]] -=1
        else:
            x[A[i]] += 1
    else:
        x[A[i]] = 1
ans = 0
for idx in x:
    ans += x[idx]
print(ans)

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	int A, B, C;
	cin >> A >> B >> C;
	
	int k;
	cin >> k;
	
	if(B > A && C > B){
		cout << "Yes" << endl;
		return 0;
	}
	
	while(B <= A){
		if(B > A){
			break;
		}
		if(k == 0) break;
		B *= 2;
		k--;
	}
	if(k == 0 && C < B){
		cout << "No" << endl;
		return 0;
	}
	if(k > 0) {	
		while(C <= B){
			if(C > B){
				break;
			}
			if(k == 0) break;
			C *= 2;
			k--;
		}
	}
	if(B > A && C > B){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
H,W = map(int,input().split())
m = []
for i in range(H):
  m.append(input())

ly = []
lt = []
for i in range(H):
  if "#" in m[i]:
    ly.append(i)
for j in range(W):
  c = 0
  for k in range(H):
    if m[k][j] == "#":
      c += 1
      break
  if c == 1:
    lt.append(j)    
###
for i in ly:
  s =""
  for j in lt:
    s += m[i][j]
  print(s)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] X = new int[n];
		for(int i = 0; i < n; i++) {
			X[i] = sc.nextInt();
		}
		int[] Y = new int[n];
		for(int i = 0; i < n; i++) {
			Y[i] = sc.nextInt();
		}		
		
		for(int i = 1; i <= 3; i++) {
			System.out.println(dist(X, Y, n, i));
		}
		System.out.println(distInf(X, Y ,n));
		
		sc.close();
	}	
	
	static double dist(int[] X, int[] Y, int n, int p) {
		double D = 0;
		for(int i = 0; i < n; i++) {
			double d = Math.abs(X[i] - Y[i]);
			D += Math.pow(d, p);
		}
		switch(p) {
			case 1 :{
				return(D);
			}
			case 2 :{
				return(Math.sqrt(D));
			}
			case 3 :{
				return(Math.cbrt(D));
			}
			default :{
				return(-1);
			}
		}
	}
	
	static double distInf(int[] X, int[] Y, int n) {
		double D = X[0] - Y[0];
		for(int i = 0; i < n; i++) {
			D = Math.max(D, Math.abs(X[i] - Y[i]));
		}
		return(D);
	}

}



Measured memory_bytes: 26528
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	ll N;  cin >> N;
	if(N % 2 == 1){
		cout << 0 << endl;
		return 0;
	}

	ll five_count = 0;
	ll keep = 5;
	while(keep <= N){
		five_count += N / keep / 2;
		keep *= 5;
	}

	cout << five_count << endl;
		
	return 0;
}


Measured memory_bytes: 256
n, m, q = map(int, input().split())
ans = [[0]*n for _ in range(n)]
for i in range(m):
  l, r = map(int, input().split())
  ans[l-1][r-1] += 1

for i in range(n-1, -1, -1):
  for j in range(i+1, n):
    ans[i][j] += ans[i][j-1]
for i in range(n-1, -1, -1):
  for j in range(i+1, n):
    ans [i][j] += ans[i+1][j]

for _ in range(q):
  p, q = map(int, input().split())
  print(ans[p-1][q-1])

Measured memory_bytes: 59224
from sys import exit
h, w = map(int, input().split())
S = [input() for i in range(h)]
for i, T in enumerate(S):
    for j, t in enumerate(T):
        if t == "#":
            flag = 0
            if j > 0:
                if T[j - 1] == "#":
                    flag += 1
            if j < w - 1:
                if T[j + 1] == "#":
                    flag += 1
            if i > 0:
                if S[i - 1][j] == "#":
                    flag += 1
            if i < h - 1:
                if S[i + 1][j] == "#":
                    flag += 1
            if flag == 0:
                print("No")
                exit()
print("Yes")


Measured memory_bytes: 9204
while True:
    e =""
    nums = [str(e) for e in input().split()]
    if nums[1] == "+":
        print ("{0}".format(int(nums[0]) + int(nums[2])))
    elif nums[1] == "-":
        print ("{0}".format(int(nums[0]) - int(nums[2])))
    elif nums[1] == "*":
        print ("{0}".format(int(nums[0]) * int(nums[2])))
    elif nums[1] == "/":
        print ("{0}".format(int(nums[0]) // int(nums[2])))
    else:
        exit()


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int N, M, Q;
int a[55], b[55], c[55], d[55];
int A[11];

int main() {
    cin >> N >> M >> Q;
    for_(i,0,Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i]; --b[i];
    }

    int ans = 0;
    function<void(int,int)> rec = [&](int i, int p) {
        if (i == N) {
            int sum = 0;
            for_(i,0,Q) {
                if (A[b[i]] - A[a[i]] == c[i]) sum += d[i];
            }
            ans = max(ans, sum);
            return;
        }

        for_(x,p,M+1) {
            A[i] = x;
            rec(i + 1, x);
        }
    };

    rec(0, 1);
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long llint;
#define inf 1e18

llint h,w;
void solve(){
	cin >> h >> w;

	llint x;
	llint y;
	if(h%2==0){
		x=h/2;
		y=h/2;
	}
	else{
		x=(h+1)/2;
		y=x-1;
	}
	llint ans=0;
	for(int i=0;i<w;i++){
		if(i%2==0){
			ans+=x;
		}
		else{
			ans+=y;
		}
	}
	if(h==1 || w==1)ans=1;
	cout << ans << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
s = input()
S = [str(c) for c in s]
result = 'Yes'
for i in range(len(s)):
  if i % 2 == 0:
    if S[i] == 'L':
      result = 'No'
  else:
    if S[i] == 'R':
      result = 'No'
print(result)

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<long long> a(n);
	for(int i=0;i<n;i++)
		cin >> a[i];

//	multiset<long long> st;
	unordered_map<long long,int> mp;

	long long cnt=0;

	for(int i=0;i<n;i++)
	{
		long long key=(a[i]*(-1)+i);
		// cnt+=(upper_bound(st.begin(),st.end(),key)-lower_bound(st.begin(),st.end(),key));
		// cnt+=st.count(key);
		// st.insert(a[i]+i);
		cnt+=mp[key];
		mp[a[i]+i]+=1;
	}

	cout << cnt << endl;




}

Measured memory_bytes: 24588
import java.util.*;
import java.util.stream.*;

class Main {
    public static int count = 0;
    public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	int n = in.nextInt();
	int[] S = new int[n];
	for (int i = 0; i < n; i++) {
	    S[i] = in.nextInt();
	}
	mergeSort(S, 0, n);
	System.out.println(IntStream.of(S)
			   .mapToObj(String::valueOf)
			   .collect(Collectors.joining(" ")));
	System.out.println(count);
    }

    public static void merge(int[] S, int left, int mid, int right) {
	int n1 = mid - left, n2 = right - mid;
	int[] L = new int[n1 + 1], R = new int[n2 + 1];
	for (int i = 0; i < n1; i++) {
	    L[i] = S[left + i];
	}
	for (int i = 0; i < n2; i++) {
	    R[i] = S[mid + i];
	}
	L[n1] = R[n2] = Integer.MAX_VALUE;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
	    count++;
	    if (L[i] <= R[j]) {
		S[k] = L[i++];
	    } else {
		S[k] = R[j++];
	    }
	}
    }

    public static void mergeSort(int[] S, int left, int right) {
	if (left + 1 < right) {
	    int mid = (left + right) / 2;
	    mergeSort(S, left, mid);
	    mergeSort(S, mid, right);
	    merge(S, left, mid, right);
	}
    }
}



Measured memory_bytes: 181288
import java.util.Scanner;

class Main{
	public static void main(String[] a){
		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();
        scanner.close();
		if (input.length() > 20) return;
		String reverse="";
		
		char[] c = input.toCharArray();
		for (int i = c.length; i > 0; i--) {
			reverse += c[i-1];
		}
		System.out.println(reverse);
	}
}

Measured memory_bytes: 25896
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(int i=(int)(x);i<(int)(y);i++)
#define RREP(i,x,y) for(int i=(int)(x);i>=(int)(y);i--)
#define all(x) (x).begin(),(x).end()

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

typedef long long ll;

using namespace std;

const int MAX_HW = 100 * 100;
int N, H, W;
int a[MAX_HW];

bool solve() {
    int cnt = 0;
    int color = 0;
    REP(y, 0, H){
        string line = "";
        REP(x, 0, W) {
            if(a[color] <= cnt){
                color++;
                cnt = 0;
            }
            string space = (line == "") ? "" : " ";
            if(y % 2 == 0){
                line = line + space + to_string(color+1);
            }else{
                line = to_string(color+1) + space + line;
            }
            cnt++;
        }
        cout << line << "\n";
    }
}

int main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> H >> W;
    cin >> N;
    REP(i, 0, N){
        cin >> a[i];
    }
    solve();
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int M = scan.nextInt();
        for(int i=0; i<M; i++) {
            N -= scan.nextInt();
        }
        System.out.println(N>=0?N:-1);
    }
}

Measured memory_bytes: 46372
s = input()
n = len(s)


count = 0
for i in range(pow(2,n-1)):
    k = 0
    buf = 0
    for j in range(n):
        if((i & (1<<j))):
            buf +=pow(10,k)*int(s[n-1-j])
            #print(buf)
            count += buf
            buf = 0
            k = 0
        else:
            buf +=pow(10,k)*int(s[n-1-j])
            k += 1
    count += buf
print(count)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAX = 30;

bool submit[MAX];

int main()
{
    int t;
    REP(MAX - 2){ cin >> t; submit[t - 1] = true;}

    REP(MAX)if(!submit[i]){ cout << i + 1 << endl; }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    set<int> mochi;

    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        mochi.insert(a);
    }
    cout << mochi.size() << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		char[] str = scn.nextLine().toCharArray();
		int N = str.length;
		int ans0 = 0, ans1 = 0;
		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) {
				if (str[i] == '0') {
					ans0++;
				} else {
					ans1++;
				}
			} else {
				if (str[i] == '1') {
					ans0++;
				} else {
					ans1++;
				}
			}
		}
		System.out.println(Math.min(ans0, ans1));
	}

}


Measured memory_bytes: 26556
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> A;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A.push_back(t);
    }

    std::sort(std::begin(A), std::end(A));

    int64_t s = 0;
    std::vector<int64_t> S;
    for (int64_t i = 0; i < N-1; ++i) {
        s += A[i];
        S.push_back(s);
    }

    for (int64_t i = N-1; i > 0; --i) {
        if (S[i-1] * 2 < A[i]) {
            std::cout << N - i << std::endl;
            return 0;
        }
    }
    std::cout << N << std::endl;

    return 0;
}


Measured memory_bytes: 2548
# coding: utf-8
 
 
def main():
 
    penki_list = input().split(' ')

    # setは重複する要素を持たない→複数のデータをまとめる
    # lenは要素の数
    print(len(set(penki_list)))
 
    return 0
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
l = [tuple(map(int,input().split())) for _ in range(3)]
s = abs((l[1][0]-l[0][0])*(l[2][1]-l[0][1]) - (l[1][1]-l[0][1])*(l[2][0]-l[0][0]))
a = ((l[1][0]-l[0][0])**2 + (l[1][1]-l[0][1])**2)**.5
b = ((l[2][0]-l[1][0])**2 + (l[2][1]-l[1][1])**2)**.5
c = ((l[2][0]-l[0][0])**2 + (l[2][1]-l[0][1])**2)**.5
t = max(a,b,c)
r = s/(a+b+c)
ng = r
ok = 0
for _ in range(80):
  mid = (ok+ng)/2
  if t*(1-mid/r) >= mid*2:
    ok = mid
  else:
    ng = mid
print("{:.12}".format(ok))


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <typeinfo>

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REP1(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
//#define YES(ans) ans?cout<<"YES":cout<<"NO"

/*
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define all(x) (x).begin(),(x).end()
*/

using namespace std;

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

    int a[5];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    cout << a[2] * 10 + a[1] + a[0];
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
using Graph = vector<vector<pair<int, int> > >;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

int dp[3][100010]; //{a_case,b_case,c_case}[...]

int a[10010];
int b[10010];
int c[10010];

int main() {
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i] >> c[i];
		if (i == 0) {
			dp[0][i] = a[i];
			dp[1][i] = b[i];
			dp[2][i] = c[i];
			continue;
		}
		else if (i > 0) {
			dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a[i];
			dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + b[i];
			dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + c[i];
		}
	}
	cout << max(dp[2][N-1],max(dp[0][N - 1], dp[1][N - 1])) << endl;




	return 0;
}


Measured memory_bytes: 1536