akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int l, r, a, b, c, d;
  cin >> a >> b >> c >> d;
  l = a + b;
  r = c + d;
  if(l < r){
    cout << "Right" << endl;
  }else if(l > r){
    cout << "Left" << endl;
  }else{
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#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() {
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll ans;
    if (x/d >= k) {
        ans = x - k*d;
        cout << ans << endl;
        return 0;
    }
    if ((k-x/d)%2 == 0) {
        ans = x - d*(x/d);
        cout << ans << endl;
        return 0;
    }
    else {
        ans = abs(x - d*(x/d) - d);
        cout << ans << endl;
    }
    return 0;
}

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

const int mod=1000000007;

ll fast_pw(ll x, ll y) {
    ll sol=1;
    while(y>0) {
        if (y%2==1) sol=(sol*x)%mod;
        y/=2;
        x=(x*x)%mod;
    }
    return sol;
}

ll dp[100005];

int main() {
    int n,k;
    ll sol=0;
    cin >> n >> k;
    for (int i=k;i>=1;i--) {
        dp[i]=fast_pw(k/i,n);
        for (int j=i*2;j<=k;j+=i) {
            dp[i]=(dp[i]-dp[j]+mod)%mod;
        }
    }
    for (int i=1;i<=k;i++) sol=(sol+i*dp[i])%mod;
    cout << sol;
}



Measured memory_bytes: 4308
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define push_back pb
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	vector<ll> A(N),B(N),C(N);
	rep(i,N)cin>>A[i];
	rep(i,N)cin>>B[i];
	rep(i,N)cin>>C[i];
	sort(all(A));
	sort(all(B));
	sort(all(C));
	ll ans = 0;
	rep(i,N){
		ll a = lower_bound(all(A),B[i]) - A.begin();
		ll c = N - (upper_bound(all(C),B[i])-C.begin());
		ans += a*c;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            long A = in.nextLong();
            long B = in.nextLong();
            long K = in.nextLong();

            long K2 = Math.max(0, K - A);
            A = Math.max(0, A - K);
            B = Math.max(0, B - K2);
            out.println(A + " " + B);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 21460
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

int powM(int x, int n){
    if(n == 0){
        return 1;
    }
    if(n % 2 == 0){
        return powM(x * x % MOD, n / 2);
    }
    return powM(x, n-1) * x % MOD;
}

int factM(int n){
    static vector<int> t = {1};

    if((int)t.size() > n){
        return t[n];
    }

    for(int i = t.size(); i <= n; i++){
        t.push_back(t[i-1] * i % MOD);
    }
    return t[n];
}

class Combination{
    private:
        vector<int> t;

    public:
        Combination(int n): t(n+1){
            t[n] = powM(factM(n), MOD-2);

            for(int i = n-1; i >= 0; i--){
                t[i] = t[i+1] * (i+1) % MOD;
            }
        }

        int comb(int n, int k){
            if(n < k || n < 0 || k < 0){
                return 0;
            }
            return factM(n) * t[k] % MOD * t[n-k] % MOD;
        }

        int getInv(int n){
            return t[n];
        }
};

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

    int n, m, k;
    cin >> n >> m >> k;
    if(n < m){
        swap(n, m);
    }

    Combination c(200000);
    int p = c.comb(n * m - 2, k - 2);

    int ans = 0;
    for(int i = 1; i < n; i++){
        ans += i * m % MOD * m % MOD * (n - i) % MOD * p % MOD;
        ans %= MOD;
    }
    for(int i = 1; i < m; i++){
        ans += i * n % MOD * n % MOD * (m - i) % MOD * p % MOD;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3956
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef char keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

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

const int inf = 1012345678;
int main(){
    char c[4][4];

    for(int i = 0; i < 3; ++i){
        scanf("%s", c[i]);
    }

    //printf("%s", c[0]);

    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 3; ++j){
            if(i == j){
                printf("%c", c[i][j]);
            }
        }
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 1604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		new Main().start();
	}
	void start(){
		Scanner in = new Scanner(System.in);
		int m = in.nextInt();
		for(int i = 0; i < m; i++){
			int syoki = in.nextInt();
			int nensu = in.nextInt();
			int n = in.nextInt();
			int max = 0;
			for(int j = 0; j < n; j++){
				int isHukuri = in.nextInt();
				double nenriRate = in.nextDouble();
				int tesuryo = in.nextInt();

				int a = syoki;
				int totalB = 0;
				for(int k = 0; k < nensu; k++){
					if(isHukuri == 1){
						a += (int)(a * nenriRate);
						a -= tesuryo;
					}else{
						totalB += (int)(a*nenriRate);
						a -= tesuryo;
					}
				}
				int total = a + totalB;
				if(max < total) max =total;
			}
			System.out.println(max);
		}
		in.close();
	}

}

Measured memory_bytes: 55492
program j01;
var f:array[0..1000000]of longint;
     n,m,u,v,i:longint;
begin
  readln(n,m);
  for i:=1 to m do
  begin
     readln(u,v);inc(f[u]);inc(f[v]);
  end;
for i:=1 to n do 
if f[i] mod 2=1 then
begin
 writeln('NO');halt;end;
writeln('YES');
end.

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    long long n,count,sum,next;
    scanf("%lld",&n);
    if (n==0){
        printf("0\n");
        return 0;
    } else if (n>0) {
        sum=1;
        count=0;
        next=1;
         while(sum<n){
             next*=4;
             sum+=next;
             count+=2;
        }
    } else {
        sum=-2;
        count=1;
        next=-2;
         while(sum>n){
             next*=4;
             sum+=next;
             count+=2;
        }
    }
    bool p[50];
    next=2;
    sum=1;
    for (int i=0; i<=count; i++){
        if (n%next==0){
            p[i]=false;
        } else {
            p[i]=true;
            n-=sum;
        }
        next*=2;
        sum*=-2;
    }
    for (int i=count; i>=0; i--){
        if (p[i]==true){
            printf("1");
        } else {
            printf("0");
        }
    }
    
    
    printf("\n");
    
	return 0 ;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
    int t,n,i,j,k,l;
    string s;
    cin>>s;
    n=s.size();
    if(s[n-1]=='s')
     cout<<s<<"es";
    else cout<<s<<"s";
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(V) (V).begin(), (V).end() 
#define x first
#define y second

using namespace std;
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}


using namespace std;

typedef long long ll;
template <typename T> using V = vector <T>;

const ll mod = 1e9 + 7;
const int MM = 1e4 + 5, KM = 105;

inline int add(int a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  return a;
}

inline int sub(int a, int b) {
  a -= b;
  if (a < 0) a += mod;
  return a;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % mod);
}

V <V <ll>> dp(MM, V <ll> (KM, 0));
int K;
void pre() {
	dp[0][0] = 1;
	for(int dig = 1; dig < MM; dig++) {
		for(int cd = 0; cd <= 9; cd++) {
			for(int rem = 0; rem < K; rem++) {
				dp[dig][rem] = add(dp[dig][rem], dp[dig - 1][(rem - cd + 10 * K) % K]);
			}
		}
	}
}
ll ansFor(V <int> &N, int ind, ll rem) {
	if(ind == -1) {
		return rem == 0;
	}
	ll cnt0 = 0;
	for(int d = 0; d < N[ind]; d++) {
		cnt0 = add(cnt0, dp[ind][(-rem - d + 10 * K) % K]);
	}
	ll cnt1 = ansFor(N, ind - 1, (rem + N[ind]) % K);
	return add(cnt0, cnt1);
}

int main() {fio;
	string N;
	cin >> N >> K;
	pre();
	V <int> num(N.size());
	for(int i = 0; i < N.size(); i++) {
		num[N.size() - i - 1] = N[i] - '0';
	}
	cout << sub(ansFor(num, N.size() - 1, 0), 1) % mod;
    return 0;
}

Measured memory_bytes: 9088
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#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;
using namespace std;

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<pair<int,int> > save(n-1);
    vector<set<int> > g(n);
    int i;
    for(i=0; i<n-1; i++) {
        int a,b;
        scanf("%d%d", &a, &b);
        g[a-1].insert(b-1);
        g[b-1].insert(a-1);
        save[i]=make_pair(a-1,b-1);
    }
    vector<int> c(n);
    for(i=0; i<n; i++) {
        scanf("%d", &c[i]);
    }
    sort(c.begin(), c.end());

    set<pair<int,int> > z;   // val, id
    vector<int> cnt(n);
    for(i=0; i<n; i++) {
        cnt[i]=(int)g[i].size();
        z.insert(make_pair(cnt[i],i));
    }

    vector<int> ans(n);
    int cnt_ans=0;
    while(!z.empty()) {
        auto it0 = z.begin();
        int val = it0->first;
        int k   = it0->second;
        ans[k]=c[cnt_ans];
        cnt_ans++;

        auto it=g[k].begin();
        for(; it!=g[k].end(); ++it) {
            int tmp=(*it);

            z.erase(make_pair(cnt[tmp],tmp));
            g[tmp].erase(k);
            cnt[tmp]--;
            z.insert(make_pair(cnt[tmp],tmp));
        }
        z.erase(*it0);
    }

    ll pnt=0;
    for(i=0; i<n-1; i++) {
        int ii = save[i].first;
        int jj = save[i].second;
        pnt += MIN(ans[ii],ans[jj]);
    }

    printf("%lld\n", pnt);
    for(i=0; i<n; i++) {
        printf("%d ", ans[i]);
    }
    printf("\n");

    return 0;
}


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

int main() {
    long long N; cin >> N;
    vector<long long> A(5);
    long long mi = 1LL<<60;
    for (int i = 0; i < 5; ++i) cin >> A[i], mi = min(mi, A[i]);
    cout << (N + mi - 1) / mi + 4 << endl;
}

Measured memory_bytes: 256
class Dice:
    def __init__(self, lst):
        self.a = lst[0]
        self.b = lst[1]
        self.c = lst[2]
        self.d = lst[3]
        self.e = lst[4]
        self.f = lst[5]
        
    def roll(self, orders):
        for order in orders:
            if order=='W':
                tmp = self.a
                self.a = self.c
                self.c = self.f
                self.f = self.d
                self.d = tmp
            elif order=='E':
                tmp = self.a
                self.a = self.d
                self.d = self.f
                self.f = self.c
                self.c = tmp
            elif order=='S':
                tmp = self.a
                self.a = self.e
                self.e = self.f
                self.f = self.b
                self.b = tmp
            elif order=='N':
                tmp = self.a
                self.a = self.b
                self.b = self.f
                self.f = self.e
                self.e = tmp
#             print(self.a, self.b, self.c, self.d, self.e, self.f)
#         print(self.a)
    
    def equal(self, dice_):
        if (self.a==dice_.a and
            self.b==dice_.b and
            self.c==dice_.c and
            self.d==dice_.d and
            self.e==dice_.e and
            self.f==dice_.f
           ):
            return True
        else:
            return False
       
            
import random
import itertools
if __name__ == '__main__':
    n = int(input())
    lsts = [[int(x) for x in input().split()] for _ in range(n)]
    ans = 'Yes'
    for lst in itertools.combinations(lsts, 2):
        dice1 = Dice(lst[0])
        dice2 = Dice(lst[1])
        for direction in 'EEENEEENEEESEEESEEENEEEN':
            if dice1.equal(dice2):
                ans='No'
                break
            else:
                dice1.roll(direction)
    print(ans)


Measured memory_bytes: 8256
/*
 * a.c
 *
 *  Created on: 2017/06/13
 *      Author: AWV060608
 */

#include	<stdio.h>
#include	<math.h>

#define		MXNMB		1000+5

int		main(void)
{
	int		n;
	int		i;
	int		xi[MXNMB], yi[MXNMB];
	double	dst, tmp;

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

	dst = 0;
	for(i=0; i<n; i++)
	{
		dst = abs(xi[i] - yi[i]) + dst;
	}
	printf("%f\n",dst);

	dst = 0;
	for(i=0; i<n; i++)
	{
		tmp = pow(abs(xi[i] - yi[i]),2) + tmp;
	}
	dst = sqrt(tmp);
	printf("%f\n",dst);

	dst = 0;
	tmp = 0;
	for(i=0; i<n; i++)
	{
		tmp = pow(abs(xi[i] - yi[i]),3) + tmp;
	}
	dst = cbrt(tmp);
	printf("%f\n",dst);

	dst = 0;
	for(i=0; i<n; i++)
	{
		if( dst < abs(xi[i] - yi[i]))
		{
			dst = abs(xi[i] - yi[i]);
		}
	}
	printf("%f\n",dst);

	return 0;
}

Measured memory_bytes: 716
#include<iostream>

using namespace std;

int main (){
	int n;
	int moun[n+10];
	int i,j;
	int temp;
	
	cin >> n;
	
	for (i=0; i<n; i++){
		cin >> temp;
		moun[i] = temp;
	}
	int cnt = 0;
	int flag = 0;
	
	for(i=1; i < n; i++){
		flag = 0;
		for(j=0; j<i; j++){
			if (moun[i] < moun[j]) {
				flag = 1;
				break;
			}
		}
		if(flag == 0) cnt++;
	}

	cout << cnt+1 <<endl;

	return 0;
} 

Measured memory_bytes: 256
import bisect

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

S = [A[0]]
for i in range(1,N):
    S.append(S[i-1]+A[i])

ans = 1e18
for i in range(2, N-1):
    # 左側 [0,i)
    left_sum = S[i-1]
    m = bisect.bisect(S, left_sum/2)

    L = [S[m], left_sum-S[m]]

    if m != 0:
        L2 = [S[m-1], left_sum - S[m-1]]
        if(abs(L[0]-L[1]) > abs(L2[0]-L2[1])): L = L2

    # 右側 [i,N)
    m = bisect.bisect(S, (S[-1]+left_sum)/2)
    R = [S[m]-left_sum, S[-1]-S[m]]

    if m != i:
        R2 = [S[m-1]-left_sum, S[-1]-S[m-1]]
        if(abs(R[0]-R[1]) > abs(R2[0]-R2[1])): R = R2


    ans = min(ans, max(L[0],L[1],R[0],R[1]) - min(L[0],L[1],R[0],R[1]))

print(ans)


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

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

int main(void) {
    string s;
    int cnt = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    REP(i, s.length()) {
        if (s[i] == 'A') {
            cnt++;
        }
    }

    cout << (cnt == 0 || cnt == 3? "No" : "Yes") << "\n";
    return 0;
}

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

using namespace std;

int c[3][3];
int i,j;
bool flag = false;

int main(){

  for (i=0; i<3; i++){
    for (j=0; j<3; j++){
        cin >> c[i][j];
      }
  }

  int a[3],b[3];
  a[0]=0;
  b[0]=c[0][0];
  b[1]=c[0][1];
  b[2]=c[0][2];
  a[1]=c[1][0] - b[0];
  a[2]=c[2][0] - b[0];

  if ( c[1][1] == a[1] +b[1] ){
    if ( c[1][2] == a[1] + b[2]){
      if ( c[2][1] == a[2] + b[1]){
        if ( c[2][2] == a[2] + b[2]){
                flag = true;
        }
      }
    }
  }

  if (flag){
    cout << "Yes" << endl;
  }else{
    cout <<  "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<iterator>
#include<algorithm>
#include<bitset>

#define Filein(N) freopen("N", "r", stdin);
#define Fileout(N) freopen("N", "w", stdout);
#define sci(x) scanf("%d", &x)
#define sci2(x,y) scanf("%d%d", &x,&y)
#define scll2(x,y) scanf("%lld%lld",&x,&y)
#define scll(x) scanf("%lld",&x)
#define scd(x) scanf("%lf", &x)
#define scstr(x) scanf("%s", x)
#define pfi(x) printf("%d", x)
#define pfll(x) printf("%lld", x)
#define pfd(x) printf("%f", x)
#define pfstr(x) printf("%s", x)
#define ps printf(" ")
#define pn printf("\n")
#define pfdt printf("..")

#define For(i,a,n) for(int i=a; i<=n;i++)
#define rFor(i,n,a) for(int i=n; i>=a; i--)
#define TestCase int testcase, cs=1; cin>>testcase;while(testcase--)

#define mkp make_pair
#define pb push_back
#define ff first
#define ss second

#define px(x) cout<<"X -> "<<x<<endl;
#define py(x) cout<<"Y = "<<x<<endl;
#define pz(x) cout<<"Z >> "<<x<<endl;
#define pstr(x) printf("%s\n",x);

using namespace std;
using ll = long long;
using vi = vector <int>;
using mpii = map<int,int>;
using si = set<int>;
using sll = set<ll>;
using vll= vector<ll>;

#define INF 1000000000
#define LINF 4000000000000000000
#define pi  (2*acos(0))
#define Mod 1000000007

 int main(){

  int n,m,p;
  sci2(m,n);
  si st;
  For(i,1,n){
  sci(p);
  st.insert(p);
  }

  if(!st.count(m)){
    pfi(m);
    return 0;
  }
 p = m;
  while(1){
    p--;
    if(!st.count(p)){
        pfi(p);
        return 0;
    }
    m++;
    if(!st.count(m)){
        pfi(m);
        return 0;
    }

  }





    return 0;
}







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

int main()
{
  int n,i,j,u,k,v;
  int G[105][105];

  scanf("%d",&n);
  if(n<1 || n>100) exit(1);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++)
      G[i][j] = 0;
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      G[u-1][v-1] = 1; //0オリジン
    }
  }

    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	printf("%d",G[i][j]);
	if(j != n-1) printf(" ");
      }
      printf("\n");
    }
  
  return 0;

}




Measured memory_bytes: 2068
/*
Êý¾Ý²»Çå¿Õ£¬±¬ÁãÁ½ÐÐÀá¡£
¶à²â²»¶ÁÍê£¬±¬ÁãÁ½ÐÐÀá¡£
±ß½ç²»ÌØÅÐ£¬±¬ÁãÁ½ÐÐÀá¡£
Ì°ÐÄ²»Ö¤Ã÷£¬±¬ÁãÁ½ÐÐÀá¡£
D P Ë³Ðò´í£¬±¬ÁãÁ½ÐÐÀá¡£
´óÐ¡ÉÙµÈºÅ£¬±¬ÁãÁ½ÐÐÀá¡£
±äÁ¿²»Í³Ò»£¬±¬ÁãÁ½ÐÐÀá¡£
Ô½½ç²»ÅÐ¶Ï£¬±¬ÁãÁ½ÐÐÀá¡£
µ÷ÊÔ²»×¢ÊÍ£¬±¬ÁãÁ½ÐÐÀá¡£
Òç³ö²» l l£¬±¬ÁãÁ½ÐÐÀá¡£
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int n=read(),m=read();
pair<int,int> a[100005];
int key[100005],sta[100005];
struct dsu{
	int f[100005];
	inline int find(int x){
		return(f[x]==x)?x:f[x]=find(f[x]);
	}
	inline bool merge(int x,int y){
		int fx=find(x),fy=find(y);
		if(fx==fy)	return 0;
		f[fx]=fy;return 1;
	}
} ufs;
vector<pair<int,int> > g[100005];
vector<int> v;
bool vis[100005];
inline bool dfs(int x,int fa){
	bool ans=sta[x];vis[x]=1;
	for(int i=0;i<g[x].size();i++){
		int y=g[x][i].fi,ind=g[x][i].se;
		if(y==fa)	continue;
		bool t=dfs(y,x);
		if(t)	v.push_back(ind);
		ans^=t;
	}
	return ans;
}
signed main(){
	fz(i,1,n)	a[i].fi=read(),a[i].se=read();
	fz(i,1,n+1)	ufs.f[i]=i;
	sort(a+1,a+n+1);
	fz(i,1,n)	key[i]=a[i].fi,sta[i]=a[i].se;
	fd(i,n,1)	sta[i]^=sta[i-1];
	fz(i,1,m){
		int l=read(),r=read();
		l=lower_bound(key+1,key+n+1,l)-key;
		r=upper_bound(key+1,key+n+1,r)-key;
		if(ufs.merge(l,r))	g[l].push_back({r,i}),g[r].push_back({l,i});
	}
	dfs(n+1,-1);
	fz(i,1,n){
		if(!vis[i]){
			bool t=dfs(i,-1);
			if(t)	return puts("-1"),0;
		}
	}
	sort(v.begin(),v.end());cout<<v.size()<<endl;
	foreach(it,v)	cout<<*it<<" ";
	return 0;
}

Measured memory_bytes: 8956
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int main() {
	int n = read;
	double d = int(read), x = int(read);
	double ans = 0;

	while(n) {
		ans += d + (n * 2 - 1) * x / 2;
		/* debug("+%lf %lf %lf\n", d + (n * 2 - 1) * x / 2, d, x); */
		d = (n + 1) * d / n + 2.5 * x / n;
		x *= (n + 2.0) / n;
		-- n;
	}

	printf("%.10lf\n", ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod

ll Solve(){
    ll N; cin>>N;
    string S; cin>>S;
    ll L=0, R=N-1;
    rep(i,N+10){
        if(L>=R) return i;
        while(true){
            if(L==N) break;
            if(S[L]=='W') break;
            L++;
        }
        while(true){
            if(R==0) break;
            if(S[R]=='R') break;
            R--;
        }
        if(L>=R) return i;
        L++; R--;
    }
    return N;
}
int main(){
    cout<<Solve()<<endl;

}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define NUM 1000000007
#define MAX 100001
#define INF LLONG_MAX
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,x,t;
    cin>>n>>x>>t;
    ll ans;
    if(n%x==0)
        ans=n/x;
    else
        ans=n/x+1;
    cout<<t*ans<<endl;
    return 0;
}


Measured memory_bytes: 3632
while p1=gets do
  hit,blow=0,0
  p2=gets.split(" ").to_enum
  p1=p1.split(" ").to_enum
  loop{
    b1,b2=p1.next,p2.next
    if b1==b2 then
      hit+=1
      next
    end
    blow+=1 if p1.find{|n|n==b2}
  }
  print "%d %d\n" % [hit,blow]
end

Measured memory_bytes: 6320
h, w, m = map(int, input().split())
H = [0 for i in range(h + 1)]
W = [0 for i in range(w + 1)]
b = set()
for i in range(m):
    hi, wi = map(int, input().split())
    H[hi] += 1
    W[wi] += 1
    b.add((hi, wi))
h_list = []
w_list = []
temp = max(H)
for i in range(len(H)):
    if H[i] == temp:
        h_list.append(i)
temp2 = max(W)
for i in range(len(W)):
    if W[i] == temp2:
        w_list.append(i)
flag = False
for i in h_list:
    for j in w_list:
        if (i, j) not in b:
            flag = True
            break
    if flag == True:
        break
if flag == True:
    print(temp + temp2)
else:
    print(temp + temp2 - 1)

Measured memory_bytes: 166816
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;

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

Measured memory_bytes: 3060
//#define _USE_MATH_DEFINES
//#include <math.h>
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    
    string W,T;
    cin >> W;
    int count = 0;
    while(cin >> T){
        if(T == "END_OF_TEXT") break;
        if(T.length() == W.length()){
            int a = 0;
            for(int i = 0; i < W.length(); i++){
                if(T[i] == W[i] || T[i] == W[i]+32 || T[i] == W[i]-32){
                    a++;
                }
            }
            if(a == W.length()) count++;
        }
    }
    cout << count << endl;
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mod 1e9+7
#define all(x) x.begin(),x.end()

int main() {
	ios_base::sync_with_stdio(false);
	cout.tie(0); cin.tie(0);
	ll n;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  ll s=0;
  for(int i=1;i<n;i++)
  {
    if(a[i]<a[i-1])
      {s+=(a[i-1]-a[i]);
      a[i]=a[i-1];}
  }
  cout<<s;
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MP make_pair
#define endl '\n'
const int mod = 10007;
const int MAXN = 2e5 + 5;
const int INF = 0x3f3f3f3f;

LL gcd(LL a, LL b) {
    return b ? gcd(b, a % b) : a;
}

LL lcm(LL a, LL b) {
    LL g = gcd(a, b);
    return a / g * b;
}

int main(int argc, char* argv[]) {
    LL a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>

using namespace std;

int main()
{
	long long n, k;
	vector<long long> arr;

	scanf("%lld %lld", &n, &k);

	for (long long i = 0; i < n; i++)
	{
		long long input;

		scanf("%lld", &input);

		arr.push_back(input);
	}

	sort(arr.begin(), arr.end(), greater<long long>());

	long long sum = 0;

	for (long long i = k; i < n; i++)
	{
		sum += arr[i];
	}

	printf("%lld\n", sum);

	return 0;
}

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

using namespace std;

int main(){
	int N, M; cin >> N >> M;
	char A[N][N];
	char B[M][M];
	for(int i = 0; i < N; ++i) for(int j = 0; j < N; ++j) cin >> A[i][j];
	for(int i = 0; i < M; ++i) for(int j = 0; j < M; ++j) cin >> B[i][j];

	for(int i = 0; i < N-M+1; ++i){
		for(int j = 0; j < N-M+1; ++j){
			bool isSame = true;
			for(int k = 0; k < M; ++k){
				for(int l = 0; l < M; ++l){
					int nowx = l + j;
					int nowy = k + i;
					if(A[nowy][nowx] != B[k][l]){
						isSame = false;
						break;
					}
				}
				if(!isSame) break;
			}
			if(isSame){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

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

int main(){
	string s;
	cin >> s;
	int n = s.size()-1;
	reverse(s.begin(),s.end());
	ll ans = 0;
	rep(bit, 1<<n){
		vector<int> d(n,0);
		rep(i,n) {
			if (bit & (1 << i)) {
				d[i] = 1;
			}
		}
		reverse(d.begin(),d.end());
		ans += s[0] - '0';
		ll count = 0;
		rep(i,n){
			if(d[i] == 0){
				count++;
				ans += (s[i+1]-'0')*pow(10, count);
			}
			if(d[i] == 1){
				count = 0;
				ans += s[i+1] - '0';
			}
		}
	}
	
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define vi vector<int>
#define pi pair<int, int>
#define pb push_back
#define ppb pop_back

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int N = 1e5 + 667;
const int INF = 1e9;

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

    int a, b;
    cin >> a >> b;
    cout << a * b;
    return 0;
}


Measured memory_bytes: 3636
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <list>
#include <ctime>
#include <memory.h>
#include <bitset>
#include <climits>
#include <iostream>
#include <stdlib.h>

#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define pb push_back
#define bs 1000000007
#define pi 3.141592653589793
#define y1 kjdfshnvoavaofobiopj
using namespace std;

int a, b, c, f, s;

int main(){
//freopen("input.txt", "r", stdin);
ios_base::sync_with_stdio(0);
cin.tie(0);

cin>>a>>b>>c;
if(a == 5)
	++f;
else
	++s;
	if(b == 5)
		++f;
	else
		++s;
		if(c == 5)
			++f;
		else
			++s;
if(f == 2 && s == 1)
	cout<<"YES"<<endl;
else
	cout<<"NO"<<endl;

return 0;}


Measured memory_bytes: 764
"""
B - Can you solve this?
2回目. 型アノテーションがはじかれるの忘れてた
"""


def solve():
    N, M, C = map(int, input().split())
    B = list(map(int, input().split()))
    ans = 0
    for n in range(N):
        A = list(map(int, input().split()))
        AB = [A[i] * B[i] for i in range(len(A))]
        if sum(AB) + C > 0:
            ans += 1
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
import sys
from itertools import combinations as cmb

H, W, K = map(int, input().split())
C = [list(sys.stdin.readline().strip()) for _ in range(H)]

black = 0
for i in range(H):
    for j in range(W):
        if C[i][j] == "#":
            black += 1

if black < K:
    print(0)
    exit()

res = 0
for h in range(1, H + 1):
    hc = cmb(range(H), h)
    for a in hc:
        for w in range(1, W + 1):
            wc = cmb(range(W), w)
            for b in wc:
                cnt = 0
                for i in a:
                    for j in b:
                        if C[i][j] == "#":
                            cnt += 1
                if cnt == K:
                    # print(a, b)
                    res += 1

print(res)


Measured memory_bytes: 74108
#include <iostream>
    #include <string>
    #include <math.h>
    #include<algorithm>
    using namespace std;
     
    int main(){
      string S;
      int K;
      cin >> S;
      cin >> K;
      int i=0;
      while(S[i]=='1'){
        i++;
      }
      if(K<=i){
       cout << '1' << endl; 
      }
      else{
       cout << S[i] << endl; 
      }
      return 0;}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator
import re


inf = float('inf')


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


# inputs
N, Q = 0, 0
S = ""
L, R = [], []


def set_inputs():
    global N, Q, S, L, R
    N, Q = get_li()
    S = get_str()
    L, R = get_data(Q, [int, int])
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    a, c = [], []
    for m in re.finditer("AC", S):
        a.append(m.start())
        c.append(m.end())
    for l, r in zip(L, R):
        s = bisect_left(a, l-1)
        e = bisect_right(c, r)
        if e - s <= 0:
            print(0)
        else:
            print(e - s)
    return


# ACACACXACXXAC
# a = [0, 2, 4, 7, 11]
# c = [2, 4, 6, 9, 13]


if __name__ == '__main__':
    main()


Measured memory_bytes: 81624
"""def power(x, y): 
    res = 1
    x=x
    while (y > 0): 
        if ((y & 1) == 1) : 
            res = (res * x) 
        y = y >> 1
        x = (x * x)
    return res""" 
"""def fact(n):
    if(n==0):
        return 1
    if(n==1):
        return 1
    return fact(n-1)+fact(n-2)"""
 
import math
#import combinations
 
 
#t=int(input())
#for _ in range(t):
    #n=int(input())
    #s=input()
    #arr=list(map(int,input().split()))
    #b=list(map(int,input().split()))
    #d={}
    #flag=0
a,b,c,d=map(int,input().split())
    #count=0
if(math.ceil(a/d)>=math.ceil(c/b)):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9032
#include <cstdio>
#include <cstdlib>
using namespace std;
char s[10];
struct node {
	int key;
	node *p,*left,*right;
};
node *NIL,*root=NIL;
void ins (int key) {
	node *p=NIL,*cur=root,*n=(node *)malloc(sizeof(node));
	n->key=key;
	n->left=NIL;
	n->right=NIL;
	while (cur!=NIL) {
		p=cur;
		if (key<cur->key) cur=cur->left;
		else cur=cur->right;
	}
	n->p=p;
	if (p==NIL) root=n;
	else if (key<p->key) p->left=n;
	else p->right=n;
}
node* find (int key,node *cur) {
	while (cur!=NIL&&cur->key!=key) {
		if (key<cur->key) cur=cur->left;
		else cur=cur->right;
	}
	return cur;
}
node* getSuccessor (node *u) {
	if (u->right!=NIL) {
		node *x=u->right;
		while (x->left!=NIL) x=x->left;
		return x;
	}
	node *p=u->p;
	while (p!=NIL&&u==p->right) {
		u=p;
		p=p->p;
	}
	return p;
}
void delNode (node *u) {
	node *del,*son;
	if (u->left==NIL||u->right==NIL) del=u;
	else del=getSuccessor (u);
	u->key=del->key;
	if (del->left!=NIL) son=del->left;
	else son=del->right;
	if (son!=NIL) son->p=del->p;
	if (del==root) root=son;
	else if (del==del->p->left) del->p->left=son;
	else del->p->right=son;
	free (del);
}
void preOrder (node *u) {
	if (u==NIL) return;
	printf (" %d",u->key);
	preOrder (u->left);
	preOrder (u->right);
}
void inOrder (node *u) {
	if (u==NIL) return;
	inOrder (u->left);
	printf (" %d",u->key);
	inOrder (u->right);
}
int main () {
	int m;
	scanf ("%d",&m);
	for (int i=0;i<m;i++) {
		scanf ("%s",s);
		if (s[0]=='i') {
			int key;
			scanf ("%d",&key);
			ins (key);
		} else if (s[0]=='f') {
			int key;
			scanf ("%d",&key);
			if (find (key,root)!=NIL) printf ("yes\n");
			else printf ("no\n");
		} else if (s[0]=='d') {
			int key;
			scanf ("%d",&key);
			delNode (find (key,root));
		} else {
			inOrder (root);
			printf ("\n");
			preOrder (root);
			printf ("\n");
		}
	}
    return 0;
}


Measured memory_bytes: 21416
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let s: Vec<char> = input::<String>().chars().collect();

    let mut ans = 0;
    let mut cur = s[0];
    for &c in &s[1..] {
        if c != cur {
            ans += 1;
        }
        cur = c;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pll;

constexpr ll INF = 1e7;

int main() {
    string S; cin >> S;
    int N = S.length() + 1;
    ll ans = 0;
    vector<ll> lef(N, INF); lef[0] = 0;
    vector<ll> rig(N, INF); rig[N-1] = 0;

    for (int i = 0; i < S.length(); i++) {
        if (S[i] == '<' && lef[i] != INF) lef[i+1] = lef[i] + 1;
        else lef[i+1] = 0;
    }
    for (int i = S.length(); 0 <= i; i--) {
        if (S[i] == '>' && rig[i+1] != INF) rig[i] = rig[i+1] + 1;
        else rig[i] = 0;
    }
    for (int i = 0; i < N; i++) {
        ans += max(lef[i], rig[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 8708
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n;
	cin>>n;
	long long p=1;
	fori(n){
		p*=i+1;
		p%=1000000007;
	}
	cout<<p;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt() - i;
    }
    Arrays.sort(a);
    int mid = a[(n-1)/2];
    long sum = 0;
    for(int i = 0; i < n; i++){
      sum += Math.abs(a[i] - mid);
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 65656
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

int N, A, B, C;
const int MAX_N = 8;
int l[MAX_N];

int dfs(int num, int a, int b, int c, int cost){
    if(num == N){
        if(a==0 || b==0 || c==0) return 1000000009;
        else return abs(a-A)+abs(b-B)+abs(c-C) + cost;
    }

    int ret0 = dfs(num+1, a, b, c, cost);
    int ret1 = dfs(num+1, a+l[num], b, c, cost+10);
    int ret2 = dfs(num+1, a, b+l[num], c, cost+10);
    int ret3 = dfs(num+1, a, b, c+l[num], cost+10);

    int ret = min(ret0, ret1);
    ret= min(ret, ret2);
    ret = min(ret, ret3);

    return ret;
}

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

    for(int i=0; i<N; i++){
        cin >> l[i];
    }

    int ans = dfs(0,0,0,0,-30);

    cout << ans << endl;

    return 0;
}


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

const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  COMinit();
  int n,k;
  ll mod = 1e9+7;
  cin >> n >> k;
  rep(i,1,k+1) cout << (COM(k-1,i-1)*COM(n-k+1,i))%mod << endl;
}

Measured memory_bytes: 15540
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

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

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  string s[3];
  rep (i, 3) {
    cin >> s[i];
  }
  cout << s[0][0] << s[1][1] << s[2][2] << endl;
  return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;

struct Node
{
    string str;
    int p, idx;
    bool operator<(const Node& rhs) const
    {
        return str == rhs.str ? p > rhs.p : str < rhs.str;
    }
} A[maxn];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> A[i].str >> A[i].p, A[i].idx = i + 1;
    sort(A, A + n);
    for (int i = 0; i < n; i++)
        cout << A[i].idx << endl;
    cin >> ws;
    return 0;
}

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

using namespace std;
typedef long long LL;

int n;
int a[100000];

int tot;
int f[100000];

void Init()
{
	f[1] = 1;
	for(int i = 2;i <= 55555;i++)
	{
		if(f[i] == 0) a[++tot] = i;
		for(int j = 1;j <= tot;j++)
		{
			if(a[j] * i > 55555) break;
			f[a[j] * i] = 1;
			if(i % a[j] == 0) break;
		}
	}
}
int main()
{
	Init();
	scanf("%d",&n);
	int j = 0;
	for(int i = 11;j < n;i += 10)
	{
		if(f[i] == 0)
		{
			printf("%d ",i);
			j++;
		}
	}
	printf("\n");
}

Measured memory_bytes: 512
import java.util.*;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		String t=sc.next();
		
		String s1=s.substring(0,1);
		String s2=s.substring(1,2);
		String s3=s.substring(2,3);
		
		String t1=t.substring(0,1);
		String t2=t.substring(1,2);
		String t3=t.substring(2,3);
		
		int result=0;
		
		if(s1.equals(t1)){
			result+=1;
			}
		else{
			result+=0;
		}
		if(s2.equals(t2)){
			result+=1;
		}
		else{
			result+=0;
		}
		if(s3.equals(t3)){
			result+=1;
		}
		else{
			result+=0;
		}
		System.out.println(result);
	}
}

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

int main() {
  string s;
  cin >> s;
  
  if(s.at(2) == s.at(3) && s.at(4) == s.at(5))
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}

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

using namespace std;
using ll = long long;

int n, w;
ll maxv[100001];
int main() {
    cin >> n >> w;
    for (int i = 0; i <= w; ++i) {
        maxv[i] = -1;
    }
    maxv[0] = 0;
    for (int i = 0; i < n; ++i) {
        int wi, vi;
        cin >> wi >> vi;
        for (int j = w - wi; j >= 0; --j) {
            if (maxv[j] == -1) continue;
            maxv[j + wi] = max(maxv[j + wi], maxv[j] + vi);
        }
    }
    ll ans = 0;
    for (int i = 0; i <= w; ++i) {
        ans = max(ans, maxv[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
n = gets.to_i
b = gets.chomp.split(" ").map(&:to_i)
a = [b[0]]
(n-2).times do |i|
  a.push(b[i] > b[i+1] ? b[i+1] : b[i])
end
a.push(b[n-2])
puts a.inject(:+)

Measured memory_bytes: 1788
#include<iostream>

int main()
{
	int a, b;
	char op;
	

	while (1) {
		std::cin >> a >> op >> b;
		if (op == '+')
			std::cout << a + b;
		else if (op == '-')
			std::cout << a - b;
		else if (op == '*')
			std::cout << a * b;
		else if (op == '/')
			std::cout << a / b;
		else if (op == '?')
			break;
		std::cout << std::endl;
	}
}

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

int main() {
	long long a, b, k;
	cin >> a >> b >> k;
	
	if (k <= a) {
		cout << a - k <<  " " << b << endl;
	}
	else if (k <= a + b) {
		cout << 0 << " " << b - (k - a) << endl;
	}
	else {
		cout << 0 << " " << 0 << endl;
	}	
}

Measured memory_bytes: 256
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
a = [list(map(int,input().split())) for i in range(n)]
ans = 0
x = 0
for code in a:
    for k,i in zip(range(m),code):
        x+=(b[k]*i)
    if x+c>0:
        ans+=1
    x=0
print(ans)

Measured memory_bytes: 3064