akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define si(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using pll = pair<ll,ll>;
using psi = pair<string,int>;
using pis = pair<int,string>;
using vl = vector<ll>;
using vs = vector<string>;


int main() {
	itn N;
  in(N);
  vl A(N);
        rep(i,N) in(A[i] ) ;
  ll ans = pow(3,N);
  int s = 1;
  rep(i,N){
   if(A[i] %2 == 0) s *= 2;
  }
  out(ans - s);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int re = 0,ch = getchar();
    while(!isdigit(ch))ch = getchar();
    while(isdigit(ch))re = (re<<1)+(re<<3)+ch-'0',ch = getchar();
    return re;
}
const int maxn = 200010;
struct edge{
    int v,w,nxt;
}e[maxn];
int h[maxn],cnt;
inline void add(int u,int v,int w){
    e[++cnt].v = v;
    e[cnt].w = w;
    e[cnt].nxt = h[u];
    h[u] = cnt;
}
inline int color(int c){
    if(c >= 3)c -= 3;
    if(c < 0)c += 3;
    return c;
}
int col[maxn],cnum[3],nsz,esz;
bool flag = 1,vis[maxn];
void coloring(int u){
    cnum[col[u]]++;nsz++;vis[u] = 1;
    for(int i = h[u];i;i = e[i].nxt){
        int v = e[i].v;
        if(e[i].w == 1)esz++;
        if(!vis[v]) col[v] = color(col[u] + e[i].w),coloring(v);
        else if(col[v] != color(col[u] + e[i].w)) flag = 0;
    }
}
int n,m;
long long ans;
int main(){
    n = read(),m = read();
    int u,v;
    for(int i = 1;i <= m;i++){
        u = read(),v = read();
        add(u,v,1);
        add(v,u,-1);
    }
    for(int i = 1;i <= n;i++){
        if(vis[i])continue;
        memset(cnum,0,sizeof(cnum));
        nsz = 0,esz = 0,flag = 1;
        coloring(i);
        if(!flag) ans += (long long)nsz * nsz;
        else if(cnum[0] && cnum[1] && cnum[2]) 
            ans += (long long)cnum[0] * cnum[1]
             + (long long)cnum[1] * cnum[2] + (long long)cnum[2] * cnum[0];
        else ans += esz;
    }
    printf("%lld",ans);
    return 0;
} 

Measured memory_bytes: 6656
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int K = sc.nextInt();

		int[] n = new int[N];

		for (int i = 0; i < K; i++){

			int d = sc.nextInt();

			for (int j = 0; j < d; j++){

				int su = sc.nextInt() - 1;

				n[su] = 1;
			}
		}

		int sum = 0;
		for (int sunu : n){
			if (!(sunu==1))
				sum ++;
		}

		System.out.println(sum);

	}

}


Measured memory_bytes: 46396
import sys
from collections import deque

input = sys.stdin.readline
h, w = map(int, input().rstrip("\n").split())
matrix = [[-1 for j in range(w)] for i in range(h)]
queue = deque()
for i in range(h):
    cells = list(input().rstrip("\n"))
    for j, cell in enumerate(cells):
        if cell == "#":
            matrix[i][j] = 0
            queue.append((i, j))
while queue:
    i, j = queue.popleft()
    for i_diff, j_diff in [(-1, 0), (0, -1), (0, 1), (1, 0)]:
        i_current = i + i_diff
        j_current = j + j_diff
        if (
            0 <= i_current < h
            and 0 <= j_current < w
            and matrix[i_current][j_current] == -1
        ):
            matrix[i_current][j_current] = matrix[i][j] + 1
            queue.append((i_current, j_current))

max_step = max([max(row) for row in matrix])
print(max_step)

Measured memory_bytes: 116212
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int m = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= d; j++) {
                if (2 <= (j / 10) && 2 <= (j % 10) && ((j / 10) * (j % 10) == i)) {
                    result++;
                }
            }
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)//rep(i,回数){処理}
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
	//入力
	int n, m, k; cin >> n >> m >> k;
	vector<int> a(n);
	vector<int> b(m);
	rep(i, n)cin >> a[i];
	rep(i, m)cin >> b[i];
	//計算
	ll t = 0;
	rep(i, m) t += b[i];
	int j = m; int ans = 0;
	rep(i, n + 1) {
		while (j > 0 && t > k) {
			--j;t -= b[j];
		}
		if (t > k) { break; }
		ans = max(ans, i + j);
		if (i == n) { break; }
		t = t + a[i];
	}
	//答えを出力
	cout << ans << endl;
	return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll n,m,s,t;
vector<P> g[101010];
ll dist[100100];

int main(){
  cin>>n>>m>>s>>t;
  s--; t--;
  rep(i,m){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;b--;c--;
    g[a].push_back(P(b,d));
    g[b].push_back(P(a,d));
    g[b].push_back(P(c,d));
    g[c].push_back(P(b,d));
    g[a].push_back(P(c,d));
    g[c].push_back(P(a,d));
  }
  priority_queue<P,vector<P>,greater<P> > que;
  que.push(P(0,s));
  rep(i,n)dist[i]=INF;
  while(que.size()){
    P p = que.top(); que.pop();
    if(dist[p.se]!=INF)continue;
    dist[p.se]=p.fi;
    for(P e : g[p.se]){
      que.push(P(e.se+p.fi,e.fi));
    }
  }
  cout<<dist[t]<<endl;
  return 0;
}



Measured memory_bytes: 37960
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define endl "\n"
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
void shikhar7s(int cas)
{
    int n,i,j,c=0,ans1=0,ans2=0;
    cin>>n;
    int p[n],q[n];
    int fac[10];
    fac[0]=1;
    for(i=1;i<10;i++)
    {
        fac[i]=i*fac[i-1];
        //cout<<i<<" "<<fac[i]<<endl;
    }
    fr(i,n)
    {
        cin>>p[i];
    }
    fr(i,n)
    {
        cin>>q[i];
    }
    int vis[n+1]={0};
    fr(i,n)
    {
        c=0;
        for(j=1;j<p[i];j++)
        {
            if(vis[j]==0)
                c++;
        }
        //cout<<c<<" "<<i<<endl;
        vis[p[i]]=1;
        ans1+=c*fac[n-i-1];
    }
    //cout<<ans1<<endl;
    fr(i,n+1)
    vis[i]=0;
    fr(i,n)
    {
        c=0;
        for(j=1;j<q[i];j++)
        {
            if(vis[j]==0)
                c++;
        }
        vis[q[i]]=1;
        ans2+=c*fac[n-i-1];
    }
    cout<<abs(ans2-ans1);
}
signed main()
{
    fast;
    int t=1;
    //cin>>t;
    int cas=1;
    while(cas<=t)
    {
    shikhar7s(cas);
    cas++;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll a[maxn],pre[maxn],q;
map <ll,int> p;

int main()
{
	ll n,x,m; cin>>n>>q>>m; a[1]=q; pre[1]=a[1]; p[a[1]]=1;
	for(int i=2;i<=n;i++)
	{
		a[i]=(a[i-1]*a[i-1])%m;
		if(p[a[i]])
		{
			int x=p[a[i]];
			
			
			ll tmp=(n-i+1)/(i-x);
			ll ans=pre[i-1];
			ll p2=pre[i-1]-pre[x-1];
			ans+=p2*tmp;
			
			tmp=(n-i+1)%(i-x);
			ans+=pre[x+tmp-1]-pre[x-1];
			
			cout<<ans<<endl;
			return 0;
		}
		p[a[i]]=i;
		pre[i]=pre[i-1]+a[i];
	}
	cout<<pre[n]<<endl;
	return 0;
}

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


void solve(string S){
    string a;
    (S[0]==S[1] or S[1]==S[2] or S[2]==S[3])?a="Bad":a="Good";
    cout<<a<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    string S;
    cin>>S;
    solve(S);
    return 0;
}


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

int k, n, d, mx, a[200005];
int main() {
	int i;
	cin >> k >> n;
	for(i=1; i<=n; i++) scanf("%d", &a[i]);
	a[0] = a[n] - k;
	a[n+1] = a[1] + k;
	for(i=1; i<=n; i++) {
		mx = max(mx, max(a[i+1] - a[i], a[i] - a[i-1]));
	}
	cout << k- mx;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
int N,A,B;
  
  scanf("%d",&N);
  
  if(N==1)
    printf("Hello World\n");
 
  scanf("%d",&A);
  scanf("%d",&B);
  
  if(N==2){
    printf("%d",A+B);
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
/*
n以下の数がちょうどk個であるような集合で、数値の和がsになるのは何通り？
1<=n<=20
1<=k<=10
1<=s<=155
*/
int d[200][200][200];
int dfs(int n,int k,int s){
	if(n<0||k<0||s<0)return 0;
	if(d[n][k][s]!=-1)return d[n][k][s];
	int ans=dfs(n-1,k-1,s-n)+dfs(n-1,k,s);
	return d[n][k][s]=ans;
}
int main(){
	memset(d,-1,sizeof(d));
	d[0][0][0]=1;
	for(int n,k,s;cin>>n>>k>>s,n;)cout<<dfs(n,k,s)<<endl;
}


Measured memory_bytes: 32416
using System;

namespace ALDS1_2_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');

            if (num == 1)
            {
                Console.WriteLine(str[0]);
                Console.WriteLine("0");
                return;
            }


            int[] input = new int[(num+1)];

            for (int i=0; i<num; i++)
            {
                input[i + 1] = int.Parse(str[i]);
            }

            input[0] = 0;
            int flag = 1;
            while (flag == 1)
            {
                flag = 0;

                for (int i=num; i>=2; i--)
                {
                    if (input[i] < input[i-1])
                    {
                        int tmp = input[i];
                        input[i] = input[i - 1];
                        input[i - 1] = tmp;
                        flag = 1;
                        input[0]++;
                    }
                }
            }

            for (int i=1; i<=num; i++)
            {
                if (i != num)
                {
                    Console.Write("{0} ", input[i]);
                }
                else
                {
                    Console.Write(input[i]);
                }
            }
            Console.WriteLine();
            Console.WriteLine(input[0]);
        }
    }
}

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

using namespace std;
const int N = 100 + 3;
char buffer[N];
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
	int n;
	scanf("%d", &n);
	pair<string, pair<int, int>> p[N];
	for (int i = 0; i < n; ++i) {
		int a;
		scanf("%s %d", buffer, &a);
		p[i] = {buffer, make_pair(-a, i + 1)};
	}
	sort(p, p + n);
	for (int i = 0; i < n; ++i)
		printf("%d\n", p[i].second.second);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

const int INF = 1e8;

const int MAX_V = 100005;

void dfs(int used[MAX_V], int cur, int g[MAX_V], int a[MAX_V], bool loop_check[MAX_V]){
    vector<int> v;
    while(true){
        //show(v.size())
        //show(cur)
        //    show(used[cur])
        if(a[cur] == 0){ //????????\????§??????§?????????
            g[cur] = cur;
            used[cur] = 1;
            for(auto it:v){
                g[it] = cur;
                used[it] = 1;
            }
            break;
        }else if(loop_check[cur]){//HoI!!! ???????????????!!!!!
            //show("heiro")
            for(auto it:v){
                g[it] = INF;
                used[it] = 1;
            }
            break;
        }
        loop_check[cur] = true;
        v.emplace_back(cur);
        cur = cur + a[cur];
    }
}

int bfs(int n, int g[MAX_V]){
    int dis[MAX_V]; //?????¢
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
    rep(i,MAX_V) dis[i] = INF;

    dis[0] = 0;
    q.push(make_pair(0,0));

    pair<int, int> u;
    while(!q.empty()){
        u = q.top(); q.pop();
        int c = u.second;
        for(int j = 6; j >= 1; j--){
            if(c + j >= n) continue;
            if(g[c + j] == INF) continue;
            if(dis[ g[c + j] ] > dis[c] + 1){
                dis[g[c + j]] = dis[c] + 1;
                q.push(make_pair(dis[c] + 1, g[c + j]));
            }
        }
    }
    //rep(i,n) show(dis[n])
    return dis[n - 1];
}

int main(){
    int n;
    cin >> n;
    int a[MAX_V];
    rep(i,n) cin >> a[i];

    int used[MAX_V] = {0};
    int g[MAX_V];
    rep(i,n){
        //show(i)
        bool tmp[MAX_V] = {0};
        if(used[i]) continue;
        dfs(used,i,g,a,tmp);
    }
    //rep(i,n){ cout << g[i] << endl; }

    //int dp[MAX_V];
    //rep(i,n) dp[i] = INF;
    //while(true){
    //    bool f = false;
    //    rep(i,n){
    //        range(j,1,7){
    //            if(g[i + j] == INF) continue;
    //            if(dp[ g[i + j] ] > dp[i] + 1){
    //                f = true;
    //                dp[ g[i + j] ] = dp[i] + 1;
    //            }
    //        }
    //    }
    //}

    cout << bfs(n,g) << endl;

}

Measured memory_bytes: 4856
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var s = o.a(1);
  var a = [];
  for(var i = n; i--;){
    if(s[i] === "0")a.push(i);
  }
  var ans = [];
  var x = n;
  for(var i = 0; i < a.length; i++){
    if(x-a[i] > m)return -1;
    while(i < a.length-1 && x-a[i+1] <= m)i++;
    ans.push(x-a[i]);
    x = a[i];
  }
  return ans.reverse().join(" ");
}

Measured memory_bytes: 21192
s = input()
t = input()
a = len(s)
b = len(t)
ans = []
#後ろから検索して残りをaで埋める
for i in range(1+a-b):
  query = s[a-b-i:a-i] 
  #print(query)
  ct= 0
  for j in range(b):
    if t[j] == query[j] or query[j] == '?':
      ct += 1
  if ct == b:
    ans.append(s[0:a-b-i]+t+s[a-i::])
if ans ==[] : print('UNRESTORABLE')
else:print(min(ans).replace('?','a'))

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

long long h, w, hbit, wbit;

long long S(long long lh, long long lw) {
	return lw * lh;
}

long long diff(long long s1, long long s2, long long s3) {
	return max(max(s1, s2), s3) - min(min(s1, s2), s3);
}

void refresh() {
	hbit = h;
	wbit = w;
}

void cor1(int i) {
	if (i == 0)
		hbit -= hbit / 3;
	else
		wbit -= wbit / 3;
}

void cor1A(int i) {
	if (i == 0)
		hbit -= hbit / 3 + 1;
	else
		wbit -= wbit / 3 + 1;
}

void cor2(int i) {
	if (i == 0)
		hbit -= hbit / 2;
	else
		wbit -= wbit / 2;
}

long long cuth1(int i) {
	if (i == 0)
		return hbit / 3;
	else
		return hbit;
}

long long cuth1A(int i) {
	if (i == 0)
		return hbit / 3 + 1;
	else
		return hbit;
}

long long cuth2(int i) {
	if (i == 0)
		return hbit / 2;
	else
		return hbit;
}

long long cutw1(int i) {
	if (i == 1)
		return wbit / 3;
	else
		return wbit;
}

long long cutw1A(int i) {
	if (i == 1)
		return wbit / 3 + 1;
	else
		return wbit;
}

long long cutw2(int i) {
	if (i == 1)
		return wbit / 2;
	else
		return wbit;
}

int main() {

	cin >> h >> w;

	long long mini = h * w;

	long long s1, s2, s3;

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			refresh();
			s1 = S(cuth1(i), cutw1(i));
			cor1(i);
			s2 = S(cuth2(j), cutw2(j));
			cor2(j);
			s3 = S(hbit, wbit);
			if (diff(s1, s2, s3) < mini) mini = diff(s1, s2, s3);
		}
	}

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			refresh();
			s1 = S(cuth1A(i), cutw1A(i));
			cor1A(i);
			s2 = S(cuth2(j), cutw2(j));
			cor2(j);
			s3 = S(hbit, wbit);
			if (diff(s1, s2, s3) < mini) mini = diff(s1, s2, s3);
		}
	}

	cout << mini << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
typedef long long ll;
const int INF = 1e9 + 7;
using namespace std;

int main(){
    int N,K; cin >> N >> K;
    vector <int> A(N);
    rep(i,N) cin >> A[i];
    sort(A.begin(),A.end(),greater<int>());//昇順
    
    ll sum=0;
    FOR(i,K,N-1){
        sum+=A[i];
    }
    cout << sum;    
}

Measured memory_bytes: 1024
s = list(input())
q = int(input())
query = [list(input().split()) for i in range(q)]

addPlace = 1
frontlist=[]
endlist=[]
for i in range(len(query)):
    if query[i][0] == "1":
        addPlace = -1 * addPlace
    else:
        if (query[i][1] == "1" and addPlace == 1) or (query[i][1] == "2" and addPlace == -1):
            frontlist.append(query[i][2])
        else:
            endlist.append(query[i][2])
s = frontlist[::-1] + s + endlist
if addPlace == 1:
    print("".join(s))
else:
    print("".join(s[::-1]))

Measured memory_bytes: 36584
#include <stdio.h>
#include <string.h>
#include <math.h>
typedef long long ll;

int SquareNumber(int);

int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	char c[10000];
	snprintf(c, 10000, "%d%d", a, b);
	int answer = SquareNumber(atoi(c));
	if (answer == 0)
		printf("No\n");
	else
		printf("Yes\n");	
	return 0;
}

int SquareNumber(int number) {
	int v = (int)sqrt((double)number);
	if (v * v == number)
		return v;
	else
		return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>

using namespace std;

typedef long long ll;

const ll prime = 10000000000 + 7;
const double PI = 3.14159265358979323846;

/*
vector<int> z_algorithm(const string& s) {
	vector<int> prefix(s.size());
	for (int i = 1, j = 0; i < s.size(); i++)
	{
		if (i + prefix[i - j] < j + prefix[j]) {
			prefix[i] = prefix[i - j];
		}
	}
}
*/

struct UnionFind {
	vector<ll> par;
	vector<ll> rank;

	UnionFind(ll n) {
		par = vector<ll>(n);
		rank = vector<ll>(n);
		for (ll i = 0; i < n; i++)
		{
			par[i] = i;
			rank[i] = 0;
		}
	}

	ll root(ll x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return root(par[x]);
		}
	}

	bool is_same(ll x, ll y) {
		return (root(x) == root(y));
	}

	void connect(ll x, ll y) {
		if (!is_same(x, y)) {
			ll x1, y1;
			x1 = root(x);
			y1 = root(y);
			if (rank[x1] < rank[y1]) {
				par[x1] = y1;
			}
			else if (rank[x1] > rank[y1]) {
				par[y1] = x1;
			}
			else {
				par[x1] = y1;
				rank[y1]++;
			}
		}
	}
};

int main() {

	ll n, k;
	cin >> n >> k;
	vector<ll> a(n), f(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (ll i = 0; i < n; i++)
	{
		cin >> f[i];
	}
	sort(f.begin(), f.end(), greater<ll>());

	ll ok, ng;
	ok = ll(1) << 60;
	ng = 0;
	ll m;

	ll sum = 0;
	ll num;

	while (ok - ng > 1) {
		sum = 0;
		m = (ok + ng) / 2;
		for (ll i = 0; i < n; i++)
		{
			if (a[i] * f[i] > m) {
				sum += a[i] - (m / f[i]);
			}
		}
		if (sum <= k) {
			// ok
			ok = m;
		}
		else {
			ng = m;
		}
	}

	sum = 0;
	for (ll i = 0; i < n; i++)
	{
		sum += a[i];
	}
	if (sum <= k) {
		ok = 0;
	}

	cout << ok << endl;

	return 0;
}

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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

Int memo[200001];
Int par[200001];
vector<Int> G[200001];

Int dfs(Int x) {
    if (memo[x] >= 0) {
        return memo[x];
    }
    Int ret = G[x].size();
    for (Int i = 0; i < (Int)G[x].size(); i++) {
        ret += dfs(G[x][i]);
    }
    return memo[x] = ret;
}

int main() {
    Int n;
    cin >> n;
    for (Int i = 2; i <= (Int)n; i++) {
        cin >> par[i];
        G[par[i]].push_back(i);
    }
    for (Int i = 1; i <= (Int)n; i++) {
        print(G[i].size());
    }
    return 0;
}

Measured memory_bytes: 16076
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int t = 0;
		for (int i = 0; i < 4; i++) {
			t += sc.nextInt();
		}
		System.out.println(t / 60);
		System.out.println(t % 60);
	}
}


Measured memory_bytes: 26116
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef long long LL;
vector<LL> inverse_list(LL n, LL p){
    vector<LL> inv(n + 1);
    inv[1] = 1;
    for (int i = 2; i <= n; ++i){
        inv[i] = inv[p % i] * (p - p / i) % p;
    }
    return inv;
}

int main(){
    LL N, M, K;
    const LL MOD = 1000000007;
    const LL MAX = 300000;
    vector<LL> inv = inverse_list(MAX, MOD);
    vector<LL> fact(MAX, 1);
    vector<LL> factinv(MAX, 1);
    for(int i = 1; i < MAX; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        factinv[i] = factinv[i - 1] * inv[i] % MOD;
    }
    auto conb = [&](LL a, LL b) -> LL {
        if(b < 0) return 0;
        assert(a < MAX && a >= 0);
        assert(b < MAX && b >= 0);
        assert(a - b < MAX && a - b >= 0);
        LL res = fact[a];
        res = res * factinv[b] % MOD;
        res = res * factinv[a - b] % MOD;
        return res;
    };
    cin >> N >> M >> K;
    LL ans = 0;
    for(LL k1 = 0; k1 <= K; k1++) {
        LL k2 = K - k1;
        LL res = (conb(N + 2 * k1, k1) - conb(N + 2 * k1, k1 - 1) + MOD)
            * (conb(M + 2 * k2, k2) - conb(M + 2 * k2, k2 - 1) + MOD) % MOD
            * conb(N + M + 2 * K, N + 2 * k1) % MOD;
        ans = (ans + res) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8132
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int n;
	cin >> n;
	ll a[n];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	bool p=true;
	//3つの異なる帽子のXORが0になる && それぞれN/3枚である
	sort(a,a+n);
	if(n%3==0){
		//3つがそれぞれ相異なる OR 全て0ならtrue それ以外はfalse
		if(a[0]!=a[n/3-1] || a[n/3]!=a[2*n/3-1] || a[2*n/3]!=a[n-1]) p=false;
		ll tmp=a[2*n/3]^a[0];
		if(a[n/3]!=tmp) p=false;
	}else if(a[n-1]==0){
		p=true;
	}else{
		p = false;
	} 
	
	if(p) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1024
x = int(input())

if 400 <= x <= 599:
    print(8)
if 600 <= x <= 799:
    print(7)
if 800 <= x <= 999:
    print(6)
if 1000 <= x <= 1199:
    print(5)
if 1200 <= x <= 1399:
    print(4)
if 1400 <= x <= 1599:
    print(3)
if 1600 <= x <= 1799:
    print(2)
if 1800 <= x <= 1999:
    print(1)

Measured memory_bytes: 9188
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=3e5+10;
struct node {
	int x,y;
}a[N];
int n,W,H;
int ql,qr,qt;
namespace tr {
	const int M=N*4;
	int tg[M],mx[M];
	inline void add(int c,int t) { mx[c]+=t,tg[c]+=t; }
	inline void push_down(int c) { if(tg[c]) add(c<<1,tg[c]),add(c<<1|1,tg[c]),tg[c]=0; }
	inline void push_up(int c) { mx[c]=max(mx[c<<1],mx[c<<1|1]); }
	void build(int l,int r,int c) {
		tg[c]=0;
		if(l==r) return (void)(mx[c]=2*a[l+1].x+2*H);
		int mid=l+r>>1;
		build(l,mid,c<<1),build(mid+1,r,c<<1|1);
		push_up(c);
	}
	void add(int l,int r,int c) {
		if(ql<=l&&qr>=r) return add(c,qt);
		int mid=l+r>>1; push_down(c);
		if(ql<=mid) add(l,mid,c<<1);
		if(qr>mid) add(mid+1,r,c<<1|1);
		push_up(c);
	}
	int query(int l,int r,int c) {
		if(ql<=l&&qr>=r) return mx[c];
		int mid=l+r>>1,ans=-1e9; push_down(c);
		if(ql<=mid) ans=max(ans,query(l,mid,c<<1));
		if(qr>mid) ans=max(ans,query(mid+1,r,c<<1|1));
		return ans;
	}
	void debug(int l,int r,int c) {
		if(l==r) return (void)(printf("%d ",mx[c]));
		int mid=l+r>>1; push_down(c);
		debug(l,mid,c<<1),debug(mid+1,r,c<<1|1);
	} 
}
int ans;
bool cmp(node A,node B){ return A.x<B.x; }
int stk1[N],top1;
int stk2[N],top2;
int lim;
void push(int p) {
//	cerr<<"push:"<<p<<' '<<a[p].y<<endl;
	if(a[p].y<=lim) {
		ql=p,qr=stk1[top1]-1,qt=-2*a[p].y;
		tr::add(1,n,1);
		while(top1&&a[stk1[top1]].y<=a[p].y) {
			ql=stk1[top1],qr=stk1[top1-1]-1,qt=2*(a[stk1[top1]].y-a[p].y);
//			cerr<<"upd:"<<p<<' '<<ql<<' '<<qr<<' '<<qt<<endl;
			tr::add(1,n,1);
			top1--;
		}
		stk1[++top1]=p;
	}
	else {
		ql=p,qr=stk2[top2]-1,qt=2*a[p].y-2*H;
		tr::add(1,n,1);
		while(top2&&a[stk2[top2]].y>=a[p].y) {
			ql=stk2[top2],qr=stk2[top2-1]-1,qt=2*(a[p].y-a[stk2[top2]].y);
//			cerr<<"upd:"<<p<<' '<<ql<<' '<<qr<<' '<<qt<<endl;
			tr::add(1,n,1);
			top2--;
		}
		stk2[++top2]=p;
	}
}
void sol() {
	sort(a+1,a+n+1,cmp);
	a[n+1].x=W;
	tr::build(1,n,1);
	stk1[top1=0]=n+1;
	stk2[top2=0]=n+1;
	int p=n;
	while(p>=1) {
		ql=p,qr=n;
		ans=max(ans,tr::query(1,n,1)-2*a[p].x);
//		cerr<<p<<':'; tr::debug(1,n,1); puts("");
		push(p--);
	}
}
int main() {
	rd(W),rd(H),rd(n);
	for(int i=1;i<=n;++i) rd(a[i].x),rd(a[i].y);
	ans=2*(max(W,H)+1);
	a[++n]=(node){W,H};
	a[++n]=(node){W,0};
	a[++n]=(node){0,H}; 
	lim=H/2; sol();
//	lim=H/2+1; sol();
//	lim=H/2-1; sol();
	for(int i=1;i<=n;++i) swap(a[i].x,a[i].y);
	swap(W,H);
	lim=H/2; sol();
//	lim=H/2+1; sol();
//	lim=H/2-1; sol();
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 12800
#pragma GCC optimize("Ofast","inline")
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define next Next
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=200005*2;
int n;
LL k;
int a[N];
int las[N],nxt[N];
int go[N][60];
LL cnt[N][60];
int main(){
	n=read(),k=read();
	For(i,1,n)
		a[i]=a[i+n]=read();
	For(i,1,n*2){
		if (las[a[i]])
			nxt[las[a[i]]]=i;
		las[a[i]]=i;
	}
	For(i,1,n){
		if (nxt[i]<n){
			go[i][0]=nxt[i]+1;
			cnt[i][0]=0;
		}
		else {
			go[i][0]=nxt[i]%n+1;
			cnt[i][0]=nxt[i]==n+n?2:1;
		}
	}
	For(j,1,59){
		For(i,1,n){
			go[i][j]=go[go[i][j-1]][j-1];
			cnt[i][j]=cnt[i][j-1]+cnt[go[i][j-1]][j-1];
		}
	}
	k--;
	int p=1;
	Fod(i,59,0)
		if (cnt[p][i]<=k){
			k-=cnt[p][i];
			p=go[p][i];
		}
	if (k>0&&p==n&&nxt[p]==n+n)
		p=n+1,k--;
	vector <int> ans;
	while (p<=n){
		if (nxt[p]<=n){
			p=nxt[p]+1;
		}
		else {
			ans.pb(a[p]);
			p++;
		}
	}
	for (auto i : ans)
		printf("%d ",i);
	return 0;
}

Measured memory_bytes: 151156
#include<iostream>

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = a + b;
    if (a + c < ans){
        ans = a + c;
    }
    if (b + c < ans){
        ans = b + c;
    }
    cout << ans;
    return 0;
}



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

class P
{
	public:
	int x,y;
	P(int X,int Y)
	{
		x=X;
		y=Y;
	}
};

int main()
{
	int set[2]={1,-1};
	char field[52][52]={""};

	while(cin>>field[1])
	{
		int flag[52][52]={0};
		stack<P> st;
		int ans=0;
		
		for(int i=2;i<=12;i++)
		{
			cin>>field[i];		
		}

		for(int i=1;i<=12;i++)
		{
			for(int j=0;j<12;j++)
			{
				if(field[i][j]!='1' || flag[i][j]==1)continue;
				st.push(P(j,i));
				flag[i][j]=1;
				ans++;

				while(!st.empty())
				{
					int x2=st.top().x;
					int y2=st.top().y;
					st.pop();

					for(int k=0;k<2;k++)
					{
						if(field[y2+set[k]][x2]!='1' ||flag[y2+set[k]][x2]==1)continue;
						flag[y2+set[k]][x2]=1;
						st.push(P(x2,y2+set[k]));
					}
					for(int k=0;k<2;k++)
					{
						if(field[y2][x2+set[k]]!='1' ||flag[y2][x2+set[k]]==1 || (x2+set[k]<0))continue;
						flag[y2][x2+set[k]]=1;
						st.push(P(x2+set[k],y2));
					}
				}
			}
		}
		cout<<ans<<endl;
		ans=0;
	}
	return 0;
}

Measured memory_bytes: 1200
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N, X;
    scan(N, X);
    auto A = aryread();
    long ans;
    if (X < A[0])
    {
        ans = A[0] - X;
        A[0] = X;
    }
    // writeln(A);
    foreach (i; 0 .. N - 1)
    {
        if (X < A[i] + A[i + 1])
        {
            long s = A[i + 1] + A[i] - X;
            // writeln(s);
            A[i + 1] -= s;
            ans += s;

        }
    }
    writeln(ans);
}


Measured memory_bytes: 4348
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int a[105];

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
        cnt += a[i];
    }
    int ans = 0, nd = (cnt - 1) / (4 * m) + 1;
    for (int i = 0; i < n; i++) {
        if (a[i] >= nd) ans++;
    }
    if (ans < m)
        printf("No\n");
    else
        printf("Yes\n");
}

Measured memory_bytes: 1660
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;



void main() {
    int N;
    scan(N);
    auto a = iota(N).map!(i => readln.chomp.to!int).array;
    auto dp = new long[][](N + 1, 5);
    fillAll(dp, infl);
    dp[0][0] = 0;

    foreach (i ; 1 .. N + 1) {
        foreach (j ; 0 .. 5) {
            foreach (k ; 0 .. j + 1) {
                if (j == 0 || j == 4) {
                    chmin(dp[i][j], dp[i - 1][k] + a[i - 1]);
                }
                else if (j == 1 || j == 3) {
                    int x;
                    if (a[i - 1] == 0) {
                        x = 2;
                    }
                    else {
                        x = a[i - 1] %  2;
                    }
                    chmin(dp[i][j], dp[i - 1][k] + x);
                }
                else if (j == 2) {
                    chmin(dp[i][j], dp[i - 1][k] + (a[i - 1] + 1) % 2);
                }
            }
        }
    }

    auto ans = dp[N].reduce!min;
    writeln(ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


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

double dp[3006][3007];
double p[3006];

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

  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  dp[n][0] = 1;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j <= n; j++) {
      if (j > 0)
        dp[i][j] += p[i]*dp[i + 1][j - 1];
      dp[i][j] += (1 - p[i])*dp[i + 1][j];
    }
  }
  double ans = 0;
  for (int j = 1 + (n/2); j <= n; j++) {
    ans += dp[0][j];
  }
  cout << fixed << setprecision(10) << ans << '\n';

  return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

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

  vector<int> count(N);
  for (int i = 0; i < N; i++) {
    if (i > 0 && S[i - 1] == 'A' && S[i] == 'C') {
      count[i] = count[i - 1] + 1;
    } else {
      count[i] = count[i - 1];
    }
  }

  int l, r;
  for (int i = 0; i < Q; i++) {
    cin >> l >> r;
    l--;
    r--;

    int ans = count[r];
    if (l > 0) {
      ans -= count[l - 1];
      if (S[l] == 'C' && S[l - 1] == 'A') {
        ans--;
      }
    }
    cout << ans << endl;
  }

  return 0;
}


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

#define mod 1000000007

// F_mod 上でのべき乗, 蟻本p115
ll modPow(ll x, ll n) {
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

// Fermat の小定理を用いた F_mod 上での逆元計算x^(mod-2)
ll Inverse(ll x){
    return modPow(x, mod - 2);
}

// iの階乗 = fact[i], main内の階乗計算をする必要がある
#define MAX_FACT 20010
ll fact[MAX_FACT];

ll nCk(int n, int k){
    //　n_C_kの計算, Inverseの中身にもmodを入れないとオーバーフローするので注意, 蟻本p.263
    ll ans = fact[n] * Inverse(fact[k] * fact[n-k] % mod);
    ans %= mod;
    return ans;
}

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

    // 階乗計算
    fact[0]=1;
    for(int i = 1; i < MAX_FACT; ++i) {
        fact[i] = fact[i-1] * i % mod;
    }

    // K-i個の青玉とi-1個の仕切り
    // N-K-(i-1)個の赤玉とi個の仕切り
    for (int i = 1; i <= K; ++i) {
        if(N-K-i+1 < 0){
            cout << 0 << "\n";
        } else{
            ll ans = 0;
            ans = nCk(K-1, K-i);
            ans = ans * nCk(N-K+1, i);
            ans %= mod;
            cout << ans << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(unsigned i=0;i<n;i++)
#define repr(i,n) for(unsigned i=n-1;i>=0;i--)
#define rep1(i,n) for(unsigned i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define cins(s,n) rep(i,n)cin>>s.at[i];
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;


ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}
int Digits(unsigned x)
{
    int ans=0;
    while(x!=0)
    {
        x/=10;
        ans++;
    }
    return ans;
}
unsigned GetDigit(unsigned num){
    return to_string(num).length();
}


int main()
{
    cin.tie(0);
ios_base::sync_with_stdio(false);
int a,b,c;cin>>a>>b>>c;
b-a==c-b?cout<<"YES":cout<<"NO";
}    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main()
{   
    int n;
    cin>>n;
    long long a[n],ans=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        while(a[i]%2==0){
            a[i]/=2;
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
object Main extends App {
  val n = io.StdIn.readLine.toInt
  val arr = Iterator.continually(io.StdIn.readLine.split(" "))
    .take(n)
    .toArray
  val ans = (Array(Array("0","0","0")).toBuffer++arr)
    .zip(arr)
    .forall{case (cur, nex) => {
      val dt =nex(0).toInt - cur(0).toInt
      val dist = (nex(1).toInt - cur(1).toInt).abs +
                 (nex(2).toInt - cur(2).toInt).abs
      dt >= dist && (dist&1) == (dt&1)
    }}

  println(if(ans) "Yes" else "No")
}

Measured memory_bytes: 77760
#include <stdio.h>
int main(void){
    int i, j, k, width, height;
    for(i=0; i>=0; i++){
             scanf("%d\n", &width);
             scanf("%d\n", &height);
             if(width==0 && height==0) break;
        for (j=0; j<width; j++){
            for (k=0; k<height; k++){ 
                putchar('#');
            }
            putchar('\n');
        }
        putchar('\n');
    }  
}


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

int main(){
#define PII pair < int , int >
	int N; cin >> N; vector < PII > vec;
	int x , l; for(int i = 1 ; i <= N ; ++i){cin >> x >> l; vec.push_back(make_pair(x - l , x + l));}
	sort(vec.begin() , vec.end() , [&](PII x , PII y){return x.second < y.second;});
	int mnr = -2e9 - 7 , sum = 0;
	for(auto t : vec) if(t.first >= mnr){mnr = t.second; ++sum;}
	cout << sum; return 0;
}


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

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

  if (A >= N % 500) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
    // ここにプログラムを追記
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

const int mod = 1e9+7;
ll dp[2005][2005];
ll sum[2005][2005];

int main() {
    int n, m; cin >> n >> m;
    vector<int> s(n+1), t(m+1);
    rep(i,n) cin >> s[i+1];
    rep(i,m) cin >> t[i+1];

    REP(i,1,n+1)REP(j,1,m+1) {
        if (s[i]==t[j]) {
            dp[i][j] = sum[i-1][j-1]+1;
            dp[i][j] %= mod;
        }

        //sumには割った余りが入ってるから、↓のsum更新式における引き算によって、負の値になってしまい、
        //modをとるとおかしくなるケースが発生してしまう。それを防ぐため、更新式にmodを足しておく
        sum[i][j] = sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j]+mod; 
        sum[i][j] %= mod;
    }

    cout << (1+sum[n][m])%mod << endl;

}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
int table[365][26];
int main()
{	
	int D;
	cin >> D;
	vec(C);
	vec(Las);
	fx(26) {
		vecp(C);
		Las.push_back(0);
	}

	fx(D) {
		fy(26) {
			cin >> table[x][y];
		}
	}
	vector<int> T(D);
	int k = 0;
	fx(26) {
		if (k < table[0][x]) {
			T[0] = x+1;
			k = table[0][x];
		}
	}
	fx(D-1) {
		ll res = -LLONG_MAX;
		fy(26) {
			ll sum = 0;
			sum += table[x + 1][y];
			fz(26){
				if (y == z) { continue; }
				sum -= C[z] * (x + 1 - Las[z]);
			}

			if (res<sum) {
				res = sum;
				T[x + 1] = y+1;
			}
		}
	}
	fx(D) {
		ce(T[x])
	}
    return 0;
}



Measured memory_bytes: 3640
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1000010;
int a[N],mp[N];
int n;
int gcd(int a,int b)
{
    return b?gcd(b,a%b):a;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) 
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    bool ok=1;
    for(int i=2;i<N;i++)
    {
        int cnt=0;
        for(int j=i;j<N;j+=i) cnt+=mp[j];
        if(cnt>1)
        {
            ok=0;
            break;
        }
    }
    int d=a[1];
    for(int i=2;i<=n;i++) d=gcd(d,a[i]);
    if(ok) cout<<"pairwise coprime"<<endl;
    else if(d==1) cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
    return 0;
}

Measured memory_bytes: 11376
#include<bits/stdc++.h>
#define N 2009
using namespace std;
 
int m,n,ans,a[N][N],b[N][N],c[N],q[N],lf[N],rg[N];
char s[N];
int main(){
	scanf("%d%d",&m,&n);
	int i,j,k;
	for (i=1; i<=m; i++){
		scanf("%s",s+1);
		for (j=1; j<=n; j++) a[i][j]=(s[j]=='#');
	}
	for (i=1; i<=m; i++)
		for (j=2; j<=n; j++)
			b[i][j]=(a[i][j]^a[i+1][j])==(a[i][j-1]^a[i+1][j-1])?b[i-1][j]+1:0;
	for (i=1; i<=m; i++){
		for (j=2; j<=n; j++) c[j]=1+b[i-1][j];
		q[k=1]=1; c[1]=-2; c[n+1]=-1;
		for (j=2; j<=n+1; j++){
			for (; c[j]<=c[q[k]]; k--) rg[q[k]]=j;
			lf[j]=q[k]; q[++k]=j;
		}
		for (j=2; j<=n; j++)
			ans=max(ans,c[j]*(rg[j]-lf[j]));
	}
	printf("%d\n",max(ans,max(m,n)));
	return 0;
}

Measured memory_bytes: 31744
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
    long double a, b, c;

    cin >> a >> b >> c;
    long double d = c - a - b;

    if (d > 0 && (4 * a * b) < d * d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰回数の上限を変更
N,M=map(int,input().split())
P=list(map(int,input().split()))
G=[[] for _ in range(N)]
for i in range(M):
    x,y=map(int,input().split())
    x-=1
    y-=1
    G[x].append(y)
    G[y].append(x)

chk=[0 for _ in range(N)]

for i in range(N):
    if P[i]==(i+1):
        chk[i]=1

def uni(v,G,cnt,C):
    C[v]=cnt
    for tmp in G[v]:
        if C[tmp]!=0:
            continue
        uni(tmp,G,cnt,C)

C=[0 for _ in range(N)]
cnt=1
ans=0
for i in range(N):
    if C[i]!=0:
        continue
    uni(i,G,cnt,C)
    cnt+=1

for i in range(N):
    p=P[i]
    if chk[p-1]:
        ans+=1
        continue
    else:
        num=i
        val=p
        if C[i]==C[p-1]:
            ans+=1
print(ans)

Measured memory_bytes: 83812
#include <iostream>
#include <string>
#include <string.h>
using namespace std;



int main(){

    int N, X;
    cin >> N >> X;
    int L[N],sumL=0;
    for(int i=0;i<N;i++){
        cin >> L[i];
        //cout << L[i] << '\n';
    }

    int count=0;
    for(int i=0;i<=N;i++){
        if(X>=sumL)count++;
        sumL += L[i];
        //cout << sumL << ',';
        //cout << count << '\n';
    }

    cout << count << '\n';

    return 0;
}

//g++ ファイル名 --input-charset=utf-8 --exec-charset=cp932
//日本語出力するときのやつ

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, e;
  double c, d;
  d = 1.0;
  cin >> a >> b;
  c = d * (a + b) / 2 + 0.5;
  e = c;
  cout << e << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int twostr(string a,string b,string c,int s,int t){
	if (a == c){
		s--;
	}
	cout << s << " ";
	if (b == c){
		t--;
	}
	cout << t;
}
int main(){
	string s,t,th;
	int a,b;
	cin >> s >> t;
	cin >> a >> b;
	cin >> th;
	twostr(s,t,th,a,b);
	return 0;
}

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

int a[4001];

int main()
{
    for(int i = 0; i <= 1000; ++i){
        for(int j = 0; j <= 1000; ++j){
            a[i+j]++;
        }
    }
    
    int n;
    while(cin >> n){
        int ans = 0;
        for(int i = 0; i <= n; ++i){
            ans += a[i] * a[n-i];
        }
        cout << ans << endl;
    }
}

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

int main(){
    int P, Q, R;
    cin >> P >> Q >> R;

    int A = P + Q;
    int B = Q + R;
    int C = P + R;

    vector<int> vec;
    vec = {A, B, C};
    sort(vec.begin(), vec.end());

    cout << vec.at(0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1e9+7;
const int INF=1e9;
const ll LINF=(ll)1e18;

int main(){
    ll n,k;
    cin>>n>>k;
    int ans=0;
    while(n>0){
        n/=k;
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define Rep(i,v) rep(i,0,(int)v.size()-1)
#define mp make_pair
#define fir first
#define sec second
#define pb push_back
#define gc getchar()
#define lint long long
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
typedef pair<int,int> pii;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
#define N 100010
char s[N];int a[N];
int main()
{
	scanf("%s",s+1);int n=(int)strlen(s+1);
	for(int i=1;i<=n;i++) a[i]=s[i]-'0';
	if(a[n]==1) return !printf("-1\n");
	for(int i=1;i<n;i++)
		if(a[i]!=a[n-i]) return !printf("-1\n");
	if(a[1]==0) return !printf("-1\n");
	int rt=1,cnt=1;
	for(int i=1;i<n;i++)
	{
		printf("%d %d\n",rt,i+1);
		if(a[i]==1) rt=i+1;
	}
	return 0;
}

Measured memory_bytes: 1920