akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

int N, A, B, C, D;
string S;




int main() {
	cin >> N >> A >> B >> C >> D;
	cin >> S;

	char current;

	if (C < D) {
		//B part
		for (int i = B - 1; i < D; i++) {
			if (i == B - 1)current = S[i];
			else {
				if (current == '#' && S[i + 1] == '#') {
					print("No");
					return 0;
				}
				else current = S[i + 1];
			}
		}
		//A part
		for (int i = A - 1; i < C; i++) {
			if (i == A - 1)current = S[i];
			else {
				if (current == '#' && S[i + 1] == '#') {
					print("No");
					return 0;
				}
				else current = S[i + 1];
			}
		}
		print("Yes");

	}
	else {
		//B part
		bool bcheck = false;
		for (int i = B - 1; i < D; i++) {
			if (i == B - 1) {
				current = S[i];
				if (S[i + 1] == '.' && S[i - 1] == '.' && S[i]=='.') {
					S[i] = '#';
					bcheck = true;
				}
			}
			else {
				if (current == '#' && S[i + 1] == '#') {
					print("No");
					return 0;
				}
				else current = S[i + 1];
				if (bcheck == false && S[i - 1] == '.' && S[i + 1] == '.'&& S[i]=='.') {
					S[i] = '#';
					bcheck = true;
				}
			}
		}

		if (bcheck == false) {
			print("No");
			return 0;
		}

		//A part
		for (int i = A - 1; i < C; i++) {
			if (i == A - 1)current = S[i];
			else {
				if (current == '#' && S[i + 1] == '#') {
					print("No");
					return 0;
				}
				else current = S[i + 1];
			}
		}
		print("Yes");

	}




	return 0;
}

Measured memory_bytes: 640
n="0"+input()
x=len(n)
k=int(input())
l=[int(i) for i in n]

## dp1:top   dp2:under
dp1=[[0]*(k+2) for i in range(x)]
dp2=[[0]*(k+2) for i in range(x)]

dp1[0][0]=1
dp1[0][1]=0
dp2[0][0]=0
dp2[0][1]=0

cnt=0
for i in range(1,x):
    if l[i]>0:
        cnt+=1
    if cnt<=k:
        dp1[i][cnt]=1
for i in range(1,x):
    for j in range(k+1):
        if j==0:
            dp2[i][0]=1
        else:
            if l[i]==0: dp2[i][j]=(dp2[i-1][j-1]*9)+(dp2[i-1][j])+(dp1[i-1][j-1]*max(0,l[i]-1))
            else: dp2[i][j]=(dp2[i-1][j-1]*9)+(dp2[i-1][j])+(dp1[i-1][j-1]*max(0,l[i]-1))+(dp1[i-1][j])
print(dp1[-1][-2]+dp2[-1][-2])


Measured memory_bytes: 38384
class UF:
    def __init__(self, N):
        self.uf = [-1]*N
        self.n = N

    def find(self, x):
        if self.uf[x]<0: return x
        self.uf[x] = self.find(self.uf[x])
        return self.uf[x]

    def size(self, x):
        return -self.uf[self.find(x)]

    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x==y: return
        if self.size(x) > self.size(y): x, y = y, x
        self.uf[y] += self.uf[x]
        self.uf[x] = y
        self.n -= 1
        
N, M = map(int, input().split())
A = list(map(int, input().split()))
uf = UF(N)
for _ in range(M):
    x, y = map(int, input().split())
    uf.union(x,y)

D = {}
for x, a in enumerate(A):
    c = uf.find(x)
    if c not in D: D[c]=[]
    D[c].append(a)

ans = 0
L = []
for d in D.values():
    d.sort()
    ans += d[0]
    L += d[1:]

L.sort()

P = len(D)-2
if len(D)==1:
    ans = 0
elif len(L)>=P:
    ans += sum(L[:len(D)-2])
else:
    ans = 'Impossible'

print(ans)


Measured memory_bytes: 33612
///In the name of GOD
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 4e5 + 10;
ll n;
string ANS;
char CH(ll x){
    return (char)('a' + x);
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> n;
    while(n){
        n--;
        ll m = (n % 26);
        ANS += CH(m);
        n = n / 26;
    }
    reverse(ANS.begin(), ANS.end());
    cout << ANS << '\n';
    return 0;
}
/*!
    I CHOOSE TO HAVE FAITH,
    BECAUSE WITHOUT THAT,
    I HAVE NOTHING....
    ITS THE ONLY THING THAT'S KEEPING ME GOING.
*/
//! N.N


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

ll n , m;

int main(){
    migmig
    cin >> n >> m;
    if(n > 2 and m > 2){
		dokme((n-2)*(m-2));
	}
    if(n > m)
		swap(n , m);
	if(n==1 and m==1)dokme(1);
	if(n == 1)
		dokme(max(0LL,m-2));
    
    cout << 0;
    
    
    return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int K;
  cin >> K;
  rep(i,K) {
    cout << "ACL";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3600
import collections

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

mod = 10**9+7

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if is_prime[i]:
            for j in range(i*2, n+1, i):
                is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

primes = sieve(10**3)

def primeFactorization(n):
    ans = []
    temp = n
    for p in primes:
        while temp%p == 0:
            ans.append(p)
            temp //= p
    if temp > 1:
        ans.append(temp)
    return collections.Counter(ans)

AFactorized = list(map(primeFactorization, A))

lcm = collections.Counter()
for a in AFactorized:
    for p, n in a.items():
        lcm[p] = max(lcm[p], n)

lcm_val = 1
for p, n in lcm.items():
    lcm_val *= pow(p, n, mod)

ans = 0
for a in A:
    ans += lcm_val * pow(a, mod-2, mod)
    ans %= mod

print(ans)

Measured memory_bytes: 7860
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		for (int i = N; i < 1000; i++) {
			String s = String.valueOf(i);
			if (s.charAt(0) == s.charAt(1) && s.charAt(0) == s.charAt(2)) {
				System.out.println(s);
				return;
			}
		}
	}
}


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

int main(){
	int n,m,k;
	cin>>n>>m;
	int sum = 0;
	for (int i = 0; i<m; i++){
		cin>>k;
		sum+=k;
	}
	if (sum > n){
		cout<<-1;
	}
	else{
		cout<<n - sum;
	}
}

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

int main() {
    stack<ll> S;
    string c;

    while(cin >> c) {
        ll x,y;
        
        if(c[0] == '+' || c[0] == '-' || c[0] == '*') {
            x = S.top(); S.pop();
            y = S.top(); S.pop();  
        }
        
        if(c[0] == '+')  S.push(x + y);
        else if(c[0] == '-') S.push(y - x);
        else if(c[0] == '*') S.push(x * y);
        else S.push(stoll(c));
    }

    cout << S.top() << endl;

    return 0;
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

int main(){
  ll N;
  cin >> N;
  vector<ll> ans;
  ll m=0,p=0;
  rep(i,N){
    ll a;
    cin >> a;
    if(a<0) {
      m--;
      ans.pb(-a);
    }else {
      p++;
      ans.pb(a);
    }
  }
  ll sum = 0;
  if(m%2==0){
    rep(i,N){
      sum += ans[i];
    }
  }else{
    sort(All(ans));
    sum -= ans[0];
    for(ll i=1;i<N;i++){
      sum += ans[i];
    }
  }
  cout<< sum << endl;
}


Measured memory_bytes: 1400
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int k = scanner.nextInt();
		List<Integer> hates = new ArrayList<>();
		boolean judge =true;

		for(int i=0; i<k;i++) {
			hates.add(scanner.nextInt());
		}

		while (judge) {
			List<Integer> list = new ArrayList<>();
			for (int i = n; i != 0; i /= 10) {
				int target = i % 10;
				list.add(target);
			}
			for(int hate:hates) {
				if(!(list.contains(hate))) {
					judge=false;
				}else {
					judge = true;
					break;
				}
			}
			n++;
		}

		System.out.println(n-1);
	}
}

Measured memory_bytes: 31300
n=gets.chomp.to_i
s_arr = []
n.times do |i|
  s_arr << gets.chomp
end

m=gets.chomp.to_i
t_arr = []
m.times do |i|
  t_arr << gets.chomp
end

hash = {}
s_arr.each do |s|
  hash[s] ||= 0
  hash[s] += 1
end

t_arr.each do |t|
  hash[t] ||= 0
  hash[t] -= 1
end

max = hash.values.max
if max < 0 then
  puts 0
else
  puts max
end





Measured memory_bytes: 1788
class Dice:
    def __init__(self, num):
        self.number = num
        self.order  = 'NNNNWNNNWNNNENNNENNNWNNN' # 6x4=24 patterns in total
        
    def roll(self, action):
        num_tmp = self.number.copy()
        if action=='N':
            self.number = [num_tmp[1], num_tmp[5], num_tmp[2], num_tmp[3], num_tmp[0], num_tmp[4]]
        elif action=='S':
            self.number = [num_tmp[4], num_tmp[0], num_tmp[2], num_tmp[3], num_tmp[5], num_tmp[1]]
        elif action=='W':
            self.number = [num_tmp[2], num_tmp[1], num_tmp[5], num_tmp[0], num_tmp[4], num_tmp[3]]
        elif action=='E':
            self.number = [num_tmp[3], num_tmp[1], num_tmp[0], num_tmp[5], num_tmp[4], num_tmp[2]]
        
    def check_is_same(self, dice2):
        is_same = False
        for a in self.order:
            dice2.roll(a)
            tmp_is_same = True
            for i in range(6):
                if self.number[i]!=dice2.number[i]:
                    tmp_is_same = False
                    break
            if tmp_is_same:
                is_same = True
                break
        return is_same
        
n = int(input())
N = [list(map(int, input().split())) for i in range(n)]

ans = 'Yes'
for i in range(n-1):
    for j in range(i+1,n):
        dice_i = Dice(N[i])
        dice_j = Dice(N[j])
        if dice_i.check_is_same(dice_j):
            ans = 'No'
            break
    else:
        continue
    break
print(ans)


Measured memory_bytes: 5612
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    NIL = -1

    m = int(input())

    root = NIL

    def insert(k):
        global root
        y = NIL
        x = root
        z = {'key':k, 'left':NIL, 'right':NIL}
        while x != NIL:
            y = x
            if z['key'] < x['key']:
                x = x['left']
            else:
                x = x['right']
        z['parent'] = y

        if y == NIL:
            root = z
        elif z['key'] < y['key']:
            y['left'] = z
        else:
            y['right'] = z

    def find(u, k):
        while u != NIL and k != u['key']:
            if k < u['key']:
                u = u['left']
            else:
                u = u['right']
        return u

    def inorder(u):
        if u == NIL:
            return
        inorder(u['left'])
        print(' ' + str(u['key']), end='')
        inorder(u['right'])

    def preorder(u):
        if u == NIL:
            return
        print(' ' + str(u['key']), end='')
        preorder(u['left'])
        preorder(u['right'])

    for _ in range(m):
        command = input()
        if command[0] == 'f':
            _, x = command.split()
            x = int(x)
            t = find(root, x)
            if t != NIL:
                print('yes')
            else:
                print('no')
        elif command[:6] == 'insert':
            _, x = command.split()
            x = int(x)
            insert(x)
        else:
            inorder(root)
            print('')
            # pythonのprintは最後に改行記号をつけてくれるので、これで改行できる
            preorder(root)
            print('')



Measured memory_bytes: 114188
// Problem : A - HEX
// Contest : AtCoder - AtCoder Beginner Contest 078
// URL : https://atcoder.jp/contests/abc078/tasks/abc078_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
char c1,c2;cin>>c1>>c2;
if(c1>c2)
cout<<">";
else if(c1<c2)
cout<<"<";
else
cout<<"=";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000

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

int main()
{
	string	str;cin >> str;
	ll ans = 0;
	
	REP(i,str.size())ans += str[i] - '0';
	
	REP(i,str.size())
	{
		ll ret = 0;
		REP(j,str.size())
		{
			ll tmp = 0;
			if(j < i)
			{
				tmp += str[j] - '0';
			}
			else if(j == i)
			{
				if(str[j] == '0')
				{
					for(int k = j-1;k >= 0;k--)
					{
						if(str[k] == '0')tmp+=9;
						else break;
					}
					tmp--;
				}
				else
				{
					tmp += ((str[j] - '0') - 1);
				}
			}
			else
			{
				tmp += 9;
			}
			//cout << tmp;
			ret += tmp;
		}
		//cout << endl;
		ans = max(ans,ret);
	}
	
	cout << ans << endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int r,c,sum,total_sum = 0;
    scanf("%d %d",&r,&c);
    int table[r+1][c+1];
 
    for(int i = 0; i < r+1; i++){
        for(int j = 0; j < c+1; j++){
            table[i][j] = 0;
        }
    }
 
    for(int i = 0; i < r; i++){
        sum = 0;
        for(int j = 0; j < c; j++){
            scanf("%d",&table[i][j]);
            sum += table[i][j];
            table[r][j] += table[i][j];
        }
        table[i][c] = sum;
        total_sum += sum;
    }
    table[r][c] = total_sum;
 
    for(int i = 0; i < r+1; i++){
        for(int j = 0; j < c; j++){
            printf("%d ",table[i][j]);
        }
        printf("%d\n",table[i][c]);
    }
}


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

int main(){
	vector<int> v(10, 0);
	
	for(int i=0; i < 10; i++) cin >> v[i];
	sort(v.begin(), v.end());
	for(int i=0; i < 3; i++)cout << v[9-i] << endl;
}

Measured memory_bytes: 1212
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);       
		int r = sc.nextInt();
		int d = sc.nextInt();
        int ans = sc.nextInt();
	  for(int i=0;i<10;i++){ans=ans*r-d;System.out.println(ans);}
  }
}

Measured memory_bytes: 21716
n=gets.to_i

a=[]
n.times do
  a<<gets.to_i
end

sum = a.inject(&:+)

if sum % 10 == 0
  s = a.reject{|x| x%10 == 0}
  if s.empty?
    puts 0
  else
    puts (sum - s.min)
  end
else
  puts sum
end

Measured memory_bytes: 1788
N=60
def f(t):
    c,t=t%N,t/N
    print "%02d:%02d:%02d"%(t/N,t%N,c)
    return

while 1:
    h,m,s=map(int,raw_input().split())
    if [h,m,s]==[-1,-1,-1]: break
    t=7200-(h*N+m)*N-s
    f(t)
    f(t*3)

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  ll n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) {
    int buf;
    cin >> buf;
    a[i] = buf -1;
  }
  int now = 0;
  int start,end;
  vector<int> root(n+1);
  vector<bool> visited(n,false);
  rep(i,n){
    if(visited[now] == true){
      rep(j,n){
        if(root[j] == now){
          start = j;
          break;
        }
      }
      break;
    }
    visited[now] = true;
    root[i] = now;
    now = a[now];
    end = i;
  }
  //rep(i,end+1) cout<<root[i]<<endl;
  //cout<< endl << start << endl;
  //cout<< end << endl;
  ll epoch = (end - start) + 1;
  ll pos = k - start;
  ll pos1;
  //cout << epoch << endl;
  if (pos < 0) pos1 =  k;
  else         pos1 = pos % epoch;
  //cout <<"pos1 "<< pos1 << endl;
  int out;
  if (pos<0) out = root[pos1];
  else       out = root[start+pos1];
  cout << out+1 << endl;
}



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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn result<'a>(x: u64, y: u64) -> u64{
    if y > 1 { x + result(x, y-1)*10 } else {x}
}

fn main(){
    input!{
        a: u64,
        b: u64,
    }
    println!("{}", if a > b {result(b, a)} else {result(a, b)})
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

void f()
{
  int n,a;
  cin>>n;
  map <int,int>m;
  for(int i=2;i<n+1;i++)
  {
    cin>>a;
    m[a]++;
  }
  for(int i=1;i<=n;i++)
  {
    cout<<m[i]<<nl;
  }
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 13044
#include <iostream>

using namespace std;

int main()
{
	// スペース区切りの整数の入力
	int a, b, c;
	cin >> a >> b >> c;
	int in = a - b;
	// 出力
	c -= in;
	if (c < 0) {
		c = 0;
	}
	cout << c;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int[] abcd = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(Max(abcd[0] * abcd[1], abcd[2] * abcd[3]));
    }
}

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


int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;

  int l=0,r=0;
  int sum=0;
  for(int i=0;i<N;++i){
    if(S[i]=='(') ++l;
    else{
      ++r;
      sum=max(sum,max(r-l,0));
    }
  }

  for(int i=0;i<sum;++i) S="("+S;
  l += sum;
  for(int i=0;i<l-r;++i) S=S+")";

  cout<<S<<endl;
}

Measured memory_bytes: 256
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		
		// given n, s
		//     1 <= n <= 10
		//     s の範囲は不明
		// 以下を全て満たす k[1,n] の個数を答えよ
		//     1*k[1] + 2*k[2] + ... + n*k[n] == s
		//     0 <= k[i] <= 9
		//     k[i] は互いに異なる
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			long res = solve(n, k);
			System.out.println(res);
		}
	}
	
	long[][] dp;
	final int SET = 1 << 10;
	long solve(int n, int k) {
		if (n <= 0 || n > 10) return 0;
		if (k < 0 || k > 385) return 0;
		
		if (dp == null) {
			dp = new long[SET][400];
			dp[0][0] = 1;
			for (int set = 0; set < SET; set++) {
				int on = Integer.bitCount(set);
				for (int sum = 0; sum < 400; sum++) if (dp[set][sum] > 0) {
					for (int i = 0; i <= 9; i++) {
						if ((set >> i & 1) == 0) {
							int nset = set | (1 << i);
							int nsum = sum + (on+1) * i;
							if (nsum < 400) {
								dp[nset][nsum] += dp[set][sum];
							}
						}
					}
				}
			}
		}
		long res = 0;
		for (int set = 0; set < SET; set++) if (Integer.bitCount(set) == n) {
			res += dp[set][k];
		}
		return res;
	}
}

Measured memory_bytes: 25576
//
// Created by watemus on 24.06.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define FF first
#define SS second

using ll = long long;
using ld = long double;

template<typename T>
using vec = vector<T>;

template<typename T>
using uset = unordered_set<T>;

template<typename T1, typename T2>
using umap = unordered_map<T1, T2>;

#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;
const ld PI = acos(-1);
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

vector<pair<int, int>> DD = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

#ifdef LOCAL
#else
#endif

const int MAX = 1e6 + 10;

void run() {
    int n;
    cin >> n;
    vec<int> usd(MAX);
    vec<int> a(n);
    map<int, int> cnt;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(RALL(a));
    for (int i = 0; i < n; i++) {
        cnt[a[i]]++;
        if (!usd[a[i]]) {
            for (int j = a[i]; j < MAX; j += a[i]) {
                usd[j] += 1;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (usd[a[i]] == 1 && cnt[a[i]] == 1) {
            ans++;
        }
    }
    cout << ans << '\n';
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    cout << fixed << setprecision(20);
    int t = 1;
//    cin >> t;
    while (t--) {
        run();
    }
    return 0;
}



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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int enum_divisors(int N)
{
    vector<int> res;
    for (int i = 1; i * i <= N; ++i)
    {
        if (N % i == 0)
        {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N / i != i)
                res.push_back(N / i);
        }
    }
    return res.size();
}

int main(){
    int n;  cin >> n;
    ll a(0);
    int b[n];
    rep(i,n){
        cin >> b[i];
        a += b[i];
    }

    a--;
    int ans(0);
    rep(i,n){
        ans += b[i]-1;
    }

    cout << ans << endl;

    return 0;
}

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

class Dice{
    public:
    int face[6];
    Dice(int *x){
    for(int i=0;i<6;i++){
        face[i]=x[i];
    }
    }
void roll_N(){
    int a=face[0],b=face[1],c=face[5],d=face[4];
    face[0]=b;face[1]=c;face[5]=d;face[4]=a;
}
void roll_W(){
    int a=face[0],b=face[2],c=face[5],d=face[3];
    face[0]=b;face[2]=c;face[5]=d;face[3]=a;
}
void roll_S(){
    int a=face[0],b=face[4],c=face[5],d=face[1];
    face[0]=b;face[4]=c;face[5]=d;face[1]=a;
}
void roll_E(){
    int a=face[0],b=face[3],c=face[5],d=face[2];
    face[0]=b;face[3]=c;face[5]=d;face[2]=a;
}
void roll_(){
    int a=face[1],b=face[2],c=face[4],d=face[3];
    face[1]=d;face[2]=a;face[4]=b;face[3]=c;
}
int answer(){
    return face[0];
}
};

int judge(int *x,int *y){
    int flg=0;
    for(int i=0;i<6;i++){
        if(x[i]==y[i]){flg+=1;}
    }
    if(flg==6){return true;}
    else{return false;}
}

int main(){
    int x[6],y[6];
    for(int i=0;i<6;i++)cin>>x[i];
    for(int i=0;i<6;i++)cin>>y[i];
    Dice dx(x),dy(y);
    //総当たりでやった方が速い。
    int flg=0;
    for(int i=0;i<4;i++){
    if(flg==1)break;
        for(int j=0;j<4;j++){
            if(flg==1)break;
            for(int k=0;k<4;k++){
                if(flg==1)break;
                if(judge(dx.face,dy.face)){
                    cout<<"Yes"<<endl;
                    flg=1;
                }
                dy.roll_();
            }
        dy.roll_E();
        }
    dy.roll_N();
    }
    if(flg==0)cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3108
# coding: utf-8

# input
a, b = map(int, input().split())
s = input()

def check(arg):
    flag = True
    for i in arg:
        if i in "0123456789":
            flag = True
        else:
            flag = False
    return flag

# calc
cut_a = s[:a]
cut_b = s[a:a+1]
cut_c = s[a+1:a+1+b]

# output
if check(cut_a) and cut_b == "-" and check(cut_c):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
'use strict'

const main = (input) => {
    input = input.split('\n')
    const X = parseInt(input[0].split(' ')[2])
    const Y = parseInt(input[0].split(' ')[3])
    const Xs = input[1].split(' ').map(i => parseInt(i))
    const Ys = input[2].split(' ').map(i => parseInt(i))

    const MAX_X = Math.max(...Xs)
    const MIN_Y = Math.min(...Ys)

    for(let i = X + 1; i <= Y; i++) { 
        if(MAX_X < i && i <= MIN_Y){
            console.log('No War')
            return
        }
    }
    console.log('War')
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	int x[n], maxx = INT_MIN , minx =INT_MAX;
	for(int i=0; i<n; i++) {
		cin>>x[i];
		minx = min(x[i], minx);	
		maxx = max(x[i], maxx);
	}
	long ts, ms = LONG_MAX;
	for(int i = minx; i<=maxx; i++) {
		ts = 0L;
		for(int j=0; j<n;j++) {
			ts += pow((i - x[j]), 2);
		}
		ms = min( ts, ms);
	}
	cout<<ms;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
    int x,y;
    scanf("%d %d",&x,&y);
    for(int i = 1;i <= x;i++){
        if(i * 2 + (x - i) * 4 == y || i * 4 + (x - i) * 2 == y){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 1660
import java.util.Scanner;

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

		// 入力値の取得
		int K = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		// 結果の出力
		System.out.println(B % K > B - A? "NG" : "OK");

		sc.close();
	}
}


Measured memory_bytes: 27000
//
//  main.cpp
//  ALDS1_7_B
//
//  Created by ptyuan on 2018/11/4.
//  Copyright © 2018 YY. All rights reserved.
//

#include <iostream>
#include <cstdio>

using namespace std;


struct Node {
    int parent = -1;
    int left = -1;
    int right = -1;
};

const int kMaxCount = 25;

Node T[kMaxCount];

int n = 0;

int sibling(int i) {

    if (-1 == T[i].parent) {
        return -1;
    }
    Node parent = T[T[i].parent];
    if (i == parent.left && parent.right != -1) {
        return parent.right;
    }
    if (i == parent.right && parent.left != -1) {
        return parent.left;
    }
    return -1;
}

int degree(int i) {
    int d = 0;
    if (T[i].left != -1) {
        d++;
    }
    
    if (T[i].right != -1) {
        d++;
    }
    
    return d;
}

int D[kMaxCount];
void depth(int u, int d) {
    if (-1 != u) {
        D[u] = d;
    } else {
        return ;
    }
    
    depth(T[u].left, d + 1);
    depth(T[u].right, d + 1);
}
int H[kMaxCount];
int height(int u) {
    int h1 = 0;
    int h2 = 0;
    if (T[u].left != -1) {
        h1 = height(T[u].left) + 1;
    }
    
    if (T[u].right != -1) {
        h2 = height(T[u].right) + 1;
    }
    H[u] = h1 > h2 ? h1 : h2;
    return H[u];
}

void print(int i, int p) {
    Node node = T[i];
    cout << "node " << i << ": " << "parent = " << node.parent <<", sibling = " << sibling(i) << ", " << "degree = " << degree(i) << ", depth = " << D[i] << ", " << "height = " << H[i] << ", ";
    
    
    if (node.parent == -1) {
        cout << "root" << endl;
    } else {
        int left = node.left;
        int right = node.right;
        if (left == -1 && right == -1) {
            cout << "leaf" << endl;
        } else {
            cout << "internal node" << endl;
        }
    }
    
}



int main(int argc, const char * argv[]) {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        Node node;
        T[i] = node;
    }

    for (int i = 0; i < n; ++i) {
        int id = -1;
        int left = -1;
        int right = -1;
        cin >> id >> left >> right;
        T[id].left = left;
        T[id].right= right;
        if (left != -1) {
            T[left].parent = id;
        }
        if (right != -1) {
           T[right].parent = id;
        }
    }
    
    int p = -1;
    for (int i = 0; i < n; ++i) {
        Node node = T[i];
        if (node.parent == -1) {
            p = i;
        }
    }
    
    depth(p, 0);
    height(p);
    
    for (int i = 0; i < n; ++i) {
        print(i, p);
    }
    
    return 0;
}



Measured memory_bytes: 3268
import java.util.Scanner;


class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();

		scan.close();

		if(a<b){

			System.out.println("a < b");
		}
		else if(a>b){

			System.out.println("a > b");
		}
		else if(a==b){

			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 17316
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> m;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        m[A[i]]++;
    }
    int cnt = 0;
    for(auto u:m){
        if(u.second > 2)cnt += u.second - 1;
        else if(u.second == 2) cnt++;
    }
    cout << N -(cnt + 1) / 2 * 2 << endl;
}

Measured memory_bytes: 5376
import java.io.*;
import java.util.*;
 
 
public class Main{
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      
      // Start writing your solution here. -------------------------------------
   int k = sc.nextInt();
     int n = sc.nextInt();
     int [] a = new int[n];
     for(int i = 0; i < n ; i ++)
       a[i] = sc.nextInt();
     int max = a[0] + k - a[n - 1];
     for(int i = 1; i < n ; i ++)
       max = Math.max(max, a[i] - a[i - 1]);
     out.println(k - max);
      /*
      int n      = sc.nextInt();        // read input as integer
      long k     = sc.nextLong();       // read input as long
      double d   = sc.nextDouble();     // read input as double
      String str = sc.next();           // read input as String
      String s   = sc.nextLine();       // read whole line as String

      int result = 3*n;
      out.println(result);                    // print via PrintWriter
      */

      // Stop writing your solution here. -------------------------------------
      out.close();
   }

     

   //-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;
      
   //-----------MyScanner class for faster input----------
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
 
      long nextLong() {
          return Long.parseLong(next());
      }
 
      double nextDouble() {
          return Double.parseDouble(next());
      }
 
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }

   }
   //--------------------------------------------------------
}

Measured memory_bytes: 47952
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a;
  int b;
  cin >> a;
  cin >> b;
  int ans;

  int min = (a / 100) * 100 + (a/10000) + ((a/1000)%10) * 10;
  int max = (b / 100) * 100 + (b/10000) + ((b/1000)%10) * 10;

  ans += (b / 100) - (a/100) - 1;
  if(min >= a){ans++;}
  if(max <= b){ans++;}

  cout << ans;
  return 0;
}


Measured memory_bytes: 256
import itertools

N = input()
# n, r = map(int, input().split())
# p = list(map(int, input().split()))
x = input().split()
# S = [int(input()) for i in range(int(n))]
summ =0
ave =0

for ii in x:
    ave += int(ii)

ave = ave / int(N)
ave = round(ave)
# ave = -(-ave // int(N))  # 問題は切り捨てか切り上げか?配列中でAVEより

for i in x:
    summ+= (int(i) - ave)**2

print(summ)


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

#define ll long long
#define ull unsigned long long
#define vii vector<int>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pdd pair<double,double>
#define pldld pair<long long double, long long double>
#define ff first
#define ss second
#define pb push_back
#define read freopen("alu.txt","r",stdin);
#define write freopen("vorta.txt","w",stdout);
#define fastio ios::sync_with_stdio(false); cin.tie(NULL);
#define PI 2*acos(0.0)
#define DEBUG(x) cerr << #x << " = " << x << endl

const int MAX = 1e6 + 5, MOD = 1e9 + 7, MAXLG = log2(MAX)+1;
const ll inf = 1e18 + 5;

ll arr[MAX];
int mark[MAX];
vii prime;
void siv(){
    for(ll i=4; i<MAX; i+=2) mark[i] = 1;
    prime.pb(2);
    for(ll i=3; i<MAX; i+=2){
        if(!mark[i]){
            prime.pb(i);
            for(ll j = i*i; j<MAX; j += 2*i){
                mark[j] = 1;
            }
        }
    }
}

map<int,bool>mp;
vii v;
int main(){

    fastio;
    siv();
    ll a,b;
    cin>>a>>b;
    for(int i=0; i<prime.size() & prime[i] * prime[i] <= a; i++){
        if(a % prime[i] == 0){
            mp[prime[i]] = true;
            while(a % prime[i] == 0) a /= prime[i];
        }
    }
    if(a > 1) mp[a] = true;

    for(int i=0; i<prime.size() & prime[i] * prime[i] <= b; i++){
        if(b % prime[i] == 0){
            if(mp.find(prime[i]) != mp.end()) v.pb(prime[i]);
            while(b % prime[i] == 0) b /= prime[i];
        }
    }

    if(b > 1){
        if(mp.find(b) != mp.end()) v.pb(b);
    }

//    for(int i=0; i<v.size(); i++) cout<<v[i]<<" ";
//    cout<<"\n";
    cout<<(int)v.size() + 1<<"\n";


}


Measured memory_bytes: 4988
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner scan = new Scanner(System.in);
		String S = scan.nextLine();
        
        if(S.equals("ABC")){
            System.out.println("ARC");
        }else{
            System.out.println("ABC");
        }
        
    }
}

Measured memory_bytes: 35704
//Signboard
#include <iostream>

using namespace std;

int main() {
    int N;
    string base, str;
    bool flg;
    cin >> N;
    cin >> base;
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        cin >> str;
        flg = false;
        for(int p = 0; p < str.size(); p++) {
            for(int s = 1; s < str.size() - p; s++) {
                string x = "";
                for(int j = 0; j < base.size(); j++) {
                    if(p + j * s < str.size()) x += str[p + j * s];
                }
                if(base == x) {flg = true; break;}
            }
            if(flg) break;
        }
        if(flg) cnt++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 3192
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define ll long long
#define pb push_back
#define Never
#define To

using namespace std;

int main(){

	cin.tie(0);
	ios::sync_with_stdio(false);

	int A,B,C;

	cin >> A >> B >>C;

	if(A +  B >= C){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	Never To return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using 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; }
#define MOD 1000000007
#define INF 1000000
#define PI 3.14159265358979323846264338327950L
#define MAX_N 200010
#define lb lower_bound //[2,4)=lb(4)-lb(2);

ll countPrimes(ll n)
{
  ll count=0;
  if (n%2==0) 
  {
    count++;
    while (n%2==0) n/=2;
  }
  for (ll i=3;i*i<=n;i=i+2)
  {
    while (n%i==0) 
    {
      n /= i;
      if (n%i!=0) count++;
    }
  }
  if (n != 1) count++;
  return (count);
}
  
int main()
{
  ll a,b;
  cin>>a>>b;
  ll g = __gcd(a,b);
  
  cout<<countPrimes(g)+1<<endl;
}

Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder179
{
    class Program
    {
        static int[] RI()
        {
            return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        }

        static long[] RL()
        {
            return Console.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        }

        static string RS()
        {
            return Console.ReadLine();
        }

        static void W(object msg)
        {
            Console.WriteLine(msg);
        }

        static void Main(string[] args)
        {
            QC();
        }

        private static void QA()
        {
            string line = RS();
            W(line + (line.EndsWith("s") ? "es" : "s"));
        }

        private static void QB()
        {
            int N = int.Parse(RS());
            int cnt = 0;
            for (int i = 0; i < N; i++)
            {
                int[] nums = RI();
                if (nums[0] == nums[1])
                {
                    cnt++;
                } else
                {
                    cnt = 0;
                }

                if (cnt >= 3) break;
            }

            W((cnt >= 3) ? "Yes" : "No");
        }

        private static void QC()
        {
            int N = int.Parse(RS());

            int cnt = 0;
            for (int i = 1; i < N; i++)
            {
                cnt += (N - 1) / i;
            }

            W(cnt);
        }

        private static void QD()
        {

        }

        private static void QE()
        {

        }
    }
}


Measured memory_bytes: 17636
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<climits>

#define ll long long int
#define llu unsigned long long int
#define N 100001
using namespace std;

vector<int> dp(N,-1);
int fun(vector<int> &v,int i){
	if(i==1)
      return 0;
    if(i<1)
    return N;
  if(dp[i]==-1){
    dp[i]=min(fun(v,i-1)+abs(v[i]-v[i-1]),fun(v,i-2)+abs(v[i]-v[i-2]));
  }
  return dp[i];
}

int main(){
	int n;
  cin>>n;
  vector<int> v(n+1);
  v[0]=2*N;
  for(int i=1;i<n+1;i++){
  cin>>v[i];
  }
  cout<<fun(v,n);

return 0;
}

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

int main(){
  long long int N;
  cin  >> N;
  long long int sum = 0;

  for (long long int i = 1; i < N + 1; i++){
    if (i % 5 != 0 && i % 3 != 0 && i % 15 != 0){
      sum += i;
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    VI a(n), b(n);
    REP(i,n){
        a[i] = in();
        b[i] = a[i];
    }
    sort(ALL(b));

    REP(i,n){
        int ans;
        if (a[i] <= b[n/2-1]){
            ans = b[n/2];
        }else{
            ans = b[n/2-1];
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <stack> 
#include <set>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;
const int INF = 1000000002;
const int mod = 1000000007;

#define N 200010

deque<int> Q;

int a[N];

int main()
{
	//freopen("in.in", "r", stdin);
	//freopen("out.out", "w", stdout);
	
	int n, x;
	scanf("%d", &n);
	scanf("%d", &x);
	Q.push_back(x);

	bool rev = false;
	for (int i = 2; i <= n; ++i)
	{
		scanf("%d", &x);
		if (!rev) Q.push_back(x);
		else Q.push_front(x);
		rev ^= 1; 
	}

	if (!rev)
	{
		for (int i = 1; i <= n; ++i)
		{
			x = Q.front();
			Q.pop_front();
			printf("%d%c", x, i == n? '\n':' ');
		}
	}
	else
	{
		for (int i = 1; i <= n; ++i)
		{
			x = Q.back();
			Q.pop_back();
			printf("%d%c", x, i == n? '\n':' ');
		}
	}

	return 0;
}



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

#define MAX 1001

int dp[MAX][MAX];
int v[MAX], w[MAX];

int main() {
	int W, n, u = 0;
	char t;
	while (cin >> W) {
		if (W == 0) break;
		cin >> n;
		u++;

		for (int i = 0; i < n; i++) {
			cin >> v[i] >> t >> w[i];
		}

		for (int i = 1; i <= n; i++) {
			for (int j = 0; j <= W; j++) {
				if (w[i - 1] <= j) {
					dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
				} else {
					dp[i][j] = dp[i - 1][j];
				}
			}
		}

		int mv, mw;
		mv = mw = 0;
		for (int i = 0; i <= W; i++) {
			if (dp[n][i] > mv) {
				mv = dp[n][i];
				mw = i;
			}
		}

		cout << "Case " << u << ":" << endl;
		cout << mv << endl;
		cout << mw << endl;
	}
	return 0;
}

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

namespace AOJ
{
  class Program
  {
    static void Main(string[] args)
    {
      var str = "";
      while ((str = Console.ReadLine()) != null){
        var ab = str.Split(' ').Select(i => int.Parse(i)).ToArray();
        Console.WriteLine("{0}",((ab[0]+ab[1]).ToString().Length));
      }
    }
  }
}

Measured memory_bytes: 6028
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MOD = 1e9+7;

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

    int n,m;
    cin >> n >> m;

    vector<int> a(m),b(m);
    rep(i,m) cin >> a[i] >> b[i];

    map<P,int> G;
    rep(i,m){
      P p1,p2;
      p1.first = a[i]; p1.second = b[i];
      p2.first = b[i]; p2.second = a[i];
      G[p1] = 1; G[p2] = 1;
    }
  
    int array[n];
    rep(i,n) array[i] = i+1;
    
    int ans = 0;
    do{
      bool ok = true;
      if(array[0] != 1) continue;
      rep(i,n-1){
        P p;
        p.first = array[i];
        p.second = array[i+1];
        if( !G[p] ) ok = false;
      }
      if(ok) ans++;
    }while(next_permutation(array, array + n));

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


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str, T: str):

    a = 0
    for i in range(len(S)):
        if S[i] == T[i]:
            a+=1
        
    print(a)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060