akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

int n,k;
ll ans = 1;
vector<int> G[100000];
bool visited[100000];
ll used[100000];

void dfs(int r,int p){
    visited[r] = 1;
    if(r){
        used[r] = 1;
        ans = ans*(k - used[p]-1)%mod;
    }else{
        ans = k;
    }

    for(int i = 0;i < G[r].size();i ++){
        int to = G[r][i];
        if(!visited[to]){
            dfs(to,r);
            used[r] ++;
        }
    }
}

int main(){
    cin >> n >> k;
    for(int i = 0;i < n-1;i ++){
        int a,b;
        cin >> a >> b;
        a --,b --;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0,0);
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 10112
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] arr=new int[n];
		for(int i=0;i<n;i++){
			arr[i]=sc.nextInt();
		}
		int []dp=new int[n];
		dp[0]=0;
		for(int i=1;i<n;i++){
			dp[i]=Integer.MAX_VALUE;
		}
		for(int i=0;i<n;i++){
			for(int j=i+1;j<=i+2;j++){
				if(j<n){
					dp[j]=Math.min(dp[j], dp[i]+Math.abs(arr[j]-arr[i]));
				}
			}
		}
		System.out.println(dp[n-1]);
	}
}

Measured memory_bytes: 59592
import sys
N, M, C = map(int, input().split())
B = input().split()
sumN = 0
count = 0

for i in range(N):
    A = input().split()
    for j in range(M):
        sumN = sumN + int(A[j])*int(B[j])
    if sumN + C > 0:
        count += 1
    sumN = 0

print(count)

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

#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long int lli;

int main()
{
	fio;
	int n,k;
	cin>>n>>k;
	if(n%k==0) cout<<0<<endl;
	else cout<<1<<endl;
	cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if( a+b < 24 ){
		System.out.println(a+b);
		}
		else{
		System.out.println(a+b-24);
		}
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>

#define CHAR_SIZE 10

int main (void)
{
    char buff[256];
    char s[CHAR_SIZE], t[CHAR_SIZE], u[CHAR_SIZE];
    int a, b;

    fgets(buff, (CHAR_SIZE * 3), stdin);
    sscanf(buff, "%s %s", s, t);
    fgets(buff, 256, stdin);
    sscanf(buff, "%d %d", &a, &b);
    fgets(buff, (CHAR_SIZE + 1), stdin);
    sscanf(buff, "%s", u);

    if(0 == strcmp(s,u))
        printf("%d %d", a-1, b);
    else
        printf("%d %d", a, b-1);
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
from collections import *

def f():
    global ans
    
    if H%3==0:
        ans = min(ans, 0)
    else:
        ans = min(ans, W)

    for i in range(1, H):
        S1 = i*W
    
        if W%2==0:
            S2 = (H-i)*(W//2)
            S3 = (H-i)*(W//2)
        else:
            S2 = (H-i)*(W//2)
            S3 = (H-i)*(W-W//2)
    
        ans = min(ans, max(S1, S2, S3)-min(S1, S2, S3))
    
H, W = map(int, input().split())
ans = 10**18
f()
H, W = W, H
f()
print(ans)

Measured memory_bytes: 74024
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.NoSuchElementException;
import java.util.concurrent.PriorityBlockingQueue;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        long ans = 0;

        ans += (n-1) * n / 2;
        ans += (m-1) * m / 2;

        System.out.println(ans);
    }

    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

}



Measured memory_bytes: 20948
#include <stdio.h>
#include <string.h>
#include <ctype.h>

void text_tolower(char *text)
{
    for (char *elm = text ?: "\0"; *elm; ++elm)
    {
        *elm = tolower(*elm);
    }
}

int main(int argc, char *argv[])
{
    char word[12];
    if (fgets(word, 12, stdin) && strtok(word, " \n"))
    {
        text_tolower(word);
        int count = 0;
        for (char line[1002]; fgets(line, 1002, stdin);)
        {
            for (char *elm = strtok(line, " \n"); elm; elm = strtok(NULL, " \n"))
            {
                if (!strcmp(elm, "END_OF_TEXT"))
                {
                    printf("%d\n", count);
                    return 0;
                }
                text_tolower(elm);
                count += !strcmp(elm, word);
            }
        }
    }
    return -1;
}



Measured memory_bytes: 2052
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
int main(void){
    int n,m,ans = 0,lmx = 0,rmn = 100010;
    cin >> n >> m;
    vector<int> l(m),r(m);
    for(int i = 0;i < m;i++){
        cin >> l[i] >> r[i];
        lmx = max(lmx,l[i]);
        rmn = min(rmn,r[i]);
    }
    
    if(rmn - lmx >= 0) cout << rmn-lmx+1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF -99999999 
using namespace std;
 
int main()
{
    string S; cin >> S;
    ll ans = 0; ll white = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if(S[S.size()-1-i] == 'W') white++;
        else ans += white;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
int m, n, a[200005];
int main() {
	scanf("%d%d", &m, &n);
	for (register int i = 1; i <= n; ++i) scanf("%d", a + i);
	int ans = 0;
	for (register int i = 1; i < n; ++i)
		ans = std::max(ans, a[i + 1] - a[i]);
	ans = std::max(ans, a[1] + m - a[n]);
	printf("%d\n", m - ans);
}


Measured memory_bytes: 896
IDENTIFICATION DIVISION.
       PROGRAM-ID. AtCoder.

       ENVIRONMENT DIVISION.
       
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 INP PIC X(100).
       01 A PIC 9(20).
       01 B PIC 9(20).
       01 E PIC ZZZZZZZZZZZZ9.
       01 temp1 PIC 9(15).
       01 temp2 PIC 9(15).
       01 N PIC 9(15).

       PROCEDURE DIVISION.
       MAIN.
           ACCEPT INP.
           PERFORM VARYING temp1 FROM 1 BY 1 
           UNTIL INP(temp1:1) = SPACE
           END-PERFORM.
           SUBTRACT 1 FROM temp1.
           MOVE INP(1:temp1) TO A.
           ADD 2 TO temp1.
           PERFORM VARYING temp2 FROM temp1 BY 1
           UNTIL INP(temp2:1) = SPACE
           END-PERFORM.
           COMPUTE N = temp2 - temp1.
           MOVE INP(temp1:N) TO B.
           IF A = B THEN
               COMPUTE E = 2 * B
           ELSE
               IF A >= B THEN
                   COMPUTE E = 2 * A - 1
               ELSE
                   COMPUTE E = 2 * B - 1
               END-IF
           END-IF.
           DISPLAY E.
        STOP RUN.
       

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


int main()
{
    int N;
    string S;
    cin >>N>>S;
    int last_num = 1;
    for(int i=1;i<N;i++)
    {
        if(S[i]!=S[i-1])
        last_num++;
    } 
    cout << last_num;

    return 0;

}

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

int n,mod,cont,pos,ind,ind2;
long long ans,ans2;
map<pair<int,int>,int> us;
pair<int,int> sx[100005],dx[100005];

long long calc(pair<int,int> x){
    
    //cout<<pos<<"->> ["<<x.first<<","<<x.second<<"]"<<endl;
    long long v=0;
    if(pos<=x.first){
        v=x.first-pos;
        pos=x.first;
    }
    else
    if(pos>=x.second){
        v=pos-x.second;
        pos=x.second;
    }
    
    return v;
}

int main(){

	cin>>n;
	for(int i=0;i<n;i++){
	    cin>>sx[i].first>>sx[i].second;
	    dx[i].first=sx[i].second;
	    dx[i].second=sx[i].first;
	    us[sx[i]]++;
	    //cout<<sx[i].first<<" "<<sx[i].second<<endl;
    }
    
    sort(sx,sx+n);
    sort(dx,dx+n);
    ind=n-1;
   

    while(cont<n){
        if(mod==0){
            while(us[sx[ind]]==0)ind--;
            ans+=calc(sx[ind]);
            us[sx[ind]]--;
        }
        else{
            while(us[{dx[ind2].second,dx[ind2].first}]==0)ind2++;
            ans+=calc({dx[ind2].second,dx[ind2].first});
            us[{dx[ind2].second,dx[ind2].first}]--;
        }
        cont++;
        mod^=1;
    }
    ans+=abs(pos);
    us.clear();
    ind2=0;
    ind=n-1;
    mod=1;
    cont=0;
    pos=0;
    for(int i=0;i<n;i++)us[sx[i]]=0;
    for(int i=0;i<n;i++)us[sx[i]]++;
    
    while(cont<n){
        if(mod==0){
            while(us[sx[ind]]==0)ind--;
            ans2+=calc(sx[ind]);
            us[sx[ind]]--;
        }
        else{
            while(us[{dx[ind2].second,dx[ind2].first}]==0)ind2++;
            ans2+=calc({dx[ind2].second,dx[ind2].first});
            us[{dx[ind2].second,dx[ind2].first}]--;
        }
        cont++;
        mod^=1;
    }
    ans2+=abs(pos);
    
    cout<<max(ans,ans2)<<endl;

return 0;
}


Measured memory_bytes: 10112
#include <iostream>
#include <cmath>
#include <climits>
using namespace std;

int main()
{
    int N;
    unsigned long long mul;
    unsigned long long pre_mul;
    unsigned long long A;
    unsigned long long limit = pow(10, 18);
    bool over = false;
    bool zero = false;

    cin >> N;
    cin >> A;
    if(A == 0) {
        zero = true;
    }
    mul = A;
    for(int i = 1; i < N; i++) {
        pre_mul = mul;
        cin >> A;
        if(A == 0) {
            zero = true;
        }
        mul *= A;
        if(mul < pre_mul) {
            over = true;
        }
        if(mul > limit) {
            over = true;
        }
    }

    if(zero) {
        cout << 0 << endl;
    } else if(over) {
        cout << -1 << endl;
    } else {
        cout << mul << endl;
    }

    /*
    int N;
    long double mul;
    long double A;
    long double limit = pow(10, 18);

    cin >> N;
    cin >> A;
    mul = A;
    for(int i = 1; i < N; i++) {
        cin >> A;
        mul *= A;
    }
    if(mul > limit) {
        cout << -1 << endl;
    } else {
        cout << (unsigned long long)mul << endl;
    }
    */

    return 0;
}

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

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

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

    deque<bool> d;
    for (int x : a) {
        int sz = d.size();
        bool up = (x - sz + 1) % 2;
        bool right = d.front();
        d.push_front((!up) | (!right));
        int ub = min(x, n) - sz;
        for (int i = 1; i <= ub; i++) {
            d.push_front((x - sz - i) % 2);
        }
        d.pop_back();
    }

    bool res = d.back();
    if (res) {
        cout << "First\n";
    } else {
        cout << "Second\n";
    }

    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k;
    cin>>k;
    int res = 0;
    for(int i = 1; i<=k; i++){
        for(int j = 1; j<=k; j++){
            for(int x = 1; x<=k; x++){
                int l = __gcd(j,x);
                res += __gcd(i,l);
            }
        }
    }
    cout<<res;
    return 0;
}

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

void solve(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << max({a*c,b*d,b*c,a*d}) << "\n";
}

signed main(){
	fastio
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include<iostream>
#include <math.h>//pow(x,y)=x^y 99999とかの場合+1するif文
#include <algorithm>//sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define rep(init,i,n) for (int i=init; i <(n);i++)
#define ll long long
#define rev(s) reverse(s.begin(),s.end())
#define sor(v) sort(v.begin(),v.end())
//コード自動整形 Shift + Alt + F @vscode
using namespace std;


/////main/////
int main() {
int x;
cin >> x;

if(x>=30){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}
}
/////main/////

/////function/////

Measured memory_bytes: 3580
io = STDIN
n,k,q=io.gets.split.map(&:to_i)
ar=q.times.map{io.gets.to_i}
score=Array.new(n,k)
hash=Hash.new{|h,k|h[k]=0}
(1..n).each {|a|hash[a]=0}
ar.each{|a|hash[a]+=1}
(1..n).each do |a|
  puts k-q+hash[a]>=1 ?  'Yes' : 'No'
end


Measured memory_bytes: 10492
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s1 = sc.next();
    String s2 = sc.next();
    String s3 = sc.next();
    String ans = "";
    ans += String.valueOf(s1.charAt(0));
    ans += String.valueOf(s2.charAt(1));
    ans += String.valueOf(s3.charAt(2));
    System.out.println(ans);
  }
}


Measured memory_bytes: 21972
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            int k = Int32.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            Console.WriteLine(s.Length <= k ? s : s.Substring(0, k) + "...");
        }
    }
}

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

namespace abc159a
{
    class Program
    {
        static void Main(string[] args)
        {

            List<int> input4 = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            int n = input4[0];
            int m = input4[1];


            int output = 0;


            if (n > 1)
            {
                output += (n * (n - 1) / 2);
            }

            if (m > 1)
            {
                output += (m * (m - 1) / 2);
            }



            Console.WriteLine(output);
        }
    }
}


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

using namespace std;

int dp[3010][3010];

void solve(){
    string a, b;
    
    cin >> a >> b;
    
    
    for(int i = 1;i <= a.size();++i){
        for(int j = 1;j <= b.size();++j){
            if(a[i - 1] == b[j - 1]){
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else{
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    
    int n, m;
    n = a.size();
    m = b.size();
    
    string ans = "";
    
    while(n > 0 && m > 0){
        if(a[n - 1] == b[m - 1]){
            ans = a[n - 1] + ans;
            --n;--m;
            continue;
        }
        if(dp[n - 1][m] > dp[n][m - 1]){
            --n;
        }
        else{
            --m;
        }
    }
    
    cout << ans;
}

int main(){
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 35584
n = int(input())
s_list = [input() for _ in range(n)]
m = int(input())
t_list = [input() for _ in range(m)]
ans = 0
for s in s_list:
    score = s_list.count(s) - t_list.count(s)
    if ans < score:
        ans = score
print(ans)

Measured memory_bytes: 3060
def gcd(x,y):
    p=min(x,y)
    q=max(x,y)
    while p != q:
        if q > p:
            q = q - p
        else:
            p = p - q
    return q

c=0
n=int(input())
a=sorted(set(list(map(int, input().split()))))
b=[]
while len(a) > 1:
    p=a[0]
    q=a[1]
    g=gcd(p,q)
    if g !=0:
        a.append(p*q//g)
    a.pop(0)
    a.pop(0)
    a=sorted(a)
print(*a)

Measured memory_bytes: 7788
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define mem(arr, i) fill(arr, arr + sizeof(arr), i)
#define MEM(arr, i) memset(arr, i, sizeof(arr))
#define Push push_back
#define Pair make_pair
#define ALL(x) x.begin(), x.end()
#define X first
#define Y second
#define ACCEL \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
	cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv(maxN+5, 1);

void ADD(lli &x, lli y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = (x % mod + mod) % mod;
}

lli mypow(lli b, lli e) {
	if (b == 0) return 0;
	lli ans = 1;
	while (e) {
		if (e & 1) MUL(ans, b);
		MUL(b, b);
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow(n, mod - 2);
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

/// coding area ///

const lli maxn = 1E5;

void solve() {
	lli n, maxAns = 0;
	cin >> n;
	
	vcL num(n);
	for (int i = 0; i < n; ++i) {
		cin >> num[i];
	}
	
	vcL dp(n, 0);
	for (int i = 1; i < n; ++i) {
		if (num[i] <= num[i - 1]) {
			dp[i] = dp[i - 1] + 1;
		}
		maxAns = max(maxAns, dp[i]);
	}
	
	cout << maxAns << '\n';
}

int main() {
//	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		cout << "Case #" << i << ": ";
		solve();
	}
	return 0;
}



Measured memory_bytes: 3456
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())
def NIJIGEN(H): return [list(input()) for i in range(H)]
mod=1000000007
N=INT()
L=LIST()
if N%2==0:
  A=range(1,N,2)
  B=range(1,N,2)
else:
  A=range(0,N,2)
  B=range(2,N,2)
A,B=list(A),list(B)
A=A+B
if sorted(A)==sorted(L):
  print(pow(2,N//2,mod))
else:
  print(0)

Measured memory_bytes: 20516
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};

int a,b,c;
int n;
int check[400];
// 電源iとモーターjとケーブルkをつないで検査した結果が，「合格」(r=1 のとき) か「不合格」(r=0 のとき) だったことを表す. 
int main()
{

  while(cin >>a>>b>>c,a||b||c){
    cin >>n;
  for(int i = 1;i <=a+b+c;i++){
    check[i] = 2;
  }
  int kaisuu = 0;
  vector<int> data1;
  vector<int> data2;
  vector<int> data3;
  for(int i = 0;i < n;i++){
    int i,j,k,r;
    cin >>i>>j>>k>>r;
    if(r){
      check[i] = 1;
      check[j] = 1;
      check[k] = 1;
    }else{
      data1.push_back(i);
      data2.push_back(j);
      data3.push_back(k);
      kaisuu++;
  }
  }

  for(int i = 0;i <kaisuu;i++){
    int x,y,z;
    x =data1[i];
    y =data2[i];
    z =data3[i];
    if(check[x] ==1 &&check[y] ==1){
      check[z] = 0;
    }else if(check[y] ==1&&check[z] ==1){
      check[x] =0;
    }else if(check[z] ==1&&check[x] ==1){
      check[y] = 0;
    }
  }
    for(int i = 1;i <=a+b+c;i++){
      cout <<check[i]<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1236
import sys
K=1024
N=331
R=range(K)
B=[1,2,4,8,16,32,64,128,256,512]
C=[0]*K
D=[[0 for i in range(N)]for j in R]

def init():
  global C,D
  for i in R:
    s=format(i,'b')
    n=s.count('1')
    C[i]=n
    if n==1:D[i][B.index(i)]=1
    else:
      for j in range(len(s)):
        if s[-j-1]=='1':
          dp=n*j
          i2=i-B[j]
          for k in range(N-dp):
            D[i][k+dp]+=D[i2][k]
  return
   
init()
for a in sys.stdin:
  n,s=map(int,a.split())
  x=0
  if s<N:x=sum([D[i][s] for i in R if C[i]==n])
  print x

Measured memory_bytes: 7148
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define in (void)scanf
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
//#define Rep(i,a,n)for(LL i=(LL)(a);i<(LL)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Repp(i,l,r,k)for(int i=(int)(l);i<(int)(r);i+=(int)(k))
//#define Repp(i,l,r,k)for(LL i=(LL)(l);i<(LL)(r);i+=(LL)(k))
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007//998244353,1000000007,1000000009,4999999999999997
int upi(const void* a, const void* b) { return*(int*)a<*(int*)b ? -1 : *(int*)a> * (int*)b ? 1 : 0; }
int downi(const void* a, const void* b) { return*(int*)a<*(int*)b ? 1 : *(int*)a> * (int*)b ? -1 : 0; }
void sortupi(int* a, int n) { qsort(a, n, sizeof(int), upi); } //1,2,3,4,...
void sortdowni(int* a, int n) { qsort(a, n, sizeof(int), downi); }
int upLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? -1 : *(LL*)a> * (LL*)b ? 1 : 0; }
int downLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? 1 : *(LL*)a> * (LL*)b ? -1 : 0; }
void sortupLL(LL* a, int n) { qsort(a, n, sizeof(LL), upLL); }
void sortdownLL(LL* a, int n) { qsort(a, n, sizeof(LL), downLL); }
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
LL gcd(LL p, LL q) { while (q) { LL t = p % q; p = q; q = t; }return p; }
LL modpow(LL a,LL n,int m){LL x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invmodpow(b,p)modpow(b,p-2,p)// a/b≡a*b^{-1}(mod p)...return b^{-1}(mod p)
typedef struct fac { LL n, exp; }F;
LL fact(LL n,F*a){LL x=n,i,j,c=0;for(i=2;i*i<=x;i++){for(j=1;x%i==0;j++)x/=i;if(j>1){a[c].n=i;a[c++].exp=j-1;}}if(x-1){a[c].n=x;a[c++].exp=1;}return c;}
LL nibtan(LL* a,LL n,LL x){LL p=0,q=n/2,r=n-1;while(r-p>1){if(x>=a[q])p=q;if(x<=a[q])r=q;q=(p+r)/2;}return a[p]==x?p:r;}
//snippet

#define N 200009

int n, k, a[N];

LL check(int x) {
	LL ret = 0;
	rep(i, n)ret += (LL)ceill((Lf)a[i] / (Lf)x) - 1;
	return ret;
}

void run(void) {
	//saw editorial
	in("%d%d", &n, &k);
	rep(i, n)in("%d", &a[i]);

	int p = 0, q = MOD / 2, r = MOD, ans = n;
	while (r - p > 1) {
		if (check(q) <= (LL)k) r = q;
		else p = q;
		q = (p + r) / 2;
	}
	if (check(r) <= k)ans = r;
	if (check(p) <= k)ans = p;
	if (!ans)ans = 1;
	printf("%d\n", ans);
}

int main(void) {
	int test = 1;
//	in("%d", &test);
	while (test--) {
		run();
	}
	return 0;
}

Measured memory_bytes: 2936
#include <stdio.h>

int search(int A[], int n, int key){
  int i=0;
  A[n] = key;
  while(A[i]!=key) i++;
  return i!=n;
}

int main(){
  int i, n, A[10000+1], q, key, sum=0;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);

  scanf("%d", &q);
  for(i=0; i<q; i++){
    scanf("%d", &key);
    if(search(A, n, key)) sum++;
  }

  printf("%d\n", sum);
  
  return 0;
}



Measured memory_bytes: 2108
import math
n,d=map(int,input().split())
x=[0 for i in range(n)]
y=[0 for i in range(n)]
count=0

for i in range(n):
  x[i],y[i]=map(int,input().split())
  
for i in range(n):
  z=math.sqrt(x[i]*x[i]+y[i]*y[i])
  if z<=d:
    count+=1

print(count)

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

int n;
int ans;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i){
		int a;
		cin >> a;
		int t = 0;
		while(a % 2 == 0){
			a /= 2;
			++t;
		}
		ans += t;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;scanf("%lld",&n);
    long long a[5];
    for(int i=0;i<5;i++)scanf("%lld",&a[i]);
    sort(a,a+5);
    long long ans=(n+a[0]-1)/a[0]+5-1;
    printf("%lld\n",ans);
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int A, P;

    cin >> A >> P;

    cout << (3 * A + P) / 2;

    return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

ll mp[1111][1111];

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

    ll w, h, a, b;cin >> h >> w >> a >> b;

    if(a == 0 && b != 0){
        REP(i, b){
            REP(j, w){
                mp[i][j] = 1;
            }
        }
    }
    else if(a != 0 && b == 0){
        REP(i, h){
            REP(j, a){
                mp[i][j] = 1;
            }
        }
    }
    else if(a != 0 && b != 0){
        REP(i, h){
            int cou = (i < b ? 0 : 1);
            REP(j, w){
                if(j == a)cou = 1 - cou;
                mp[i][j] = cou;
            }
        }
    }

    REP(i, h){
        REP(j, w){
            printf("%d", mp[i][j]);
        }
        printf("\n");
    }

	return 0;
}


Measured memory_bytes: 9856
from math import sqrt
x1, y1, x2, y2 = map(int, raw_input().split())
dx = x2 - x1
dy = y2 - y1
for i in xrange(input()):
    x, y = map(int, raw_input().split())
    a = float(dx*(x - x1) + dy*(y - y1)) / (dx**2 + dy**2)
    print "%.09f %0.09f" % (2*x1 - x + 2*a*dx, 2*y1 - y + 2*a*dy)

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

int main(){
    int N,M,Q;
    cin >> N >> M >> Q;
    int cnt[600][600]={};
    for(int i=0;i<M;i++){
        int l,r; cin >> l >> r;
        cnt[l][r]++;
    }
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            cnt[i][j]+=cnt[i][j-1];
        }
    }
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            cnt[i][j]+=cnt[i-1][j];
        }
    }
    for(int i=0;i<Q;i++){
        int l,r; cin >> l >> r;
        cout << cnt[r][r]+cnt[l-1][l-1]-cnt[r][l-1]-cnt[l-1][r] << endl;
    }
}

Measured memory_bytes: 2304
import java.util.Scanner;

class Main {

	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		long N=stdIn.nextLong();
		long M=stdIn.nextLong();
		long z=0,y=0;
		if(N>=M/2)
			System.out.println(M/2);
		else {
			z=(M-(N*2))/4;
			y=N+z;
			System.out.println(y);
		}
	}
}

Measured memory_bytes: 22740
/* ITP1_9_C: Card Game */

#include <iostream>

enum Result { P1_WIN, P2_WIN, DRAW };

const int WINNING_POINTS  = 3;
const int MAX_WORD_LENGTH = 100;

Result fight(char *w1, char *w2) {
    for (int i = 0; w1[i] || w2[i]; i++) {
        if (! w2[i] || w1[i] > w2[i])
            return P1_WIN;

        if (! w1[i] || w1[i] < w2[i])
            return P2_WIN;
    }
    return DRAW;
}

int main() {
    std::ios::sync_with_stdio(false);

    char word1[MAX_WORD_LENGTH + 1];
    char word2[MAX_WORD_LENGTH + 1];
    int taro_points   = 0;
    int hanako_points = 0;
    int n_fights;

    std::cin >> n_fights;
    for (int i = 0; i < n_fights; i++) {
        std::cin >> word1 >> word2;
        Result result = fight(word1, word2);

        switch (result) {
        case P1_WIN:
            taro_points += WINNING_POINTS;
            break;
        case P2_WIN:
            hanako_points += WINNING_POINTS;
            break;
        case DRAW:
            taro_points++;
            hanako_points++;
            break;
        }
    }

    std::cout << taro_points << " " << hanako_points << std::endl;
    return 0;
}

Measured memory_bytes: 1208
#include <iostream>

using namespace std;
typedef long long ll;

int main()
{
  ll x, y;
  cin >> x >> y;
  ll ans = 1000000000000LL;
  if(y - x >= 0) ans = min(ans, y - x);
  if(y - (-x) >= 0) ans = min(ans, y + x + 1);
  if((-y) - x >= 0) ans = min(ans, -y - x + 1);
  if((-y) - (-x) >= 0) ans = min(ans, -y + x + 2);
  cout << ans << endl;
}


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

int main(){
  int s;
  int a,b,c;
  
  cin >> s;
  a = s/100;
  b = (s-a*100)/10;
  c = (s-a*100-b*10);
  cout << a+b+c << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  char c;
  cin >> c;
  if (c == 'A') puts("T");
  if (c == 'T') puts("A");
  if (c == 'C') puts("G");
  if (c == 'G') puts("C");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
 
using namespace std;
 
int main()
{
map<string,int> msi;
int m,n;
cin >> n;
for(int i = 0; i < n; ++i){
string s;
cin >> s;
msi[s]++;
}
cin >> m;
for(int i = 0; i < m; ++i){
string s;
cin >> s;
msi[s] --;
}
int r = 0;
for(auto it = msi.begin(); it != msi.end(); ++it)
  r = max(r, it->second);
cout << r;
return 0;
 
 
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define COMLEN 7
#define STRLEN 13
#define FOUND 1
#define NOT_FOUND 0
#define M 2000000

void insert(char *);
int find(char *);
int h1(long long);
int h2(long long);
int H(long long, int);
long long generate(char *);

char D[M][13] = {};

int main(){
  int n;
  int i;
  char com[COMLEN], str[STRLEN];

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%s %s", com, str);
    //printf("Debug\n");
    if(com[0] == 'i') insert(str);
    else{
      if(find(str) == FOUND) printf("yes\n");
      else printf("no\n");
    }
  }
  
  return 0;
}

void insert(char *str){
  int i = 0, index;
  while(1){
    if(find(str) == FOUND) return;
    //printf("Debug\n");
    index = H(generate(str), i);
    //printf("Debug\n");
    if(strlen(D[index]) == 0){
      strcpy(D[index], str);
      return;
    }
    else i++;
  }
}

int find(char *str){
  int i = 0, index;
  while(1){
    index = H(generate(str), i);
    //printf("%d\n", index);
    if(strcmp(D[index], str) == 0){
      //printf("Debug1\n");
      return FOUND;
    }
    else if(strlen(D[index]) == 0){
      //printf("Debug2\n");
      return NOT_FOUND;
    }
    else i++;
  }
  return NOT_FOUND;
}

int h1(long long key){
  return key % M;
}

int h2(long long key){
  return 1 + (key % (M - 1));
}

int H(long long key, int i){
  return (h1(key) + i * h2(key)) % M;
}

long long generate(char *str){
  int l, x;
  int i;
  long long key = 0, y = 1;
  
  l = strlen(str);
  for(i=0;i<l;i++){
    if(str[i] == 'A') x = 1;
    else if(str[i] == 'C') x = 2;
    else if(str[i] == 'G') x = 3;
    else if(str[i] == 'T') x = 4;
    key += x * y;
    y *= 10;
    //printf("%lld\n", key);
  }

  //printf("%lld\n", key);
  return key;
}



Measured memory_bytes: 16076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main()
{
      int n;
      cin>>n;
      int a[n];
      rep(i,0,n)
      cin>>a[i];
      int dp[n];
      dp[0]=0;
      dp[1]=abs(a[1]-a[0]);
      
      for(int i=2;i<n;i++)
      {
      	dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	  }

   cout<<dp[n-1];
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int r = sc.nextInt();

        while (!(n == 0 && r == 0)) {

            int[] hanafuda = new int[n];

            for (int i = 0; i < n; i++) {
                hanafuda[i] = n - i;
            }

            for (int i = 0; i < r; i++) {
                int p = sc.nextInt();
                int c = sc.nextInt();
                hanafuda = shuffle(p, c, hanafuda);

            }

            System.out.println(hanafuda[0]);

            n = sc.nextInt();
            r = sc.nextInt();
        }

        sc.close();
    }

    static int[] shuffle(int p, int c, int[] a) {

        int[] keep = new int[a.length];

        for (int i = 0; i < a.length; i++) {
            keep[i] = a[i];
        }

        for (int i = 0; i < p - 1; i++) {
            a[c + i] = keep[i];
        }

        for (int i = 0; i < c; i++) {
            a[i] = keep[p - 1 + i];
        }

        return a;
    }
}


Measured memory_bytes: 37108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int maxn=1e5+5;
const int maxm=5e2+5;
const int maxq=55;
const int INF=0x3f3f3f3f;
ll x[maxn];
int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k))
    {
        for(int i=1;i<=n;i++)
        {
            scanf("%lld",&x[i]);
        }
        ll ans=-1;
        for(int i=1;i<=n-k+1;i++)
        {
            ll a=x[i];ll b=x[i+k-1];
            ll t;
            if(a<0&&b>0) t=min(-a,b)*2+max(-a,b);
            else if(b<0) t=-a;
            else t=b;
            if(ans==-1) ans=t;
            else ans=min(ans,t);
        }
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
typedef pair<int, int> P;
vector<int> A[4];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, W;
    cin >> N >> W;
    int w[110], v[110];
    rep(i, N) cin >> w[i] >> v[i];
    int lw = w[0];
    rep(i, N) w[i] -= lw;
    rep(i, N) A[w[i]].push_back(v[i]);
    rep(i, 4) sort(A[i].begin(), A[i].end(), greater<int>());
    
    int ans = 0;
    rep(i, A[0].size() + 1) {
        rep(j, A[1].size() + 1) {
            rep(k, A[2].size() + 1) {
                rep(l, A[3].size() + 1) {
                    int sum_w = 0, sum_v = 0;
                    rep(a, i) {
                        sum_w += lw;
                        sum_v += A[0][a];
                    }
                    rep(a, j) {
                        sum_w += lw + 1;
                        sum_v += A[1][a];
                    }
                    rep(a, k) {
                        sum_w += lw + 2;
                        sum_v += A[2][a];
                    }
                    rep(a, l) {
                        sum_w += lw + 3;
                        sum_v += A[3][a];
                    }
                    if (sum_w <= W) {
                        ans = max(ans, sum_v);
                    }
                }   
            }   
        }   
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if(x <= W && y <= H){
        if(x + r <= W && x - r >= 0 && y + r <= H && y - r >= 0){
           cout << "Yes" << endl;
        }else{
           cout << "No" << endl;
    }
    }else{
    cout << "No" << endl;
    }
}


Measured memory_bytes: 3096
#include <iostream>
#include <cmath>
#include <string>
#include <map>
#include <queue>
using namespace std;

#define A 3
#define B 9

struct pazzle{
  int f[B];
  int space;
  string path;

  bool operator < (const pazzle &p) const{
    for(int i=0;i<B;i++){
      if(f[i]==p.f[i])continue;
      return f[i]>p.f[i];
    }
    return false;
  }
};

static const int dx[4]={-1,0,1,0};
static const int dy[4]={0,-1,0,1};
static const char dir[4]={'u','l','d','r'};

bool isTarget(pazzle p){
  for(int i=0;i<B;i++)
    if(p.f[i]!=(i+1))return false;
  return true;
}

string bfs(pazzle s){
  queue<pazzle> Q;
  map<pazzle,bool> V;
  pazzle u,v;
  s.path = "";
  Q.push(s);
  V[s]=true;

  while(!Q.empty()){
    u=Q.front();
    Q.pop();

    if(isTarget(u))return u.path;

    int sx = u.space/A;
    int sy = u.space%A;

    for(int r=0;r<4;r++){
      int tx = sx+dx[r];
      int ty = sy+dy[r];

      if(tx<0 || ty<0 || tx>=A || ty>=A)continue;

      v=u;
      swap(v.f[u.space],v.f[tx*A+ty]);
      v.space = tx*A+ty;
      if(!V[v]){
        V[v]=true;
        v.path += dir[r];
        Q.push(v);
      }
    }
  }
  return "unsolvable";
}

int main(){
  pazzle in;

  for(int i=0;i<B;i++){
    cin >> in.f[i];
    if(in.f[i]==0){
      in.f[i]=B;
      in.space =i;
    }
  }
 string ans = bfs(in);
 cout << ans.size() << endl;

 return 0;
}



Measured memory_bytes: 30620
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll a,b,c; cin >> a >> b >> c;
	ll s = c - a - b;
	if(s < 0){
		puts("No");
		return 0;
	}
	s = s * s;
	ll t = 4 * a * b;
	if(s > t) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		int[] v=new int[n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
			v[i]=sc.nextInt();
		}
		for(int i=0;i<n-1;i++){
			for(int j=n-1;j>i;j--){
				if(a[j-1]>a[j]){
					int box=v[j-1];
					v[j-1]=v[j];
					v[j]=box;
					box=a[j];
					a[j]=a[j-1];
					a[j-1]=box;
				}
			}
		}
		int max=-1;
		int maxPtr=0;
		for(int i=0;i<n;i++){
			if(v[i]>max){
				max=v[i];
				maxPtr=a[i];
			}
		}
		System.out.println(maxPtr+" "+max);
	}
}

Measured memory_bytes: 17332
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,dig,sum,i;
sum=0;
cin>>N;
i=N;
while(i){
dig=i%10;
sum+=dig;
i/=10;
}
if((N%sum)==0){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define long long ll
using namespace std;
struct T{
  int t,x,y;
};
int n;
T tra[100009];
int main(){
  cin >> n;
  tra[0].t = 0; tra[0].x = 0; tra[0].y = 0;
  for(int i=1;i<=n;i++){
    cin >> tra[i].t >> tra[i].x >> tra[i].y;
  }
  bool frag = true;
  for(int i=1;i<=n;i++){
    int o = tra[i].t - tra[i-1].t;
    int p = abs(tra[i].x-tra[i-1].x)+abs(tra[i].y-tra[i-1].y);
    if( o - p < 0 || (o-p)%2 != 0 ) frag = false;
  }
  if(frag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
  char a[9],b[9];
  scanf("%s %s",a,b);
  int num=atoi(strcat(a,b)),i;
  for(i=1;i<1000;i++){
    if(i*i==num) {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 128
// -*- mode: cpp; coding=utf-8-unix; -*-
// vim: filetype=cpp fileencoding=utf-8 fileformat=unix
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;


int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	int A, B, T;

	cin >> A >> B >> T;

	int count = T/A;

	cout << count * B << endl;

	return 0;
}



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

int main(){
  int n, m, l;
  long long a[100][100], b[100][100], c[100][100]={};

  cin>>n>>m>>l;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<l;j++){
      cin>>b[i][j];
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      for(int k=0;k<m;k++){
        c[i][j]+=a[i][k]*b[k][j];
      }
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      if(j+1!=l) cout<<c[i][j]<<" ";
      else cout<<c[i][j]<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3336
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define show(x) cout << #x << " = " << x << endl;
int main(){
    int l;
    string s,t;
    cin >> l >> s >> t;
    if(s+t > t+s)swap(s,t);
    string ans;
    int k,kk;
    for(int i = 0; i*s.size() <= l; i++){
        if((l-i*s.size())%t.size()==0){
            k = i;
            kk = (int)(l-i*s.size())/t.size();
        }
    }
    rep(i,k)ans += s;
    rep(i,kk)ans += t;
    cout << ans << endl;
}

Measured memory_bytes: 1544
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <map>
#include <string>
#include <string.h>

using namespace std;
#define maxn  255

long long a[maxn * maxn];
long long b[maxn * maxn];
long long c[maxn * maxn];

int main() {
	int n;
	while(~scanf("%d",&n),n) {
		int m = n * (n + 1) / 2;
		int t1 = 0;
		int t2 = 0;
		for(int i = 0; i < m; i ++) {
			scanf("%lld", &a[i]);
			if(a[i] % 2 == 1)
				b[t1++] = a[i];
			else
				c[t2++] = a[i];
		}
		sort(b, b + t1);
		sort(c, c + t2);
		double x = (c[0] * 1.0) / b[0] * c[1];
		long long ans = (long long)(sqrt(x) + 0.001); 
		printf("%lld\n",ans);
		for(int i = 0; i < n; i ++) {
			if (i == n - 1)
				printf("%lld\n",c[i] / ans);
			else 
				printf("%lld ",c[i] / ans);
		}
	}
	return 0;
}

Measured memory_bytes: 1700
import numpy as np

def resolve():
    S = []
    T = []
    N = int(input())
    for i in range(N):
        s, t = input().split()
        S.append(s)
        T.append(int(t))
    X = input()

    idx = S.index(X)
    cumsum = np.cumsum(np.array(T))
    time = cumsum[-1] - cumsum[idx]
    print(time)

if __name__ == "__main__":
    resolve()



Measured memory_bytes: 23724
// https://atcoder.jp/contests/abc097/tasks/abc097_b
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// 二乗法によるべき乗
int ipow(int base, int exp) {
    int result = 1;
    while (exp) {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        base *= base;
    }

    return result;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, maxv = 0;
    cin >> n;
    if (n == 1) {
        cout << "1\n";
    } else {
        FOR(i, 1, sqrt(n) + 1) FOR(j, 2, sqrt(n)) {
            int t = ipow(i, j);
            if (t > n)
                break;
            maxv = max(maxv, t);
        }
        cout << maxv << endl;
    }

    return 0;
}

Measured memory_bytes: 256
S = input()

N = int(S[:4])
M=int(S[5:7])
D=int(S[8:10])
# print(N,M,D)

if(N==2019):
    if(M<=4):
        print("Heisei")
    else:
        print("TBD")
elif(N<2019):
    print("Heisei")
else:
    print("TBD")



Measured memory_bytes: 2940