akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	fmt.Println((n + 1) / 2)
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include <algorithm>
using namespace std;

int main()
{
	int x, y;
	cin >> x >> y;
	if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12)
	{
		if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)
		{
			cout << "Yes";
		}
		else
		{
			cout << "No";
		}
	}
	else if (x == 4 || x == 6 || x == 9 || x == 11)
	{
		if (y == 4 || y == 6 || y == 9 || y == 11)
		{
			cout << "Yes";
		}
		else
		{
			cout << "No";
		}
	}
	else if (x == 2)
	{
		if (y == 2)
		{
			cout << "Yes";
		}
		else
		{
			cout << "No";
		}
	}
}

Measured memory_bytes: 256
N,Y = gets.split.map(&:to_i)

i, j, k = -1, -1, -1

(0..N).each do |n|
  (0..N - n).each do |h|
      sum = 10000*n + 5000*h + 1000*(N - n - h)
      i, j, k = n, h, N - n - h if Y == sum
      break if Y == sum
  end
end

puts "#{i} #{j} #{k}"

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  int a[3]={};
  int x;
  cin >> n;
  rep(i,n){
    cin >> x;
    a[x%3]++;
  }
  if(a[0]==n) cout << 1 << endl;
  else{
    int res=0;
    int count=0;
    if(a[1]>a[2]) count=1;
    else count=2;
    a[count]--;
    while(1){
      res++;
      if(count==0) break;
      if(count==1){
        if(a[1] > 0){
        a[1]--;
        count = 2;
        } else if(a[0] > 0){
          a[0]--;
          count = 1;
        }
        else {
          count=0;
          if(a[2] == 0) break;
        }
      } else {
        if(a[2] > 0){
          a[2]--;
          count=1;
        } else if(a[0] > 0){
          a[0]--;
          count=2;
        } else {
          count=0;
          if(a[1]==0) break;
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}



Measured memory_bytes: 3088
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]

ans = Counter(S[0])
for i in range(1,n):
  tmp = Counter(S[i])
  for a in ans.keys():
    if a in tmp:
      ans[a] = min(ans[a],tmp[a])
    else:
      ans[a] = 0
x = ''
for a in ans.items():
  x += a[0]*a[1]
print(''.join(sorted(x)))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define getcx getchar_unlocked
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define MAX 100005
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

int main() {

	string s, t;
	int i, j, k, ls, lt, cnt = 0, ans = INT_MAX;

	cin>>s>>t;
	ls = s.length();
	lt = t.length();

	for(i = 0; i <= (ls-lt); i++) {

		cnt = 0;
		int idx = i;
		for(j = 0; j < lt; j++, idx++) {

			if(s[idx] != t[j]) cnt++;
		}

		ans = min(ans, cnt);
	}

	cout<<ans<<en;
	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cmath>
#include<vector>
#include<climits>
#include<algorithm>
#include<numeric>
#include<iomanip>
#include<map>
#include<set>
#include<random>
#include<cassert>
using namespace std;
#define ll long long int
#define ld long double
const ll Mod = 1000000007;
ll CaseN=1;
const ld PI = 22/7.0;

bool mycmp(string s,string t)
{
if(s.size()<t.size())
{
return true;	
}		
return false;
}

string generate_bstring(ll n)
{
string str;
for(ll i=0;i<n;i++)
{
ll a = rand()%2;
if(a==0)
str += '0';
else
str += '1';
}
	
return str;	
}



ll Test()
{
    ll ans = 0;
  
    return ans;
}

void solve()
{
	char c;
	cin>>c;
	if((ll)c >= (ll)'a' && (ll)c <=(ll)'z')
	{
	cout<<"a";	
	}
	else
	{
	cout<<"A";	
	}
	
   // cout<<"Case #"<<CaseN<<": ";
   CaseN++;
	// print your ans below;
    
return ;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	solve();
	}
}


Measured memory_bytes: 3640
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;

LL a,b,c,d,e;

LL Gcd(LL x,LL y) {
	if(y==0) return x;
	return Gcd(y,x%y);
}
int main() {
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	a--; e=c*d/Gcd(c,d);
	printf("%lld\n",b-a-((b/c-a/c)+(b/d-a/d)-(b/e-a/e)));
	return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    vector<int> a(26);
    vector<int> b(26);
    for (int i = 0; i < s.size(); i++) {
        a.at(s.at(i) - 'a')++;
    }
    for (int i = 0; i < t.size(); i++) {
        b.at(t.at(i) - 'a')++;
    }
    string anss, anst;
    for (int i = 0; i < 26; i++) {
        if (a.at(i) != 0) {
            for (int j = 0; j < a.at(i); j++) {
                anss += (char)('a' + i);
            }
        }
    }
    for (int i = 25; i >= 0; i--) {
        if (b.at(i) != 0) {
            for (int j = 0; j < b.at(i); j++) {
                anst += (char)('a' + i);
            }
        }
    }
    if (anss < anst) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
ab = [list(map(int, input().split())) for i in range(N)]
ab_sort = sorted(ab, key=lambda x: x[1])
#print(ab)
#print(ab_sort)

now = 0
for work in ab_sort:
    if now + work[0] <= work[1]:
        now += work[0]
    else:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 55176
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int ddx[6]={0,1,0,-1,1,-1},ddy[6]={-1,0,1,0,1,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,m,l,k,a,h;
vector<Pi> road[110];
int cold[110];
int condition[110][110];

struct sit{
	int town;
	int time_limit;
	int take_time;
};
sit construct_sit(int _town,int _time_limit,int _take_time){
	sit s;
	s.town=_town;
	s.time_limit=_time_limit;
	s.take_time=_take_time;
	return s;
}
queue<sit> qq;
int ans=1e8;
int main(){
	while(1){
		cin>>n>>m>>l>>k>>a>>h;
		ans=1e8;
		if(n==0&&m==0&&l==0&&k==0&&a==0&&h==0)break;
		REP(i,110){
			cold[i]=0;
			road[i].clear();
		}
		while(qq.size())qq.pop();
		
		REP(i,l){
			int t;
			cin>>t;
			cold[t]=1;
		}
		REP(i,k){
			int x,y,z;
			cin>>x>>y>>z;
			road[x].push_back(Pi(y,z));
			road[y].push_back(Pi(x,z));
		}
		qq.push(construct_sit(a,m,0));
		REP(i,110)
			REP(j,110)
			condition[i][j]=1e8;
		condition[a][m]=0;
		while(qq.size()){
			sit s1=qq.front();qq.pop();
			//cout<<s1.town<<" "<<s1.time_limit<<" "<<s1.take_time<<endl;
			if(s1.town==h){
				ans=min(ans,s1.take_time);
				continue;
			}
			REP(i,road[s1.town].size()){
				int next_town=road[s1.town][i].first;
				int now_take_time=road[s1.town][i].second;
				if(s1.time_limit<now_take_time)continue;
				if(condition[next_town][s1.time_limit-now_take_time]>s1.take_time+now_take_time){
					qq.push(construct_sit(next_town,s1.time_limit-now_take_time,s1.take_time+now_take_time));
					condition[next_town][s1.time_limit-now_take_time]=s1.take_time+now_take_time;
				}
				if(cold[next_town]){
					for(int j=1;j+s1.time_limit-now_take_time<=m;j++){
						if(condition[next_town][s1.time_limit-now_take_time+j]>s1.take_time+now_take_time+j){
						qq.push(construct_sit(next_town,s1.time_limit-now_take_time+j,s1.take_time+now_take_time+j));
						condition[next_town][s1.time_limit-now_take_time+j]=s1.take_time+now_take_time+j;
						}
					}
				}
			}
		}
		if(ans==1e8)cout<<"Help!"<<endl;
		else cout<<ans<<endl;
	}
	return 0;
}
					


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

int main() {
  int N, A, B;
  int X;
  cin >> N >> A >> B;
  
  X = N * A;
  
  if (X >= B) {
    cout << B << endl;
  } else {
    cout << X << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

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

int N,U,V,M;
int u[512][512], n[512][512];
map<int, int>mu,mn;
int dy[]={-1,1,-1,1,-1,1,0,0}, dx[]={-1,1,0,0,1,-1,1,-1};

int countLine(int y, int x, int a[512][512]){
  int res = 0, f;
  f = 1;
  rep(i,N) f &= (a[y][i]==0);
  res += f;
  f = 1;
  rep(i,N) f &= (a[i][x]==0);
  res += f;
  if(y==x){
    f = 1;
    rep(i,N) f &= (a[i][i]==0);
    res += f;
  }
  if(y==N-x-1){
    f = 1;
    rep(i,N) f &= (a[i][N-i-1]==0);
    res += f;
  }
  if(res>0 && N==1)  res = 1;
  return res;
}

int main(){
  int x[100005];
  scanf("%d%d%d%d",&N,&U,&V,&M);
  rep(i,N) rep(j,N){
    scanf("%d", &u[i][j]);
    mu[u[i][j]] = i*N+j;
  }
  rep(i,N) rep(j,N){
    scanf("%d", &n[i][j]);
    mn[n[i][j]] = i*N+j;
  }
  rep(i,M) scanf("%d", x+i);
  int ru = 0, rn = 0;
  rep(i,M){
    if(mu.find(x[i]) != mu.end()){
      int pos = mu[x[i]];
      u[pos/N][pos%N] = 0;
      ru += countLine(pos/N, pos%N, u);
    }

    if(mn.find(x[i]) != mn.end()){
      int pos = mn[x[i]];
      n[pos/N][pos%N] = 0;
      rn += countLine(pos/N, pos%N, n);
    }
//    cout << ru << " " << rn << endl;
    if(ru >= U && rn >= V){
      puts("DRAW"); return 0;
    }else if(ru >= U){
      puts("USAGI"); return 0;
    }else if(rn >= V){
      puts("NEKO"); return 0;
    }
  }
  puts("DRAW");
  return 0;
}

Measured memory_bytes: 16312
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt()*100;
    int g = sc.nextInt()*10;
    int b = sc.nextInt()*1;
    int all = r + g + b;
    if(all % 4 == 0){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


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

int main(){
    ll N,i;
    ll result=0;
    string S;
    cin>>N;
    for(i=1;i<=N;i++){
        S=to_string(i);
        if(S.size()%2==1)result+=1;
    }
    cout<<result<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define memset(x,y) memset(x,y,sizeof(x))
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
using namespace std;
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("text1.in","r",stdin);
	//freopen("text1.out","w",stdout);
	double r;
	cin>>r;
	cout<<PI*2*r<<endl; 
	return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int v[3];
    cin >> v[0] >> v[1] >> v[2];
    sort(v, v+3);
    int ans = v[2]-v[1];
    int d = v[2]-v[0]-ans;
    ans += d/2 + 2*(d&1);
    cout << ans << endl;
}


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

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

  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int ans = 1;
  bool u = false, d = false;
  rep(i, n - 1) {
    if (a[i] == a[i + 1])
      continue;
    if (a[i] < a[i + 1]) {
      if (!u && !d)
        u = true;
      if (u)
        continue;
    }
    if (a[i] > a[i + 1]) {
      if (!u && !d)
        d = true;
      if (d)
        continue;
    }
    ++ans;
    u = d = false;
  }

  cout << ans << endl;
}

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

using namespace std;

map <int, int>memo;

int collaz (int x) {
    if (x%2==0) {
        return x/2;
    }
    return (x*3)+1;
}

int main () {
    int n,i=1;
    cin >> n;
    while (memo[n]==0) {
        memo[n] = i++;
        n=collaz(n);
    }
    cout << i;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

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

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;cin>>a>>b;
    cout<<(ll)a*b;
    return 0;
}


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

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

	int N, K;
	cin >> N >> K;
	int x[100];
	int sum = 0;
	for (int i = 0; i < N; i++){
		cin >> x[i];
		sum += min(x[i], K - x[i]);
	}
	cout << 2*sum;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a,b;
  cin >> a >> b;
  int max =0;
  for(int i = 0;i<2;i++){
    if(a>b){
  	max += a;
    --a;
  }else{
  	max += b;
    --b;
  }
  }
  cout << max << endl;
 return 0; 
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))

x_sorted = sorted(x)
length = len(x) - 1
center_min = x_sorted[(length - 1) // 2]
center_max = x_sorted[(length + 1) // 2]
for elem in x:
    if elem <= center_min:
        print(center_max)
    else:
        print(center_min)

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << '\n';
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' '

int main() {
    int a; cin >> a;
    int b; cin >> b;
    if (a >= 13) PRINT(b)
    else if (a >= 6) PRINT((int)b/2)
    else PRINT(0)

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int T,k,n,a,b,c,d;
int main(){
    scanf("%d",&T);
    while(T--){
        scanf("%d%d%d%d",&a,&b,&c,&d);n=a+b;
        int l=0,r=n+1,mid,A,B;k=(max(a,b)-1)/(min(a,b)+1)+1;;
        while(l<r){
            mid=(l+r)>>1;
            A=a-mid/(k+1)*k-mid%(k+1);B=b-mid/(k+1);
            if(B<=1ll*A*k)l=mid+1;else r=mid;
        }
        A=a-l/(k+1)*k-l%(k+1);B=b-l/(k+1);r=l+B-A*k+1;
        for(int i=c;i<=min(d,l);i++)putchar(i%(k+1)?'A':'B');
        for(int i=max(c,l+1);i<=d;i++)putchar((i-r)%(k+1)?'B':'A');
        puts("");
    }
    return 0;
}//ONION_CYC QwQ

Measured memory_bytes: 256
#include <stdlib.h>
#include <assert.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <complex>
#include <iomanip>
#include <bitset>
#include <random>
#include <vector>
#include<string>

using namespace std;

int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a <= k)
		cout << "Yay!" << endl;
	else
		cout << ":(" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define forn(i, a, b) for (int i = a; i < b; ++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}

int main() {
#ifdef LOCAL
  freopen("g.txt", "r", stdin);
// freopen("main.txt", "w", stdout);
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
  ios::sync_with_stdio(0);
  cin.tie(0);
#define endl '\n'
#define dbg(...) 18
#endif
  bool y = false;
  char c;
  int n;
  cin >> n;
  while (n--) {
    cin >> c;
    y = y || (c == 'Y');
  }
  if (y)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)

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

   if(n<b){ cout<<a*n/b<<endl;}
else{cout<<a*(b-1)/b<<endl;}
}

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double


int main(){
  int n, k; // 2 <= N <= 2e5
  cin >> n >> k; // 1 <= k <= n-1
  vector<ll> ai(n, 0); // 1 <= ai <= 1e9
  rep(i, n) {
    cin >> ai[i];
  }

  int mulnum = 0;
  rep(i, n) {
    if (mulnum < k) {
      ++mulnum;
    } else {
      if (ai[i-k] < ai[i]) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4804
function main(input) {
  const inputs =input.split('\n')
  const [N] = inputs[0].split(' ')
  if (N % 1000 === 0) {
    console.log(0)
  } else {
    console.log(
      (1000 - (N % 1000))
    )
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 29688
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
vvi dis;
vi dx = {1,0,-1,0};
vi dy = {0,1,0,-1};
int h,w;
bool inrange(int y,int x){
  return 0<=x&&x<w&&0<=y&&y<h;
}
int solve(int y,int x,vvb &used){
  if(dis[y][x]!=-1) return dis[y][x];
  int mn = INT_MAX;
  used[y][x] = true;
  REP(i,4){
    int ny = y+dy[i];
    int nx = x+dx[i];
    if(inrange(ny,nx)&&!used[ny][nx]) mn = min(mn,solve(ny,nx,used)+1);
  }
  return dis[y][x] = mn;
}
signed main(){
  cin >> h >> w;
  dis.assign(h,vi(w,-1));
  vvi mp(h,vi(w,0));
  stack<pii> st;
  int ct = h*w;
  REP(i,h)REP(j,w){
    char c;
    cin >> c;
    if(c=='#') mp[i][j] = 1,st.push(make_pair(i,j)),ct--;
  }
  stack<pii> nst;
  int ans = 0;
  while(ct){
    while(!st.empty()){
      pii p = st.top();
      st.pop();
      REP(i,4){
        int ny = p.first+dy[i];
        int nx = p.second+dx[i];
        if(!inrange(ny,nx)) continue;
        if(!mp[ny][nx]){
          ct--;
          nst.push(make_pair(ny,nx));
          mp[ny][nx] = 1;
        }
      }
    }
    swap(st,nst);
    ++ans;
  }
  cout << ans << endl;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  int res = n;
  for (int i = 0; i <= n; i++) {
    int cnt = 0;
    int x = i;
    while (x) {
      cnt += x % 6;
      x /= 6;
    }
    x = n - i;
    while (x) {
      cnt += x % 9;
      x /= 9;
    }
    res = min(res, cnt);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll a[100001] = {};
ll p = 0;
int main() {
	rep(i, 2, 1500) {
		bool pr = true;
		rep(j, 2, i) {
			if (!(i % j)) {
				pr = false;
				break;
			}
		}
		if (pr && i % 10 == 1)a[p++] = i;
		if (p == 55)break;
	}

	ll n; cin >> n;
	rep(i, 0, n) {
		cout << a[i];
		if (i != n - 1)cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N;
int A[100003];
unordered_map<int, int> M;

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

  cin >> N;
  int a;
  rep(i, N){
    cin >> a;
    M[a]++;
  }
  int ans=0;
  for (auto it=M.begin(); it !=M.end(); ++it){
    int cnt = it->second;
    if (cnt%2) ans++;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 4388
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<cstdlib>
using namespace std;

int main() {
  int a,b,c,d,ans;
  cin >> a >> b >> c >> d;
  for(int i = 0; i < a; i++) {
    if(i < b) {
      ans += c;
    }else {
      ans += d;
    }
  }
  cout << ans << endl;
}


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

#define INF 1000000000L
#define MAX(a, b) ((a) > (b) ? (a) : (b))

using namespace std;

int main(void) {
    int min_index = 0, N;
    long long tmp, max = -INF;
    vector<long long> R;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        R.push_back(tmp);
    }
    for (int i = 1; i < N; i++) {
        max = MAX(R[i] - R[min_index], max);
        if (R[i] < R[min_index]) min_index = i;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,x;
    cin >> a >> b >> x;
    int sum;
    sum = a+b;
    if(x>=a && x<=sum){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}




Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n=1 ,i ,j=0 ,weight ,cnt[10]={0} ,fact[10];
  fact[0] = n;
  
    for( i=1 ; i<10 ; i++ ){   //　10までの階乗を用意
    n = n * 2;
    fact[i] = n;
  }

  while( scanf( "%d" ,&weight ) != EOF ){
    
    if( weight == 0 ){
      printf( "0" );
    }

    else{
      for( i=9 ; i>=0 ; i-- ){    // 階乗の大きいほうから引く
	if( weight >= fact[i] ){
	  weight = weight - fact[i];
	  cnt[i] = 1;             // 引けたら印を付ける
	}
      }
      
      for( i=0 ; i<10 ; i++){    //　引くことのできた階乗を出力
	
	if( cnt[i] == 1 ){
	  if( j >= 1 ){
	    printf( " " );
	  }
	  printf( "%d" ,fact[i] );
	  j++;
	}
      }
    }
    
    printf( "\n" );
    j=0;
    for( i=0 ; i<10 ; i++ ){
      cnt[i] = 0;
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
int selectionSort(int A[], int N)
{
int i, j, t, sw = 0, minj;
for(i=0;i<N-1;i++){
 minj = i;
 for(j=i;j<N;j++){
  if(A[j]<A[minj])
  minj=j;
  }
  t = A[i];
  A[i] = A[minj];
  A[minj] = t;
  if(i!=minj)
  sw++; 
}
return sw;
}


int main(void)
{
int i, N, A[100], sw;

scanf("%d", &N);
for(i=0;i<N;i++)
scanf("%d", &A[i]);

sw = selectionSort(A, N);

for(i=0;i<N;i++){
if(i>0)
printf(" ");
printf("%d", A[i]);
}
printf("\n");
printf("%d\n", sw);

return 0;
}

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

int main() {
  int N,L;
  cin >> N >>L;
  vector<string> strr(N);
  for(int i=0; i<N; i++)
    cin >> strr.at(i);
  sort(strr.begin(), strr.end());
  for(int i=0; i<N; i++)
    cout << strr.at(i); 
  
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

int main(){
	string s;
	cin >> s;
	int sum=0;
	for(int i=0;i<s.size();i++){
		sum+=(s[i]-'0');
	}
	if(sum%9==0)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3744
code_a = Hash[
*%w(
'	000000
,	000011
-	10010001
.	010001
?	000001
A	100101
B	10011010
C	0101
D	0001
E	110
F	01001
G	10011011
H	010000
I	0111
J	10011000
K	0110
L	00100
M	10011001
N	10011110
O	00101
P	111
Q	10011111
R	1000
S	00110
T	00111
U	10011100
V	10011101
W	000010
X	10010010
Y	10010011
Z	10010000
)]
code_a[' '] = '101'

code_b = Hash[*%w(
11011	.
11100	,
11101	-
11110	'
11111	?
)] 
(?A..?Z).each{|c|
	code_b["%05b" % (c.ord - ?A.ord)] = c
}
code_b['11010'] = " "

while gets
	puts $_
	.chomp
	.each_char
	.map{|c| code_a[c]}
	.join
	.scan(/.{1,5}/)
	.map{|s| code_b[s + ?0 * (5 - s.size)]}
	.join
end

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

int main()
{
	int first,second,third;
	int a[10];
	for(int i = 0; i < 10; i++){
		cin >> a[i];
	}
	sort(a,a+10);
	first = a[9];
	second = a[8];
	third = a[7];
	
	cout << first << endl;
	cout << second << endl;
	cout << third << endl;

	return 0;
}

Measured memory_bytes: 1176
using System;

public class hello
{
    public static void Main()
    {
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            string[] s = line.Trim().Split(' ');
            string[] s2 = Console.ReadLine().Trim().Split(' ');
            var hit = 0;
            var hitblow = 0;
            for (int i = 0; i < 4; i++)
            {
                if (s[i] == s2[i]) hit++;
                for (int j = 0; j < 4; j++)
                    if (s2[i] == s[j]) hitblow++;
            }
            Console.WriteLine("{0} {1}", hit, hitblow-hit);
        }
    }
}

Measured memory_bytes: 8972
#include <bits/stdc++.h>
using namespace std;
const int N = 1234567;
vector <pair<int,int> > G[N] ;
vector <int> newg[N];
queue <int> q ;
int f[N],son[N],id[N],dp[N],n,m ;
bool use[N];
inline void init(int i){
    f[i]=i;son[i]=0;id[i]=-1;use[i]=false ;
}
int find(int x){
    return (x==f[x])?x:f[x]=find(f[x]) ; 
}
inline void merge(int x,int y){
    int X=find(x),Y=find(y) ;
    if (X==Y) return ;
    if (son[X]<son[Y]) f[X]=Y ;
    else {
        f[Y]=X ;
        if (son[X]==son[Y]) son[X]++ ;
    }
} 
inline int read(){
    char c;int f=1 ;
    while ((c=getchar())<'0' || c>'9') if (c=='-') f=-1 ;
    int res=c-'0' ;
    while ((c=getchar())>='0' && c<='9') res=res*10+c-'0' ;
    return res*f ; 
}
int main(){
    n=read();m=read() ;
    for (int i=1;i<=m;i++){
        int a,b,c ;
        a=read();b=read();c=read() ;
        G[c].push_back(make_pair(a,b)) ;
    }
    int cnt=n; 
    for (int i=1;i<=N;i++){
        if (G[i].empty()) continue;
        for (int j=0;j<G[i].size();j++){
            init(G[i][j].first) ;
            init(G[i][j].second) ;
        }
        for (int j=0;j<G[i].size();j++) merge(G[i][j].first,G[i][j].second) ;
        for (int j=0;j<G[i].size();j++){
            if (!use[G[i][j].first]){
                use[G[i][j].first]=true ;
                int X=find(G[i][j].first) ;
                if (id[X]==-1) id[X]=++cnt ;
                newg[G[i][j].first].push_back(id[X]) ;
                newg[id[X]].push_back(G[i][j].first) ;
            }
            if (!use[G[i][j].second]){
                use[G[i][j].second]=true ;
                int X=find(G[i][j].second) ;
                if (id[X]==-1) id[X]=++cnt ;
                newg[G[i][j].second].push_back(id[X]) ;
                newg[id[X]].push_back(G[i][j].second) ;
            }
        }
    }
    q.push(1) ;
    memset(dp,-1,sizeof(dp)) ;
    dp[1]=0;
    while(!q.empty()){
        int v=q.front();q.pop() ;
        for (int i=0;i<newg[v].size();i++){
            int to=newg[v][i] ;
            if (dp[to]==-1){
                dp[to]=dp[v]+1 ;
                q.push(to) ;
            }
        }
    }
    if (dp[n]==-1) cout<<-1 ;
    else cout<<dp[n]/2 ;
    return 0;
}

Measured memory_bytes: 85376
import java.io.*;

public class Main {
  public static void main(String[] args) {
    try {
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      int count = Integer.parseInt(in.readLine());
      String[] inArr = in.readLine().split(" ");
      String[] bArr = Sort.bubbleSort(inArr);
      String[] sArr = Sort.selectionSort(inArr);
      StringBuilder bubbleSb = new StringBuilder();
      for(String str : bArr) { bubbleSb.append(str).append(" "); }
      StringBuilder selectSb = new StringBuilder();
      for(String str : sArr) { selectSb.append(str).append(" "); }
      System.out.println(bubbleSb.toString().trim());
      System.out.println("Stable");
      System.out.println(selectSb.toString().trim());
      if(Sort.isStable(inArr, sArr)) {
        System.out.println("Stable");
      } else {
        System.out.println("Not stable");
      }
    } catch(IOException e) {
    }
  }
}

class Sort {
  public static String[] bubbleSort(String[] arr) {
    String[] bArr = arr.clone();
    for(int i=0; i<bArr.length; i++) {
      for(int j=bArr.length-1; j>i; j--) {
        if(Sort.compCard(bArr[j], bArr[j-1]) == 2) {
          String tmp = bArr[j];
          bArr[j] = bArr[j-1];
          bArr[j-1] = tmp;
        }
      }
    }
    return bArr;
  }

  public static String[] selectionSort(String[] arr) {
    String[] sArr = arr.clone();
    for(int i=0; i<sArr.length; i++) {
      int minj = i;
      for(int j=i; j<sArr.length; j++) {
        if(Sort.compCard(sArr[minj], sArr[j]) == 1) { minj = j; }
      }
      if(i != minj) {
        String tmp = sArr[i];
        sArr[i] = sArr[minj];
        sArr[minj] = tmp;
      }
    }
    return sArr;
  }

  public static int compCard(String str1, String str2) {
    int i = Integer.parseInt(str1.substring(1));
    int j = Integer.parseInt(str2.substring(1));
    if(i > j) {
      return 1;
    } else if(i == j) {
      return 0;
    } else {
      return 2;
    }
  }

  public static boolean isStable(String[] in, String[] out) {
    int cnt = in.length;
    for(int i=0; i<cnt; i++) {
      for(int j=i+1; j<cnt; j++) {
        if(Sort.compCard(in[i], in[j])==0) {
          for(int k=0; k<cnt; k++) {
            for(int l=k+1; l<cnt; l++) {
              if(out[k].equals(in[j]) && out[l].equals(in[i])) {
                return false;
              }
            }
          }
        }
      }
    }
    return true;  
  }
}

Measured memory_bytes: 25212
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e16;
const int N = 2e5 + 5;

gp_hash_table <LL,LL> dp[ N ];
int n;
LL a[ N ];

LL solve(int idx, int taken) {
  int need = n/2 - (n - idx + 1)/2;
  if (taken < need) return -INF;
  if (idx >= n) return taken == n/2 ? 0 : -INF;
  if (dp[idx][taken]) return dp[idx][taken];
  LL ret = -INF;
  ret = max(ret, solve(idx + 2, taken + 1) + a[idx]);
  ret = max(ret, solve(idx + 1, taken));
  return dp[idx][taken] = ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif // LOCAL
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  cout << solve(0, 0) << endl;
  return 0;
}


Measured memory_bytes: 73976
#include <stdio.h>
#include <string.h>
    
#define Max 500000
    
void insert(int); 
void find(int, int);
int successor(int);
void delete(int);
void Preorder(int);  
void Inorder(int);  
    
    
typedef struct{
  int key;
  int p;
  int h[2];
} Node;
    
Node D[Max];
    
int main(){
  int i, n, v;
  char s[7];
    
  scanf("%d", &n);
    
  D[0].key = -1;
    
     
  for(i = 0; i < n; i++){
    D[i].h[0] = -1;
    D[i].h[1] = -1;
    
    scanf("%s", s);
    
    if(strcmp(s, "insert") == 0){
      scanf("%d", &D[i].key);
      insert(i);
    }
    else if(strcmp(s, "print") == 0){
      Inorder(0);
      printf("\n");
      Preorder(0);
      printf("\n");
    }
    else if(strcmp(s, "find") == 0){
      scanf("%d", &v);
      find(0, v);
    }
    else if(strcmp(s, "delete") == 0){
      scanf("%d", &v);
      delete(v);
    }
  }
      
  return 0;
}
    
    
void insert(int z){
  int x, y;
    
  y = -1;
  x = 0;
    
  if(z != 0){
    while(x != -1){
      y = x;
      if(D[z].key < D[x].key) x = D[x].h[0];
      else x = D[x].h[1];
    }
  }
    
  D[z].p = y;
    
  if(y != -1){
    if(D[z].key < D[y].key) D[y].h[0] = z;
    else D[y].h[1] = z;
  }
}
    
void find(int x, int k){
    
  if(x == -1) printf("no\n");
  else if(D[x].key == k) printf("yes\n");
  else if(k < D[x].key) find(D[x].h[0], k);
  else find(D[x].h[1], k);
}
    
int successor(int x){
  int y;
    
  if(D[x].h[1] != -1){
    x = D[x].h[1];
    while(D[x].h[0] != -1) x = D[x].h[0];
    return x;
  }
      
  else {
    y = D[x].p;
    while(y != -1 && x == D[y].h[1]){
      x = y;
      y = D[y].p;
    }
    return y;
  }
}
    
void delete(k){
  int x, y, z = 0;
    
  while(1){
    if(D[z].key == k) break;
    else if(k < D[z].key) z = D[z].h[0];
    else z = D[z].h[1];
  }
    
  if(D[z].h[0] == -1 || D[z].h[1] == -1) y = z;
  else y = successor(z);
    
  if(D[y].h[0] != -1) x = D[y].h[0];
  else x = D[y].h[1];
    
  if(x != -1) D[x].p = D[y].p;
    
  if(D[y].p != -1){
    if(y == D[D[y].p].h[0]) D[D[y].p].h[0] = x;
    else D[D[y].p].h[1] = x;
  }
    
  if(y !=  z) D[z].key = D[y].key;
    
}
    
    
void Preorder(int a){
  printf(" %d", D[a].key);
    
  if(D[a].h[0] != -1) Preorder(D[a].h[0]);
  if(D[a].h[1] != -1) Preorder(D[a].h[1]);
}
    
    
void Inorder(int a){
  if(D[a].h[0] == -1){
    printf(" %d", D[a].key);
    if(D[a].h[1] != -1) Inorder(D[a].h[1]);
  }
  else{
    Inorder(D[a].h[0]);
    printf(" %d", D[a].key);
    if(D[a].h[1] != -1) Inorder(D[a].h[1]);
  }
}



Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define all(x) x.begin(), x.end()
using ll = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    if(2*k-1>n) cout<<"-1\n";
    else {
        ll a = n/2, b=2*n-a;
        vector<tuple<ll,ll,ll>> x;
        auto app = [&](ll u, ll v) { x.emplace_back(u+v,u,v); };
        rep(i,0,a) app(k+i,k+b+i);
        rep(i,0,n-a) app(k+a+i,k+n+i);
        sort(all(x));
        rep(i,0,n) {
            ll w,u,v=k+2*n+i;
            tie(ignore,w,u) = x[i];
            cout<<w<<" "<<u<<" "<<v<<endl;
        }
    }
}


Measured memory_bytes: 5232
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }

int a,b,c,n;

int solve() {
	int ret=0;
	for(int i=0;i*a<=n;++i) for(int j=0;i*a+j*b<=n;++j) { int rem=n-i*a-j*b; if(rem%c==0) ++ret; }
	return ret;
}

void run() {
	scanf("%d%d%d%d",&a,&b,&c,&n);
	printf("%d\n",solve());
}

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader tec = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		for (String line; (line = tec.readLine()) != null;) {
			int n=Integer.parseInt(line.trim());
			int[]arr=new int[n];
			HashMap<Integer, Boolean>bool=new HashMap<>();
			for (int i = 0; i < n; i++){ 
				arr[i]=Integer.parseInt(tec.readLine().trim());
				bool.put(arr[i], (i&1)==1);
			}
			Arrays.sort(arr);
			int cont=0;			
			for (int i = 0; i < arr.length; i++) {
				if((i&1)==0==bool.get(arr[i])){
					cont++;
				}
			}
			out.println(cont>>1);
		}
		out.close();
	}
}

Measured memory_bytes: 46640
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N=input()
print(a[int(N)-1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll N, X, M;
	cin >> N >> X >> M;
	vector<int> hoge(M);
	vector<ll> sum = {0};
	ll x = X;
	int s, t;
	for (int i = 1; ; ++ i) {
		sum.push_back(sum.back() + x);
		if (hoge[x]) {
			s = hoge[x];
			t = i;
			break;
		}
		hoge[x] = i;
		x = x*x % M;
	}
	if (N < (int)sum.size()) {
		cout << sum[N] << endl;
		return 0;
	}
	ll k1 = (N - (s-1)) / (t - s);
	ll k2 = (N - (s-1)) % (t - s);
	cout << sum[s-1] + (sum[t-1]-sum[s-1]) * k1 + (sum[s-1+k2]-sum[s-1]) << endl;
}


Measured memory_bytes: 4308
#8:47
MOD=10**9+7
INT_MAX=10**20+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#################################################################################
x,n=INPUT()
A=INPUT()
if x not in A:
    print(x)
else:
    for d in range(1,102):
        if x-d not in A:
            print(x-d)
            break
        elif x+d not in A:
            print(x+d)
            break
        


Measured memory_bytes: 62000
#include <bits/stdc++.h>
#define int long long 
using namespace std;
const int N = 1e5 + 10;
int ton[N], n, q, sum;
signed main(){
	cin >> n;
	for (int i = 1, x; i <= n; i++) {
		cin >> x;
		++ton[x];
		sum += x; 
	}
	cin >> q;
	while(q--) {
		int b, c;
		cin >> b >> c;
		sum -= ton[b] * b;
		sum += ton[b] * c;
		ton[c] += ton[b];
		ton[b] = 0;
		cout << sum << endl;
	}
	return 0;
}

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

using PP = pair<int, int>;
const int inf = 1e9;

int n;
vector<PP> P[4];
int ext[4][4];

int dir(char c) {
  if (c == 'R') return 0;
  if (c == 'U') return 1;
  if (c == 'L') return 2;
  if (c == 'D') return 3;
}

double cat(double t) {
  const double dx[] = { 1, 0, -1, 0 };
  const double dy[] = { 0, 1, 0, -1 };
  double lx = inf;
  double rx = -inf;
  double ly = inf;
  double ry = -inf;
  for (int k = 0; k < 4; ++k) {
    lx = min(lx, ext[k][2] + dx[k] * t);
    rx = max(rx, ext[k][0] + dx[k] * t);
    ly = min(ly, ext[k][3] + dy[k] * t);
    ry = max(ry, ext[k][1] + dy[k] * t);
  }
  return (rx - lx) * (ry - ly);
}

vector<double> events(PP p, PP q, PP c) {
  vector<double> ts;
  ts.push_back(c.first - p.first);
  ts.push_back(c.second - p.second);
  ts.push_back(q.first - c.first);
  ts.push_back(q.second - c.second);
  ts.push_back(double(q.first - p.first) / 2);
  ts.push_back(double(q.second - p.second) / 2);
  return ts;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x, y;
    char c;
    cin >> x >> y >> c;
    P[dir(c)].push_back(PP(x, y));
  }
  
  for (int k = 0; k < 4; ++k) {
    int xl = 1e9;
    int xr = -1e9;
    int yl = 1e9;
    int yr = -1e9;
    for (PP p : P[k]) {
      xl = min(xl, p.first);
      xr = max(xr, p.first);
      yl = min(yl, p.second);
      yr = max(yr, p.second);
    }
    ext[k][0] = xr;
    ext[k][1] = yr;
    ext[k][2] = xl;
    ext[k][3] = yl;
  }
  
  auto va = events(
    PP(ext[0][2], ext[0][0]),
    PP(ext[2][2], ext[2][0]),
    PP(
      min(ext[1][2], ext[3][2]),
      max(ext[1][0], ext[3][0])
      )
  );
  
  auto vb = events(
    PP(ext[1][3], ext[1][1]),
    PP(ext[3][3], ext[3][1]),
    PP(
      min(ext[0][3], ext[2][3]),
      max(ext[0][1], ext[2][1])
      )
  );
  
  vector<double> ts;
  for (double t : va) if (t >= 0) ts.push_back(t);
  for (double t : vb) if (t >= 0) ts.push_back(t);
  ts.push_back(0);
  
  double mn = 1e50;
  for (double t : ts) {
    mn = min(mn, cat(t));
  }
  cout << fixed << setprecision(16) << mn << endl;
}


Measured memory_bytes: 1276
import Control.Applicative

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

solve :: [Int] -> String
solve [x, a, b]
  | c <= 0 = "delicious"
  | c <= x = "safe"
  | otherwise = "dangerous"
  where
    c = b - a


Measured memory_bytes: 508
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

string itos(long long a) {
    string s = to_string(a);
    return s;
}

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    int ans = 0;
    for(int i=0;i<N;i++){
        string s = itos(i+1);
        if(s.length()%2==1) ans++;
    }
    cout << ans << nn;
    return 0;
}

Measured memory_bytes: 256