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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    int n;
    cin >> n;
    int t[n];
    rep(i,n) cin >> t[i];
    int time = 0;
    rep(i,n){
        time+=t[i];
    }

    int m;
    cin >> m;

    int p[m];
    int x[m];

    rep(i,m) cin >> p[i] >> x[i];


    for(int i=0;i<m;i++){
        int q = time;
        q-=t[p[i]-1];
        q+=x[i];
        cout << q << endl;
    }
}

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

int cnt[100002];

int main(){
    string S;
    cin >> S;
    int N = S.size();
    int l = 0, r = N + 1;
    while(r - l > 1){
        int k = (l + r) / 2;
        bool ok;
        for(int d=0;d<2;d++){
            memset(cnt, 0, sizeof(cnt));
            ok = true;
            for(int i=0;i<k;i++){
                if(i != 0){
                    cnt[i] += cnt[i - 1];
                }
                if((S[i] == '1' && cnt[i] % 2 == d) || (S[i] == '0' && cnt[i] % 2 == (d + 1) % 2)){
                    cnt[i]++;
                    if(i + k <= N){
                        cnt[i + k]--;
                    }else{
                        ok = false;
                        break;
                    }
                }
            }
            if(ok) break;
        }
        if(ok){
            l = k;
        }else{
            r = k;
        }
    }
    cout << l << endl;

    return 0;
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;

#define PB push_back

VI PS, QS, AS, NS, cnts;
int P, Q, A, N;
int T;

VVI have_n_ts;

int p_, q_;

// p / q

constexpr int MEMO_LIMIT = 3000;
int memo[MEMO_LIMIT][MEMO_LIMIT] = {};

// require: m > n
inline int gcd(int m, int n) {
    if (m < n) return gcd(n, m);
    if (m < MEMO_LIMIT && memo[m][n]) return memo[m][n];
    int ans = __gcd(m, n);
    if (m < MEMO_LIMIT) memo[m][n] = ans;
    return ans;
}

inline void yakubun(int &p, int &q) {
    int c = gcd(p, q);
    if (c == 1) return;
    p /= c;
    q /= c;
}

inline void add(int p1, int q1, int p2, int q2, int &np, int &nq) {
    np = p1 * q2 + p2 * q1;
    nq = q1 * q2;
    if (np > 0) {
        yakubun(np, nq);
    }
}

inline void sub(int p1, int q1, int p2, int q2, int &np, int &nq) {
    add(p1, q1, -1 * p2, q2, np, nq);
}

int np, nq;
inline void dfs(int p, int q, int a, int n, int before) {
    if (a > 12000) return;

    for (int t : have_n_ts[n]) {
        cnts[t] += a <= AS[t] && p == PS[t] && q == QS[t];
    }
    
    if (n >= 7) return;

    for (int i = before; i * a <= 12000; i++) {
        add(p, q, 1, i, np, nq);
        dfs(np, nq, a * i, n + 1, i);
    }
}

int main(void) {
    have_n_ts.resize(8);
    T = 0;
    while (cin >> P >> Q >> A >> N, P) {
        yakubun(P, Q);
        PS.PB(P);
        QS.PB(Q);
        AS.PB(A);
        NS.PB(N);
        for (int i = 1; i <= N; i++) {
            have_n_ts[i].PB(T);
        }
        ++T;
    }

    cnts.resize(T);

    dfs(0, 1, 1, 0, 1);

    for (auto cnt : cnts) cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 35136
# frozen_string_literal: true

n, m, x, y = gets.split.map(&:to_i)
x_list = gets.split.map(&:to_i).sort
y_list = gets.split.map(&:to_i).sort

candidates1 = ((x + 1)..y).to_a
candidates2 = ((x_list[-1] + 1)..100).to_a
candidates3 = (-100..y_list[0]).to_a

answer =
  if (candidates1 & candidates2 & candidates3).empty?
    "War"
  else
    "No War"
  end

puts answer

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin>>a[i];
    vector<int> b(n);
    REP(i,n) b[i]=a[i];
  sort(a.begin(),a.end());
    REP(i,n){
        if(b[i]>=a[n/2]){
            cout<<a[n/2-1]<<endl;
        }else{
            cout<<a[n/2]<<endl;
        }

    }
    return 0;
}


Measured memory_bytes: 3712
# include <bits/stdc++.h>
//# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define fors(i, s) for (int i = 0; s[i]; i++)
# define in freopen("input.txt", "r", stdin)
# define out freopen("output.txt", "w", stdout)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define mkp make_pair
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
 
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e5 + 7;


int main()
{
	speed;
	int n, m;
	cin >> n >> m;
	if ( n == m ) cout << "Yes";
	else cout << "No";
	time;
}


Measured memory_bytes: 256
#include <stdio.h>


int main() {
	int w, h, x, y, r;

	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

	//	円の中心が (r,r) 以上 (w-r, h-r) 未満ならOK

	if (x < r || y < r || x > w - r || y > h - r) {
		puts("No");
	}
	else {
		puts("Yes");
	}

	return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <tuple>
#include <stdbool.h>
#include <bitset>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;
using namespace std;


int main(void) {
    int n;
    cin >> n;

    int i;
    int highest = 0;
    int miss = 0;
    for(i = 0 ; i < n ; ++i) {
        int h;
        cin >> h;
        if (highest <= h) {
            highest = h;
        } else {
            miss++;
        }
    }
    cout << (n - miss) << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>

using namespace std;

bool binary_search(vector<int> &v, int n, int s) {
  int left = 0;
  int right = n;

  while(left < right) {
    int mid = (int)( left + right ) / 2;
    if(v[mid] < s) {
      left = mid + 1;
    }
    else if(v[mid] > s) {
      right = mid;
    }
    else {
      return true;
    }
  }
  return false;
}

int main(void) {
  int n, m, q, s;
  vector<int> v;

  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> m;
    v.push_back(m);
  } 

  cin >> q;
  for(int i = 0; i < q; i++) {
    cin >> s;
    if(binary_search(v, n, s)) {
      cout << "1" << endl;
    }
    else {
      cout << "0" << endl;
    }
  }


}



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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  sort(a.begin(),a.end());
  int gcd=a[0];
  int x,y,tmp;
  for(int i=1;i<n;i++){
    x=gcd;
    y=a[i];
    if(!(y%x)) continue;
    y%=x;
    while(x%y){
      tmp=x;
      x=y;
      y=tmp%y;
    }
    gcd=y;
  }
  // cout << gcd << endl;
  for(int i=0;i<n;i++){
    if(k<=a[i]&&(a[i]-k)%gcd==0){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#define NMAX 2000000
#define VMAX 10000

using namespace std;

int main() {
	unsigned short *A, *B;
	int n;
	int C[VMAX + 1];
	scanf("%d", &n);

	for (int i = 0; i <= VMAX; i++) C[i] = 0;
	A = (unsigned short*)malloc(sizeof(short)*n + 1);
	B = (unsigned short*)malloc(sizeof(short)*n + 1);

	for (int i = 1; i <= n; i++) {
		scanf("%hu", &A[i]);
		C[A[i]]++;
	}
	for (int i = 1; i <= VMAX; i++) {
		C[i] += C[i - 1];
	}
	for (int i = n; i >= 1; i--) {
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}
	for (int i = 1; i <= n; i++) {
		if (i > 1) printf(" ");
		printf("%d", B[i]);
	}
	printf("\n");
}

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int n, x;
	cin >> n >> x;

	if(n == 2){
		if(x == 2){
			cout << "Yes" << endl;
			cout << "1" << endl;
			cout << "2" << endl;
			cout << "3" << endl;
		}else{
			cout << "No" << endl;
		}
		return 0;
	}

	if(x == 1 || x == 2*n -1){
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;

	multiset<int> ms;
	rep(i, 2*n-1) ms.insert(i+1);

	if(x != 2*n - 2){
		ms.erase(x+2);
		ms.erase(x-1);
		ms.erase(x);
		ms.erase(x+1);

		auto itr = ms.begin();
		rep(i, 2 * n - 1){
			if(i < n - 3 || n < i){
				cout << *itr << endl;
				itr++;
			}else if(i == n - 3){
				cout << x+2 << endl;
			}else if(i == n - 2){
				cout << x-1 << endl;
			}else if(i == n - 1){
				cout << x << endl;
			}else if(i == n){
				cout << x+1 << endl;
			}
		}
	}else{
		ms.erase(x-1);
		ms.erase(x+1);
		ms.erase(x);
		ms.erase(x-2);

		auto itr = ms.begin();
		rep(i, 2 * n - 1){
			if(i < n - 3 || n < i){
				cout << *itr << endl;
				itr++;
			}else if(i == n - 3){
				cout << x-1 << endl;
			}else if(i == n - 2){
				cout << x+1 << endl;
			}else if(i == n - 1){
				cout << x << endl;
			}else if(i == n){
				cout << x-2 << endl;
			}
		}
	}
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll R;
  IN(R);
  double Rd = (double)R;
  printf("%.12lf\n", 2*Rd*M_PI);

  return 0;
}


Measured memory_bytes: 3740
n,m=map(int,input().split())
H=list(map(int,input().split()))
lb=[True]*n
for r in range(m):
    a,b=input().split()
    a,b=int(a)-1,int(b)-1
    if H[a]>H[b]:
        lb[b]=False
    elif H[a]<H[b]:
        lb[a]=False
    else:
        lb[a]=False
        lb[b]=False
print(lb.count(True))

Measured memory_bytes: 19964
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
int a[5];
int n,m;
int s,c;
inline void read(int &x)
{
	int f;char c;
	for (f=1,c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for (x=0;c<='9'&&c>='0';c=getchar()) x=x*10+(c&15);x*=f;
}
inline int mn(int _x,int _y)
{
	return _x<_y?_x:_y;
}
inline int mx(int _x,int _y)
{
	return _x>_y?_x:_y;
}
inline int ab(int _x)
{
	if(_x<0) return -_x;
	else return _x;
}
inline bool check(int x,int y)
{
	if(x==-1) return true;
	if(x==y) return true;
	return false;
}
int main()
{
	read(n);read(m);
	memset(a,-1,sizeof(a));
	while(m--)
	{
		read(s);read(c);
		if(a[s]!=-1)
		{
			if(a[s]!=c) 
			{
				puts("-1");
				return 0;
			}
		}
		else
		{
			a[s]=c;
		}
	}
	if(n==3)
	{
		for(int i=0;i<=9;i++)
		{
			for(int j=0;j<=9;j++)
			{
				for(int k=1;k<=9;k++)
				{
					if(check(a[1],k)&&check(a[2],j)&&check(a[3],i))
					{
						printf("%d\n",k*100+j*10+i);
						return 0;
					}
				}
			}
		}
	}
	if(n==2)
	{
		for(int i=0;i<=9;i++)
		{
			for(int j=1;j<=9;j++)
			{
				if(check(a[1],j)&&check(a[2],i))
				{
					printf("%d\n",j*10+i);
					return 0;
				}
			}
		}
	}
	if(n==1)
	{
		for(int i=0;i<=9;i++)
		{
			if(check(a[1],i))
			{
				printf("%d\n",i);
				return 0;
			} 
		}
	}
	puts("-1");
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 6000 + 5 ; 
int m, n, dp[5][N << 1], P ; 
signed main()
{
	n = gi() * 3, m = n << 1, P = gi(), dp[0][n] = 1 ; 
	rep( i, 0, n ) {
		rep( j, 0, m ) {
			dp[2][j - 1] = ( dp[2][j - 1] + dp[0][j] * ( i + 1 ) % P ) % P ;
			if(j) dp[1][j + 1] = ( dp[1][j + 1] + dp[0][j] ) % P ; 
			dp[3][j] = ( dp[3][j] + dp[0][j] * ( ( i + 1 ) * ( i + 2 ) % P ) % P ) % P ;
		} 
		if( i != n ) rep( k, 0, 3 ) rep( j, 0, m ) dp[k][j] = dp[k + 1][j] ; 
	}
	int Ans = 0 ; 
	rep( i, n, m ) Ans = ( Ans + dp[0][i] ) % P ;
	cout << Ans << endl ;
	return 0 ; 
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ll long long
using namespace std;



int main() {
  ll x;
  cin >> x;
  ll count = 0;
  ll a = 100;
  for (int i = 0; a < x; i++){
    a += a / 100;
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,i,s;
int main()
{
	cin>>n;
	for (i=1;s<n;i++) s+=i;
	cout<<i-1;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()

int main(){
  ll n,d,x;cin>>n>>d>>x;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
  }
  int ans=x;
  rep(i,n){
    ans+=(int((d-1)/a[i])+1);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from collections import defaultdict
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N,M = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
flag = 0
order = 0
while True:
    for i in range(N):
        if a[i] % 2 == 0:
            a[i] = a[i] // 2
        else:
            cnt += 1
    if cnt == 0:
        order += 1
        continue
    elif cnt == N:
        break
    else:
        print(0)
        flag = 1
        break
if flag == 0:
    S = a[0]
    for i in range(1,N):
        p = fractions.gcd(S,a[i])
        S = (S*a[i]) // p
    q = S*(2**(order-1))
    loc = M // q
    if loc % 2 == 1:
        loc += 1
    print(loc // 2)

Measured memory_bytes: 24228
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <cstring>

#define ll long long
#define ld long double
#define HS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF 0x3f3f3f3f3f3f3f3f
#define point complex <double> 
#define pi acos(-1)
#define mod 1000000007


using namespace std;


double dot(point a, point b)
{
	return (conj(a) * b).real();
}
double cross(point a, point b)
{
	return (conj(a) * b).imag();
}
//double hypotness = hypot(3, 4);

int cum[100005];


int main() {
	HS
	int n, k;
	cin >> n >> k;
	int mini = 1e9;
	int arr[100005];
	int pos;
	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}
	ll ans = 0;
	for (int i = 1; i < n; i++)
	{
		ans++;
		i += k - 2;
	}

	cout << ans << endl;
	/*ll ans = 0;
	for (int i = pos; i < n; i++)
	{
		ans++;
		i += k - 2;
	}

	for (int i = pos; i > 1; i--)
	{
		ans++;
		i -= k - 2;
	}
	cout << ans << endl;
	*/
	return 0;
}

Measured memory_bytes: 3960
#include "bits/stdc++.h"
using namespace std;
#define MODULO 1000000007
#define PI 3.14159265359
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
   int n;
   cin>>n;
   int a=0,w=0,t=0,r=0;
   for(int i=0;i<n;++i)
   {
   	string x;
   	cin>>x;
   	if(x[0]=='A')
   	a++;
   	if(x[0]=='T')
   	t++;
   	if(x[0]=='W')
   	w++;
   	if(x[0]=='R')
   	r++;
   }
   cout<<"AC x "<<a<<endl;
   cout<<"WA x "<<w<<endl;
   cout<<"TLE x "<<t<<endl;
   cout<<"RE x "<<r<<endl;
    return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int>   vi;
typedef vector<long long> vll;
typedef vector<pair<int,int> > vii;
#define ll long long
#define pb push_back
#define mp  make_pair
#define ff first
#define ss second
#define pq priority_queue
#define sf scanf
int inf = (1e9) + 7;




int main(){


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


	if(abs(x - a) < abs(x-b))
		printf("A\n");
	else
		printf("B\n");



}	

Measured memory_bytes: 764
import Control.Applicative
import Data.List

main :: IO ()
main = getLine >> solve <$> f >>= print
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> Int
solve = maybe (-1) id . f Nothing
  where
    f mx [_] = mx
    f mx (x:xs) = let mx' = maximum $ (mx :) $ map Just $ filter inccons $ map (* x) xs
                  in f mx' xs

inccons :: Int -> Bool
inccons = and . (tail >>= zipWith f) . unfoldr g
  where
    f x y = x + 1 == y
    g 0 = Nothing
    g x = let (q, r) = divMod x 10
          in Just (r, q)



Measured memory_bytes: 4476
import java.util.*;
public class Main {
	public static void main(String[] args)
	{
		//変数
		long min=1000000000;
		//System.out.println(min);
		ArrayList<Long> h=new ArrayList<Long>();
		
		//入力
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();
		int K=sc.nextInt();
		for(int i=0;i<N;i++)
		{
			long hi=sc.nextInt();
			h.add(hi);
		}
		
		//処理
		Collections.sort(h);
		for(int i=0;i<N;i++)
		{
			if(i>N-K)
			{
				break;
			}
			long b=h.get(i+K-1)-h.get(i);
			if(min>b)
			{
				min=b;
			}
		}
		// 出力
		System.out.println(min);
	}
}

Measured memory_bytes: 59192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		boolean newLine = false;
		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = parseInt(line);

			for (int i = 0; i < n; i++) {
				//
				int[][] puzzle = new int[9][9];
				boolean[][] result = new boolean[9][9];

				for (int j = 0; j < 9; j++) {
					StringTokenizer st = new StringTokenizer(br.readLine());
					for (int k = 0; k < 9; k++) {
						puzzle[j][k] = parseInt(st.nextToken());
					}
				}

				int[] occured = new int[10];

				//行
				for (int j = 0; j < 9; j++) {
					Arrays.fill(occured, 0);
					for (int k = 0; k < 9; k++) {
						occured[puzzle[j][k]]++;
						if (occured[puzzle[j][k]] > 1) result[j][k] = true;
					}
				}
				for (int j = 8; j >= 0; j--) {
					Arrays.fill(occured, 0);
					for (int k = 8; k >= 0; k--) {
						occured[puzzle[j][k]]++;
						if (occured[puzzle[j][k]] > 1) result[j][k] = true;
					}
				}

				//列
				for (int j = 0; j < 9; j++) {
					Arrays.fill(occured, 0);
					for (int k = 0; k < 9; k++) {
						occured[puzzle[k][j]]++;
						if (occured[puzzle[k][j]] > 1) result[k][j] = true;
					}
				}
				for (int j = 8; j >= 0; j--) {
					Arrays.fill(occured, 0);
					for (int k = 8; k >= 0; k--) {
						occured[puzzle[k][j]]++;
						if (occured[puzzle[k][j]] > 1) result[k][j] = true;
					}
				}

				// 3x3
				for (int j = 0; j < 9; j += 3) {
					for (int k = 0; k < 9; k += 3) {
						Arrays.fill(occured, 0);
						for (int l = j; l < j + 3; l++) {
							for (int m = k; m < k + 3; m++) {
								occured[puzzle[l][m]]++;
								if (occured[puzzle[l][m]] > 1) result[l][m] = true;
							}
						}
					}
				}
				for (int j = 8; j > 0; j -= 3) {
					for (int k = 8; k > 0; k -= 3) {
						Arrays.fill(occured, 0);
						for (int l = j; l > j - 3; l--) {
							for (int m = k; m > k - 3; m--) {
								occured[puzzle[l][m]]++;
								if (occured[puzzle[l][m]] > 1) result[l][m] = true;
							}
						}
					}
				}

				//出力
				if (newLine) System.out.println();
				newLine = true;
				for (int j = 0; j < 9; j++) {
					for (int k = 0; k < 9; k++) {
						if (result[j][k])
							System.out.print("*" + puzzle[j][k]);
						else
							System.out.print(" " + puzzle[j][k]);
					}
					System.out.println();
				}
			}
		}
	}
}

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

long long memo[101][4];
long long calc(string &s, int i, int k) {
    if (memo[i][k] >= 0) return memo[i][k];
    if (i == s.size()) return memo[i][k] = (k == 0 ? 1 : 0);
    if (k == 0) return memo[i][k] = 1;
    long long ret = 0;
    if (s[i] != '0') {
        // 0 < d < s[i]
        long long n = s.size() - i - 1;
        if (k == 1) ret += (s[i] - '1');
        else if (k == 2) ret += (s[i] - '1') * n * 9;
        else ret += (s[i] - '1') * n * (n - 1) / 2 * 81;
        // s[i] (> 0)
        ret += calc(s, i+1, k-1);
        // 0
        if (k == 1) ret += n * 9;
        else if (k == 2) ret += n * (n - 1) / 2 * 81;
        else ret += n * (n - 1) * (n - 2) / 6 * 729;
    } else {
        ret += calc(s, i+1, k);     // 0
    }
    
    return memo[i][k] = ret;
}

int main() {
    string s; int k;
    cin >> s >> k;
    for (int i = 0; i < 100; i++) for (int j = 0; j < 4; j++) memo[i][j] = -1;
    cout << calc(s, 0, k) << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
S = input()

LR = 0
RL = 0
happy = 0
for i in range(N-1):
	if S[i:i+2] == "RL":
		RL += 1
	elif S[i: i+2] == "LR":
		LR += 1
	elif S[i] == S[i+1]:
		happy += 1

if K <= min(RL, LR):
	print(happy + 2 * K)
else:
	print(N - 1)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, m, a[1010];
int cnt, cnt2;

signed main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt += a[i];
	}
	for (int i = 0; i < n; i++) {
		if (cnt <= 4 * a[i] * m)cnt2++;
	}
	if (m <= cnt2)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int a, b, c;
   cin >> a >> b >> c;
   cout << a + b + c - max(a, max(b, c)) << endl;
   return 0;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
#define MOD 1000000007
#define MAX 110000
ll dp[220][MAX]={};
signed main(){
  init_io();
  ll n,x,ans=0;
  cin >> n >> x;
  vector<ll> s(n);
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  sort(s.begin(),s.end());
  for(int i=0;i<=x;i++){
    dp[0][i] = i;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<=x;j++){
      dp[i+1][j] += dp[i][j%s[i]];
      dp[i+1][j] %= MOD;
      dp[i+1][j] += dp[i][j] * i;
      dp[i+1][j] %= MOD;
    }
  }
  cout << dp[n][x]<<endl;
}


Measured memory_bytes: 174208
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y,z;
    cin>>x>>y>>z;
    int l=z,ans=0;
    while(l<=x-z){
        if(l+y<=x-z){
            ans++;
            l+=y+z;
        }
        else break;
        //cout<<l<<endl;
    }
    cout<<ans<<endl;
}

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


int main(){
  
  int n = 0;
  string s;
  cin >> s;
  for(int i = 0; i < 3; i++){
    if(s.at(i) == '1'){
      n++;
    }
  }
  cout << n << endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static int rootNumber;

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int[] preorder = new int[n];
		for (int i = 0; i < n; i++) {
			preorder[i] = sc.nextInt();
		}

		int[] inorder = new int[n];
		for (int i = 0; i < n; i++) {
			inorder[i] = sc.nextInt();
		}

		rootNumber = 0;
		postorder(inorder,preorder[0],preorder);
		System.out.println();

	}

	public static void postorder(int[] order, int root, int[] preorder){
		for (int i = 0; i < order.length; i++) {
			if (order[i] == root) {
				if (i != 0) {
					rootNumber++;
					int newRoot = preorder[rootNumber];
					int[] order1 = new int[i];

					for (int j = 0; j < order1.length; j++) {
						order1[j] = order[j];
					}

					postorder(order1, newRoot, preorder);

				}

				if (i != order.length - 1) {
					rootNumber++;
					int newRoot = preorder[rootNumber];
					int[] order1 = new int[order.length -1 - i];

					for (int j = 0; j < order1.length; j++) {
						order1[j] = order[i+1+j];
					}

					postorder(order1, newRoot, preorder);
				}

				if (order[i] != preorder[0]) {
					System.out.print(order[i] + " ");
				} else {
					System.out.print(order[i]);
				}

			}
		}
	}
}

Measured memory_bytes: 26364
import sys
import itertools
sys.setrecursionlimit(10000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    n,d = map(int,input().split())
    ans = 0
    for i in range(n):
        x,y = map(int,input().split())
        c = math.sqrt(x**2+y**2)
        if c<=d:
            ans+=1
    print(ans)

Measured memory_bytes: 69948
module Main where

import           Data.Maybe                     ( fromJust )
import           Data.List
import           Control.Monad
import qualified Data.ByteString.Char8         as BS

bytestr2Int = fst . fromJust . BS.readInt
getInt = bytestr2Int <$> BS.getLine

main :: IO ()
main = do
    n <- getInt
    putStrLn $ check n

check n = if 82 < n
    then "No"
    else if or [ m * l == n | m <- [1 .. 9], let l = div n m, l < 10 ]
        then "Yes"
        else "No"


Measured memory_bytes: 380
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
double abs(double x , double y){
  if (x>= y ) {
    return x-y;
  }
  else {
    return y-x;
  }
}

int main() {
  
  int a,b,h,m;
  cin >> a >> b >> h >> m;
  double ans,de,x,z,y,w,q;
  z=11*m;
  w=z/60;
  q=abs(h,w);
  x=3.1415926535893238*q/6;
  
  de = cos(  x );
  ans = a*a+b*b-2*a*b*de;
  y = sqrt( ans);
  
  cout << fixed << setprecision(10);
  cout << y << endl;
  
}

Measured memory_bytes: 4036
#include<bits/stdc++.h>
using namespace std;
static const int64_t INF=100000000000;
int64_t N,T;
int64_t dp[200005][31];
int main(){
cin>>N>>T;
  vector<int64_t>A(N);
  vector<int64_t>B(N);
  for(int i=0;i<N;i++){
  int64_t a;cin>>a;A.at(i)=a+1;
    cin>>B.at(i);
  }vector<pair<double,int64_t>>C;vector<int64_t>D;
  for(int64_t i=0;i<N;i++){
  if(A[i]==1)D.push_back(B[i]+1);
    else{
    double a=A[i];double b=B[i];
      pair<double,int64_t>p(-(a+b)/(b+1),i);
      C.push_back(p);
    }
   }sort(C.begin(),C.end());sort(D.begin(),D.end());
  int M=C.size();
  vector<pair<int64_t,int64_t>>P(M);
  for(int i=0;i<M;i++){
int64_t I=C[i].second;
    pair<int64_t,int64_t>p(A[I],B[I]);
    P[i]=p;
  }for(int i=0;i<=M;i++)
    for(int j=1;j<=30;j++)
      dp[i][j]=INF;
  for(int i=1;i<=M;i++)
    for(int j=1;j<=30;j++){
    dp[i][j]=min(dp[i-1][j],P[i-1].first*(dp[i-1][j-1]+1)+P[i-1].second);
    }vector<int64_t>d(N-M+1);
  d[0]=0;
  for(int i=1;i<=N-M;i++)
    d[i]=d[i-1]+D[i-1];
  int64_t ans=0;
  for(int i=0;i<=30;i++){
  if(dp[M][i]<=T){
  auto itr=upper_bound(d.begin(),d.end(),T-dp[M][i]);
    int k=distance(d.begin(),itr);
    if(ans<k+i-1)ans=k+i-1;
   }
  }cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 61140
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
ll dp[2010];
ll mod=1e9+7;
int main()
{
    int s;
    cin>>s;
    dp[3]=1;
    for(int i=4;i<=s;i++)
    {
        for(int j=3;j<i;j++)
        {
            if(i-j<3) break;
            dp[i]+=dp[i-j];
            dp[i]%=mod;
        }
        dp[i]++;
        dp[i]%=mod;
    }
    
    cout<<dp[s]<<endl;
    

    int ab;
    cin>>ab;
    return 0;
} 

Measured memory_bytes: 3636
function Main(input){
    input = input.split(" ");

    input[0] = Number(input[0]);
    input[1] = Number(input[1]);
    input[2] = Number(input[2]);
    input[3] = Number(input[3]);

    if(input[2] >= input[1]){
        console.log(0);
    }else if(input[3] <= input[0]){
        console.log(0);
    }else{
        if(input[0] < input[2]){
            var start = input[2]
        }else{
            var start = input[0]
        }

        if(input[1] < input[3]){
            var end = input[1]
        }else{
            var end = input[3]
        }

        console.log('%d', end - start);
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
N = int(input())
sqrStrList = input().split()
sqrList = [int(i) for i in sqrStrList]

prevNum = 10 ** 9 
isPossible = True

for i in reversed(range(len(sqrList))):
    nowNum = sqrList[i]
    if nowNum > prevNum:
        if nowNum != prevNum + 1:
            isPossible = False
            break
    else:
        prevNum = nowNum

if isPossible:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14252
#include <iostream>

using namespace std;

int main()
{
    int A, B, K;
    cin >> A >> B >> K;

    for (int i = 0; i < K; i++){
        if (A % 2 == 1) A--;
        B += A / 2;
        A /= 2;

        i++;
        if (i == K) break;

        if (B % 2 == 1) B--;
        A += B / 2;
        B /= 2;
    }

    cout << A << " " << B << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

constexpr int MOD = 998244353;

class mint {
  int n;
public:
  mint(int n_ = 0) : n(n_) {}
  explicit operator int() { return n; }
  friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
  friend mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
  friend mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
  friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
  friend mint &operator+=(mint &a, mint b) { return a = a + b; }
  friend mint &operator-=(mint &a, mint b) { return a = a - b; }
  friend mint &operator*=(mint &a, mint b) { return a = a * b; }
  friend bool operator==(mint a, mint b) { return a.n == b.n; }
  friend bool operator<(mint a, mint b) { return a.n < b.n; }
  friend bool operator!=(mint a, mint b) { return a.n != b.n; }
  friend istream &operator>>(istream &i, mint &a) { return i >> a.n; }
  friend ostream &operator<<(ostream &o, mint a) { return o << a.n; }
};

mint modinv(mint n) {
  int a = (int)n, b = MOD;
  int s = 1, t = 0;
  while (b != 0) {
    int q = a / b;
    a -= q * b;
    s -= q * t;
    swap(a, b);
    swap(s, t);
  }
  return s >= 0 ? s : s + MOD;
}

const int INF = 1e9;

class segment_tree {
  using T = int;
  int N;
  vector<T> dat;
  T mempty = -INF;
  int mappend(int x, int y) {
    return max(x, y);
  }

public:
  segment_tree(int n) {
    N = 1;
    while (N < n) N *= 2;
    dat.resize(N * 2, mempty);
    for (int i = 0; i < n; i++) {
      dat[i + N] = mempty;
    }
    for (int i = N - 1; i >= 1; i--) {
      dat[i] = mappend(dat[i * 2], dat[i * 2 + 1]);
    }
  }

  void update(int k, T v) {
    k += N;
    dat[k] = v;
    while (k > 1) {
      k >>= 1;
      dat[k] = mappend(dat[k * 2], dat[k * 2 + 1]);
    }
  }

  T query(int l, int r) {
    l += N;
    r += N - 1;
    T x = mempty, y = mempty;
    while (l <= r) {
      if ((l & 1) == 1) x = mappend(x, dat[l++]);
      if ((r & 1) == 0) y = mappend(dat[r--], y);
      l >>= 1;
      r >>= 1;
    }
    return mappend(x, y);
  }
};

int main() {
  int N; cin >> N;
  vector<pair<int, int>> XD(N);
  rep(i, N) cin >> XD[i].first >> XD[i].second;
  sort(range(XD));
  vector<int> X(N), D(N);
  rep(i, N) tie(X[i], D[i]) = XD[i];
  vector<int> next(N);
  segment_tree seg(N);
  for (int i = N - 1; i >= 0; i--) {
    next[i] = i;
    // X[j] < X[i] + D[i]
    int j = lower_bound(range(X), X[i] + D[i]) - X.begin();
    if (i + 1 < j) {
      next[i] = seg.query(i, j);
    }
    seg.update(i, next[i]);
  }
  vector<mint> dp(N + 1);
  dp[0] = 1;
  rep(i, N) {
    dp[i + 1] += dp[i];
    dp[next[i] + 1] += dp[i];
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 7040
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef vector<P> vp;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}
bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
    
int main(){
    ll N; cin >> N;
    vl ts(N + 1, 0), xs(N + 1, 0), ys(N+ 1, 0);
    ts[0] = 0; xs[0] = 0; ys[0] = 0;
    for (int i = 1; i <= N; i++) {
        cin >> ts[i]; cin >> xs[i]; cin >> ys[i];
    }
    
    bool ok = true;
    
    for (int i = 1; i <= N ; i++) {
        ll dt = ts[i] - ts[i-1];
        ll dx = xs[i] - xs[i-1];
        ll dy = ys[i] - ys[i-1];
        if(dt < abs(dx) + abs(dy)){
            ok = false; break;
        }
        if((dt - abs(dx) + abs(dy)) % 2 != 0){
            ok = false; break;
        }
    }
    
    cout << (ok ? "Yes" : "No") << endstr;
    return 0;
}


Measured memory_bytes: 2560
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
N=int(input())
lst=[0 for i in range(N+1)]
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            a=x**2+y**2+z**2+x*y+y*z+z*x
            if a<=N:
                lst[a]+=1
for i in range(1,N+1):
    print(lst[i])


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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(int size) {
        prime.resize(size + 1, 1);
        prime[0] = 0;
        prime[1] = 0;
        FOR(i, 2, size) {
            if (prime[i]) {
                for (int j = 2 * i; j <= size; j += i) {
                    prime[j] = 0;
                }
            }
        }
    }

};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


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

string s;

int main() {

    cin >> s;
    string t = "";
    REP(i, s.size()) {
        if (s[i] == 'x')continue;
        else t += s[i];
    }
    bool pal = 1;
    REP(i, t.size()) {
        if (t[i] != t[t.size() - 1 - i]) {
            pal = 0;
            break;
        }
    }
    if (pal) {
        vector<int> A(t.size() + 1);
        int p = 0, res = 0;
        REP(i, s.size()) {
            if (s[i] == 'x') A[p]++;
            else p++;
        }
        REP(i, (t.size() + 1) / 2)res += abs(A[i] - A[t.size() - i]);
        cout << res << endl;
    } else cout << -1 << endl;


    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INT_INF = 1LL << 60;
const ll money = 1e15;
//to　は重みあり隣接リスト（第一成分が接続先で、第二成分が辺の重み）で
// to　は　vec<ve<cpair
// to_dist　は　各ノードへのvからの（暫定的な)最小値を保存でただのvec

vector<vector<pair<ll,ll>>> to1; vector<vector<pair<ll,ll>>> to2;
vector<ll> to_dist1; vector<ll> to_dist2;

ll N,M,S,T;

void Dijkstra1(ll v){
  to_dist1[v] = 0; 
  
  priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> Q; 
  Q.push(make_pair(0,v)); 
  //キューは、暫定の重さとノードの番号を持つ priorityは第一成分に適用、つまり
  //暫定の値が最も小さなものから見ていく
  
  while(!Q.empty()){
    //行きについてまずは調べる
    pair<ll,ll> p = Q.top(); Q.pop();
    ll s = p.first; ll t = p.second; //sが重さ、tが番号
    if( to_dist1[t] < s){ continue;}
    else{
      //t-ノードから繋がる全てのノードについて、もしto_dist[t] + to[t][]より大きければ更新
      for(auto ne: to1[t]){
        ll x = ne.first; ll y = ne.second;
        //firstが隣接するノード、secondがそこまでの距離
        if( to_dist1[x] > to_dist1[t] + y){
          to_dist1[x] = to_dist1[t] + y; Q.push(make_pair( to_dist1[x], x));}}}}

  
}

void Dijkstra2(ll v){
  to_dist2[v] = 0; 
  
  priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> Q; 
  Q.push(make_pair(0,v)); 
  //キューは、暫定の重さとノードの番号を持つ priorityは第一成分に適用、つまり
  //暫定の値が最も小さなものから見ていく
  
  while(!Q.empty()){
    //行きについてまずは調べる
    pair<ll,ll> p = Q.top(); Q.pop();
    ll s = p.first; ll t = p.second; //sが重さ、tが番号
    if( to_dist2[t] < s){ continue;}
    else{
      //t-ノードから繋がる全てのノードについて、もしto_dist[t] + to[t][]より大きければ更新
      for(auto ne: to2[t]){
        ll x = ne.first; ll y = ne.second;
        //firstが隣接するノード、secondがそこまでの距離
        if( to_dist2[x] > to_dist2[t] + y){
          to_dist2[x] = to_dist2[t] + y; Q.push(make_pair( to_dist2[x], x));}}}}

  
}


      

int main(){
  cin >> N >> M >> S >> T; S--; T--;
  to1.resize(N); to2.resize(N);
  to_dist1 = vector<ll> (N,INT_INF); to_dist2 = vector<ll> (N,INT_INF);
                                                      
 
  for(ll i = 0; i < M; i++){
    ll u,v,a,b; cin >> u >> v >> a >> b; u--; v--;
    to1[u].push_back(make_pair(v,a)); // Sからの重みを収納
    to1[v].push_back(make_pair(u,a));
    to2[u].push_back(make_pair(v,b));
    to2[v].push_back(make_pair(u,b));}
  
  Dijkstra1(S); Dijkstra2(T);
  // Sからのyenでの最小コスト経路、Tからのsnuukでの最小コスト経路をそれぞれ求める
  
  vector<ll> ans(N);
  ans[N-1] = to_dist1[N-1] + to_dist2[N-1];
  //N-1年後にて、両替はN-1番目の都市でしかありえない
  for(ll i = N - 1; i >= 1; i--){
    ans[i-1] = min(ans[i], to_dist1[i-1] + to_dist2[i-1]);}
  // i-1年後には、0-indexedにて、i-1番目の都市が解禁
  for(ll i = 0; i < N; i++){ cout << money - ans[i] << endl;}
  return 0;}

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

int main() {
    int n;
    cin >> n;

    vector<int> dp(n+1, 1e9);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        dp[i+1] = min(dp[i+1], dp[i] + 1);
        for (int a = 6; i + a <= n; a *= 6) dp[i+a] = min(dp[i+a], dp[i] + 1);
        for (int a = 9; i + a <= n; a *= 9) dp[i+a] = min(dp[i+a], dp[i] + 1);
    }

    cout << dp[n] << endl;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n;
  cin>>n;
  vll a(n);
  REP(i,n)
    cin>>a[i];
  
  ll sum = 0;
  REP(i,n)
    sum += a[i]%2;
  
  if(sum%2==0)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
typedef long long LL;
const int mo=1000000007;
bool a[1005][1005];
char s[1005];
struct M{
	LL a0,a1,a2,a3;
};
M operator *(M A,M B){
	M C;
	C.a0=(A.a0*B.a0+A.a1*B.a2)%mo;
	C.a1=(A.a0*B.a1+A.a1*B.a3)%mo;
	C.a2=(A.a2*B.a0+A.a3*B.a2)%mo;
	C.a3=(A.a2*B.a1+A.a3*B.a3)%mo;
	return C;
}
M operator ^(M A,int B){
	M C=(M){1,0,0,1};
	for (;B;B>>=1,A=A*A)
		if (B&1) C=C*A;
	return C;
}
int ksm(LL x,int y){
	LL i=1;
	for (;y;y>>=1,(x*=x)%=mo)
		if (y&1) (i*=x)%=mo;
	return i;
}
int main(){
	int h,w,x1=0,x2=0,y1=0,y2=0,n=0,ans;
	LL k;
	scanf("%d%d%lld\n",&h,&w,&k);k%=mo-1;
	for (int i=1;i<=h;i++){
		scanf("%s",s+1);
		for (int j=1;j<=w;j++) n+=a[i][j]=s[j]=='#';
	}
	for (int i=1;i<=h;i++){
		x1+=a[i][1]&a[i][w];
		for (int j=1;j<w;j++) x2+=a[i][j]&a[i][j+1];
	}
	for (int j=1;j<=w;j++){
		y1+=a[1][j]&a[h][j];
		for (int i=1;i<h;i++) y2+=a[i][j]&a[i+1][j];
	}
	if (!k || (x1 && y1)) ans=1;
	else if (!x1 && !y1) ans=ksm(n,k-1);
	else{
		if (y1) x1=y1,x2=y2;
		M A=(M){n,0,-x2,x1};
		A=A^(k-1);
		ans=(A.a0+A.a2)%mo;
	}
	printf("%d\n",(ans+mo)%mo);
}

Measured memory_bytes: 1152