akhauriyash/Code-Regression huggingface dataset:
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e5 + 10, inf = 1e9;

int sum(int x);

int main() {
	int n; cin >> n;
	int best = inf;
	for (int a = 1; a < n; ++a) {
		int b = n - a;
		best = min(best, sum(a) + sum(b));
	}
	cout << best;
}

int sum(int x) {
	int ans = 0;
	while (x) {
		ans += x % 10;
		x /= 10;
	}
	return ans;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    static int[] a, b;
    static int N;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        a = new int[N+1];
        int cnt = 0;
        for(int i = 1; i<N+1; i++) {
            a[i] = sc.nextInt();
        }
        b = new int[N+1];
        for(int i = 1; i<N+1; i++) b[i] = -1;
        for(int j = N; j>=1; j--) {
            if((a[j] == 1 && isOdd(j)) || (a[j] == 0 && !isOdd(j))) {
                if(b[j]==-1 ||b[j]==0) b[j] = 0;
                else {
                    System.out.println(-1);
                    return;
                }
            }
            else if((a[j] == 0 && isOdd(j))|| (a[j] == 1 && !isOdd(j))) {
                if(b[j]==-1 ||b[j]==1) {
                    if(b[j] == -1)cnt++;
                    b[j] = 1;
                    //System.out.println(j +" "+ isOdd(j));
                }
                else {
                    System.out.println(-1);
                    return;
                }
            }

        }
        System.out.println(cnt);
        for(int i = 1; i<N+1; i++) if(b[i]==1)System.out.println(i);
    }
    public static boolean isOdd(int j) {
        boolean cnt = false;
        for(int i = j*2; i<N+1; i=i+j) {
            if(b[i] == 1)cnt = !cnt;
        }
        return cnt;
    }
}

Measured memory_bytes: 83356
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
#define Rep(i,a) for(int i = 0; i < a; i++)
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#define x first
#define y second
#define pb(a) push_back(a)
const int N = 2010, mod = 1e9 + 7;
int n, k, f[N][N], fac[N * N], inv[N * N];
int C(int n, int m) { return 1LL * fac[n] * inv[n - m] % mod * inv[m] % mod; }
int pw(int a, int b) { 
	int w = 1; 
	for(;b; b >>= 1, a = 1LL * a * a % mod) 
		if (b & 1) w = 1LL * w * a % mod; 
	return w; 
}
int main() {
	scanf("%d%d",&n,&k);
	if (k == 1) { printf("1\n"); return 0; } 
	f[0][0] = 1;
	fac[0] = 1; rep(i,1,n * k) fac[i] = 1LL * fac[i - 1] * i % mod;
	inv[n * k - 1] = pw(fac[n * k - 1], mod - 2);
	dep(i,n * k - 2,0) inv[i] = 1LL * (i + 1) * inv[i + 1] % mod;

	rep(i,0,n - 1) rep(j,0,n - i) if (f[i][j]) {
		if (j < n) (f[i][j + 1] += f[i][j]) %= mod;
		if (j) f[i + 1][j - 1] = (f[i + 1][j - 1] + 1LL * C(k * (n - i) - j - 1, k - 2) * (n - i) % mod * f[i][j]) % mod; 
	}
	printf("%d\n",f[n][0]);
	return 0;
}

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

using namespace std;
int main() {
  int a[5] = {0};
  for (int i = 0; i < 5; i++) {
    cin >> a[i];
  }

  int result = 99999999;
  do {
    int total = 0;
    for (int i = 0; i < 4; i++) {
      if (a[i] % 10 == 0)
        total += a[i];
      else
        total += (a[i] / 10) * 10 + 10;
    }

    total += a[4];
    result = min(result, total);
  } while (next_permutation(a, a + 5));

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=100010,Mod=998244353;
const double pi=acos(-1.0);
typedef long long int ll;
typedef pair<int,int> pii;
int a,b;
int main()
{
  cin>>a>>b;
  if((a+b)&1) cout<<"IMPOSSIBLE\n";
  else cout<<(a+b)/2<<endl;
  return 0;
}


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

int main() {
    int H,W;
    cin >> H >> W;
    string vec[H][W];
    
    
    for(int i = 0;i < H; i++){
        string S;
        cin >> S;
        for(int j = 0;j < W; j++ ){
            vec[i][j] = S[j];
        }
    }
    
    
    int count;
    for(int i = 0;i < H; i++){
        for(int j = 0;j < W; j++){
            count = 0;
            if(vec[i][j] == "#"){
                cout << "#";
            }
            else{
                if(i-1 >= 0 && j-1 >= 0 && vec[i-1][j-1] == "#"){
                    count++;
                }
                if(i-1 >= 0 && vec[i-1][j] == "#"){
                    count++;
                }
                if(i-1 >= 0 && j+1 < W && vec[i-1][j+1] == "#"){
                    count++;
                }
                if(j-1 >= 0 && vec[i][j-1] == "#"){
                    count++;
                }
                if(j+1 < W && vec[i][j+1] == "#"){
                    count++;
                }
                if(i+1 < H && j-1 >= 0 && vec[i+1][j-1] == "#"){
                    count++;
                }
                if(i+1 < H && vec[i+1][j] == "#"){
                    count++;
                }
                if(i+1 < H && j+1 < W && vec[i+1][j+1] == "#"){
                    count++;
                }
            cout << count;
            }
        }
    cout << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define f(i,a,b) for(int i = a; i < b; i++)
#define MAX 1000000010
using namespace std;
typedef long long int ll;
ll dp[1010][1010];
ll mod=1e9 +7;
string t[1010];
int main(){
	int n,m,a,b,x,ans=0;
	cin>>n>>m;
	f(i,0,n) cin>>t[i];
	f(i,0,n){
		f(j,0,m){
			if(t[i][j]=='#') continue;
			if(i==0 && j==0) dp[0][0]=1;
			else if(i==0) dp[i][j]=dp[i][j-1];
			else if(j==0) dp[i][j]=dp[i-1][j];
			else{
				if(t[i-1][j]=='.') dp[i][j]+=dp[i-1][j];
				if(t[i][j-1]=='.') dp[i][j]+=dp[i][j-1];
				dp[i][j]=dp[i][j]%mod;
			}
		}
	}
	cout<<dp[n-1][m-1];
}

Measured memory_bytes: 9216
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    char str[15] = { 0 };
    scanf("%s", str);
    int n = strlen(str);
    vector<char> z;
    int i;
    for (i = 0; i < n; i++) {
        if (str[i] == 'B') {
            if(!z.empty())
            z.pop_back();
        }
        else z.push_back(str[i]);
    }
    z.push_back('\0');
    printf("%s\n", &z[0]);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


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

dx = [1,1,1,0,0,-1,-1,-1]
dy = [1,0,-1,1,-1,1,0,-1]

A = [[] for i in range(H)]
for i in range(H):
    for j in range(W):
        count = 0
        for k in range(8):
            ny = i + dy[k]
            nx = j + dx[k]
            if S[i][j]:
                if 0 <= ny < H and 0 <= nx < W:
                    if S[ny][nx] == "#":
                        count += 1
        A[i].append(str(count))

for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
           A[i][j] = "#"
for i in range(H):
    print("".join(A[i]))

Measured memory_bytes: 3188
#include <iostream>

int main()
{
    std::ios_base::sync_with_stdio(0);
    int h,w,a,b;
    std::cin >> h >> w >> a >> b;

    for (int j=0;j<h;++j)
    {
        for (int i=0;i<w;++i)
        {
            if (i < a && j < b) std::cout << 1;
            else if (i >= a && j >= b) std::cout << 1;
            else std::cout << 0;
        }
        std::cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 1280
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws Exception
	{
		int n=nextInt();
		int a[]=new int[n+1];
		for(int i=1;i<=n;i++)
			a[i]=nextInt();
		Arrays.sort(a,1,n+1);
		long ans=a[n];
		for(int i=3,c=n;i<=n;i++)
		{
			if(i%2==1)
				c--;
			ans+=a[c];
		}
		out.println(ans);
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 55876
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
typedef pair <int, int> P;

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

    int n;
    cin >> n;

    vector <P> num(n);
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;

        int l = 0, r = 0;
        stack <int> st;
        for (char c : s) {
            if (c == ')') {
                if (st.empty()) {
                    l++;
                } else {
                    st.pop();
                }
            } else {
                st.push(1);
            }
        }
        r = st.size();

        num[i] = {r - l, l};
    }

    sort(num.begin(), num.end(), greater<P>());
    
    int right = 0;
    for (int i = 0; i < n; i++) {
        int l = num[i].second;
        int r = num[i].first + l;
        if (l == 0) right += r;
    }

    for (int i = 0; i < n; i++) {
        int l = num[i].second;
        int r = num[i].first + l;
        if (r && l) {
            if (right < l) {
                cout << "No" << endl;
                return 0;
            } else {
                right = right - l + r;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        int l = num[i].second;
        int r = num[i].first + l;
        if (r == 0) right -= l;
    }

    cout << (right == 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 11100
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  if('A' <= s[k - 1] && s[k - 1] <= 'Z') s[k - 1] = 'a' + (s[k - 1] - 'A');

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
    long long a,i,k,x;
    cin>>k;
    queue<long long>q;
    for(i=1; i<=9; i++)
    {
        q.push(i);
    }
    for(i=1; i<=k; i++)
    {
        x=q.front();
        q.pop();

        if(x%10!=0)
        {
            q.push(x*10+x%10-1);
        }
        q.push(x*10+x%10);
        if(x%10!=9)
        {
            q.push(x*10+x%10+1);
        }
    }
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a <= A; ++a) {
    for (int b = 0; b <= B; ++b) {
      for (int c = 0; c <= C; ++c) {
        int total = 500*a + 100*b + 50*c; // 合計金額
        if (total == X) ++res; // 合計金額が X に一致したら答えをインクリメント
      }
    }
  }
  cout << res << endl;
}

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

#define MAX 10001

main(){
    int n, m, L[MAX], R[MAX], C[MAX*2], i, j, k;
    while( cin >> n >> m ){
	if ( n == 0 && m == 0 ) break;
	for ( i = 0; i < n; i++ ) cin >> L[i];
	for ( i = 0; i < m; i++ ) cin >> R[i];
	L[n] = R[m] = 1000001;
	i = j = k = 0;
	while( k < n + m ) {
	    C[k++] = (L[i] <= R[j]) ? L[i++] : R[j++];
	}
	int maxv = C[0];
	for ( int i = 1; i < n+m; i++ ){
	    if ( maxv < C[i] - C[i-1] ) maxv = C[i] - C[i-1];
	}
	cout << maxv << endl;
    }
}

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

int main(){
    int a,b;
    cin >> a >> b;
    int ans=0;
    for(int i=0;i<2;i++){
        if(a>=b){
            ans += a;
            a -= 1;
        }else{
            ans += b;
            b -= 1;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>

using ull = unsigned long long int;
using ll = long long int; 

using namespace std;

int main(){
    ll a, b;

    cin >> a >> b;

    if(a>9||b>9) cout << -1 << endl;
    else cout << a*b << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <stdint.h>
#include <map>

using namespace std;

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

  map<int, int> X;

  X.emplace(1,0);
  
  for(int n=2; n<=N; ++n) {
    X.emplace(n,0);

    int a;
    cin >> a;

    ++X[a];
  }

  for (int n=1; n<=N; ++n) {
    cout << X[n] << endl;
  }

  return 0;
}


Measured memory_bytes: 13008
/*
 * FileName:     fix
 * CreatedDate:  2020-07-12 20:45:35 +0900
 * LastModified: 2020-07-12 21:22:36 +0900
 */

#include <stdio.h>
#include <stdlib.h>
int c = 0;
void reconstruct(int *preorder, int *inorder, int left, int right, int *pos, int *postorder){
    if(left>=right)return;
    int root, root_pos;
    root = preorder[*pos];
    *pos = *pos+1;
    root_pos = left;
    for(int i=left; i<right; i++){
        if(inorder[i]==root){
            root_pos = i;
        }
    }
    reconstruct(preorder, inorder, left, root_pos, pos, postorder);
    reconstruct(preorder, inorder, root_pos + 1, right, pos, postorder);
    
    postorder[c++] = root;

}
int main(void){
    int n;scanf("%d", &n);
    int pos = 0;

    int *preorder = malloc(n*sizeof(int));
    int *inorder = malloc(n*sizeof(int));
    int *postorder = malloc(n*sizeof(int));
    for(int i=0; i<n; i++) scanf("%d", preorder+i);
    for(int i=0; i<n; i++) scanf("%d", inorder+i);
    reconstruct(preorder, inorder, 0, n, &pos, postorder);
    for(int i=0; i<n; i++){
        if(i==0){
            printf("%d", postorder[0]);
            continue;
        }
        printf(" %d", postorder[i]);
    }
    printf("\n");
    free(preorder);
    free(inorder);
    free(postorder);
    return 0;
}



Measured memory_bytes: 2096
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
        for j in range(W):
            if i==0 or i==H-1:
                print("#",end="")
            elif j==0 or j==W-1:
                 print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7004
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

type rgb struct {
	R, G, B int
}

func nextInt() int {
	n, _ := strconv.Atoi(nextString())
	return n
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	S := nextString()

	rc := 0
	gc := 0
	bc := 0

	for _, s := range S {
		if s == 'R' {
			rc++
		} else if s == 'G' {
			gc++
		} else {
			bc++
		}
	}

	sum := rc * gc * bc

	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			k := j + (j - i)
			if k < N {
				str := []byte{S[i], S[j], S[k]}
				if isRGB(string(str)) {
					sum--
				}
			}
		}
	}
	fmt.Println(sum)
}

func isRGB(subString string) bool {
	switch subString {
	case "RGB":
		return true
	case "RBG":
		return true
	case "GRB":
		return true
	case "GBR":
		return true
	case "BRG":
		return true
	case "BGR":
		return true
	default:
		return false
	}
}


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

using namespace std;

int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int dp[3001][3] = {{0}};
    int sum=0;
    dp[0][0] = 1;
    for (int i=0; i<N; i++) {
        for (int j=N; j>=0; j--) {
            if (j + R <= N) dp[j + R][0] = dp[j][0];
            if (j + G <= N) dp[j + G][1] = dp[j][0] + dp[j][1];
            if (j + B <= N) dp[j + B][2] = dp[j][0] + dp[j][1] + dp[j][2];
            dp[j][0] = 0; dp[j][1] = 0; dp[j][2] = 0;
        }
        sum += dp[N][0] + dp[N][1] + dp[N][2];
    }
    cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 256
n = int(input())
sp = [None]*n
for i in range(n):
    sp[i] = [input().split(" "), i+1]
sp = list(map(lambda x: [[x[0][0], int(x[0][1])], x[1]], sp))
sl = list(map(lambda x: x[0][0], sp))
sp2 = []
for s in sorted(list(set(sl))):
    l = list(filter(lambda x: x[0][0] == s, sp))
    sp2.extend(sorted(l, key=lambda x:x[0][1], reverse=True))
for x in sp2:
    print(x[1])


Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a,b,c,d,e,x,y;
	cin>>a>>b>>c>>d;
	e=a+b+c+d;
	x=e/60;
	y=e%60;
	cout<<x<<endl;
	cout<<y<<endl;
	return 0;
	}



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

typedef long long int ll;
typedef pair<int,int> pi;
priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

#define dodebug(i, n, arr)	for(int i=0;i<n;++i)	cout<<arr[i]<<" ("<<i<<")\n";

ll gcd(ll a,ll b){	if(b == 0)	return a;return gcd(b,a%b);}
ll binpow(ll n,ll x){	ll ans = 1;while(x){if(x & 1)	ans *= n;n *= n;x >>= 1;}return ans;}

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

	int n, cap;
	cin>>n>>cap;
	vector<ll> dp(int(1e5+1), 1e12);

	dp[0] = 0;
	ll w; int v;
	for(int i=0;i<n;++i){
		cin>>w>>v;
		for(int i=1e5;i-v>=0;--i)	dp[i] = min(dp[i], dp[i-v] + w);
	}

	int ans = 0;
	for(int i=1e5;i>=0;--i){
		if(dp[i] <= cap){
			// ans = i;
			cout<<i<<"\n";
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3956
#include <iostream> 
using namespace std;
int main(void)
{
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if (x - r<0 || x + r>w || y - r < 0 || y + r > h)cout << "No";
	else cout << "Yes";
	cout << endl;
}


Measured memory_bytes: 3104
package main

import (
	"bufio"
	"flag"
	"fmt"
	"os"
	"sort"
	"strconv"
	"testing"
)

/*-----------Main-----------*/

func main() {
	x, y := readI(), readI()
	var tsuru, kame int
	for tsuru <= x {
		kame = x - tsuru
		if y == tsuru*2+kame*4 {
			fmt.Println("Yes")
			return
		}
		tsuru++
	}
	fmt.Println("No")

}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	testing.Init()
	if flag.Parse(); flag.Arg(0) == "debug" {
		debug()
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Println("Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}


Measured memory_bytes: 1844
#include <bits/stdc++.h>
using namespace std;
 
#define  int    long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff         first
#define  ss    second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int32_t main()
{
    fast
    char c;
    cin>>c;
    if(c>='a')
        cout<<"a";
    else
        cout<<"A";
}

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

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

int main(){
  int n;
  cin>>n;
  vector<ll> v(n);
  ll sum = 0;
  rep(i,n) {
    cin>>v[i];
    sum+=v[i];
  }
  sort(v.begin(), v.end());
  int i = 0;

  rep(i,n) {
    if(sum %10 !=0 or sum == 0) break;
    if(v[i] % 10 !=0) {
      sum -= v[i];
      break;
    }
  }
  if(sum % 10 == 0)
    std::cout << 0 << std::endl;
  else
    std::cout << sum << std::endl;
  
  return 0;
}


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

namespace ABC_D
{
    class D058
    {
        static int _Mod = 1000000007;

        static void Main(string[] args)
        {
            int[] h = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
            int n = h[0], m = h[1];
            int[] x = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
            int[] y = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();

            long sumY = 0, sum = 0;
            for (int i = 1; i < m; i++)
            {
                long areaY = y[i] - y[i - 1];
                long cnty = (long)i * (m - i); cnty %= _Mod;
                sumY += areaY * cnty; sumY %= _Mod;
            }

            for(int j = 1; j < n; j++)
            {
                long cntx = (long)j * (n - j); cntx %= _Mod;
                long cut = sumY * (x[j] - x[j - 1]); cut %= _Mod;
                cut *=  cntx; cut %= _Mod;
                sum += cut; sum %= _Mod;
            }

            Console.WriteLine(sum);
        }

    }
}


Measured memory_bytes: 38344
#include <bits/stdc++.h>
using namespace std;
#define ll long int
int main() {
    
    int n;
    cin>>n;int k;
    ll ans=0;
    if(n%2==0){k=(n/2)-1;}
    else{k=((n+1)/2)-1;}
    for(int i=1;i<=k;i++){
        if(n%i==0)ans+=n/i-1;
        else{
            ans+=n/i;
        }
    }
    cout<<ans+n/2<<endl;
	return 0;
}


Measured memory_bytes: 3632
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll arr[25];

int main() {
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
	}
	ll cnt = 1;
	for(int i = 1; i < N; i++) {
		int flag = 1;
		for(int j = i - 1; j >= 0; j--) {
			if(arr[j] > arr[i]) {
				flag = 0;
				break;
			}
		}
		if(flag) {
			cnt++;
		}
	}
	printf("%lld\n", cnt);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;using std::queue;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;using std::swap;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::vector<int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}

namespace ndifix{
template<class T> void sort(T &v){std::sort(v.begin(),v.end());}
template<class T> void rsort(T &v){std::sort(v.rbegin(),v.rend());}
}

int main(){
  int l,r;cin>>l>>r;
  int ans=2019;
  for(int i=l;i<l+2020&&i<r;i++){
  for(int j=i+1;j<l+2020&&j<=r;j++){
    ans=min(ans,((i%2019)*(j%2019))%2019);
  }}
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int par[N],n,b[N],m;
long long sum[N],v[N];
vector<int>g[N];
vector<pair<int,int>>temp;
bool vis[N];
int get(int u){return par[u] == u ? u : par[u] = get(par[u]);}
int main(){
	//freopen("readin.txt","r",stdin);
	scanf("%d%d",&n,&m);
	for(int i = 0,a;i < n;i++){
		par[i] = i;
		scanf("%d%d",&a,b + i);
		temp.push_back({a - b[i],i});
	}
	for(int i = 0,a,b;i < m;i++){
		scanf("%d%d",&a,&b);
		g[--a].push_back(--b);
		g[b].push_back(a);
	}
	sort(temp.begin(),temp.end());
	for(auto i : temp){
		int need = max(0,i.first),at = i.second;
		sum[at] = b[at];
		v[at] = need;
		vis[at] = 1;
		for(auto j : g[at]){
			int from = get(j);
			if(from == at || !vis[from])continue;
			sum[at]+=sum[from];
			// if(sum[from] + v[from] >= need)v[at] = min(v[at],v[from]);
			// else v[at] = min(v[at],need - sum[from]);
			v[at] = min(v[at],max(v[from],need - sum[from]));
			par[from] = at;
		}
	}
	printf("%lld\n",sum[temp.back().second] + v[temp.back().second]);
}

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long

const int H = 1e4 + 5;
const int N = 1e3 + 5;

int dp[H];
int h, n;
int a[N], b[N];

int solve(int health) {
	if (health <= 0) return 0;
	int &ans = dp[health];
	if (ans != -1) return ans;
	ans = 1e9 + 7;
	for (int i = 1; i <= n; i++)
		ans = min(ans, solve(health - a[i]) + b[i]);
	return ans;
}
				
int32_t main() {
	fast_cin();  

	cin >> h >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i];
	memset(dp, -1, sizeof dp);
	int ans = solve(h);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#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, resolve
    int N;
    map<ll,ll> ans;
    cin >> N;
    for(int i=0; i<N; i++) {
        ll a;
        cin >> a;
        ans[a]++;
    }

    if (ans.size() == N) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 12800
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <map>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define MAX_N 105
int vx [4]= {1,0,-1,0};
int vy [4]= {0,1,0,-1};
long long  dp[MAX_N][21]={};//dp[iテァツ閉ェテァツ崢ョテ」ツ?セテ」ツ?ァテ」ツ?ォ][テ・ツ?、]テッツシツ敕・ツ?凝ヲツ閉ー
int V[MAX_N],W[MAX_N];
int data[MAX_N],B[MAX_N];
int K ,N,a[MAX_N];
using namespace std;
void init(){

  /*cin >> N;
  cin >> a[1];
    dp[1][a[1]]=1;
  for(int l= 2;l<=N-1;l++){
    cin >> a[l];
    for(int i= 0;i<=20;i++){
      if(i-a[l]>=0&&i-a[l]<=20) dp[l][i] += dp[l-1][i-a[l]];
      if(i+a[l]>=0&&i+a[l]<=20) dp[l][i] += dp[l-1][i+a[l]];
    }
      //REP(i,21)cout<<l<<':'<< i<<' '<<dp[l-1][i]<<endl;
  }
  //REP(i,21)cout<< i<<' '<<dp[N-1][i]<<endl;
  cin >> a[N];
  cout << dp[N-1][a[N]]<<endl;
  */
}
void solve(){
  init();

}
int main(){
    vector<int>h ;
    int t;
    REP(i,10)
    {cin >> t;
    h.push_back(t);
  }
  sort(h.begin(),h.end());
  reverse(h.begin(),h.end());
  REP(i,3)cout << h[i]<<endl;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using  namespace std;
int main(){
    long long n, a, first = -1, second = -1, ans = 0;
    cin >> n;
    map<long long, long long> A;
    for(long long i=0;i<n;i++){
        cin >> a;
        A[a]++;
    }
    for(auto itr=A.begin();itr!=A.end();itr++){
        if(itr->second >1){
            if(first < itr->first){
              	second = first;
                first = itr->first;
                if(itr->second > 3){
                    if(second < itr->first){
                        second = itr->first;
                    }
                }
            }else if(second < itr->first){
                second = itr->first;
            }
        }
    }
    if(first != -1 && second != -1){
        ans = first * second;
    }
    
    cout << ans << endl;
    return 0;
}


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> void chmax(T& a,const T& b){if(a < b) a = b;}
template<typename T> void chmin(T& a,const T& b){if(b < a) a = b;}
typedef long long ll;

int T;

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

	cin >> T;
	FOR(i,0,T){
		int N,D;
		cin >> N >> D;
		cout << (N - 1) * 127 + (N % 2 ? D : 127 - D) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
def s(x):
	return sum(map(int,list(str(x))))

a = []

K = int(input())

l = 0
cnt = 0
while cnt<K*50:
	for i in range(1,K+1):
		x = int(str(i)+'9'*l)
		y = int(str(i+1)+'9'*l)
		if x*s(y) > y*s(x):
			break
		a.append(x)
		cnt += 1
	l += 1
	
ans = sorted(set(a))[:K]
print('\n'.join(map(str,ans)))


Measured memory_bytes: 8148
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>

#define Range(_index, _begin,_end) for(int _index=_begin;i<_end;_index++)
#define Loop(_idx, _ini, _end) for(int _idx=_ini;_idx<_end;_idx++)
#define Loop0(_idx, _end) Loop(_idx,0,_end)
#define ForEach(_elem,_array) for(const auto& _elem : _array)

const int Num = 100001;

int main() {
    int N, Q;
    std::cin >> N >> Q;
    char S[Num];
    std::cin >> S;

    try {
    std::vector<int> Temp(N + 1, 0);
    Loop0(i, N) {
        Temp[i + 1] = Temp[i] + ((S[i] == 'A' && S[i + 1] == 'C') ? 1 : 0);
    }

    Loop0(_, Q) {
        int l, r;
        std::cin >> l >> r;
        std::cout << Temp[r-1] - Temp[l-1] << std::endl;
    }
    }
    catch(const std::exception& e) {
        std::cout << "hoge" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1280
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
    char f[8][8];
    int x,y,i,j;
    while(1)
    {
        x=y=-1;
        for(i=0;i<8;i++)cin >> f[i];
        if(cin.eof())break;
        for(x=0;x<8;x++)
        {
            for(y=0;y<8;y++)
            {
                if(f[x][y]=='1')
                {
                    i=x;
                    j=y;
                    break;
                }
            }
            if(i==x&&j==y)break;
        }
        if(i<7&&j<7&&f[i+1][j]=='1'&&f[i][j+1]=='1'&&f[i+1][j+1]=='1')printf("A\n");
        else if(i<5&&f[i+3][j]=='1')printf("B\n");
        else if(j<5&&f[i][j+3]=='1')printf("C\n");
        else if(i<6&&j>0&&f[i+2][j-1]=='1')printf("D\n");
        else if(i<7&&j<6&&f[i+1][j+2]=='1')printf("E\n");
        else if(i<6&&j<7&&f[i+2][j+1]=='1')printf("F\n");
        else if(i<7&&j<7&&j>0&&f[i][j+1]=='1'&&f[i+1][j-1]=='1')printf("G\n");
    }
    return 0;
}

Measured memory_bytes: 3008
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		int A,B,C,K;
		A=sc.nextInt();
		B=sc.nextInt();
		C=sc.nextInt();
		K=sc.nextInt();
		int sum=A;
		if(A>=K) {
			sum = K;
		}
		else if(A+B>=K) {
			sum=A;
		}else {
			sum=A-(K-A-B);
		}
		System.out.println(sum);
		
	}
}
 
 
 

Measured memory_bytes: 27040
n, k = map(int, input().split())
s = input()

a = []

i = 0
while i < n:
    j = 1
    while i + j < n and s[i] == s[i + j]:
        j += 1
    a.append((s[i], j))
    i += j
if a[0][0] == '0':
    a = [('1', 0)] + a
if a[-1][0] == '1':
    a.append(('0', 0))

while len(a) < k * 2:
    a.append(('1', 0))
    a.append(('0', 0))
m = len(a)


s = [0] * (m + k * 5 + 1)
for i in range(m + k * 2):
    if i < m:
        s[i + 1] = s[i] + a[i][1]
    else:
        s[i + 1] = s[i]
ans = 0
for i in range(1, m, 2):
    ans = max(ans, s[i + k * 2] - s[i - 1])
print(ans)


Measured memory_bytes: 22424
aa = int(input()) + 1
bb = int(input()) + 1
cc = int(input()) + 1
x = int(input())
count = 0

for a in range(aa):
  for b in range(bb):
    for c in range(cc):
      if 500*a + 100*b + 50*c == x:
        count+=1
print(count)


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
int a,b,c,d,f;
while(1){
	scanf("%d %d",&a,&b);
	if(a==0&&b==0)break;
	for(c=0;c<a;c++){
		for(d=0;d<b;d++){
			f=c+d;
			if(f%2==0){
				printf("#");
			}else{
				printf(".");
			}
		}
		printf("\n");
	}
printf("\n");
}
return 0;
}


Measured memory_bytes: 2040
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
//const int inf = 1000000000; //10^9
//const ll MX = 1e18; //1(1倍)e(指数)18(10^18)
//const ll MOD = 1e9 + 7;
//加算代入演算子は+=
//int 2^31 10^9まで
//intは10桁、long longは18桁、doubleは308桁、long double は4932桁
//10^10くらいまででdoubleは誤差が発生しちゃう。なるべく整数にすること
//doubleからlong longにキャストするときは、+0.5で切り捨ての誤差を調整
//__int128()で128bit対応の整数（多倍長整数）
//||は片方が成り立つとき
int main()
{
    ll a; double b;
    cin >> a >> b;
    int temp_b = b * 100 + 0.5;
    ll ans = 0;
    ans = a * temp_b;
    ans /= 100;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3720
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl



signed main() {

	int D, G;
	cin >> D >> G;
	int p[10], c[10];
	rep(i, D) cin >> p[i] >> c[i];

	int ans = INF;
	rep(n, 1LL << D) {

		int s = 0, ma = 0, maix=-1, kosu=0;
		rep(i, D) {
			if (n & (1LL << i)) {
				s += 100 * (i+1) * p[i] + c[i];
				kosu += p[i];
			}
			else {
				maix = max(maix,i);
			}
		}
		if (s < G) {
			int s1 = 100 * (maix + 1);
			int need = (G - s+(s1-1)) / s1;
			if (need >= p[maix]) {
				continue;
			}
			kosu += need;
		}
		ans = min(ans, kosu);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int l;
    int r;
    int d;
    cin >> l >> r >> d;
    int count = 0;
    for(int i = 0; i <= r; i++){
        if(l <= i && r >= i){
            if(i % d == 0){
                count++;
            }
        }
        else{
            continue;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3568
use proconio::marker::Usize1;
fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        m: usize,
        mut hw: [(Usize1,Usize1);m],
    }
    hw.sort_unstable();
    let mut ch=vec![0;h];
    let mut cw=vec![0;w];
    let mut mh=0;
    let mut mw=0;
    for &(h,w) in &hw {
        ch[h]+=1;
        mh=mh.max(ch[h]);
        cw[w]+=1;
        mw=mw.max(cw[w]);
    }
    let mut hs=vec![];
    for (i,v) in ch.into_iter().enumerate() {
        if v==mh {
            hs.push(i);
        }
    }
    let mut ws=vec![];
    for (i,v) in cw.into_iter().enumerate() {
        if v==mw {
            ws.push(i);
        }
    }
    for i in hs {
        for &j in &ws {
            if let Err(_)=hw.binary_search(&(i,j)) {
                println!("{}",mh+mw);
                return;
            }
        }
    }
    println!("{}",mh+mw-1);
}


Measured memory_bytes: 17468
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		new Main().solveC();
		// new Main().solveD();
		//		new Main().solveE();
		//		new Main().solveF();
	}

	private void solveA() {
		Scanner scanner = null;
		int numN = 0;
		int numA = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			numA = scanner.nextInt();

			int res = numN % 500;

			System.out.println(res <= numA ? "Yes" : "No");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			int[] wk = new int[numN];
			for (int i = 0; i < wk.length; i++) {
				wk[i] = scanner.nextInt();
			}

			Arrays.sort(wk);

			int alice = 0;
			int bob = 0;
			boolean convert = true;
			for (int i = wk.length - 1; i >= 0; i--) {
				if (convert) {
					alice += wk[i];
				} else {
					bob += wk[i];
				}
				convert = !convert;
			}

			System.out.println(alice - bob);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private boolean chkC(int[][] wk, int max, int currentA, int[] aA, int[] bA) {
		if (currentA > max) {
			return false;
		}

		aA[0] = currentA;
		for (int j = 0; j < bA.length; j++) {
			bA[j] = wk[0][j] - currentA;
		}
		for (int i = 0; i < aA.length; i++) {
			aA[i] = wk[i][0] - bA[0];
		}
		boolean isMatch = true;
		outside: for (int i = 0; i < bA.length; i++) {
			for (int j = 0; j < bA.length; j++) {
				isMatch = wk[i][j] == aA[i] + bA[j];
				if (!isMatch) {
					break outside;
				}
			}
		}
		return isMatch ? true : chkC(wk, max, currentA + 1, aA, bA);
	}

	private void solveC() {
		Scanner scanner = null;

		try {
			scanner = new Scanner(System.in);

			int[][] wk = new int[3][3];
			int[] aA = new int[3];
			int[] bA = new int[3];

			int max = 0;
			for (int i = 0; i < wk.length; i++) {
				for (int j = 0; j < wk[i].length; j++) {
					wk[i][j] = scanner.nextInt();
					max = Math.max(max, wk[i][j]);
				}
			}

			System.out.println(chkC(wk, max, 0, aA, bA) ? "Yes" : "No");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveE() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveF() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

int main(void){
    int N, x = 0, y = 0, t = 0;
    std::string ans = "Yes";
    std::cin >> N;
    for (int i = 0; i < N; ++i){
        int nt, nx, ny, d;
        std::cin >> nt >> nx >> ny;
        d = std::abs(x - nx) + std::abs(y - ny);
        if (d > nt - t or (nt - t - d) % 2 != 0){
            ans = "No";
            break;
        }
        t = nt;
        x = nx;
        y = ny;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>

int main(int argc, char **argv)
{
    int n;
    int c[21];
    int v[21];

    std::cin >> n;
    for (int i = 0; i < n; i++) std::cin >> v[i];
    for (int i = 0; i < n; i++) std::cin >> c[i];
    int s = 0;
    for (int i = 0; i < n; i++) if (v[i] > c[i]) s += v[i] - c[i];

    std::cout << s << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define NUM 10
void bsort(int a[], int n)
{
	int i, j;
	
	for (i = 0; i < n - 1; i++) {
		for ( j = n - 1; j > i; j--) {
			if (a[j - 1] < a[j]) {
				int temp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = temp;
			}
		}
	}
}
int main(void)
{
	int i,height[NUM];
	
	for(i=0;i<NUM;i++){
		scanf("%d",&height[i]);
	}
	
	bsort(height,NUM);
	
	for(i=0;i<3;i++){
		printf("%d\n",height[i]);
	}
	return 0;
}

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

int main(){
  string a,b,c;
  int d;
  cin >> a >> b;
  c = a+b;

  d=stoi(c);
  
  for(int i=0;i<1000;i++){
    if(i*i == d){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
N, A, B = list(map(int, input().split()))
S = input()

an = 0  # 今までaが何人いたか
bn = 0  # 今までbが何人いたか
an2 = 0 # 今ままでaの合格者が〜
bn2 = 0

for si in S:
    if si == 'c':
        print('No')
    elif si == 'a':
        if an2 + bn2 < A + B:
            print('Yes')
            an2 += 1
        else:
            print('No')
        an += 1
    else:
        if an2 + bn2 < A + B and bn + 1 <= B:
            print('Yes')
            bn2 += 1
        else:
            print('No')
        bn += 1

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#include <algorithm>
// #include <atcoder/all>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>
using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i, m, n) for (ll(i) = (ll)(m); i < (ll)(n); ++i)
#define REP2(i, m, n) for (ll(i) = (ll)(n)-1; i >= (ll)(m); --i)
#define rep(i, n) REP(i, 0, n)
#define rep2(i, n) REP2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define rall(hoge) (hoge).rbegin(), (hoge).rend()
#define en '\n'
using Edge = pair<ll, ll>;
using Graph = vector<vector<Edge>>;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
template <class T> inline void print(T x) { cout << x << '\n'; }
template <class T> bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
// ~~~~~~~~~~~~~~memo~~~~~~~~~~~~~~
// for (int i = 0; i < n; ++i)
// cout << res << endl;
// cout << res << '\n';
// int型の2次元配列(h×w要素の)の宣言
// vector<vector<int>> data(h, vector<int>(w));
// rotate(s.begin(), s.begin() + 1, s.end());
// sort(all(a),greater<int>());
// s.substr(0,2) 先頭から2文字切り出す
// for (auto it = mp.rbegin();it != mp.rend(); ++it)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = c - a, y = d - b;
    printf("%d %d %d %d\n", c - y, d + x, a - y, b + x);
    return 0;
}


Measured memory_bytes: 3716
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

#define ll long long

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int n = 5;
int k;

vector<int> a(n);

void input() {
  for (auto&& i : a)
    cin >> i;

  cin >> k;
}

void solve1() {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j)
        continue;

      if (abs(a[i] - a[j]) > k) {
        cout << ":(";

        exit(0);
      }
    }
  }

  cout << "Yay!";
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve1();
}


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

using u64 = std::uint64_t;
constexpr u64 inf = std::numeric_limits<u64>::max();

#define REP(i, n) for (u64 i = 0; i < (n); ++i)

namespace io {
  constexpr int is = 1 << 17;
  char ib[is], *ip = ib + is, it;
  inline char getc() {
    if (ip == ib + is) { read(STDIN_FILENO, ib, is); ip = ib; }
    return *ip++;
  }
  inline u64 scan() {
    u64 r = 0;
    if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
    else while ((it = *ip++) & 16) r = r * 10 + it - '0';
    return r;
  }
  constexpr int os = 1 << 17;
  char ob[os], *op = ob, ot;
  inline void putc(const char c) {
    *op++ = c;
    if (op == ob + os) { write(STDOUT_FILENO, ob, os); op = ob; }
  }
  /* x shoud be greater than or equal to zero */
  inline void print(u64 x) {
    char d[20];
    int i = 0;
    while (true) {
      d[i] = x % 10 + 48;
      x /= 10;
      ++i;
      if (x <= 0) break;
    }
    while (i--) {
      putc(d[i]);
    }
  }
  inline void flush() {
    write(STDOUT_FILENO, ob, op - ob);
  }
}

u64 collect(const vector<vector<u64>> &G, const vector<u64> &H, u64 u, u64 v, u64 p) {
  if (u == v) return 0;
  for (auto e : G[u]) {
    u64 t = H[e] ^ u;
    if (t == p) continue;
    u64 s = collect(G, H, t, v, u);
    if (s != inf) {
      return s | (1ULL << e);
    }
  }
  return inf;
}

u64 search(u64 ans, u64 j, u64 m, u64 mask, vector<u64> &paths) {
  if (j != m) {
    return (
      search(ans, j + 1, m, mask, paths)
    - search(ans, j + 1, m, mask | paths[j], paths)
    );
  } else {
    return ans >> __builtin_popcountl(mask);
  }
}

signed main() {
  u64 n = io::scan();
  auto G = vector<vector<u64>>(n);
  auto H = vector<u64>(n);
  REP(i, n - 1) {
    u64 a = io::scan() - 1;
    u64 b = io::scan() - 1;
    G[a].push_back(i);
    G[b].push_back(i);
    H[i] = a ^ b;
  }
  u64 m = io::scan();
  auto paths = vector<u64>(m);
  REP(j, m) {
    u64 u = io::scan() - 1;
    u64 v = io::scan() - 1;
    paths[j] = collect(G, H, u, v, -1);
  }
  u64 ans = search(1ULL << (n - 1), 0, m, 0, paths);
  io::print(ans);
  io::flush();
}


Measured memory_bytes: 384