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

#define pb         push_back

const int INF = 1000000000;
const int MOD = 1000000007;

int main(void) {
	while(1){
		int n, p;
		int st[100] = {0};
		cin >> n >> p;
		if(n == 0 && p == 0) break;

		int i = 0;
		int wan = p;
		while(1){
			if(wan > 0){
				st[i]++;
				wan--;
				if(st[i] == p){
					printf("%d\n", i);
					break;
				}
			}else{
				wan += st[i];
				st[i] = 0;
			}
			/*
			for(int j=0; j<n; j++){
				printf("%d:%d\n", j, st[j]);
			}
			puts("");
			*/
			i++;
			i%=n;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1144
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		long X = long.Parse(str[1]);
		long mod = 1000000007;
		var A = new List<long>();
		string[] str2 = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A.Add(long.Parse(str2[i]));
		}
		A.Sort((x,y)=>y.CompareTo(x));
		long[,]D = new long[N+1,X+1];
		D[0,X] = 1;
		for(var i=0;i<N;i++){
			for(var j=0;j<=X;j++){
				long j2 = j%A[i];
				if(j>0){
					D[i+1,j2] = (D[i+1,j2] + D[i,j]) % mod;
				}
				D[i+1,j] = (D[i+1,j] + D[i,j] * (N-1-i)) % mod;
			}
		}
		long ans = 0;
		for(var j=0;j<=X;j++){
			ans = (ans + D[N,j] * j) % mod;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 165716
#include<iostream>
using namespace std;
 
int main(){
  int n,re[10],ans;
  while(1){
    cin >> n;
    if(n == 0) break;
    ans = 0;
    for(int i=0;i<9;i++){
      cin >> re[i];
      ans += re[i];
    }
    ans = n - ans;
    cout << ans << endl;
  }
}

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

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

  int R = 0, B = 0;
  for (int i = 0; i < S.length(); i++){
    if (S[i] == 'R') R ++;
    else B++;
  }

  if (R > B) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;

	int xc2 = ( x1 + x2 + y1 - y2);
	int yc2 = (-x1 + x2 + y1 + y2);

	int x3 = xc2 - x1;
	int y3 = yc2 - y1;
	int x4 = xc2 - x2;
	int y4 = yc2 - y2;

	cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;

	return 0;
}

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

struct StCrd
{
  string m_sMrk;
  int    m_nNum;
  int    m_nSeq;
};

void fnInput(vector<StCrd> &rvoCrd)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  rvoCrd.resize(nMaxSiz);
  for (int i = 0; i < nMaxSiz; i++)
  {
    cin >> rvoCrd[i].m_sMrk >> rvoCrd[i].m_nNum;
    rvoCrd[i].m_nSeq = i + 1;
  }
}

int fnPartition(vector<StCrd> &rvoCrd, int nFront, int nBack)
{
  int nMid = nFront;

  for (int i = nFront; i < nBack; i++)
    if (rvoCrd[i].m_nNum <= rvoCrd[nBack].m_nNum)
      swap(rvoCrd[nMid++], rvoCrd[i]);

  swap(rvoCrd[nMid], rvoCrd[nBack]);
  return nMid;
}

void fnQuickSort(vector<StCrd> &rvoCrd, int nFront, int nBack)
{
  if (nFront < nBack)
  {
    int nMid = fnPartition(rvoCrd, nFront, nBack);
    fnQuickSort(rvoCrd, nFront, nMid - 1);
    fnQuickSort(rvoCrd, nMid + 1, nBack);
  }
}

void fnResult(const vector<StCrd> &cnrvoCrd)
{
  bool bStable = true;
  for (int i = 0; i < cnrvoCrd.size();    )
  {
    int j = i;
    while (cnrvoCrd[i].m_nNum == cnrvoCrd[++j].m_nNum)
      if (cnrvoCrd[i].m_nSeq < cnrvoCrd[j].m_nSeq);
      else
      {
        bStable = false; 
        goto LOOP_END;
      }

    i = j;
  }

LOOP_END:
  if (bStable)  cout << "Stable" << endl;
  else          cout << "Not stable" << endl;

  for (int i = 0; i < cnrvoCrd.size(); i++)
    cout << cnrvoCrd[i].m_sMrk << " " << cnrvoCrd[i].m_nNum << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<StCrd> voCrd;

  fnInput(voCrd);
  fnQuickSort(voCrd, 0, voCrd.size() - 1);
  fnResult(voCrd);

  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pair2;
typedef pair<int, pair<int, int> > pair3;
typedef pair<int, pair<int, pair<int, int> > > pair4;
#define MAXN 200013
#define INF 1000000000000000000LL
#define MOD 1000000007LL
#define IINF 1000000000
#define mp make_pair
#define pb push_back
#define remove pop
#define all(x) x.begin(), x.end()

//Task: Find a cycle.


int n, m;

vector<int> adj[MAXN];

int seen[MAXN];
int par[MAXN];
int dist[MAXN];

set<int> curSeen;
vector<int> curStack;
vector<int> answer;
bool cycle;

pair<int, vector<int>> bfs(int c) {

	queue<int> q;

	q.push(c);
	seen[c] = true;
	par[c] = -1;

	int bestAnswer = 0;

	bool solved = false;

	while (q.size() > 0) {
		int cur = q.front(); q.pop();

		bool shouldBreak = false;
		for (int next : adj[cur]) {
			if (next == c) {
				//we done
				bestAnswer = cur;
				shouldBreak = true;
				solved = true;
				break;
			}

			if (seen[next]) continue;

			seen[next] = true;
			dist[next] = dist[cur] + 1;
			par[next] = cur;
			q.push(next);
		}

		if (shouldBreak) {
			break;
		}
	}

	if (!solved) {
		return mp(IINF, vector<int>());
	}

	int length = dist[bestAnswer] + 1;
	vector<int> thisAns;

	while (bestAnswer != c) {
		thisAns.pb(bestAnswer);
		bestAnswer = par[bestAnswer];
	}
	thisAns.pb(c);

	return mp(length, thisAns);
}

int main() {
	if (fopen("FILENAME.in", "r")) {
		freopen("FILENAME.in", "r", stdin);
		freopen("FILENAME.out", "w", stdout);
	}
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;b--;

		adj[a].pb(b);
	}

	int bestLength = IINF;
	vector<int> bestVector;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			seen[j] = 0;par[j] = -1;dist[j] = 0;
		}
		curStack.clear();

		//cout << "doing dfs from " << i << endl;
		pair<int, vector<int> > result = bfs(i);

		if (result.first < bestLength) {
			bestLength = result.first;
			bestVector = result.second;
		}
		
	}

	if (bestLength == IINF) 
		cout << -1 << endl;
	else {
		cout << bestLength << endl;
		for (int j : bestVector) {
			cout << (j + 1) << endl;
		}
	}
}

Measured memory_bytes: 5376
import java.util.*;

public class Main {    
    
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);                
        
       boolean flag[] = {false,false,false,false,false,false,false,false};
        
       int over = 0;
            
       int N = sc.nextInt();
       
       int a[] = new int[N];


    for(int i = 0;i < N;i++){       
       a[i] = sc.nextInt();
           
       if(a[i] >= 3200){
               over++;
       }

       for(int j = 0;j <= 7;j++){           
           if(400*j <= a[i] && a[i] < 400*(j+1)){
                flag[j] = true;
           }                                            
       }
       
    }
               
    int sum = 0;
       
    for(int i = 0;i < 8;i++){
        
           if(flag[i]){
               sum++;
           }
           
    }
       
       int min = sum;       
       if(sum == 0)
            min = 1;       

       int max = sum + over;       
       
       System.out.println(min + " " + max);
        
    }                                      
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<ll> vll;

const int MAX_N = 50;

ll C[MAX_N+1][MAX_N+1] = {0};

int main() {
  ll n, a, b, ans_cnt = 0;
  double ans_ave = 0;
  vll v;
  cin >> n >> a >> b;
  for (int i=0; i<n; i++) {
    ll tmp; cin >> tmp;
    v.push_back(tmp);
  }
  for (int i=0; i<=n; i++) {
    C[i][0] = 1;
    for (int j=1; j<=i; j++) {
      C[i][j] = C[i-1][j-1] + C[i-1][j];
    }
  }

  sort(v.begin(), v.end(), greater<ll>());
  int cnt_va = 0, upper_va_idx = 0;
  for (int i=0; i<n; i++) {
    if (v[a-1] < v[i]) {
      upper_va_idx++;
    }
    if (v[a-1] == v[i]) {
      cnt_va++;
    }
    if (i < a) {
      ans_ave += v[i];
    }
  }
  ans_ave = ans_ave / a;

  if (cnt_va == n) {
    for (int i=a; i<=b; i++) {
      ans_cnt += C[n][i];
    }
  } else {
    if (upper_va_idx == 0) {
      for (int i=a-1; i<b && v[i] == v[a-1]; i++) {
        ans_cnt += C[cnt_va][i+1];
      }
    } else {
      ans_cnt = C[cnt_va][a - upper_va_idx];
    }
  }
  printf("%.6lf\n%lld\n", ans_ave, ans_cnt);
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> X(N,-1);
    vector<int> L(N,0);
    vector<pair<int,int>> A(N,make_pair(-1,-1));
    vector<int> DP(N+10,1);
    vector<int> DP2(N+10,1);
    int s,g;
    rep(i,N){
        cin >> X[i] >> L[i];
        s = X[i] - L[i];
        g = X[i] + L[i];
        A[i] = make_pair(s, g);
        //int S = max(s, 0);
        //int G = min(g, 1000)
    }
    
    
    sort(A.begin(), A.end());
    //int cntA=0, cntB=0;
    int ps = A[0].first;
    int pg = A[0].second;
    for(int i=1;i<N;i++){
        if(pg <= A[i].first){
            DP[i] = DP[i-1] + 1;
            pg = A[i].second;
        }else{
            DP[i] = DP[i-1];
        }
    }
    int ans1 = DP[N-1];
    if(N>1){
    DP[0] = 1;
    DP[1] = 1;
    ps = A[1].first;
    pg = A[1].second;
    for(int i=2;i<N;i++){
        if(pg <= A[i].first){
            DP[i] = DP[i-1] + 1;
            pg = A[i].second;
        }else{
            DP[i] = DP[i-1];
        }
    }
    ans1 = max(ans1, DP[N-1]); 
    }
    ps = A[N-1].first;
    pg = A[N-1].second;
    if(N > 1){
    for(int i=N-2;0<=i;i--){
        if(A[i].second <= ps){
            DP2[i] = DP2[i+1] + 1;
            ps = A[i].first;
        }else{
            DP2[i] = DP2[i+1];
        }
    }
    
    ans1 = max(ans1, DP2[0]);
    DP2[N-1] = 1;
    DP2[N-2] = 1;
    ps = A[N-2].first;
    pg = A[N-2].second;
    for(int i=N-3;0<=i;i--){
        if(A[i].second <= ps){
            DP2[i] = DP2[i+1] + 1;
            ps = A[i].first;
        }else{
            DP2[i] = DP2[i+1];
        }
    }
    ans1 = max(ans1, DP2[0]);
    }
    /*
    rep(i,N){
        cout << DP[i] <<' ';
    }*/
    //cout << endl;

    cout << ans1 << endl;
}



Measured memory_bytes: 2560
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>
#include <math.h>           // sqrt()

int
main(int argc, char **argv)
{
	double x;
	double h, h2;
	double area;

	while (true)
	{
		scanf("%lf %lf", &x, &h);
		if (x == 0 && h == 0)
			break;

		h2 = sqrt(h * h + x * x / 4);
		area = (h2 * x) / 2 * 4 + x * x;
		printf("%.8f\n", area);
	}

	return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <climits>
using namespace std;

int main() {
    int n, m;
    int a[50][50], b[50][50];
    cin >> n >> m;
    string s;
    for (int y = 0; y < n; y++) {
        cin >> s;
        for (int x = 0; x < n; x++) {
            a[y][x] = s[x] == '#' ? 0 : 1;
        }
    }
    for (int y = 0; y < m; y++) {
        cin >> s;
        for (int x = 0; x < m; x++) {
            b[y][x] = s[x] == '#' ? 0 : 1;
        }
    }

    int k = n - m + 1;
    for (int y = 0; y < k; y++) {
        for (int x = 0; x < k; x++) {
            int(*t)[50] = (int(*)[50])&a[y][x];
            for (int y = 0; y < m; y++) {
                for (int x = 0; x < m; x++) {
                    if (t[y][x] != b[y][x]) goto break2;
                }
            }
            cout << "Yes" << endl;
            quick_exit(0);
        break2:
            continue;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

int main(){
    int n;cin>>n;
    string yes="YES",no="NO";
    while(n--){
        vector<int> a(10);
        for(auto &e:a)cin>>e;

        bool ans=false;
        for(int i=0; i<(1<<10); i++){
            bool ok=true;
            int px=-1,py=-1;
            for(int j=0; j<10; j++){
                if(i&(1<<j)){
                    if(px==-1)px=a[j];
                    else
                        if(!(px<a[j])) ok=false;
                        else px=a[j];
                } else {
                    if(py==-1)py=a[j];
                    else
                        if(!(py<a[j])) ok=false;
                        else py=a[j];
                }
            }
            ans|=ok;
        }
        cout<<(ans?yes:no)<<endl;
    }
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;


void solve(){
  long long int n; cin >> n;
  long long int a[5]; for(int i = 0; i < 5; i++) cin >> a[i];
  long long int x[6];
  for(int i = 0; i < 6; i++) x[i] = 0;
  x[0] = n;
  int ans = 0;
  while(x[5] < n){
    long long int y[6];
    for(int i = 0; i < 6; i++) y[i] = x[i];
    for(int i = 1; i <= 5; i++){
      y[i - 1] -= min(x[i - 1], a[i - 1]);
      y[i] += min(x[i - 1], a[i - 1]);
    }
    for(int i = 0; i < 6; i++) x[i] = y[i];
    //for(int i = 0; i < 6; i++) cout << x[i] << " "; cout << endl;
    ans++;
  }
  cout << ans << endl;

  return;
}

void solve2(){
  long long int n; cin >> n;
  long long int a[5]; for(int i = 0; i < 5; i++) cin >> a[i];
  long long int x[6]; for(int i = 0; i < 6; i++) x[i] = 0;
  x[0] = n;
  int minid = 0;
  for(int i = 1; i < 5; i++){
    if(a[i] < a[minid]) minid = i;
  }
  long long int ans;
  n % a[minid] == 0 ? ans = n / a[minid] : ans = n / a[minid] + 1;
  ans += 4;
  cout << ans << endl;
  return;
}

int main(){
  solve2();
  return 0;
}


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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


signed main() {
    //my-code
    ll n; cin >> n;
    ll x = 0;
    vector<ll> a(n); REP(i, n) cin >> a[i];

    REP(i, n) {
        x ^= a[i];
    }
    ll y;
    REP(i, n) {
        y = x ^ a[i];
        if (i != (n-1)) {
            cout << y << " ";
        } else {
            cout << y << endl;
        }
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int a[21] , n ,ans ;
int main()
{

    cin >> n ;
    for (int i = 0 ; i < n ; i++)
        cin >>a[i];
    for (int i = 1 ; i < n - 1 ; i++)
    {
        if ((a[i] > a[i - 1] && a[i] < a[i + 1]) || (a[i] < a[i - 1] && a[i] > a[i + 1] ))ans++;
    }
    cout <<ans ;

    return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())
K = int(input())

flag = True
for f in range(K):
    g = 2 ** f
    h = 2**(K - f)
    
    
    bm = b * g
    cm = c * h

    if a < bm and bm < cm:
        print('Yes')
        flag = False
        break

if flag:
    print('No')
        

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

int main(){
    int h,m,s,total,h1,m1,s1,total1;
    while(1){
        cin >> h >> m >> s;
        if(h == -1 && m == -1 && s == -1){
            break;
        }
        total1 = h*3600 + m*60 + s;
        total1 = 120*60 - total1;
        total1 *= 3;
        
        total = h*3600 + m*60 + s;
        total = 120*60 - total;
        h = total/3600;
        total %= 3600;
        m = total/60;
        total %= 60;
        s = total;
        
        h1 = total1/3600;
        total1 %= 3600;
        m1 = total1/60;
        total1 %= 60;
        s1 = total1;
        
        printf("%02d:%02d:%02d\n",h,m,s);
        printf("%02d:%02d:%02d\n",h1,m1,s1);
    }
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
 int arr[1000001];
typedef long long int ll;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll l,r,d,x=0;
    string s;
    cin>>l;
   
    for(int i=1;i<=100;i++) {
        for(int j=1;j<=100;j++) {
            for(int k=1;k<=100;k++) {
                ll sum=(i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i);
                arr[sum]++;
            }
        }
     
    }
    for(int i=1;i<=l;i++)
    cout<<arr[i]<<'\n';
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int h,w,dp[1001][1001];
string s[10001];
void solve(){
    cin>>h>>w;
    rep(i,0,h) cin>>s[i];
    dp[1][1]=1;
    rep(i,1,h+1){
        rep(j,1,w+1){
            if(i+j!=2 and s[i-1][j-1]=='.') dp[i][j]=(dp[i-1][j]+dp[i][j-1])%hell;
        }
    }
    cout<<dp[h][w]<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main(void)
{
  int N;
  cin >> N;
  int A, B;
  cin >> A >> B;
  int P;
  int Acnt = 0;
  int Bcnt = 0;
  int Ccnt = 0;
  for(int i = 0; i < N; i++){
    cin >>P;
    if(P<=A) Acnt++;
    else if(P<=B) Bcnt++;
    else Ccnt++;
  }
  cout << min({Acnt, Bcnt, Ccnt}) << endl;
  return 0;
}


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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)

long long comb(long long m) {
	return (m * (m - 1)) / 2;
}


int main() {
	int n,m;
	cin >> n >> m;
	vector<int> h(n);
	rep(i, n)	cin >> h[i];
	vector<int> a(m);
	vector<int> b(m);
	rep(i, m)	cin >> a[i] >> b[i];

	vector<int> ans(n);		//良い展望台は0

	rep(i, m) {
		if (h[a[i]-1] <= h[b[i]-1])		ans[a[i]-1] = 1;
		if (h[b[i]-1] <= h[a[i]-1])		ans[b[i]-1] = 1;
	}

	int anss = 0;
	rep(i, n) {
		if (ans[i] == 0)	anss++;
	}

	cout << anss << endl;


}

Measured memory_bytes: 4732
#include <iostream>

using namespace std;

int calcNumOfCombination(int n, int r);

int main(void) {
	int N, M, ans;
	cin >> N >> M;
	ans = calcNumOfCombination(N, 2) + calcNumOfCombination(M, 2);

	cout << ans << endl;
	return 0;
}

int calcNumOfCombination(int n, int r) {
	int num = 1;
	for (int i = 1; i <= r; i++) {
		num = num * (n - i + 1) / i;
	}
	return num;
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]

ans = 12*10**6
for i in range(2**n):
    s = [0]*(m+1)
    for j in range(n):
        if (i>>j) & 1 == 1:
            for k in range(m+1):
                s[k] += ca[j][k]
    for j in range(1, m+1):
        if s[j] < x:
            break
    else:
        ans = min(ans, s[0])
print(-1 if ans == 12*10**6 else ans)

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

int main(){
  int n,i,ans=0,cur=0,res=0;
  cin >> n;
  
  for(i=0; i<n; i++){
    cin >> cur;
    if(cur>=res){
      res=cur;
      ans++;
    }
  }
  
  cout << ans;
}
  

Measured memory_bytes: 256
#include <stdio.h>
int main() {
    int x, y, t;
    
    while(1) {
        scanf("%d%d", &x, &y);
        
        if (x == 0 && y == 0) break;
        
        if (x > y) {
            t = y;
            y = x;
            x = t;
        }
        
        printf("%d %d\n", x, y);
    }
    return 0;
}


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

const int INF=1e18;

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

    vector<int> dp(N);
    for(int i=0;i<N;i++) dp[i]=INF;
    dp[0]=0;
    for(int i=0;i<N;i++){
        if(i+1<N){
            dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
        }
        if(i+2<N){
            dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
        }
    }
    cout<<dp[N-1]<<endl;
}


Measured memory_bytes: 1792
// Created by arvybhatt

#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

int main()
{
    fast;

    int n;cin>>n;
    string s;cin>>s;
    int dp[n][3]={0};
    for(int i=0 ;i<s.length(); i++)
    {
    	if(s[i]=='R')
    		dp[i][0]++;
    	if(s[i]=='G')
    		dp[i][1]++;
    	if(s[i]=='B')
    		dp[i][2]++;
    }
    for(int i=1; i<s.length(); i++)
    {
    	dp[i][0]+=dp[i-1][0];
    	dp[i][1]+=dp[i-1][1];
    	dp[i][2]+=dp[i-1][2];
    }
   

    ll ans=0;

    for(int i=0; i<n-2; i++)
    {
    	for(int j=i+1; j<=n-1; j++)
    	{
    		int x=j-i;
    		if((s[i]=='R' && s[j]=='G') || (s[i]=='G' && s[j]=='R') )
    		{

    			int y=dp[n-1][2]-dp[j][2];
    			//cout<<y<<" ";
    			if(j+x < n)
    			{
    				if(s[j+x]=='B')
    					y--;
    				
    			}
    			//cout<<y<<"\n";
    			if(y>0)
    			ans+=y;


    		}
    		else if((s[i]=='R' && s[j]=='B') || (s[i]=='B' && s[j]=='R') )
    		{
    			int y=dp[n-1][1]-dp[j][1];
    			if(j+x<n)
    			{
    				if(s[j+x]=='G')
    					y--;
    				
    			}
    			if(y>0)
    			ans+=y;

    		}
    		else if((s[i]=='G' && s[j]=='B') || (s[i]=='B' && s[j]=='G'))
    		{
    			int y=dp[n-1][0]-dp[j][0];
    			if(j+x<n)
    			{
    				if(s[j+x]=='R')
    					y--;
    				
    			}
    			if(y>0)
    			ans+=y;

    		}
    	}
    }
    cout<<ans;

  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <ctime>


#ifndef M_PI
#define M_PI 3.141592653589
#endif
#define int long long
#define double long double
#define f(variable, start, end) for (int variable = start; variable < end; ++variable)
#define be(a) a.begin(), a.end()
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define nor cout << "NO\n"; return
#define yesr cout << "YES\n"; return
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>


using namespace std;


template<typename T, typename E>
vector<T> &operator>>(vector<T> &v, E a) {
    v.push_back(a);
    return v;
}

//pair output
template<typename E>
ostream &operator<<(ostream &os, pair<E, E> &t) {
    os << t.first << ' ' << t.second;
    return os;
}

//"map" pair output
template<typename E>
ostream &operator<<(ostream &os, pair<const E, E> &t) {
    os << t.first << ' ' << t.second;
    return os;
}

//vector output
template<typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
    for (T i : vec) {
        os << i << ' ';
    }
    return os;
}

//2 dimensional vector output
template<typename T>
ostream &operator<<(ostream &os, vector<vector<T> > &vec) {
    for (vector<T> i : vec) {
        os << i << '\n';
    }
    return os;
}

//vector<pair<T, E>> output
template<typename T, typename E>
ostream &operator<<(ostream &os, vector<pair<T, E>> &vec) {
    for (pair<T, E> i : vec) {
        os << i.first << ' ' << i.second << '\n';
    }
    return os;
}


int32_t main() {
    cin.tie(NULL);
    cout.tie(NULL);
    cout.setf(ios::fixed);
    cout.precision(10);
    ios_base::sync_with_stdio(false);
#ifdef TIME
    int32_t start = clock();
#endif

    int n;
    cin >> n;
    cout << ((n % 1000 == 0) ? 0 : 1000 - n % 1000);

#ifdef TIME
    cout << "\ntime: " << (clock() - start) / (CLOCKS_PER_SEC * 1.0);
#endif

    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a.at(i);
	}
	for (int i = 0; i < w + 2; i++) {
		cout << '#';
		if (i - 1 == w) {
			cout << endl;
		}
	}
	for (int i = 0; i < h; i++) {
		cout << '#' << a.at(i) << '#' << endl;
	}
	for (int i = 0; i < w + 2; i++) {
		cout << '#';
		if (i - 1 == w) {
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	static long[][] dp;
	static int[] arrW;
	static int[] arrV;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int w = sc.nextInt();
		dp = new long[n + 1][w + 1];
		arrW = new int[n + 1];
		arrV = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			arrW[i] = sc.nextInt();
			arrV[i] = sc.nextInt();
		}
		System.out.println(dfs(n, w));
	}
	
	static long dfs (int n, int w) {
		if (n < 0 || w < 0) {
			return Long.MIN_VALUE;
		}
		if (n == 0 || w == 0) {
			return 0;
		}
		if (dp[n][w] != 0) {
			return dp[n][w];
		}
		
		dp[n][w] = Math.max(dfs(n - 1, w), dfs(n - 1, w - arrW[n]) + arrV[n]);
		return dp[n][w];
	}
}


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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
// using namespace __gnu_pbds;
typedef long double ld;
typedef long long ll;
#define int ll
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define vi vector<int>
#define pii pair<int,int>
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define MAX 100005
#define initialize(arr,elem) memset(arr,elem,sizeof(arr))
#define sz size
const int MOD = 1e9+7;

// typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld dp[301][301][301];
int n;
ld n1;
int cnt[4];
ld solve(int one, int two, int three){
	if (one <0 || two<0||three<0) return (ld)0;
	if (one ==0 && two == 0 && three==0) return dp[0][0][0] = (ld) 0;

	if (dp[one][two][three] != -1) return dp[one][two][three];
	ld total = (ld) (one+two+three);

	dp[one][two][three] = (solve(one-1,two,three)*(ld)one + solve(one+1,two-1,three)*(ld)two + solve(one, two+1,three-1)*(ld)three +n1)/total;
	return dp[one][two][three];
}
void rand_shuff(vi &arr){
	random_device rd;
	mt19937 g(rd());
	shuffle(all(arr),g);
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);


	cin>>n;
	n1 = (ld) n;
	initialize(cnt,0);
	For(i,0,301){
		For(j,0,301){
			For(k,0,301) dp[i][j][k] = (ld) -1 ;
		}
	}
	For(i,0,n){
		int x;
		cin>>x;
		cnt[x]++;
	}
	cout<<fixed<<setprecision(15);
	cout<<solve(cnt[1],cnt[2],cnt[3])<<endl;
	//cout<<dp[0][0][0]<<endl;
	return 0;
}


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

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

const long long MOD = 100000000;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a.at(i);
  vector<ll> x(n,0);
  rep(i,n){
    if(i%2==0) x.at(0)+=a.at(i);
    else x.at(0)-=a.at(i);
  }
  for(int i=1;i<n;i++){
    x.at(i)=2*a.at(i-1) - x.at(i-1);
  }
  rep(i,n){
    cout << x.at(i) << " ";
  }
  cout << endl;
}


Measured memory_bytes: 2944
def main():
  n = int(input())
  p = [0 for _ in range(n)]

  for _ in range(n):
    taro, hanako = input().split()

    if taro > hanako:
      p[0] += 3
    elif hanako > taro:
      p[1] += 3
    else:
      p[0] += 1
      p[1] += 1

  print(p[0], p[1])

if __name__ == '__main__':
  main()


Measured memory_bytes: 5608
#include <iostream>

using namespace std;

int main() {
    int P, Q, R;
    cin >> P;
    cin >> Q;
    cin >> R;

    int max = P;
    if(Q > max) max = Q;
    if(R > max) max = R;

    cout << P + Q + R - max << endl;

    return 0;
}

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

namespace Welcome_to_AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var array = Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();
            var sortedArray = array.OrderBy(_ => _).ToArray();

            if (array.SequenceEqual(sortedArray))
            {
                Console.WriteLine("YES");
                return;
            }

            var count = 0;
            for (int i = 0; i < n; i++)
            {
                if (array[i] != sortedArray[i])
                    count++;
            }

            if (count == 2)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


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

int main()
{
    int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
    int ans=0;
    int z=min(x,y);
    ans+=z*min(a+b,c*2);
    if(x<y)ans+=(y-z)*min(b,c*2);
    else if(x>y)ans+=(x-z)*min(a,c*2);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <bitset>
#include <cmath>
#include <vector>
#include <memory>
#include <algorithm>
#include <unordered_set>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <numeric>

using namespace std;
using uint = unsigned int;
using ulong = unsigned long;
using ushort = unsigned short;
using uchar = unsigned char;

int main() {
#ifdef __TEST_CODE
    // A dumb way of inlining test cases
    stringstream input_s(
            "4\n"
            "RRGB"
    );
    stringstream output_s;

    string expected_out("1800\n"
    );
    expected_out += "\n";
    istream &in = input_s;
    ostream &out = output_s;
#else
    istream& in = cin;
        ostream& out = cout;
#endif


    long long n;
    in >> n;

    string s;
    in >> s;

    vector<int> r;
    vector<int> g;
    vector<int> b;

    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            r.push_back(i);
        }
        if (s[i] == 'G') {
            g.push_back(i);
        }
        if (s[i] == 'B') {
            b.push_back(i);
        }
    }

    long long result = 0;
    for (int j = 1; j < n; ++j) {
        for (int diff = 1; diff <= (n / 2) + 1; ++diff) {
            auto i = j - diff;
            auto k = j + diff;
            if ((i >= 0) &&
                (k <= n - 1)) {
                if (s[j] != s[k] && s[i] != s[j] && s[i] != s[k]) {
                    result -= 1;
                }
            }
        }
    }
    result += g.size() * b.size() * r.size();


    out << result << endl;


#ifdef __TEST_CODE
    string actual_out = output_s.str();
    cout << actual_out;
    cout << "Output correct: " << (expected_out == actual_out) << endl;
#endif
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>

#define repAll(n) (n).begin(), (n).end()
#define repConAll(n) (n).cbegin(), (n).cend()

using namespace std;

namespace {

}

int main()
{
	long long N = 0, M = 0;

	cin >> N >> M;

	// 外側1周分のみ表。

	long long sum = 0;
	
	if (N == 1 && M == 1){
		sum = 1;
	}
	else if (N == 1){
		sum = M - 2;
	}
	else if (M == 1){
		sum = N - 2;
	}
	else {
		sum = (N - 2) * (M - 2);
	}

	cout << sum;

	return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = long.Parse(Console.ReadLine());

        var ans = long.MaxValue;
        for (long i = 1; i * i <= n; i++)
        {
            if (n % i == 0)
            {
                ans = Math.Min(
                    ans,
                    i + n / i - 2);
            }
        }
        Console.WriteLine(ans);
    }
}


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

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  bool ans = false;
  
  rep(i, 100)
  {
    if(A*i % B == C) ans = true;
  }
  
  if(ans) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ans;
string a;
string b="CODEFESTIVAL2016";
int main(){
	cin>>a;
	for(int i=0;i<a.size();i++){
		if(a[i]==b[i])
		   ans++; 
	}
	 cout<<a.size()-ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <fstream>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long ll;
#define REP(i, N) for (int i = 0; i < (int)N; i++)

class DAG {
  vector<bool> visited;

  void dfs(int u, vector<vector<int>> &G) {
    if(visited[u]) return;
    visited[u] = true;
    for(int v: G[u]) dfs(v, G);
    topologicalSorted.push_back(u);
  }

public:
  vector<int> topologicalSorted;
  bool valid;

  DAG(vector<vector<int>> G) {
    int V = G.size();
    visited.resize(V, false);

    for(int i = 0; i < V; i++) dfs(i, G);

    reverse(topologicalSorted.begin(), topologicalSorted.end());

    valid = static_cast<int>(topologicalSorted.size()) == V;
  }
};

int main () {
  int V, E;
  cin >> V >> E;

  vector<vector<int>> adjacentList(V, vector<int>());

  REP(i,E) {
    int s, t;
    cin >> s >> t;
    adjacentList[s].push_back(t);
  }

  DAG dag(adjacentList);
  for(auto u: dag.topologicalSorted) {
    cout << u << endl;
  }

  return 0;
}



Measured memory_bytes: 4116
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<stdio.h>
using namespace std;
typedef long long ll;
double *dp;




void solve(){
	
	int  N;
	int *d;
	cin >> N;
	d = new int[N];
	int sum = 0;
	for (int i = 0;i < N;i++)cin >> d[i];
	for (int i = 0;i < N;i++) {
		for (int j = 0;j < i;j++) {
			sum += d[i] * d[j];
		}
	}
	cout << sum << endl;
	
}


int main() {
	solve();

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long 
    #define ld long double
    #define MOD 1000000007
    #define mod9 1000000009
    #define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    #define mp make_pair
    #define pb push_back
    #define ct ll t;cin>>t;while(t--)
    #define bi begin()
    #define ei end()
    #define fi first 
    #define se second  
    #define foe(i,a,b) for(ll i=a;i<b;i++)
    #define rfoe(i,a,b) for(ll i=a;i>=0;i--)
    #define sz(s) s.size() 
    #define mem(a,s) memset(a,s,sizeof(a)) 
    #define all(v) v.bi,v.ei
    #define MAX             8000000000000000064LL
    #define MIN            -8000000000000000064LL   

    typedef pair<ll,ll> pii;
    
    ll add(ll a, ll b){return (a%MOD + b%MOD + ((MAX)/MOD)*MOD)%MOD;}
    ll sub(ll a, ll b){return (a%MOD - b%MOD + ((MAX)/MOD)*MOD)%MOD;}
    ll mul(ll a, ll b){return ((a%MOD)*(b%MOD) + ((MAX)/MOD)*MOD)%MOD;}
    ll lcm(ll a,ll b){return(a*b)/__gcd(a,b);}
    ll fact[1000007 ]={0};
    ll expo(ll x, ll y) {ll res=1;x=x%MOD;while(y>0){if(y&1)res=(1ll*res*x)%MOD;
    y=y>>1;x=(1ll*x*x)%MOD;} return res;}
    void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%MOD;}
    ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expo(fact[r],MOD-2)))%MOD; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res;}
    ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res; }
    int const N=2e5+9;
    ll const INF = 2e18+5;
    ll dx[8]={0,0,1,-1,1,1,-1,-1};
    ll dy[8]={1,-1,0,0,-1,1,-1,1};
    long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = mul(res,a);
        a = mul(a,a);
        b >>= 1;
    }
    return res;
}
    void solve()
    {  
       ll n;
       cin>>n;
       ll ans=binpow(10,n);
       ans=sub(ans,binpow(9,n));
        ans=sub(ans,binpow(9,n));
       ans=add(ans,binpow(8,n));
        cout<<ans<<" ";
    }
    int main()
    {
        fast
        // facto();
        // Sieve();
    //    ct    
        { 
            solve();
        }
    }


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

int main(){
    int a,b;
    cin>>a>>b;
    if(a>b){
        cout<<"a > b"<<endl;
    }
    else if(a<b){
        cout<<"a < b"<<endl;
    }
    else{
        cout<<"a == b"<<endl;
    }
}


Measured memory_bytes: 3084
def main():
    S = input()
    T = input()
    l = len(T)
    m = l
    for i in range(len(S)-l+1):
        r = 0
        for j in range(l):
            if S[i+j] != T[j]:
                r += 1
        if r < m:
            m = r
    return m
print(main())


Measured memory_bytes: 72912
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int mx=-10000000;
        int mi=10000000;
        long sum=0;
        for(int i=0;i<N;i++){
            int a=sc.nextInt();
            sum+=a;
            if(mx<a){mx=a;}
            if(mi>a){mi=a;}
        }
        System.out.printf("%d %d %d\n",mi,mx,sum);
    }     
}



Measured memory_bytes: 41224
## ABC086C
## C - Traveling
import sys

n = int(input())
pos = [[int(_) for _ in input().split()] for _ in range(n)]

x = 0
y = 0
t = 0

for i in pos:
    ti, xi, yi = map(int,i)
    # print(t,x,y)
    dl = abs(xi-x)+abs(yi-y)
    dt = ti-t
    if (dl > dt or (dl-dt)%2 == 1):
        print('No')
        sys.exit()
    else:
        x = xi
        y = yi
        t = ti

print('Yes')

Measured memory_bytes: 21108
S = input()
t = 0
p = 0
for s in S:
    if s == "g":
        if t > 0: #パーを出す
            t -= 1
            p += 1
            continue
        else:
            t += 1 #グーを出す
    else:
        if t > 0: #パーを出す
            t -= 1
        else: #グーを出す
            p -= 1
            t += 1
print(p)


Measured memory_bytes: 3316
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_INPUT_LEN     ( 10000 )
#define NUM_MAX_DATA      ( 1000 )
#define MAX_DATA_STR_LEN  ( 100 )
#define NO_DATA           ( 9999 )

struct data
{
    char data_str[MAX_DATA_STR_LEN + 1];
    short  data_num;
};

int split(char *str, const char *delim, char *outlist[]);


int main() {

    char  InputLine[MAX_INPUT_LEN + 1] = "";
    char* InputList[NUM_MAX_DATA + 1] = {0};

    struct data DataList[NUM_MAX_DATA + 1];
    int  data_count = 0;
    char* ret_fgets = NULL;
	int i = 0;

    int num = 0;
	int data_num = 0;
	int min = 1000;
	int max = 0;
	char newline = 'a';

    /* Get input data */
    scanf("%d", &num);
    scanf("%c", &newline);

    /* Init input list*/
    //init_list(DataList, NUM_MAX_DATA);
    for (i = 0; i < NUM_MAX_DATA; i++)
    {
        /* set data_num */
        memset( &DataList[i], 0x00, sizeof(struct data) );
        strcpy(DataList[i].data_str, "ZZZ");
        DataList[i].data_num = 0xffff;
    }

    /* Get all data */
    ret_fgets = fgets(InputLine, sizeof(InputLine), stdin);
    if (ret_fgets != NULL)
    {
        data_count = split(InputLine, " \n", InputList);
    }

    /* Set data-num */
    for (i = 0; i < data_count; i++)
    {
        /* set data_num */
        strcpy(DataList[i].data_str, InputList[i]);
        DataList[i].data_num = atoi(DataList[i].data_str);
    }

	for(i = 0; i < data_count; i++ )
	{
		data_num = DataList[i].data_num;
		if( data_num < min )
			min = data_num;
		if( data_num > max )
			max = data_num;
	}

    printf( "%d\n", max - min );

    return 0;
}

int split(char *str, const char *delim, char *outlist[])
{
    char *token;
    int count = 0;
    char *next_token = NULL;
    
    //token = strtok_s(str, delim, &next_token);
    token = strtok(str, delim);
    while ((token != NULL) && (count < NUM_MAX_DATA)) {
        outlist[count++] = token;
        //token = strtok_s(NULL, delim, &next_token);
        token = strtok(NULL, delim);
    }
    return count;
}



Measured memory_bytes: 256
using System;

public class Program
{
	public static void Main()
	{
        var N = int.Parse(Console.ReadLine());
        var Ai = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        var count = 0;
        var flug = true;

        while (flug == true)
        {
            for (var i=0; i < N; i++)
            {
                if(Ai[i] % 2 == 1)
                {
                    flug = false;
                    break;
                }
                else
                {
                    Ai[i] /= 2;
                }
            }
            if (flug == true) count++;
        }


        Console.WriteLine(count);
	}
}


Measured memory_bytes: 13140
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<array>
#include<deque>
#include<queue>
#include<map>
#include<cmath>
#include<stdio.h>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::array;
using std::queue;
using std::deque;
using std::priority_queue;
using std::multimap;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;
using std::sin;
using std::cos;
using std::log;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;
#define MOD 1000000007;
#define PI 3.141592653589793;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int N;
/*約数が8->27*素数or125*素数or素数3つの積*/

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

	cin >> N;
	if(N < 105){
		cout << 0;
	}else if(N < 135){
		cout << 1;
	}else if(N < 165){
		cout << 2;
	}else if(N < 189){
		cout << 3;
	}else if(N < 195){
		cout << 4;
	}else{
		cout << 5;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    int n;
    ld d;
    cin>>n>>d;
    ll ans=0;
    for(int i=0;i<n;i++){
        ld x,y;
        cin>>x>>y;
        if(pow(x*x+y*y,0.5)<=d){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
int a[101];
int main()
{
	int n,m,i,j,min1=1001,k=0,t=0;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		min1=min(min1,a[i]);
		k+=a[i];
	}
	m-=k;
	if(m>min1)
	{
		t=m/min1;
	}
	t+=n;
	printf("%d",t);
} 

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <vector>
typedef long long LL;
constexpr int kVmax = 1e5 + 1;
//constexpr int kVmax = 50;

#define DEBUG 0

int main() {
  int N, W; std::cin >> N >> W;
  LL score[kVmax];

  score[0] = 0;
  for (int i = 1; i < kVmax; ++i) score[i] = W + 1;

#if DEBUG
  for (LL s : score) std::cout << s << " ";
  std::cout << std::endl;
#endif

  for (int i = 0; i < N; ++i) {
    int w, v; std::cin >> w >> v;
#if DEBUG
    std::cout << w << ", " << v << std::endl;
#endif
    LL prev_score[kVmax];
    for (int i = 0; i < kVmax; ++i) prev_score[i] = score[i];
    for (int j = 0; j < kVmax - v; ++j) {
      score[j+v] = std::min(
          prev_score[j+v], prev_score[j] + w);
    }

#if DEBUG
    for (LL s : score) std::cout << s << " ";
    std::cout << std::endl;
#endif
  }

#if DEBUG
  for (LL s : score) std::cout << s << " ";
  std::cout << std::endl;
#endif

  for (int i = kVmax - 1; i >= 0; --i) {
    if (score[i] <= W) {
      std::cout << i << std::endl;
      return 0;
    }
  }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;

#define SZ(x) ((int)x.size())

const int N = (int)2e3+5;
int n, ind[N], a[N];
bool vis[N];
vector<int> g[N];

bool dfs(int u) {
	vis[u] = true;
	for (int v = 1; v <= n; ++v) if (__gcd(a[u], a[v]) > 1 && !vis[v]) {
		g[u].push_back(v), ++ind[v];
		dfs(v);
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++i) if (!vis[i]) dfs(i);
	priority_queue<ii> pq;
	for (int i = 1; i <= n; ++i) if (!ind[i]) pq.push(ii(a[i], i));
	while (SZ(pq)) {
		int u = pq.top().second; pq.pop();
		printf("%d ", a[u]);
		for (int v : g[u]) if (!(--ind[v])) pq.push(ii(a[v], v));
	}
	return 0;
}

Measured memory_bytes: 640