akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>

using namespace std;

#define N 131075
int bitCount(int bit) {
	int ret = 0;
	while (bit > 0) {
		++ret;
		bit = bit & (bit - 1);
	}
	return ret;
}

int ret[N];

void construct(int l, int r, int a, int b, int n, int bit, int myxor) {
	if (l + 1 == r) {
		ret[l] = a | myxor;
		ret[r] = b | myxor;
		return;
	}
	int mid = (l + r) / 2;
	int ind = -1;

	int axor = myxor, bxor = myxor;
	for (int i = 0; i < n; ++i) {
		if (bit&(1 << i)) {
			continue;
		}
		if ((a&(1 << i)) != (b&(1 << i))) {
			ind = i;
			if (a&(1 << i)) {
				axor |= (1 << i);
			}
			if (b&(1 << i)) {
				bxor |= (1 << i);
			}
			break;
		}
	}
	bit |= (1 << ind);
	int c = 0, f = -1, fInd = -1;
	for (int i = 0; i < n; ++i) {
		if (bit&(1 << i)) {
			continue;
		}
		c |= (1 << i);
		if (fInd == -1) {
			f = 0;
			fInd = i;
		}
	}
	c = (c & a);
	c = c ^ (1 << fInd);
	int tc = c;

	if (a&(1 << ind)) {
		tc |= (1 << ind);
		axor = myxor | (1 << ind);
	}
	construct(l, mid, a, tc, n, bit, axor);
	tc = c;
	if (b&(1 << ind)) {
		tc |= (1 << ind);
		bxor = myxor | (1 << ind);
	}
	construct(mid + 1, r, tc, b, n, bit, bxor);
}
void solve() {
	int n;
	scanf("%d", &n);
	int a, b; scanf("%d %d", &a, &b);
	b = a ^ b;
	int bc = bitCount(b);
	if (bc & 1) {
		printf("YES\n");
		b = a ^ b;
		int sz = (1 << n);
		construct(0, sz - 1, a, b, n, 0, 0);
		for (int i = 0; i < sz; ++i) {
			printf("%d ", ret[i]);
		}
	}
	else {
		printf("NO\n");
	}
}
int main() {
	//freopen("input.txt", "r", stdin);
	solve();
	return 0;
}


Measured memory_bytes: 1664
for i in range(3):
  a=list(map(int, input().split()))
  for j in range(6):
    x=a[3]*3600+a[4]*60+a[5]
    y=a[0]*3600+a[1]*60+a[2]
    z=x-y
    h=z//3600
    m=(z-h*3600)//60
    s=z-(h*3600+m*60)
  print(h,m,s)


Measured memory_bytes: 5596
#include "bits/stdc++.h"
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INF 100000000
typedef long long ll;

using namespace std;

vector<int> v;

int main()
{

    int n, h;
    int imax=0;
    int cnt=0;

    cin >> n>>h;
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        imax = max(imax, a);
        v.pb(b);
    }
    sort(all(v));
    reverse(all(v));
    
    REP(i, n) {
        if (imax > v[i])break;
        h -= v[i];
        cnt++;
        if (h <= 0)break;
    }
    if (h > 0) {
        cnt += h / imax + (h%imax ? 1 : 0);
    }
    cout << cnt<<endl;
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
using namespace std;
int N;
int A[10000], B[10000];
int main () {
  cin >> N;
  for(int i = 0; i < N; ++i) cin >> A[i];
  for(int i = 0; i < N; ++i) cin >> B[i];

  long long pl = 0, mi = 0;
  for(int i = 0; i < N; ++i) {
    int diff;
    diff = B[i] - A[i];
    if (diff > 0) {
      pl += diff / 2;
    }else{
      mi += -diff;
    }
  }
  cout << (mi <= pl ? "Yes" : "No") << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
typedef long long ll;
int ceil(int a,int b){// a以上でｂの倍数の最小値を出力//
    return (a+b-1)/b*b;
}
int stoii(string s){ //stoi関数の代用//
    return atoi(s.c_str());
}
int main(void){
   vector<int> v(26,0);
   string s;
   cin>>s;
   rep(i,s.size()){
       v['z'-s[i]]++;
   }
   rep(i,26){
       if(v[i]!=0 && v[i]%2!=0){
           cout<<"No"<<endl;
           return 0;
       }
   }
   cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
n,l = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

res = nil
a.each_cons(2).each_with_index{|x,i| (x[0]+x[1] >= l) && (res = i)}
if res
  puts 'Possible'
  (1..res).each {|x| puts x}
  ((res+2)..(n-1)).to_a.reverse.each {|x| puts x}
  puts res+1
else
  puts 'Impossible'
end


Measured memory_bytes: 12940
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define DESYNC ios::sync_with_stdio(0); cin.tie(0);
#define deb(x) cerr << ">> " << #x << " : " << x << "\n"
#define print(a) for(auto x : a) cout << x << " "; cout << endl;

using namespace std;

const int inf = 1e18 + 42;
const int M = 998244353;
const int MOD = 1e9 + 7;

int power(int x, int y) {
	if (y == 0) return 1;
	if (y & 1) return (x * power(x, y - 1));
	int t = power(x, y / 2);
	return (t * t);
}

int no_of_bits(int n) {
	int cnt = 0;
	while(n) cnt++, n >>= 1;
	return cnt;
}

const int MAX = 1e6 + 5;

// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

void solve()
{
	int a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;
}

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


Measured memory_bytes: 3608
# -*- coding: utf-8 -*-
STDIN.gets
arr = STDIN.gets.split.map(&:to_i)

min = arr.inject(1000000) do |cmin, i|
  if cmin < i then
    cmin
  else 
    i
  end
end

max = arr.inject(-1000000) do |cmax, i|
  if cmax > i then
    cmax
  else
    i 
  end
end

sum = arr.inject(&:+)

puts "#{min} #{max} #{sum}"

Measured memory_bytes: 9080
#include <cstdio>
#include <cstdlib>
#include <stack>

using namespace std;
int main(void){
    // Your code here!
    stack<int> S;
    int a, b, x;
    char s[10];
    
    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a+b);
        }
        else if (s[0] == '*') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a*b);
        }
        else if (s[0] == '-') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(b-a);
        }
        else {
            S.push(atoi(s));
        }
    }
    printf("%d\n", S.top());
}



Measured memory_bytes: 2740
#include <stdio.h>

int main(void)
{
    int a, b;

    scanf("%d %d", &a, &b);

    if(a == b){
        printf("a == b\n");
    }
    else if(a > b){
        printf("a > b\n");
    } 
    else if(a < b){
        printf("a < b\n");
    }

    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(int (i) = 1; (i) < (n); ++(i))
#define rrep1(i,n) for(int (i) = (n) - 1; (i) >= 1; --(i))
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

int main()
{
    ll n,min;
    cin >> n;
    vector<ll> a(n);
    rep0(i, n)cin >> a[i];
    sort(all(a));
    min = a[0];
    while (1) {
        rep0(i, n){
            if (min > a[i] % min && a[i] % min != 0) {
                min = a[i] % min;
                if (min == 1) {
                    cout << 1 << endl;
                    return 0;
                }
                goto loopend;
            }
        }
        cout << min << endl;
        return 0;
    loopend:;
    }
    return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    //cin.tie(nullptr);
   // ios_base::sync_with_stdio(false);

    int n;
    cin>>n;

    int p[1001][1001];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>p[i][j];
        }

        sort(p[i],p[i]+3);
    }

    int ans=0;

    for(int i=0;i<n-1;i++){
    

        for(int j=i+1;j<n;j++){
            if(p[i][0]==p[j][0]&&p[i][1]==p[j][1]&&p[i][2]==p[j][2]){
                ans++;
                break;
             
            }
        } 
        }
    cout<<ans<<"\n";
    return 0;
}



Measured memory_bytes: 7048
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W,N;cin>>H>>W>>N;
  vector<int>A(N);
  vector<vector<int>>B(H,vector<int>(W));
  int count=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    for(int j=0;j<A[i];j++){
      if(count%(W*2)<W)B[count/W][count%(W*2)]=i+1;
      else B[count/W][W*2-count%(W*2)-1]=i+1;
      count++;
    }
  }
  for(int i=0;i<H;i++){for(int j=0;j<W;j++)cout<<B[i][j]<<(j!=W-1? " ":"");cout<<endl;}
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int cnt[n + 1];
	memset(cnt, 0, sizeof(cnt));
	for (int i = 1; i <= n; i++) {
		for (int j = i; j <= n; j += i) cnt[j]++;
	}
	int64_t res = 0;
	for (int i = 0; i <= n; i++) res += (int64_t) i * cnt[i];
	printf("%" PRId64 "\n", res);
	return 0;
}


Measured memory_bytes: 42864
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<int> a(n);
    int t = 0;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        t ^= a[i];
    }

    for (int i = 0; i < n; i++) {
        cout << (t ^ a[i]) << " \n"[i == n - 1];
    }

    return 0;
}

Measured memory_bytes: 3984
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define ar array
#define pb push_back



int main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("outputc.txt","w",stdout);
	// #endif
	
	//int t;
	//cin>>t;
	//while(t--)
	{
		int n;
		cin>>n;
		int a[n];
		ll sum=0;
		for(auto &x:a)
		{
			cin>>x;
			sum+=x;
		}
		//dp[i][j] ans for range i...j
		ll dp[n][n][2];
		memset(dp,0,sizeof(dp));
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(i==j)
				{
					dp[i][j][0]=a[i];
					dp[i][j][1]=0;
				}
			}
		}
		for(int i=n-1;i>=0;i--)
		{
			for(int j=i;j<=n-1;j++)
			{
				if(j<i)continue;
				if(i+1<n&&j-1>=0)
				{
					dp[i][j][0]=max(dp[i][j-1][1]+a[j],dp[i+1][j][1]+a[i]);
					dp[i][j][1]=min(dp[i+1][j][0],dp[i][j-1][0]);
				}
			}
		}
		cout<<2*dp[0][n-1][0]-sum;
		
	}
		
}


Measured memory_bytes: 144272
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

d = n - m + 1
flg = False
for i in range(d):
    for j in range(d):
        if a[i][j : j + m] == b[0]:
            for k in range(1, m):
                if a[i + k][j : j + m] != b[k]:
                    break
            else:
                print("Yes")
                flg = True
                break
    if flg:
        break
else:
    print("No")

Measured memory_bytes: 9148
#include<bits/stdc++.h>
#include<string>
#include<map>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define vii         vector<pair<ll,ll> >
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define rep1(i,a,b) for(ll i=a;i<= b;i++)
#define PI          3.14159
#define MAX         100000001
#define fast_io      ios_base::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
#define scan(var)    scanf("%lld",&var)
#define print(var)   printf("%lld\n", var);
#define BLOCK 317
#define double       long double
#define mod          998244353
using namespace std;
ll arr[101];
ll arr1[101];
int main()
{
  fast_io
  ll n;
  cin >> n;
  rep(i,0,n)
  {
    arr[i] = LLONG_MAX;
  }
  rep(i,0,n - 1)
  {
    cin >> arr1[i];
    arr[i] = min(arr[i],arr1[i]);
    arr[i + 1] = min(arr[i + 1],arr1[i]);
  }
  ll sum = 0;
  rep(i,0,n)
  {
    sum += arr[i];
  }
  cout << sum;
  return 0;
}



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

int main(void) {
	int k,x;
	cin >> k >> x;
	for (int i=0; i < 2*k - 1; i++) {
		int a = x - k + 1 + i;
		if ((a >= -1000000) && a <= 1000000) {
			cout << a<<" ";
		}
	}
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

int main(int argc, char const *argv[]) {
  long long n,c,k;cin>>n>>c>>k;
  vector<long long> a(n);
  for(int i=0;i<n;++i)cin>>a[i];
  sort(a.begin(),a.end());
  int res=0;
  int j=0;
  while(j<n){
    res++;
    long long l=a[j];
    int i;
    for(i=0;i<c&&j+i<n&&a[i+j]<=l+k;i++);
    j+=i;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
char s[10005];
int main()
{
    cin>>s;
    int len=strlen(s),idx=0;
    for(int i=0;i<len;i++)
    {
        if(s[i]=='C'&&idx==0)      idx++;
        else if(s[i]=='F'&&idx==1) {idx++;break;}
    }
    if(idx==2) printf("Yes");
    else printf("No");
    return 0;
}

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

int main(){
    bool flag = true;
    string s,t = "",u = "";
    char c[99];
    
    cin >> s;
    for(int i = 0; i < (s.length()-1) / 4; i++){
        if(s[i] != s[(s.length()-1) / 2 - i - 1]){ flag = false;}
    }
    for(int i = 0; i < (s.length()-1) / 4; i++){
        if(s[i + (s.length()-1) / 2 + 1] != s[s.length() - i - 1]){ flag = false;}
    }

    for(int i = 0; i < (s.length()-1) / 2; i++){
        t += s[i];
        u += s[i + (s.length()-1) / 2 + 1];
    }

    if(t != u){ flag = false;}

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

Measured memory_bytes: 256
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
  for j in range(1,105):
    for k in range(1,105):
      v = i*i+j*j+k*k+i*j+j*k+k*i;
      if v<10050:
        ans[v]+=1
for i in range(n):
  print(ans[i+1])

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

using namespace std;
using ll = long long;

ll gcd(ll x, ll y) {
	ll r;
	if (x < y)swap(x, y);

	while (y > 0) {
		r = x%y;
		x = y;
		y = r;
	}
	return x;
}
int main() {
	ll n;
	cin >> n;
	ll ans = 1000000001;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	for (ll i = 0; i < n - 1; i++) {
		ans = min(ans, gcd(a[i], a[i + 1]));
	}
	cout << ans << endl;

	return 0;
}

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

int main(void) {

	int N, K;
	cin >> N >> K;

	vector<int> tall(N);

	for (int i = 0; i < N; i++) cin >> tall[i];

	sort(tall.begin(), tall.end());

	int d =tall.end()- upper_bound(tall.begin(), tall.end(), K-0.00001);

	cout << d;
}


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

int main () {
  int n;
  cin >> n;
  int ten[3] = {9, 900, 90000};
  int siki[3] = {10, 1000, 100000};
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (siki[i] <= n) {
      ans += ten[i];  
    }    
    else {
      if (n >= siki[i] - ten[i]) {
        ans += n - (siki[i] - ten[i]) + 1;  
      }  
    }
  }  
  cout << ans << endl;
}

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

using namespace std;

int main(){
	int a,b;
	char c[100000];
	cin>>a>>b;
	cin>>c;
	for(int i=0;i<a;i++)
	{
		if(c[i]<'0' || c[i]>'9')
		{
			cout<<"No";
			return 0;
		}
	}
	if(c[a]>='0' && c[a]<='9')
	{
		cout<<"No";
		return 0;
	}
	for(int i=a+1;i<a+b;i++)
	{
		if(c[i]<'0' || c[i]>'9')
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        if(X >= 30){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35724
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

S = In.str()
T = In.str()

ans = len(T)+1
for i in range(len(S)-len(T)+1):
    ct = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            ct+=1
    
    ans = min(ans, ct)

Out.int(ans)

######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 74240
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    var kotlin=scan.nextLine().toInt()
    var arr = scan.nextLine().split(" ").map{ it.trim().toLong() }.toTypedArray()

    var buy : Long= 0
    var money : Long = 1000
    var count : Long = 0
    var remain :Long  = 0
    var xsell: Long = Long.MAX_VALUE
    for(i  in 0..arr.size-2)
    {
        var x = arr[i]
        var y = arr[i+1]

        if(count==0.toLong() && x<xsell && x<y)
        {
            buy = x
            count = (money/x)
            remain = money - (count*x)
            //println("$x buy $money $count $remain")
        }
        if (x>buy && count>0 && x>y)
        {
            money = (count*x) + remain
            count = 0
           // println("$x sell $money $count $remain")
            xsell = x
        }
    }

    if (arr[arr.lastIndex]>buy && count>0)
    {
        money = (count*arr[arr.lastIndex]) + remain
    }

    if(money==(arr[0]*count))
        println("1000")
    else
        println(money)
}


Measured memory_bytes: 42260
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr int INF = 1000000000 + 8;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int ans = INF;
    ans = min(abs(a + b - c - d), ans);
    ans = min(abs(a + c - b - d), ans);
    ans = min(abs(a + d - b - c), ans);

    cout << ans << endl;
}



Measured memory_bytes: 3216
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	vint X,Y,H;
	for(int i=0;i<N;i++){
		int x,y,h;
		cin>>x>>y>>h;
		X.pb(x);
		Y.pb(y);
		H.pb(h);
	}
	for(int x=0;x<=100;x++){
		for(int y=0;y<=100;y++){
			int height=-1;
			bool flag=0;
			for(int i=0;i<N;i++){
				if(H[i]==0)
					continue;
				if(height==-1)
					height=H[i]+abs(X[i]-x)+abs(Y[i]-y);
				else{
					if(height!=H[i]+abs(X[i]-x)+abs(Y[i]-y))
						flag=1;
				}
			}
			for(int i=0;i<N;i++){
				if(H[i]==0){
					if(height-abs(X[i]-x)-abs(Y[i]-y)>0)
						flag=1;
				}
			}
			if(flag)
				continue;
			else{
				cout<<x<<" "<<y<<" "<<height<<endl;
				return 0;
			}
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    long long int a[100010];

    cin >> n;

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

    sort(a, a+n);

    for (int i = 0; i < n; i++) {
        if (a[i] % 2 != 0) {
            cout << "first" << endl;
            return (0);
        }
    }

    cout << "second" << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

//https://atcoder.jp/contests/abc079/tasks/abc079_c

string ABCD;
string OP;

static bool dfs(int sum, string op) {
    if (op.length() == 3) {
        OP = op;
        return sum == 7;
    }

    if (dfs(sum+(ABCD[op.length()+1] - '0'), op + "+")) return true;
    if (dfs(sum-(ABCD[op.length()+1] - '0'), op + "-")) return true;
    return false;
}

int main() {
    cin >> ABCD;

    if (dfs(ABCD[0]-'0', "")) {
        printf("%c%c%c%c%c%c%c=7\n", ABCD[0], OP[0], ABCD[1], OP[1], ABCD[2], OP[2], ABCD[3]);
    }

    return 0;
}

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

using namespace std;

#define ll long long

int main() {

	ios::sync_with_stdio(false);
	cin.tie(0);

	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <stdint.h>
# include <stdio.h>
# include <math.h>
#include <cstdlib>
# include <algorithm>
# include <string>
using namespace std;

int main(){
    int n,v,j;
    int A[1000];
    cin >>n;
    for(int i=0;i<n;i++){
        cin >>A[i];
        if(i ==0) cout <<A[i];
        else cout <<" "<<A[i];

    }
    cout <<"\n";
    for(int i=1;i<n;i++){
        v= A[i];
        j =i-1;
        while(j>=0 && A[j] >v){
            A[j+1] =A[j];
            j--;
            A[j+1] = v;
        }
        for(int i=0;i<n;i++){
            if(i ==0) cout <<A[i];
            else cout <<" "<<A[i];

        }
        cout <<"\n";

    }

    
	return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
#define hell 1000000007
#define PI acos(-1.0)
#define S second
#define F first
#define lli long long int
#define li long int
#define ld long double
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
 
#define run(j, n) for(auto ii=j;ii!=n;ii++)
#define out(j, n) for(auto ii=j;ii!=n;ii++) cout<<(*ii)<<" ";




int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << fixed << showpoint;
cout << setprecision(11);


int n;cin>>n;
int s = 1e3;
while(s<n)
{
  s+=1000;
}

cout<<s-n;

return 0;
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String Wd = in.readLine();
		int H = Integer.parseInt(Wd);

		Wd = in.readLine();
		int W = Integer.parseInt(Wd);

		Wd = in.readLine();
		int N = Integer.parseInt(Wd);

		int ans = 0;
		int black=0;
		while(true){
			if(H<W){
				black+=W;
				ans++;
				H--;
			}else{
				black+=H;
				ans++;
				W--;
			}
			if(black >=N){
				break;
			}
		}
		System.out.println(ans);

	}

}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int count = 0;
  rep(secret, 1000) {
    char secret_chars[4] = {};
    sprintf(secret_chars, "%03d", secret);
    int ok = 0;
    int secret_chars_index = 0;
    rep(i, S.size()) {
      if (secret_chars_index < 3 && S[i] == secret_chars[secret_chars_index]) {
        ok++;
        secret_chars_index++;
      }
    }
    count += ok == 3;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n%1000 == 0) {
            System.out.println(0);
        } else {
            System.out.println(1000 - (n % 1000));
        }
    }
}

Measured memory_bytes: 27076
#include <iostream>
#include <string>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[n];
    int cnt=0, max=0;
    cin >> a[0];
    for(int i=1; i<n; i++) {
        cin >> a[i];
        if(a[i-1]>=a[i]) cnt++;
        else {
            if(max<cnt) max=cnt;
            cnt=0;
        }
    }
    if(max<cnt) max=cnt;

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

void sort(int num[]) {
	int n = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = 3 - 1; j > i; j--) {
			if (num[i] > num[j]) {
				n = num[i];
				num[i] = num[j];
				num[j] = n;
			}
		}
	}
}

int main(void) {
	int num[3];
	scanf("%d", &num[0]);
	scanf("%d", &num[1]);
	scanf("%d", &num[2]);
	if (1 <= num[0] && num[0] <= 10000 && 1 <= num[1] && num[1] <= 10000 && 1 <= num[2] && num[2] <= 10000) {
		sort(num);
	}
	printf("%d %d %d\n", num[0], num[1], num[2]);
}


Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;

int main(){
    int n, k;
    int h[100100];
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> h[i];
    int count = 0;
    for(int i = 0; i < n; i++){
        if(h[i] >= k) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 640
n = readline.to_i
a = readline.split.map(&:to_i)
a, b = a.each_slice(2).to_a.transpose

def k a
    count = Hash.new(0)
    a.each {|elem| count[elem] += 1}
    count
end

ra = k(a).to_a.sort_by{|(_,b)| b}.reverse
rb = k(b).to_a.sort_by{|(_,b)| b}.reverse

res = []
if ra[0][0] != rb[0][0]
    res << ra[0][1] + rb[0][1]
else
    res << ra[0][1] + rb[1][1] if rb.size > 1
    res << ra[1][1] + rb[0][1] if ra.size > 1
    res << ra[0][1] + 0
    res << 0 + rb[0][1]
end

puts n - res.max

Measured memory_bytes: 18552
#include<stdio.h>

int main(void){
        int a,b,c,m=0;
        scanf("%d %d %d",&a,&b,&c);
        for(; a<=b; a++){
                if(c % a == 0)
                        m++;
        }
        printf("%d\n",m);
        return 0;
}

Measured memory_bytes: 596
N = int(input())
W = []
for i in range(N):
	W.append(input())

ans = "Yes"
check = []
head = W[0][0]
for word in W:
	if (word[0] == head) and (not (word in check)):
		check.append(word)
		head = word[-1]
	else:
		ans = "No"
		break

print(ans) 

Measured memory_bytes: 3064
N, M = map(int, input().split())
S = [0] * M
C = [0] * M
for i in range(M):
    S[i], C[i] = map(int, input().split())
start = 10 ** (N - 1)
stop = 10 ** N
if start == 1:
    start = 0
for n in range(start, stop):
    n = str(n)
    for i in range(M):
        if n[S[i] - 1] != str(C[i]):
            break
    else:
        print(n)
        break
else:
    print(-1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;}
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;

int main(void){
    string S;
    cin >> S;

    if(S == "Sunny") cout << "Cloudy" << endl;
    if(S == "Cloudy") cout << "Rainy" << endl;
    if(S == "Rainy") cout << "Sunny" << endl;
    return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

using Tup = tuple<ll, ll, ll>;
using Graph = vector<vector<Pll>>;
Graph g;
ll N, M;
Vl pos;
bool ok;

void dfs(ll idx, ll p) {
    for (const auto& edge : g[idx]) {
        ll to, c;
        tie(to, c) = edge;
        ll np = p + c;
        if (pos[to] == -1) {
            pos[to] = np;
            dfs(to, np);
        }
        else if (pos[to] != np) {
            ok = false;
        }
    }
}

bool topological_sort(std::vector<int>& res, const Graph& g) {
    const int n = static_cast<int>(g.size());
    res.resize(n);
    int idx = 0;

    int e = 0;
    std::vector<int> indeg(n);
    for (const auto& ch : g) {
        for (const auto& to : ch) {
            ++indeg[to.first];
            ++e;
        }
    }

    std::stack<int> st;
    for (int i = 0; i < n; ++i) {
        if (indeg[i] == 0) st.push(i);
    }

    while (!st.empty()) {
        int u = st.top();
        st.pop();
        res[idx++] = u;
        for (const auto& to : g[u]) {
            --indeg[to.first];
            --e;
            if (indeg[to.first] == 0) st.push(to.first);
        }
    }

    if (e > 0) {
        res.clear();
        return false;
    }

    return true;
}

void solve() {
    cin >> N >> M;
    g.resize(N);
    pos.assign(N, -1);
    for (ll i = 0; i < M; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        g[a].emplace_back(b, c);
    }

    Vi ords;
    ok = topological_sort(ords, g);

    if (ok) {
        for (ll i = 0; i < N; i++) {
            if (pos[ords[i]] == -1) {
                pos[ords[i]] = 0;
                dfs(ords[i], 0);
            }
        }

        ll mx = *max_element(pos.begin(), pos.end());
        if (mx > 1000000000) ok = false;
    }

    cout << (ok ? "Yes\n" : "No\n");
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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

using namespace std;

map<int,int> m;
int n;
int main() {
  cin >> n;

  vector<int> a(n,0);

  for(int i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  sort(a.begin(),a.end());
  a.erase(unique(a.begin(),a.end()),a.end());
  int ans = 0;
  for(int i = 0; i < a.size(); i++) {
    ans += m[a[i]] % 2;
    // cout << m[a[i]]<<endl;
  }

  cout << ans << endl;
    
}


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

const int MOD = (int)1e9+7;

int main(){
  string S;
  cin >> S;

  string x="2019/04/30";
  for(int i=0;i<S.size();i++){
    if(S.at(i)>x.at(i)){
      cout << "TBD" << endl;
      return 0;
    }
    else if(S.at(i)<x.at(i)){
      cout << "Heisei" << endl;
      return 0;
    }
  }
  cout << "Heisei" << endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
/*                   وتزودوا فإن خير الزاد التقوى                    */
/*       وما تدري نفس ماذا تکسب غدا وما تدري نفس باي ارض تموت      */
#include<unordered_map>
using namespace std;
#define endl '\n'
#define ll long long
#define PI acos(-1)
#define watch(x) cerr<<#x<<" = { "<<x<<" }\n"
#define sz(n) n.size()
#define Mo7med_Sayed fast();
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define RT(v) return cout<<v,0;
#define mem(dp,n) memset(dp,n,sizeof dp)
const double EPS = (1e-7);
const ll OO = INT_MAX, mod = 1e9 + 7, N = 2e5 + 5;
void run() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
#endif
}
ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }
void fast()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

ll  n, m, w, k, t;
ll dp[100005][3];
vector<vector<ll>>adj;
ll solve(int u, int p, bool co)
{
	ll& ret = dp[u][co];
	if (~ret)return ret;
	ret = 1;
	for (auto v : adj[u])
	{
		if (v == p)continue;
		ret *= ((co ? solve(v, u, !co) : 0) + (solve(v, u, 1))) % mod;
		ret %= mod;
	}
	return ret %= mod;

}
int main()
{
	run();
	Mo7med_Sayed;
	cin >> n;
	mem(dp, -1);
	adj.resize(n + 1);
	for (int i = 1; i < n; i++) {
		ll u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	RT((solve(1, -1, 0) + solve(1, -1, 1))%mod);
}


Measured memory_bytes: 20688
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	bool flag=false;
	for(int i=0;i<s.size();++i)
	{
		if(s[i]=='C')
			flag=true;
		if(flag&&s[i]=='F')
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
 } 

Measured memory_bytes: 256
import java.util.Scanner;
     
    public class Main {
     
    static Scanner sc = new Scanner(System.in);
    static int N, T, E;
    static int[] x;
     
    static int solve() {
    for (int i = 0; i < N; ++i) {
    for (int t = x[i]; t <= T + E; t += x[i]) {
    if (t >= T - E) return i + 1;
    }
    }
    return -1;
    }
     
    public static void main(String[] args) {
    N = sc.nextInt();
    T = sc.nextInt();
    E = sc.nextInt();
    x = new int[N];
    for (int i = 0; i < N; ++i) {
    x[i] = sc.nextInt();
    }
    System.out.println(solve());
    }
    }

Measured memory_bytes: 12000
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
#define MAXN 100000
#define INF 1100000000
#define LL long long
int a[MAXN+5];
bool vis[MAXN+5];
int n,m;
vector<int>G[MAXN+5];
int mina,p,cnt;
LL ans;
void DFS(int u,int fa)
{
	if(vis[u]) return;
	else vis[u]=1;
	if(a[u]<mina)
	{
		mina=a[u];
		p=u;
	}
	for(int i=0;i<G[u].size();i++)
	{
		int v=G[u][i];
		DFS(v,u);
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(int i=0;i<m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i=0;i<n;i++)
		if(!vis[i])
		{
			mina=INF,p=-1,cnt++;
			DFS(i,-1);
			ans+=1LL*a[p];
			a[p]=INF;
		}
	if(cnt==1)
	{
		printf("0\n");
		return 0;
	}
	sort(a,a+n);
	for(int i=0;i<cnt-2;i++)
		if(a[i]==INF)
		{
			printf("Impossible\n");
			return 0;
		}
		else ans+=1LL*a[i];
	printf("%lld\n",ans);
}

Measured memory_bytes: 6272
#include<iostream>
#include<math.h>
using namespace std;
typedef long long ll;
int gcd(int a,int b)
{
	int r;
	do
    {
      r=a%b;
      a=b;
      b=r;
    }while(r!=0);
	return a;
}
int main()
{
	int k,i,j,q,sum;
	sum=0;
	cin>>k;
	for(i=1;i<=k;i++)
	  for(j=1;j<=k;j++)
	    for(q=1;q<=k;q++)
	    sum+=gcd(i,gcd(j,q));
	    cout<<sum<<endl;
	return 0;
 } 

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL a, n, m;
	in >> a >> n >> m;

	LL ans = 0;
	for (LL y = 1; y <= 9 * 8; ++y)
	{
		LL t = 1;
		rep(i, n) t *= (y + a);
		if (t <= m)
		{
			LL r = 0;
			while (t > 0)
			{
				r += t % 10;
				t /= 10;
			}
			if (r == y) ++ans;
		}
	}

	out << ans << std::endl;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

int extgcd(int a, int b, int &x, int &y){
    int d = a;
    if(b != 0){
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else{
        x = 1;
        y = 0;
    }
    return d;
}

signed main(){

    int N; cin >> N;
    vec A(N); readv(A);

    vec G1(N), G2(N);
    int x, y;
    G1[0] = A[0];
    FOR(i, 1, N){
        int g = extgcd(G1[i - 1], A[i], x, y);
        G1[i] = g;
    }
    G2[N - 1] = A[N - 1];
    IFOR(i, 0, N - 1){
        int g = extgcd(G2[i + 1], A[i], x, y);
        G2[i] = g;
    }
    int ans = max(G1[N - 2], G2[1]);
    REP(i, N - 2) Max(ans, extgcd(G1[i], G2[i + 2], x, y));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
using System;

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

            long N = long.Parse(Console.ReadLine());

            long sum = 0;
            long t = N;

            while(t != 0) {
                sum += t % 10;

                t /= 10;
            }

            Console.WriteLine(N % sum == 0 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    string a, b, c;
    int flag = 0;
    cin >> a >> b >> c;
    reverse(a.begin(), a.end());
    if(a[0] != b[0]) {
        flag = 1;
    }
    reverse(b.begin(), b.end());
    if(b[0] != c[0]) {
        flag = 1;
    }

    cout << (flag == 0 ? "YES" : "NO");
    
    cout << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define LSOne(S) (S & (-S))
#define ll long long
#define two pair<int,int>
#define twol pair<ll,ll>
#define four pair<two,two>
#define pb push_back
#define mk make_pair
#define y1 y1922
#define INF 1000000000000000000
#define P 1000000007
#define lmax 1000000000
#define nn 1000003
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>
#define vtwo vector<two>
#define ALL(container) (container).begin(), (container).end()
#define sz(container) (int)(container.size())
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define mid(a,b) (a+b>>1)
#define minN 0
#define maxN 10000000
#define na(x) ((x)<P?(x):(x)-P)
#define ab(a) (-(a)<(a)?(a):-(a))
#define FAST std::ios::sync_with_stdio(false)
#define xRand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define rnd rng
#define IT iterator
typedef
tree<
  int,// aq pair<int,int> shegidzlia
  null_type,
  less/*_equal*/<int>,// aqac
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
// '_equal' mashin ginda roca multiset gchirdeba
template<class key, class value,class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
ordered_map<int, int> my_map;
inline int rin(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
inline int bin(){
	int x=0;char ch=getchar();
	while (ch<'0'||ch>'9') ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x;
}
string s;
ll a,ans;
int main(){FAST;xRand;
cin>>s;
int i=0;
while(i<sz(s)-1){
	if(s[i]=='A'){
		a++;
		i++;
	}else if(s[i]=='B'&&s[i+1]=='C'){
		ans+=a;
		i+=2;
	}else{
		a=0;
		i++;
	}
}
cout<<ans<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
                 *   *   * *   *
                  *   *   *   *
                   *   * *   *
                     *  *   *
					   *  *


*/






Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
using LL = long long; using PII = pair<LL, LL>; using VI = vector<LL>; using VVI = vector<VI>;
using VB = vector<bool>; using VS = vector<string>; using VP = vector<PII>;
#define VV(T)        vector<vector<T>>
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define $(x)         {cout << #x << " = " << (x) << endl;}


void solve(long long A, long long B){
    cout << A * B << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] input = sc.next().toCharArray();
        boolean north = false;
        boolean south = false;
        boolean west = false;
        boolean east = false;
        for(char c: input){
            if(c == 'N')
                north = true;
            else if(c == 'S')
                south = true;
            else if(c == 'W')
                west = true;
            else
                east = true;
        }
        boolean cond1 = (north && south) || (!north && !south);
        boolean cond2 = (west && east) || (!west && !east);
        if(cond1 && cond2)
            System.out.println("Yes");
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21972