akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int N,H;
int main(){
    cin >> N >> H;
    vector<int> a(N),b(N);
    int mightySword = 0;
    REP(i,N){
        cin >> a[i] >> b[i];
        chmax(mightySword, a[i]);
    }
    sort(b.begin(),b.end(),greater<int>());
    int ans = 0; int katanaIndex = 0;
    // 最強の刀より高い威力を出すものは全部投げるべき
    // 最強の刀を投げる必要がある場合は、最後に投げれば良い
    // つまり投げ威力が振り威力最強より大きいものを上から使い、余った体力を振り威力で削る。
    while(H > 0){
        if(mightySword < b[katanaIndex]){
            H -= b[katanaIndex];
            ++katanaIndex;
            ++ans;
        } else {
            ans += (H + (mightySword - 1)) / mightySword;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 3005
using namespace std;
using LL = long long;
int n,a[M];
LL dp[M][M];
bool vis[M][M];
LL dfs(int l,int r) {
    if (l>r) return 0;
    if (vis[l][r]) return dp[l][r];
    vis[l][r] = true;
    LL &res = dp[l][r];

    res = -(1LL << 60);
    res = max(res, a[l] - dfs(l+1, r));
    res = max(res, a[r] - dfs(l, r-1));
    return res;
}
int main()
{
    scanf("%d", &n);
    REP(i,1,n) scanf("%d", &a[i]);
    printf("%lld\n", dfs(1,n));
    return 0;
}


Measured memory_bytes: 58952
n = int(input())
bn = list(map(int,input().split()))

ans = []

while len(bn)>0:
  lst = []
  for i in range(len(bn)):
    if i+1 == bn[i]:
      lst.append(i)
  if len(lst) == 0:
    print(-1)
    exit(0)
  ans.append(bn.pop(lst[-1]))
for i in ans[::-1]:
  print(i)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>
#include <map>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))
const ll mod = 1000000007;
const double eps = 1e-10;
const int MAX = 200000;

int main() {
	int n;
	cin >> n;
	cout << n*n << endl;
  return 0;
}

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

ll ans = 0;
string s;
int size;

void saiki(ll count, ll mid, ll re){ 
    if(count == size){
        ans += re + mid;
        return;
    }
    int a = s[count] - '0';
    count++;
    saiki(count, mid*10+a, re);
    saiki(count, a, re+mid);
}

int main(){
    cin >> s;
    size = s.size();
    saiki(0, 0, 0);
    cout << ans/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll (i)=0;(i)<(ll) (n);(i)++)
int main(void){
    ll n,i=0,j,p,h[1000010],k;
    double c=1,kaku=0;
    cin >> n >> k;
    for(i=1;i<=n;i++)
    {
        j=i;
        while(j<k)
        {
            c=c/2;
            j=j*2;
        }
        kaku+=c/n;
        c=1;
    }
    cout << fixed << setprecision(12);
    cout << kaku << endl;
    return 0;

}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = {0, 1, 0, -1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'u', 'r', 'd', 'l'};
static const ll INF = 1ll << 60;
static const ll MOD = 1e9 + 7;

signed main() {
  string n;
  cin >> n;
  for (auto& ch : n) {
    if (ch == '7') {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 3624
# we collect the input A1 upto An.
# limit cannot exceed 10**18
# if N = 0 then ans = 0
# in N is in range then compute 1 * A[n]
N = int(input())
ans = 1
limit = 10 ** 18
length = 0

A = list(map(int, input().split()))

A0 = set(A)
if 0 in A0:
    ans = 0
else:
    pass

for n in range(N):
    ans = ans * A[n]
    if ans == 0:
        break
    elif ans > limit:
        length = 1
        break
    else:
        pass

if length == 1:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 21616
<?php
#include <stdio.h>
# 整数の入力
fscanf(STDIN, "%d", $a);//500円玉の枚数　0-50
fscanf(STDIN, "%d", $b);//100円玉の枚数　0-50
fscanf(STDIN, "%d", $c);//50円玉の枚数　0-50
fscanf(STDIN, "%d", $x);//合計金額　50の倍数

$ways = 0;

for($i=0;$i<$a+1;$i++){
  for($j=0;$j<$b+1;$j++){
    for($k=0;$k<$c+1;$k++){
      $sum = $i*500 + $j*100 + $k*50;
      if($sum == $x){
        $ways++;
      }
    }
  }
}

echo $ways."\n";

Measured memory_bytes: 3700
import java.util.*;
import java.io.*;
import java.lang.*;

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

        if (a.charAt(0) == b.charAt(0))
            System.out.println('H');
        else
            System.out.println('D');
    }
}


Measured memory_bytes: 35456
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = 998244353;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve() {
	ll n;
	cin >> n;
	vector<P> xd(n);
	REP(i, n) cin >> xd[i].first >> xd[i].second;
	sort(all(xd));
	set<P> st;
	Array dp(n, 0);
	rep2(i, 0, n) {
		ll x = xd[i].first;
		ll d = xd[i].second;
		auto it2 = st.lower_bound({ x+d,i });
		auto it = st.lower_bound({ x,i });
		
		ll ret = 1;
		while (it != it2) {
			ll x2 = it->first;
			ll i2 = it->second;
			(ret *= dp[i2]) %= MOD;
			it=st.erase(it);
		}

		(dp[i] = ret + 1) %= MOD;

		st.insert({ x,i });
	}

	ll ans = 1;
	for (auto i : st) {
		(ans *= dp[i.second])%=MOD;
	}
	cout << ans << en;

}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 11264
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = []
for i in range(n):
  c.append(min(a[i],b[i]))
d = [0 for _ in range(n)]
e = [0 for _ in range(n)]
d[0] = 1
e[-1] = 1
for i in range(1,n):
  if a[i-1] != a[i]:
    d[i] = 1
for i in range(n-1)[::-1]:
  if b[i+1] != b[i]:
    e[i] = 1
for i in range(n):
  if d[i] * e[i] == 1 and a[i] != b[i]:
    print(0)
    break
else:
  for i in range(n):
    if d[i] == 1 and a[i] != c[i]:
      print(0)
      break
    if e[i] == 1 and b[i] != c[i]:
      print(0)
      break
  else:
    ans = 1
    mod = 10 ** 9 + 7
    for i in range(n):
      if d[i] == e[i] == 0:
        ans *= c[i]
        ans %= mod
    print(ans)

Measured memory_bytes: 88804
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1e-8

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

int main(){
	while(1){
		int mx,Mx,my,My,n;
		mx=Mx=my=My=0;
		p[0]=MP(0,0);
		cin>>n;
		if(n==0)return 0;
		REP(i,n-1){
			int idx,d;
			cin>>idx>>d;
			p[i+1]=MP(p[idx].first+dx[d],p[idx].second+dy[d]);
			mx=min(mx,p[i+1].first);
			Mx=max(Mx,p[i+1].first);
			my=min(my,p[i+1].second);
			My=max(My,p[i+1].second);
		}
		cout << Mx-mx+1<< " " << My-my+1 << endl;
	}
}

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

struct Node{
  int p, l, r;
};

Node t[100005];
int D[100005];//node depth

int rec(int u, int p){
  D[u] = p;
  if(t[u].r != -1){
    rec(t[u].r, p);
  }
  if(t[u].l != -1){
    rec(t[u].l, p + 1);
  }
}

void print(int a){
  cout << "node " << a << ": ";
  cout << "parent = " << t[a].p << ", ";
  cout << "depth = " << D[a] << ", ";
  
  if(t[a].p == -1){
    cout << "root, ";
  }else if(t[a].l == -1){
    cout << "leaf, ";
  }else{
    cout << "internal node, ";
  }

  cout << "[";

  int c;
  for(int i = 0, c = t[a].l; c != -1; i++, c = t[c].r){
    if(i){
      cout << ", ";
    }
    cout << c;
  }

  cout << "]" << endl;
}

int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    t[i].p = -1;
    t[i].l = -1;
    t[i].r = -1;
  }

  int id, k, c, l, r;
  for(int i = 0; i < n; i++){
    cin >> id >> k;
    for(int j = 0; j < k; j++){
      cin >> c;
      if(j == 0)t[id].l = c;
      else t[l].r = c;
      l = c;
      t[c].p = id;
    }
  }

  for(int i = 0; i < n; i++){
    if(t[i].p == -1)r = i;
  }

  rec(r, 0);

  for(int i = 0; i < n; i++){
    print(i);
  }
}

Measured memory_bytes: 7760
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n;
ll M=1e5+1;

//bit全探索
vi bt;
void setbit(ll i){
  bt.clear();
  for(ll tmp=0;i>0;i/=2){
    if (i%2==1) bt.push_back(tmp);
    tmp++;
  }
}




int main(){
  ll ans=0,q;
  cin >>n;
  n++;
  ll nlg=ceil(log2(n));
  vi V(n),W(n);
  REP(i,n-1) cin>>V[i+1]>>W[i+1];

  cin >>q;
  vi u(q),L(q);
  REP(i,q) cin>>u[i]>>L[i];

  //上半分
  ll nhi=nlg-(nlg/2);
  if (nhi==9)nhi=11;
  vvi data(1LL<<nhi, vi(M));  // N * M の2次元配列

  for(ll i=1;i<(1LL<<nhi);i++){
    for(ll j=0;j<M;j++){
      if ((j-W[i])>=0)
      {
        data[i][j]=max(data[i/2][j-W[i]]+V[i],data[i/2][j]);
      }
      else
      {
        data[i][j]=data[i/2][j];
      }
    }
  }


int uiv[10];
int wuiv=0;


//下半分
for(ll loop=0;loop<q;loop++){
  ll uidx=u[loop];
  if (uidx<(1LL<<nhi)){
    cout<<data[uidx][L[loop]]<<endl;
  }else{//上＋下
    ll maxval=0;
    //vi uiv;
    int nn=0;
    wuiv=0;
    for(;;uidx/=2){
      if (uidx<(1LL<<nhi))break;
      uiv[wuiv]=uidx;
      wuiv++;
      nn++;
    }

    int bn=1<<nn;
    for(int i=0;i<bn;i++){
      //setbit(i);
      ll tmpw=0;
      ll tmpv=0;
      for(int j=0;j<nn;j++){
        if (i&(1<<j)){
          tmpv+=V[uiv[j]];
          tmpw+=W[uiv[j]];
        }
      }
      //for (auto j : bt) {
        //tmpv+=V[uiv[j]];
        //tmpw+=W[uiv[j]];
      //}
      if (tmpw<=L[loop]){
        maxval=max(data[uidx][L[loop]-tmpw]+tmpv,maxval);
      }
    }

    cout<<maxval<<endl;
  }












}


  return 0;
}

Measured memory_bytes: 809288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())
const int N=1e3+10;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,m,a,b;
char s[N][N];

int main() {
	cin>>n>>m>>a>>b;
	memset(s,'.',sizeof(s));
	if(n&1) {
		for(int i=1;i<m&&a;i+=2) --a,s[n][i]='<',s[n][i+1]='>';
	}
	if(m&1) {
		for(int i=1;i<n&&b;i+=2) --b,s[i][m]='^',s[i+1][m]='v';
	}
	for(int i=1;i<n;i+=2)
		for(int j=1;j<m;j+=2) {
			if(a>=2) {
				a-=2;
				s[i][j]=s[i+1][j]='<';
				s[i][j+1]=s[i+1][j+1]='>';
			}
			else if(b>=2) {
				b-=2;
				s[i][j]=s[i][j+1]='^';
				s[i+1][j]=s[i+1][j+1]='v';
			}
			else if(i==n-2&&j==m-2&&a&&b) {
				--a;--b;
				s[i][j]=s[i+2][j+1]='<';
				s[i][j+1]=s[i+2][j+2]='>';
				s[i][j+2]=s[i+1][j]='^';
				s[i+1][j+2]=s[i+2][j]='v';
			}
			else if(a) {
				--a;
				s[i][j]='<';s[i][j+1]='>';
			}
			else if(b) {
				--b;
				s[i][j]='^';s[i+1][j]='v';
			}
		}
	if(a||b) cout<<"NO";
	else {
		cout<<"YES\n";
		for(int i=1;i<=n;i++,putchar('\n'))
			for(int j=1;j<=m;j++) putchar(s[i][j]);
	}
	return 0;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12

int n;
char s[2];
int res[4];

int main()
{
  while(scanf("%d,%s", &n, s) != EOF){
    if(!strcmp(s, "A") ) res[0] += 1;
    if(!strcmp(s, "B") ) res[1] += 1;
    if(!strcmp(s, "AB")) res[2] += 1;
    if(!strcmp(s, "O") ) res[3] += 1;
  }

  rep(i, 4) cout << res[i] << endl;

  return 0;
}

Measured memory_bytes: 1204
n,m=map(int,input().split())

data=[0]*n
s=set()

for i in range(m):
    p,a=input().split()
    p=int(p)-1
    if p in s:
        continue
    else:
        if a=='WA':
            data[p]-=1
        else:
            data[p]*=-1
            s.add(p)

print(len(s),sum([data[i] for i in range(n) if data[i]>0]))

Measured memory_bytes: 18084
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    vn = vk = vn_k = 1
    for i in range(1, n+1):
        vn = vn * i % modp
        if i == k:
            vk = vn
        if i == n-k:
            vn_k = vn
    return vn * get_inv(vk, modp) * get_inv(vn_k, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

def main():
    N,R=mis()
    if N>=10:
        print(R)
    else:
        print(R+100*(10-N))

main()







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

void traceArray(int A[],int N){
    for(int i = 0; i < N; i++){
        if(i > 0){
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
}

int bubbleSort(int A[],int N){
    int cnt = 0;
    for(int i = 0; i< N; i++){
        for(int j = N-1; j >= i+1; j--){
            if(A[j] < A[j-1]){
                swap(A[j],A[j-1]);
                cnt++;
            }
        }
    }
    traceArray(A,N);
    return cnt;
}

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }
    int cnt = bubbleSort(a,n);
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
 
  long long int N, M, count; 
 
  cin >> N;
  cin >> M;
  
  if(2*N > M){
   cout << M/2;
  }
  else {
    count = N;
    M -= 2*N;
    count += M/4;
    cout << count;
  } 
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,c;
	while(scanf("%d",&c)!=EOF){
	a=c%39;
		if(a==0){
			a=39;
		}
		if(a<=9){
			printf("3C0%d\n",a);
		}
		else{
			printf("3C%d\n",a);
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    if(n % 2 == 1 && 2*k+2*n-1-n/2 > k+n*2){
        cout << -1 << endl;
        return 0;
    }
    if(n % 2 == 0 && 2*k+2*n-n/2 > k+n*2){
        cout << -1 << endl;
        return 0;
    }

    
    int a[n], b[n], c[n];

    int i = k + n - 2;
    int cnt = 0;
    while(i >= k){
        a[cnt] = i;
        cnt++;
        i -= 2;
    }
    i = k + n - 1;
    while(i >= k){
        a[cnt] = i;
        cnt++;
        i -= 2;
    }
    cnt = 0;
    i = k + n * 2 - n / 2;
    while(i < k + n * 2){
        b[cnt] = i;
        cnt++;
        i++;
    }
    i = k + n;
    while(cnt < n){
        b[cnt] = i;
        cnt++;
        i++; 
    }
    cnt = 0;
    while(cnt < n){
        c[cnt] = k + n * 3 - 1 - cnt;
        cnt++;
    }

    rep(i,n)cout << a[i] << ' ' << b[i] << ' ' << c[i] << endl;

    return 0;
}
 
 


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

void adjacency_list(int n, vector<vector<int>>& a)
{
	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			int v;
			cin >> v;
			a[u][--v] = 1;
		}
	}
}

int main()
{
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(n));
	adjacency_list(n, a);

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


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n;
	cin >> n;
	vll d(n);
	rep(i,n) cin >> d[i];
	sort(all(d));
	Eunique(d);
	cout << SIZE(d) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
#define ck(n,a,b) (a<=(n)&&(n)<=b)
#define F first
#define S second
using namespace std;
int opCalc(char op,int left,int right){
	int ret;
	if(op=='+'){
		ret=left+right;
	}else if(op=='*'){
		ret=left*right;
	}
	return ret;
}

int main(){
	int n;
	while(cin>>n,n){
		string s[20];
		vector<pair<int,int>> vt;
		int maxj=0;
		REP(i,0,n){
			cin>>s[i];
			REP(j,0,(int)s[i].size()){
				if(s[i][j]=='.') continue;
				vt.push_back({j,s[i][j]-'0'});
				maxj=max(maxj,j);
				break;
			}
		}
		int ans=vt[0].S;
			for(int j=maxj-1;j>=0;j--){
				for(int i=0;i<(int)vt.size()-2;i++){
					if((vt[i].S+'0'!=(int)'+'&&vt[i].S+'0'!=(int)'*')||vt[i].F!=j)	continue;
					bool flag=false;
					while(vt[i].F+1==vt[i+1].F&&vt.size()>1&&i+1<vt.size()){
						if(!flag) {
							ans=opCalc((char)vt[i].S+'0',vt[i+1].S,vt[i+2].S);
							vt.erase(vt.begin()+i+2);
							flag=true;
						}else	ans=opCalc((char)vt[i].S+'0',vt[i+1].S,ans);
						vt.erase(vt.begin()+i+1);
					}

					vt[i]={vt[i].F,ans};
				}
			}
			p(ans);
	}
	return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
操作の回数･･･
あたまから順番になっているものをカウントしてくとか
1324

12だけ
34をおしりから入れなおし＝2

325146
1だけ
23456=5

おしりから
65だけ
4321あたまから＝4

63127485
12 =6
876=5

12453
ちがった・・・わからん
21435
54321
4231

13245
ええ、解説でもあってそうなんだが
13452

231546
123546
123564
123645
123456

231546
423156
342156
234156
123456

6
2
3
1
6
4
5
=2になるはず
これか
2345で並ぶから6-4=2か
231645
*/
int main(){
  ll N,high=0; cin>>N;
  vector<ll> A(N+1,0),B(N+1,0);
  for(ll i=1; i<=N; i++){
    cin>>A[i];
    B[A[i]]=B[A[i]-1]+1;
    high=max(high,B[A[i]]);
  }
  cout<<N-high<<endl;
}

Measured memory_bytes: 6416
N = int(input())
#N,K = map(int, input().split())
dct = {}
mx = 0
for z in range(N):
    x = input()
    try:
        dct[x] += 1
    except:
        dct[x] = 1
    mx = max(mx, dct[x])
keys = list(dct.keys())
ans = []
for key in keys :
    if dct[key] == mx:
        ans.append(key)
ans.sort()
for elem in ans:
    print(elem)


Measured memory_bytes: 94040
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  ll n;cin>>n;
  ll a,b;cin>>a>>b;
  ll tmp = abs(a - b);
  ll ans;
  if(tmp % 2){
    ans = min(a-1,n-b) + 1 + (b - a - 1)/2;
  }else{
    ans = tmp / 2;
  }
  print(ans);
  return 0;
}


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

int main(void){
	long i, j, n, m;
	scanf("%ld %ld", &n, &m);
	long x[n], y[m];
	for(i = 0; i < n; i++) scanf("%ld", &x[i]);
	for(i = 0; i < m; i++) scanf("%ld", &y[i]);

	long sumx = 0;
	for(i = 0; i < n; i++){
		sumx += x[i]*(i*2-(n-1));
		sumx %= MOD;
	}
	long sumy = 0;
	for(i = 0; i < m; i++){
		sumy += y[i]*(i*2-(m-1));
		sumy %= MOD;
	}
	printf("%ld\n", sumx*sumy%MOD);

	return 0;
}


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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define vint vector<int>
#define vvint vector<vector<int>>

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
  char b;cin >> b;
  switch(b){
    case 'A': cout << 'T' << endl;
              break;
    case 'T': cout << 'A' << endl;
              break;
    case 'C': cout << 'G' << endl;
              break;
    case 'G': cout << 'C' << endl;
              break;

  }

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T> void dbg(T x) { cout << x << "\n"; }
template<typename T, typename U> static void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void chmax(T &x, U y) { if (x < y) x = y; }


int n, m;

// O(n^2)
using Dist = int;
const int VMAX = 110;
Dist cost[VMAX][VMAX];
Dist d[12][VMAX];
void dijkstra(int s, int a) {
    d[a][s] = 0;
    vector<int> used(n, 0);
    while (1) {
        int v = -1;
        for (int to = 0; to < n; to++) {
            if (used[to]) continue;
            if (v == -1 || d[a][to] < d[a][v]) v = to;
        }
        if (v == -1) break;
        used[v] = 1;
        for (int to = 0; to < n; to++) {
            Dist nd = d[a][v] + cost[v][to];
            if (a > 0) chmin(nd, d[a - 1][v] + cost[v][to] / 2);
            if (nd < d[a][to]) d[a][to] = nd;
        }
    }
}

void init() {
    fill_n(*d, 12 * VMAX, INF);
    fill_n(*cost, VMAX * VMAX, INF);
}

int main() {
    int c, s, t;
    while (cin >> c >> n >> m >> s >> t, c) {
        init();
        s--; t--;
        rep(i, m) {
            int a, b, f; cin >> a >> b >> f;
            a--; b--;
            cost[a][b] = cost[b][a] = f;
        }
        rep(a, c + 1) dijkstra(s, a);
        cout << d[c][t] << "\n";
    }

    return 0;
}


Measured memory_bytes: 3104
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = LIST()

ball = [0] * (N+1)

for i in range(len(a), 0, -1):
	if i > N // 2:
		ball[i] = a[i-1]
	else:
		tmp = a[i-1]
		for x in range(i, N+1, i):
			# print(x)
			if x == i:
				continue
			tmp = tmp ^ ball[x]
			# print("tmp", tmp)
		ball[i] = tmp
		# print("i",i)
		# print(tmp, a[i-1])
# print(ball)
print(sum(ball))
for i, j in enumerate(ball):
	if j == 1:
		print(i, end=" ")
print()


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

int main(){

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

  sort(v, v+5, greater<int>());
  
  for(int i=0; i<5; i++){
  	cout << v[i];
  	if(i != 4)
  		cout << " ";
	}
	cout << endl;
	
  return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

int main() {
	int n;
	string s;
	cin >> n >> s;
	int cnt_r = 0;
	int cnt_g = 0;
	int cnt_b = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') cnt_r++;
		if (s[i] == 'G') cnt_g++;
		if (s[i] == 'B') cnt_b++;
	}
	ll cnt_error = 0;
	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j <= (i + n - 1) / 2; j++) {
			if (s[i] != s[j] && s[j] != s[2 * j - i] && s[2 * j - i] != s[i]) cnt_error++;
		}
	}
	ll ans = (ll)cnt_r * cnt_g * cnt_b - cnt_error;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
/**
  *  Worg
  */
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>

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

    std::multiset<int> mset;
    for (int i = 0; i < (1 << n); i++) {
        int x; std::cin >> x;
        mset.insert(-x);
    }

    std::multiset<int> a, b;
    a.insert(*mset.begin()); mset.erase(mset.begin());

    for (int i = 1; i <= n; i++) {
        for (auto& x: a) {
            auto it = mset.upper_bound(x);

            if (it == mset.end()) {
                std::cout << "No\n"; return 0;
            }

            b.insert(*it); mset.erase(it);
        }

        for (auto& x: b) {
            a.insert(x);
        }
        b.clear();
    }

    std::cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 18688
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<chrono>
#include<unordered_map>
#include<random>
#include<complex> 
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned ll 
#define endl '\n'
#define mk make_pair
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);

}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };
int lx[] = { 2, 2, -1, 1, -2, -2, -1, 1 };
int ly[] = { -1, 1, 2, 2, 1, -1, -2, -2 };
const ld eps = 1e-9;
const int N = 1e5 + 50, M = 1e5 + 10, mod = 1e9 + 7;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll t = gcd(a, b); return t ? (a / t * b) : 0; }
int n;
int dp[N];
int ar[N];
pair<int, int>arr[N];
int solve(int ind) {
	if (ind == n)
		return 0;
	int& ret = dp[ind];
	if (ret != -1)return ret;
	ret = solve(ind + 1);
	int id = lower_bound(ar, ar + n, arr[ind].second) - ar;
	ret = max(ret, solve(id) + 1);
	return ret;
}
int main() {
	fast_in_out();
//	cout << fixed << setprecision(6);
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x, r;
		cin >> x >> r;
		arr[i].first = x - r;
		arr[i].second = x + r;
	}
	sort(arr, arr + n);
	for (int i = 0; i < n; i++) {
		ar[i] = arr[i].first;
	}
	memset(dp, -1, sizeof dp);
	cout << solve(0) << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int n;
vector<int> v, c;

int solve() {
  int sum{};
  REP(i, n) {
    if (v[i] - c[i] > 0)
      sum += v[i] - c[i];
  }
  return sum;
}

int main() {
  cin >> n;
  REP(i, n) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  REP(i, n) {
    int a;
    cin >> a;
    c.push_back(a);
  }
  cout << solve() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(pos,mp) for(ll pos=mp.begin();pos!=mp.end();pos -++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll a;
    double b;
    cin >> a >> b;

    ll bl = llround(b * 100);

    ll ans = a * bl / 100;

    cout << ans << endl;
}


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

using namespace std;
const int maxn = 1e5 + 5;
vector<int> adj[maxn];
int dp[maxn];

int dfs(int u){
    if (dp[u] != -1) return dp[u];
    dp[u] = 0;
    for (auto v : adj[u]){
        dp[u] = max(dp[u], 1 + dfs(v));
    }
    return dp[u];
}

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) dp[i] = -1;
    for (int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++){
        ans = max(ans, dfs(i));
    }
    cout << ans;
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define endl "\n"

#define aim_cpo do{ios::sync_with_stdio(false);\
cin.tie(nullptr);cout.precision(10);cout<<fixed;}while(0)

#define LOCAL_INPUT do{FILE *stream1;\
stream1=freopen("/Users/aim_cpo/CLionProjects/competitive/in.txt","r",stdin);\
if(stream1==nullptr)return 0;}while(0)
#define LOCAL_OUTPUT do{FILE *stream2;\
stream2 = freopen("out.txt", "w", stdout);\
if (stream2 == nullptr) return 0;}while(0)

#ifdef LOCAL_DEFINE
#define show(x) cerr << #x << " = " << (x) << endl
#define showV(v, n) do{\
for(int _i_t_e_=0; _i_t_e_<(n);_i_t_e_++)\
cerr<<"("<<_i_t_e_<<" = "<<(v)[_i_t_e_]<<") ";\
cerr<<endl;}while(0);
#define showA(a, n) do{\
for(int _i_t_e_=0;_i_t_e_<(n);_i_t_e_++)\
cerr<<"("<<_i_t_e_<<" = "<<(a)[_i_t_e_]<<") ";\
cerr<<endl;}while(0);
#else
#define show(x)
#define showV(v, n)
#define showA(a, n)
#endif

typedef long long ll;
typedef unsigned long long ull;

constexpr const int INT_INF=0x3f3f3f3f; //1061109567
constexpr const ll LL_INF=0x3f3f3f3f3f3f3f3f; //4557430888798830399

template <typename T> bool chmin(T &a, T b){return a>b?(a=b,true):false;}
template <typename T> bool chmax(T &a, T b){return a<b?(a=b,true):false;}

// INT
#define GCD(a, b) __gcd(a, b)
template <typename T> T LCM(T a, T b) {return a / GCD(a, b) * b;}
template <typename T> T EXTGCD(T a, T b, T& x, T& y) {
    T d = a;
    if (b != 0) {d=EXTGCD(b,a%b,y,x);y-=(a/b)*x;}
    else x=1,y=0;
    return d;
}
template <typename T> bool is_prime(T a) {
    for(int i=2;i*i<=a;i++)if(a%i==0)return 1;
    return 0;
}

// MOD
ll MOD = 1000000000L + 7L;
#define add(a, b) ((a % MOD) + (b % MOD)) % MOD
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define sub(a, b) ((a % MOD) + MOD - (b % MOD)) % MOD
template <typename T> T mod_inverse(T a, T mod, bool prime){ // if mod is prime, "prime" is true.
    if(prime){
        T tmp=mod-2,now=a,res=1;while(tmp){if(tmp&1)res=mul(res,now);now=mul(now,now);tmp>>=1;}
        return res;
    }else{T x,y;EXTGCD(a,mod,x,y);return (mod+x%mod)%mod;}
}
#define divide(a, b) ((a % MOD) * (mod_inverse(b, MOD, true))) % MOD

//LLの数値をつかう時は最後にLをつける癖をつけよう
//
//  ┏┓┏┓　┓　┏┓
//  ┏┛┃┃　┃　┗┫
//  ┗┛┗┛　┻　┗┛
//
//   謹┃賀┃新┃年┃
//   ━┛━┛━┛━┛
//WWWWWWWWWWWWWWWWWWWWWW

int n, a, b, c;
int bb[11];

int main() {
    aim_cpo; // インタラクティブのときは消すように.
#ifdef LOCAL_DEFINE
    LOCAL_INPUT; // インタラクティブのときは消すように.
//    LOCAL_OUTPUT; // ファイルに出力したいときのみ
    show(MOD);
#endif
    cin >> n >> a >> b >> c;
    bb[n]++;
    bb[a]++;
    bb[b]++;
    bb[c]++;
    if (bb[1] == 1 && bb[9] == 1 && bb[7] == 1 && bb[4] == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
#ifdef  LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s." << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  string S;
  cin >> S;
  const int32_t length = static_cast<int32_t>(S.length());
  vector<bool> lookup(256, true);
  for (int32_t i = 0; i < length; ++i) {
    const char ch = S.c_str()[i];
    lookup[ch] = false;
  }
  bool found = false;
  char result[2];
  result[1] = '\0';
  for (char ch = 'a'; ch <= 'z'; ++ch) {
    if (lookup[ch]) {
      result[0] = ch;
      found = true;
      break;
    }
  }
  if (found) {
    cout << string(result) << endl;
  } else {
    cout << "None" << endl;
  }

  return 0;
}


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

int n,m,ans;
int s[233];
int c[233];
int str[233];

int convert(int x){
        if (x==0)return 1;
        int tmp=0;
        for (;x;x/=10)
                str[++tmp]=x%10;
        std::reverse(str+1,str+1+tmp);
        return tmp;
}

int main (){
        ans=INT_MAX;
        std::cin >> n >> m;
        for (int i=1;i<=m;i++)
                std::cin >> s[i] >> c[i];
        for (int i=0;i<=999;i++)
                if (convert(i)==n){
                        bool ok=true;
                        for (int j=1;j<=m;j++)
                                if (str[s[j]]!=c[j])
                                        ok=false;
                        if (ok)
                                ans=std::min(ans,i);
                }
        if (ans==INT_MAX)
                ans=-1;
        std::cout << ans << '\n';
        return 0;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()

n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    edge[v - 1].append([w, u - 1])
    edge[u - 1].append([w, v - 1])

# O(ElogV)
import heapq
def dijkstra(s):
    # 始点sから各頂点への最短距離
    d = [float('inf')]*n
    d[s] = 0
    # 各頂点が訪問済みかどうか
    used = [False]*n
    used[s] = True
    # 仮の距離を記録するヒープ
    que = []
    for e in edge[s]:
        heapq.heappush(que, e)
    while que:
        minedge = heapq.heappop(que)
        if used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = True
        for e in edge[v]:
            if not used[e[1]]:
                heapq.heappush(que, [e[0] + d[v], e[1]])
    return d

d = dijkstra(0)
ans = [0]*n

for i in range(n):
    if d[i] % 2 == 1:
        ans[i] = 1

for i in ans:
    print(i)

Measured memory_bytes: 49988
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu push_back           
#define pp pop_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const int MOD=1e9+7 ;
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+11;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> ivc;
typedef pair<ll,ll> ipr;
 
int main()
{
    IOS();
   
    int n;
    cin>>n;
    cout<<n*n*n;


    return 0;
  
}

Measured memory_bytes: 256
N = int(input())
count = 0

for i in range(N):
    d_1, d_2 = input().split()
    if d_1 == d_2:
        count += 1
    else:
        count = 0

    if count == 3:
        break
    else:
        pass

if count == 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62252
from collections import defaultdict

n = int(input())
As  = list(map(int, input().split()))
if n == 1:
    print(1)
    exit()

Ss = sorted(As)
cnt = 0
d = defaultdict(int)
As = [False] * (10**6+10)

for s in Ss:
    d[s] += 1

for s in Ss:
    if As[s]:continue
    else:
        if d[s] == 1:
            cnt += 1
        ind = 1
        while s * ind <= 10**6:
            As[s*ind] = True
            ind += 1

print(cnt)


Measured memory_bytes: 122616
#include<stdio.h>

int main (){
	int K,A,B;
	int sum=0;
	scanf("%d",&K);
	scanf("%d %d", &A,&B );
for (int i=A ; i<=B ; i++ ){
	if (i%K==0){
	printf("OK\n");
	return 0;
} 
else {
	continue;
}
}
	puts("NG\n");
	return 0;
}


Measured memory_bytes: 1620
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

int main () {
    
    int a, b; cin >> a >> b;

    int res = a + b;
    res = max(res, a - b);
    res = max(res, a * b);

    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define max(x, y) ((x)<(y) ? (y) : (x))

int main(){
  int n, m;  scanf("%d %d", &n, &m);
  int **graph, *to, *ans, *table, anslen = 0;
  graph = (int**)malloc(sizeof(int*)*(n+3));
  to    = (int*) malloc(sizeof(int) *(n+3));
  ans   = (int*) malloc(sizeof(int) *(n+3));
  table = (int*) malloc(sizeof(int) *(n+3));
  for(int i=0; i<n+3; i++)
    graph[i] = (int*)malloc(sizeof(int)*(n+3));

  while(m--){
    int x, y;  scanf("%d %d", &x, &y);
    graph[x][++graph[x][0]] = y;
    to[y]++;
  }
    
  int queue[100005] = {0}, front = 0, rear = 0;
  for(int i=1; i<=n; i++)  
    if(!to[i])  queue[rear++] = i;
  
  while(front != rear){
    int now = queue[front];  front = (front + 1) % 100005;
    ans[anslen++] = now;
    for(int i=1; i<=graph[now][0]; i++)
      if(--to[graph[now][i]] == 0)
	queue[rear] = graph[now][i],  rear = (rear + 1) % 100005;
  }

  int r = 0;
  for(int i=0; i<anslen; i++)
    for(int j=1; j<=graph[ans[i]][0]; j++){
      table[graph[ans[i]][j]] = max(table[graph[ans[i]][j]], table[ans[i]]+1);
      r = max(r, table[graph[ans[i]][j]]);
    }
  
  printf("%d\n", r);

  free(graph);
  free(to);
  free(ans);
  return 0;
}


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

int selection_sort(vector<int>& a,int N) {
  int cnt = 0;
  int flag = 1;
  for(int i=0;i<N;i++) {
    int minj = i;
    for(int j=i;j<N;j++) {
      if(a[j] < a[minj]) {
        minj = j;
      }
    }
    if(minj != i) {
      swap(a[minj],a[i]);
      cnt++;
    }
  }
  return cnt;
}

int main(void) {
  int N;
  vector<int> a;

  /* input */
  cin >> N;
  for(int i=0;i<N;i++) {
    int _t;
    cin >> _t;
    a.push_back(_t);
  }

  int cnt = selection_sort(a,N);
  for(int i=0;i<N;i++) {
    cout << a[i] << (i+1==N ? "" : " ");
  }
  cout << endl;
  cout << cnt << endl;
}

Measured memory_bytes: 1220
N = int(input())
S = input()
Q = int(input())
qs = [input().split() for i in range(Q)]

def ctoi(c):
    return ord(c) - ord('a')

class BinaryIndexedTree:
    def __init__(self,size):
        self.N = size
        self.bit = [0]*(size+1)
    def add(self,x,w): # 0-indexed
        x += 1
        while x <= self.N:
            self.bit[x] += w
            x += (x & -x)
    def _sum(self,x): # 1-indexed
        ret = 0
        while x > 0:
            ret += self.bit[x]
            x -= (x & -x)
        return ret
    def sum(self,l,r): # [l,r)
        return self._sum(r) - self._sum(l)
    def __str__(self): # for debug
        arr = [self.sum(i,i+1) for i in range(self.N)]
        return str(arr)
bits = [BinaryIndexedTree(N) for i in range(26)]

s = []
for i,c in enumerate(S):
    bits[ctoi(c)].add(i,1)
    s.append(c)

ans = []
for a,b,c in qs:
    if a=='1':
        i = int(b)-1
        bits[ctoi(s[i])].add(i,-1)
        bits[ctoi(c)].add(i,1)
        s[i] = c
    else:
        l,r = int(b)-1,int(c)
        a = 0
        for i in range(26):
            if bits[i].sum(l,r):
                a += 1
        ans.append(a)
print(*ans,sep='\n')

Measured memory_bytes: 170976
N = int(input())
A = list(map(int, input().split()))
K = []

for i in A:
    if i%2 == 0:
       K.append(i)

for m in K:
    if not (m%3 == 0 or m%5 == 0):
        print('DENIED')
        exit()

print('APPROVED')

Measured memory_bytes: 3060
while 1:
    n = int(input())
    if n == 0:
        break
    l = [list(map(int,input().split())) for i in range(n)]
    for i in range(n):
        if l[i][0] == 100 or l[i][1] == 100 or l[i][2] == 100:
            print("A")
        elif l[i][0] + l[i][1] >= 180:
            print("A")
        elif l[i][0] + l[i][1] + l[i][2] >= 240:
            print("A")
        elif l[i][0] + l[i][1] + l[i][2] >= 210:
            print("B")
        elif l[i][0] + l[i][1] + l[i][2] >= 150 and (l[i][0] >=80 or l[i][1] >=80) :
            print("B")
        else:
            print("C")


Measured memory_bytes: 5628