akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
    #define MAX 10000
    #define NIL -1

    struct Node{
    int p, l, r;
    };

    struct Node T[MAX];
    int n;
    int D[MAX], H[MAX];

    int getDepth(int u){
    int d = 0;
    while(1){
        u = T[u].p;
        if ( u == NIL ) break;
        d++;
    }
    return d;
    }

    int getSibling(int u){
    if ( T[u].p == NIL ) return NIL;
    if ( T[T[u].p].l != u && T[T[u].p].l != NIL ) return T[T[u].p].l;
    if ( T[T[u].p].r != u && T[T[u].p].r != NIL ) return T[T[u].p].r;
    return NIL;
    }

    void print(int u){
    printf("node %d: ", u);

    printf("parent = %d, ", T[u].p);
    printf("sibling = %d, ", getSibling(u));
    int deg = 0;
    if ( T[u].l != NIL ) deg++;
    if ( T[u].r != NIL ) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);

    if ( T[u].p == NIL ){
        printf("root\n");
    } else if ( T[u].l == NIL && T[u].r == NIL ){
        printf("leaf\n");
    } else {
        printf("internal node\n");
    }
    }

    int main(){
    int i, v, l, r;
    scanf("%d", &n);

    for ( i = 0; i < n; i++ ) {
        T[i].p = NIL;
    }

    for ( i = 0; i < n; i++ ){
        scanf("%d %d %d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if ( l != NIL ) T[l].p = v;
        if ( r != NIL ) T[r].p = v;
    }

    for ( i = 0; i < n; i++ ){
        D[i] = getDepth(i);
        H[i] = 0;
    }

    for ( i = 0; i < n; i++ ){
        if ( T[i].l == NIL && T[i].r == NIL ) { 
        H[i] = 0;
        int p = T[i].p;
        int c = 1;
        while(1){
        if ( p == NIL ) break;
        if ( H[p] < c ) H[p] = c;
        c++;
        p = T[p].p;
        }
        }
    }

    for ( i = 0; i < n; i++ ) print(i);
    return 0;
    }


Measured memory_bytes: 2100
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    string s;
    int x, y;
    cin >> s >> x >> y;
    s += "T";
    vector<int> X, Y;
    bool first = true;
    bool state = true;
    int cur = 0;
    rep(i, s.size()){
        if(s[i] == 'F') cur++;
        if(s[i] == 'T'){
            if(state){
                if(first){
                    x -= cur;
                    cur = 0;
                    first = false;
                }
                else {
                    X.pb(cur);
                    cur = 0;
                }
                state = false;
            }
            else {
                Y.pb(cur);
                cur = 0;
                state = true;
            }
        }
    }
    int xsum = 0, ysum = 0;
    rep(i, X.size()) xsum += X[i];
    rep(i, Y.size()) ysum += Y[i];
    
    vector<int> XX(8010, 0), YY(8010, 0);
    XX[0] = YY[0] = 1;
    rep(i, X.size()){
        auto tmp = XX;
        rep(j, XX.size()){
            tmp[j + X[i]] |= XX[j];
        }
        XX = tmp;
    }
    rep(i, Y.size()){
        auto tmp = YY;
        rep(j, YY.size()){
            tmp[j + Y[i]] |= YY[j];
        }
        YY = tmp;
    }
    if((xsum - x) % 2 != 0 || (ysum - y) % 2 != 0) {
        output("No");
        return 0;
    }
    if(XX[(xsum - x) / 2] && YY[(ysum - y) / 2]){
        output("Yes");
    }
    else {
        output("No");
    }
    
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> II;
 
const int MAXN = (int) 1e5 + 10;
int n;
vector<int> adj[MAXN];
 
int DFS(int u, int T, int par = -1) {
    vector<int> a;
    for (int i = 0; i < (int) adj[u].size(); ++i) {
        int v = adj[u][i];
        if (v != par) a.push_back(DFS(v, T, u));
    }
    if ((int) a.size() % 2 == 0 && par != -1) a.push_back(0);
    sort(a.begin(), a.end());
 
    if ((int) a.size() % 2 == 0) {
        for (int i = 0; i < (int) a.size(); ++i)
            if (a[i] + a[(int) a.size() - i - 1] > T) return T + 3;
        return 0;
    }
 
    int l = 0, r = (int) a.size() - 1, f = -1;
    while (l <= r) {
        int mid = (l + r) >> 1;
        vector<int> b;
        for (int i = 0; i < (int) a.size(); ++i)
            if (i != mid) b.push_back(a[i]);
        bool check = true;
        for (int i = 0; i < (int) b.size() / 2; ++i) {
            if (b[i] + b[(int) b.size() - i - 1] > T) {
                check = false;
                break;
            }
        }
        if (check) {
            f = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    if (f == -1) {
        // printf("#%d: %d\n", u, T + 3);
        return T + 3;
    }
    // printf("#%d: %d\n", u, a[f] + 1);
    return a[f] + 1;
}
 
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n - 1; ++i) {
        int u, v; scanf("%d%d", &u, &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
 
    int l = 1, r = n, f = -1;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (DFS(1, mid) <= mid + 1) {
            f = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
 
    int cnt = 0;
    for (int i = 1; i <= n; ++i) cnt += (int) adj[i].size() % 2;
 
    printf("%d %d\n", cnt / 2, f);
    return 0;
}

Measured memory_bytes: 17664
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
char ch[100];
int b[200] = {0};
int main()
{
    int n;
    cin >> n;
    int i;
    for(i = 1; i <= n; i++)
        cin >> ch[i];
    for(i = 1; i <= n; i++)
    {
        if(ch[i] == '(')
            b[i] = -1;
        else
            b[i] = 1;
    }
    int lsum = 0;
    int rsum = 0;
    int sum = 0;
    for(int j = 1; j <= n; j++)
    {
        lsum+=b[j];
        if(lsum > 0)
            lsum = 0;
    }
    for(int j = 1; j <= n; j++)
    {
        if(b[j] == -1)
            sum+=b[j];
        if(b[j] == 1 && sum >= 0)
            rsum+=b[j];
        if(b[j] == 1 && sum < 0)
            sum+=b[j];
    }
    int e,r;
    for(r = 0; r < rsum; r++)
        cout << '(';
    for(i = 1; i <= n; i++)
        cout << ch[i];
    for(e = 0; e < abs(lsum); e++)
        cout << ')';
    return 0;
}


Measured memory_bytes: 256
s = input()

if 1 <= int(s[:2]) <= 12:
    if 1 <= int(s[2:]) <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= int(s[2:]) <= 12:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 61824
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    var takaHP = scanner.nextInt()
    val takaAT = scanner.nextInt()
    var aoHP = scanner.nextInt()
    val aoAT = scanner.nextInt()
    var check = true
    do{
        if(check) {
            aoHP -= takaAT
            check = false
        }
        else {
            takaHP -= aoAT
            check = true
        }

    }while (takaHP > 0 && aoHP > 0)
    if(aoHP <= 0) println("Yes")
    else println("No")

}

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

using namespace std;

typedef pair<int,int> pi;
typedef long long ll;

int N, P[300005];

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

bool isValid(int x, int y){
	return (x >= 0 && x <= N+1 && y >= 0 && y <= N+1);
}

int dist[505][505], grid[505][505], tot = 0;

deque<pi> q;

void runBFS(){
	while (!q.empty()){
		pi a = q.front();
		q.pop_front();
		int x = a.first, y = a.second;
		for (int i = 0; i < 4; ++i){
			if (isValid(x+dx[i],y+dy[i])){
				if (grid[x+dx[i]][y+dy[i]] == 0){
					if (dist[x+dx[i]][y+dy[i]] > dist[x][y]){
						dist[x+dx[i]][y+dy[i]] = dist[x][y];
						q.push_front(pi(x+dx[i],y+dy[i]));
					}
				}
				else{
					if (dist[x+dx[i]][y+dy[i]] > dist[x][y] + 1){
						dist[x+dx[i]][y+dy[i]] = dist[x][y] + 1;
						q.push_back(pi(x+dx[i],y+dy[i]));
					}
				}
				
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N*N; ++i){
		cin >> P[i];
		P[i]--;
		grid[P[i]/N+1][P[i]%N+1] = 1;
		dist[P[i]/N+1][P[i]%N+1] = 1e9;
	}
	
	for (int i = 1; i <= N; ++i){
		q.push_back(pi(0,i));
		q.push_back(pi(N+1,i));
		q.push_back(pi(i,0));
		q.push_back(pi(i,N+1));
	}
	runBFS();
	for (int i = 1; i <= N*N; ++i){
		grid[P[i]/N+1][P[i]%N+1] = 0;
		int x = P[i]/N+1, y = P[i]%N+1, mx, my, mdist = 1e9;

		for (int j = 0; j < 4; ++j){
			if (dist[x+dx[j]][y+dy[j]] < mdist){
				mdist = dist[x+dx[j]][y+dy[j]];
				mx = x+dx[j];
				my = y+dy[j];
			}
		}
		q.push_back(pi(mx,my));
		runBFS();
		/*
		for (int j = 1; j <= N; ++j){
			for (int k = 1; k <= N; ++k){
				cout << dist[j][k] << ' ';
			}
			cout << '\n';
		}
		*/
		tot += dist[P[i]/N+1][P[i]%N+1];
		//cout << tot << '\n';
		
	}
	cout << tot << '\n';
}

Measured memory_bytes: 7404
import java.util.*;

class Main{

    public static void main(String[] args)
    {
	int t,n,m,p,q,v;
	double ki=0,tai=0,maxx=0,r;

	Scanner in = new Scanner(System.in);	

	t = in.nextInt();
	for(int j=0;j<t;j++)
	    {
		n = in.nextInt();
		m = in.nextInt();
		n = n + 1;
		n = n - 1;
		ki = 0;
		tai = 0;
		for(int i=0;i<m;i++){
		    v = in.nextInt();
		    r = in.nextDouble();
		    ki = ki + v*r;
		    tai += r;
		}
		maxx = Math.max(maxx,ki/tai);
	    }
		ki = 0;
		tai = 0;
		p = in.nextInt();
		q = in.nextInt();
		p = p + 1;
		p = p -1;
		for(int i=0;i<q;i++)
		    {
			v = in.nextInt();
			r = in.nextDouble();
			ki+=v*r;
		tai+=r;
		    }
		double hell;
		hell = ki/tai;
		if(hell+0.0000001<maxx)System.out.println("YES");
		else System.out.println("NO");
		
    }
}

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

int main() {
	int n,k,i;
	int ans=0;
	int alpha[26]={0};
	string s;
	cin>>n>>k;
	for(i=0;i<n;i++){
		cin>>s;
		alpha[s[0]-'A']--;
	}
	
	while(1){
		sort(alpha,alpha+26);
		for(i=0;i<k;i++){
			alpha[i]++;
			if(alpha[i]>0){
				goto end;
			}
		}
		ans++;
	}
	end:
	cout<<ans<<endl;
}

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

int n, x, maxim, ans;

int main() {
    cin >> n;

    maxim = 0;
    for(int i = 1; i <= n; i++) {
        cin >> x;

        maxim = max(maxim, x);
        ans += x;
    }

    ans -= maxim / 2;

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++)cin>>a[i];
  ll ans=1;
  sort(a,a+n);
  ll sum[n];sum[0]=a[0];
  for(ll i=1;i<n;i++)sum[i]=sum[i-1]+a[i];
  for(ll i=n-2;i>=0;i--){
    if(sum[i]*2>=a[i+1])ans++;
    else break;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
import math
a,b,h,m = map(int,input().split())

h_s = 360*h/12+30*m/60
m_s = 360*m/60
s = abs(h_s - m_s)
print(abs(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(s)))))

Measured memory_bytes: 9552
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int N,E,T;

int gen[303];

vector<vector<int>> G[303];

int main(){
    cin >> N >> E >> T;
    for(int i = 1;i <= N;i++){
        cin >> gen[i];
    }
    for(int i = 0;i < E;i++){
        int g,c;
        cin >> g >> c;
        G[g].push_back(vector<int>(c,0));
        for(auto& a : G[g].back()){
            cin >> a;
        }
    }

    vector<i64> dp(N + 1,1e9);
    for(int i = 1;i <= N;i++){
        if(gen[i]) dp[i] = 1;
    }

    for(int i = 0;i < N;i++){
        for(int v = 1;v <= N;v++){
            for(auto& g : G[v]){
                vector<i64> temp;
                for(int & chi : g){
                    temp.push_back(dp[chi]);
                }
                sort(temp.rbegin(),temp.rend());
                i64 res = 0;
                for(int c = 0;c < temp.size();c++){
                    res = max(res,temp[c] + c);
                }
                res = max(res , (i64)g.size());
                dp[v] = min(dp[v],res);
            }
        }
    }
    if(dp[T] >= 1e9) dp[T] = -1;
    cout << dp[T] << endl;
}


Measured memory_bytes: 3232
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
    int x,a,b;
    scanf("%d",&x);
    scanf("%d",&a);
    scanf("%d",&b);
    x-=a;
    while(x>=b)
    {
        x-=b;
    }
    cout<<x<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{   /// Standing in the hall of fame
    ios_base::sync_with_stdio() , cin.tie(NULL) , cout.tie(NULL);
    string s;
    cin >> s;
    int x;
    if(s[0] == 'R')     x = 1;
    else if(s[0] == 'C')x = 2;
    else                x = 3;
    cout << ((x == 1)? "Sunny" : (x == 2)? "Rainy" : "Cloudy") << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps DBL_EPSILON
#define mod (ll)1000000007
#define INF INT_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	int k, x;
	cin >> k >> x;
	for (int i = x - k + 1; i <= x + k - 2; i++)cout << i << " ";
	cout << x + k - 1 << endl;
	return 0;
}

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

using namespace std;
typedef pair<int, int> P;

struct edge {
	int to, cap, rev;
	edge(int a, int b, int c) {
		to = a, cap = b, rev = c;
	}
};

int m, n;
int b[500], w[500];
vector<vector<edge>> G;
bool used[1000 + 100];
int INF = 100000000;

void build_edge(int from, int to, int cap) {
	G[from].push_back(edge(to, cap, G[to].size()));
	G[to].push_back(edge(from, 0, G[from].size() - 1));
}

int dfs(int v, int t, int f) {
	if (v == t)return f;
	used[v] = true;
	for (int i = 0; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

vector<vector<int>> bpf;//b_prime_factor
vector<vector<int>> wpf;//r_prime_factor

vector<int> get_factor(int a) {
	vector<int> result;
	int p = 2;
	while (p * p <= a) {
		int cnt = 0;
		while (a % p == 0) {
			a /= p;
			cnt++;
			if (cnt == 1)result.push_back(p);
		}
		p++;
	}
	if(a != 1)result.push_back(a);
	return result;
}

int main() {

	while (1) {
		cin >> m >> n;
		if (!(m + n))break;
		bpf.resize(m), wpf.resize(n);
		G.resize(m + n + 2);
		for (int i = 0; i < m; i++)cin >> b[i], bpf[i] = get_factor(b[i]);
		for (int j = 0; j < n; j++)cin >> w[j], wpf[j] = get_factor(w[j]);

		//building edge by factors information
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < bpf[i].size(); k++) {
					for (int l = 0; l < wpf[j].size(); l++) {
						if (bpf[i][k] == wpf[j][l]) {
							build_edge(i + 1, j + m + 1, 1);
							goto next;
						}
					}
				}
			next:;
			}
		}
		for (int i = 0; i < m; i++)build_edge(0, i + 1, 1);
		for (int j = 0; j < n; j++)build_edge(j + m + 1, m + n + 1, 1);
		//get ans by network flow problem

		int flow = 0;
		for (;;) {
			for (int i = 0; i < 1050; i++)used[i] = false;
			int f = dfs(0, m + n + 1, INF);
			if (f == 0)break;
			flow += f;
		}
		cout << flow << endl;
		G.clear(), bpf.clear(), wpf.clear();
	}
	return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a*c, a*d, b*c, b*d}) << endl;


    return 0;
}


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

namespace ABC_085A
{
    class Program
    {
        static void Main(string[] args)
        {
            String s;

            s = Console.ReadLine();

            char[] cs = s.ToCharArray();

            cs[3] = '8';

            Console.WriteLine(cs);

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#define NIL -1
struct Node {
	int p;
	int l;
	int r;
};

struct Node T[30];

void preParse(int u) {
	if (u == NIL) return;
	printf(" %d", u);
	preParse(T[u].l);
	preParse(T[u].r);
}

void inParse(int u) {
	if (u == NIL) return;
	inParse(T[u].l);
	printf(" %d", u);
	inParse(T[u].r);
}

void postParse(int u) {
	if (u == NIL) return;
	postParse(T[u].l);
	postParse(T[u].r);
	printf(" %d", u);
}

int main() {
	int n, i, root, v, l, r;
	scanf("%d", &n);

	for (i = 0; i < n; ++i) {
		T[i].p = NIL;
	}
	for (i = 0; i < n; ++i) {
		scanf("%d %d %d", &v, &l, &r);
		T[v].l = l;
		T[v].r = r;
		if (l != NIL) T[l].p = v;
		if (r != NIL) T[r].p = v;
	}
	for (i = 0; i < n; ++i) {
		if (T[i].p == NIL) root = i;
	}

	printf("Preorder\n");
	preParse(root);
	printf("\n");

	printf("Inorder\n");
	inParse(root);
	printf("\n");

	printf("Postorder\n");
	postParse(root);
	printf("\n");

	return 0;
}

Measured memory_bytes: 1812
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 100000;
int N;
ll x[MAX_N+1], y[MAX_N+1];
int a, b;
ll D;
bool rm[MAX_N+1];
set<pll> s1;
set<pll> s2;
vector<pll> v1;
vector<pll> v2;
map<pll, int> id;

int main() {
  cin >> N >> a >> b;
  for (int i = 1; i <= N; ++i) cin >> x[i] >> y[i];
  D = (abs(x[a]-x[b])+abs(y[a]-y[b]));

  for (int i = 1; i <= N; ++i) {
    int tx = x[i], ty = y[i];
    x[i] = tx - ty;
    y[i] = tx + ty;
  }


  for (int i = 1; i <= N; ++i) {
    s1.insert(pll(x[i], y[i]));
    s2.insert(pll(y[i], x[i]));
    id[pll(x[i], y[i])] = i;
  }

  queue<int> que;
  que.push(a);

  while (!que.empty()) {
    int v = que.front(); que.pop();
    if (rm[v]) {continue;}
    rm[v] = true;

    int tx = x[v], ty = y[v];
    auto ite = s1.lower_bound(pll(tx-D, ty-D));

    while (ite != s1.end()) {
      if (ite->fi != tx-D || ite->sc > ty+D) break;
      pll tp = *ite;
      que.push(id[*ite]);
      s1.erase(ite++);
    }

    ite = s1.lower_bound(pll(tx+D, ty-D));
    while (ite != s1.end()) {
      if (ite->fi != tx+D || ite->sc > ty+D) break;
      que.push(id[*ite]);
      s1.erase(ite++);
    }

    ite = s2.upper_bound(pll(ty-D, tx-D));
    while (ite != s2.end()) {
      if (ite->fi != ty-D || ite->sc >= tx+D) break;
      que.push(id[pll(ite->sc, ite->fi)]);
      s2.erase(ite++);
    }

    ite = s2.upper_bound(pll(ty+D, tx-D));
    while (ite != s2.end()) {
      if (ite->fi != ty+D || ite->sc >= tx+D) break;
      que.push(id[pll(ite->sc, ite->fi)]);
      s2.erase(ite++);
    }

  }


  for (int i = 1; i <= N; ++i) {
    if (rm[i]) {
      v1.push_back(pll(x[i], y[i]));
      v2.push_back(pll(y[i], x[i]));
    }
  }

  sort(all(v1));
  sort(all(v2));

  ll ans = 0;
  for (int v = 1; v <= N; ++v) {
    if (rm[v]) {
      int tx = x[v], ty = y[v];
      ans += upper_bound(all(v1), pll(tx-D, ty+D)) - lower_bound(all(v1), pll(tx-D, ty-D));

      ans += upper_bound(all(v1), pll(tx+D, ty+D)) - lower_bound(all(v1), pll(tx+D, ty-D));

      ans += lower_bound(all(v2), pll(ty+D, tx+D)) - upper_bound(all(v2), pll(ty+D, tx-D));

      ans += lower_bound(all(v2), pll(ty-D, tx+D)) - upper_bound(all(v2), pll(ty-D, tx-D));
    }
  }

  cout << ans / 2 << endl;

  return 0;
}



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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
struct Dinic {
	struct Hen {
		int to;
		int64_t cap;
		int rev_id;
	};
	int n;
	std::vector<std::vector<Hen> > hen;
	Dinic (int n) : n(n), hen(n) {}
	void add_hen(int a, int b, int64_t c) {
		hen[a].push_back({b, c, (int) hen[b].size()});
		hen[b].push_back({a, 0, (int) hen[a].size() - 1});
	}
	std::vector<int> dist;
	void bfs(int s) {
		dist.assign(n, 1000000000);
		std::queue<int> que;
		que.push(s);
		dist[s] = 0;
		while (que.size()) {
			int i = que.front();
			que.pop();
			for (auto j : hen[i]) if (j.cap > 0 && dist[j.to] > dist[i] + 1) dist[j.to] = dist[i] + 1, que.push(j.to);
		}
	}
	std::vector<int> heads;
	int64_t dfs(int i, int goal, int64_t flow) {
		if (i == goal) return flow;
		for (int &j = heads[i]; j < (int) hen[i].size(); j++) {
			if (hen[i][j].cap <= 0 || dist[hen[i][j].to] <= dist[i]) continue;
			int64_t new_flow = dfs(hen[i][j].to, goal, std::min(flow, hen[i][j].cap));
			if (new_flow > 0) {
				hen[i][j].cap -= new_flow;
				hen[hen[i][j].to][hen[i][j].rev_id].cap += new_flow;
				return new_flow;
			}
		}
		return 0;
	}
	int64_t run(int s, int t) {
		int64_t res = 0;
		while (1) {
			bfs(s);
			if (dist[t] == 1000000000) break;
			heads.assign(n, 0);
			int64_t cur;
			while ((cur = dfs(s, t, 1000000000)) > 0) res += cur;
		}
		return res;
	}
};

int main() {
	int n = ri();
	int a[n + 1];
	for (int i = 1; i <= n; i++) a[i] = ri();
	int64_t base = 0;
	Dinic dinic(n + 2);
	for (int i = 1; i <= n; i++) {
		if (a[i] >= 0) {
			dinic.add_hen(0, i, a[i]);
			dinic.add_hen(i, n + 1, 0);
			base += a[i];
		} else {
			dinic.add_hen(0, i, 0);
			dinic.add_hen(i, n + 1, -a[i]);
		}
		for (int j = i + i; j <= n; j += i) dinic.add_hen(j, i, 1000000000000000000);
	}
	base -= dinic.run(0, n + 1);
	printf("%" PRId64 "\n", base);
	return 0;
}




Measured memory_bytes: 256
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N,M = map(int, input().split())
    A = list(map(int, input().split()))
    threshold = sum(A)/(4*M)
    count = 0
    for a in A:
        if a >= threshold:
            count += 1
        if count == M:
            return "Yes"
    return "No"

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 5588
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

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

    vector<ll> p(n);
    ll a = 0;
    ll ans = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
        a = max(a, p[i]);
        ans += p[i];
    }

    cout << ans - a / 2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
	string s, key="", max="";
	map<string, int> count;
	int ans_int=0;
	while(cin >> s){
		if(s.size() > max.size()) max = s;
		++count[s];
	}
	for(map<string,int>::iterator it = count.begin(); it != count.end(); it++){
		if(ans_int < it->second){
		ans_int = it->second;
		key = it -> first;
		}
	}
			cout << key << " " << max << endl;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		long sum=0;
		long N = cin.nextInt();
		for(int i = 0; i < N;i++){
			long n = cin.nextLong();
			sum += n;
		}
		System.out.println(sum/N);
	}

}

Measured memory_bytes: 12000
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var DTS = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var D = DTS[0]; var T = DTS[1]; var S = DTS[2];
            Console.WriteLine(T * S >= D ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 27460
#n=int(input())
A,B,C,X,Y=map(int,input().split())
#hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
mn=A*X+B*Y
for i in range(max(X,Y)+1):
    mn=min(mn,2*i*C+A*max(0,X-i)+B*max(0,Y-i))

print(mn)

Measured memory_bytes: 9188
#include <iostream>
#include <climits>

using namespace std;

#define INF 2000000000
#define N 100000

int a, b, c, x, y, ans;

void solve()
{
    ans = INT_MAX;

    for (int i = 0; i <= N; i++) {
        int sum = 2*c*i;

        sum += a*max(0, x-i);
        sum += b*max(0, y-i);

        if (sum < ans) ans = sum;
    }
}

int main()
{
    scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);

    solve();

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64
#define n_max int(1e5)


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if( a <= c and c <= b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
  int n = ri();
  char* s;
  if (n < 1200) s="ABC";
  else if (n < 2800) s = "ARC";
  else s = "AGC";
  
  puts(s);
  
  return 0;
}


Measured memory_bytes: 384
# (r, H-r)   (W-r, H-r)
# (r, r)     (W-r, W)    に囲まれた領域に中心がある円はYes, それ以外はNo

W, H, x, y, r = map(int, input().split())
if r <= x <= W-r and r <= y <= H-r:
    print('Yes')
else:
    print('No')
 


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

int main() {
  long N;
  cin >> N;
  long L[N+1];
  L[0]=2;
  L[1]=1;
  for(int i=2;i<N+1;i++){
    L[i]=L[i-1]+L[i-2];
  }
  cout << L[N];
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    map<string, int> mp;

    int max_n = 0;
    rep(i, 0, N) {
        string s;
        cin >> s;
        mp[s]++;
        max_n = max(mp[s], max_n);
    }

    for (auto m : mp) {
        if (m.second == max_n) {
            cout << m.first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 25216
n = int(input())
a = [int(input()) for _ in range(n)]

sorted_a = sorted(a)
first_a = sorted_a[-1]
second_a = sorted_a[-2]

for i in range(len(a)):
    if a[i] == first_a:
        print(second_a)
    else:
        print(first_a)



Measured memory_bytes: 14112
use std::io::stdin;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let n: i64 = buf.trim().parse().ok().unwrap();
    if n%2==0 {
        println!("{}", n);
    } else { 
        println!("{}", n*2);
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

vector<int> g[200005];
int d[200005];

void dfs(int x, int p) {
    for (int i : g[x]) if (i != p) {
        d[i] += d[x];
        dfs(i, x);
    }
}

int main() {
    ios::sync_with_stdio(false);
    int n, q, u, v;
    cin >> n >> q;
    for (int i = 1; i < n; i++) cin >> u >> v, g[u].push_back(v), g[v].push_back(u);
    while (q--) cin >> u >> v, d[u] += v;
    dfs(1, 1);
    for (int i = 1; i <= n; i++) cout << d[i] << ' ';
}


Measured memory_bytes: 27768
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
const int maxn=21,mod=1000000007;
int n,m,k;
int must[maxn][maxn],F[maxn][1<<maxn],G[maxn][1<<maxn];
void upd(int &x,int y){
	x=(x+y)%mod;
}
int main(){
	memset(must,-1,sizeof must);
	read(n);n--;
	if(!n)return puts("1"),0;
	read(m);read(k);
	rep(i,1,k){
		int a,b,c;
		read(a);read(b);read(c);
		must[b][a]=c;
	}
	rep2(i,0,n)F[i][0]=1;
	rep(i,1,m)rep2(now,0,n){
		rep2(S,0,1<<n)G[now][S]=0;
		rep2(S,0,1<<n){
			int lst;
			if(!now)lst=n-1;
			else lst=now-1;
			if(S>>now&1){
				if(must[now+1][i]!=0)upd(G[now][S],F[lst][S]);
			}else{
				if(must[now+1][i]!=1)upd(G[now][S],F[lst][S]);
				if(must[now+1][i]!=0){
					int nxtS=S^(1<<now);
					rep2(k,now+1,n)if(S>>k&1){
						nxtS^=1<<k;
						break;
					}
					upd(G[now][nxtS],F[lst][S]);
				}
			}
		}
		rep2(S,0,1<<n)F[now][S]=G[now][S];
	}
	int ans=0;
	rep2(S,0,1<<n)upd(ans,F[n-1][S]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 156032
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	N := readInt()
	m := make(map[int]bool)

	for i := 0; i < N; i++ {
		a := readInt()
		_, ok := m[a]
		if ok {
			delete(m, a)
		} else {
			m[a] = true
		}
	}
	println(len(m))
}


Measured memory_bytes: 5504
#include<iostream>
#include<vector>
#include<algorithm>
#define lli long long int
#define INF 1e9+5
using namespace std;

int main()
{   

int h,n;
cin>>h>>n;
vector<int> dp(h+1,INF);
dp[0]=0;
while(n--)
{
	int cost, value;
	cin>>value>>cost;
	for(int i=0;i<=h;i++)
	{
		int j=min(h, i+value);
		dp[j]=min(dp[j],dp[i]+cost);
	}
}
cout<<dp[h];
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int	cnt = parseCnt();

		while(cnt-- > 0) {
			String	tmp = parseStdin();
			System.out.println(tmp.replace("Hoshino", "Hoshina"));
		}
	}

	private static int parseCnt() {
		int		cnt = 0;
		String	str = null;

		if ((str = parseStdin()) != null) {
			cnt = Integer.parseInt(str);
		}

		return cnt;
	}

	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (tmp != null) {
            	if (!tmp.isEmpty()) {
            		stdin = tmp;
            	}
        	}
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

Measured memory_bytes: 16948
/*
* Author : MaxSally
*/
/********   All Required Header Files ********/
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (ll i = j ; i <= k ; ++i)
#define rrep(i, j, k) for (int i = j; i >= k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

const int N = 0;
ll cnt = 0, n;
set<ll> s;

void solve(ll i){
    ll m = n;
    s.insert(i);
    if(i == 1) return;
    while(m > 1 && m % i == 0){
        m /= i;
    }
    if(m % i == 1){
        cnt++;
    }
}

int main(){
    io;
    //freopen("input.txt","r",stdin);
    cin >> n;

    for(ll i = 1; i * i <= n; i++){
        if(n % i != 0){
            continue;
        }
        solve(i);
        if(i * i != n){
            solve(n/i);
        }
    }
    for(ll i = 1; i * i <= n - 1; i++){
        if((n - 1) % i == 0){
            if(i * i != (n - 1)){
                if(s.find((n - 1)/i) == s.end()){
                    cnt++;
                }
            }
            if(s.find(i) == s.end()){
                cnt++;
            }
        }
    }
    cout << cnt;
    return 0;
}


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

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

typedef struct{
	int m[12][12];
	int l[12][12];
}state;

state push(state t,int x,int y){
	t.l[x][y]=(t.l[x][y]+1)%2;
	for(int i=0;i<5;i++){
		t.m[x+dx[i]][y+dy[i]]=(t.m[x+dx[i]][y+dy[i]]+1)%2;
	}
	return t;
}

int cal(state t,int b){
	for(int i=1;i<=10;i++){
		if(b%2)t=push(t,i,1);
		b/=2;
	}
	for(int i=2;i<=10;i++){
		for(int j=1;j<=10;j++){
			if(t.m[j][i-1]){
				t=push(t,j,i);
			}
		}
	}
	for(int i=1;i<=10;i++){
		for(int j=1;j<=10;j++){
			if(t.m[j][i]){
				return 0;
			}
		}
	}
	for(int i=1;i<=10;i++){
		for(int j=1;j<=10;j++){
			cout<<t.l[j][i];
			if(j==10){
				cout<<endl;
			}
			else cout<<" ";
		}
	}
	
	return 1;
}

int main(){
	int n;cin>>n;
	while(n--){
		state tmp;
		for(int i=1;i<=10;i++){
			for(int j=1;j<=10;j++){
				cin>>tmp.m[j][i];
				tmp.l[j][i]=0;
			}
		}
		for(int i=0;i<=1023;i++){
			if(cal(tmp,i))break;
		}
	}
	
	return 0;
}


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

int main() {
int d;
  cin >> d;
  if(d == 24) cout << "Christmas Eve" << endl;
  if(d == 25) cout << "Christmas" << endl;
  if(d == 23) cout << "Christmas Eve Eve" << endl;
  if(d == 22) cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
import math
import sys
input = sys.stdin.readline


def main():
    sc = Scan()
    a, b = sc.intarr()
    count = 1
    index = 0
    while count < b:
        count += a-1
        index += 1

    print(index)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()


Measured memory_bytes: 3064
N, M = map(int, input().split())
solve_problem = set()
WA = [0 for _ in range(N)]

ans = 0
penalty = 0

for i in range(M):
    p, S = input().split()
    if p in solve_problem:
        continue

    if S == 'AC':
        solve_problem.add(p)
        ans += 1
        penalty += WA[int(p)-1]
    if S == 'WA':
        WA[int(p)-1] += 1

print('{} {}'.format(ans, penalty))



Measured memory_bytes: 14852
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
A = list(map(int, input().split()))
minv, maxv = min(A), max(A)
mini, maxi = -1, -1

for i in range(N):
    if minv == A[i]:
        mini = i
    if maxv == A[i]:
        maxi = i

if minv * maxv >= 0:
    print(N - 1)
    if minv >= 0:
        for i in range(N - 1):
            print(i + 1, i + 2)
    else:
        for i in range(N, 1, -1):
            print(i, i - 1)
else:
    print(2 * N - 1)
    if abs(minv) < abs(maxv):
        for i in range(N):
            print(maxi + 1, i + 1)
        for i in range(N - 1):
            print(i + 1, i + 2)
    else:
        for i in range(N):
            print(mini + 1, i + 1)
        for i in range(N, 1, -1):
            print(i, i - 1)


Measured memory_bytes: 9512
a,b,c,d,e,f=map(int,input().split())
w_m=int((f*100/(100+e)))//100*100
s_m=f*e//(100+e)
answ=100*a
anss=0
for i in range(w_m//(a*100)+1):
    for j in range((w_m-i*a*100)//(b*100)+1):
        w=(i*a+j*b)*100
        if i==0 and j==0:
            w=min(100*a,100*b)
            s_m=f-w
        for k in range(s_m//c+1):
            for l in range((s_m-k*c)//d+1):
                s=k*c+l*d
                if (anss*(s+w)<s*(anss+answ)) and (s*(100+e)<=e*(s+w)):
                    answ=w
                    anss=s
print(answ+anss,anss)


Measured memory_bytes: 42220
#include <iostream>
#include <vector>
#include <cmath>
int main(){
  int n = 0,min = __INT_MAX__ ,t = 1;
  int sum = 0;
  std::cin >> n;
  std::vector<int> balls(n);

  for(int i = 0; i < n; i++){
    std::cin >> balls[i];
    sum += balls[i];
  }
  const int all = sum;
  sum = 0;
  for(t = 1; t < balls.size();t++){
      sum += balls[t - 1];
      int temp = all - sum;
      if(min > abs(temp - sum)){
        min = abs(temp - sum);
      }
  }
  std::cout << min;    
}

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

int main(){
    int elementNumber, *numberArray;
    // read input
    scanf("%d\n",&elementNumber);
    numberArray = ( int* )malloc( elementNumber*sizeof( int ));
    for ( int ixArray = 0 ; ixArray < elementNumber ; ixArray++ ){
        scanf("%d",&numberArray[ixArray]);
        if ( ixArray == elementNumber-1 ) printf("%d\n",numberArray[ixArray]); // print result of initial step
        else printf("%d ",numberArray[ixArray]);
    }
    // sort in ascending order
    for (int jxArray = 1 ; jxArray < elementNumber ; jxArray++ ){        
        int keyNumber = numberArray[jxArray];
        int ixArray = jxArray-1;
        while ( ixArray >= 0 && numberArray[ixArray] > keyNumber ){
            numberArray[ixArray+1] = numberArray[ixArray];
            ixArray = ixArray-1;
        }
        numberArray[ixArray+1] = keyNumber;
        //print result after each step
        for ( int kxArray = 0 ; kxArray < elementNumber ; kxArray++ ){
            if ( kxArray == elementNumber-1 ) printf("%d\n",numberArray[kxArray]);
            else printf("%d ",numberArray[kxArray]);
        }
    }
    free(numberArray);
    return EXIT_SUCCESS;
}



Measured memory_bytes: 2040
#!/usr/local/bin/python3

N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

cont = 0
for d1, d2 in D:
    if d1 == d2:
        cont += 1
    else:
        cont = 0
    if cont >= 3:
        print('Yes')
        exit()
print('No')
exit()


Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	string s;
	cin >> s;
	vector<int> ans(s.size(), 0);
	int addr = 0, index = -1;
	s += "R";
	rep2(i, 1, s.size()){
		if(s[i-1] != s[i]){
			if(s[i-1] == 'R'){
				addr = i-1;
				ans.at(addr) += (i-index)/2;
				ans.at(addr+1) += (i-1-index)/2;
			}else{
				ans.at(addr+1) += (i-index)/2;
				ans.at(addr) += (i-1-index)/2;
			}
			index = i-1;
		}
	}
	rep(i, ans.size()){
		if(i != 0) cout << " ";
		cout << ans.at(i);
	}
	cout << endl;
	return 0;
}

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

int main() {
    int D, T, S; cin >> D >> T >> S;
    int x = S * T;
    if(x >= D){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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 dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
ll a[100100];
ll ans=0;
int co=2;
int main(){
	cin>>n;
	REP(i,n)cin>>a[i];
	ans+=a[0]-1;
	FOR(i,1,n){
		if(a[i]==co){
			co++;
		}else if(a[i]>co){
			int t2=a[i]-1;
			ans+=(ll)t2/co;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
/*input
5
1 2 3 4 5
*/
#include<bits/stdc++.h>
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long n,m,k;
	cin>>n>>m>>k;
	cout<<min(n*m,k);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    int c=0,i;
    cin>>s>>t;
    for(i=0;i<3;i++)
    {
        if(s[i]==t[i])
            c++;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3628
n=int(input())
b=list(map(int,input().split()))
total=0
pre=0
for i in range(n):
  if i==0:
    total+=b[0]
  elif i==n-1:
    total+=b[n-2]
  else:
    total+=min(b[i-1],b[i])
print(total)

Measured memory_bytes: 3060
alp = "abcdefghijklmnopqrstuvwxyz"
s = input()
if len(s) < 26:
  for x in alp:
    if x not in s:
      print(s+x)
      break
elif s == alp[::-1]:
  print(-1)
else:
  for i in range(24,-1,-1):
    for j in range(25,i,-1):
      if s[i] < s[j]:
        print(s[:i]+s[j])
        exit()

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,m,flag=1,i;
    char s[100];
    scanf("%d%d",&a,&b);
    getchar();
    scanf("%s",s);
    if(strlen(s)==a+b+1)
    {
        for(i=0; i<strlen(s); i++)
        {
            if(i<a&&!(s[i]>='0'&&s[i]<='9'))
            {
                flag=0;
                break;
            }
            if(i==a&&s[i]!='-')
            {
                flag=0;
                break;
            }
            if(i>a&&!(s[i]>='0'&&s[i]<='9'))
            {
                flag=0;
                break;
            }
        }
    }
    else flag=0;
    if(flag) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256