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

using namespace std;

const int N=1e5+10;

typedef vector<int> vec;

class RUQ
{
public:
    vec data;
    vec lazy;
    int n;

    RUQ(int _n)
    {
        data.resize(4*_n);
        lazy.resize(4*_n);
        for(n=1;n<_n;n<<=1);
        fill(data.begin(),data.end(),(1LL<<31)-1);
        fill(lazy.begin(),lazy.end(),-1);
    }

    void Down(int p,int l,int r)
    {
        if(lazy[p]==-1) return;
        if(l+1>=r)
        {
            data[p]=lazy[p];
        }else
        {
            lazy[p*2+1]=lazy[p*2+2]=lazy[p];
        }
        lazy[p]=-1;
    }

    void update(int p,int l,int r,int x,int a,int b)
    {
        if(a>=r||b<=l) return;
        if(a<=l&&r<=b)
        {
            lazy[p]=x;
            return;
        }
        Down(p,l,r);
        int mid=(l+r)/2;
        update(p*2+1,l,mid,x,a,b);
        update(p*2+2,mid,r,x,a,b);
    }

    int query(int p,int l,int r,int a,int b)
    {
        if(a>=r||b<=l) return -1;
        Down(p,l,r);
        if(a<=l&&r<=b) return data[p];
        int mid=(l+r)/2;
        if(a<mid)
        {
            return query(p*2+1,l,mid,a,b);
        }else
        {
            return query(p*2+2,mid,r,a,b);
        }
    }
};

int main()
{
    int n,q;

    while(scanf("%d %d",&n,&q)!=EOF)
    {

        RUQ ruq(n);
        while(q--)
        {
            int op,a,b,c;
            scanf("%d",&op);
            if(op)
            {
                scanf("%d",&a);
                printf("%d\n",ruq.query(0,0,ruq.n,a,a+1));
            }else
            {
                scanf("%d %d %d",&a,&b,&c);
                ruq.update(0,0,ruq.n,c,a,b+1);
            }
        }
    }

    return 0;
}



Measured memory_bytes: 5968
import sys


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


def input_ints():
    return list(map(int, input().split()))


def main():
    n, k = tuple(input_ints())
    ps = input_ints()
    ps.sort()
    print(sum(ps[0:k]))


main()


Measured memory_bytes: 9264
#include "bits/stdc++.h"
 
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;


signed main(){
    llin(h);
    llin(w);
    llin(n);
    vpl4 k(1);
    ll x;
    ll y;
    k[0]=mp(h+1,1);
    ll p=0;
    ll q=h+1;
    FOR(i,1,n){
        cin >>x;
        cin >>y;
        if (y<x){
            k.pb(mp(x,y));
        }
        if (y==x){
            q=min(x,q);
        }
    }
    SORT(k);
    if(q<k[0].fi){
        p++;
    }else{
        sal(k[0].fi-1);
        return 0;
    }
    FOR(j,0,n){
    if (k[j].se+p==k[j].fi){
        p++;
    }
    if(k[j].se+p<k[j].fi){
        sal(k[j].fi-1);
        return 0;
    }
    }
}


Measured memory_bytes: 6000
export default solve;

// =================================================
// ABC110B
// =================================================

// main
function main(lines) {
  console.log(solve(lines));
}

// solver
function solve(lines: string[]): string {
  const { nums } = parseLines(lines);

  const num = +nums.join('');
  let ans = 0;
  loop: for (let i = 9; i > 0; i--) {
    const v = +[i, i, i].join('');
    if (v >= num) {
      ans = v;
    } else {
      break loop;
    }
  }
  return ans.toString();
}

// helpers
function parseLines(lines: string[]) {
  const nums = lines[0].split('').map(s => +s);
  const obj = { nums };
  debug(obj);
  return obj;
}

// general helpers
function debug(message?: any, ...optionalParams: any[]) {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
}

// reader
if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume().setEncoding('utf8');
  const lines = [];
  require('readline')
    .createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}


Measured memory_bytes: 7756
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int c[5][5];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
struct wolf{
	int m[4][4];
};
int solve(int a,wolf b){
	if(a==0){
		for(int i=0;i<4;i++)for(int j=0;j<4;j++)if(b.m[i][j])return 0;
		return 1;
	}
	
	for(int i=0;i<4;i++)for(int j=0;j<4;j++){
		wolf to=b;
		to.m[i][j]++;
		if(to.m[i][j]>=5){
			to.m[i][j]=0;
			vector<pair<pair<int,int>,int> >p;
			for(int k=0;k<4;k++)p.push_back(make_pair(make_pair(i,j),k));
			while(p.size()){
				vector<pair<pair<int,int>,int> >tmp;
				for(int k=0;k<p.size();k++){
					int nr=p[k].first.first;
					int nc=p[k].first.second;
					int dir=p[k].second;
					nr+=dx[dir];
					nc+=dy[dir];
					if(nr<0||nc<0||nr>=4||nc>=4)continue;
					if(to.m[nr][nc]){to.m[nr][nc]++;continue;}
					tmp.push_back(make_pair(make_pair(nr,nc),dir));
				}
				for(int k=0;k<4;k++)for(int l=0;l<4;l++)
					if(to.m[k][l]>=5){
						to.m[k][l]=0;
						for(int m=0;m<4;m++)tmp.push_back(make_pair(make_pair(k,l),m));
					}
				p=tmp;
			}
		}
		if(solve(a-1,to))return 1;
	}
	return 0;
}
int main(){
	for(int i=0;i<4;i++)for(int j=0;j<4;j++)scanf("%d",&c[i][j]);
	for(int i=0;i<=5;i++){
		wolf st;
		for(int j=0;j<4;j++)for(int k=0;k<4;k++)st.m[j][k]=c[j][k];
		if(solve(i,st)){
			printf("%d\n",i);return 0;
		}
	}
	printf("-1\n");
}

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


using namespace std;
#define int long long

int32_t main() 
{
    int n,i,j;
    cin>>n;
    int a[n],b[n]={0};
    int freq[200001]={0};
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
        freq[a[i]]++;
    }
    
    sort(a,a+n);
    vector<pair<int,int>> v;
    vector<int> vv;
    for(i=0;i<n;i++)
    {
        int cnt=1;
        while(i+1<n && a[i]==a[i+1]) 
        {
            i++;
            cnt++;
        }
        cnt=(cnt*(cnt-1))/2;
        vv.push_back(cnt);
        v.push_back({a[i],cnt});
    }
    
    for(i=1;i<v.size();i++)
    {
        v[i].second+=v[i-1].second;
    }
    
    int m=v.size();
    //cout<<m<<endl;
    map<int,int> mp;
    for(i=0;i<v.size();i++)
    {
        int temp=v[m-1].second-vv[i];
        int tt=freq[v[i].first]-1;
        temp+=(tt*(tt-1))/2;
        mp[v[i].first]=temp;
    }
    
    for(i=0;i<n;i++)
    {
        cout<<mp[b[i]]<<"\n";
    }
    
}

Measured memory_bytes: 17128
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    sx, sy, tx, ty = MI()

    ans = deque([])
    # path1
    ans.extend(['U']*abs(ty - sy))
    ans.extend(['R']*abs(tx - sx))

    # path2
    ans.extend(['D']*abs(ty - sy))
    ans.extend(['L']*abs(tx - sx))

    # path3
    ans.extend(['L'])
    ans.extend(['U']*(abs(ty - sy)+1))
    ans.extend(['R']*(abs(tx - sx)+1))
    ans.extend(['D'])

    # path4
    ans.extend(['R'])
    ans.extend(['D'] * (abs(ty - sy)+1))
    ans.extend(['L'] * (abs(tx - sx)+1))
    ans.extend(['U'])

    # print(ans)
    printlist(ans, '')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 27192
N = int(input())
from collections import deque
a = deque(list(map(int, input().split())))
a.append(0)
a.appendleft(0)
s = 0
for i in range(N + 1):
    s += abs(a[i + 1] - a[i]) 
for i in range(1, N + 1):
    ans = s - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1])
    print(ans)

Measured memory_bytes: 14312
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
#define what(x) cerr << #x << " is " << x << endl;
const int INF = 1 << 28;

int main() {
    int N;
    cin >> N;
    vi a(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    int max_idx = max_element(a.begin(), a.end()) - a.begin();
    int min_idx = min_element(a.begin(), a.end()) - a.begin();
    cout << 2 * (N - 1) << endl;
    if (a[max_idx] >= -a[min_idx]) {
        for (int i = 0; i < N; ++i) {
            if (max_idx != i)
                cout << max_idx + 1 << " " << i + 1 << endl;
        }
        for (int i = 0; i < N - 1; ++i) {
            cout << i + 1 << " " << i + 2 << endl;
        }
    } else {
        for (int i = 0; i < N; ++i) {
            if (min_idx != i)
                cout << min_idx + 1 << " " << i + 1 << endl;
        }
        for (int i = N - 1; i >= 1; --i) {
            cout << i + 1 << " " << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string ans="No";
  REPP(i,1,10) {
    REPP(j,1,10) {
      if(i*j==N) ans="Yes";
    }
  }
  cout << ans << endl;
}

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

template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

int main()
{
  ll n, k;
  cin >> n >> k;

  if (n == 0)
  {
    cout << 0 << endl;
    return 0;
  }

  if (n < k)
  {
    cout << min(n, k-n) << endl;
    return 0;
  }
  
  ll amari = n % k;
  cout << min(k - amari, amari) << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))

ans=0

for i in range(N):
    if V[i]>C[i]:
        ans+=V[i]-C[i]
    elif V[i]<C[i]:
        ans+=0
    else:
        ans+=0

print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s)                                                               \
    do {                                                                       \
    } while (0)
#define dump(x)                                                                \
    do {                                                                       \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

void solve() {
    int n;
    cin >> n;
    VVI a(2, VI(n));
    REP(i, 0, 2) REP(j, 0, n) cin >> a[i][j];
    VVI dp(2, VI(n));
    dp[0][0] = a[0][0];
    dp[1][0] = a[1][0] + a[0][0];
    REP(j, 1, n) {
        dp[0][j] = dp[0][j - 1] + a[0][j];
        dp[1][j] = max(dp[1][j - 1], dp[0][j]) + a[1][j];
    }
    cout << dp[1][n - 1] << endl;
}

signed main() {
    solve();

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    readLine()
    val x = readLine()!!.split(" ").map{ it.toInt() }
    val min = x.min()!!
    val max = x.max()!!
    var res: Int? = null
    for (i in min..max) {
        var tmp = 0;
        x.forEach { tmp += Math.pow((it-i).toDouble(), 2.0).toInt() }
        res = if (res == null) tmp else Math.min(res, tmp)
    }
    println(res)
}

Measured memory_bytes: 37692
/*データセットは 2 行からなる． 
1 行目には品物の個数 n と使ってよい最大の金額 m が与えられる． 
n は整数であり，2 ≤ n ≤ 1000 が成り立つ． 
m は整数であり，2 ≤ m ≤ 2,000,000 が成り立つ． 
2 行目には n 個の品物の価格が与えられる． 
ai (1 ≤ i ≤ n) が i 番目の品物の価格である． 
この値は整数であり，1 以上 1,000,000 以下である．*/
#include<iostream>
using namespace std;
int main(){
	while(true){
		int n,m;
		cin>>n>>m;
		if(n==0&&m==0)break;
		int a[1000]={};
		int b=0;
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(a[i]+a[j]<=m&&a[i]+a[j]>b){
					b=a[i]+a[j];
				}
			}
		}
		if(b==0){
			cout<<"NONE"<<endl;
		}	
		else{
			cout<<b<<endl;
		}	
    }
	return 0;
}				



Measured memory_bytes: 3100
#include<stdio.h>
#include<math.h>
int main()
{
  int n,i,j,pri=0;
  scanf("%d",&n);
 
  int N[n];
  for(i=0; i<n; i++){
    scanf("%d",&N[i]);
     
    int k=0;
    if((N[i]==2) || (N[i]==3)) pri++;
  
    else if((N[i]%2)!=0){
      for(j=3;j<=sqrt(N[i]);j+=2){   
    if((N[i]%j)==0){
      k=1;
      break;
    }
      }
      if(k==0) pri++;
    }
  }
  printf("%d\n",pri);
  return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int k,n;
    cin >> k >> n;
    int A[n];
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    long long int min = A[n-1] - A[0];
    for(int i = 0; i < n-1; i++){
        A[i] += k;
        if(min > A[i] - A[i+1]){
            min = A[i] - A[i+1];
        }
    }
    cout << min << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }

typedef int type;
const type INIT = 0;

class segment_tree {
private:
	int n;
	vector<type> dat;

	inline type function(type a, type b) const {
		return max(a, b);
	}

	type query(int a, int b, int k, int l, int r) const {
		if(r <= a || b <= l)
			return INIT;

		if(a <= l && r <= b) {
			return dat[k];
		}
		else {
			const type vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			const type vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return function(vl, vr);
		}
	}

public:
	segment_tree(int n_) {
		n = 1;
		while(n < n_) n *= 2;
		dat.resize(2 * n - 1, INIT);
	}

	inline void update(int k, type a) {
		k += n - 1;
		dat[k] = a;

		while(k > 0) {
			k = (k - 1) / 2;
			dat[k] = function(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}

	inline type query(int a, int b) const {
		return query(a, b, 0, 0, n);
	}
};

inline int next(int idx, int mod) {
	return (idx + 1) % mod;
}

inline int mod_sub(int a, int b, int mod) {
	return (a - b + mod) % mod;
}

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

	int n, k;
	cin >> n >> k;

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

	const int number_of_edges = n / 2;
	int lds = 0;
	vector<bool> used(n, false);

	for(int i = 0; i < n; ++i) {
		if(used[i]) continue;

		used[i] = true;
		used[a[i]] = true;

		vector<int> sequence(n, -1);
		const int pos = a[i] - i;

		for(int j = i + 1; j != a[i]; j = next(j, n)) {
			const int pos_a = mod_sub(a[j], i, n);
			if(pos_a > pos) { // intersect
				sequence[n - pos_a - 1] = mod_sub(j, i, n);
			}
		}

		sequence.erase(remove(sequence.begin(), sequence.end(), -1), sequence.end());

		segment_tree seg(n);

		for(int i = 0; i < static_cast<int>(sequence.size()); ++i) {
			const int value = seg.query(sequence[i] + 1, n) + 1;
			chmax(lds, value);
			seg.update(sequence[i], value);
		}
	}

	int ans = min(lds + 1 + k, number_of_edges);
	cout << ans << endl;
	return EXIT_SUCCESS;
}

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

using namespace std;

#define N 800
#define LL long long

const LL mod=1000000007;
LL n,m,a[N],b[N],f[N][N],g[N][N];

void upd(LL &x,LL y){x=(x+y%mod+mod)%mod;}

int main(){
	scanf("%lld",&n);
	for (LL i=0;i<n*2;++i) scanf("%lld",a+i);
	for (LL i=0;i<n;++i){
		LL x=a[i<<1],y=a[i<<1|1];
		if (x>0&&y>0){b[x]=b[y]=-1; continue;}
		if (x<0&&y<0){++m; continue;}
		if (x>0) b[x]=1;
		if (y>0) b[y]=1;
	}
	f[0][0]=1;
	for (LL i=1,x=0,y=0;i<=n*2;++i){
		if (b[i]<0) continue;
		memset(g,0,sizeof g);
		if (b[i]>0){
			for (LL j=0;j<=x+y;++j)
				for (LL k=0;k<=x+y;++k){
					upd(g[j+1][k],f[j][k]);//m
					if (k) upd(g[j][k-1],f[j][k]*k);//m
				}
			++x;
		}
		else{
			for (LL j=0;j<=x+y;++j)
				for (LL k=0;k<=y;++k){
					if ((j-k-x+y)>=0&&m-(j-k-x+y)/2>0) upd(g[j+1][k],f[j][k]*(m-(j-k-x+y)/2));//m-1
					if (j) upd(g[j-1][k],f[j][k]);//m
					upd(g[j][k+1],f[j][k]);//m
				}
			++y;
		}
		memcpy(f,g,sizeof f);
	}
	printf("%lld\n",f[0][0]);
	
	return 0;
}
			

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


int main()
{
	int N;
	cin>>N;
	map<int,int> m;
	rep(i,N)
	{
		int a;
		cin>>a;
		m[a]++;
	}
	int ans=0;
	for(auto p : m)
	{
		if(p.first>p.second)
		{
			ans+=p.second;
		}
		else
		{
			ans+=p.second-p.first;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7928
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;

int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS

  
    int n;
    cin >> n;

    if(n >= 30)
    {
      cout << "Yes";
    }
    else
    {
      cout << "No";
    }



    return 0;
}


Measured memory_bytes: 3648
import sys
n = int(input())
h = list(map(int, input().split()))

last = h[n-1]
for i in range(n-1):
  if h[n-2-i] > h[n-1-i] + 1:
    print ("No")
    sys.exit()
  elif h[n-2-i] > h[n-1-i]:
    h[n-2-i] -= 1
  
print ("Yes")

Measured memory_bytes: 63856
# coding: utf-8

def showBuilding(mansion):
    for i, building in enumerate(mansion):
        for line in building:
            for room in line:
                print(' ' + str(room), end='')
            print()
        if i != 3:
            print('####################')

def calcMoving(mansion, moving_status):
    b, f, r, v = moving_status
    live_in_person = mansion[b-1][f-1][r-1]
    
    if live_in_person + v >= 9:
        live_in_person = 9
    elif live_in_person + v < 0:
        live_in_person = 0
    else:
        live_in_person += v
    
    mansion[b-1][f-1][r-1] = live_in_person

if __name__ == '__main__':
    mansion = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
    
    for _ in range(int(input())):
        calcMoving(mansion, map(int, input().split()))

    showBuilding(mansion)



Measured memory_bytes: 5628
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
//typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-7

#define INF 1e9

int const MaxSize = 1e5 + 10;
LL a[3* MaxSize];
int n;

int main() {

	ios_base::sync_with_stdio(false);
	//freopen("/Users/george/A_1.in", "r", stdin);

	cin >> n;
	LP(i, 0, 3*n){
		cin >> a[i];
		a[i] *= -1;
	}

	sort(a, a + 3*n);

	LL nAns = 0;

	LP(i, 0, n){
		nAns += a[2 * i + 1];
	}

	cout << -nAns << endl;


	return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

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

        int N = nextInt(sc);

        int V[] = getIntArray(sc, N);
        int C[] = getIntArray(sc, N);

        show(calc(V, C, N));
    }

    private static int calc(int[] V, int[] C, int N) {
        int answer = 0;

        for (int i = 0; i < N; i++) {
            int diff = V[i] - C[i];
            if (diff > 0) answer += diff;
        }

        return answer;
    }

    private static void show(int answer) {
        System.out.println(answer);
    }

    private static int[] getIntArray(Scanner sc, int range) {
        int A[] = new int[range];
        for (int i = 0; i < range; i++) {
            A[i] = nextInt(sc);
        }
        return A;
    }

    private static int nextInt(Scanner sc) {
        return Integer.parseInt(sc.next());
    }
}

Measured memory_bytes: 23124
#1_5_C
import math

def plot(x,y):
    print(f'{x:.8f}',"",f'{y:.8f}')

def Koch(n,x1,y1,x2,y2):
    if n == 0:
        plot(x1,y1)
        return
    sx = (2 * x1 + x2) / 3
    sy = (2 * y1 + y2) / 3
    tx = (x1 + 2 * x2) / 3
    ty = (y1 + 2 * y2) / 3
    ux = (tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/(2))+sx
    uy = (tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
    Koch(n-1,x1,y1, sx,sy)
    Koch(n-1,sx,sy, ux,uy)
    Koch(n-1,ux,uy, tx,ty)
    Koch(n-1,tx,ty, x2,y2)
    
n = int(input())    
Koch(n,0,0, 100,0)
plot(100,0)


Measured memory_bytes: 5864
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
const int N = 1000000;

int main() {
    string s; cin >> s;
    bool ans = true;

    if(s.front() != 'A')ans = false;
    int count = 0;

    for (int i = 1; i < s.size(); ++i) {
        if(isupper(s[i])){
            if(i == 1 || i == s.size() - 1 || s[i] != 'C'){
                ans = false;
            }
            count++;

        }
    }
    if(count != 1)ans = false;

    if(ans)print("AC");
    else print("WA");
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

vector<vector <int> > input;

int h_in_max(int lx, int ly, int rx, int ry){
	int m = input[ly + 1][lx + 1];

	REP(i, ly + 1, ry){
		REP(j, lx + 1, rx){
			if(m <= input[i][j]) m = input[i][j];
		}
	}

	return m;
}

int h_out_min(int lx, int ly, int rx, int ry){
	int m = input[ly][lx];

	REP(i, ly, ry + 1){
		REP(j, lx, rx + 1){
			if(i == ly || i == ry || j == lx || j == rx){
				if(input[i][j] <= m) m = input[i][j];
			}
		}
	}

	return m;
}

int point(int lx, int ly, int rx, int ry, int m){
	int ans = 0;

	REP(i, ly + 1, ry){
		REP(j, lx + 1, rx){
			ans += m - input[i][j];
		}
	}

	return ans;
}

int main(){
	vector<int> ans;

	while(true){
		int d, w;
		cin >> d >> w;

		if(d == 0 && w == 0) break;

		rep(i, d){
			vector<int> v;

			rep(j, w){
				int x;
				cin >> x;
				v.push_back(x);
			}

			input.push_back(v);
		}

		int tmpans = 0;

		// 左上
		REP(ly, 0, d - 2){
			REP(lx, 0, w - 2){
				// 右下
				REP(ry, ly + 2, d){
					REP(rx, lx + 2, w){
						int outmin = h_out_min(lx, ly, rx, ry);
						int inmax = h_in_max(lx, ly, rx, ry);

						if(inmax < outmin){
							int p = point(lx, ly, rx, ry, outmin);
							
							if(tmpans <= p){
								tmpans = p;
								// cout << p << endl;
							}
						}
					}
				}
			}
		}

		ans.push_back(tmpans);
		input.clear();
	}

	for(auto i : ans){
		cout << i << endl;
	}

	return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 100000;
int main()
{
  int n,a,i,res=0;
  int c[N_MAX];
  cin >> n;
  fill(c,c+N_MAX,0);
  for(i=0;i<n;i++){
    cin >> a;
    c[a]++;
  }
  for(i=1;i<N_MAX-1;i++)
    res=max(res,c[i-1]+c[i]+c[i+1]);
  cout << res << endl;
  return 0;
}


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

int main() {
    int N, A;
    cin >> N >> A;
    int x;
    x = N % 500;

    if(x <= A) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int alice, bob;
    cin >> alice >> bob;
    if (alice == bob)
        cout << "Draw";
    else if (alice == 1)
        cout << "Alice";
    else if (bob == 1)
        cout << "Bob";
    else if (alice > bob)
        cout << "Alice";
    else if (alice < bob)
        cout << "Bob";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int maxn=2e5+10;
int a[maxn];
long long  num[maxn];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<maxn;i++)num[i]=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		num[a[i]]++;
	}	
	long long ans=0,tmp;
	for(int i=1;i<=n;i++){
		ans=ans+num[i]*(num[i]-1)/2;
	}
	for(int i=1;i<=n;i++){
		tmp=num[a[i]]*(num[a[i]]-1)/2-(num[a[i]]-2)*(num[a[i]]-1)/2;
		printf("%lld\n",ans-tmp);
	}
	return 0;
}

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

int main()
{
    int n,k,sum=0;
    cin>>n>>k;
    int ar[n+4];
    for(int i=1;i<=n;i++)
        cin>>ar[i];
    sort(ar+1,ar+n+1);
    for(int i=n;i>=1,k>0;i--)
    {
        sum+=ar[i];
        k--;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
   string a,b,s;
    cin >> a >> s >> b;
    transform(s.begin(),s.end(),s.begin(),::toupper);
    cout << "A" << s[0] << "C" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n;
std::vector<long> edge[100005];
long u[2];//[0]:u, [1]:v
long dist[2][100005];

void dfs(long p, long vis){
    for(long i = 0; i < edge[vis].size(); i++){
        long nx = edge[vis][i];
        if(dist[p][nx] == -1){
            dist[p][nx] = dist[p][vis] + 1;
            dfs(p, nx);
        }
    }
}

int main(){
    scanf("%ld%ld%ld", &n, &u[0], &u[1]);
    for(int i = 0; i < n-1; i++){
        long a, b;
        scanf("%ld%ld", &a, &b);
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    for(long i = 1; i <= n; i++){
        dist[0][i] = -1;
        dist[1][i] = -1;
    }
    dist[0][u[0]] = 0;
    dfs(0, u[0]);
    dist[1][u[1]] = 0;
    dfs(1, u[1]);
    long d = 0;
    for(long i = 1; i <= n; i++){
        if(dist[1][i] - dist[0][i] > 0){
            d = std::max(d, dist[1][i]);
        }
    }
    printf("%ld\n", d-1);
}


Measured memory_bytes: 12544
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];


    ll ans = 0;
    sort(a.begin(), a.end(), greater<ll>());
    ans += a[0];
    int now = n-2;
    int i = 1;
    while(now > 0){
        ans += a[i] * min(now, 2);
        now = max(0, now-2);
        i++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4456
#include <stdio.h>
#include <vector>
#include <list>
#include <array>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <stdexcept>


using std::string;
using std::vector;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// util
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

std::vector<std::string> split(const std::string& input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// user func
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void printList(const vector<int>& list) {
    // print
    for(int i = 0; i < list.size(); i++){
        printf("%d", list[i]);
        if(i != list.size() -1){
            printf(" ");
        }
    }
    printf("\n");
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// logic
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

vector<int> countingSort(vector<int>& list){
    const int max = 2000000;
    // const int max = 10;
    vector<int> result(list.size());
    vector<int> countingList(max, {0});
    
    // count
    for(int i = 0; i < list.size(); i++){
        countingList[list[i]]++;
    }
    
    // set lower num count
    for(int i = 1; i < countingList.size(); i++){
        countingList[i] = countingList[i - 1] + countingList[i];
    }

    // sort
    for(int i = list.size() - 1; 0 <= i; i--){
        int index = countingList[list[i]] - 1;
        result[index] = list[i];
        countingList[list[i]]--;
    }
    return result;
}

void solve() {
    int n;
    scanf("%d", &n);
    vector<int> list(n);
    for(int i = 0; i < n; i++){
        int v;
        scanf("%d", &v);
        list[i] = v;
    }
    auto result = countingSort(list);
    printList(result);
    
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// main
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    solve();
    return 0;
}


Measured memory_bytes: 26256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d,x,a[100];
    cin>>n>>d>>x;
    int ans=x;
    for(int i=0;i<n;i++){
        cin>>a[i];
        int o=1+(d-1)/a[i];
        ans+=o;
    }
    cout<<ans<<endl;
    return 0;
}

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

int A, B, C, K;
void input() {
  cin >> A >> B >> C >> K;
}

void solve() {
  int s = 0;
  if (A + B < K) cout << 2 * A + B - K << endl;
  else if (A < K) cout << A << endl;
  else cout << K << endl;
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  int N;
  string s, t;
  cin >> N >> s >> t;
  for (int i = 0; i < N; ++i) {
    bool flg = true;
    for (int j = 0; j < N - i; ++j) {
      if (s[i + j] != t[j]) {
        flg = false;
        break;
      }
    }
    if (flg) {
      printf("%d\n", N + i);
      return 0;
    }
  }
  printf("%d\n", 2 * N);
}

Measured memory_bytes: 3216
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;

typedef long long ll;

stringstream input;

struct complex{
	bool ov;
	ll re, im;

	complex( ll re_, ll im_, bool ov_ = false ):
		re(re_), im(im_), ov(ov_)
		{
			if( !ov ){
				ov = max( abs(re), abs(im) ) > 10000;
			}
		}

	complex operator -(){
		return complex( -re, -im, ov );
	}
	void operator +=( const complex &c ){
		*this = complex( re + c.re, im + c.im, ov | c.ov );
	}
	void operator -=( const complex &c ){
		*this = complex( re - c.re, im - c.im, ov | c.ov );
	}
	void operator *=( const complex &c ){
		*this = complex(
			re * c.re - im * c.im,
			re * c.im + im * c.re,
			ov | c.ov
		);
	}
};
const complex i( 0, 1 );

complex term();
complex factor();
complex expr();

complex expr(){
	complex c = term();
	char ch;
	for(;;){
		if( input.peek() == '+' ){
			input >> ch;
			c += term();
		}
		else if( input.peek() == '-' ){
			input >> ch;
			c -= term();
		}
		else break;
	}
	return c;
}

complex term(){
	complex c = factor();
	char ch;
	while( input.peek() == '*' ){
		input >> ch;
		c *= factor();
	}
	return c;
}

complex factor(){
	char ch;
	if( input.peek() ==  '(' ){
		input >> ch;
		complex c = expr();
		input >> ch;
		return c;
	}
	if( input.peek() == 'i' ){
		input >> ch;
		return i;
	}
	if( input.peek() == '+' ){
		input >> ch;
		return factor();
	}
	if( input.peek() == '-' ){
		input >> ch;
		return -factor();
	}
	
	ll val;
	input >> val;
	return complex( val, 0, input.fail() );
}

int main(){
	for( string s; getline( cin, s ); ){
		input.clear();
		input.str(s);
		complex c = expr();

		if( c.ov ) cout << "overflow";
		else{
			if( c.re ){
				cout << c.re;
				if( c.im > 0 ) cout << '+';
			}
			else if( !c.im )
				cout << '0';

			if( c.im ){
				cout << c.im << 'i';
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<ll, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

int main(){
    fastIO;
    int n;
    cin >> n;
    int c0 = 0, c1 = 0;
    int a;
    for(int i = 0 ; i < n ; i ++ ){
        cin >> a;
        if(a % 2 == 0)
            c0 ++ ;
        else
            c1 ++ ;
    }
    if(c1 % 2 == 0)
        cout << "YES\n";
    else
        cout << "NO\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);
		StringBuilder sb = new StringBuilder();
		while(sc.hasNext()){
			
			int m = Integer.parseInt(sc.next());
			int f = Integer.parseInt(sc.next());
			int r = Integer.parseInt(sc.next());
			
			if(m== -1 && f == -1 && r == -1 ){
				
				break;
			}
			
			sb.append(culculateRank(m,f,r));
			sb.append("\n");
			
		}
		System.out.print(sb);
		
		
	}

	private static String culculateRank(int m, int f, int r) {
		
		if(m == -1 || f == -1){
			return "F";
		}
		
		int sum = m + f;
		
		if(sum >= 80){
			
			return "A";
		}
		else if(65 <= sum && sum < 80){
			
			return "B";
		}
		else if(50 <= sum && sum < 65){
			
			return "C";
		}else if(30 <= sum && sum < 50){
			
			if( r>=50){
				return "C";
			}else{
				return "D";
			}
			
		}
		
		return "F";
	}
	
	

}



Measured memory_bytes: 26104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
typedef pair<double, double> dd;
#define mp make_pair
#define pb push_back
#define debug(x) cerr << #x << " = " << x << " "

const int N = 2e5+2;
const int A = 26;
char s[N];
int occur[A];
int d[N];
int choice[N];
int nxt[N];
int cal(int choice)
{
  return d[occur[choice]+1] + 1;
}
int main()
{
  while (~scanf("%s", s))
    {
      int len = strlen(s);
      fill(occur, occur+A, len);
      d[len] = 1;
      d[len+1] = 0;
      for (int i = len-1; i >= 0; --i)
	{
	  occur[s[i]-'a'] = i;
	  d[i] = cal(choice[i] = 0);
	  for (int c = 1; c < A; ++c)
	    {
	      int tmp = cal(c);
	      if (tmp < d[i])
		{
		  d[i] = tmp;
		  choice[i] = c;
		}
	    }
	  nxt[i] = occur[choice[i]]+1;	  
	}
      int cur = 0;
      while (cur < len)
	{
	  putchar(choice[cur]+'a');
	  cur = nxt[cur];
	}
      putchar('\n');
    }
}


Measured memory_bytes: 2816
#include<iostream>
#include<cstring>
#include<cstdio>
#define N 100010
using namespace std;
int fa[N],d[N];
inline int findf(int x)
{
	int fx=x,y,sav,s=0;
	while(fx^fa[fx]) s+=d[fx],fx=fa[fx];
	while(x^fx) sav=d[x],d[x]=s,s-=sav,
				y=fa[x],fa[x]=fx,x=y;
	return fx;
}
int main()
{
	int n,m,f=1;scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) fa[i]=i,d[i]=0;
	while(m--)
	{
		int x,y,z;scanf("%d%d%d",&x,&y,&z);
		int fx=findf(x),fy=findf(y);
		if(fx^fy) fa[fx]=fy,d[fx]=z+d[y]-d[x];
		else if(d[x]-d[y]==z) continue;
		else {	f=0;break;	}
	}
	if(f) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
    ll X;
    cin>>X;
    vector<ll> Yaku(0);
    ll Y=X;
    ll YY=pow(X, 0.5);
    ll Sz=0;
    for(ll i=1; i<=YY; i++){
        if(Y%i==0){
            Yaku.push_back(i);
            if(i*i!=Y){
                Yaku.push_back(Y/i);
                Sz++;
            }
            Sz++;
        }
    }
    sort(ALL(Yaku));
    rep(i, Sz){
        ll B=0;
        ll A=B+Yaku[i];
        ll AA=pow(A, 5);
        ll BB=pow(B, 5);
        while(1){
          		//cout<<A<<" "<<B<<endl;
            if(AA-BB==X){
                cout<<A<<" "<<B<<endl;
                return 0;
            }
          	if(AA-BB>X)break;
            A++;
            B++;
            AA=pow(A, 5);
            BB=pow(B, 5);
        }
    }
  	rep(i, Sz){
        ll B=0;
        ll A=B+Yaku[i];
        ll AA=pow(A, 5);
        ll BB=pow(B, 5);
        while(1){
          		//cout<<A<<" "<<B<<endl;
            if(AA+BB==X){
                cout<<A<<" "<<-1*B<<endl;
                return 0;
            }
          	if(A==0)break;
            A--;
            B++;
            AA=pow(A, 5);
            BB=pow(B, 5);
        }
    }
  
}

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;


int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    cout << max(a*b, c*d) << endl;

    return 0;
}



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

#define int long long
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int N, C;
int D[555][555];
int c[555][555];
map<int, int> mp0, mp1, mp2; // map<色, 個数>
int X[5][50];

// mod0の色、mod1の色、mod2の色を決め打った時の合計コスト
int solve(int zero, int one, int two) {
	int ret = 0;
	// mod0の色を変える合計コストを求める
	for (int ci = 1; ci <= C; ci++) {
		ret += D[ci-1][zero-1] * X[0][ci];
	}
	// mod1の色を変える合計コストを求める
	for (int ci = 1; ci <= C; ci++) {
		ret += D[ci-1][one-1] * X[1][ci];
	}
	// mod2の色を変える合計コストを求める
	for (int ci = 1; ci <= C; ci++) {
		ret += D[ci-1][two-1] * X[2][ci];
	}

	return ret;
}

signed main() {
	cin >> N >> C;
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			cin >> D[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> c[i][j];
			int I = i+1, J = j+1;
			// mod0, mod1, mod2ごとにその色が何個あるかを求める
			X[(I+J)%3][c[i][j]]++;
		}
	}

	int ans = 1e18;
	for (int c0 = 1; c0 <= C; c0++) { // mod0の色
		for (int c1 = 1; c1 <= C; c1++) { // mod1の色
			for (int c2 = 1; c2 <= C; c2++) { // mod2の色
				if (c0 == c1) continue;
				if (c0 == c2) continue;
				if (c1 == c2) continue;

				int t = solve(c0, c1, c2);
				chmin(ans, t);
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4352
N,M=(int(x) for x in input().split())
#N=int(input())
#A=list(map(int, input().split()))

if N>=2:
    a=int(N*(N-1)/2)
else:
    a=0

if M>=2:
    b=int(M*(M-1)/2)
else:
    b=0

print(a+b)

Measured memory_bytes: 2940
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

N = input()
A = raw_input()
B = raw_input()
C = raw_input()

ans = 0
for i in range(N):
    m = {A[i], B[i], C[i]}
    ans += len(m) - 1

print ans

Measured memory_bytes: 2808
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int N, M;
	cin >> N >> M;

	vector<bool> flg(N + 1, false);
	vector<int> T(N + 1, 0);

	for (int i = 0; i < M; i++) {
		int tmp;
		cin >> tmp;
		flg[tmp] = true;
	}

	T[0] = 1;

	for (int i = 1; i <= N; i++) {
		if (flg[i]) {
			continue;
		}
		if (i == 1) {
			T[i] += T[i - 1];
		} else {
			T[i] += T[i - 2];
			T[i] += T[i - 1];
		}
		T[i]%=MOD;
	}

	cout << T[N] << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int BinarySearch(int A[], int n, int key) {
	int mid;
	int Left = 0;
	int Right = n;
	
	while (Left < Right) {
		mid = (Left + Right) / 2;
		if (A[mid] == key) {
			return 1;
		}
		if(A[mid] < key){
			Left = mid + 1;
		} else {
			Right = mid;
		}
	}
	return 0;
}

int main() {
	int i;
	int n, q;
	int S[100000], T[50000];
	int ans = 0;

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

	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &T[i]);
		if (BinarySearch(S, n, T[i]) == 1) ans++;
	}

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

	return 0;
}


Measured memory_bytes: 2312
#include<iostream>
using namespace std;
string a;
int n=0;
int main()
{
	cin>>a;
	if(a[0]!='C')n++;
	if(a[1]!='O')n++;
	if(a[2]!='D')n++;
	if(a[3]!='E')n++;
	if(a[4]!='F')n++;
	if(a[5]!='E')n++;
	if(a[6]!='S')n++;
	if(a[7]!='T')n++;
	if(a[8]!='I')n++;
	if(a[9]!='V')n++;
	if(a[10]!='A')n++;
	if(a[11]!='L')n++;
	if(a[12]!='2')n++;
	if(a[13]!='0')n++;
	if(a[14]!='1')n++;
	if(a[15]!='6')n++;
	cout<<n<<endl;
	return 0;
}

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

int main(){

    string s, t; cin >> s >> t;
    s = s + t;
    int n = stoi(s);
    for(int i = 1; i < 10000; i++){
        if(n == i*i){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


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

int main(){
  int N,T; cin>>N>>T;
  long long X=0;
  vector<int>t(N); 
  for(int i=0;i<N;i++) cin>>t.at(i);
  
  for(int i=0;i<N-1;i++){
    if(T>t.at(i+1)-t.at(i))
      X+=t.at(i+1)-t.at(i);
    else
      X+=T;
  }
  
  X+=T;
  
  cout<<X;
}

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

int main() {
	string s;
	cin >> s;
	bool s1 = true;
	bool s2 = true;
	bool s3 = true;

	int hs = (s.length() - 1) / 2;

	int l1 = hs;
	int l2 = hs;
	int sl = s.length() - 1;
	int sl2 = s.length() - 1;
	
	for(int i = 0; i < hs; i++) {
		if(s[i] != s[--l1]) s1 = false;
	}
	for(int i = 0; i < hs; i++) {
		if(s[++l2] != s[sl--]) s2 = false;
	}

	for(int i = 0; i < hs; i++) {
		if(s[i] != s[sl2--]) s3 = false;
	}
	
    if(s1 && s2 && s3) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,c=0;
  cin>>n;
  string s;
  cin>>s;
  for(int i=0;i<s.length()-2;i++)
  {
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
    {
      c++;
      i+2;
    }
  }
  cout<<c;
  return 0;
}

Measured memory_bytes: 256