akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define f first
#define s second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 100500;

int n, s, w, e;

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(5) << fixed;

	string S;
	cin >> S;
	for(char ch : S){
		if(ch == 'N')
			n = 1;
		if(ch == 'W')	
			w = 1;
		if(ch == 'S')
			s = 1;
		if(ch == 'E')
			e = 1;
	}

	if((n ^ s) + (w ^ e) == 0)
		cout << "Yes";
	else cout << "No";	
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}

Measured memory_bytes: 256
while true
	h, w = gets.split( " " ).map { | val | val.to_i }
	break if 0 == h && 0 == w
	pa1 = [ "#", "." ]
	pa2 = [ ".", "#" ]
	h.times { | i |
		if 0 == i%2
			w.times {  | i |
				print( "#{pa1[i%2]}" )
			}
			print( "\n" )
		else
			w.times {  | i |
				print( "#{pa2[i%2]}" )
			}
			print( "\n" )
		end
	}
	print( "\n" )
end

Measured memory_bytes: 6108
import java.io.*;
import java.util.Arrays;
    
class Main{
   
static final PrintWriter out=new PrintWriter(System.out);
static final int MOD=10007;
    
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] pic=new int[n];
line=br.readLine();
for(int i=0;i<n;i++) pic[i]=bit(line.charAt(i));
int[][] dp=new int[n][1<<3];
for(int i=0;i<1<<3;i++){
if((i&(1<<0))!=0&&(i&pic[0])!=0) dp[0][i]=1;
}
for(int i=1;i<n;i++){
for(int j=1;j<(1<<3);j++){
for(int k=1;k<(1<<3);k++){
if((k&pic[i])!=0){
if((j&pic[i])!=0) dp[i][k]+=dp[i-1][j];
else if((j&pic[i])==0&&(j&k)!=0) dp[i][k]+=dp[i-1][j];
dp[i][k]%=MOD;
}
}
}
}
int ans=0;
for(int i=1;i<1<<3;i++) ans+=dp[n-1][i];
out.println(ans%MOD);
out.flush();
}
}
  
public static int bit(char c){
if(c=='J') return 1<<0;
else if(c=='O') return 1<<1;
else return 1<<2;
}
}

Measured memory_bytes: 18636
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int r, g;
    cin >> r >> g;
    cout << 2*g - r << endl;

    return 0;
}



Measured memory_bytes: 256
import fractions
from functools import reduce

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

n, m = map(int, input().split())
a = list(map(int, input().split()))

a_2 = list(a[i] // 2 for i in range(n))
t = lcm_list(a_2)

if not all([(t // i) % 2 for i in a_2]):
    print(0)
    quit()

p = (m - t) // (2 * t) + 1
print(p)


Measured memory_bytes: 16344
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; ++i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)

const int MAX = 1e5+10;

ll N, W, w, v;
ll dp[MAX];
ll ans;

int main() {
  cin >> N >> W;
  dp[0] = 1;
  REP (i, N) {
    cin >> w >> v;
    for (int j = W-w; j >= 0; --j) if (dp[j] > 0)
      dp[j+w] = max(dp[j+w], dp[j]+v);
  }
  REP (i, W+1) ans = max(ans, 1ll*dp[i]);
  cout << ans-1 << endl;
}

Measured memory_bytes: 1024
def main():
    a, b, k = map(int, input().split())

    output_list = []

    for i in reversed(range(1,min(a,b)+1)):
        if a % i == 0 and b % i == 0:
            output_list.append(i)

    print(output_list[k-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string st;
    cin>>st;
    int a=0,b=0,c=0,d=0;
    for(int i=0;i<st.length();i++){
        if(st[i]=='N'){
            a++;
        }else if(st[i]=='S'){
            b++;
        }else if(st[i]=='W'){
            c++;
        }else{
            d++;
        }
    }
    if(((a&&b)||(!a&&!b))&&((c&&d)||(!c&&!d))){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

int rec(int l = 0, int r = n, int cnt = 0)
{
    if(l == r)
    {
        return 0;
    }

    if(r - 1 == l)
    {
        return h[l] - cnt;
    }

    int min_h = 200;
    range(i, l, r)
    {
        min_h = min(min_h, h[i]);
    }

    int ans = min_h - cnt;
    int left_edge = l;
    range(i, l, r)
    {
        if(h[i] <= min_h)
        {
            if(left_edge == i)
            {
                left_edge++;
            }
            else
            {
                ans += rec(left_edge, i, min_h);
                left_edge = i + 1;
            }
        }

        if (i == r - 1)
        {
            ans += rec(left_edge, r, min_h);
        }
    }

    return ans;
}

int main() {
    cin >> n;
    h.resize(n);
    rep(i, n) cin >> h[i];
    cout << rec() << endl;
    return 0;
}

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

#define FOR(i, a, b) for (int i = a; i < (int) b; i++) 
#define F0R(i, a) FOR (i, 0, a)
#define GO(to, a) for (auto to : a)

#define f first
#define s second
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;

const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};

const int m[] = {+31, +29, +31, +30, +31, +30, +31, +31, +30, +31, +30, +31};

map<long long, long long> dp;

long long solve (long long p) {
	if (p == 1) return 1;
	if (dp.find(p) != dp.end()) return dp[p];
	return dp[p] = 1 + solve (p / 2) + solve (p / 2);
}

int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long n;
	cin >> n;
	cout << solve (n) << '\n';
	return 0;
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N, K;
    cin >> N >> K;
    int h[N];
    for (int i = 0; i < N; i++) cin >> h[i];

    int dp[N];
    fill(dp, dp + N, INF);
    dp[0] = 0;

    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= K; j++) {
            if (i + j <= N - 1) {
                dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i + j]));
            }
        }
    }

    cout << dp[N-1] << endl;

    return 0;
}

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

const int N = 1e5 + 10;
typedef long long ll;
ll n, C;
ll a[N], b[N], x[N], v[N], sum[N];

int main() {
    scanf("%lld%lld", &n, &C);
    for (int i = 1; i <= n; i++) scanf("%lld%lld", &x[i], &v[i]);
    for (int i = 1; i <= n; i++)
        a[i] = a[i - 1] + v[i] - (x[i] - x[i - 1]);
    x[n + 1] = C;
    for (int i = n; i >= 1; i--)
        b[i] = b[i + 1] + v[i] - (x[i + 1] - x[i]);
    for (int i = 2; i <= n; i++)
        a[i] = max(a[i - 1], a[i]);
    for (int i = n - 1; i >= 1; i--)
        b[i] = max(b[i + 1], b[i]);
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, a[i] + b[i + 1] - x[i]);
        ans = max(ans, b[i] + a[i - 1] - (C - x[i]));
        ans = max(ans, a[i]);
        ans = max(ans, b[i]);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define per(i,m,n) for(lli i=m-1;i>=n;i--)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b==c||a+c==b||b+c==a)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int main(){
    LL x,k,d;
  	cin>>x>>k>>d;
  	if (x < 0) x = -x;
    	LL t = x / d;
      	if (k <= t){
        	cout<< x - k * d;
        }else{
          	LL tmp1 = x - t * d;
          	LL tmp2 = tmp1;
          	if (k >= t + 1){
              	tmp2 = d - tmp1;
            }
          	if (tmp2 < tmp1){
                if ((k - t - 1) % 2 == 0) cout<<tmp2<<endl;
                else cout<<tmp1<<endl;
            }else{
                if ((k - t) % 2 == 0) cout<<tmp1<<endl;
                else cout<<tmp2<<endl;
            }
        }
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define dump(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  ll ans = 0;
  for(int i = 0; i < n; i++) {
    bool sosuu = true;
    for(int j = 2; j <= sqrt(a[i]); j++) {
      if(a[i] % j == 0) {
        sosuu = false;
        break;
      }
    }
    if(sosuu) { ans++; }
  }

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


Measured memory_bytes: 3260
n=int(input())
A=list(map(int,input().split()))

if 1 not in A:
  print(-1)
else:
  ans,now,i=0,1,0
  while i<n:
    if A[i]==now:
      now+=1
    else:
      ans+=1
    i+=1
  print(ans)

Measured memory_bytes: 26396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int h, w;
P st, ed;
P move(P now, vector<vector<bool>> &board, int dir) {
  P adj = {now.first + dx[dir], now.second + dy[dir]};
  if(0 <= adj.first && adj.first < h && 0 <= adj.second && adj.second < w && board[adj.first][adj.second]) {
    return {-1, -1};
  }
  while(1) {
    now = {now.first + dx[dir], now.second + dy[dir]};
    if(0 <= now.first && now.first < h && 0 <= now.second && now.second < w) {
      if(now == ed) {
        return now;
      }
      if(board[now.first][now.second]) {
        board[now.first][now.second] = false;
        now = {now.first - dx[dir], now.second - dy[dir]};
        return now;
      }
    } else {
      return {-1, -1};
    }
  }
}
int solve(int cnt, P now, vector<vector<bool>> &board) {
  if(cnt == 10) {
    return INF;
  } else {
    int mi = INF;
    for(int i=0;i<4;++i) {
      P next = move(now, board, i);
      if(next == ed) {
        mi = cnt + 1;
        break;
      }
      if(next == make_pair(-1, -1)) {
        continue;
      }
      mi = min(mi, solve(cnt + 1, next, board));
      board[next.first + dx[i]][next.second + dy[i]] = true;
    }
    return mi;
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  while(1) {
    cin >> w >> h;
    if(h == 0) break;
    vector<vector<bool>> board(h, vector<bool>(w, false));
    for(int i=0;i<h;++i) {
      for(int j=0;j<w;++j) {
        int tmp; cin >> tmp;
        if(tmp == 1) {
          board[i][j] = true;
        } else if(tmp == 2) {
          st = {i, j};
        } else if(tmp == 3) {
          ed = {i, j};
        }
      }
    }
    int ans = solve(0, st, board);
    cout << (ans == INF ? -1 : ans) << endl;
  }
}


Measured memory_bytes: 3080
import math
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())

cnt = math.ceil(math.sqrt(N * 2))
if cnt * (cnt - 1) != N * 2:
    print('No')
    exit()

ans = np.zeros((cnt, cnt - 1), dtype=int)
ans[np.triu_indices(cnt - 1)] = np.arange(1, N + 1)
ans[1:].T[np.triu_indices(cnt - 1)] = np.arange(1, N + 1)
print('Yes')
print(cnt)
for r in ans:
    print(cnt - 1, *r)


Measured memory_bytes: 20912
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i<n; i++)
            a[i] = sc.nextInt();
        boolean[] stones = new boolean[k+1];
        for(int i = 0; i<=k; i++) {
            for(int x: a) {
                if(i>=x && !stones[i-x])
                    stones[i] = true;
            }
        }
        System.out.println(stones[k]?"First":"Second");
    }
}

Measured memory_bytes: 22868
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
bool prime[50022];
void eratos()
{
	memset(prime,true,sizeof(prime));
	prime[0]=false;
	prime[1]=false;
	for(int i=2;i*i<50022;i++)
	{
		if(!prime[i])continue;
		for(int j=i*2;j<50022;j+=i)
		{
			prime[j]=false;
		}
	}
	return;
}
int main()
{
	int n,k,s;
	eratos();
	while(scanf("%d",&n)!=EOF)
	{
		for(int i=n-1;;i--)
		{
			if(prime[i])
			{
				k=i;
				break;
			}
		}
		for(int i=n+1;;i++)
		{
			if(prime[i])
			{
				s=i;
				break;
			}
		}
		printf("%d %d\n",k,s);
	}
	return 0;
}

Measured memory_bytes: 1244
#include <iostream>
using namespace std;
int main( void )
{
	int h1, m1, s1, h2, m2, s2;
	while ( cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2 )
	{
		s1 += m1 * 60 + h1 * 3600;
		s2 += m2 * 60 + h2 * 3600;
		int s = s2 - s1;
		int h = s / 3600;
		s %= 3600;
		int m = s / 60;
		s %= 60;
		cout << h << " " << m << " " << s << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

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

  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    if (a % 2 == 1)
    {
      cout << "first" << endl;
      return 0;
    }
  }

  cout << "second" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    while(k--){
        vector<int> b(n+1,0);

        rep(i,n){
            b[max(i-a[i],0)]++;
            b[min(i+a[i]+1,n)]--;            
        }
        rep(i,n){
            b[i+1]+=b[i];
        }
        /*
        rep(i,n) cout<<b[i]<<" ";
        cout<<endl;
        */
        rep(i,n){
            a[i]=min(b[i],n);
        }
        bool ok=true;
        rep(i,n){
            if(a[i]!=n) ok=false;
        }
        if(ok){
            rep(i,n) cout<<a[i]<<" ";
            cout<<endl;
            return 0;
        }
    }

    rep(i,n){
        cout<<a[i]<<" ";
    }
    cout<<endl;
}

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

int main(){
	int n, prime[10000], flag[50005] = {}, cnt = 1;
	prime[0] = 2;
	flag[2] = 1;
	for (int i = 3; i < 50000; i += 2){
		int k = 0;
		for (int j = 3; j <= sqrt(i); j++) {
			if (i % j == 0){
				k = 1;
				break;
			}
		}
		if (!k) {
			flag[i] = 1;
			prime[cnt] = i;
			cnt++;
		}
	}
	while (1){
		cnt = 0;
		cin >> n;
		if (!n) break;
		for (int i = 0; prime[i] <= n / 2; i++){
			if (flag[n - prime[i]]) cnt++;
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1388
#define FNAME ""

#include <bits/stdc++.h>

#define hash padjf9srpi
#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (n); i++)
#define fornr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define forab(i, a, b) for (int i = (a); i < (b); i++)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
 
#ifdef _WIN32
    #define I64 "%I64d"
#else
    #define I64 "%lld"
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair <int, int> pii;                                                                                                                                                                                      
typedef vector <int> vi;

template <class T> T sqr(const T &a) {return a * a;}


char s[3000000];
LL k;

int main()
{
#ifdef LOCAL
    freopen(FNAME".in", "r", stdin);
    freopen(FNAME".out", "w", stdout);
#endif

	fgets(s, 3000000, stdin);
	scanf("%lld", &k);
	int n = strlen(s);
	while (isspace(s[n - 1]))n--;
	forn(i, n) {
	    if (!k)
	    	break;
		if (s[i] != 'a' && 'z' - s[i] + 1 <= k) {			
			k -= 'z' - s[i] + 1, s[i] = 'a';
		}	
	}
	k %= 26;
	fornr(i, n) {
		s[i] = (s[i] - 'a' + k) % 26 + 'a';
 		break;
	}
	printf("%s", s);
}



Measured memory_bytes: 512
fn main() {
    let st = read_vec::<String>();
    let ab = read_vec::<usize>();
    let u = read_vec::<String>();

    if st[0] == u[0] {
        println!("{} {}", ab[0]-1, ab[1]);
    } else if st[1] == u[0] {
        println!("{} {}", ab[0], ab[1]-1);
    } else {
        println!("{} {}", ab[0], ab[1]);
    }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <stdio.h>

#define N 102

int check(int s,int d,int v);

int root[N][N]; /* rooter path */
int visited[N]; /* already visited flag */

int que[N][2];  /* queue for bfs {id,TTL} */
int wp,rp;      /* write pointer, read pointer for queue */

int main(){
    int n,r,k,t;
    int p,s,d,v;
    int i,j;
    char c;
    int ans;

    /* init root */
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            root[i][j]=0;
        }
    }

    /* input */
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&r);
        scanf("%d",&k);
        for(j=0;j<k;j++){
            scanf("%d",&t);
            root[r][j] = t;
        }
    }


    scanf("%d",&p);
    for(i=0;i<p;i++){
        scanf("%d %d %d",&s,&d,&v);
        ans = check(s,d,v);
        printf(ans?"%d\n":"NA\n",ans);
    }
    return 0;
}
 
 
int check(int s,int d,int v){
    int i,ret,nows,nowv,nexts;

    for(i=0;i<N;i++)visited[i]=0;

    /* init que */
    wp=0;
    rp=0;

    visited[s]=1;
    /* push que */
    que[wp][0]=s;
    que[wp][1]=v;
    wp++;

    while(rp<wp){
        /* pop que */
        nows=que[rp][0];
        nowv=que[rp][1];
        rp++;

        if(nows==d) return v-nowv+1; /* goal(return num of rooter) */
        if(--nowv<=0) continue;/* TTL is too small */

        /* check next rooter */
        for(i=0;root[nows][i];i++){
            nexts=root[nows][i];

            if(visited[nexts]) continue; /* already visited */
            visited[nexts]=1;

            /* push que */
            que[wp][0]=nexts;
            que[wp][1]=nowv;
            wp++;
        }
    }

    return 0;/* can't alive */
}

Measured memory_bytes: 640
#include <stdio.h>

int primes[] = {11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381};

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    printf("%d%c", primes[i], (i + 1 == n ? '\n' : ' '));
  }
  return 0;
}

Measured memory_bytes: 128
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
x,y,z = map(int,input().split())

print(z,x,y)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する

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

int main(){
  int n; cin >> n;
  vector<bool> p(60000,true);
  for(int i = 2; i < 55560; i++){
    if(!p[i]) continue;
    for(int j = 2; j*i < 55560; j++){
      p[i*j] = false;
    }
  }
  vector<int> fp;
  for(int i = 2; i < 55560; i++){
    if(p[i] && i % 5 == 1) fp.push_back(i);
  }
  for(int i = 0; i < n; i++){
    cout << fp[i] << " ";
  }
}

Measured memory_bytes: 3568
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

struct UnionFind{
    v: Vec<usize>
}

impl UnionFind{
    fn new(n: usize) -> UnionFind{
        let mut v: Vec<usize> = Vec::new();
        for i in 0..n{
         v.push(i);
        }
        UnionFind{v:v}
    }

    fn find(&mut self, i: usize) -> usize{
        if self.v[i] == i{
            i
        }else{
            let ni = self.v[i];
            self.v[i] = self.find(ni);
            self.v[i]
        }
    }

    fn union(&mut self, i: usize, j: usize){
        let root_i = self.find(i);
        let root_j = self.find(j);
        self.v[root_i] = root_j;
    }
    
}

struct CombMod{
    fac: Vec<u64>,
    inv: Vec<u64>,
    finv: Vec<u64>,
    mmod: u64,
}

impl CombMod{
    pub fn new(max: u64, m: u64) -> CombMod{
        let max: usize = max as usize;
        let mut fac: Vec<u64> = vec![0;max+1];
        let mut finv: Vec<u64> = vec![0;max+1];
        let mut inv: Vec<u64> = vec![0;max+1];

        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;

        for i in 2..max+1{
            fac[i] = fac[i-1] * i as u64 % m;
            inv[i] = m - inv[m as usize %i] * (m/(i as u64)) % m;
            finv[i] = finv[i-1] * inv[i] % m;
        }
        
        CombMod{
            fac: fac,
            finv: finv,
            inv: inv,
            mmod: m,
        }
    }

    fn get(&self, n: u64, m: u64) -> u64{
        assert!(n >= m && n != 0 && m != 0);
        self.fac[n as usize] * self.finv[m as usize] % self.mmod
            * self.finv[(n-m) as usize] % self.mmod
    }
}


fn main(){
    let n: usize = read_as_vec()[0];
    let v: Vec<i32> = read_as_vec();
    let c: Vec<i32> = read_as_vec();

    let mut profits: Vec<i32> = vec![0;n];

    for i in 0..n{
        profits[i] = v[i] - c[i];
    }

    profits.sort();

    println!("{}", profits.into_iter().skip_while(|x| *x < 0).sum::<i32>());
}


Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define rep(i,n) for(ll i=0;i<n;i++)
typedef long long ll;
using namespace std;

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

// テーブルを作る前処理
/*
void COMinit() {
    fac[0] = fac[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
    }
}
*/

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}

void chmax(ll &a,const ll &b){
    if(a<b) a=b;
}
void chmin(ll &a,const ll &b){
    if(a>b) a=b;
}


int main()
{

    ll N;
    cin >>N;

    ll a[N],tot=0;

    rep(i,N){
        cin >> a[i];
        tot = tot^a[i];
    }

    rep(i,N-1){
        ll ans = tot^a[i];
        cout << ans << " ";

    }

    ll ans = tot^a[N-1];
    cout << ans << endl;
  



    return 0;


}

Measured memory_bytes: 5184
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <string>
#include <functional>
#include <cassert>
#include <cmath>
#define SIZE 600005
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll inv[SIZE],fac[SIZE],finv[SIZE];
void make()
{
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<SIZE;i++)
	{
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]*(ll) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
ll C(int a,int b)
{
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
ll solve(int n,int m,int L)
{
	ll ret=C(n+L,n);
	//printf("%lld\n",ret);
	for(int t=0;(t+1)*m<=L;t++)
	{
		int zan=L-(t+1)*m;
		int a=n-m,b=m;
		for(int k=0;k*t<=L&&k<=a;k++)
		{
			if(zan<0) break;
			ll vl=C(zan+n,n)*C(a,k)%MOD*C(n,a)%MOD;
			if(k%2==1) ret+=vl;
			else ret+=MOD-vl;
			ret%=MOD;
			zan-=t+1;
		}
		zan=L-(t+2)*m;
		for(int k=0;k*t<=L&&k<=a;k++)
		{
			if(zan<0) break;
			ll vl=C(zan+n,n)*C(a,k)%MOD*C(n,a)%MOD;
			if(k%2==0) ret+=vl;
			else ret+=MOD-vl;
			ret%=MOD;
			zan-=t+1;
		}
	}
	//printf("%d %d %d : %lld\n",n,m,L,ret);
	return ret;
}
int main()
{
	make();
	int n,m,l,r;
	scanf("%d %d %d %d",&n,&m,&l,&r);
	printf("%lld\n",(solve(n,m,r)-solve(n,m,l-1)+MOD)%MOD);
	return 0;
}


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

using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
//int dx[]={+1,-1,+0,+0};///Four Directions
//int dy[]={+0,+0,+1,-1};///Four directions
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions

//int mark[10007];vi prime;void seive(){for(int i=2;i<10000;i++){if(mark[i]==0){prime.pb(i);for(int j=i+i;j<=10000;j+=i)mark[j]=1;}}}

//freopen("input.txt", "r", stdin);

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

   ll w,s;
   cin>>s>>w;
   if(w>=s) cout<<"unsafe"<<endl;
   else cout<<"safe"<<endl;

   End;
}


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

long long solve(long long h) {
  if (h == 1) return 1;
  return 1 + 2 * solve(h/2);
}

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  long long h;
  cin >> h;

  cout << solve(h) << '\n';
}  


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  long double a, b;
  cin >> a >> b;
  ll ans = a * b;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3732
N = int(input())

order_city_point = []
for i in range(1,N+1):
    city,point = input().split()
    order_city_point.append([i,city,int(point)]) 

order_city_point.sort(reverse=True,key=lambda x: x[2])
order_city_point.sort(key=lambda x:x[1])

for order,_,__ in order_city_point:
    print(order)



Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
const ll mod=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  ll a,b,c,n,m;
  cin>>a>>b>>c>>m>>n;
  ll ret=longinf;
  rep(i,n+1){
    ll res=i*b;
    res+=2*(n-i)*c;
    ll num=max(0LL,m-(n-i));
    if(a<=2*c)res+=num*a;
    else res+=2*num*c;
    ret=min(res,ret);
    }
  cout<<ret<<endl;
  return 0;
  }

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

using namespace std;

int main(void) {
	int a, b, c;

	cin >> a >> b;

	c = a + b;

	if (c < 10) {
		cout << c << endl;
	}

	else
	{
		cout << "error" << endl;
	}

	return 0;
}

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

using namespace std;

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

#define PI (2*acos(0.0))
#define eps 1e-9
#define pcase cout<<"Case "<<++cs<<":"
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define mp make_pair
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007


int main()
{
    int i = 0, j = 0, cs = 0, in;
    string s; cin>>s;
    int ans = 0;
    if(s == "SAT") ans = 1;
    if(s == "SUN") ans = 7;
    if(s == "MON") ans = 6;
    if(s == "TUE") ans = 5;
    if(s == "WED") ans = 4;
    if(s == "THU") ans = 3;
    if(s == "FRI") ans = 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	pushpush()
}

func pushpush() {
	var n = nextInt()
	var a = make([]int,n)
	for i :=0; i<n; i++ {
		a[i] = nextInt()
	}

	for i:=n-1; i>=0; i-=2 {
		fmt.Print(a[i])
		fmt.Print(" ")
	}
	var start = 0
	if n % 2 == 1 {
		start = 1
	}
	for i:=start; i<n; i+=2 {
		fmt.Print(a[i])
		if(i+2<n) {
			fmt.Print(" ")
		}
	}
}

Measured memory_bytes: 9344
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



int main(){
  int H,W,K;
  cin >> H >> W >> K;
  char C[H][W];
  int sum = 0;
  int ans = 0;
  rep(i,H) {
	rep(j,W) {
	  cin >> C[i][j];
	  if(C[i][j] == '#') sum++;
	}
  }
  for(int bith = 0; bith < (1<<H); bith++) {
	for(int bitw = 0; bitw < (1<<W); bitw++) {
	  int tmp = sum;
	  rep(i,H) {
		rep(j,W) {
		  if(bith & (1<<i) || bitw & (1<<j)) {
			if(C[i][j] == '#') tmp--;
		  }
		}
	  }
	  if(tmp == K) ans++;
	  //	  cout << tmp << endl;
	}
  }
  cout << ans << endl;
  return 0;
}



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

int main() {
  int N, sum = 0;
  cin >> N;
  for(int i=0; i < N; i++){
    int l, r;
    cin >> l >> r;
    sum += (r - l + 1);
  }
  cout << sum <<endl;
 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll n,k;
	cin>>n>>k;
	ll arr[n];
	for(int a=0;a<n;a++)
	cin>>arr[a];
	if(k>=n)
	cout<<"0";
	else 
	{
		sort(arr,arr+n);
		ll y=0;
		for(int a=0;a<n-k;a++)
		y=y+arr[a];
		cout<<y;
	}
	return 0;
}



Measured memory_bytes: 1920
//JSD
#include<algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#define ll long long
#define Mod 1000000007
using namespace std;
ll modular_exponentiation(ll a,ll b){
	if(b==0){
		return 1;
	}
	if(b==1){
		return a%Mod;
	}
	ll x=modular_exponentiation(a,b/2);
	x=(x*x)%Mod;
	if(b%2==1){
		x=(x*a)%Mod;
	}
	return x;
}
ll modular_divison(ll a,ll b){
    return (modular_exponentiation(b,Mod-2)*a)%Mod;
}

bool isPrime(ll n){
	if(n<=1) return 0;
	if(n==2 or n==3 ) return 1;
	if(n%2==0 or n%3==0) return 0;
	for(ll i=5;i*i<=n;i+=6){
		if(n%i==0 or n%(i+2)==0)
			return 0;
	}
	return 1;
}
struct primeFactorInfo{
	map<ll,ll> M;
	set<ll> S;
};
primeFactorInfo pfs(ll n){
	primeFactorInfo p;
	for(ll i=2;i<=sqrt(n);i++){
		if(n%i==0){
			p.S.insert(i);
			while(((n%i)==0)){
				p.M[i]++;
				n/=i;
			}
		}
	}
	if(n>1){
		p.M[n]++;
		p.S.insert(n);
	}
	return p;
}
void sieve(ll n,vector<ll>& v){
	bool isComposite[n+1]={0};
	isComposite[0]=isComposite[1]=1;
	for(ll i=2;i*i<=n;i++){
		if(!isComposite[i]){
			v.push_back(i);
			for(int j=2;j*i<=n;j++){
				isComposite[i*j]=1;
			}
		}
	}
}
primeFactorInfo pfsUsingSieve(ll n){
	primeFactorInfo p;
	vector<ll > v;
	sieve(n,v);
	for(auto i: v){
		if(n%i==0){
			p.S.insert(i);
			while(((n%i)==0)){
				p.M[i]++;
				n/=i;
			}
		}
	}
	if(n>1){
		p.M[n]++;
		p.S.insert(n);
	}
	return p;
}
map<ll,ll> dp;
ll solve(ll n){
	if(dp.find(n)!=dp.end())
		return dp[n];
	ll ans=2*solve(n/2)+1;
	dp[n]=ans;
	return ans;
}
int main(){
dp[1]=1;
dp[0]=0;
	ll h;
	cin>>h;
	cout<<solve(h);
	return 0;
}


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

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

    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    std::sort(a.begin(), a.end(), std::greater<int>());

    int sum[2] = { 0 };

    for (int i = 0; i < n; i++) {
        sum[i % 2] += a[i];
    }

    std::cout << sum[0] - sum[1] << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int y,m,d;
  while(scanf("%d%d%d",&y,&m,&d)!=-1){
    if(y<1868)
      puts("pre-meiji");
    else if(y==1868){
      if(m<9)
	puts("pre-meiji");
      else if(m==9){
	if(d<8)
	  puts("pre-meiji");
	else
	  printf("meiji %d %d %d\n",y-1867,m,d);
      }else
	printf("meiji %d %d %d\n",y-1867,m,d);
    }else if(y<1912)
      printf("meiji %d %d %d\n",y-1867,m,d);
    else if(y==1912){
      if(m<7)
	printf("meiji %d %d %d\n",y-1867,m,d);
      if(m==7){
	if(d<=29)
	  printf("meiji %d %d %d\n",y-1867,m,d);
	else
	  printf("taisho %d %d %d\n",y-1911,m,d);
      }else
	printf("taisho %d %d %d\n",y-1911,m,d);
    }else if(y<1926)
      printf("taisho %d %d %d\n",y-1911,m,d);
    else if(y==1926){
      if(m<12)
	printf("taisho %d %d %d\n",y-1911,m,d);
      if(m==12){
	if(d<=24)
	  printf("taisho %d %d %d\n",y-1911,m,d);
	else
	  printf("showa %d %d %d\n",y-1925,m,d);
      }else
	printf("showa %d %d %d\n",y-1925,m,d);
    }else if(y<1989)
      printf("showa %d %d %d\n",y-1925,m,d);
    else if(y==1989){
      if(m<1)
	printf("showa %d %d %d\n",y-1925,m,d);
      if(m==1){
	if(d<=7)
	  printf("showa %d %d %d\n",y-1925,m,d);
	else
	  printf("heisei %d %d %d\n",y-1988,m,d);
      }else
	printf("heisei %d %d %d\n",y-1988,m,d);
    }else
      printf("heisei %d %d %d\n",y-1988,m,d);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<long long,long long> pll;

int main(){
    int n,rta=0,k;
    cin >> n >> k;
    int arr[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    sort(arr,arr+n);
    for(int i=0;i<k;i++){
        rta+=arr[i];
    }
    cout << rta << endl;
  }



Measured memory_bytes: 3648
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[]s  = new String[n];
   
    for(int i=0; i<n; i++) {
    	s[i] = sc.next();
    	    }
    Arrays.sort(s);
    int cou = 1;
    for(int i=0; i<n-1; i++) {
    	if(!s[i]. equals (s[i+1])) {
    		cou++;
    	}
    }
    	System.out.println(cou);
      }
}


Measured memory_bytes: 71088
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

/* デカい配列はここで宣言 */

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    priority_queue<pair<ll, ll> > q;
    map<ll, ll> m;
    for (ll i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        m[temp]++;
    }

    for (auto t : m)
    {
        q.push(make_pair(t.second, t.first));
    }
    while (q.top().first > 1 && q.size() > 1)
    {
        pair<ll, ll> t = q.top();
        q.pop();
        pair<ll, ll> p = q.top();
        q.pop();
        t.first--;
        p.first--;
        q.push(t);
        if (p.first > 0)
        {
            q.push(p);
        }
    }
    cout << q.size() << endl;
}


Measured memory_bytes: 8696
#include <iostream>

using namespace std;

int main()
{
  int X,N;
  cin >> X >> N;
  if(N == 0)
  {
    cout << X << endl;
  }
  else
  {
    int a[N];
    for(int n = 0;n< N;n++)
    {
      cin >> a[n];
    }
    int iBuf;
    int iBuf2 = -1;
    for(int i=0;i < 101;i++)
    {
      iBuf = X - i;
      for(int j = 0;j < N;j++)
      {
        if(iBuf == a[j])
        {
          iBuf2 = iBuf;
        }
      }
      if(iBuf2 != iBuf)
      {
        break;
      }
      iBuf = X + i;
        for(int j = 0;j < N;j++)
      {
        if(iBuf == a[j])
        {
          iBuf2 = iBuf;
        }
      }
      if(iBuf2 != iBuf)
      {
        break;
      }
    }
    cout << iBuf << endl;
  }
  return 0;
}

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

int n, x;

int main()
{
	while (scanf("%d", &n) != EOF)
	{
		x = 0;
		for (int i = 1, y; i <= n; ++i)
		{
			scanf("%d", &y);
			x += y & 1;
		}
		puts(x ? "first" : "second"); 
	}
	return 0;
}


Measured memory_bytes: 384
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=1e7+2;
fast;
ll ans;
ll n,m,l,r;
void solve()
{
   cin>>n>>m;
  r=INT_MAX;
   for(int i=0;i<m;i++)
    {
        ll a,b;cin>>a>>b;
        l=max(l,a);r=min(r,b);
    }
    cout<<max(0ll,r-l+1)<<endl;
}

int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
   // int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
from collections import deque
d = deque()
N = int(input())
array = list(map(int,input().split()))
for i in range(N):
    if i%2==0:
        d.appendleft(array[i])
    else:
        d.append(array[i])
if N%2==0:
    d = reversed(d)
ans = ' '.join(map(str,d))
print(ans)

Measured memory_bytes: 36260
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <stdlib.h>
#include <deque>
#include <cstdint>
using namespace std;

int main () {
  int n;
  cin >> n ;
  int d[n];
  for (int i = 0; i < n; i++){
    int t;
    cin >> t;
    d[i] = t;
  }
  sort(d, d + n, greater <int>());
  int k;
  k = d[n/2-1]- (d[n/2]);
  cout << k;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;

long ggd(long a, long b) {//最小公倍数，最大公約数
	if(a<b)swap(a,b);
	if (b == 0) {
		return a;			
	}
	return ggd(b, a % b);
}
long lcm(long number1,long number2){
	return number1/ggd(number1,number2)*number2;	
}

int main(){ 
  int a,b;
  std::cin >> a>>b;
  std::cout << lcm(a,b) << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

int gcd(int a,int b){
  if(a<b) swap(a,b);
  if(a%b==0) return b;
  else return gcd(b,a%b);
}

int lcm(int a,int b){
  return (a*b)/gcd(a,b);
}


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  cout<<lcm(a,b)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define   ull unsigned long long
struct ss{
	int a,b;
}    c[100005];
bool cmp(ss x,ss y)
{
	return x.a<y.a;
}
int n,m;
ull ans;
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>c[i].a>>c[i].b;
    sort(c+1,c+n+1,cmp);
  	for(int i=1;i<=n;i++)
  	{
  		int d=min(m,c[i].b);
  		ans+=(ull)d*c[i].a;
  		m-=d;
  		if(!m)break;
  	}
  	printf("%llu\n",ans);
  	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;
int h[110];
int main(){
	int i,j,n,ans = 0;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> h[i];
	}
	while(1){
		int num = 0;
		for(i=0;i<n;i++){
			if(i!=0 && h[i-1]!=0 && h[i]==0) num++;
			if(i==n-1 && h[i]!=0) num++;
		}
		ans +=num;
		for(i=0;i<n;i++){
			if(h[i]) h[i]--;
		}
		for(i=0;i<n;i++){
			if(h[i]) break;
			if(i==n-1){
				cout << ans << endl;
				return 0;
			}
		}
	}
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define zeroes(x) memset(x,0,sizeof(x))
typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;

int main()
{		
	/*
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif*/
    IOS
   ll a,b;
   cin>>a>>b;
   cout<<max(a+b,max(a-b,a*b));




}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin>>n>>m;
    vector<ll> x(n),y(n),z(n);
    rep(i,n)cin>>x[i]>>y[i]>>z[i];
    ll ans=0;
    for(int tmp=0;tmp<1<<3;tmp++){
        bitset<3> s(tmp);
        vector<ll> d(n);
        int po[3];
        for(int i=0;i<3;i++){
            if(s.test(i))po[i]=1;
            else po[i]=-1;
        }
        for(int i=0;i<n;i++)d[i]=x[i]*po[0]+y[i]*po[1]+z[i]*po[2];
        sort(d.begin(),d.end(),greater<ll>());
        ll sum=0;
        for(int i=0;i<m;i++)sum+=d[i];
        if(sum>ans)ans=sum;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256