akhauriyash/Code-Regression huggingface dataset:
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
const int maxn=100111;
int n;
pair<int,int> a[maxn],b[maxn];
vector<pair<int,int> > v;
bool f[maxn*2];
int main()
{
	geti(n);
	ll sum0=0,sum1=0;
	for(int i=1;i<=n;i++)
	{
		ll x,y;
		getii(x,y);
		sum0+=x;
		sum1+=y;
		a[i]=MP(x,i);
		b[i]=MP(y,i);
		v.PB(MP(x,i));
		v.PB(MP(y,n+i));
	}
	sort(v.begin(),v.end());
	ll ans=0;
	bool flag=0;
	for(int i=0;i<n;i++)
	{
		int id=v[i].SS;
		f[id]=1;
		ans+=v[i].FF;
	}
	pair<pair<int,int>,pair<int,int> > mx0,mx1;
	mx0=mx1=MP(MP(-1e9,-1),MP(-1e9,-1));
	for(int i=1;i<=n;i++)
	{
		if(f[i]&&f[i+n])flag=1;
		pair<int,int> cur;
		if(f[i])
		{
			cur=a[i];
			if(cur>mx0.FF)mx0.SS=mx0.FF,mx0.FF=cur;
			else if(cur>mx0.SS)mx0.SS=cur;
		}
		if(f[i+n])
		{
			cur=b[i];
			if(cur>mx1.FF)mx1.SS=mx1.FF,mx1.FF=cur;
			else if(cur>mx1.SS)mx1.SS=cur;
		}
	}
	if(flag||mx0.FF.SS==-1||mx1.FF.SS==-1)cout<<ans<<endl;
	else
	{
//		cerr<<mx0.FF.FF<<","<<mx0.FF.SS<<" "<<mx0.SS.FF<<","<<mx0.SS.SS<<endl;
//		cerr<<mx1.FF.FF<<","<<mx1.FF.SS<<" "<<mx1.SS.FF<<","<<mx1.SS.SS<<endl;
		ll mn=2e9;
		for(int i=1;i<=n;i++)
		{
			if(f[i])
			{
				mn=min(mn,(ll)b[i].FF-max(mx1.FF.FF,(i==mx0.FF.SS?mx0.SS.FF:mx0.FF.FF)));
			}
			if(f[i+n])
			{
				mn=min(mn,(ll)a[i].FF-max(mx0.FF.FF,(i==mx1.FF.SS?mx1.SS.FF:mx1.FF.FF)));
			}
		}
		cout<<min(ans+mn,min(sum0,sum1))<<endl;
	}
	return 0;
}


Measured memory_bytes: 3824
#include <stdio.h>
#include <vector>
 
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(void)
{
  int A,B,max;
 
  scanf("%d %d",&A, &B);
  
  if(A+B>A-B) max = A+B;
  else max = A-B;
  if(max<A*B) max = A*B;
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 128
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

printList [a] = print a
printList (a:as) = putStr ( show a ) >> putChar ' ' >> printList as

main = readInt >>= print . solve

solve x
	| x <= 599  = 8
	| x <= 799  = 7
	| x <= 999  = 6
	| x <= 1199 = 5
	| x <= 1399 = 4
	| x <= 1599 = 3
	| x <= 1799 = 2
	| x <= 1999 = 1

Measured memory_bytes: 3844
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int a, b;
	cin >> a >> b;

	int ma = max(max(a + b, a - b), a * b);
	cout << ma << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <bits/stl_numeric.h>

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


int main() {

    int N,M;
    cin >> N >> M;
    vector <int> douro(N, 0);

    for(int i = 0; i < M; ++i)
    {
        int a,b;
        cin >> a >> b;
        --a;--b;
        ++douro[a];
        ++douro[b];
    }

    for(auto t:douro)
    {
        cout << t << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,l,n) for(int i=l; i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main() {
  int n,m,c; cin>>n>>m>>c;
  int a[m],b[m],cnt=0; 
  REP(i,m) cin>>b[i];
  REP(i,n){
    int sum=0;
    REP(j,m){
      cin>>a[j];
      sum+=a[j]*b[j];
    }
    if(sum+c>0) cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
n=int(input())
inix=0
iniy=0
for _ in range(n):
    t,x,y=map(int,input().split())
    dist=abs(x-inix) + abs(y-iniy)
    if t<dist or (t+dist)%2 != 0:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 3060
n, k, s = [int(i) for i in input().split(' ')]

ls = [s for i in range(k)]
if s == 10**9:
  pad = [s-1 for i in range(n-k)]
else:
  pad = [s+1 for i in range(n-k)]

for i in ls+pad:
	print(i)

Measured memory_bytes: 8904
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if (a == 1) a+=13;
  if (b == 1) b+=13;
  if (a == b) cout << "Draw" << endl;
  else cout << (a>b ? "Alice" : "Bob") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926

typedef long long int ll;

//ll chk[55];
//ll num[55];
//ll num2[55];
//ll num[ten5];
//ll num2[ten5];
//char cmap[10][10];
//priority_queue<long long int> pq;   //big at front
//stack<int> stk;
//vector<pair<ll,ll>> vint;
//vector<ll> vtime;
//deque<ll> deq[55];
//list<int> li;
//set<int> sint;
//set<ll> sll;
//map<ll,ll> mp;


int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3,range;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1;
    long long int a,a1,a2,a3,a4,a5,a6;
    a=a1=a2=a3=a4=a5=a6=0;
    //float f,g,h;
    //string s,s1;
    //char now,pre,c;
    cin>>n;
    m=n;
    while(m>0)
    {
        sum+=m%10;
        m/=10;
    }
    if(n%sum==0) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
_n, m = gets.split.map(&:to_i)
data = Hash.new{|h, k| h[k] = []}
m.times do |i|
  p, y = gets.split.map(&:to_i)
  data[p] << [i, y]
end
arr = Array.new(m)
data.each do |k,v|
  v.sort_by{|tmp| tmp[1]}.each_with_index do |tmp, i|
    arr[tmp[0]] = [k, i+1]
  end
end
arr.each do |v|
  puts format("%06d%06d", v[0], v[1])
end


Measured memory_bytes: 32892
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N;

  cin >> N;

  vector<int> a(N);

  for(int i=0;i<N;i++){  
    cin >> a.at(i);
  }

  if(N==1){
    cout << 1 << endl;
    return 0;
  }//要素一個の場合

  sort(a.begin(),a.end());//昇順に

  int max=-1;

  for(int i=0;i<a.size()-1;){
    int count=1,step=1;

    while(a.at(i)==a.at(i+count)||a.at(i)+1==a.at(i+count)||a.at(i)+2==a.at(i+count)){
      if(a.at(i)==a.at(i+count)){
        step++; count++;
      }

      else count++;

      if(i+count==a.size()) break;
      
    }
    
    if(max<count){
      max=count;
    }

    i+=step;
  }

    cout << max << endl;
  

  return 0;
}

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

#define sd1(a) scanf("%d",&a)
#define sd2(a,b) scanf("%d %d",&a,&b)

using namespace std;
using Graph = vector<vector<int>>;

// 深さ優先探索
Graph G(100005);
int Fennec[100005];
int Sunuke[100005];

void dfs(int v,int before,int step,bool f) {
		if(f) Fennec[v]=step;
		else Sunuke[v]=step;
    for(int i=0;i<G[v].size();i++)
			if(G[v][i]!=before) dfs(G[v][i],v,step+1,f);
}

int main()
{
	int a,b;
	int N;
	int ans=0;
	sd1(N);
	for(int i=0;i<N-1;i++){
		sd2(a,b);
		a--,b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(0,-1,0,true);
	dfs(N-1,-1,0,false);
	for(int i=0;i<N;i++) ans+=(Fennec[i]<=Sunuke[i])?1:-1;
	puts((ans>0)?"Fennec":"Snuke");
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  
  cin >> a >> b >> c ;
  if(a>=b && a>=c)
    cout << b+c <<endl;
  if(b>a && b>=c)
    cout << a+c <<endl;
  if(c>b && c>a)
    cout << a+b <<endl;
}

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

int main()
{
    int n,j,c;
    scanf("%d",&n);
    char s[10000];
    scanf("%s",&s);
    j=strlen(s);
    for(int i=0;i<j;i++){
        c = s[i] - 'A';
        s[i] = 'A' + (c+n)%26;


}
printf("%s",s);
return 0;

}


Measured memory_bytes: 1744
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

vector<ll> acc;
void init(const vector<int>& a) {
    int n = a.size(); acc.assign(n + 1, 0);
    for (int i = 0; i < n; i++) acc[i + 1] = acc[i] + a[i];
}
ll get(int l, int r) { return acc[r] - acc[l]; }

vector<vector<bool>> vis;
vector<vector<ll>> memo;
ll dp(int l, int r) {
    if (l + 1 == r) return 0;
    if (vis[l][r]) return memo[l][r];
    vis[l][r] = true;
    ll res = INF;
    for (int sep = l + 1; sep < r; sep++) {
        res = min(res, dp(l, sep) + dp(sep, r) + get(l, r));
    }
    return memo[l][r] = res;
}

int main() {
    int N; cin >> N;
    vector<int> a(N);
    for (int& ai : a) cin >> ai;
    init(a);
    vis.assign(N, vector<bool>(N + 1, false));
    memo.assign(N, vector<ll>(N + 1, 0));
    cout << dp(0, N) << endl;
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000009
using namespace std;
int ans[114514];
int main(){
	string str;
	cin>>str;
	ll ss = str.size();
	ll cur = 0;
	ll rcnt = 0, lcnt = 0;
	while(cur<ss){
		if(str[cur]=='R' && lcnt==0){
			rcnt++;
		}
		else if(str[cur]=='L'){
			lcnt++;
		}
		else{
			ll rpos = cur-lcnt-1;
			ll lpos = rpos + 1;
			//cout<<rpos<<" "<<lpos<<" "<<rcnt<<" "<<lcnt<<endl;
			ans[rpos]+=(rcnt+1)/2 + lcnt/2;
			ans[lpos]+=rcnt/2 + (lcnt+1)/2;
			rcnt = 1;
			lcnt = 0;
		}
		cur++;
	}
	ll rpos = cur-lcnt-1;
	ll lpos = rpos + 1;
	//cout<<rcnt<<" "<<lcnt<<endl;
	ans[rpos]=(rcnt+1)/2 + lcnt/2;
	ans[lpos]=rcnt/2 + (lcnt+1)/2;
	for(int i=0;i<ss;i++){
		cout<<ans[i]<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#define int long long
#define REP(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define mp make_pair
#define Pii pair< int, int > 
#define Pid pair< int, double > 
#define Pdd pair< double, double > 
#define MOD 998244353
#define EPS 0.00000001

using namespace std;

signed main() {
    int n,m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2;
    return 0;
}

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

int main(){
    int n,ans=0,ans2=0;;
    cin>>n;
    vector<int>a(n);
    vector<int>b(n);
    for(int i=0;i<n;i++)cin>>a[i];

    for(int i=0;i<n;i++)cin>>b[i];
    
    vector<int>c(n-1);
    for(int i=0;i<n-1;i++)cin>>c[i];

    for(int i=0;i<n;i++){
        ans+=b[a[i]-1];
        //cout<<a[i]<<endl;
        //cout<<ans<<endl;
        //cout<<b[a[i]-1]<<endl;
        
    }
    for(int i=0;i<n-1;i++){
        if((a[i]+1)==a[i+1]){
            ans2+=c[a[i]-1];
            //cout<<a[i]<<endl;
        }
    }
    cout<<ans+ans2<<endl;

return 0;
}


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

int main(){
    int A[110][110];

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

    for(int i=0;i<c;i++){
        int x,y,r;
        scanf("%d %d %d",&x,&y,&r);

        if(r==1){
            for(int i=0;i<x;i++){
                for(int j=0;j<b;j++)
                    A[i][j]=1;
            }
        }else if(r==2){
            for(int i=x;i<a;i++){
                for(int j=0;j<b;j++)
                    A[i][j]=1;
            }
        }else if(r==3){
            for(int i=0;i<a;i++){
                for(int j=0;j<y;j++)
                    A[i][j]=1;
            }
        }else if(r==4){
            for(int i=0;i<a;i++){
                for(int j=y;j<b;j++)
                    A[i][j]=1;
            }
        }
    }
    int cc=0;

    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
            if(A[i][j]==0)  cc++;
        }
    }

    cout << cc << endl;

    return 0;
}


Measured memory_bytes: 256
while line = gets
  n = line.chomp.to_i
  break if n == 0

  stack = []
  n.times do
    stack << gets.chomp.to_i
  end

  stack.sort!
  
  wait = [0]
  for i in 1...stack.size
    wait << wait[i - 1] + stack[i - 1]
  end

  puts wait.inject(:+)
end

Measured memory_bytes: 9052
import java.util.Scanner;

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

        if (sc.nextInt() == 1) {
            System.out.println("Hello World");
        } else {
            System.out.println(sc.nextInt() + sc.nextInt());
        }
        sc.close();
    }
}

Measured memory_bytes: 22868
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  int a,b,c ;
  cin >> a >> b>> c ;
  
  if((b/a)==0){
    cout << b/a << endl ;
    return 0 ;
  }else{
    int cnt = b/a ;
    if(cnt>c){
      cout << c << endl ;
      return 0 ;
    }else{
      cout << cnt << endl ;
      return 0 ;
    }

  }
  }


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, m;
  cin >> n >> m;
  bool ok[n + 1];
  REP(i, n + 1) ok[i] = true;
  REP(i, m) {
    int a;
    cin >> a;
    ok[a] = false;
  }
  ll dp[101010] = {};
  dp[0] = dp[1] = 1;
  for (int i = 2; i <= n; ++i) {
    if (ok[i - 1]) {
      dp[i] += dp[i - 1];
      dp[i] %= MOD;
    }
    if (ok[i - 2]) {
      dp[i] += dp[i - 2];
      dp[i] %= MOD;
    }
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 1152
n, t = [int(i) for i in input().split()]
dishes = []
for _ in range(n):
    a, b = map(int, input().split())
    dishes.append((a, b))

dishes = sorted(dishes, key=lambda x: x[0])

dp = [[0] * t for _ in range(n+1)]

ans = 0

for i in range(n):
    for j in range(t):
        if j < dishes[i][0] :
            dp[i+1][j] = dp[i][j]
        else:
            if dp[i][j] > dp[i][j-dishes[i][0]]+dishes[i][1]:
                dp[i+1][j] = dp[i][j]
            else:
                dp[i+1][j] = dp[i][j-dishes[i][0]]+dishes[i][1]
    ans_i = dp[i][t-1] + max( dishes[i:], key=lambda x: x[1])[1]
    ans = max(ans, ans_i)

print(ans)

Measured memory_bytes: 117976
N = int(input())
A = [int(_) for _ in input().split()]
Q = int(input())
b_to_c = [[int(_) for _ in input().split()] for i in range(Q)]

sum = 0
memo = [0] * (10 ** 5 + 1)
for i in A:
    memo[i] += 1
    sum += i

for bc in b_to_c:
    b = bc[0]
    c = bc[1]
    sum -= (b * memo[b])
    sum += (c * memo[b])
    memo[c] += memo[b]
    memo[b] = 0
    print(sum)


Measured memory_bytes: 31200
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

vector<ll>graph[100005];
bool visit[100005]={false};


ll res=0;
map<ll,ll>m;
map<pair<ll,ll>,ll>ans;

void dfs(ll start,ll val){
    visit[start]=true;
    res=max(res,ll(graph[start].size()));
    int cnt=1;
    for(int i=0;i<graph[start].size();i++){
        if(!visit[graph[start][i]]){
            ll k=graph[start][i];
            if(cnt!=val){ans[{min(start,k),max(start,k)}]=cnt;}
            else{cnt++;ans[{min(start,k),max(start,k)}]=cnt;}
            dfs(k,cnt);
            cnt++;
        }
    }
    }

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<pair<ll,ll>>edge;
    for(int i=0;i<n-1;i++){
        ll a,b;
        cin>>a>>b;
        edge.push_back({min(a,b),max(a,b)});
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    dfs(1,0);
    cout<<res<<endl;
    for(int i=0;i<n-1;i++){
        cout<<ans[edge[i]]<<endl;
    }
    return 0;
    }


Measured memory_bytes: 16500
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef pair<int, int> PII;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s.at(0)==s.at(1)&&s.at(1)==s.at(2)){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll A, B, H, M;
    cin>>A>>B>>H>>M;
    ll fun=H*60+M;
    double funshin=(double)(fun*6%360), jishin=(double)(fun%720)*0.5;
    double aidanokaku=abs(funshin-jishin);
    //aidanokaku=min(aidanokaku, 360-aidanokaku);
    //cout<<aidanokaku<<endl;
    cout<<setprecision(20)<<sqrt(A*A+B*B-2*A*B*cos(aidanokaku*acos(-1)/180))<<endl;
    return 0;
}


Measured memory_bytes: 4172
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) < (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n) - 1; (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (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;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    ll x,y,cnt = 0;
    cin >> x >> y;
    if (x == 1) {
        x = 2;
        ++cnt;
    }
    while (x <= y){
        x *= 2;
        ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "../../../debug_print.hpp"
#else
#define debug(...)
#endif
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    string s, t, u;
    int a, b;
    scan(s, t, a, b, u);

    if (s == u)
        a--;
    else if (t == u)
        b--;
    print(a, b);

    return 0;
}

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

int main()
{
 	int A,B,C;
  	cin>>A>>B>>C;
  
  	if(A+B+C>=22){
    	cout<<"bust"<<endl;
    }
  	else{
		cout<<"win"<<endl;
    }
  
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(){
	char s[100000];
	int t[10000000],i=0,j=0,a=1;
	int min1=0,min2=0;
	
	scanf("%s",&s);
	
	while(s[i] != '\0'){
		t[i] = s[i] - '0';
		i++;
	}
	
	for(j=0;j<i;j++){
		if((a%2) == 1){
			if(t[j] == 1){
				t[j] = 0;
				min1++;
			}
		}
		else{
			if(t[j] == 0){
				t[j] = 1;
				min1++;
			}
		}
		a++;
	}
	a=1;
	i=0;
	
	while(s[i] != '\0'){
		t[i] = s[i] - '0';
		i++;
	}
	
	for(j=0;j<i;j++){
		if((a%2) == 1){
			if(t[j] == 0){
				t[j] = 1;
				min2++;
			}
		}
		else{
			if(t[j] == 1){
				t[j] = 0;
				min2++;
			}
		}
		a++;
	}
	
	if(min1 < min2) printf("%d\n",min1);
	else printf("%d\n",min2);
	
	return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll MOD = 1000000007;

int main(){
  ll N, M;
  cin >> N >> M;
  ll a;
  vl step(N + 1, 1);
  rep(i, M){
    cin >> a;
    step[a] = 0;
  }

  vl dp(N + 1, 0);
  dp[0] = 1;

  rep2(i, 1, N + 1){
    if(i > 1){
      if(step[i - 2] != 0){
	dp[i] += dp[i - 2];
	dp[i] %= MOD;
      }      
    }
    if(step[i - 1] != 0){
      dp[i] += dp[i - 1];
      dp[i] %= MOD;
    }
  }

  cout << dp[N] << endl;
  
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int N;
 	bool can = false;
  	cin >> N;
  
  	
  	for(int i=0; i <= N/4; i++){
      for(int j=0; j <= N/7; j++){
        if(4*i+7*j == N)
          can = true;
      }
    }
  
  	if(can == true)
      cout << "Yes" << endl;
  	else
      cout << "No" << endl;
}

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

#define ALL(a) begin(a), end(a)
#define SZ(a) ((int)a.size())

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<string> grid(2 * n);
  for (int i = 0; i < 2 * n; i += 2) {
    cin >> grid[i];
    grid[i + 1] = grid[i];
  }
  for (const auto &s : grid) {
    cout << s << '\n';
  }
  return 0;
}



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

int main() {
    int n,k; cin >> n >> k;
    int ans = 1;
    for(int i=0; i<n; i++){
        ans = min(ans+k,ans*2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    long long x, k, d;
    cin >> x >> k >> d;
    if(x < 0) x = -x;
    if(x/d >= k){
        cout << x - k*d << endl;
    }else{
        k -= x/d;
        x %= d;
        if(k%2 == 1){
            x = d-x;
        }
        cout << x << endl;
    }
}


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

int ans[100][100];

int main(){
    int h, w, n;
    scanf("%d %d %d", &h, &w, &n);
    vector<int> arr(n);
    for(int i=0 ; i<n ; ++i)
        scanf("%d", &arr[i]);
    int curr = 0;
    for(int i=0 ; i<h ; ++i){
        if(i%2 == 0){
            for(int j=0 ; j<w ; ++j){
                if(arr[curr] == 0)
                    curr++;
                ans[i][j] = curr+1;
                arr[curr]--;
            }
        }
        else{
            for(int j=w-1 ; j>=0 ; --j){
                if(arr[curr] == 0)
                    curr++;
                ans[i][j] = curr+1;
                arr[curr]--;
            }
        }
    }
    for(int i=0 ; i<h ; ++i){
        for(int j=0 ; j<w ; ++j)
            printf("%d ", ans[i][j]);
        printf("\n");
    }
}


Measured memory_bytes: 384
import java.util.*;
import java.io.*;

public class Main {

    private static final int M = 1_000_000_007;

    public Main(FastScanner in, PrintWriter out, int test) {
        long A = in.nextLong();
        String[] B = in.next().split("\\.");
        int b = Integer.parseInt(B[0]) * 100 + Integer.parseInt(B[1]);
        out.println(A * b / 100);
    }

    private long pow(int x, int p) {
        long res = 1, a = x;
        while (p > 1) {
            if (p % 2 == 1)
                res = res * a % M;

            a = a * a % M;
            p /= 2;
        }
        res  = res * a % M;
        return res;
    }

    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        // Scanner in = new Scanner(
                // new BufferedReader(new InputStreamReader(System.in)));
        FastScanner in = new FastScanner(System.in);

        // int T = in.nextInt();
        for (int t = 1; t <= 1; t++) {
            Main sol = new Main(in, out, t);
        }

        out.close();
    }
}


class FastScanner{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public FastScanner(InputStream stream)
    {
        this.stream = stream;
    }

    int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    boolean isSpaceChar(int c)
    {
        return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
    }

    boolean isEndline(int c)
    {
        return c=='\n'||c=='\r'||c==-1;
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

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

    String next(){
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isSpaceChar(c));
        return res.toString();
    }

    String nextLine(){
        int c = read();
        while (isEndline(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isEndline(c));
        return res.toString();
    }
}

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

int main() {
  int N;
  cin >> N;
  float tax = 1.08;
  int price = 0;
  while (price * tax < N + 1) {
    price++;
    if (N <= price * tax && price * tax < N + 1) {
      cout << price;
      break;
    }
    if (price * tax >= N + 1) {
      cout << ":(";
      break;
    }
  }
}


Measured memory_bytes: 3520
import Data.List
main = getContents >>= mapM (putStrLn . caesar_cipher) . lines
caesar_cipher = unwords . head . filter (\ws -> intersect ws keys /= []) . map words . iterate (map shift)
 where
  keys = ["the", "the.", "this", "this.", "that", "that."] 
  shift c
   | notElem c ['a'..'z'] = c
   | c=='z' = 'a'
   | otherwise = succ c

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; ++i) cin >> A[i];

    bool ok = true;
    for (int i=0; i<N; ++i) {
        if (A[i] % 2 == 0 && (A[i] % 3 && A[i] % 5)) ok = false;
    }
    cout << (ok ? "APPROVED" : "DENIED") << endl;

    return 0;
}

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

public class Main {

	static int N, K, Z = 0, F = 0;
	static int ANSWER = Integer.MAX_VALUE;
	static int[] DATA;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] lineArr = br.readLine().split(" ");
		N = Integer.parseInt(lineArr[0]);
		K = Integer.parseInt(lineArr[1]);

		DATA = new int[N];

		lineArr = br.readLine().split(" ");

		int tmp;
		for (int i = 0; i < N; i++) {
			DATA[i] = Integer.parseInt(lineArr[i]);
			tmp = Integer.parseInt(lineArr[i]);

			if (tmp < 0) {
				F++;
			} else if (tmp == 0) {
				Z++;
			}

			DATA[i] = tmp;
		}

		int start = 0;
		if (F > K) {
			start = F - K + Z;
		}

		int startValue;
		int endValue;
		for (int i = start; i < N - K + 1; i++) {
			startValue = DATA[i];
			endValue = DATA[i + K - 1];

			tmp = endValue - startValue;
			tmp += Math.min(Math.abs(startValue), Math.abs(endValue));

			if (ANSWER > tmp) {
				ANSWER = tmp;
			}
		}

		System.out.println(ANSWER);

	}
}

Measured memory_bytes: 38868
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;
int n;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int x,a;
    cin >> x >> a;
    if (x < a) {
        cout << "0";
    } else {
        cout << "10";
    }
    return 0;
}


Measured memory_bytes: 256
from functools import reduce

n, s = map(int, input().split())
xl = [int(i) - s for i in input().split()]

def gcd_(a, b):
    while b:
        a, b = b, a%b
    return a
def gcd(*numbers):
    return reduce(gcd_, numbers)

print(abs(gcd(*xl)))

Measured memory_bytes: 14748
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
int main() {
cout << fixed << setprecision(30);
  double n;
  cin>>n;
  ll ans=0;
 for(double i=1;i<=n;i++){
   ll t=1.08*i;
   t=floor(t);

   if(t==n)ans=i;
 }
  if(ans!=0)putout(ans);
  else putout(":(");
}


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

// π M_PI
// deg = rad*180/M_PI

int main() {
    string s;
    cin >> s;
    if ( s[0] == s[1] && s[1] == s[2] ) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


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


class Program
{
    static void Main(string[] args)
    {
        string[] ABM = Console.ReadLine().Split(' ');
        int A = int.Parse(ABM[0]);
        int B = int.Parse(ABM[1]);
        int M = int.Parse(ABM[2]);
        string[] astr = Console.ReadLine().Split(' ');
        int[] a = new int[A];
        for(int i=0; i<A; i++){
            a[i] = int.Parse(astr[i]);
        }
        string[] bstr = Console.ReadLine().Split(' ');
        int[] b = new int[B];
        for(int i=0; i<B; i++){
            b[i] = int.Parse(bstr[i]);
        }

        int aMin = a[0];
        int bMin = b[0];
        for(int i=1; i<A; i++){
            if(a[i] < aMin) aMin = a[i];
        }
        for(int i=1; i<B; i++){
            if(b[i] < bMin) bMin = b[i];
        }

        int cost;
        int minCost = aMin + bMin;
        int x; int y; int c;

        int[,] dataset = new int[M,3];
        for(int i=0; i<M; i++){
            string[] input = Console.ReadLine().Split(' ');
            x = int.Parse(input[0]);
            y = int.Parse(input[1]);
            c = int.Parse(input[2]);

            cost = a[x-1] + b[y-1] - c;

            if(cost < minCost){
                minCost = cost;
            }
        }

        Console.WriteLine(minCost);
    }
}

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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n; cin>>n;
  vi a(n);
  rep(i,0,n) cin>>a[i];
  sort(all(a));
  vector<lli> pre(n);
  pre[0] = a[0];
  rep(i,1,n) pre[i] = pre[i-1] + a[i];
  int cnt = 0;
  debug(pre, a);
  rep(i,0,n) {
    lli x = pre[i];
    int pos = i;
    int flag = 0;
    while(true) {
      auto it = ub(all(a), 2*x);
      it--;
      int pp = it - a.begin();
      debug(i, pp, pos);
      if(pp == n-1) {
        break;
      }
      if(pp == pos) {
        flag = 1;
        break;
      }
      pos = pp;
      x = pre[pp];
    }
    if(!flag) cnt++;
  }
  cout<<cnt<<endl;
}



Measured memory_bytes: 1408
N = int(input())
P = [[0,0,0]]+[list(map(int,input().split())) for n in range(N)]
ans = "Yes"

for n in range(N):
  dt = P[n+1][0]-P[n][0]
  dx = abs(P[n+1][1]-P[n][1])
  dy = abs(P[n+1][2]-P[n][2]) 
  if dt<dx+dy or dt%2!=(dx+dy)%2:
    ans = "No"

print(ans)

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

long A;//[1000100];
int main(){

	long int i,j;
	long int x,y,a,b,c;
	long N,M;
	long long sum=0;
	scanf("%ld%ld",&N,&M);
	
	for(i=0;i<M;i++){
		scanf("%ld",&A);
		sum +=A;
	}
	
	if(N-sum>=0)printf("%lld\n",N-sum);
	else printf("-1\n");

	return 0;
}

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

#define sd(x) scanf("%d", &(x))
#define ll long long 
#define F first
#define S second
#define pii pair<int,int>
#define pbk push_back
#define mkp make_pair
#define PI 3.141592653589793
#define watch(x) cout << (#x) << " is " << (x) << endl
const int oo = 0x3f3f3f3f;

const int N = 100005;
const int M = 200005;
bool vis[N];
bool ok = 1;
ll dis[N];
vector<pii> adj[N];

void dfs( int v , ll d ){
	if( vis[v] && d != dis[v] ){
		ok = 0;
		return;
	}
	if( vis[v] )return;
	vis[v] = 1;
	dis[v] = d;
	for( auto it : adj[v] ){
		int c_v = it.F;
		ll D = d + it.S;
		dfs(c_v , D);
	}
}

int main(){
	int n , m;
	sd(n); sd(m);
	for( int i = 0; i < m; i++ ){
		int l , r , d;
		sd(l); sd(r); sd(d);
		adj[l].pbk(make_pair(r , d));
		adj[r].pbk(make_pair(l , -d));
	}
	for( int i = 1; i <= n; i++ )if( !vis[i] )dfs(i , 0);
	if( !ok )cout << "No\n";
	else cout << "Yes\n";
}

Measured memory_bytes: 11520
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Long> list = new ArrayList<Long>(n);
		
		for(int i = 0; i < n; i++) {
			list.add(sc.nextLong());
		}
		
		Collections.sort(list);
		int count = 0;
		
		for(int i = 0; i < n - 2; i++) {
			for(int j = i + 1; j < n - 1; j++) {
				for(int k = j + 1; k < n; k++) {
					if(list.get(i).equals(list.get(j)) || list.get(i).equals(list.get(k)) || list.get(j).equals(list.get(k))) {
						continue;
					}
					
					if(list.get(i) + list.get(j) > list.get(k)) {
						count++;
					}
					
				}
			}
		}
		
		System.out.println(count);
		
	}

}


Measured memory_bytes: 37272
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;

int main(){
	int u,v;
	map<int,int> m;
	while(~scanf("%d %d",&u,&v)){
		
		if(u==v && u==0){
			bool isok = true;
			for(map<int,int>::iterator it =m.begin();it != m.end(); it++){
				if(it->first == 1 && it->second % 2 == 0) isok = false;
				else if(it->first == 2 && it->second % 2 == 0) isok = false;
				else if(it->first > 2 && it->second % 2){
					isok = false;
					break;
				}
			}
			printf("%s\n",isok ? "OK" : "NG");
			m.clear();
			continue;
		}		
		m[u]++;
		m[v]++;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <climits>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <string>

using namespace std;

const int len = 110;
int n,sum1,sum2;
char s[len];

void init() {
    sum1 = sum2 = 0;
}

void readl() {
    scanf("%s",s);
}

void output() {
    if (sum1<=sum2) {
        for (int i=1;i<=sum2-sum1;i++) printf("(");
         printf("%s\n",s);
    }
     else {
         printf("%s",s);
         for (int i=1;i<=sum1-sum2;i++) printf(")");
     }
}

void work() {
    for (int i=0;i<n;i++) {
        if (s[i] == '(') sum1++;
         else sum2++;
        if (sum2 > sum1) {printf("(");sum1++;}
    }
    output();
}

int main() {
    //freopen("test.in","r",stdin);
    //freopen("test.out","w",stdout);
    cin >> n;
    init();
    readl();
    work();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
  vector<int> v(5);
  cin >> v[0];
  cin >> v[1];
  cin >> v[2];
  cin >> v[3];
  cin >> v[4];
  int temp = 0;
  int temp1= 0;
  int temp2 = 0;
  int total = 0;
  for(int i = 0 ; i < 5 ; ++i){
    if(v[i] % 10 != 0){
        temp2 = ( v[i] /10 + 1)*10 - v[i];
        if(temp < temp2 ){
            total +=  (temp1/ 10 + 1)*10;
            temp1 = v[i];
            temp = temp2;
        }
        else total += (v[i] / 10 + 1)*10;
    }
    else total += v[i];
  }
  total += temp1;
  if(total % 10 != 0) total -= 10;
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef pair<ll, pair<ll, ll> > P;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define REP(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)((x).size()))

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e15+10;
const ll mod = 1e9+7;//998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;


int main() {
    int N;
    cin >> N;
    vector<ll> A, B;//(200005), B(200005);
    rep(i, N){
        ll a, b;
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
    }
    
    sort(ALL(A));
    sort(ALL(B));
    //rep(i, N){
    //    cout <<A[i] << " " << B[i] << endl;
        //fprintf(stderr, "%d, %d\n", A[i], B[i]);
    //}
    if (N % 2 == 1){
        cout << B[N/2] - A[N/2] + 1;
    } else {
        ll m = A[N/2] + A[N/2 - 1];
        ll M = B[N/2] + B[N/2 - 1];
        cout << M - m + 1;
    }
        
    return 0;
}


Measured memory_bytes: 6644
#include <iostream>                                        
using namespace std;                                       
                                                           
int main(void) {                                           
  int n, m;                                                
  cin >> n >> m;                                           
  int C[m], T[n+1];                                        
  for (int i=0; i<m; i++) {                                
    cin >> C[i];                                           
    for (int j=0; j<n+1; j++) {                            
      T[j]=10001;                                          
      T[0]=0;                                              
    }                                                      
  }                                                        
  for (int i=0; i<m; i++) {                                
    for (int j=C[i]; j<=n; j++) {                          
      T[j]=min(T[j],T[j-C[i]]+1);                          
    }                                                      
  }                                                        
  cout << T[n] << endl;                                    
}                                                          
                                                           
                           

Measured memory_bytes: 3268
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define pb push_back
#define mp make_pair
#define F first
#define S1 second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define mod 1e9+7
#define P(a,b) pair<a,b>
#define CIN(V,s,n) for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n) for(int i=s;i<n;i++){cout <<  V[i] << " ";}

using namespace std;
ll up(vector<vector<char> > &G,ll r,ll c,ll m)
{
    ll n = G.size();
    if(r>=0 && c >=0 && r < n && c < m)
    {
        if(G[r][c]=='*')
            return (1 + up(G,r,c-1,m));
        else
            return 0;
    }
    else
        return 0;
}
ll down(vector<vector<char> > &G,ll r,ll c,ll m)
{
    ll n = G.size();
    if(r>=0 && c >= 0 && r < n && c < m)
    {
        if(G[r][c]=='*')
            return (1 + down(G,r,c+1,m));
        else
            return 0;
    }
    else
        return 0;
}
ll left(vector<vector<char> > &G,ll r,ll c,ll m)
{
    ll n = G.size();
    if(r>=0 && c >= 0 && r < n && c < m)
    {
        if(G[r][c]=='*')
            return (1 + left(G,r-1,c,m));
        else
            return 0;
    }
    else
        return 0;
}
ll right(vector<vector<char> > &G,ll r,ll c,ll m)
{
    ll n = G.size();
    if(r>=0 && c >= 0 && r < n && c < m)
    {
        if(G[r][c]=='*')
            return (1 + right(G,r+1,c,m));
        else
            return 0;
    }
    else
        return 0;
}
void is_star(vector<vector<char> > &G,vector<pair<ll , pair<ll ,ll > > > &S,ll r,ll c,ll m)
{
    ll u = up(G,r,c-1,m);
    ll d = down(G,r,c+1,m);
    ll l = left(G,r-1,c,m);
    ll r1 = right(G,r+1,c,m);

    if(u==d && d==l && l==r1 && d!=0)
    {
        for(ll i=1;i<=u;i++)
        {
            S.pb(mp(r+1,mp(c+1,i)));
        }
    }
}
void find_stars(vector<vector<char> > &G,vector<pair<ll , pair<ll ,ll > > > &S,ll m)
{
    ll n = G.size();
    for(ll i=1;i<n-1;i++)
    {
        for(ll j=1;j<m-1;j++)
        {
            if(G[i][j]=='*')
                {
                    //cout <<i << " " << j << endl;
                    is_star(G,S,i,j,m);
                }
        }
    }
}

int main()
{
	ll n,m,i,j,k,l,w,s,u,v,count0=0;
	cin >> n >> m >> k;

	ll a = min(n,m);
	ll b = min(m,k);
	ll c = min(n,k);

	if(a!=b)
        cout << (a+b);
    else if(a!=c)
        cout << (a+c);
    else
        cout << (b+c);

    return 0;
}


Measured memory_bytes: 256