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

int main(){
  string S;
  cin >> S;
  int N, input[15];
  N = S.size();
  
  long int sum = 0;
  
  for(int i=0;i<(1<<N-1);i++){
    long int acc = 0;
    for(int j=0;j<N;j++){
      acc *= 10;
      acc += S[j] - '0';
      if((i & (1<<j)) == 0){
        sum += acc;
        acc = 0;
      }
    }
    sum += acc;
  }
  
  
  
  //sum += atol(S.substr(0, N).c_str());
  
  
  /*
  for(int i=1;i<N;i++){
    string left = S.substr(0, i);
    long int left_num = atol(S.substr(0, i).c_str());
    long int right_num = atol(S.substr(i, N).c_str());
    sum += left_num + right_num;
    cout << left_num << " " << right_num << endl;
  }
  
  for(int i=0;i<N;i++){
    long int res = S[i] - '0';
    sum += res;
  }
  */
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    int A[300][300];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            cin >> A[i][j];
        }
    }
    int cnt[300];
    int ans = 500;
    for(int i = 0; i < M; i++){
        for(int j = 0; j < M; j++){
            cnt[j] = 0;
        }
        for(int j = 0; j < N; j++){
            cnt[A[j][0]-1]++;
        }
        int cnt_max = 0;
        int max_idx;
        for(int j = 0; j < M; j++){
            if(cnt_max < cnt[j]){
                cnt_max = cnt[j];
                max_idx = j;
            }
        }
        ans = min(ans, cnt_max);
        for(int j = 0; j < N; j++){
            bool flag = false;
            for(int k = 0; k < M-1; k++){
                if(A[j][k] == max_idx+1) flag = true;
                if(flag){
                    A[j][k] = A[j][k+1];
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
//作者:中国江苏南京丁天行
using namespace std;
int n,a[200005],k,ans;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        int x;
        scanf("%d",&x);
        a[x]=i;
    }
    for(int i=1;i<=n;++i){
        if(a[i]>a[i-1])++k;
        else ans=max(ans,k),k=1;
    }
    printf("%d\n",n-max(ans,k));
	//system("pause");
	return 0;
}


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

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

    int p[n+1], q[n+1];
    p[0] = q[0] = 0;
    for(int i = 1; i <= n; i++){
        cin >> p[i];
        q[p[i]] = i;
    }  

    int dp[n+1]; dp[0] = 0;
    for(int i = 1; i <= n; i++){
        if(q[p[i]-1] < i){
            dp[i] = dp[q[p[i]-1]]+1;
        }else{
            dp[i] = 1;
        }
    }

    int ans = -1;
    for(int i = 1; i <= n; i++) ans = max(ans, dp[i]);

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

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

const int N=2030,inf=1e9;
int ans,n,l[N],r[N],mx[N];
char S[N],T[N];

void solve(){
	for(int i=0;i<n;++i){
		l[i]=r[i]=0;
		for(int j=i;T[j]=='0';j=(j+1)%n)++r[i];
		for(int j=i;T[j]=='0';j=(j+n-1)%n)++l[i];
	}
	for(int i=0;i<n;++i){
		memset(mx,0,sizeof mx);
		int cnt=i;
		for(int j=0;j<n;++j)if(S[j]!=T[(i+j)%n])
			mx[l[j]]=max(mx[l[j]],r[j]-i),++cnt;
		int xm=0,mn=inf;
		for(int j=n-1;~j;--j)
			mn=min(mn,xm+j),xm=max(xm,mx[j]);
		ans=min(ans,2*mn+cnt);
	}
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>S>>T;n=strlen(S);ans=inf;
	int flag1=0,flag2=0;
	for(int i=0;i<n;++i){
		if(S[i]=='1')flag1=1;
		if(T[i]=='1')flag2=1;
	}
	if(!flag2){
		if(flag1)cout<<-1<<'\n';
		else cout<<0<<'\n';
		return 0;
	}
	solve();
	reverse(S,S+n);reverse(T,T+n);
	solve();
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
<?php
/**
 * ABC126
 * D - Even Relation
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d", $n);

for ($i = 0; $i < $n - 1; $i++) {
    fscanf(STDIN, "%d %d %d", $u, $v, $w);
    $tree[--$u][--$v] = $w;
    $tree[$v][$u] = $w;
}

$map = array_fill(0, $n, false);

dfs(0, 0);

foreach ($map as $m) {
    echo $m, PHP_EOL;
}

function dfs($parent, $color) {
    global $map, $tree;
    $map[$parent] = $color;
    foreach ($tree[$parent] as $child => $length) {
        if ($map[$child] !== false) continue;
        if ($length % 2 == 1) {
            dfs($child, 1 - $color);
        } else {
            dfs($child, $color);
        }
    }
}



Measured memory_bytes: 68088
from sys import setrecursionlimit
setrecursionlimit(100000000)
from collections import defaultdict
from collections import deque
# starting with start node and then looking for the kids
# and the solving the sub-problem with kids
def recursive_dfs(graph, start_node, map1):
  if start_node not in graph:
    map1[start_node] = 0
    return 0
  dist = 0
  for child in graph[start_node]:
    if child not in map1:
      dist = max(recursive_dfs(graph, child, map1), dist)
    else:
      dist = max(map1[child], dist)
  map1[start_node] = dist + 1
  #print(map1)
  return (dist + 1)
 
N,M = [int(i) for i in input().split()] # nodes, edges
graph = defaultdict(list)
for i in range(M):
  s,d = [i for i in input().split()]
  graph[s].append(d)
map1 = defaultdict(int)
ans = 0
for i in range(1, N+1):
  if i in map1:
    ans = max(ans, map1[str(i)])
  else:
    ans = max(recursive_dfs(graph, str(i), map1), ans)
print("%s" % ans)


Measured memory_bytes: 179460
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000003;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
map<P,ll> mp;
const ll MAX = 2000010;//設定して

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;//＊１
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
//階乗
long long factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return (fac[n]*finv[k])%mod;
}
// 二項係数計算
long 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-2
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    init();
    int q;
    cin>>q;
    while(q--){
        ll x,d,n;
        cin>>x>>d>>n;
        if(x==0)cout<<0<<endl;
        else if(d==0){
            cout<<modpow(x,n)<<endl;
        }
        else if(n>=mod)cout<<0<<endl;
        else if(d==1){
            cout<<factor(x+n-1,x-1)<<endl;
        }
        else{
            x*=modpow(d,mod-2);
            x%=mod;
            cout<<(factor(x+n-1,x-1)*modpow(d,n))%mod<<endl;
        }
    }
}

Measured memory_bytes: 47744
#include<bits/stdc++.h>
#define lp3(i,a,b) for(int i=a;i<b;i++)
#define lp2(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	string ans="Alice";
	int a,b;
	cin>>a>>b;
	if(a==1)a+=100;
	if(b==1)b+=100;
	if(a==b)ans="Draw";
	else if(a<b)ans="Bob";
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
A=[list(map(int,input().split())) for i in range(n)]

M=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
    for j in A[i][2:]:
        M[i][j-1]=1

for i in range(n):
    print(*M[i])


Measured memory_bytes: 6388
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
#define MOD 1000000007

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

  ll n, m;
  cin >> n >> m;

  if (n == m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int a, b;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b;
    if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
        cout << a*b << E;
    }
    else {
        cout << -1 << E;
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
S = input()

arr = []
cnt = 0
comp = S[0]
for s in S:
    if s==comp:
        cnt += 1
    else:
        arr.append(cnt)
        cnt = 1
        comp = s
arr.append(cnt)

if len(arr)<3:
    print(sum(arr))
else:
    if S[0]=='1':
        L = (len(arr)+1)//2 - K +1
        l = 0
        tmp = sum(arr[2*l:2*(l+K)+1])
        ans = tmp
        for l in range(1, L):
            tmp = tmp - (arr[2*(l-1)]+arr[2*l-1]) + sum(arr[2*(l-1+K)+1 : min(2*(l+K)+1, len(arr))])
            ans = max(tmp, ans)
    else:
        L = (len(arr)+1)//2 - K + 1
        l = 0
        tmp = sum(arr[2*l:2*(l+K)])
        ans = tmp
        for l in range(1, L):
            tmp = tmp - sum(arr[max(0,2*l-3) : 2*l-1]) + sum(arr[2*(l+K-1): min(2*(l+K), len(arr))])
            ans = max(tmp, ans)
            
    print(ans)

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

using namespace std;
typedef long long ll;

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

  for (int i = 0; i < k; ++i) {
    vector<int> cnt(n, 0);
    for (int j = 0; j < n; ++j) {
      int from = max(0, j - a[j]);
      int to = min(n - 1, j + a[j]);
      cnt[from]++;
      if (to + 1 < n) cnt[to + 1]--;
    }
    for (int j = 1; j < n; ++j) {
      cnt[j] = cnt[j - 1] + cnt[j];
    }
    a = cnt;
    if (a[0] == n) break;
  }
  for (int i = 0; i < n; ++i) {
    cout << a[i];
    if (i == n - 1) puts("");
    else cout << ' ';
  }
  return 0;
}



Measured memory_bytes: 4844
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int c=a;
    if(b>a)
    {
        c=b;
    }
    if(a*b*c%2==0)
    {
        printf("No\n");
    }
    else
    {
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <set>
using namespace std;
 
struct NODE {
    int id;
    int degree;
    int parent;
    int depth;
    vector<int> child;
};
 
 
int main() {
    vector<NODE> node;
    int n;
    int i,j;
    int id,k;
    scanf("%d",&n);
    node.resize(n);
    for(i=0; i<n; ++i) {
        scanf("%d%d",&id,&k);
        node[id].parent=-1; // default
        node[id].depth=0;   // default
        if(0==(node[id].degree=k)) {
            continue;
        }
        node[id].child.resize(k);
        for(j=0; j<k; ++j) {
            scanf("%d",&node[id].child[j]);
        }
    }
    for(i=0; i<n; ++i) {
        if((k=node[i].degree)==0) continue;
        for(j=0; j<k; ++j) {
            node[node[i].child[j]].parent=i;
        }
    }
    for(i=0; i<n; ++i) {
        j=i;
        while(node[j].parent!=-1){
            j=node[j].parent;
            ++node[i].depth;
        }
    }
    for(i=0; i<n; ++i) {
        if(node[i].parent==-1) {
            printf("node %d: parent = %d, depth = %d, root, [",i,node[i].parent,node[i].depth);
            for(j=0; j<node[i].degree-1; ++j) {
                printf("%d, ",node[i].child[j]);
            }
            if(node[i].degree!=0) {
                printf("%d",node[i].child[j]);
            }
            printf("]\n");
        } else if(node[i].degree==0) {
            printf("node %d: parent = %d, depth = %d, leaf, [",i,node[i].parent,node[i].depth);
            for(j=0; j<node[i].degree-1; ++j) {
                printf("%d, ",node[i].child[j]);
            }
            if(node[i].degree!=0) {
                printf("%d",node[i].child[j]);
            }
            printf("]\n");
        } else {
            printf("node %d: parent = %d, depth = %d, internal node, [",i,node[i].parent,node[i].depth);
            for(j=0; j<node[i].degree-1; ++j) {
                printf("%d, ",node[i].child[j]);
            }
            if(node[i].degree!=0) {
                printf("%d",node[i].child[j]);
            }
            printf("]\n");
        }
    }
    return 0;
}

Measured memory_bytes: 6572
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
tot = abs(A[1])
for i in range(2,N+1):
    tot += abs(A[i]-A[i-1])
tot += abs(A[N])
for i in range(1,N+1):
    if i==1:
        print(tot-abs(A[1])-abs(A[2]-A[1])+abs(A[2]))
    elif i==N:
        print(tot-abs(A[N])-abs(A[N]-A[N-1])+abs(A[N-1]))
    else:
        print(tot-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))

Measured memory_bytes: 83280
#include<stdio.h>

int main(void){

	int n,i;
	int debt=100000;
	float percent = 0.05;
	int risi;
	double stac;

	scanf("%d",&n);

	for(i=0;i<n;i++){
		risi = debt*percent;
		if(risi%1000 == 0){
			debt = debt + risi;		
		}
		else{
			stac = risi%1000;
			risi = risi-stac+1000;
			debt = debt+risi;
		}
	}

	printf("%d\n",debt);


	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int count = 1;
        Scanner sc = new Scanner(System.in);
        while (true) {
            //数字を受け取る
            int x = sc.nextInt();
            //もし受け取った数字が0なら処理を終了する
            if (x == 0) {
                break;
            }

            System.out.println("Case " + count + ": " + x);
            count++;

        }
    }
}



Measured memory_bytes: 43344
def read_values():
    return map(int, input().split())


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


def f():
    N = int(input())

    for a in range(9, 0, -1):
        if N % a != 0:
            continue
        b = N // a
        if 1 <= b <= 9:
            print("Yes")
            return

    print("No")


if __name__ == '__main__':
    f()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	string s; cin >> s;

	string t = "";
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != '/') {
			t += s[i];	
		}
	}

	int n = stoi(t);

	if (n > 20190430) {
		cout << "TBD" << endl;	
	}else {
		cout << "Heisei" << endl;	
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int N=2e5+5;
int a[N];

int b[N];
char s[N];
char t[N];
ll f[N];
int used[15];
int cmp1(int a,int b)
{
    return b<a;
}

multiset<int> ss;
map<int,int>mp;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n);
    ll ans=a[n];
    int now=n-1;
    int num=0;
    for(int i=1;i<=n-2;i++){
        ans+=a[now];
        num++;
        if(num==2) {
            now--;
            num=0;

        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4412
n = int(input())
d = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
 
s = sum(b)
 
for i in range(n-1):
  if d[i+1]-d[i] == 1:
    s += c[d[i]-1]
    
print(s)

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

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int ans=0;
    for(int i=2;i<n;i++){
        if(s[i-2]=='A' && s[i-1]=='B' && s[i]=='C') ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
main = do
  getLine
  a <- getLine >>= return . (map read) . words :: IO [Int]

  let (o,e) = splitOddEven a

  putStrLn $ (unwords . (map show)) $ (\xs -> if even (length xs) then reverse xs else xs) ((reverse o) ++ e)

  where
    splitOddEven xs = splitOddEven' xs 1
      where
        splitOddEven' [] _ = ([], [])
        splitOddEven' (x:xs) n
          | odd n = (x:o, e)
          | otherwise = (o, x:e)
          where
            (o, e) = splitOddEven' xs (n+1)
            


Measured memory_bytes: 150780
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int a = 0, b = 0, rest = 0;

    scanf("%d %d", &a, &b);
    rest = 16 - (a+b);
    if ((a+b) > 16) {
        printf(":(\n");
    } else {
        if (a > 8 || b > 8) {
            printf(":(\n");
        } else {
            printf("Yay!\n");
        }
    }
    return 0;
}


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

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

  int64_t d = __gcd(n, m);
  int64_t ans = n * m / d;
  map<int64_t, char> map;
  for (auto i = 0; i < n; i++) {
    map.insert(make_pair(i * m / d, s[i]));
  }
  for (auto i = 0; i < m; i++) {
    if (map.find(i * n / d) != map.end()) {
      if (map.find(i * n / d)->second != t[i]) {
	ans = -1;
	break;
      }
    }
  }
  cout << ans << endl;
}


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

int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  
  if(e-a>k){
    cout<<":("<<endl; 
  }
  else{
    cout<<"Yay!"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int count=0,minj,n,temp,A[100];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    for(int i=0;i<n;i++){
        minj=i;
        for(int j=i;j<n;j++){
            if(A[j]<A[minj]){
                minj=j;
            }
        }
    if(i!=minj){
        temp=A[minj];
        A[minj]=A[i];
        A[i]=temp;
        count+=1;
    }
    }
    for(int i=0;i<n;i++){
        if(i==0)cout<<A[i];
        else cout<<" "<<A[i];
    }
    cout<<endl<<count<<endl;
}


Measured memory_bytes: 3084
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int z = sc.nextInt();
			if(z==0) break;
			
			int x = 1;
			int y = z;
			long max = 0;
			while(x<=y){
				if(x*x*x+y*y*y<=z*z*z){
					max = Math.max(max, x*x*x+y*y*y);
					x++;
				}else{
					y--;
				}
			}
			System.out.println(z*z*z-max);
		}	
	}	
}

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

int main(){
 int x;
 int num[10000];

 int count = 0;
 while(1){
   cin >> x;
   if( x==0 ){
    break;
   }
   num[count] = x;
   count++;
 }

 for( int i=0; i<count; i++ ){
  cout << "Case " << i+1 << ": " << num[i] << endl;
 }

 return 0;
}


Measured memory_bytes: 3128
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")

#include <stdio.h>
#include <stdlib.h>

#define NMAX 200001

int a[NMAX];
int imos[NMAX];

void reset(int n) {
    for(int i = 0; i < n; i++) imos[i] = 0;
}

int max(int a, int b) {
    if(a > b) return a;
    else return b;
}

int min(int a, int b) {
    if(a > b) return b;
    else return a;
}

int get_int() {
    int res = 0;
    char c = getchar();
    while(c != EOF && c != ' ' && c != '\n') {
        res *= 10;
        res += c - '0';
        c = getchar();
    }
    return res;
}

void put_int(int n) {
    char c[30];
    int sz = 0;
    c[sz++] = (n % 10) + '0';
    n /= 10;
    while(n > 0) {
        c[sz++] = (n % 10) + '0';
        n /= 10;
    }
    for(int i = sz-1; i >= 0; i--) {
        putchar(c[i]);
    }
    putchar('\n');
}

int main(){

    int n, k;
    n = get_int();
    k = get_int();
    for(int i = 0; i < n; i++) a[i] = get_int();

    for(int itr = 0; itr < k; itr++) {
        reset(n+1);
        for(int i = 0; i < n; i++){
            imos[max(0, i - a[i])]++;
            imos[min(n, i + a[i] + 1)]--;
        }
        int acc = 0;
        for(int i = 0; i < n; i++){
            acc += imos[i];
            a[i] = acc;
        }
        int sum = 0;
        for(int i = 0; i < n; i++) sum += a[i];
        if(sum == n * n) break;
    }

    for(int i = 0; i < n; i++) put_int(a[i]);
    return 0;
}


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

#define SIZE 500000

int heap[SIZE];
int n;

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

void maxHeapify(int i){
  int l = left(i),r = right(i);
  int largest,tmp;

  if(l <= n && heap[l] > heap[i]){
    largest = l;
  }else{
    largest = i;
  }

  if(r <= n && heap[r] > heap[largest]){
    largest = r;
  }

  if(largest != i){
    tmp = heap[i];
    heap[i] = heap[largest];
    heap[largest] = tmp;
    maxHeapify(largest);
  }
}

void buildMaxHeap(){
  int i;
  for(i = n/2; i > 0; i--){
    maxHeapify(i);
  }
}

int main(){
  int i;

  scanf("%d",&n);

  for(i = 1; i <= n; i++){
    scanf("%d",&heap[i]);
  }

  buildMaxHeap();

  for(i = 1; i <= n; i++){
    printf(" %d",heap[i]);
  }

  printf("\n");

  return 0;
}

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

int main() {
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	while (1) {
		if (s.find("esare") == 0 || s.find("maerd") == 0) {
			s.erase(0, 5);
		}
		else if (s.find("resare") == 0) {
			s.erase(0, 6);
		}
		else if (s.find("remaerd") == 0) {
			s.erase(0, 7);
		}
		else {
			cout << "NO" << endl;
			return 0;
		}
		if (s == "") {
			cout << "YES" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 512
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+5;
const int mod=1e9+7;
ll n,m;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
	cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
	int i;
	int n;
	int m[100]={};
	int max=0;
	while(scanf("%d",&n)!=EOF)
	m[n-1]++;

	for(i=0;i<100;i++){
		if(max < m[i])	max=m[i];
	}
	for(i=0;i<100;i++){
		if(m[i] == max)	printf("%d\n",i+1);
	}
	return 0;
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;

  int ew = 0,we;
  int cmin;
  for(int i = 1;i < n;i++){
    if(s[i] == 'E'){
      ew++;
    }
  }

  we = 0;
  cmin = ew;

  for(int i = 1;i < n;i++){
    if(s[i] == 'E'){
      ew--;
    }
    if(s[i-1] == 'W'){
      we++;
    }
    cmin = min(cmin,we+ew);
  }

  cout << cmin << endl;
  return 0;
}


Measured memory_bytes: 900
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <queue>
#include <unordered_map>
using namespace std;
typedef long long ll;
int main(){
    int k;cin >> k;
    ll sum=0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int t=1;t<=k;t++){
                sum += __gcd(i, __gcd(j, t));
            }
            
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            string s = ReadLine();

            int[] Wmap = Enumerable.Repeat(0,n+1).ToArray();
            int Wtmp = 0;
            //累積和を取る
            //累積和の数列を作るときは index0 = 0
            Wmap[0] = 0;
            for (int i = 1; i <= n; i++)
            {
                if (s[i - 1] == 'W') Wtmp++;
                Wmap[i] = Wtmp;
            }

            //計算する
            // iがリーダーの位置となる
            // 計算式
            // ans = min(ans, リーダーより左にいる W の数 + リーダーより右にいるEの数)
            int ans = n;
            for (int i = 1; i <= n; i++)
            {
                ans = Min(ans,
                    Wmap[i-1] + (n-i) - (Wmap[n] - Wmap[i])
                    );
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 17504
n,q = gets.split.map(&:to_i)
s = gets.chomp.split("")
lr = q.times.map{gets.split.map(&:to_i)}

lcnt = Array.new(n+1,0)
for i in 1..(n-1)
  s[i-1..i].join == "AC" ? ps = 1 : ps = 0
  lcnt[i+1] = lcnt[i] + ps
end

lr.each do |rn|
  rn[0] > 1 && s[rn[0]-2..rn[0]-1].join == "AC" ? ms = 1 : ms = 0
  puts lcnt[rn[1]]-lcnt[rn[0]-1]-ms
end

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


int main()
{
int h,w;
while(1){
	scanf("%d %d",&h,&w);
	if((h|w)==0)break;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
}
return 0;
}


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

struct rest{
	string s;
	int num;
};

bool cmp(rest a,rest b)
{
	if(a.s!=b.s)
	    return a.s<b.s;
	else
	    return a.num>b.num;
}
int main()
{
	int n;
	cin>>n;
	
	rest resta[n+1];
	rest restb[n+1];
	

	for(int i=1;i<=n;i++)
	{
		cin>>resta[i].s>>resta[i].num;
	}
	
	for(int i=1;i<=n;i++)
	{
	    restb[i].s=resta[i].s;
		restb[i].num=resta[i].num;	
	}
	sort(resta+1,resta+n+1,cmp);
	
	int ans[n+1];
	
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(resta[i].s==restb[j].s && resta[i].num==restb[j].num)
			{
				ans[i]=j;
				continue;
			}
			
			
		}
	}
	
	for(int i=1;i<=n;i++)
	{
		cout<<ans[i]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} combination(1000000);

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    vector<mint> dp(n);
    dp[0] = 1;
    rep(i, n) if (i != 0) dp[i] = dp[i - 1] + (mint(1) / (i + 1));

    mint ans = 0;
    rep(i, n - 1) {
        ll cost = v[i + 1] - v[i];
        mint c = dp[i];

        mint now = c * cost;
        ans += now;
    }
    ans *= combination.fact[n - 1];
    cout << ans << endl;
}


Measured memory_bytes: 20268
from sys import stdin
def main():
	readline=stdin.readline
	S=readline().strip()
	T=readline().strip()
	for i in range(len(S)):
		U=S[i:]+S[:i]
		if U==T:
			print("Yes")
			break
	else:
		print("No")
if __name__=="__main__":
	main()

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
using ll = long long;

const ll MOD = 998244353;
const ll MAX_V = 10000;
ll fact[MAX_V + 1], invfact[MAX_V + 1];

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b % MOD;
    if (n % 2 == 0) {
        return mypow(b * b % MOD, n / 2);
    } else {
        return mypow(b, n - 1) * b % MOD;
    }
}

void precalc() {
    invfact[0] = fact[0] = 1;
    for (ll i = 1; i <= MAX_V; ++i) {
        fact[i] = fact[i - 1] * i % MOD;
    }

    invfact[MAX_V] = mypow(fact[MAX_V], MOD - 2);
    for (ll i = MAX_V - 1; i >= 0; --i) {
        invfact[i] = invfact[i + 1] * (i + 1) % MOD;
    }
    return;
}

ll comb(ll a, ll b) {
    if (a < b) return 0;
    if (a == 0) return 1;  // a = b = 0

    return fact[a] * invfact[a - b] % MOD * invfact[b] % MOD;
}

ll calc(ll N, ll s, ll d) {
    ll ret = 0;
    for (ll q = 0; q <= min(d, N); ++q) {
        ret += (mypow(2LL, q) * comb(d, q) % MOD) * comb(s + N - 1, N - q) % MOD;
        ret %= MOD;
    }
    return ret;
}

int main() {
    precalc();

    ll K, N;
    cin >> K >> N;

    for (ll i = 2; i <= K * 2; ++i) {
        ll d = (i <= K + 1 ? (i - 1) / 2 : (2 * K - i + 1) / 2);
        if (i % 2 > 0) {
            cout << calc(N, K - d * 2, d) << endl;
        } else {
            cout << (calc(N, K - d * 2 - 1, d) + calc(N - 1, K - d * 2 - 1, d)) % MOD << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

string s;
int main(){
  cin >> s;
  int N = s.size();
  N--;
  i64 ans = 0;
  for(int i = 0; i < 1 << N; i++){
    stringstream ss;
    i64 sum = 0;
    ss << s[0];
    for(int j = 0;j < N;j++){
      if(i & (1 << j)){
        i64 temp;
        ss >> temp;
        ss.clear();
        sum += temp;
      }
      ss << s[j + 1];
    }
    i64 temp;
    ss >> temp;
    ss.clear();
    sum += temp;
    ans += sum;
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    long long N;
    cin >> N;
    if(N==1){
        puts("1");
        return 0;
    }
    for(int i=sqrt(N);i<N;i++){
        if((i+1)*(i+1)>N){
            cout << i*i << endl;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;

#define int long long

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}

#define FOR(a,b,c) for(int a=b, __c=c; a<=__c; ++a)
#define FORD(a,b,c) for(int a=b, __c=c; a>=__c; --a)
#define forv(a,b) for(auto &a:b)

#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define reset(f,x) memset(f,x,sizeof(f))
#define fasty ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)

#define bit(x,i) (x>>(i-1)&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))

const int N=1e5+5;
int n,a[N],mod;
vector<int> ad[N];
int f[N],g[N];

void dfs(int u,int par){
   forv(v,ad[u]) if(v!=par){
      dfs(v,u);
      f[u]*=(f[v]+1);
      f[u]%=mod;
   }
}
void dfs1(int u,int par){
   vector<int> a,l,r;
   int cnt=0, m=0;
   forv(v,ad[u]) if(v!=par) cnt++;
   a.resize(cnt+5,0);
   l.resize(cnt+5,0);
   r.resize(cnt+5,0);
   forv(v,ad[u]) if(v!=par) a[++m]=v;
   l[0]=r[m+1]=1;
   FOR(i,1,m) l[i]=l[i-1]*(f[a[i]]+1)%mod;
   FORD(i,m,1) r[i]=r[i+1]*(f[a[i]]+1)%mod;
   FOR(i,1,m){
      int v=a[i];
      g[v]=(g[u]*(l[i-1])%mod*r[i+1]%mod+1)%mod;
      dfs1(v,u);
   }
}

int32_t main(){
   fasty;

   cin>>n>>mod;
   FOR(i,1,n-1){
      int u,v;
      cin>>u>>v;
      ad[u].pb(v); ad[v].pb(u);
   }

   FOR(i,1,n) f[i]=g[i]=1;
   dfs(1,1);
   dfs1(1,1);

   FOR(i,1,n) cout<<f[i]*g[i]%mod<<'\n';
}


Measured memory_bytes: 35700
#include<cstdio>
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        double x1,y1,x2,y2,x3,y3,x4,y4;
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        if((y2-y1)/(x2-x1)==(y4-y3)/(x4-x3)) printf("YES\n");
        else printf("NO\n");
    }
}

Measured memory_bytes: 0
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N = ni()
    val A = na(N)

    val win = A.exists(_ % 2 != 0)
    if (win) out.println("first")
    else out.println("second")
  }


  def debug(as: Array[Boolean]): Unit = {
    System.err.println(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(s: String): Unit = {
    System.err.println(s)
  }

  def debug(num: Long): Unit = {
    System.err.println(num)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

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


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 1e9;
    for(int i=-100; i<=100; i++){
        int now = 0;
        for(int j=0; j<n; j++){
            now += (a[j]-i)*(a[j]-i);
        }
        ans = min(now,ans);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N; cin >> N;
    vector<double> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v.at(i);
    }
    
    sort(v.begin(), v.end());
    
    double S = v.at(0);
    for (int i = 1; i < N; i++) {
            S += v.at(i);
            S /= 2;
    }
    
    cout << S << endl;
}

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

vector<vector<int>> graph(200);

vector<int> done(200, -1);
bool is_bigraph(int v, bool b) {
    if (done.at(v) != -1) {
        if (done.at(v) == b) return true;
        else return false;
    }

    done.at(v) = b;
    for (int i = 0; i < (int)graph.at(v).size(); i++) {
        if (!is_bigraph(graph.at(v).at(i), b ^ 1)) return false;
    }
    return true;
}

const int max_v = 200;
int d[max_v][max_v];
int V;
const int INF = 300;

void warshall_floyd() {
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
    int n;
    cin >> n;
    V = n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            char c;
            cin >> c;
            if (c == '1') {
                graph.at(i).push_back(j);
                graph.at(j).push_back(i);

                d[i][j] = 1;
                d[j][i] = 1;
            }
            else {
                d[i][j] = INF;
                d[j][i] = INF;
            }
        }
    }
    
    if (!is_bigraph(0, 0)) {
        cout << -1 << endl;
        return 0;
    }
    
    warshall_floyd();
    int maximum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            maximum = max(maximum, d[i][j]);
        }
    }
    cout << maximum + 1 << endl;
}

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

using namespace std;

 
int main() {
    int a, b;

    cin >> a >> b;

    if(a < 10 && b < 10){
        int sum = 0;
        sum = a * b;
        cout << sum;
    }
    else
    {
        cout << -1;
    }
    

    }

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

int main() {
    cout << fixed << setprecision(10);
    
    int N; cin >> N;
    vector<vector<int>> c(9, vector<int>(9));
    repr(i, 1, N+1) {
        int k1 = i%10;
        if (k1 == 0) continue;
        int km = i/pow(10, floor(log10(i)));
        // cout << "i " << i << " 1 " << k1 << " m " << km << endl;
        c[km-1][k1-1] += 1;
    }
    int ans = 0;
    rep(i, 9) {
        rep(j, 9) {
            ans += c[i][j] * c[j][i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>

using namespace std;

int digit_length(int num){
    int count = 0;
    while(num){
        num = num / 10;
        ++count;
    }
    return count;
}

int main(){
    int n;
    cin >> n;
    bool flag = false;
    for(int i = 0;i < digit_length(n);i++){
        if((n / int(pow(10, i)) % 10) == 7){
            flag = true;
        }
    }
    if(flag == true){cout << "Yes" << endl;}else{cout << "No"<< endl;}
    return 0;
}


Measured memory_bytes: 3776
#include<bits/stdc++.h>
#define LL long long
#define inf 0x3fffffff
using namespace std;

int m,d;

int main()
{
    cin>>m>>d;
    int ans=0;
    for (int i=1;i<=m;i++)
        for (int j=10;j<=d;j++)
            if ((j%10)*(j/10)==i&&j%10>=2&&j/10>=2) ans++;
    cout<<ans<<endl;
    return 0;
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int r,g,b; cin >> r >> g >>b;
    int su = r*100+g*10 + b;
    if(su%4==0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int main() {
	int A, B;
	cin >> A >> B;
	int x = 0;
	for(int i = A;i <= B;i++){
		if(i / 10000 == i % 10 && i / 1000 % 10 == i / 10 % 10){
			x++;
		}
	}
	cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(void){
    int a,b;
    std::cin >> a >> b;
    if(a>b){
        std::cout << "a > b" << std::endl;
    }else if(a==b){
        std::cout << "a == b" << std::endl;
    }else{
        std::cout << "a < b" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3080
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		String ss = s.substring(s.length() - 1, s.length());
		List<String> l1 = Arrays.asList("2", "4", "5", "7", "9");
		List<String> l2 = Arrays.asList("0", "1", "6", "8");

		if (l1.contains(ss)) {
			System.out.println("hon");
		} else if (l2.contains(ss)) {
			System.out.println("pon");
		} else {
			System.out.println("bon");
		}

		sc.close();
	}
}

Measured memory_bytes: 26920
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。

for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}

*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

int dy[] = { 0, 1, 0, -1 };
int dx[] = { 1, 0, -1, 0 };


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/


/*実行開始からの経過時間を表すよ。

while (clock() < 1900000) {  }

*/


/*まだ使えないテクニックのメモだよ。

for (int bit = 0; bit < (1<<n); ++bit)//bit全探索用のfor文だよ

*/


/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/


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

	int x[55], y[55];

	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}

	map<pair<int, int>,int> mp;

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i == j) { continue; }
			mp[make_pair(x[i] - x[j], y[i] - y[j])] += 1;
		}
	}

	int mx = 0;

	for (pair<pair<int, int>,int> x : mp) {
		mx = max(mx, x.second);
	}

	cout << n - mx << endl;



	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){

	int N,i;
  	scanf("%d",&N);
  	int A[N],B[N-1];
  	int count = 0;
  	for(i=0;i<N;i++){
      	scanf("%d",&B[i]);
    }
	A[0] = B[0];
  	for(i=0;i<N-2;i++){
    	if(B[i] >= B[i+1]){
        	A[i+1] = B[i+1];
        }else{
        	A[i+1] = B[i];
        }
    }
  	A[N-1] = B[N-2];
    for(i=0;i<N;i++){
    	count += A[i];
      	//printf("%d",A[i]);
    }
  	printf("%d\n",count);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
int A,B,Cnt = 0;
scanf("%d %d",&A,&B);

//1回目
if(A > B){
Cnt += A;
A --;
}
else{
Cnt += B;
B --;
}

//二回目
if(A > B){
Cnt += A;
A --;
}
else{
Cnt += B;
B --;
}

printf("%d",Cnt);

return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdio>
#include<utility>
#include<algorithm>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
#define all(L) L.begin(),L.end()
using ll=long long;
#define RO 1
#define SI 2
#define PA 3

int N,M;
int P[100000],Y[100000];
vector<int> idy[100001];

void dfs(int m,int bits,int &count){
    if(m>N) return;
    if(bits==0b111) count++;
    dfs(10*m+7,bits|0b100,count);
    dfs(10*m+5,bits|0b010,count);
    dfs(10*m+3,bits|0b001,count);
}

int main(){
    cin>>N>>M;
    rep(i,0,M){
        cin>>P[i]>>Y[i];
        idy[P[i]].push_back(Y[i]);
    }
    rep(i,1,N+1){
        sort(idy[i].begin(),idy[i].end());
    }

    rep(i,0,M){
        printf("%06d",P[i]);
        int x;
        x=(int)(lower_bound(idy[P[i]].begin(),idy[P[i]].end(),Y[i])-idy[P[i]].begin())+1;
        printf("%06d\n",x);
    }
}    




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

int main() {
    int N;
    string S;
    cin >> N >> S;
    vector<int> vec(N);
    int Nsum=0;
    for(int i = 0;i<N;i++){
        if(S.at(i)=='.'){
            vec.at(i)=1;
            Nsum++;
            }else
            {
                vec.at(i)=0;
            }
    }
    int sum=0;
    int flag=min(Nsum,N-Nsum);
    for(int i=0;i<N;i++){
        sum+=vec.at(i);
        if((i+Nsum+1-2*sum)<flag){
            flag = 1+i+Nsum-2*sum;
        }
    }
    cout << flag << endl;
    return 0;
}

Measured memory_bytes: 1412