akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define do double
#define loop(i,n) for(int i=0;i<n;i++)
#define lop(a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mkp make_pair

typedef vector <int> vi;
typedef map <int,int> mii;
typedef set <int> si;
typedef pair <int,int> pii;
typedef unordered_map <int,int> um;
typedef unordered_set <int> us;
typedef multiset <int> ms;
typedef vector < pair <int,int> > vpii;
// Driver code 
int dfs(int n,vi g[],int i,int dp[],bool vis[])
{
    vis[i]=true;
    // if(g[i].size()==0)
    //     return 0;
      for(int j=0;j<g[i].size();j++)
      {
        if(!vis[g[i][j]])
            dfs(n,g,g[i][j],dp,vis);
        dp[i]=max(dp[i], 1+ dp[g[i][j]]);
      } 

    return dp[i];
}
int main() 
{ 
    int n,m,mx=0;
    cin>>n>>m;
    vi g[n+1];
    int dp[n+1]={};
    bool vis[n+1];
    memset(vis,false,n+1);
    loop(i,m)
    {
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
    }
    for(int i=1;i<=n;i++)
    {   if(!vis[i])
        dp[i]=dfs(n,g,i,dp,vis);
        mx=max(mx,dp[i]);
    }
    cout<<mx<<"\n";
} 



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

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

  vector<int> A(M);
  vector<int> B(M);
  for (int i=0; i<M; i++){
    cin >> A[i] >> B[i];
  }

  int count;
  for (int i=0; i<N; i++){
    count = 0;
    for (int j=0; j<M; j++){
      if (A[j] == i+1){
        count++;
      }
      if (B[j] == i+1){
        count++;
      }
    }
    cout << count << endl;
  }

  return 0;
}


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

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

vector<int> p;
vector<int> r;

void init(int n) {
  p.reserve(n);
  r.reserve(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
}

int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }

bool same(int x, int y) { return root(x) == root(y); }

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y)
    return;

  if (r[x] < r[y])
    p[x] = y;
  else {
    p[y] = x;
    if (r[x] == r[y])
      r[x]++;
  }
}

int main() {
  vector<int> ABC(3);
  for (int i = 0; i < 3; i++) {
    cin >> ABC[i];
  }
  sort(ABC.begin(), ABC.end());
  int ans = ABC[0] + ABC[1] + ABC[2] * 10;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,F[44],i;

  scanf("%d",&n);
  
  F[0] = 1;
  F[1] = 1;
  
  for(i=2;i<=n;i++){
    F[i] = F[i-2] + F[i-1];
  }
  
  printf("%d\n",F[n]);
  return 0;
}


Measured memory_bytes: 2056
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int main() {
    string x;
    cin >> x;

    stack<char> s;

    for (int i = 0; i < x.size(); ++i) {
        if (!s.empty() && s.top() == 'S' && x[i] == 'T') {
            s.pop();
        } else {
            s.push(x[i]);
        }
    }

    cout << s.size() << endl;
}

Measured memory_bytes: 644
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    a,b=ns()
    print(a*b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 10680
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

long long GetAttackNum(long long n)
{
	if (n == 1)
	{
		return 1;
	}

	return 1 + 2 * GetAttackNum(n / 2);
}

int main()
{
	long long h;
	cin >> h;
	cout << GetAttackNum(h) << endl;
}


Measured memory_bytes: 256
import math

def main():
  a, b, c, d = map(int, input().split())
  
  n = c/b
  n_ = math.ceil(n)
  m = a/d
  m_ = math.ceil(m)
  
  if n_ <= m_:
    print('Yes')
  else:
    print('No')

main()

Measured memory_bytes: 9192
/*
    C - Dice and Coin
    https://atcoder.jp/contests/abc126/tasks/abc126_c
*/
#include <bits/stdc++.h>
using namespace std;

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

    double n, k;
    cin >> n >> k;

    vector<int> num_of_playing_dice(n);
    double probability = 0.0;

    for (int i = 1; i <= n; i++) {
        int count = 0;
        int dice = i;
        while (dice < k) {
            dice *= 2;
            count++;
        }
        probability += (double)pow(0.5, count);
    }

    cout << fixed;
    cout << setprecision(10) << (probability / n) << endl;
}


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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

constexpr int MOD = 1000000007;

bool check(const string& s, int i, int j) {
    int k = 0;
    while (i + k <= j - k) {
        if (s[i + k] != s[j - k]) { return false; }
        ++k;
    }
    return true;
}

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

    string s;
    cin >> s;

    int n = s.size();
    if (!check(s, 0, n - 1)) {
        cout << "No" << endl;
        return 0;
    }
    if (!check(s, 0, (n - 3) / 2)) {
        cout << "No" << endl;
        return 0;
    }
    if (!check(s, (n + 1) / 2, n - 1)) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n, m, k;
  cin >> n >> m >> k;
  vl a(n+1);
  vl b(m+1);
  ll dpa[n+1];
  ll dpb[m+1];
  ll count = 0;
  dpa[0] = 0;
  dpb[0] = 0;
  for (ll i = 1; i <= n; i++){
    cin >> a[i];
    dpa[i] = dpa[i - 1] + a[i];
  }
  for(ll i=1;i<=m;i++){
    cin >> b[i];
    dpb[i] = dpb[i - 1] + b[i];
  }
  ll ans = 0;
  for (ll i = 0; i <= n;i++){
    ll tmp = max((ll)0, ans - i + 1);
    for (ll j = tmp; j <= m; j++){
      if(dpa[i]+dpb[j]<=k){
        ans = i + j ;
      }
      else{
        break;
      }
    }
  }
  print(ans);
}

Measured memory_bytes: 9536
#include<iostream>
using namespace std;int n[12][345],a,b;bool u[10];void d(int l,int c){n[l][c]++;if(l==10)return;for(int i=0;i<10;i++)if(!u[i]){u[i]=1;d(l+1,c+(l+1)*i);u[i]=0;}}int main(){for(a=0;a<10;a++)u[a]=0;d(0,0);while(cin>>a>>b)cout<<(b<345?n[a][b]:0)<<endl;return 0;}

Measured memory_bytes: 2988
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    ll mi = a[0];
    ll mi_index = 0;
    for(int i = 0; i < N; i++){
        if(a[i] < mi){
            mi = a[i];
            mi_index = i;
        }
    }
    ll ma = a[0];
    ll ma_index = 0;
    for(int i = 0; i < N; i++){
        if(a[i] > ma){
            ma = a[i];
            ma_index = i;
        }
    }
    
    cout << 2*N-2 << endl;
    if(abs(mi) > abs(ma)){
        for(int i = 0; i < N; i++){
            if(i != mi_index){
                cout << mi_index+1 << " " << i+1 << endl;
            }
        }
        for(int i = 0; i < N-1; i++){
            cout << N-i << " " << N-i-1 << endl;
        }
    }
    else{
        for(int i = 0; i < N; i++){
            if(i != ma_index){
                cout << ma_index+1 << " " << i+1 << endl;
            }
        }
        for(int i = 0; i < N-1; i++){
            cout << i+1 << " " << i+2 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <utility>
using namespace std;

typedef long long LL;

LL solve(LL x, LL y){
	x = abs(x);
	y = abs(y);
	if(x < y){ swap(x, y); }
	if(x == 0 && y == 0){ return 0; }
	if(max(x, y) == 1){ return 1; }

	LL a = x + y;
	if(x & 1 && y == 0){ ++a; }
	else if(x & y & 1){ --a; }
	return a;
}

int main(){
	LL x, y;
	while(cin >> x >> y){
		cout << solve(x, y) << endl;
	}
}


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

string pro(int a, int b)
{
    stringstream aa, bb;
    string A, B;
    aa << a, bb << b;
    aa >> A, bb >> B;

    reverse(All(A));
    while(A.size() != 6)
        A.Pb('0');

    reverse(All(B));
    while(B.size() != 6)
        B.Pb('0');

    reverse(All(A));
    reverse(All(B));

    A += B;
    return A;
}

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

    int p[mx5], y[mx5];
    vector<int> v[mx5];

    for(int i = 0; i < m; i++){
        cin >> p[i] >> y[i];
        v[p[i]].Pb(y[i]);
    }

    for(int i = 1; i <= n; i++)
        sort(All(v[i]));

    map<pair<int, int>, int> mp;
    for(int i = 1; i <= n; i++){
        int it = 1;
        for(auto j: v[i])
            mp[{i, j}] = it++;
    }

    for(int i = 0; i < m; i++)
        cout << pro(p[i], mp[{p[i], y[i]}]) << '\n';

    return 0;
}


Measured memory_bytes: 15940
#include<stdio.h>
#include<stdlib.h>
void countingSort(int[],int[],int,int);
void printArray(int[],int);
int main(void)
{
  int i;//counter
  int n;//length of array
  int max=0;//maximum value of array
  int *arr;
  int *sortedArr;
  scanf("%d",&n);
  arr=(int*)malloc(sizeof(int)*n);
  sortedArr=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&arr[i]);
      if(max<arr[i]) max=arr[i];
    }
  countingSort(arr,sortedArr,n,max);
  printArray(sortedArr,n);
  return 0;
}
void countingSort(int arr[],int sortedArr[],int n,int max)
{
  int i;//counter
  int *countArr=(int*)malloc(sizeof(int)*(max+1));
  for(i=0;i<max+1;i++) countArr[i]=0;
  for(i=0;i<n;i++) countArr[arr[i]]++;
  for(i=1;i<max+1;i++) countArr[i]+=countArr[i-1];
  for(i=n-1;i>=0;i--)
    {
      sortedArr[countArr[arr[i]]-1]=arr[i];
      countArr[arr[i]]--;
    }
}
void printArray(int arr[],int n)
{
  int i;//counter
  for(i=0;i<n;i++)
    {
      if(i>0) printf(" ");
      printf("%d",arr[i]);
    }
  printf("\n");
}



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

int n ;

int a[100010] ;

int main(){
	#define NAME "HCN"
	//freopen( NAME".inp" , "r" , stdin ) ; freopen( NAME".out" , "w" , stdout ) ;

	ios_base :: sync_with_stdio(false) ;

	cin >> n ;

	for (int i = 1; i <= n; ++ i) cin >> a[i] ;

	sort(a + 1, a + n + 1) ;
	
	int cur = a[1], cnt = 1 ; 

	int best = 0 ;

	long long ans = 0 ;

	for (int i = 2; i <= n; ++ i){
		if(a[i] == cur) cnt ++ ;
		else{
			if(cnt >= 4) ans = 1ll * cur * cur ;
			else if(cnt >= 2) ans = 1ll * cur * best ;
			if(cnt >= 2) best = cur ;
			cur = a[i] ; cnt = 1 ;
		}
	}

	if(cnt >= 4) ans = 1ll * cur * cur ;
	else if(cnt >= 2) ans = 1ll * cur * best ;

	cout << ans << endl ;

	return 0 ;
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
ll N, A, B;
int main() {
  scanf("%ld %ld %ld", &N, &A, &B);
  ll ans = N/(A+B)*A+min(A, N%(A+B));
  printf("%ld\n", ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<pi> vpi;

#define debugone(x) cerr << #x << " " << x << endl;
#define debugtwo(x) cerr << #x << "-------------" << endl;for(auto &it: x) cerr << it << " ";cerr << endl;
#define debugthree(x, i, j) cerr << #x << "------------" << endl;cerr << "from " << i << " to " << j << endl;for(int k=i; k<=j; k++) cerr << x[k] << " ";cout << endl;

const int mod = (int)1e9 + 7;


int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, m;
	cin >> n >> m;
	long long array[n], cumSum[n];	
	long long sum = 0;
	for(int i = 0; i < n; i++){
		cin >> array[i];
		sum += array[i];
		cumSum[i] = ((i == 0) ? array[i] : (cumSum[i-1] + array[i]));
	}

	sort(array, array + n);

	vector<pair<int, int>> v;
	for(int i = 0; i < m; i++){
		int b, c;
		cin >> b >> c;
		v.emplace_back(c, b);
	}

	sort(v.rbegin(), v.rend());

	int updateId = 0;
	for(auto &it : v){
		int c = it.first, b = it.second;
		int currUpdateDone = 0;

		while(updateId < n && array[updateId] < c && currUpdateDone < b){
			sum += c - array[updateId];
			updateId++;
			currUpdateDone++;
		}
	}

	cout << sum << endl;
}	

Measured memory_bytes: 2936
use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::cmp::*;
use std::collections::HashSet;
use std::iter::Iterator;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
  input! {
  n: i64,
  mut h: [i64; n],
  }

  if n == 1 {
    println!("Yes");
    return;
  }

  let mut prev = 0;
  for &i in h.iter().rev() {
    if prev == 0 {
      prev = i ;
      continue;
    }

    if i > prev {
      if prev < i - 1 {
        println!("No");
        return;
      } else {
        prev = i - 1;
      }
    } else {
      prev = i;
    }
  }
  println!("Yes");
}


Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

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

int main(){
	while(cin>>n&&n){
		fill(b,b+(n+1)/2,0);
		set<int> s;
		rep(i,n-1)s.insert((i+1)*(i+1)%n);
		int cur=0;
		set<int>::iterator ite=s.begin();
		while(ite!=s.end()){
			a[cur++]=*ite;
			ite++;
		}
		//rep(i,cur)cout<<a[i]<<endl;cout<<cur<<endl;
		rep(i,cur)rep(j,cur){
			if(i==j)continue;
			int r=a[j]-a[i];
			if(r<0)r+=n;
			if(r>(n-1)/2)r=n-r;
			b[r]++;
		}
		rep(i,(n-1)/2)cout<<b[i+1]<<endl;
	}
}

Measured memory_bytes: 1060
///答え見ました
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

vector<vector<int>>g(15,vector<int>(15,-1));//初期値-1の二次元配列

int main() {
  int n;
  cin >> n;
  
  for(int i=0; i<n; i++){
    int a;
    cin >> a;
   for(int j=0; j<a; j++){
     int b,c;
     cin >> b >> c;
     --b;
     g[i][b]=c;
   }
  }//0or1の入力
  
  int ans=0;
  for(int i=0; i < 1<<n; i++){
    int count=0;
    vector<int>d(n);
    for(int j=0; j<n; j++){
      if(i>>j&1==1){
        d[j]=1;
        count++;
      }
    }//n桁の二進数をn人に振り分け
    
    bool ok=true;
    for(int j=0; j<n; j++){
      if(d[j]==1){
        for(int k=0; k<n; k++){
         if(g[j][k]==-1) continue;
         if(g[j][k]!=d[k]) ok=false;
        }
      }
    }//1の人の証言と対象の状態が一致しているかどうか
    
    if(ok==true) ans=max(ans,count);
    
  }
  
  
  cout << ans << endl;
  
  return 0;
  
}


Measured memory_bytes: 256
fun main (args:Array<String>){
    val intN = readLine()!!.toInt()
    var count = 0
    for(i in 1..9){
       for(j in 1..9){
           if(i * j == intN) count++
           else continue
       }
    }
    if(count >= 1) print("Yes")
    else print("No")
}

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

using namespace std;

#define inf 210000000
#define int long long

bool cmp(int a,int b){
		return a > b;
}

signed main() {
		int n;
		cin >> n;
		vector<int> a;
		for(int i=0;i<n;i++){
				int tmp;
				cin >> tmp;
				a.push_back(tmp);
		}
		sort(a.begin(),a.end(),cmp);
		int cnt = 0;
		int ans = 1;
		while(true){
				if (a[0] == a[1]){
						ans *= a[0];
						cnt++;
						for(int i=0;i<2;i++){
								a.erase(a.begin());
						}
				}else{
						a.erase(a.begin());
				}
				if(cnt == 2 or a.size() < 2) break;
		}
		if(cnt == 2) cout << ans << endl;
		else cout << 0 << endl;
}


Measured memory_bytes: 1400
// E.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 2e5 + 200;

int n, m, ai[MAX_N];

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= 2 * n; i++)
        scanf("%d", &ai[i]);
    sort(ai + 1, ai + 1 + 2 * n);
    int l = 0, r = n, res;
    while (l <= r)
    {
        int mid = (l + r) >> 1;
        bool valid = true;
        for (int i = 2 * mid + 1; i <= (n << 1); i++)
            if (ai[i] + ai[2 * n + 2 * mid + 1 - i] < m)
            {
                valid = false;
                break;
            }
        if (valid)
            r = mid - 1, res = mid;
        else
            l = mid + 1;
    }
    int pos = res << 1;
    int ans = 0;
    for (int i = 1; i <= pos; i++)
        ans = max(ans, ai[i] + ai[pos - i + 1]);
    for (int i = pos + 1; i <= (n << 1); i++)
        ans = max(ans, (ai[i] + ai[(n << 1) + pos - i + 1]) % m);
    printf("%lld\n", ans);
    return 0;
}

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

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

    int strlen = N.length();

    string dst = N.substr(strlen - 1, 1);

    if (dst == "3") cout << "bon" << endl;
    else if (dst == "0" || dst == "1" || dst == "6" || dst == "8") cout << "pon" << endl;
    else cout << "hon" << endl;
}

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

int main(){
    int h,m,s,Sec;
    
    cin >> Sec;
    
    s = Sec % 60;
    Sec /= 60;
    m = Sec % 60;
    h = Sec / 60;
    
    cout << h << ':' << m << ':' << s << endl;
    
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> 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); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int N;
map<string, int> mp;

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    cin >> N;
    REP(i, N) {
        string s;
        cin >> s;
        SORT(s);
        mp[s]++;
    }
    int ans = 0;
    for (auto p : mp) {
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11264
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn solve(a: i64, b: i64, c: i64) -> bool {
  let x = c - a - b;
  if x < 0 {
    return false;
  }
  4 * a * b < x * x
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    a: i64,
    b: i64,
    c: i64,
  }

  puts!("{}\n", if solve(a, b, c) {"Yes"} else {"No"});
}


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

#define PI 3.14159265358979

using namespace std;

double f(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4)
{
	return ((x1-x2)*(y3-y1)+(y1-y2)*(x1-x3))*((x1-x2)*(y4-y1)+(y1-y2)*(x1-x4));
}

int main()
{
	double x[4],y[4];

	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3])!=EOF)
	{
		if(f(x[0],y[0],x[2],y[2],x[1],y[1],x[3],y[3])>0 || f(x[1],y[1],x[3],y[3],x[0],y[0],x[2],y[2])>0)cout << "NO" << endl;
		else cout << "YES" << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;

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

        long x = sc.nextLong();
        long y = sc.nextLong();

        int ans = 0;
        while(x <= y) {
            ans++;
            x *= 2;
        }
        System.out.println(ans);

        sc.close();
    }
}

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

using ll = long long;

template <typename T> T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;

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

    ll res = 0;
    set<int> used_pos;
    for(int i = 1; i <= N; ++i) {
        ll l2, r2;
        auto r = used_pos.lower_bound(pos[i]);
        if(r == end(used_pos)) {
            r2 = N;
        } else {
            r2 = *r;
        }
        if(r == begin(used_pos)) {
            l2 = -1;
        } else {
            l2 = *prev(r);
        }
        ll c = (pos[i] - l2) * (r2 - pos[i]);
        //cout << l2 << ' ' << pos[i] << ' ' << r2 << " -> " << c << endl;
        res += 1LL * c * i;
        used_pos.insert(pos[i]);
    }
    cout << res << endl;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x,2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vd = vector<long double>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  ll n,k,x,tot=0,ans=-1e18,t=0,now;
  cin >> n>>k;
  vi p(n);
  vi c(n);
  cins(n, p);
  cins(n, c);
  rep(i, n) p[i]--;
  rep(si, n){
    x=si;
    vi s;
    tot=0;
    t=0;
    while(true){
      x=p[x];
      s.push_back(c[x]);
      tot+=c[x];
      if(x==si) break;
    }
    ll l = s.size();
    rep(i, l){
      t += s[i];
      if(i+1>k) break;
      now = t;
      if(tot > 0){
        ll e = (k-(i+1))/l;
        
        now += tot*e;
      }
      
    ans=max(ans,now);
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI;
typedef pair<ll,ll> pii;
const ll mod = 1LL<<60;



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

	int n,ma,mb;
	cin >>n >>ma >>mb;
	VI a(n), b(n), c(n);
	rep(i,n) cin >> a[i] >>b[i] >>c[i];
	ll ans = mod;
	vector<vector<ll>> cp(510, vector<ll>(510, mod));
	cp[0][0]=0;
	rep(i,n){
		vector<vector<ll>> np(510, vector<ll>(510, mod));
		rep(j, 501) rep(k, 501) if( cp[j][k] < mod ){
			np[j + a[i]][k + b[i] ] = min(np[j + a[i]][k + b[i] ] ,cp[j][k] + c[i]);
			np[j][k] = min(np[j][k], cp[j][k]);
			//if( (j + a[i]) * (ll)mb == (k + b[i]) * (ll)ma ){
			//	ans = min(ans, np[j + a[i]][k + b[i] ]);
			//}
		}
		swap(cp, np);
	}
	
	rep(j,501) rep(k,501) {
		if(j>0 && k>0 && (ll)j*mb == (ll)k*ma) ans = min(ans, cp[j][k]);
	}
	
	if(ans ==mod) cout << -1 <<endl;
	else cout << ans <<endl;
	
	
	return 0;

}


Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef int64_t lint;
constexpr double PI=3.14159265358979323846;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;

int main() {
	int N, D;
	cin >> N >> D;
	int a=0, b=0, c=0;
	double x, y, z;
	rep(i, N) {
		std::cin >> x >> y;
		if (sqrt(x*x + y*y) <= D) a++;
	}
	std::cout << a << '\n';
}


Measured memory_bytes: 3804
N = int(raw_input())
A = raw_input().split(" ")

print " ".join(A)
for i in range(1, N):
    v = A[i]
    j = i - 1

    while j >= 0 and int(A[j]) > int(v):
        A[j+1] = A[j]
        j = j - 1

    A[j+1] = v

    print " ".join(A)
    

Measured memory_bytes: 6252
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  string s;
  cin>>s;
  string ans;
  rep(i,s.size()){
    if(s[i]=='D'||s[i]=='?'){
      ans+="D";
    }
    else{
      ans+="P";
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3920
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

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


Measured memory_bytes: 892
#include<stdio.h>

int main()
{
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	
	if(a<b)
	{
		printf("a < b\n");
	}
	else if(a>b)
	{
		printf("a > b\n");
	}
	else 
	{
		printf("a == b\n");
	}
	
	return 0;
}



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

#define  all(v)            v.begin(), v.end()
#define  sz(x)             (int)x.size()
#define  debug(x)          cout << #x << ':' << x << endl;
#define  rep(i,n)          for(long long i = 0; i <  n ; i++)
#define  reps(i,n)         for(long long i = 1; i <= n ; i++)
#define  make_unique(v)    sort(all(v));v.erase(unique(all(v)), v.end());
#define  REMOVE(v,a)       v.erase(remove(v.begin(),v.end(), a), v.end());
#define  pb                push_back
#define  mp                make_pair
#define  endl              '\n'
#define  fi                first
#define  se                second
#define  ajs(a)            (a<0)?(-1*a):a

using namespace std;
typedef long long          ll;
typedef vector<long long>  vll;
typedef pair<ll,ll>        pll;
const ll MOD = 1000000007;
bool cmp(int X, int Y) {return X > Y;}

ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return (a / gcd(a, b)) * b;}
ll modpow(ll a, ll b, ll m=MOD){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){if(b<0){return 0;}ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}

ll ncr(ll n , ll r){
	if(r > n - r) {r = n - r;}
	if(r==1){return n;}
	if(r==0){return 1;}
	
	if(r == n){return 1;}
	
	return ((n*ncr(n-1,r-1))/r)%MOD;
	}


int main(){ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n;cin>>n;
ll a[n];
ll b[n];
rep(i,n){
	ll x,y;cin>>x>>y;
	a[i] = x+y;
	b[i] = x-y;
	
	}
sort(a,a+n);
sort(b,b+n);

ll ans = max(a[n-1]-a[0] , b[n-1]-b[0]);
cout<<ans;

}	







	


Measured memory_bytes: 6732
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int a[]=new int[n];
		int sum=0;
		for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
			sum += a[i]-1;
		}
		scan.close();
		System.out.println(sum);
	}

}

Measured memory_bytes: 25676
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

#define DEBUG(x) cerr << #x << ": " << x << endl

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

const int MOD = 1e9 + 7;

#define MAXN 200000
int F[MAXN+4];
void build_factorial_table(int N) {
   F[0] = 1;
   for (int i = 1; i <= N; ++i)
      F[i] = (F[i-1] * 1LL * i) % MOD;
}

int inv[MAXN+4]; 
int invF[MAXN+4];
void build_inverse_factorial_table(int N) {
   inv[0]  = inv[1] = 1;
   invF[0] = invF[1] = 1;
   for (int i = 2; i <= N; ++i) {
      inv[i] = (MOD - (MOD / i) * 1LL * inv[MOD % i] % MOD) % MOD;
      invF[i] = (invF[i-1] * 1LL * inv[i]) % MOD;
   }
}

int nCk(int n, int k) {
   if (n < 0 || k < 0 || k > n)  // invalid n or k
      return 0;
   long long res = F[n];
   res = (res * invF[k]) % MOD;
   res = (res * invF[n-k]) % MOD;
   return res;
}


int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N, K;
   cin >> N >> K;

   build_factorial_table(N);
   build_inverse_factorial_table(N);

   int res = 0;
   for (int k = 0; k <= K && k <= N; ++k) {
      llong a = nCk(N, k);
      llong b = nCk(k + (N - k) - 1, (N - k) - 1);  // stars and bars
      res += (a * b) % MOD;
      if (res >= MOD)
         res -= MOD;
   }

   cout << res << endl;

   return 0;
}


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

using namespace std;
char a[21][21];
bool vis[21][21];
int n,m;
int X[] = {1 , -1 , 0 , 0};
int Y[] = {0 , 0 , 1 , -1};

bool check(int i , int j){
    return (i >= 0 && i<n && j >=0 && j<m && !vis[i][j] && a[i][j] != '#');
}

int BFS(int i , int j , int k , int q){

    queue < pair < int , int > > Q;
    Q.push({i , j});
    int dis[30][30];
    for(int i = 0;i<=20;i++){
        for(int j = 0;j<=20;j++){
            dis[i][j] = 1e9;
        }
    }
    memset(vis , 0 , sizeof(vis));
    dis[i][j] = 0;
    vis[i][j] = true;
    Q.push({i , j});
    while(!Q.empty()){
        pair < int , int > x = Q.front();
        Q.pop();
        for(int i = 0;i<4;i++){
            if(check(X[i] + x.first , Y[i] + x.second)){
                dis[X[i] + x.first][Y[i] + x.second] = 1 + dis[x.first][x.second];
                vis[X[i] + x.first][Y[i] + x.second] = true;
                Q.push({X[i] + x.first , Y[i] + x.second});
            }
        }
    }
    return dis[k][q];
}

int main()
{
    cin >> n >> m;
    for(int i=0;i<n;i++){
        for(int j = 0;j<m;j++)
            cin >> a[i][j];
    }
    int Ans = 0;
    for(int i = 0;i<n;i++){
        for(int j = 0;j<m;j++){
            if(a[i][j] == '.'){
                for(int k = 0;k<n;k++){
                    for(int q = 0;q<m;q++){
                        if(a[k][q] == '.'){
                            Ans = max(Ans , BFS(i , j , k , q));
                        }
                    }
                }
            }
        }
    }
    cout << Ans;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int N;
	cin >> N;
	vector<int> v;
	for (int i = 0;i < N;i++){
		ll l;
		cin >> l;
		v.pb(l);
	}
	sort(ALL(v));
	cout << abs(v[0] - v[N- 1]) <<endl;
	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

// Description: ??°??????????????????(?????????????°??????¨???)
// Verifyed: Many Diffrent Problem 

//Appropriately Changed
using edge=struct{int to;};
using G=vector<vector<edge>>;

//Appropriately Changed
void add_edge(G &graph,int from,int to){ 
	graph[from].push_back({to});
}

// Description: ????????°???????????????????????£????????? 
// TimeComplexity: $ \mathcal{O}(V + E) $
// Verifyed: AOJ GRL_3_C 

auto strongly_connected_components(const G& graph){
    int n=graph.size(),k=0;
    vector<int> par(n),ord(n,-1),low(n),scc(n,-1),res;
    stack<int> s;

    auto dfs=[&](int v,int p,int &k){
        auto func=[&](int v,int p,int &k,auto func)->void{
            ord[v]=k++,low[v]=ord[v],par[v]=p,s.push(v);
            for(auto &e:graph[v]){
                if(scc[e.to]!=-1) continue;
                if(ord[e.to]==-1)
                    func(e.to,v,k,func),chmin(low[v],low[e.to]);
                else
                    chmin(low[v],ord[e.to]);
            }
            if(ord[v]!=low[v]) return ;
            while(1){
                int u=s.top();s.pop();
                scc[u]=v;
                if(u==v) break;
            }
        };
        return func(v,p,k,func);
    };

    rep(v,n) if(ord[v]==-1) dfs(v,-1,k);
    return scc;     
}

int main(void){
	int v,e;
	cin >> v >> e;
	G graph(v);
	rep(i,e){
		int a,b;
		cin >> a >> b;
		add_edge(graph,a,b);
	}

	auto res=strongly_connected_components(graph);
	
    int q;
    cin >> q;
    rep(loop,q){
        int u,v;
        cin >> u >> v;
        cout << (res[u]==res[v]) << endl;
    }
	return 0;
}

Measured memory_bytes: 4544
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
#define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;




int main() {
    multiset<ll> s;
    ll q,x;
    ll n;
    cin>>n;
    rep(i,n){
        scanf("%lld %lld",&q,&x);
        if(q==1){
            fin(s.count(x));
        } else if(q==0){
            s.insert(x);
            fin(s.size());
        }
        else if(q==2){
            s.erase((x));
        } else {
            int r;
            cin>>r;
            for(auto i=s.lower_bound(x);i!=s.end()&&*i<=r;i++){
                if(*i>=x)cout<<*i<<endl;
            }
        }
        
    }
    
}




Measured memory_bytes: 12412
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;

  vector<vector<int>> c(10, vector<int>(10));
  for (auto& e : c) {
    for (auto& e2 : e) {
      cin >> e2;
    }
  }

  vector<int> a(h*w, 0);
  for (auto& e : a) {
    cin >> e;
  }

  for (int k = 0; k < 10; k++) {
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }

  int ans = 0;
  for (auto e : a) {
    if (e == -1) continue;
    ans += c[e][1];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())

print(l[k-1])

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <queue>

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

#define swap(a, b, typ) \
    do { \
        typ tmp = a; \
        a = b; \
        b = tmp; \
    } while (0)

class Elem {
    public:
        int value;
        int orig_pos;

        bool operator < (const Elem &other) const {
            return value < other.value;
        }

        bool operator > (const Elem &other) const {
            return value > other.value;
        }
};

const int MAX_N = 100000;

int n;
Elem a[MAX_N];
Elem b[MAX_N];

int tmp[MAX_N];

void print() {
    for (int i = 0; i < n; i++) {
        cout << a[i].value << " ";
    }
    cout << endl;
    for (int i = 0; i < n; i++) {
        cout << b[i].value << " ";
    }
    cout << endl;
}

void input(void) {
    cin >> n;

    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a[i] = {x, i};
    }

    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        b[i] = {x, i};
    }
}

/*
 * Sort b and swap corresponding eleements in a.
 */
void sort_b() {
    sort(&b[0], &b[n]);

    for (int i = 0; i < n; i++) {
        a[b[i].orig_pos].orig_pos = i;
        b[i].orig_pos = i;
    }
}

int count_cycles() {
    int arrow[MAX_N];
    bool visited[MAX_N];
    queue<int> que;
    int count = 0;

    for (int i = 0; i < n; i++) {
        arrow[a[i].orig_pos] = i;
        visited[i] = false;
        que.push(i);
    }

    while (!que.empty()) {
        int cur = que.front();
        int next;
        que.pop();
        if (visited[cur]) {
            continue;
        }
        visited[cur] = true;
        while (1) {
            next = arrow[cur];
            if (visited[next]) {
                break;
            }
            visited[next] = true;
            cur = next;
        }
        count++;
    }

    return count;
}

int main(void) {
    input();

    sort_b();

    sort(&a[0], &a[n]);
    for (int i = 0; i < n; i++) {
        if (a[i].value > b[i].value) {
            cout << "No" << endl;
            return 0;
        }
    }

    int cycles = count_cycles();

    if (cycles > 1) {
        cout << "Yes" << endl;
        return 0;
    }

    for (int i = 0; i < n - 1; i++) {
        if (b[i].value >= a[i + 1].value ){ 
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

ll dp[55][55][3000];

int main() {
  int N,A; cin >> N >> A;
  vector<int> x(N);
  rep(i, N) cin >> x[i];
  dp[0][0][0] = 1;
  rep(i, N) {
    rep(j, N) {
      rep(k, 3000) {
        if(dp[i][j][k]==0) continue;
        dp[i+1][j][k] += dp[i][j][k];
        dp[i+1][j+1][k+x[i]] += dp[i][j][k];
      }
    }
  }
  ull ans = 0;
  for(int i=1; i<=N; ++i) ans += dp[N][i][i*A];
  cout << ans << endl;
}


Measured memory_bytes: 65792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;
typedef long long ll;

const int MOD = 1e9+7;
const int INF = 1e9;
ll dp[123456][3] = {};
ll a[123456][3];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    rep(i,N)cin>>a[i][0]>>a[i][1]>>a[i][2];
    rep(i,3){
        dp[0][i] = a[0][i];
    }
    rep(i,N)rep(pre, 3)rep(pos, 3){
        if(pre == pos)continue;
        dp[i+1][pos] = max(dp[i+1][pos], dp[i][pre] + a[i+1][pos]);
    }
    cout<<max({dp[N][0],dp[N][1],dp[N][1]})<<endl;
}

Measured memory_bytes: 5504