akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int n;
  cin >> n;
  vector<pair<pair<string, int>, int>> rest(n);
  rep(i,n) {
    string s;
    int p;
    cin >> s >> p;
    rest[i].fi.fi = s;
    rest[i].fi.se = -p;
    rest[i].se = i+1;
  }

  sort(rest.begin(), rest.end());
  rep(i,n) cout << rest[i].se << endl;
  return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d%d", $N, $M);
for($i = 0; $i < $M; $i++){
  fscanf(STDIN, "%d%d", $u, $t);
  $c[$u][] = $t;
}
fscanf(STDIN, "%d%d", $S, $T);

$p[0][$S] = 1;
for($i = 0; $i < $N*5+200; $i++){
  if(isset($p[$i]))foreach($p[$i] as $current => $_){
    if(isset($c[$current]))foreach($c[$current] as $next){
      if(!isset($map[$i % 3][$next])){
        $map[$i % 3][$next] = true;
        $p[$i+1][$next] = true;
      }
      if(($i+1)%3==0&&$next==$T){
        echo ($i+1) / 3;
        exit;
      }
    }
  }
}
echo -1;


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

int main(){
    
    long long  a,b,c,d;
    cin >> a >> b >> c >> d;
    if(b > 0 && d > 0){
        if(a*c < b*d){
            cout << b*d << endl;
            return 0;
        }
        else{
            cout << a*c << endl;
            return 0;
        }
    }
    else if(b < 0 && d > 0){
        if(c >= 0){
            cout << b*c << endl;
            return 0;
        }
        else{
            cout << a*c << endl;
            return 0;
        }
    }
    else if(d < 0 && b > 0){
        if(a >= 0){
            cout << d*a << endl;
            return 0;
        }
        else{
            cout << c*a << endl;
            return 0;
        }
    }
    else{
        cout << a*c << endl;
        return 0;
    }
}


Measured memory_bytes: 3580
#include<stdio.h>
int hig,wid;
char grid[3000][3000];
int put_vt[3000][3000];
int put_ho[3000][3000];
int main(void){
    int i,j,y,x;
    for(i=0;i<3000;i++){
        for(j=0;j<3000;j++){
            grid[i][j]=0;
            put_vt[i][j]=0;
            put_ho[i][j]=0;
        }
    }
    scanf("%d %d",&hig,&wid);
    for(i=0;i<hig;i++){
        scanf("%s",grid[i]);
    }
    int start,ren;
    for(y=0;y<hig;y++){
        start=0;
        ren=0;
        for(x=0;x<wid;x++){
            if(grid[y][x]=='.'){
                ren++;
            }else if(grid[y][x]=='#'){
                for(j=start;j<x;j++){
                    put_ho[y][j]=ren;
                }
                start=x+1;
                ren=0;
            }
        }
              if(ren!=0){
            for(j=start;j<wid;j++){
                put_ho[y][j]=ren;
            }
        }
    }
    for(x=0;x<wid;x++){
        start=0;
        ren=0;
        for(y=0;y<hig;y++){
            if(grid[y][x]=='.'){
                ren++;
            }else if(grid[y][x]=='#'){
                for(j=start;j<y;j++){
                    put_vt[j][x]=ren;
                }
                start=y+1;
                ren=0;
            }
        }
             if(ren!=0){
            for(j=start;j<hig;j++){
                put_vt[j][x]=ren;
            }
        }
    }
    int ans=0;
    for(i=0;i<hig;i++){
        for(j=0;j<wid;j++){
            if(ans<put_vt[i][j]+put_ho[i][j]){
                ans=put_vt[i][j]+put_ho[i][j];
            }
        }
    }
    printf("%d\n",ans-1);
    return 0;
}

Measured memory_bytes: 79232
#include <stdio.h>

int N;

int main(void) {
	scanf("%d", &N);

	int i = 1;
	while ((1 + i)*i < N * 2) {
		i++;
	}
	while (N > 0) {
		if (N - i >= 0) {
			printf("%d\n", i);
			N -= i;
		}
		i--;
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
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, k;

int main() {
    cin >> n >> k;
    int limit = (n-1)*(n-2)/2;
    if(k > limit) cout << -1 << endl;
    else {
        int cnt = limit-k;
        cout << cnt+(n-1) << endl;
        bool flg = true;
        for(int i = 2; i <= n; ++i) {
            cout << 1 << " " << i << endl;
        }
        for(int u = 2; u <= n; ++u) {
            for(int v = u+1; v <= n; ++v) {
                if(cnt != 0) {
                    cout << u << " " << v << endl;
                }else {
                    flg = false;
                    break;
                }
                cnt--;
            }
            if(!flg) break;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

void swap(int& a, int& b){
    a = a ^ b; b = a ^ b; a = a ^ b;
}

int bubbleSort(int a[], int n){
    int cnt = 0;
    for(int i = 1; i < n; ++i){
        int f = 1;
        for(int j = n; j > i; --j){
            if(a[j] < a[j - 1]) { swap(a[j], a[j - 1]); ++cnt; f = 0;}
        }
        if(f) break;
    }
    return cnt;
}

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



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100005
 
int n;
char s[MAX_N];
bool t[11][(1<<10)];
bool dp[11][(1<<10)];
 
bool check(int S){
  memset(dp,false,sizeof(dp));
  dp[0][0]=true;
  int a=1;
  for(int i=0;i<10;i++){
    if(~S>>i&1)continue;
    for(int j=0;j<(1<<10);j++){
      if(!t[i][j])continue;
      int k=(1<<10)-1-j;
      while(1){
        dp[a][j+k]|=dp[a-1][k];
        if(dp[a][j+k] && ((j+k)&S)==S )return true;
        if(k==0)break;
        k=(k-1)&(~j);
      }
    }
    a++;
  }
  return false;
}
 
bool solve(){
  for(int bit=0;bit<(1<<10);bit++)
    if(check(bit))return true;
  return false;
}
 
int main(){
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    memset(t,false,sizeof(t));
    scanf("%s",s);
    int bit=0;
    for(int i=0;i<n;i++){
      if(s[i]=='u')bit=0;
      if('0'<=s[i]&&s[i]<='9'){
        int num=s[i]-'0';
        t[ num ][ bit ] = true;
        bit|=(1<<num);
      }
    }
    if(solve() )printf("UNSAFE\n");
    else printf("SAFE\n");
  }
  return 0;
}

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

char X[200005];
int n;

int main(){
    scanf("%s",X);
    n = strlen(X);
    int Ss = -1, Se = -2;
    int llen = n;
    for(int i = 0; i < n; i++){
        if(X[i] == 'S'){
            if(Ss == -1) Ss = Se = i;
            else ++Se;
        }else if(X[i] == 'T'){
            if(Se < Ss) continue;
            --Se;
            llen -= 2;
        }else{
            Ss = -1; Se = -2;
        }
    }
    cout << llen << '\n';
}

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

using namespace std;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

int main()
{
    const auto A(cin2var<size_t>());
    const auto B(cin2var<size_t>());
    size_t     tap  = 0;
    size_t     plug = 1;
    while (true) {
        if (plug >= B) break;
        --plug;
        plug += A;
        ++tap;
    }
    cout << tap << endl;
    return 0;
}

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

int main()
{
    int N, num;
    int nums[1000];
    double mult, sum;
    cin >> N;
    mult = 1;
    for(int i=0; i<N; i++){
        cin >> num;
        nums[i] = num;
        mult *= num;
    }
    sum = 0;
    for(int i=0; i<N; i++){
        sum += mult/nums[i] ;
    }
    cout << fixed;
    cout << setprecision(7) << mult/sum;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main{
    public static void main(String[] args){
	try{
	    BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
	    String st;
	    while((st=s.readLine())!=null){
		int count = 0, n = Integer.valueOf(st);
		int[] x = new int[n];
		
		for(int i=1; i<n; i++)
		    if(x[i]==0){
			count++;
			for(int j=i; j<n; j+=(i+1))
			    x[j]=1;
		    }
		System.out.println(count);
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
using namespace std;
signed  main(){
  string a;
  int b=0;
  cin>>a;
  for(int i=0;i<a.size();i++){
    if(a[i]=='+'){
      b++;
    }else{
      b--;
    }
  }
  cout<<b<<"\n";
}


Measured memory_bytes: 256
import sys

n,k = map(int,input().split())
a = list(map(int,input().split()))
dp = [sys.maxsize]*(n)
dp[0] = 0
for i in range(n):
  for j in range(i+1,k+i+1):
    if j<n:
      dp[j] = min(dp[j],dp[i]+abs(a[i]-a[j]))

print(dp[n-1])

 

Measured memory_bytes: 52448
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    vector<vector<P>> A(N);
    REP(i,N) {
        int a; cin >> a;
        REP(j,a) {
            int x,y; cin >> x >> y;
            A[i].push_back(P(x,y));
        }
    }
    queue<veci> que;
    que.push({0});
    que.push({1});
    int ans = 0;
    while(1) {
        veci res = que.front();
        que.pop();
        if(res.size() == N+1) break;
        if(res.size() == N) {
            //REP(i,N) cout << res[i] << " ";
            //cout << endl;
            int cnt = 0;
            bool ok = true;
            REP(i,N) {
                if(res[i] == 0) continue;
                REP(j,A[i].size()) {
                    if(res[A[i][j].first-1] != A[i][j].second) ok = false;
                }
                cnt++;
            }
            if(ok)
            chmax(ans,cnt);
        }
        REP(i,2) {
            veci memo = res;
            memo.push_back(i);
            que.push(memo);
        }
    }
    cout << ans << endl;
}


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

int main(){
    int N, M; cin >> N >> M;
    set<int> from1, endN;
    from1.insert(0);
    endN.insert(0);

    int a, b;
    for( int i = 0; i < M; i++ ){ 
        cin >> a >> b;
        if( a == 1 ){
            //cout << "from1" << endl;
            if( endN.find(b) != endN.end() ){
                cout << "POSSIBLE" << endl;
                return 0;
            } else {
                from1.insert(b);
            }
        }
        if( b == N ){
            //cout << "endN" << endl;
            if( from1.find(a) != from1.end() ){
                cout << "POSSIBLE" << endl;
                return 0;
            } else {
                endN.insert(a);
            }
        }
    }


    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 9600
while True:
    x=int(input())
    if x==0:
        break
    oturi=1000-x
    a=oturi//500
    b=oturi//100-a*5
    c=(oturi%100)//50
    d=(oturi%100)//10-c*5
    e=(oturi%10)//5
    f=(oturi%10)-e*5
    kazu=a+b+c+d+e+f
    print(kazu)


Measured memory_bytes: 5592
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


struct UnionFind {
	vector<int> par, rank, cnt;
	UnionFind(int n) : par(n), rank(n, 0), cnt(n, 1){
		for(int i=0; i<n; ++i) par[i] = i;
	}
 
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}
 
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
 
		if (rank[x] < rank[y]) swap(x, y);
 
		par[y] = x;
		cnt[x] += cnt[y];
		if (rank[x] == rank[y]) rank[x]++;
	}
 
	bool same(int x, int y) {
		return find(x) == find(y);
	}
 
	int size(int x) {
		return cnt[find(x)];
	}
};

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
    long long N,K; cin >> N >> K;
    vector<long long> a(N);
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }

    long long dp[100][2]; memset(dp,-1,sizeof(dp));
    dp[0][0] = 0;
    const int MAX = 50;
    for (int i = 0; i < MAX; i++){
        long long mask = 1LL << (MAX-i-1);

        int num = 0;
        for (int j = 0; j < N; j++){
            if (a[j] & mask) num++;
        }
        long long c0 = mask*num, c1 = mask*(N-num);

        if (dp[i][1] != -1){
            dp[i+1][1] = max(dp[i+1][1], dp[i][1] + max(c0, c1));
        }

        if (dp[i][0] != -1){
            if (K & mask){
                dp[i+1][1] = max(dp[i+1][1], dp[i][0] + c0);
            }
        }

        if (dp[i][0] != -1){
            if (K & mask) dp[i+1][0] = max(dp[i+1][0], dp[i][0] + c1);
            else dp[i+1][0] = max(dp[i+1][0], dp[i][0] + c0);
        }
    }
    cout << max(dp[MAX][0], dp[MAX][1]) << endl;
}

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

int min3 (int x, int y, int z){
  if (x < y && x < z) {
    return x;
  }
  else if (y < x && y < z) {
    return y;
  }
  else {
    return z;
  }
}

int gcd3 (int a, int b, int c){
    int gcd=1;
    for(int i=1; i<=min3(a, b, c); i++) {
        if (a%i==0 && b%i==0 && c%i==0) gcd=i;
    }
    return gcd;
}

int main(){
ll ans=0;
int k;
cin >> k;

rep1(a,k)rep1(b,k)rep1(c,k){
    ans+=gcd3(a, b, c);
}

cout << ans << endl;

}

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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 100111, inf = 1000111222;
const ll mod = 1000000007;


ll powm(ll a, ll b) {
    if (b == 0) {
        return 1;
    }
    if (b % 2 == 0) {
        return powm((a * a) % mod, b / 2);
    } else {
        return (a * powm(a, b - 1)) % mod;
    }
}

ll f[max_n];
ll rf[max_n];

void precalc() {
    f[0] = 1;
    f[1] = 1;
    for (int i = 2; i < max_n; ++i) {
        f[i] = (f[i - 1] * i) % mod;
    }

    for (int i = 0; i < max_n; ++i) {
        rf[i] = powm(f[i], mod - 2);
    }
}

ll c(ll n, ll k) {
    //cout << n << ' ' <<k << endl;
    if (k > n) return 0;
    //cout << (f[n] * rf[n - k]) % mod << endl;
    return (f[n] * rf[n - k]) % mod;
}

vector<int> v[max_n];
int n, k;
ll ans = 1;

void dfs(int cur, int pr) {
    if (cur == 0) {
        ans *= k;
        ans %= mod;
        ans *= c(k - 1, v[cur].size());
        ans %= mod;
    } else {
        ans *= c(k - 2, v[cur].size() - 1);
        ans %= mod;
    }
    for (int to : v[cur]) {
        if (to == pr) continue;
        dfs(to, cur);
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> n >> k;
    precalc();
    for (int i = 0; i + 1 < n; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        --a, --b;
        v[a].PB(b);
        v[b].PB(a);
    }
    dfs(0, -1);
    cout << ans << endl;
    return 0;
}




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

void add(string s, int now, int last, int range) {
    int m = min(now,range);

    rep(i,m){
        string t = s;
        t += 'a' + i;
        if (now == last) {
            cout << t << endl;
        } else {
            add(t, now+1, last, max(range, i+2));
        } 
    }
}

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

    string s = "";
    add(s, 1, N, 1);

    return 0;
}



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

using namespace std;
using ll = long long;
using P = pair<int,int>;
inline int ri() {
	int r; cin >> r; return r;
}
int cnt = 0;
vector<vector<int>> hen;
vector<int> hi;

void dfs(int v) {
	bool res = true;
	for(auto i : hen[v]) {
		if(hi[i] >= hi[v])res = false;
	}	
	cnt += res;
}

int main()
{
	int n, m;
	cin >> n >> m;
	hen.resize(n);
	hi.resize(n);
	for(int i = 0; i < n; i++)cin >> hi[i];
	for(int i = 0; i < m; i++){
		int a, b; cin >> a >> b; a--, b--;
		hen[a].push_back(b);
		hen[b].push_back(a);
	}

	for(int i = 0; i < n; i++) {
		dfs(i);
	}
	cout <<cnt << endl;
}

Measured memory_bytes: 8820
#include <stdio.h>

int main(void) {
  int a, b;
  scanf("%d%d", &a, &b);

  int x = b - a;
  int y = 0;
  for(int i = x; i > 0; i--) {
    y += i;
  }

  printf("%d\n", y-b);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll dp[51][51][2509],a[51],x,k;
ll f(int i ,int cnt ,int sum){
    if (i==x)
        return((double)sum/cnt==k);
    if (dp[i][cnt][sum]!=-1)
        return dp[i][cnt][sum];
    return dp[i][cnt][sum]=f(i+1,cnt,sum)+f(i+1,cnt+1,sum+a[i]);
}
int main()
{
    FASTINOUT;
    cin>>x>>k;
    for (int i=0;i<x;i++)
        cin>>a[i];
    memset(dp,-1,sizeof dp);
    cout<<f(0,0,0);
    return 0;
}





Measured memory_bytes: 54624
package main

import (
	"fmt"
	"strings"
)

// 問題文の条件だと、文字列の最初と最後を見ればいいので
// HasPrefixとHasSuffixを使う
// 参考
// https://atcoder.jp/contests/keyence2019/submissions/4003072

func main() {
	var S string
	fmt.Scan(&S)
	K := "keyence"
	prefixes := make([]string, len(K))
	suffixes := make([]string, len(K))
	for i := 0; i < len(K); i++ {
		prefixes[i] = K[:i]
		suffixes[i] = K[i:]
	}
	for i := 0; i < len(K); i++ {
		if strings.HasPrefix(S, prefixes[i]) && strings.HasSuffix(S, suffixes[i]) {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AKthTerm solver = new AKthTerm();
        solver.solve(1, in, out);
        out.close();
    }

    static class AKthTerm {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int[] array = {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};
            out.println(array[in.nextInt() - 1]);
        }

    }

    static class Scanner {
        private final InputStream in;
        private final byte[] buffer;
        private int ptr;
        private int buflen;

        public Scanner(InputStream in) {
            this.in = in;
            this.buffer = new byte[1024];
            this.ptr = 0;
            this.buflen = 0;
        }

        private boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }

        private byte readByte() {
            if (hasNextByte()) return buffer[ptr++];
            return -1;
        }

        private boolean isPrintableChar(byte c) {
            return '!' <= c && c <= '~';
        }

        private void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
        }

        public boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        public int nextInt() {
            if (!hasNext()) throw new NoSuchElementException();
            int n = 0;
            boolean minus = false;
            byte b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 21460
S = int(input())
mod = 10**9 + 7

dp = [0] * (S+1)
dp[0] = 1
x = 0
for i in range(1,S+1):
  if i-3 >= 0:
    x += dp[i-3]
    x %= mod
  dp[i] = x
print(dp[S])

Measured memory_bytes: 9060
import Control.Monad
import Data.List

main:: IO ()
main = do
  n <- readLn
  ws <- replicateM n getLine
  putStrLn $ if isFollowRules ws then "Yes" else "No"

isFollowRules :: [String] -> Bool
isFollowRules ws = not (hasDuplication ws) && isShiritori ws

hasDuplication :: (Eq a) => [a] -> Bool
hasDuplication xs = xs /= nub xs

isShiritori :: [String] -> Bool
isShiritori [] = True
isShiritori [_] = True
isShiritori [x, y] = last x == head y
isShiritori (x:y:xs) = last x == head y && isShiritori (y:xs)


Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int mod=1000000007 ;

void solve(){
	
	int n,m ;
	cin>>n>>m ;

	ll arr[m] ;
	ll sum=0 ;

	for(int i=0;i<m;i++){
		cin>>arr[i] ;
		sum+=arr[i] ;
	}

	if(sum>n){
		cout<<-1 ;
	}
	else{
		cout<<n-sum ;
	}

}


int main(){


	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[101];
    scanf("%s",s);
    int n,i,j,a=0;
    n=strlen(s);
    for(i=0;i<(n/2);i++)
    {
        if(s[i]!=s[n-1-i])
            a++;
    }
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 x;
  cin >> x;
  if (x == 1)
    cout << 0 << endl;
  else
    cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
#define Max 500000
#define INFTY 2000000000

int L[Max/2+2];
int R[Max/2+2];
int count =0;

void mergeA(int A[],int left,int mid,int right){
    int n1 = mid-left;
    int n2 = right-mid;
    
    int i,j,k;
    for(i=0; i<n1; i++) L[i]=A[left + i];
    for(i=0; i<n2; i++) R[i]=A[mid + i];
    L[n1] = INFTY;
    R[n2] = INFTY;
    i=0;
    j=0;
    for(k=left; k<right; k++){
        if(L[i]<=R[j]){
            A[k] = L[i];
            i++;
            count++;
        }else{
            A[k] = R[j];
            j++;
            count++;
        }
    }
    
    
}

void mergeSort(int A[],int left,int right){
    if(left+1<right){
        int mid =(left+right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        mergeA(A,left,mid,right);
    }
}




int main() {
    int n;
    int i;
    int A[Max];
    scanf("%d",&n);
    
    for(i=0; i<n; i++){
        scanf("%d",&A[i]);
    }
    mergeSort(A, 0, n);
    
    for(i=0; i<n; i++){
        printf("%d",A[i]);
        if(i<n-1) printf(" ");
    }
    printf("\n%d\n",count);
    
    return 0;
}


Measured memory_bytes: 5592
import sys
input = sys.stdin.buffer.readline

def main():
	K,M = map(int,input().split())
	
	def factorize(n):
		fct = []  # prime factor
		b, e = 2, 0  # base, exponent
		while b * b <= n:
			while n % b == 0:
				n = n // b
				e = e + 1
			if e > 0:
				fct.append((b, e))
			b, e = b + 1, 0
		if n > 1:
			fct.append((n, 1))
		return fct
	
	N = 10**5+100
	MOD = 10**9+7
	fac = [0]*(N+1)
	fac[0],fac[1] = 1,1
	invfac = [0]*(N+1)
	invfac[0],invfac[1] = 1,1

	for i in range(2,N+1):
		fac[i] = (fac[i-1]*i)%MOD

	invfac[-1] = pow(fac[-1],MOD-2,MOD)
	for i in range(N,0,-1):
		invfac[i-1] = (invfac[i]*i)%MOD

	def coef(x,y):
		num = ((fac[x]*invfac[y])%MOD)*invfac[x-y]%MOD
		return num
	
	fl = factorize(M)
	
	ans = 1
	for pr,cnt in fl:
	    ans *= coef(K+cnt-1,K-1)
	    ans %= MOD
	
	print(ans)
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 40432
#Coding: utf-8

n=int(input())
p=list(map(int, input().split()))
count=0
for i in range (1,n-1):
    if p[i]>p[i+1] and p[i]<p[i-1]:
        count+=1
    elif p[i]>p[i-1] and p[i]<p[i+1]:
        count+=1

print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int x,y;
  while(1){
    cin >> x >> y;
    if(x==0&&y==0){
      break;
    }
    if(x>y){
      int temp=x;
      x=y;
      y=temp;
    }
    cout << x << ' ' << y << endl;
  }
  return(0);
}


Measured memory_bytes: 3056
/*
ID: deidnan1
TASK: barn1
LANG: C++11
*/ 

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ii = std::pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>; //vector<vector<int>>
using vs = vector<string>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend() 
#define sz(x) (int)((x).size())
#define arrsz(x) (int) (sizeof((x))/sizeof((x)[0]))

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

/* Usage: output_vector(solution), which prints elements with spaces and then new line*/
template<typename T>
void output_vector(const vector<T> &v, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());
 
    for (int i = start; i < end; i++)
        cout << v[i] << " ";
    cout << endl;
}
// FILE I/O
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

int main() 
{
   for (int i = 1; i <=5; i++)
   {
       int num;
       cin >> num;
       if (num == 0)
       {
           cout << i << endl;
           break;
       }
   }
}
   

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <set>
using namespace std;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    int N, M; cin >> N >> M;
    vector<int> X(M), Y(M), Z(M);
    for (int i = 0; i < M; ++i) cin >> X[i] >> Y[i] >> Z[i], --X[i], --Y[i];
    UnionFind uf(N);
    for (int i = 0; i < M; ++i) uf.merge(X[i], Y[i]);
    set<int> se;
    for (int i = 0; i < N; ++i) se.insert(uf.root(i));
    cout <<(int)se.size()<<endl;
    
}

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

public class Main{
	public static void main(String[] args)  throws IOException,NumberFormatException{
		try {
		FastScanner sc=new FastScanner();
		int x=sc.nextInt(),y=sc.nextInt();
		int a [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
		
		
		System.out.println(a[x]==a[y]?"Yes":"No");
		
		}
		catch(Exception e) {
			return ;
		}
		
	}
	static final Random random=new Random();
	
	static void ruffleSort(int[] a) {
		int n=a.length;
		for(int i=0;i<n;i++) {
			int oi=random.nextInt(n),temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	
	public static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try { 
                                      st=new StringTokenizer(br.readLine());				               
                              } catch (IOException e) {}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		long[] readLongArray(int n) {
			long[] a=new long[n];
			for(int i=0; i<n ; i++) a[i]=nextLong();
			return a;
		}
		
		String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
	}

}


Measured memory_bytes: 32528
# frozen_string_literal: true

n, k = gets.split.map(&:to_i)
h = Array.new(n) { gets.to_i }.sort
min = 10**9 - 1

(n - k + 1).times do |i|
  min = [min, h[i + k - 1] - h[i]].min
end

puts min

Measured memory_bytes: 4472
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int w = scanner.nextInt();

        final Map<Integer, List<Long>> items = new HashMap<>();
        for (int i = 0; i < n; i++) {
            final int wi = scanner.nextInt();
            final long vi = scanner.nextInt();
            items.computeIfAbsent(wi, v -> new ArrayList<>()).add(vi);
        }

        items.values().forEach(list -> list.sort(Comparator.reverseOrder()));

        final List<Integer> keys = new ArrayList<>(items.keySet());
        final long answer = recursive(keys, items, 0, w, 0);
        System.out.println(answer);
    }

    private static long recursive(final List<Integer> keys, final Map<Integer, List<Long>> items, final long value, final int w, final int index) {
        long maxValue = value;
        if (index < keys.size() - 1) {
            maxValue = Math.max(maxValue, recursive(keys, items, value, w, index + 1));
        }

        final int key = keys.get(index);
        final List<Long> values = items.get(key);
        long tmpValue = value;
        for (int i = 0; i < values.size() && key * (i + 1) <= w; i++) {
            tmpValue += values.get(i);
            if (index < keys.size() - 1) {
                maxValue = Math.max(maxValue, recursive(keys, items, tmpValue, w - key * (i + 1), index + 1));
            }
        }
        return Math.max(maxValue, tmpValue);
    }
}


Measured memory_bytes: 27348
from collections import deque
S=input()
N=int(input())
q=deque([S[i] for i in range(len(S))])

c=0
for i in range(N):
  A=list(map(str,input().split()))
  if A[0]=='1':
     c+=1
     c%=2
  else:
     if (c+int(A[1]))%2==1:
       q.appendleft(A[2])
     if (c+int(A[1]))%2==0:
       q.append(A[2])
s=''
if c==0:
  for i in range(len(q)):
    r=q.popleft()
    s+=r
if c==1:
  for i in range(len(q)):
    d=q.pop()
    s+=d
print(s)  


Measured memory_bytes: 6748
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,m,q,t,x;
    cin>>n>>m;
    list <long long> a[n];
    list<long long>::iterator itr;
    for(long long i=0;i<m;i++){
        cin>>q>>t;
        if(q==0){
            cin>>x;
            a[t].push_back(x);
        }
        else if(q==1){
            for(itr = a[t].begin(); itr!=a[t].end(); ++itr) {
                if(itr!=a[t].begin()){
                    cout<< " ";
                }
                cout << *itr ;
            }
            cout<<endl;
            
        }
        else{
            cin>>x;
            a[x].splice(a[x].end(), a[t]);
        }
    }
    
    return 0;
}


Measured memory_bytes: 18644
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  
  int n;
  cin >> n;

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

  deque<int> b;

  FOR(i, 1, n + 1){
    if(n % 2 == 0){
      if(i % 2 == 0){
        b.push_front(a[i - 1]);
      }
      else{
        b.push_back(a[i - 1]);
      }
    }
    else{
      if(i % 2 == 0){
        b.push_back(a[i - 1]);
      }
      else{
        b.push_front(a[i - 1]);
      }
    }
  }

  REP(i, n) cout << b[i] << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> B(n - 1);
  for(int i = 0; i < n - 1; ++i) cin >> B[i];
  int sum = B[0];
  sum += B[n - 2];
  for(int i = 0; i < n - 2; ++i){
    sum += min(B[i], B[i + 1]);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,h;
    cin >> n >> h;
    VI a(n),b(n);
    REP(i,0,n) cin >> a[i] >> b[i];
    sort(all(a));
    sort(all(b));
    reverse(all(a));
    reverse(all(b));
    int cnt = 0;
    while (b[cnt] >= a[0] && h > 0 && cnt < n) {
        h -= b[cnt++];
    }
    if (h > 0) cnt += (h + a[0] - 1) / a[0];
    cout << cnt << endl;
} 

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

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

#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

#define vc vector<char>
#define vvc vector<vc>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvvll vector<vvll>
#define vs vector<str>
#define vvs vector<vs>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vpll vector<pll>
#define vvpll vector<vpll>
#define vb vector<bool>
#define vvb vector<vb>
#define rep(i, a, b) for (int i = (a); i < int(b); i++)
#define repi(i, a, b) for (int i = (a); i <= int(b); i++)


using namespace std;
ll INF = LONG_LONG_MAX;
ll mod = 1000000000 + 7;

template <typename T, typename L>
void read(vector<T> & _data, L & _size, bool _shift) {
    _data.resize(_size + (ll)_shift);
    for (ll i = (ll)_shift; i < _size + (ll)_shift; i++)
        cin >> _data[i];
}

template <typename T, typename L>
void read(vector<vector<T>> & _data, L & _rows, L & _cols, bool _shiftRows, bool _shiftCols) {
    _data.resize(_rows + (ll)_shiftRows);
    for (ll i = 0; i < _rows + (ll)_shiftRows; i++)
        _data[i].resize(_cols + (ll)_shiftCols);
    for (ll i = (ll)_shiftRows; i < _rows + (ll)_shiftRows; i++)
        for (ll j = (ll)_shiftCols; j < _cols + (ll)_shiftCols; j++)
            cin >> _data[i][j];
}

template <typename T>
void write(vector<T> & _data, bool _shift) {
    for (ll i = (ll)_shift; i < _data.size(); i++)
        cout << _data[i] << " ";
    cout << endl;
}


//TODO: SOLUTION

ll n, m, cmp;
vvll gr;
vll comp;

void dfscomp(ll x) {
    if (comp[x] != -1)
        return;
    comp[x] = cmp;
    for (auto y : gr[x]) {
        dfscomp(y);
    }
}

void solve() {
    cin >> n >> m;
    gr.resize(n + 1);
    rep(i, 0, m) {
        ll u, v;
        cin >> u >> v;
        gr[u].push_back(v);
        gr[v].push_back(u);
    }
    comp.resize(n + 1, -1);
    cmp = 0;

    repi(i, 1, n) {
        if (comp[i] == -1) {
            dfscomp(i);
            cmp++;
        }
    }

    vll nums(n, 0);
    repi(i, 1, n) {
        nums[comp[i]]++;
    }
    ll ans = 0;
    rep(i, 0, n) {
        ans = max(ans, nums[i]);
    }
    cout << ans << endl;
}


int main() {

    // TODO: Set value of this variable manually
    bool _multipleTestCases = false;

    if (_multipleTestCases) {
        ll t; cin >> t;
        while (t--)
            solve();
    }
    else {
        solve();
    }

    return 0;
}

Measured memory_bytes: 23520
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    string X;
    cin >> X;
    
    int tmp = 0, ans = 0;
    REP(i, (int)X.size()){
        if(X[i] == 'T') tmp++;
        else tmp--;
        chmax(ans, tmp);
    }

    cout << ans*2 << "\n";
    return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <string>

std::string s;

// + を入れるか入れないかで場合分けをするdfs
long dfs(int idx_from, int idx_to, long total) {
    if (idx_to == s.size()) return total + std::stol( s.substr(idx_from, idx_to - idx_from) );
    long num1 = std::stol( s.substr( idx_from, idx_to - idx_from ) );
    return dfs( idx_from, idx_to+1, total ) + dfs( idx_to, idx_to+1, total+num1 );
}

int main() {
    std::cin >> s;
    std::cout << dfs(0, 1, 0) << std::endl;
    return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int x = sc.NextInt();
        int a = sc.NextInt();
        int b = sc.NextInt();

        int answer = (x - a) % b;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    double n;
    cin >> n;
    int nt = n;
    nt %= 2;

    double ans = (n + (double)nt)/2 / n;

    printf("%.10f", ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define maju 1919114514
using namespace std;
int main() {
	int n, m;
	int lmax = 0, rmin = maju;
	cin >> n >> m;
	vector<int> l(m),r(m);
	for (int i = 0; i < m; i++) {
		cin >> l[i] >> r[i];
		if (l[i] > lmax)lmax = l[i];
		if (r[i] < rmin)rmin = r[i];
	}
	if (rmin < lmax)cout << 0 << endl;
	else if (n < lmax)cout << 0 << endl;
	else if (lmax <= n && n <= rmin) {
		cout << n - lmax + 1 << endl;
	}
	else cout << rmin - lmax + 1 << endl;

	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

/*
計算量について
n = 20くらいまでならbit全探索できるよ

なお、j番目のマスク（2^j）が欲しいだけなら、
「1 << j」として、
1をj回左シフトするだけで一瞬で作れるので、
わざわざリストを作る必要はない。
*/

/*
cf. Bit探索メモ
1. 2^N通りの全てを探索する場合
	0 <= i < 2^Nまでの全ての整数をチェックする必要。
	（なお、2^N = (1 << N)）

2. j番目のビットが立っているか確認する場合。
	対象の数値をiとしたとき、
	「i & (1 << j) == 0」ならば、ビットは立っていない。
	（AND演算子を使用。この時の「1 << j」（= 2^j）が、マスクになる。）

3. j番目のビットを立たせたい場合。
	対象の数値をiとしたとき、
	「k = i | (1 << j)」とすれば、
	kは、iのj番目のビットを立たせた数値となる。
	（OR演算子を使用。bit DPなどで役立つ。）
*/

class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む
		string line = Console.ReadLine();
		int[] num = new int[4];
		for(int i=0; i<4; i++){
			num[i] = int.Parse(line.Substring(i,1));
		}

		//operator
		string[] op = new string[3];

		//bit探索（0 <= 1 < 2^3）
		for(int i=0; i<(1<<3); i++){
			//各ビットをチェック
			/*
			ビットが立っている場合、+とする
			*/
			for(int j=0; j<3; j++){
				op[j] = (i & (1 << j)) != 0 ? "+" : "-";
			}

			int res = num[0];
			for(int j=0; j<3; j++){
				if(op[j] == "+"){
					res += num[j+1];
				}
				else{
					res -= num[j+1];
				}
			}

			if(res == 7){
				break;
			}
		}

		//出力
		Console.WriteLine("{0}{1}{2}{3}{4}{5}{6}=7",
		num[0],op[0],num[1],op[1],num[2],op[2],num[3]);
	}
}



Measured memory_bytes: 17584
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i;
    cin>>n;
    ll a[3*n];
    for (i=0;i<3*n;i++)
        cin>>a[i];
    priority_queue<int,vector<int>,greater<int>> left_part;
    priority_queue<int> right_part;
    ll left[3*n],right[3*n];
    ll cur_sum=0;
    for (i=0;i<3*n;i++)
    {
        left_part.push(a[i]);
        cur_sum+=a[i];
        if (left_part.size()>n)
        {
            cur_sum-=left_part.top();
            left_part.pop();
        }
        left[i]=cur_sum;
    }
    cur_sum=0;
    for (i=3*n-1;i>=0;i--)
    {
        right_part.push(a[i]);
        cur_sum+=a[i];
        if (right_part.size()>n)
        {
            cur_sum-=right_part.top();
            right_part.pop();
        }
        right[i]=cur_sum;
    }
    ll ans=-1e18;
    for (i=n-1;i<2*n;i++)
        ans=max(ans,left[i]-right[i+1]);
    cout<<ans<<endl;
}

Measured memory_bytes: 8312