akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  string o,e,ans="";
  cin >> o >> e;
  for(int i=0;i<e.size();i++){
    ans+=o[i];
    ans+=e[i];
  }
  if(o.size()!=e.size())
    ans+=o[o.size()-1];
  //cout << e.size() << endl;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include <functional>

#define big ((long long)(1e9)+7)

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
	string s;
	string t;
	cin >> s >> t;
	for(int i = 0;i < s.size();i++)
	{
		if(s.at(i) != t.at(i))
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


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

int main() {
  string a,b;
  cin>>a;
  cin>>b;
  int la=a.size();
  int lb=b.size();
  if (la+1==lb && b.erase(la)==a){
    cout <<"Yes";
  }else{
    cout <<"No";
  }
  
}

Measured memory_bytes: 3628
import math
while True:
  n = int(input())
  if n == 0:
    break;
  else:
    sum = 0
    var = 0
    s = input().rstrip().split(' ')
    for i in range(n):
      sum += int(s[i])
    average = sum / n
    for j in range(n):
      var += (int(s[j]) - average) ** 2
    var = math.sqrt(var / n)
    print(var)


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 10000000000;
/****** define constant end ********/


/****** define variable start ******/
ll h;
/******* define variable end *******/

ll solve(){
    cin >> h;
    ll ans = 0;
    REP(i, (ll)log2(h)+1){
        ans += pow(2, i);
    }
    cout << ans << endl;
    return 0;
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return (int)end_solve;
}


Measured memory_bytes: 256
S = list(input())
K = int(input())

for i in range(len(S)):
  n = ord(S[i])
  if S[i] == 'a':
    continue
  if ord('z') - n + 1 <= K:
    K -= ord('z') - n + 1
    S[i] = 'a'
assert K >= 0
if K != 0:
  n = ord(S[-1])
  n -= ord('a')
  n += K
  n %= 26
  n += ord('a')
  S[-1] = chr(n)
print(''.join(S))
    
    


Measured memory_bytes: 4152
#include<bits/stdc++.h>
using namespace std;
int h[100500],n,mem[100500];
#define INF 1000000000
int dp(int i){
    if(i==1) return 0;
    if(i<1) return INF;
    if(mem[i]!=-1) return mem[i];
    int a1= dp(i-1)+abs(h[i-1]-h[i]);
    int a2 =dp(i-2)+abs(h[i-2]-h[i]);
    return  mem[i]=min(a1,a2);
}
int main(){
    int n;
    cin >> n;
    memset(mem,-1,sizeof(mem));
    for(int i=1;i<=n;i++){
        cin >> h[i];
    }
    cout << dp(n) << '\n';
    return 0;
}



Measured memory_bytes: 4096
/*I wanna be the very best, like no one ever was...*/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({a * c, a * d, b * c, b * d});
	
	return 0;
}

Measured memory_bytes: 3644
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    print(a+b//2)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include<sstream>
#include <vector>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L

#define INF 0x3f3f3f3f
//const int N = 2e5 + 5;

 
//int vis[N];
bool sortcol(const vector<int>& v1,
	const vector<int>& v2) {
	return v1[0] < v2[0];
}

int32_t  main() {

	IOS;
  
 
	int X;

	cin >> X;

	int init = 100;
	int cnt = 0;
	while (true) {
		int interest= init*0.01;
		init += interest;
		cnt++;
		if (init >= X) {
			break;
		}

	}

	cout << cnt << endl;
 
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt(); 
		int W = sc.nextInt();
		
		char[][] arr = new char[H][W];
		for (int i = 0; i < H; i++) {
			arr[i] = sc.next().toCharArray();
		}

		List<Integer> removeHList = new ArrayList<>();
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (arr[i][j] == '#') {
					break;
				}
				if (j == W - 1) {
					removeHList.add(i);
				}
			}
		}
		
		List<Integer> removeWList = new ArrayList<>();
		for (int i = 0; i < W; i++) {
			for (int j = 0; j < H; j++) {
				if (arr[j][i] == '#') {
					break;
				}
				if (j == H - 1) {
					removeWList.add(i);
				}
			}
		}
		
		List<List<Character>> result = new ArrayList<>();
		for (int i = 0; i < H; i++) {
			if (removeHList.contains(i)) {
				continue;
			}
			List<Character> tempList = new ArrayList<>();
			for (int j = 0; j < W; j++) {
				if (removeWList.contains(j)) {
					continue;
				}
				tempList.add(arr[i][j]);
			}
			result.add(tempList);
		}
		
		for (int i = 0; i <result.size(); i++) {
			for (int j = 0; j < result.get(0).size(); j++) {
				System.out.print(result.get(i).get(j));
			}
			System.out.println();
		}
		sc.close();
	}
}


Measured memory_bytes: 24788
#include<stdio.h>                                                    
int main(void)
{
   int n,i,res=0;
   int c[50],v[50],r[50];

   scanf("%d",&n);

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

   for(i=0;i<n;i++){
      r[i]=v[i]-c[i];
      if(r[i]>0){
            res +=r[i];
         }
   }

   printf("%d",res);
   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 4001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll,ll,ll>>>;

// MOD確認

int main(){
    ll X;
    cin >> X;
    //cout << (ll)(pow(X,5) + 5 * pow(X,4) + 10 * pow(X,3) + 10 * pow(5,2) + 5 * X + 1) << endl;
    FOR(i,-200,200) FOR(j,-200,200){
        if(pow(i,5) - pow(j,5) == X){
            cout << i << ' ' << j << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 4064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+5;
const ll mod=1e9+7;
int a[27];
int main()
{
 string s;
 cin>>s;
 int cnt=0;
 for(int i=0;i<4;i++)
    a[s[i]-'A']++;
 for(int i=0;i<26;i++)
    if(a[i]==2)
    cnt++;
 puts(cnt==2?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
N = int(input())
adj = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    adj[u].append((v, w))
    adj[v].append((u, w))

stack = [0]
color = [-1]*N
color[0] = 0
while stack:
    v = stack.pop()
    for child, w in adj[v]:
        if color[child] < 0:
            color[child] = (color[v] + w) % 2
            stack.append(child)

for i in color:
    print(i)

Measured memory_bytes: 93420
import numpy as np
n = int(input())
a = list(map(int, input().split()))
a_sum = np.cumsum(a)
sunuke = 0
res = 10**19
for i in range(n-1):
  sunuke += a[-i-1]
  if(abs(sunuke-a_sum[-i-2]) < res):
    res = abs(sunuke-a_sum[-i-2])
print(res)


Measured memory_bytes: 33036
import numpy as np
n,k = [int(j) for j in input().split()]
r = np.full(n,False)
for i in range(k):
    d = int(input())
    a = [int(j) - 1 for j in input().split()]
    for j in a:
        r[j] = True
print(n - len(r[r]))

Measured memory_bytes: 27168
#include <cmath>
#include <cstdio>
int X;

bool is_prime(int n) {
  int s = sqrt(n);
  for (int i = 2; i < s; ++i) {
    if ((n % i) == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  scanf("%d", &X);
  while (!is_prime(X)) ++X;
  printf("%d\n", X);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<int, int> P;


int main(){
    int n;  cin >> n;
    vector<vector<int>> state(n, vector<int>(n, INT32_MAX));
    vector<vector<int>> exist(n, vector<int>(n, 1));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            state[i][j] = min(i, min(j, min(n-1-i, n-1-j)));
        }
    }

    vector<P> dir = {P(0, 1), P(1, 0), P(-1, 0), P(0, -1)};
    function<bool(int, int)> check = [&](int i, int j){
        return (i >= 0) && (j >= 0) && (i < n) && (j < n);
    };

    function<void(int, int)> dfs = [&](int i, int j){
        int cur = state[i][j];
        for(auto d: dir){
            int ni = i + d.fs, nj = j + d.sc;
            if(!check(ni, nj))  continue;
            if(state[ni][nj] > cur + exist[i][j]){
                state[ni][nj] = cur + exist[i][j];
                dfs(ni, nj);
            }
        }
    };

    ll res = 0;
    for(int k = 0; k < n * n; k++){
        int p;  cin >> p;
        p--;
        int i = p / n, j = p % n;
        res += state[i][j];
        exist[i][j] = 0;
//        cout << state[i][j] << endl;
        dfs(i, j);
    }

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 36624
N = int(input())
a = [int(x) for x in input().split()]

ans = a[0]
for i in range(1, N):
    ans = ans ^ a[i]

res = [0 for _ in range(N)]
for i in range(N):
    res[i] = ans ^ a[i]
    res[i] = str(res[i])

print(' '.join(res))

Measured memory_bytes: 35864
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner a = new Scanner(System.in);		
		int b = a.nextInt();
		int c  = b / 10;
		if(b % 10 == 7) {
		    System.out.println("Yes");
		}else if(b / 10 == 7) {
			System.out.println("Yes");
		}else if(b % 100 == 70) {
			System.out.println("Yes");	
		}else if(c % 10 == 7) {
			System.out.println("Yes");
		}else if(b / 100 == 7) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}	
	}
}

Measured memory_bytes: 35880
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var list = Console.ReadLine().Split(' ');
        var n = int.Parse(list[0]);
        var m = int.Parse(list[1]);

        var lrs = new KeyValuePair<int, int>[m];
        for (int i = 0; i < lrs.Length; ++i)
        {
            var list2 = Console.ReadLine().Split(' ');
            var l_ = int.Parse(list2[0]);
            var r_ = int.Parse(list2[1]);
            lrs[i] = new KeyValuePair<int, int>(l_, r_);
        }

        var l = 1;
        var r = n;

        for (int i = 0; i < lrs.Length; ++i)
        {
            var lr = lrs[i];
            var nl = lr.Key;
            var nr = lr.Value;
            if (l < nl)
                l = nl;
            if (nr < r)
                r = nr;
            if (r < l)
                break;
        }

        Console.WriteLine(Math.Max(r - l + 1, 0));
    }
}


Measured memory_bytes: 15820
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {
    SPEED;
    int a;
    cin >> a;
    if (a%2 == 0) {
        cout << fixed << setprecision(9) << 0.5 << endl;
    } else {
        double temp = a/2;
        temp+=1;
        temp/=a;
        cout << fixed << setprecision(9) << temp << endl;
    }
    return 0;
}

Measured memory_bytes: 3800
#include <iostream>
#include <math.h>
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define N 100005
#define inf 1e18
#define mem(a,b) memset(a,b,sizeof(a))

using namespace std;

ll binomialCoeff(ll n,ll k)
{
    ll res = 1;
    if(k >n - k)
        k = n - k;
    for(int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

ll power(ll x,ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}


ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}

void Sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}

//*************************************************    CHECK CONSTRAINS    **********************************************************************//

long double dp[3005][3005];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
    int n;
    cin >> n;
    int t = n/2;
    if(n%2==0)
        t--;
    long double p[n+1];
    for(int i=1;i<=n;i++)
        cin >> p[i];
    dp[0][0] = 1.0;
    for(int i=1;i<=n;i++)
        dp[0][i] = dp[0][i-1]*p[i];
    for(int i=1;i<=t;i++)
    {
        dp[i][1] = 1.0;
        for(int j=2;j<=n;j++)
            dp[i][j] = dp[i][j-1]*p[j] + dp[i-1][j-1]*(1.0-p[j]);
    }
    cout << fixed << setprecision(10) << dp[t][n];
}


Measured memory_bytes: 71936
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g){
    for(int i = g; i < n; i++){
        int v = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n){
    for(int h = 1; ;){
        if(h > n) break;
        G.push_back(h);
        h = 3*h +1;
    }
    for(int i = G.size() -1; i >=0; i--){
        insertionSort(A, n, G[i]);
    }
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++) scanf("%d", &A[i]);
    cnt = 0;

    shellSort(A, n);

    cout << G.size() <<endl;
    for(int i = G.size()-1; i>=0; i--){
        printf("%d", G[i]);
        if (i) printf(" ");
    }
    printf("\n");
    printf("%d\n", cnt);
    for(int i = 0; i < n; i++) printf("%d\n", A[i]);

    return 0;
}

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

int main(int argc, char const *argv[])
{
	int a,b;
	cin >> a >> b;
	if(0>=a%500-b){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
S = input()
tmp = "U"
S = tmp + S
N = len(S)

for i in range(N):
    if i % 2 == 1:
        if S[i] == "R" or S[i] == "U" or S[i] == "D":
            continue
        else:
            print("No")
            exit()
    else:
        if S[i] == "L" or S[i] == "U" or S[i] == "D":
            continue
        else:
            print("No")
            exit()
else:
    print("Yes")


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

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		//int x = 2;
		Scanner scan = new Scanner(System.in);
	    int x = scan.nextInt();
		int z = (int)Math.pow(x, 3);
		System.out.println(z);
	}
}

Measured memory_bytes: 26164
H, W = map(int,input().split())
HW = [str(input()) for i in range(H)]

i = 0
while len(HW) > i:
  if "#" not in HW[i]:
    HW.pop(i)
    i -= 1
  i += 1  
  #print(HW)  
#print(HW)
clear_w = [0] * W
for i in range(len(HW)):
  for j in range(W):
    x = HW[i][j]
    if x == "#":
      clear_w[j] = 1
#print(clear_w)
 
for i in range(len(HW)):
  HW[i] = [HW[i][j] for j in range(W) if clear_w[j] == 1]
  
#print(HW)      
for i in range(len(HW)):
  for j in range(len(HW[i])):
    if j != len(HW[i]) - 1:
      print(HW[i][j], end = "")
    else:
      print(HW[i][j])

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

int main() {
   vector<string> s(3);
   rep(i, 3) {
       cin >> s[i];
   }

   cout << "A" << s[1][0] << "C" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*
*/
using Graph = vector<bitset<10>>;
ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main(){
  int N,R;
  cin >> N >> R;
  if(N >= 10) cout << R << endl;
  else cout << R + 100*(10-N);
}

Measured memory_bytes: 256
x, k, d = map(int, input().split())

ax = abs(x)
n = ax // d
if n >= k:
    ans = ax - k*d
else:
    a = ax - n*d
    if (k - n) % 2:
        ans = abs(a - d)
    else:
        ans = abs(a)

print(ans)


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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  int res = 0;
  bool f = true;
  while (f) {
    f = false;
    for (int j = n - 1; j >= 1; j--) {
      if (a[j] < a[j - 1]) {
        res++;
        swap(a[j], a[j - 1]);
        f = true;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << a[i];
    if (i == n - 1) break;
    cout << ' ';
  }
  cout << '\n' << res << '\n';
  return 0;
}


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

long long int max(long long int a,long long int b)
{
    if(a<=b)
    {
        return b;
    }
    else
    {
        return a;
    }
}

int main()
{
    long long int n,wt,w[105],v[105],j,i;
    scanf("%lld %lld",&n,&wt);
    long long int t[n+2][wt+5];
    for(i=0;i<n;i++)
    {
        w[i]=0,v[i]=0;
        for(j=0;j<=wt;j++)
        {
            t[i][j]=0;
        }
    }
    for(i=0;i<n;i++)
    {
        scanf("%lld %lld",&w[i],&v[i]);
    }
    for(i=0;i<=n;i++)
    {
        t[i][0]=0;
    }
    for(j=1;j<=wt;j++)
    {
        if(w[0]<=j)
        {
            t[0][j]=v[0];
        }
    }
    for(i=1;i<n;i++)
    {
        for(j=1;j<=wt;j++)
        {
            if(w[i]>j)
            {
                t[i][j]=t[i-1][j];
            }
            else
            {
                t[i][j]=max(v[i]+t[i-1][j-w[i]],t[i-1][j]);
            }
            // printf("%lld-%lld-%lld\n",i,j,t[i][j]);
        }
    }
    printf("%lld\n",t[n-1][wt]);
}

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

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

    int N;
    cin >> N;

    vector<int> h(N);
    for (int i=0; i<N; ++i) cin >> h[i];

    vector<long long> cost(N, 1e9);
    cost[0] = 0;
    for (int i=0; i<N-1; ++i) {
        if (i+1 < N)
            cost[i+1] = min(cost[i+1], cost[i] + (long long)abs(h[i] - h[i+1]));
        if (i+2 < N)
            cost[i+2] = min(cost[i+2], cost[i] + (long long)abs(h[i] - h[i+2]));
    }

    cout << cost[N-1] << endl;
    

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  cout << (s == "ARC" ? "ABC" : "ARC") << endl;
  return 0;
}

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

int a[220];

int main()
{
    int n, ans = 0;
    scanf("%d", &n);
    n <<= 1;
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i += 2) ans += a[i];
    printf("%d\n", ans);
    return 0;
}

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

string a, b, ans;
int main()
{
	int i, j, k;
	cin >> a >> b;
	for (i = a.size(); i >= 0; i--) {
		for (j = 0; j < b.size(); j++) {
			if (i + j >= a.size() || a[i + j] != b[j] && a[i + j] != '?') break;
		}
		if (j == b.size()) break;
	}
	if (i < 0) {
		cout << "UNRESTORABLE";
		return 0;
	}
	k = i;
	for (i = 0; i < a.size(); i++) {
		if (k <= i && i < k + b.size()) ans += b[i - k];
		else if (a[i] == '?') ans += 'a';
		else ans += a[i];
	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        s: String,
        t: String,
        a: i32,
        b: i32,
        u: String,
    }

    if u == s {
        println!("{} {}", a - 1, b);
    } else {
        println!("{} {}", a, b - 1);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <algorithm>
using std::pow;

int main() {
    int A, B, C, K;
    std::cin >> A >> B >> C;
    std::cin >> K;

    int max_sum = 0;
    for (int a = 0; a <= K; a ++) {
        for (int b = 0; b <= K - a; b ++) {
            int c = K - a - b;
            int sum = A * (int)pow(2, a) + B * (int)pow(2, b) + C * (int)pow(2, c);
            max_sum = std::max(max_sum, sum);
        }
    }
    std::cout << max_sum << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s="";
int main(){
    cin>>s;
    bool flag=true;
    map <char, int>mp;
    for(int i=0;i<int(s.size());i++){
        mp[s[i]]++;
    }
    for(auto it=mp.begin();it!=mp.end();++it){if(it->second%2==1)flag=false;}
    cout<<(flag?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = scan.nextInt();

		if ((n % 500) <= a) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


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

#define int long long
#define INF 1e18

int const mod = 1e9+7;

int n;

int tab[22][22];

int memo[2097152][22];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i< n; i++){
        for(int j = 0; j < n; j++){
            cin >> tab[i][j];
        }
    }
    for(int i = 0; i < (1<<n); i++) memo[i][n] = 1;
    for(int mask = (1<<n)-2; mask >= 0; mask--){
        int c = __builtin_popcount(mask);
        for(int i = 0; i < n; i++){
            if(((1<<i)&mask)) continue;
            if(!tab[c][i]) continue;
            memo[mask][c]+=memo[mask|(1<<i)][c+1];
            if(memo[mask][c] >= mod) memo[mask][c]-=mod;
        }
    }
    cout << memo[0][0] << endl;
}


Measured memory_bytes: 360704
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N, D = map(int, input().split())
    
    n = D*2+1
    print(N//n+1 if N%n else N//n)

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc134","b",main)

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


def solve(a: int, b: int, c: int, d: int):
    print(max(a*c,a*d,b*c,b*d))
    return


# Generated by 1.1.7.1 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()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    solve(a, b, c, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
using System;
using System.Collections.Generic;

public class CSharp
{
    public static void Main()
    {
        Kyopuro chokudai = new Kyopuro();
        chokudai.AtCoder();
    }
}

public class Kyopuro
{

    int n, d;
    int[][] x;

    public void AtCoder()
    {
        string[] input;
        input = Console.ReadLine().Split(' ');
        n = int.Parse(input[0]);
        d = int.Parse(input[1]);
        x = new int[n][];
        int ans = 0;
        int tmp = 0;
        int y = 0;

        for(int i=0; i<n; i++)
        {
            x[i] = new int[d];
            input = Console.ReadLine().Split(' ');
            for(int j=0; j<d; j++)
            {
                x[i][j] = int.Parse(input[j]);
            }
        }

        for(int i=0; i<n; i++)
        {
            for(int j=i+1; j<n; j++)
            {
                tmp = 0;
                for(int k=0; k<d; k++)
                {
                    y = x[i][k] - x[j][k];
                    tmp += y * y;
                }
                for(int k=0; k<200; k++)
                {
                    if (k * k == tmp) ans++;
                }
            }
        }

        Console.WriteLine(ans);
    }
    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

int main()
{
    int x;
    int n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i,n)cin >> p[i];
    ssort(p);
    int min=INF;
    int min_val=INF;
    vector<int> val(102);
    rep(i,102)val[i]=0;
    rep(i,n)val[p[i]]++;
    int dist=INF;
    for(int i=x;i>-1;--i){
        if(val[i]==0){
            min=i;
            dist=x-i;
            break;
        }
    }
    
        for(int j=x+1;j<102;++j){
            if(val[j]==0){

                if(j-x<dist){
                    min=j;
                    dist=j-x;
                    break;
                }
            }
        
    }
    
    
    cout << min << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
typedef long long ll;
const int N=1e5+5;
ll m[N],s[N],cum[N];
int main(){
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m;
   cin>>n>>m;
   map<ll,int>mp;
   ll ans=0;
   cum[0]=0;
   ll sum=0;
   mp[0]=1;
   for(int i=0;i<n;i++){
       int c;
   cin>>c;
    cum[i]=cum[i-1]+c;
    cum[i]%=m;
    ans+=mp[cum[i]];

    mp[cum[i]]++;

   }
   cout<<ans;





    return 0;
}


Measured memory_bytes: 8360
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=2005;
int u[N],v[N],re[N],vis[N],owo[N<<1];
int n,m,a,b,ans;
vector<pii> e[N];
vi p[N],id[N];

int dfs(int u,int fa,int aim,int from){
	if(u==aim)return 1;
	for(auto v:e[u])	
		if(v.fi!=fa&&dfs(v.fi,u,aim,from))
			return p[from].pb(v.se),1;
	return 0;
}

int main(){
	read(n),read(m);
	rep(i,1,n-1){
		read(a),read(b);
		e[a].pb(mp(b,2*i));
		e[b].pb(mp(a,2*i+1));
	}
	rep(i,1,m){
		read(u[i]),read(v[i]);
		dfs(u[i],0,v[i],i);
		for(auto k:p[i])id[k/2].pb(i),re[k/2]++;
	}
	rep(i,1,n-1)ans+=min(2,re[i]);
	for(;;){
		int f=0,g=0;
		rep(i,1,n-1)
			if(re[i]==1&&owo[i*2]!=owo[i*2+1]){f=i;break;}
		rep(i,1,n-1)
			if(re[i]>=2&&!f){f=i;break;}
		if(!f)break;
		for(auto k:id[f])
			if(!vis[k]){g=k;break;}
		vis[g]=1;
		for(auto k:p[g]){
			if(k/2!=f)continue;
			if(owo[k]){
				swap(u[g],v[g]);
				for(auto &j:p[g])j^=1;
			}
			for(auto j:p[g])re[j/2]--,owo[j]=1;
		}
	}
	printf("%d\n",ans);
	rep(i,1,m)printf("%d %d\n",u[i],v[i]);
	return 0;
}

Measured memory_bytes: 13952
s = readline.chomp.to_i

def is_753(x)
  found = {}
  x.to_s.each_char do |c|
    case c
    when '3','5','7'
      found[c] = true
    else
      return false
    end
  end
  found['3'] and found['5'] and found['7']
end

def dfs(n, upper, ans)
  if n > upper
    return
  end
  if is_753(n)
    ans << n
  end
  dfs( n*10 + 3, upper, ans )
  dfs( n*10 + 5, upper, ans )
  dfs( n*10 + 7, upper, ans )
end

ans = []
dfs(0, s, ans)
puts ans.size


Measured memory_bytes: 3836
#include <stdio.h>
#include <stdlib.h>
 
int main(void) {
 
  // 入力
  int a,b,c;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  
  int result;

  result=c-(a-b);
  if(result<0)result=0;
  printf("%d\n",result);
 
  return 0;
}

Measured memory_bytes: 128
def swapeds(s,a,b):
    return s.translate(str.maketrans({a:b,b:a}))
s = input()
arr = [1 for _ in range(26)]
ok = True
for i in s:
    if arr[ord(i)-97] > 0:
        arr[ord(i)-97] = 0
    else:
        ok = False
        break
mina = 25
for i in range(26):
    if arr[i] > 0 :
        mina = i
        break
        
if ok and s != 'zyxwvutsrqponmlkjihgfedcba':
    if len(s) < 26:
        print(s+chr(mina+97))
    else:
        for i in range(1,26)[::-1]:
            if s[i-1] < s[i]:
                tmp = s[i-1]
                maxs = 'z'
                break
        for i in range(s.index(tmp)+1,26)[::-1]:
            if tmp  < s[i] and maxs > s[i]:
                maxs = s[i]
        print(s[0:s.index(tmp)]+maxs)
else:
    print(-1)

Measured memory_bytes: 3064
//
//  main.cpp
//  contest
//
//  Created by TmpGuest on 2020/4/18.
//  Copyright © 2020 TmpGuest. All rights reserved.
//

#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

int main() {
ios_base::sync_with_stdio(false);
    
    string s;
    cin>>s;
    switch(s[s.length()-1]) {
        case '2':
        case '4':
        case '5':
        case '7':
        case '9':
            cout<<"hon\n";
            break;
        case '0':
        case '1':
        case '6':
        case '8':
            cout<<"pon\n";
            break;
        case '3':
            cout<<"bon\n";
            break;
            
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main()
{
    long long n , s=0;

    cin>>n;

    s = (n*(n+1)/2) - ((n/3*(n/3+1))/2)*3 - ((n/5*(n/5+1))/2)*5 +((n/15*(n/15+1))/2)*15;

    cout<<s;

    return 0;
}


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

using namespace std;

int main() {
	
	long long a,b,x,r;
	cin>>a>>b>>x;
	if(a==0){
	r=(b/x)+1;	
		
	} else
	r=((b/x)-(a-1)/x);
	
	printf("%lld",r);
	
	
	
	return 0;
}

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

int main(){
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> P(N,K-Q);
  for(int i = 0; i < Q; ++i){
    int a;
    cin >> a;
    --a;
    ++P[a];
  }
  for(auto p : P){
    if(p > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


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

#define LL long long
#define COIN const int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define LEN(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

int n,ans;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >>n;
	ans=n/2;
	if (n%2) ans++;
	cout <<ans<<endl;
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void print(vector<vector<long long int>> &dp)
{
    for(long long int i=0;i<dp.size();i++)
    {
        for(long long int j=0;j<dp[0].size();j++)
        {
            cout<<dp[i][j]<<"   ";
        }
        cout<<endl;
    }
    
}
bool comp(pair<long long int,long long int> A,pair<long long int,long long int> B)
{
    return A.first<B.first;
}
int dfs(int i,vector<int> &vis,vector<int> &dis,vector<int> adj[])
{
    for(auto it=adj[i].begin();it!=adj[i].end();it++)
    {
        if(!vis[*it])
        {
            vis[*it]=1;
            dis[i]=max(dis[i],1+dfs(*it,vis,dis,adj));
        }
        else
        {
            dis[i]=max(dis[i],1+dis[*it]);
        }
    }
    return dis[i];
}
int main() 
{
    int v,e;
    cin>>v>>e;
    vector<int> adj[v];
    for(int i=0;i<e;i++)
    {
        int src,des;cin>>src>>des;
        src--;des--;
        adj[src].push_back(des);
    }
    vector<int> vis(v,0);
    vector<int> dis(v,0);
    for(int i=0;i<v;i++)
    {
        if(!vis[i])
        {
            vis[i]=1;
            dfs(i,vis,dis,adj);
        }
    }
    cout<<*max_element(dis.begin(),dis.end());
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) v.erase(unique(ALL(v)), v.end())
#define bit(i) (1LL<<i)
#define sz(v) ((LLI)(v).size())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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


  LLI W,H,x,y;
  while(cin >> W >> H >> x >> y){
    double ans = (double)W*H/2;

    cout << setprecision(12) << ans << " ";
    cout << (2*x==W and 2*y==H ? 1 : 0) << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
int A,B,C,K;
cin>>A>>B>>C>>K;
if(A>=B&&A>=C)
cout<<A*pow(2,K)+B+C<<endl;
else if(B>=A&&B>=C)
cout<<A+B*pow(2,K)+C<<endl;
else
cout<<A+B+C*pow(2,K)<<endl;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args){
        Deque<String> formula = new ArrayDeque<String>();
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()){
            String input;
            if((input=scan.next()).equals("+")) input = String.valueOf(Integer.parseInt(formula.poll())+Integer.parseInt(formula.poll()));
            else if(input.equals("-")) input = String.valueOf(-1*Integer.parseInt(formula.poll())+Integer.parseInt(formula.poll()));
            else if(input.equals("*")) input = String.valueOf(Integer.parseInt(formula.poll())*Integer.parseInt(formula.poll()));
            formula.push(input);
        }
        System.out.println(formula.poll());
    }
}

Measured memory_bytes: 26240
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long;
using P = pair<int, int>;
using lP = pair<ll, ll>;
using fP = pair<double, double>;

map<int, int>mp;
void prime_factor(int n) {
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1)mp[n]++;
}
int main() {
    int n;
    cin >> n;
    rep(i, n) {
        prime_factor(i + 1);
    }
    int a75 = 0, a25 = 0, a15 = 0, a5 = 0, a3 = 0;
    for (auto x : mp) {
        if (x.second >= 74)a75++;
        if (x.second >= 24)a25++;
        if (x.second >= 14)a15++;
        if (x.second >= 4)a5++;
        if (x.second >= 2)a3++;
    }
    int ans = 0;
    ans += a75;
    ans += a25 * (a3-1);
    ans += a15 * (a5-1);
    ans += a5 * (a5-1)/2 * (a3-2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i=0; i < n; i++) cin >> v[i];
    for (int i=0; i < n; i++) v[i] -= (i+1);
    sort(v.begin(), v.end());
    int ans=  0;
    for (int i=0; i < n; i++){
        ans += abs(v[n/2] - v[i]);
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 1792
arr = list(int(a) for a in input().split())

# 最小値ベースに直して
# ２つ選んで２減らす
# １つ選んで１減らす

arr.sort()
A = 0
B = arr[1] - arr[0]
C = arr[2] - arr[0]

# 2で何回割り切れるか
ans = B // 2

# 残りがいくつあるか
B -= ans * 2
C -= ans * 2
ans += B + C

print(ans)


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

using namespace std;

const int mxn = 1e2;

double a[mxn + 11];

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%lf", a + i);
	}
	double ans = 0;
	for (int i = 0; i < n; i++){
		ans += 1.0 / a[i];
	}
	ans = 1.0 / ans;
	printf("%.5lf\n", ans);
	return 0;
}


Measured memory_bytes: 256
func solve(_ A: Int, _ B: Int, _ C: Int, _ K: Int) -> Int {
  
  var K = K
  if K <= A {
    return K
  }
  K -= A
  
  if K <= B {
    return A
  }
  
  K -= B
  
  return A - K
  
}

let line = readLine()!
let inputs = line.split(separator: " ")
var A = Int(inputs[0])!
var B = Int(inputs[1])!
var C = Int(inputs[2])!
var K = Int(inputs[3])!

print(solve(A, B, C, K))

Measured memory_bytes: 8312
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int r, c, n;
int x[maxn], y[maxn], a[maxn];
int g[maxn][4];
int  used[maxn], usedc[maxn], usedr[maxn];
long long v[maxn], u[maxn];
long long minv, minu;
vector< pair<int, int> > rows[maxn], cols[maxn];

int read() {
  if (scanf("%d%d%d", &r, &c, &n) < 3) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &x[i], &y[i], &a[i]);
    x[i]--;
    y[i]--;
  }
  return true;
}

bool dfs(int i) {
  minv = min(minv, v[x[i]]);
  minu = min(minu, u[y[i]]);
  used[i] = true;
  for (int ii = 0; ii < 4; ii++) {
    int j = g[i][ii];
    if (j == -1 || used[j]) {
      continue;
    }
    if (ii & 1) {
      long long vv = v[x[i]] + a[j] - a[i];
      if (usedr[x[j]] && v[x[j]] != vv) {
        return false;
      }
      v[x[j]] = vv;
      usedr[x[j]] = true;
      if (!dfs(j)) {
        return false;
      }
    } else {
      long long uu = u[y[i]] + a[j] - a[i];
      if (usedc[y[j]] && u[y[j]] != uu) {
        return false;
      }
      u[y[j]] = uu;
      usedc[y[j]] = true;
      if (!dfs(j)) {
        return false;
      }
    }
  }
  return true;
}

void solve() {
  for (int i = 0; i < r; i++) {
    rows[i].clear();
    usedr[i] = false;
  }
  for (int i = 0; i < c; i++) {
    cols[i].clear();
    usedc[i] = false;
  }
  for (int i = 0; i < n; i++) {
    rows[x[i]].push_back(make_pair(y[i], i));
    cols[y[i]].push_back(make_pair(x[i], i));
    for (int j = 0; j < 4; j++) {
      g[i][j] = -1;
    }
  }
  for (int i = 0; i < r; i++) {
    sort(rows[i].begin(), rows[i].end());
    for (int j = 0; j + 1 < sz(rows[i]); j++) {
      g[rows[i][j].second][0] = rows[i][j + 1].second;
      g[rows[i][j + 1].second][2] = rows[i][j].second;
    }
  }
  for (int i = 0; i < c; i++) {
    sort(cols[i].begin(), cols[i].end());
    for (int j = 0; j + 1 < sz(cols[i]); j++) {
      g[cols[i][j].second][1] = cols[i][j + 1].second;
      g[cols[i][j + 1].second][3] = cols[i][j].second;
    }
  }
  for (int i = 0; i < n; i++) {
    used[i] = false;
  }
  for (int i = 0; i < n; i++) {
    if (used[i]) {
      continue;
    }
    v[x[i]] = 0;
    u[y[i]] = 0;
    usedr[x[i]] = true;
    usedc[y[i]] = true;
    minv = 0;
    minu = 0;
    if (!dfs(i) || a[i] + minu + minv < 0) {
      printf("No\n");
      return;
    }
  }
  printf("Yes\n");
}

int main() {
  precalc();
#ifdef LOCAL
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 16768
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

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

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    int N;
    cin >> N;
    vector<int> A(N-1);
    for (int i=0; i<N-1; i++) cin >> A[i];

    // resolve
    map<int, int> mp;
    for (int i=1; i<=N; i++) mp[i] = 0;
    for (auto a: A) mp[a]++;

    // output
    for (auto m: mp) {
      cout << m.second << endl;
    }


    return 0;
}


Measured memory_bytes: 13552
n,m = (int(x) for x in input().split())
ar = [[] for i in range(n + 1)]
bfs = []
ans = [-1] * (n+1)

for i in range(m):
    a,b = (int(x) for x in input().split())
    ar[a].append(b)
    ar[b].append(a)

bfs.append(1)
ans[1] = 1

while(bfs):
    now = bfs.pop(0)
    for i in ar[now]:
        if ans[i] != -1:
            continue
        ans[i] = now
        bfs.append(i)

print("Yes")
for i in range(2,n + 1):
    print(ans[i])

Measured memory_bytes: 33820
is_exist = false
val_x, val_y, val_z = -1, -1, -1
max_n, total_yen = gets.chomp.split(" ").map(&:to_i)

# 1,000yen
# ptn_z means 0..max_n
ptn_z = max_n + 1
ptn_z.times do |z|
  
  # 5,000yen
  # ptn_y means 0..(max_n-z)
  ptn_y = (max_n - z) + 1
  ptn_y.times do |y|
    
    # 10,000yen
    # ptn_x means max_n - z - y
    x = max_n - z - y
    # print "#{z}#{y}#{x}\n"
    
    if total_yen == (10000*x) + (5000*y) + (1000*z)
      is_exist = true
      val_x = x
      val_y = y
      val_z = z
      break
    end
  end
  
  break if is_exist
end

print "#{val_x} #{val_y} #{val_z}\n"

Measured memory_bytes: 3836
#include<stdio.h>

int kei(int,int,int,int);
int c[9];

int main(){
	int i,a;
	for(i=0;i<9;i++){
		scanf("%d",&c[i]);
		if(c[i]==0)a=i;
	}
	printf("%d\n",kei(a,0,10,1));
	return 0;
}

int kei(int a,int co,int b,int e){
	int min=999,sum=0,i,m;
	if((e==co || b==10) && a==8){	
		for(i=0;i<8;i++){
			if(c[i]!=i+1){
				sum++;
				break;
			}
		}
		if(sum==0)return co;
	}
	while(co<e){
	
		if((a+1)%3!=0 && b!=a+1){
			m=c[a+1];
			c[a+1]=c[a];
			c[a]=m;
			m=kei(a+1,co+1,a,e);
			if(min>m){
				min=m;
				break;
			}
			m=c[a];
			c[a]=c[a+1];
			c[a+1]=m;
		}
		if((a-1)%3!=2 && a!=0 && b!=a-1){
			m=c[a];
			c[a]=c[a-1];
			c[a-1]=m;
			m=kei(a-1,co+1,a,e);
			if(min>m){
				min=m;
				break;
			}
			m=c[a];
			c[a]=c[a-1];
			c[a-1]=m;
		}
		if(a-3>=0 && b!=a-3){
			m=c[a];
			c[a]=c[a-3];
			c[a-3]=m;
			m=kei(a-3,co+1,a,e);
			if(min>m){
				min=m;
				break;
			}
			m=c[a];
			c[a]=c[a-3];
			c[a-3]=m;
		}
		if(a+3<9 && b!=a+3){
			m=c[a];
			c[a]=c[a+3];
			c[a+3]=m;
			m=kei(a+3,co+1,a,e);
			if(min>m){
				min=m;
				break;
			}
			m=c[a];
			c[a]=c[a+3];
			c[a+3]=m;
		}
		if(b==10)e++;		
		else return min;
	}
	return min;
}



Measured memory_bytes: 2084
#include<iostream>
using namespace std;
int gcd(int x,int y)//??????y????????°????????????x?°?
{
	if(x%y==0)
		return y;
	if(x>y)
		return gcd(y,x%y);
	if(x<y)
		return gcd(x,y%x);


}
int main()
{
	int x,y;
	cin>>x>>y;
		cout<<gcd(x,y)<<endl;
		
	
	

	return 0;


}

Measured memory_bytes: 3080
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	char[] s = sc.next().toCharArray();
      	int a, z;
      	int i = 0;
      	int j = s.length-1;
      	while(true){
        	if(s[i] == 'A'){
              	a=i;
          		break;
            }
          	i++;
        }
      	while(true){
         	if(s[j] == 'Z'){
            	z=j;
              	break;
            }
          	j--;
        }
      	System.out.println(j-i+1);
    }
}

Measured memory_bytes: 40832