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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s; cin >> s;
	int K; cin >> K;
	vector<string> cnds;
	for (int len = 1; len <= min(5, int(s.size())); len++) {
		for (int i = 0; i+len <= int(s.size()); i++) {
			cnds.push_back(s.substr(i, len));
		}
	}
	sort(cnds.begin(), cnds.end());
	cnds.erase(unique(cnds.begin(), cnds.end()), cnds.end());
	cout << cnds[K-1] << '\n';

	return 0;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------

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

  int n,a,b; cin >> n >> a >> b;
  int mx = min(a,b);
  if(a+b>n){
    cout << mx << " " << a+b-n << endl;
  }else{
    cout << mx << " " << 0 << endl;
  }


  return 0;
}


Measured memory_bytes: 256
X = int(input())

if 400 <= X < 600:
  print(8)
elif 600 <= X < 800:
  print(7)
elif 800 <= X < 1000:
  print(6)
elif 1000 <= X < 1200:
  print(5)
elif 1200 <= X < 1400:
  print(4)
elif 1400 <= X < 1600:
  print(3)
elif 1600 <= X < 1800:
  print(2)
elif 1800 <= X < 2000:
  print(1)

Measured memory_bytes: 9184
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

const int N = 705;
const int M = 490005;
int n, m, u, v, ans = 0x7fffffff;
bool g[N][N], s[N], t[N];
int col[N], cnt[2];

void dfs(int x, int c){
    col[x] = c;
    cnt[c == 1]++;
    for(int i = 1; i <= n; i++){
        if(i == x || g[x][i])   continue;
        if(!col[i]) dfs(i, -c);
        else if(col[i] == c){
            puts("-1");
            exit(0);
        }
    }
}

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; i++){
        scanf("%d%d", &u, &v);
        g[u][v] = g[v][u] = 1;
    }
    s[0] = 1;
    for(int i = 1; i <= n; i++){
        if(col[i])  continue;
        cnt[0] = cnt[1] = 0;
        dfs(i, 1);
        memset(t, 0, sizeof t);
        for(int j = 0; j <= n; j++){
            t[j+cnt[0]] |= s[j];
            t[j+cnt[1]] |= s[j];
        }
        for(int j = 0; j <= n; j++)
            s[j] = t[j];
    }
    for(int i = 0; i <= n; i++)
        if(s[i])
            ans = min(ans, i*(i-1)/2 + (n-i)*(n-i-1)/2);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){

  int N,i,j,k,minj,count=0;
  char *v;

  scanf("%d", &N);
  char *A[N],*B[N],str[100];

  for(i=0;i<N;i++){
    scanf("%s",str);
    A[i]=(char *)malloc(sizeof(char) * (strlen(str)+1));
    B[i]=(char *)malloc(sizeof(char) * (strlen(str)+1));
    strcpy(A[i],str);
    strcpy(B[i],str);
  }
  
  /*BubbleSort*/
  for( i = 0 ; i < N-1 ; i++){
    for( j = N-1 ; j > i ; j--){      
      if(atoi(&A[j][1]) < atoi(&A[j-1][1])){
     	v = A[j];
       	A[j] = A[j-1];
       	A[j-1] = v;	
      }
    }
  }
  printf("%s",A[0]);
  for(k=1;k<N;k++)printf(" %s",A[k]);
  printf("\nStable\n");
  
  /*SelctionSort*/
  for(i = 0 ; i <= N-1 ; i++){
    minj = i;
    for( j = i ; j <= N-1 ; j++){
      if(atoi(&B[j][1]) < atoi(&B[minj][1]))minj = j;
    }
    if(i != minj){
      v = B[i];
      B[i] = B[minj];
      B[minj] = v;
    }
  }
  printf("%s",B[0]);
  for(k=1;k<N;k++)printf(" %s",B[k]);
  printf("\n");

  for(i = 0 ; i <= N-1 ; i++){
    if(A[i][0] != B[i][0] || A[i][1] != B[i][1]){
      printf("Not stable\n");
      count++;
      break;
    }
  }
  if(count==0)printf("Stable\n");
  
 return 0;
}



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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char& ch) {
	string s = "";
	s += ch;
	return "'" + s + "', ";
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL_DEFINE
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
   
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
typedef pair<int, int> pii;
const int mod = (int) 1000000007; // 998244353;
const int inf = (int) 2e18;



int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	
	int a;
	cin >> a;
	cout << a + (a * a) + (a * a * a) << '\n';
	
	return 0;
}






Measured memory_bytes: 3664
N,M=map(int, input().split())
H=list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(int(M))]

AB_unique=list(map(list, set(map(tuple, AB))))

AB_road=[[] for i in range(N)]
for AB in AB_unique:
    if H[AB[0]-1] > H[AB[1]-1]:
        AB_road[AB[1]-1].append(AB[0])
    elif H[AB[0]-1] < H[AB[1]-1]:
        AB_road[AB[0]-1].append(AB[1])
    else:
        AB_road[AB[1]-1].append(AB[0])
        AB_road[AB[0]-1].append(AB[1])

print(AB_road.count([]))

Measured memory_bytes: 127268
N, M = map(int, input().split())

A = []

for i in range(N):
    x, y, z = map(int, input().split())
    A.append([x, y, z])

res = 0

for a in [0, 1]:
    for b in [0, 1]:
        for c in [0, 1]:
            X = []
            for i in range(N):                
                x = A[i][0] if a == 0 else -A[i][0]
                y = A[i][1] if b == 0 else -A[i][1]
                z = A[i][2] if c == 0 else -A[i][2]
                X.append(x+y+z)
            X.sort(reverse=True)
            res = max(res, sum(X[:M]))

print(res)

Measured memory_bytes: 3188
<?php

fscanf(STDIN, '%d', $w);
fscanf(STDIN, '%d', $n);
$arr = range(1, $w);
for ($i = 0; $i < $n; $i++) {
    $line = trim(fgets(STDIN));
    sscanf($line, '%d,%d', $a, $b);
    $tmp = $arr[$a - 1];
    $arr[$a - 1] = $arr[$b - 1];
    $arr[$b - 1] = $tmp;
}
echo implode(PHP_EOL, $arr), PHP_EOL;

Measured memory_bytes: 6592
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y,ans=0;
	cin>>x>>y;
	if(x==1 && y==1) ans+=400000;
	if(x==1) ans+=300000;
	if(x==2) ans+=200000;
	if(x==3) ans+=100000;
	x=y;
	if(x==1) ans+=300000;
	if(x==2) ans+=200000;
	if(x==3) ans+=100000;
	cout<<ans;
	return 0;	
}

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

int main() {
  int a, b, c;
  set<int> s;

  cin >> a >> b >> c;

  s.insert(a);
  s.insert(b);
  s.insert(c);
  
  int ans = s.size();

  cout << ans << endl;

  return 0;
}

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

//Function Macros:
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main()
{
    int N;
    cin >> N;
    vector<int> H(N);
    int mx = 0, cnt = 0;
    rep(i, N)
    {
        cin >> H[i];
        if (i >= 1 && (H[i] <= H[i - 1]))
        {
            cnt++;
        }
        else if (i >= 1)
        {
            mx = max(mx, cnt);
            cnt = 0;
        }

        if (i == N-1)
        {
            mx = max(mx, cnt);
        }
    }
    cout << mx << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

int main(){
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	if(A <= C && B >= C){
		if(B <= D){
			cout << B - C << endl;
		} else {
			cout << D - C << endl;
		}
	} else if(A >= C && A <= D){
		if(B >= D){
			cout << D - A << endl;
		} else {
			cout << B - A << endl;
		}
	} else{
		cout << 0 << endl;
	}
}


Measured memory_bytes: 256
#親ー子の順に書かれてるか否かめっちゃ重要なのになあ
n,q = map(int,input().split())

peer = [[] for _ in range(n)]
for i in range(n-1):
  a,b = (map(int,input().split()))
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)

pq = [0 for _ in range(n)]
for i in range(q):
  p,x = map(int,input().split())
  p -= 1
  pq[p] += x

now = [0]
ans = pq
now = [0]
mom = [0 for _ in range(n)]
mom[0] = 1
while now != []:
  last = now
  now = []
  for x in last:
    for y in peer[x]:
      if mom[y] == 0:
        now.append(y)
        mom[y] = 1
        ans[y] += ans[x]

print(' '.join(list(map(str,ans))))

Measured memory_bytes: 66832
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	ll A, B, N;
	cin >> A >> B >> N;


	ll kotae = 0;
	N = min(N, B);

	if (A >= B) {

		rep1(i, N) {
			ll tmp = (A * i / B) - A * (i / B);
			chmax(kotae, tmp);
		}
	}
	else {

		ll k = 1;
		ll tmp = ((B * k + A - 1) / A);
		while (tmp <= N) {

			ll tmp2 = (A * tmp / B) - A * (tmp / B);
			chmax(kotae, tmp2);
			k++;
			tmp = ((B * k + A - 1) / A);

		}


	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int dx[] = {1,	 -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 1e4 + 211;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

int n, ans;

main () {				
	cin >> n;
	if (n & 1) {
		cout << 0 << endl;
		return 0;
	}

	
	n /= 2;

	int p = 1;
	forn (i, 1, 25) {
		p *= 5;
		ans += n / p;
	}

	cout << ans << endl;
		
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <math.h>
#include <limits.h>

using namespace std;

typedef long long ll;

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 main(void) {
    double A, B;
    int H, M;
    cin >> A >> B >> H >> M;

    double minutes = H * 60 + M;

    double ta = M_PI / 30 * minutes;
    double tb = M_PI / (30 * 12) * minutes;
    // double ta = 6 * minutes % 360;
    // double tb = (6 / 12 * minutes;

    printf("%.10f\n", sqrt(A * A + B * B - 2 * A * B * cos(ta - tb)));

    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int n; 
    cin>>n;
    if(n==2){
        int A,B;
        cin>>A>>B;
        cout<<A+B<<endl;
    }
    else{cout<<"Hello World"<<endl;}
    return 0;
}

Measured memory_bytes: 256
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <set>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 100001;
const int INF = 1000000001;

struct Interval {
    int left, right;
    bool operator < (const Interval& r) const {
        return left != r.left ? left < r.left : right < r.right;
    }
};

int n;
Interval a[MAX];
multiset <int> q;
int minR, maxL;
int leftIdx, rightIdx;
int leftBorder;

int eval() {
    int ret = 0;
    ret += max(0, minR - leftBorder + 1);
    auto it = q.begin();
    ret += max(0, *it - maxL + 1);
    return ret;
}

int solve() {
    sort(a, a + n);
    minR = +INF, maxL = -INF;
    for (int i = 0; i < n; i++) {
        minR = min(minR, a[i].right);
        if (minR == a[i].right)
            leftIdx = i, leftBorder = a[i].left;
        maxL = max(maxL, a[i].left);
        if (maxL == a[i].left)
            rightIdx = i;
    }
//    fprintf(stderr, "minR = %d, maxL = %d\n", minR, maxL);
    
    int ans = 0;
    multiset <int> L, R;
    for (int i = 0; i < n; i++) {
        L.insert(a[i].left);
        R.insert(a[i].right);
    }
    for (int i = 0; i < n; i++) {
        L.erase(L.find(a[i].left));
        R.erase(R.find(a[i].right));
        auto lit = L.end(); lit--;
        auto rit = R.begin();
        ans = max(ans, a[i].right - a[i].left + 1 + max(0, *rit - *lit + 1));
        L.insert(a[i].left);
        R.insert(a[i].right);
    }
//    fprintf(stderr, "Initial answer: %d\n", ans);
//    fprintf(stderr, "Excluded [%d, %d]\n", a[leftIdx].left, a[leftIdx].right);

    for (int i = 0; i < n; i++) {
        if (i == leftIdx)
            continue;
        q.insert(a[i].right);
//        fprintf(stderr, "  >> adding %d\n", a[i].right);
    }
    
    ans = max(ans, eval());
//    fprintf(stderr, "  >> answer: %d\n", eval());
    
    for (int i = 0; i < n; i++) {
        if (i == leftIdx || i == rightIdx)
            continue;
//        fprintf(stderr, "Removing [%d, %d]\n", a[i].left, a[i].right);
        leftBorder = max(leftBorder, a[i].left);
        q.erase(q.find(a[i].right));
        ans = max(ans, eval());
//        fprintf(stderr, "  >> answer: %d\n", eval());
    }
    return ans;
}

int main(void) {
//	in = fopen("B.in", "rt");
	
	fscanf(in, "%d", &n);
	for (int i = 0; i < n; i++) {
	    fscanf(in, "%d %d", &a[i].left, &a[i].right);
    }
    fprintf(out, "%d\n", solve());
	
	return 0;
}

Measured memory_bytes: 15104
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    string s;
  cin>>s;
  int t=s.length();
  bool jud=true;
  for(int i=0;i<t;i++){
    for(int j=0;j<t;j++){
		if(j!=i){
          if(s[i]==s[j]){
            jud=false;
            goto a;
          }
        }
    }
  }
  a:
  if(jud==true){
	cout<<"yes";
  }else{
	cout<<"no";
  }
    return 0;
}

Measured memory_bytes: 256
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65
//おまじない



int main() {

	ull n;
	ull lucas[87] = { 0 };
	lucas[0] = 2, lucas[1] = 1;

	cin >> n;

	rep(i, 0, n+1) {
		if (i >= 2) {
			lucas[i] = lucas[i - 1] + lucas[i - 2];
		}
	}

	cout << lucas[n] << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def main():
    s = input()
    q = int(input())

    hanten = 0 # 偶数なら正常、 奇数なら反転状態

    front = "" # リストの前に追加するのは、O(n)なので避ける
    back = ""

    for _ in range(q):
        tmp = readline().split()
        if len(tmp) == 1:
            hanten ^= 1
        else:
            if hanten: # 反対ver
                if tmp[1] == '1':
                    back += tmp[2]
                else:
                    front += tmp[2]
            else: # 正常
                if tmp[1] == '1':
                    front += tmp[2]
                else:
                    back += tmp[2]

    if hanten == 0:
        print(front[::-1] + s + back)
    else:
        print((front[::-1] + s + back)[::-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 4468
//To debug :  g++ -g file.cpp -o code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807;
#define big1 LONG_MAX
#define big2 INT_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 INT_MIN
#define sma3 -1000000000;
#define mp make_pair
#define mt make_tuple
#define dub double
#define ivec vector<int>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
	FAST

	int n,i,k,val,j;

	cin>>n>>k;

	int arr[n+1],ans[n+1]={0};

	rep(i,1,n+1)
		cin>>arr[i];

	arr[0] = INT_MAX;

	ans[0] = 0;
	ans[1] = 0;

	rep(i,2,n+1)
	{

		val = ans[i-1] + abs(arr[i]-arr[i-1]);


		for(j=(i-2);j>=1 && (i-j)<=k;--j)
		{

			val = min(val,ans[j]+abs(arr[i]-arr[j]));
		}

		ans[i] = val;



		//ans[i] = min(ans[i-1]+abs(arr[i]-arr[i-1]),ans[i-2]+abs(arr[i]-arr[i-2]));
	}


	cout<<ans[n]<<"\n";





	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    int ans[10] = {1, 1, 0, 2, 0, 0, 1, 0, 1, 0};
    if(ans[n%10] == 0)cout << "hon" << endl;
    if(ans[n%10] == 1)cout << "pon" << endl;
    if(ans[n%10] == 2)cout << "bon" << endl;
}

Measured memory_bytes: 3596
-- Try AtCoder
-- author: Leonardone @ NEETSDKASU

yes = "Yes"
no  = "No"

search ch tp = search' $ snd tp where
    search' (x:xs)
        | x == ch   = (True  && fst tp, xs)
        | otherwise = search' xs
    search' []      = (False && fst tp, [])

searchC = search 'C'
searchF = search 'F'

answer (True, _)  = yes
answer (False, _) = no

main = putStrLn . answer . searchF . searchC . (,) True =<< getLine



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

map<ll, ll> prime_factors(ll n) {
    map<ll, ll> res;
    if(n == 1) { // n=1 の素因数分解は n^1
        res[n] = 1;
        return res;
    }
    for(ll i = 2, _n = n; i*i <= _n; ++i) {
        while(n % i == 0) {
            ++res[i]; // 素数i^{res[i]}
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}

ll count (ll n) {
    ll i = 1;
    ll sum = 1;
    ll cnt = 0;
    while (sum <= n) {
        i++;
        cnt++;
        sum += i;
    }
    return cnt;
}


int main(){
    ll n;
    cin >> n;
    if(n == 1) {cout << 0 << endl; return 0;}
    map<ll, ll> keep = prime_factors(n);
    ll ans = 0;
    for(auto p : keep) {
        ans += count(p.second);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int main(){
    char c[3][3];
    rep(i,3) rep(j,3) cin >> c[i][j];

    cout << c[0][0] << c[1][1] << c[2][2] << endl;
} 

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	_Bool flag[50000];
	int prime[10000];
	int i, j;
	int n;
	int count;
	int max;
	for (i = 2; i <= 3 || i <= sqrt(50000); i++) {
		for (j = 2; i * j <= 50000; j++) {
			flag[i*j-1] = 1;
		}
	}
	j = 0;
	for (i = 2; i < 50000; i++) {
		if (!flag[i-1]) {
			prime[j++] = i;
		}
	}
	max = j - 1;
	while (scanf("%d", &n)) {
		if (!n)
			break;
		j = max;
		count = 0;
		for (i = 0; i <= j; i++) {
			while (1) {
				if (n - prime[i] > prime[j]) {
					break;
				}
				else if (n - prime[i] < prime[j]) {
					j--;
				}
				else {
					count++;
					break;
				}
				if (i > j)
					break;
			}
		}
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 676
import java.util.*;
//import java.lang.Math;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            int a=sc.nextInt();
            int b=sc.nextInt();
            if(a==0 && b==0) break;
            for(int i=0;i<a;i++){
                for(int j=0;j<b;j++){
                    if(i!=0 && i!=a-1 && j!=0 && j!=b-1) System.out.print(".");
                    else System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
        sc.close();
    }
}


Measured memory_bytes: 34268
import java.util.Scanner;
 
public class Main {
  int getColor(int rate) {
    if (rate < 400)
      return 0;
    if (rate < 800)
      return 1;
    if (rate < 1200)
      return 2;
    if (rate < 1600)
      return 3;
    if (rate < 2000)
      return 4;
    if (rate < 2400)
      return 5;
    if (rate < 2800)
      return 6;
    if (rate < 3200)
      return 7;
    return 8;
  }

  void run() {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] num = new int[9];
    for (int i = 0; i < n; i++) {
      int rate = sc.nextInt();
      num[getColor(rate)]++;
    }

    int ans = 0;
    for (int i = 0; i < 8; i++) {
      if (num[i] > 0) {
        ans++;
      }
    }

    int min = ans;
    int max = ans;
    if (num[8] > 0) {
      if (min == 0) {
        min = 1;
      }
      max = max + num[8];
    }
    System.out.println(min + " " + max);
  }

  public static void main(String[] args) {
    new Main().run();
  }
}


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

#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    int N; cin >> N;
    vll A(N); REP(i, N) cin >> A[i];
    vll B(N); REP(i, N) B[i] = A[i] - i - 1;

    sort(B.begin(), B.end());

    ll ans1 = 0; REP(i, N) ans1 += llabs(B[i] - B[N/2-1]);
    ll ans2 = 0; REP(i, N) ans2 += llabs(B[i] - B[N/2]);
    cout << min(ans1, ans2) << endl;

    return 0;
}


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

using namespace std;

class Solution {
public:
	string redOrNot(int a, const string& s) {
		return (a < 3200) ? "red" : s;
	}
};

int main() {
	int a;
	string s;
	cin >> a >> s;

	Solution sol;
	string ans = sol.redOrNot(a, s);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
S=list(input())
if S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]:
	print("Yes")
elif S[0]==S[2] and S[1]==S[3] and S[0]!=S[1]:
	print("Yes")
elif S[0]==S[3] and S[1]==S[2] and S[0]!=S[1]:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<62;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T& t,const V& v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T& t,const V& v){for(auto &e:t)fill_v(e,v);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int n,aa,bb,cc;cin>>n>>aa>>bb>>cc;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=INF;
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<(1<<n);j++){
            for(int k=0;k<(1<<n);k++){
                bool f=false;
                int c1=0,c2=0,c3=0;
                for(int l=0;l<n;l++){
                    int c=0;
                    if(i&(1<<l)){
                        c1++;c++;
                    }
                    if(j&(1<<l)){
                        c2++;c++;
                    }
                    if(k&(1<<l)){
                        c3++;c++;
                    }
                    if(c>1)f=true;
                }
                if(f){
                    continue;
                }
                if(c1==0||c2==0||c3==0)continue;
                int s1=0,s2=0,s3=0;
                for(int l=0;l<n;l++){
                    if(i&(1<<l))s1+=a[l];
                    if(j&(1<<l))s2+=a[l];
                    if(k&(1<<l))s3+=a[l];
                }
                chmin(ans,abs(s1-aa)+abs(s2-bb)+abs(s3-cc)+(c1-1)*10+(c2-1)*10+(c3-1)*10);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int L[300000], R[300000];

int cnt = 0;

int merge(int A[], int n, int left, int mid, int right){

int i, j, k;

int n1 = mid - left;

int n2 = right - mid;

int L[500000], R[500000];


  for( i = 0; i < n1; i++ ){

    L[i] = A[left + i];

  }

  for( i = 0; i < n2; i++ ){

    R[i] = A[mid + i];

  }

  L[n1] = R[n2] = 2000000000;

  i = 0;

  j = 0;


  for( k = left; k < right ; k++ ){

    cnt++;

    if(L[i] <= R[j]){

      A[k] = L[i];

      i = i + 1;

    }

    else{

      A[k] = R[j];

      j = j + 1;

    }

  }

}


void mergeSort(int A[], int n, int left, int right){

int mid;

  if(left+1 < right){

    mid = (left + right)/2;

    mergeSort(A, n, left, mid);

    mergeSort(A, n, mid, right);

    merge(A, n, left, mid, right);

  }

}


int main(void){

int n, i;

int A[500000];

  scanf("%d", &n);

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

  mergeSort(A, n, 0, n);

  for(i = 0; i < n; i++){

    if(i==0)printf("%d",A[i]);

    else printf(" %d",A[i]);

  }

 printf("\n%d\n",cnt);

  return 0;

}

Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
bool check(vector<long long> A, vector<long long>F, long long N, long long K, long long half){
    long long Sum=0;
    for(long long i=0; i<N; i++){
        long long Z=A.at(i)*F.at(i);
        if(Z>half){
            Sum += A.at(i)-half/F.at(i);
        }
    }
    if(Sum>K){
        return false;
    }
    return true;
}


int main (){
    long long N;
    cin>>N;
    long long K;
    cin>>K;
    
    vector<long long> A(N), F(N);
    for(long long i=0 ;i<N; i++){
        cin>>A.at(i);
    }
    for(long long i=0; i<N; i++){
        cin>>F.at(i);
    }

    sort(A.begin(), A.end());
    sort(F.rbegin(), F.rend());

    long long left=-1;
    long long right=A.at(N-1)*F.at(0) + 1;
    long long half=(left+right)/2;
    while(right-left>1){
      	//cout<<left<<" "<<right<<endl;
        if(!check(A, F, N, K, half)){
            left=half;
            half=(left+right)/2;
          	//cout<<"X";
        }
        else{
            right=half;
            half=(left+right)/2;
          	//cout<<"O";
          	
        }
		//cout<<left<<" "<<right<<endl;


    }
    cout<<right<<endl;

}

Measured memory_bytes: 6552
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

struct state {
	int c, p;
	string s;
	state(int c, int p, string s) : c(c), p(p), s(s) {};
};

int main() {
	int n;
	while (cin >> n, n) {
		string st, en;
		cin >> st >> en;

		stack<state> S;
		S.push(state(0, 0, st));
		int ans = INT_MAX;
		while (!S.empty()) {
			state st = S.top();
			S.pop();
			if (st.p == n) {
				ans = min(ans, st.c);
				continue;
			}

			if (st.s[st.p] == en[st.p]) {
				S.push(state(st.c, st.p + 1, st.s));
				continue;
			}

			REP(i, n - st.p) {
				string ns = st.s;
				int diff = en[st.p] - st.s[st.p] + 10;
				REP(j, i+1) {
					ns[st.p + j] = (ns[st.p + j] - '0' + diff) % 10 + '0';
				}
				S.push(state(st.c + 1, st.p + 1, ns));
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1220
#include <stdio.h>
 
int main(){
	int n;
	scanf("%d",&n);
	if(0 < n && n < 105)
		printf("0");
	else if(104 < n && n < 135)
		printf("1");
  	else if(134 < n && n < 165)
      	printf("2");
	else if(164 < n && n < 189)
		printf("3");
  	else if(188 < n && n < 195)
      	printf("4");
	else if(194 < n && n <= 200)
		printf("5");
	return 0;
}

Measured memory_bytes: 128
program agc038_a
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: h,w,a,b,i,j,ii
    integer(int32), allocatable:: aa(:),bb(:)
    character(:),allocatable:: ans1,ans2

    read*, h,w,a,b

    allocate(aa(h+1), bb(w+1))
    allocate(character(w):: ans1,ans2)
    do i=1,a
        ans1(i:i) = '1'
        ans2(i:i) = '0' 
    end do
    do i=a+1,w
        ans1(i:i) = '0'
        ans2(i:i) = '1'
    end do

    do i=1,h+1
        aa(i) = a*h+(w-2*a)*(i-1)
    end do

    do i=1,w+1
        bb(i) = b*w+(h-2*b)*(i-1)
    end do
    ! print'(*(i0,1x))', aa(:)
    ! print'(*(i0,1x))', bb(:)
    do i=1,h+1
        do j=1,w+1
            if (aa(i)==bb(j)) then
                do ii=1,b
                    print'(a)', ans1
                end do
                do ii=b+1,h
                    print'(a)', ans2
                end do
                stop
            end if
        end do
    end do
    print'(a)', 'No'
end program agc038_a

Measured memory_bytes: 1152
n,a,b = gets.chomp.split.map(&:to_i)
if n+1 < a+b
  printf("%d\n",-1)
  exit
end

result = []

min = 1
max = n
possible = true
while min <= max
  b -= 1
  
  if a == 0
    possible = false
    break
  end
  
  if max-a+1 <= min
    result.concat((min..max).to_a)
    break
  else
    result.concat(((max-a+1)..max).to_a)
  end
  max -= a
  a -= 1
    
  if b == 0
    possible = false
    break
  end
  
  if max <= min+b-1
    result.concat((min..max).to_a.reverse)
    break
  else
    result.concat((min..(min+b-1)).to_a.reverse)
  end
  min += b
end

if possible
  printf("%s\n",result.join(" "))
else
  printf("%d\n",-1)
end

Measured memory_bytes: 10504
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
int compare_int_small(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
// 公約数
long long int gcd(long long int a, long long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long long int lcm(long long int a, long long int b){
  return a * b / gcd(a, b);
}

// 5min
int main(void){
  int a, b;
  int ans = 0;

  scanf("%d%d", &a, &b);

  if(a >= 13){
    ans = b;
  }else if(a >= 6){
    ans = b / 2;
  }else{
    ans = 0;
  }
  
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main()
{
	char s[15], fs[5], ss[9];
	scanf("%s", s);

	int i, j;
	for (i = 0; i < 4; i++) {
		fs[i] = s[i];
	}
	fs[4] = '\0';
	for (j = 0; j < 8; j++) {
		ss[j] = s[j + 4];
	}
	ss[8] = '\0';
	printf("%s %s\n", fs,ss);
	
	return 0;
}

Measured memory_bytes: 128
#include "stdio.h"
#include "math.h"

#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#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++)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;

int main()
{
	double a, b, c, d, e, f;
	while (cin>>a>>b>>c>>d>>e>>f) {
		double x, y;
		
		x = 1/(a*e-b*d)*(c*e-b*f);
		y = 1/(a*e-b*d)*(f*a-c*d);
		
		if (x == -0.0) x = 0.0;
		if (y == -0.0) y = 0.0;
		
		//cout << x << " " << y << endl;
		printf("%.3f %.3f\n", x, y);
	}
}

Measured memory_bytes: 1236
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
      	long K = sc.nextLong();
      	long A = sc.nextLong();
      	long B = sc.nextLong();
      	long num = 0;
      	long keisan = 0;
      	
      	keisan = A + (K-A+1)/2*(B-A);
      	
		
        	if((K-A+1)%2 == 1){
            	keisan++;
              	if(A < B+2 && K > A && 1+K < keisan){
                  	num = keisan;
	            }else{
            		num = 1+K;
	            }
        	}else{
        		if(A < B+2 && K > A && 1+K < keisan){
                  	num = keisan;
	            }else{
            		num = 1+K;
	            }
     	   }
      	System.out.print(num);
    }
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int ctoi(char c) {
  return c - '0';
}

template <class C>
void printContainer(C &container, const char *delim=",") {
  for(const auto &e : container) {
    std::cout << e << delim;
  }
  std::cout << "\n";
}

// Greatest common divisor
template<class T>
T gcd(T x, T y) {
  if(x < y) {
    std::swap(x, y);
  }
  T r = x % y;
  while(r != 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

// Least common multiple
template<class T>
T lcm(T x, T y) {
  return (x*y)/gcd(x,y);
}

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

  if(op == '+') {
    cout << a+b << endl;
  } 
  else {
    cout << a-b << endl;
  }
  return 0;
}


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

int  main()
{
  int n,t;
  scanf("%d%d",&n,&t);
  int a[200200];
  for(int i=0;i<n;i++)
  {
      scanf("%d",&a[i]);
  }
  if(n==1)
  {
      printf("%d\n",t);
  }
  else
  {
  int p=a[0];
  int s=0;
  for(int i=1;i<n;i++)
  {
     if(p+t<a[i])
     {
         s+=a[i]-p-t;
     }
     p=a[i];
  }
  //printf("%d %d %d\n",p,t,s);
    printf("%d\n",p+t-s-a[0]);
  }
    return 0;
}


Measured memory_bytes: 1024
/**
 * Title:
 * Url:
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    bool flag = true;
    for(int i=0; i<n; i++) {
        if(a[i]%2==0) {
            if(!(a[i]%3==0|a[i]%5==0)) {
                flag = false;
                break;
            }
        }
    }
    if(flag) {
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    int x;cin>>x;
    if(x>=30)
        cout<<"Yes"<<nl;
    else
        cout<<"No"<<nl;
}

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

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

using namespace std;

int main(){
    int i, j=0;
    char c[4];
    for (i=0; i<4; i++){
        cin >> c[i];
    }
    
    for (i=0; i<4; i++){
        if (c[i]=='2') j++;
    }

    cout << j << '\n';

}

Measured memory_bytes: 256
N, Y = map(int, input().split())
L    = [10000, 5000, 1000]

is_fail = True

for a in range(N+1):
    for b in range(N+1-a):
        if Y - 10000 * a - 5000 * b == 1000 * (N - a - b):
            print(a, b, N - a - b)
            is_fail = False
            break
    if not is_fail:
        break

if is_fail:
    print('-1 -1 -1')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

int main() {
    ios::sync_with_stdio(false);
    Int n;
    cin >> n;
    vector<Int> b(n);
    vector<Int> res;
    for (Int i = 0; i < n; i++) cin >> b[i];
    for (Int i = 0; i < n; i++) {
        for (Int j = (Int)b.size() - 1; j >= 0; j--) {
            if (b[j] == j + 1) {
                res.emplace_back(b[j]);
                b.erase(b.begin() + j);
                break;
            }
        }
    }
    if (b.empty()) {
        for (Int i = n - 1; i >= 0; i--) dump(res[i]);
    }
    else {
        dump(-1);
    }
    return 0;
} 

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int N = 0;
    cin >> N;
    vector<int> a(N+1);
    vector<int> box(N+1);
    reps (i, N)
    { 
        cin >> a[i];
        box[i] = -1;
    }

    box[N] = a[N];

    int M = 0;
    vector<int> b;

    int t = 1;
    rreps (i, N)
    {
        int tmp = a[i];
        for (int k = 2*i; k <= N; k += i)
        {
            tmp ^= box[k];
        }
        
        box[i] = tmp;
    }

    for (int i = 0; i < box.size(); ++i)
    {
        if (box[i])
        {
            M++;
            b.pb(i);
        }
    }

    cout << M << endl;
    rep (i, SZ(b))
    {
        if (i != SZ(b) - 1)
            cout << b[i] << " ";
        else
            cout << b[i] << endl;
    }
    

    return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  int ans = 0;
  cin >> N;
  for (int i = 1; i < N+1; i++) {
    if (to_string(i).length() % 2 == 0) {
      i = i * 10 - 1;
      continue;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    //入力を受け取る
    int D, T, S;
    cin >> D >> T >> S;
 
    //高橋君の移動時間を計算する
    double time = (double)D / S;
 
    //Tとtimeの大小関係に応じて出力をする
    if (T >= time) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3620
//Har Har Mahadev
using namespace std;
#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll long long int
#define pb push_back
#define mp make_pair
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " -> " << a << endl;
	err(++it, args...);
}
const ll mod = 1e9 + 7;
void testcase(){
	ll n,a[200005];
	ll ans = 0,sum = 0;
	cin >> n;
	for(int i{0};i < n;i++)cin >> a[i];
	for(int i{0};i < n;i++){
		sum += a[i];
		sum %= mod;
	}
	for(int i{0};i < n;i++){
		sum -= a[i];
		sum = (sum + 5*mod)%mod;
		ans += a[i]*sum;
		ans %= mod;
	}
	cout << ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


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

int main() {
    int n, co = 0, sum = 0;
    cin >> n;
    string x;
    vector<string> a(n);
    vector<int> b(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        cin >> b[i];
    }
    cin >> x;

    for(int i = 0; i < n; i++) {
        if(x == a[i]){
            co = i;
            break;
        }
    }

    for(int i = co + 1; i < n; i++) {
        sum += b[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
h,w,k=map(int,input().split())
l=[list(input()) for i in range(h)]

m=[]
q=0

s=[]
for i in range(h):
    for j in range(w):
        s.append(q)
    m.append(s)
    s=[]

q=1
p=0
for j in range(h):
    p=0
    for i in range(w):
        if l[j][i]=="#":
            for k in range(p,w):
                m[j][k]=q
            p=i+1
            q+=1

for i in range(w):
    for j in range(h-1):
        for i in range(w):
            if m[j][i]==0:
                m[j][i]=m[j+1][i]
                
for i in range(w):
    for j in range(1,h):
        for i in range(w):
            if m[j][i]==0:
                m[j][i]=m[j-1][i]
for i in m:
	for j in i:
		print(j,end=" ")
	print()


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

static const int INFTY = (1<<20);
static const int MAXm = 30;
static const int MAXn = 60000;

int n, m, C[MAXm], T[MAXn];

int main() {
  cin >> n >> m;
  T[0] = 0;
  for (int i = 1; i <= n; i++) T[i] = INFTY;
  for (int i = 1; i <= m; i++) cin >> C[i];

  for (int i = 0; i <= m; i++) {
    for (int j = C[i]; j <= n; j++) {
      T[j] = min(T[j], T[j - C[i]] + 1);
    }
  }

  cout << T[n] << endl;
}


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

int main() {
int64_t N,K;
cin >> N >> K;
  if(2*N < K){
  	cout << N << endl;
  }
  else if(2*N == K){
  	cout << 0 << endl;
  }
  else if(2*N > K && N < K){
  	cout << K - N << endl;
  }
  else if(N == K){
  	cout << 0 << endl;
  }
  else if(N%K == 0){
  	cout << 0 << endl;
  }
  else if(2*(N%K) < K){
  	cout << N%K << endl;
  }
  else if(2*(N%K) == K){
  	cout << 0 << endl;
  }
  else if(2*(N%K) > K){
  	cout << K-N%K << endl;
  }
}

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


const int GCM(const int a,const int b){
	int x(a),y(b);
	while(x%=y){
		std::swap(x,y);
	}
	return y;
}

const int LCM(const int a,const int b){
	int x(a),y(b);
	while(x%=y){
		std::swap(x,y);
	}
	long long tmp(a);
	tmp*=b;
	tmp/=y;
	return tmp;
}


int main(int,char**){
	int a,b;
	while(std::cin >>a){
		std::cin >> b;
		std::cout << GCM(a,b) << ' ' << LCM(a,b)<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys,queue,copy,math
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
INF = float('inf')

r = int(input())

ans = (r*r)/(1*1)
print(int(ans))



Measured memory_bytes: 4080
#include<stdio.h>
#include <stdlib.h>
int main(){
  
  int x,y,q,i,sum;
  int box[101][101]={0};
  sum= 0;
  scanf("%d%d",&x,&y);
for(i=0;i<x;i++){
	for(q=0;q<y;q++){
		scanf("%d",&box[i][q]);
		box[x][q]+=box[i][q];
		box[i][y]+=box[i][q];
		sum+=box[i][q];
	}
}  
box[x][y]+=sum;
for(i=0;i<=x;i++){
	for(q=0;q<=y;q++){
		if(q<y){printf("%d ",box[i][q]);}
		else{printf("%d",box[i][q]);}
	}printf("\n");
}
  return 0;
}

Measured memory_bytes: 652
import java.util.*;

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

    int N = scan.nextInt();
    int T = scan.nextInt();
    int A = scan.nextInt();
    int H[];
    H = new int[N];
    double ansh = 10000000;
    int ans = 0;
    for (int i = 0;i<H.length ;i++ ) {
        H[i] = scan.nextInt();
    }

    for (int i = 0;i<H.length ;i++ ) {
        if (ansh > Math.abs(A-(T-(double)H[i]*0.006))) {
            ans = i;
            ansh = Math.abs(A-(T-(double)H[i]*0.006));
        }
    }
    System.out.println(ans+1);
  }
}


Measured memory_bytes: 24528