akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define Rep(i, N) for(int i = 0; i < N; i++)

typedef pair<int, int> Pi;
#define fi first
#define se second

const int INF = 1 << 28;
signed main()
{
  int N;
  Pi P[20005];

  cin >> N;
  Rep(i, N) {
    cin >> P[i].fi; P[i].se = i;
  }
  
  sort(P, P + N);
  
  int A[20005], B[20005];
  
  int a, b;
  a = b = 0;
  A[0] = a, B[0] = b;
  
  Rep(i, N - 1) {
    int sa1 = P[i + 1].se - P[i].se;
    int sa2 = P[i + 1].se - P[0].se;
    if(sa1 < 0) {
      a++; b = sa2 - a;
    } else {
      b--; a = sa2 - b;
    }
    
    A[i + 1] = a, B[i + 1] = b;
  }

  Rep(i, N - 1) cout << A[i] + INF << " "; cout << A[N - 1] + INF << endl;
  Rep(i, N - 1) cout << B[i] + INF << " "; cout << B[N - 1] + INF << endl;

  return 0;
}
  


Measured memory_bytes: 1280
import numpy as np

H,W = map(int,input().split())

A = np.array(tuple(tuple(map(int,input().split())) for _ in range(H)))
B = np.array(tuple(tuple(map(int,input().split())) for _ in range(H)))

D = np.abs(A-B)
del A,B

if W > H:
    W,H = H,W
    D = D.T

L = D.max()*(H+W-1)+1
dp0 = np.zeros((W,L), dtype=bool)
dp1 = np.zeros_like(dp0)

dp1[0,D[0,0]] = True
for y in range(H):
    for x,d in enumerate(D[y]):
        dp1[x,d:] |= dp0[x,:L-d]
        dp1[x,:L-d] |= dp0[x,d:]
        dp1[x,:d] |= dp0[x,d:0:-1]
        dp1[x,d:] |= dp1[x-1,:L-d]
        dp1[x,:L-d] |= dp1[x-1,d:]
        dp1[x,:d] |= dp1[x-1,d:0:-1]
    dp0,dp1 = dp1, dp0
    dp1.fill(False)

print(next(i for i,v in enumerate(dp0[-1]) if v))


Measured memory_bytes: 14704
#include <bits/stdc++.h>
using namespace std;
long double n,k,z,x,c,zx,s,a1=1,a2=2;
int main()
{
    cin>>n>>k;
    z=1/n;
    for(int i=1;i<=n;i++){
       zx=i;x=1;
       while(zx<=k-1){
          x=x*(a1/a2);
          zx*=2;
       }
       s+=z*x;
    }
    cout<<fixed<<setprecision(9)<<s<<endl;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using namespace std;

int main()
{
    ll n;
    cin >> n;
    vector<ll> v(n);
    ll ma = 0;

    rep(i, n) {
        cin >> v[i];
    }
    auto v2 = v;
    std::sort(v2.begin(),v2.end(),std::greater<ll>());

    for(ll i = 0; i < n; ++i) {
        ll res = 0;
        if (v2[0] == v[i]) {
            cout << v2[1] << endl;
        }
        else {
            cout << v2[0] << endl;
        }
        //     rep(j, n) {
        //         if (i == j) continue;
        //         res = max(res, v[j]);
        //     }
        //     cout << res << endl;
        // }
        // else {
        //     cout << res << endl;
        // }
    }
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    string S; cin >> S;
    long long K; cin >> K;

    for (long long i = 0; i < K; ++i) {
        if (S[i] != '1') {
            cout << S[i] << endl;
            return 0;
        }
    }
    cout << '1' << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
d=dict()
for _ in range(m):
  a,b=map(int,input().split())
  if a not in d:
    d[a]=1
  else:
    d[a]+=1
  if b not in d:
    d[b]=1
  else:
    d[b]+=1
d=list(d.items())
for node,cnt in d:
  if cnt%2:
    print('NO')
    exit()
print('YES')

Measured memory_bytes: 14948
#include <iostream>

using namespace std;

int main(void){
    int num, tmp;
    cin >> num;
    tmp = num % 10;
    switch (tmp) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

typedef long long ll;

int main()
{ int N; cin >> N;
 ll s = (ll) sqrt( (double) N);
 
 ll max_c = 1;
 
 for(ll c = 1; c <= s; c++){
   if(c * c <= N){ max_c = max(max_c, c*c);}}
 
 cout << max_c << endl;
 
 return 0;}
 

Measured memory_bytes: 256
if __name__ == "__main__":
    N = int(input())
    S = list(map(int, input().split()))
    S.extend([-1, float('inf')])
    S.sort()
    # print(S)
    Q = int(input())
    T = list(map(int, input().split()))
    ans = 0
    for ti in T:
        for sj in S:
            if sj==ti:
                ans += 1
                break

    print(ans)



Measured memory_bytes: 6552
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp14
{
    class Class4
    {
        static void Main()
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            int C = int.Parse(Console.ReadLine());
            int X = int.Parse(Console.ReadLine());

            int count = 0;
            for(int i = 0; i <= A; i++)
            {
                for(int j = 0; j <= B; j++)
                {
                    int k = (X - 500 * i - 100 * j) / 50;
                    if (k <= C&k>=0) count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

bool isprime(int n){
	if (n == 1){
		return false;
	}
	if (n == 2){
		return true;
	}
	int sq = (int)sqrt(double(n)) + 1;
	for (int i = 2; i <= sq; i++){
		if (n%i == 0){
			return false;
		}
	}
	return true;
}

int main(){
	int N, C, K;
	cin >> N >> C >> K;
	vector<ll> T;
	int i, j, k;
	for (i = 0; i < N; i++){
		ll t;
		cin >> t;
		T.push_back(t);
	}
	sort(T.begin(), T.end());
	T.push_back(1e9);
	int nw, tw, ans;
	nw = 0;
	ans = 0;
	for (i = 0; i < N; i++){
		if (nw == 0){
			tw = T[i];
		}
		nw++;
		if (nw == C){
			ans++;
			nw = 0;
		}
		else if (T[i + 1] - tw > K){
			ans++;
			nw = 0;
		}
	}
	if (nw != 0){
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  int x,y,z;
  cin>>x>>y>>z;
  swap(x,y);
  swap(x,z);
  cout<<x<<" "<<y<<" "<<z<<endl;
}

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

int main() {
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  int pizza = 0;
  int E = C*2;
  if (A+B <= E)
    pizza = A*X + B*Y;
  else if (E <= min(A,B))
    pizza = E*max(X,Y);
  else if (X > Y)
    pizza = E*Y + min(A,E)*(X-Y);
  else
    pizza = E*X + min(B,E)*(Y-X);
  cout << pizza << endl;
} 

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

const int INF = 1001001001;

int a[12][12];

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  rep(i,n){
    cin >> c[i];
    rep(j,m){
      cin >> a[i][j];
    }
  }
  int ans = INF;
  rep(s,1<<n){
    int cost = 0;
    vector<int> d(m);
    rep(i,n){
      if(s>>i&1){
        cost += c[i];
        rep(j,m){
          d[j] += a[i][j];
        }
      }
    }
      bool ok = true;
      rep(j,m){
        if(d[j] < x) ok = false;
      }
        if(ok) ans =  min(ans, cost);
      }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
  
}



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

using namespace std;

const int maxi=1e6;
int n;
int a[maxi];
long long ans;
set<int> st;
int main()
{
    cin>>n;

   while(n--)
   {
       int x;
     scanf("%d",&x);
     if (*st.lower_bound(x)==x) st.erase(x); else st.insert(x);
   }

   cout<<st.size();

  return 0;
}


Measured memory_bytes: 4864
program abc121d
  integer(8) :: a, b, x(0:3), y(0:3)
  read *, a, b
  x = [a, 1_8, a+1, 0_8]
  y = [b, 1_8, b+1, 0_8]
  print *, xor(a,xor(x(mod(a,4)),y(mod(b,4))))
end program abc121d


Measured memory_bytes: 768
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(void){
	int n,k,i,ans=0;
	cin>>n>>k;
	int x;
	for(i=0;i<n;i++){
		cin>>x;
		ans+=min(abs(0-x),abs(k-x));
	}
	cout<<ans*2<<endl;
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = -1000000000
for i in range(N):
  cost = 0
  S = []
  x = P[i] - 1
  l = 1
  while 1:
    cost += C[x]
    S.append(cost)
    if x == i:
      break
    l += 1
    x = P[x] - 1
  if cost > 0:
    for j in range(l):
      ans = max(ans, S[j] + cost * ((K - j - 1) // l))
  else:
    ans = max(ans, max(S[:min(K, l)]))
print(ans)

Measured memory_bytes: 81416
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll m, k;
  cin >> m >> k;
  vl ans;
  bool ok = true;
  if(m == 0) {
    if(k != 0) ok = false;
    ans = {0, 0};
  } else if(m == 1) {
    if(k != 0) ok = false;
    ans = {0, 0, 1, 1};
  } else {
    if(k == 0) {
      rep(i, 1 << m) rep(_, 2) ans.push_back(i);
    } else {
      if(k >= (1 << m)) ok = false;
      ans = {0, k, 0};
      rep2(i, 1, 1 << m) if(i != k) ans.push_back(i);
      ans.push_back(k);
      for(ll i = (1 << m) - 1; i > 0; i--)
        if(i != k) ans.push_back(i);
    }
  }
  if(ok) {
    for(auto v : ans) cout << v << ' ';
    cout << endl;
  } else
    cout << -1 << endl;
}

Measured memory_bytes: 6416
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define CMAX(m, x)  m = max(m,x);
#define CMIN(m, x)  m = min(m,x);
#define itn int
typedef long long lint;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    int n;
    cin >> n;
    set<string> kuji;
    REP(i,n){
        string s;
        cin >> s;
        kuji.insert(s);
    }
    cout << kuji.size() << endl;
    return 0;
}

Measured memory_bytes: 19224
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
const long long MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}



ll cnt(ll x, ll dep, vector<ll> &barg, vector<ll> &paty){
    if(dep<=0) return (x<=0)?0:1;
    if(x<=barg[dep-1]+1)return cnt(x-1,dep-1,barg,paty);
    else{
        return paty[dep-1]+1 + cnt(x-2-barg[dep-1],dep-1,barg,paty);
    }
}


int main() {
    ll n,x;cin>>n>>x;
    
    vector<ll> barg(n+1);
    vector<ll> paty(n+1);
    barg[0]=1LL;
    paty[0]=1LL;
    rep(i,n){
        barg[i+1]=barg[i]*2+3;
        paty[i+1]=paty[i]*2+1;
    }
    ll ans = cnt(x,n,barg,paty);

        
    cout<<ans<<endl;

    return 0;
}









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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll n;
vl a;
vl b;
vl ans;

int main(){
  cin >> n;
  a = vl(n);
  for(ll i = 0;i < n;i++) cin >> a[i];
  for(ll i = 1,j = 0;j < n;i = (i+2)%n,j++){
    b.push_back(a[(i+1)%n]-a[i]);
  }
  for(ll i = 1;i < n;i++){
    b[i] += b[i-1];
  }
  ll rui = accumulate(b.begin(),b.end(),0ll);
  ll all = accumulate(a.begin(),a.end(),0ll);
  // cout << (all/2-rui)/n << endl;
  ll x = (all/2-rui)/n;
  ans = vl(n);
  for(ll i = 3%n,j = 0;j < n;i = (i+2)%n,j++){
    ans[i] = 2*(x+b[j]);
  }
  for(ll i = 0;i < n-1;i++) cout << ans[i] << " ";
  cout << ans[n-1] << endl;

}


Measured memory_bytes: 3828
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:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        xs: [(u64,u64);n]
    }
    let mut xs = xs;
    xs.sort_by(|l,r| {
        if l.1 != r.1 { l.1.cmp(&r.1) }
        else { l.0.cmp(&r.0) }
    });
    let mut t = 0;
    for (a,b) in xs {
        t += a;
        if b < t {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


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

void input(string& rsColor)
{
  int nColorSiz;
  cin >> nColorSiz >> rsColor;
}

int calcColor(string sColor)
{
  int nColorCnt = 0;
  int nFwd = 0;

  while (nFwd < sColor.size() )
  {
    while ( nFwd < sColor.size() - 1   &&
            sColor[nFwd] == sColor[nFwd + 1] )
      ++nFwd;

    ++nColorCnt;
    ++nFwd;
  }
  return nColorCnt;
}

int main()
{
  string sColor;

  input(sColor);
  cout << calcColor(sColor) << endl;

  return 0;
}

Measured memory_bytes: 3824
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
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; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

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

    int N, M;cin >>N>>M;
    VVI A(N, VI(M));
    VI food(M, 0);
    REP(i, N)
    {
        int K;cin>> K;
        REP(j, K)
        {
            int a;
            cin >> a;
            food.at(a-1)++;
        }
    }
    int ans=0;
    REP(i, M)
    {
        if (food.at(i)==N)
        {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

s,t = input().split()
a,b = inpm()
u = input()

if u == s:
    a -= 1
elif u == t:
    b -= 1

print(a,b)

Measured memory_bytes: 31280
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    auto s = new bool[](10^^6 + 1);
    s[] = 1;
    s[0] = s[1] = 0;

    for (int p = 2; p*p <= 10^^6; p++) {
        if (s[p]) {
            for (int q = p*p; q <= 10^^6; q += p) {
                s[q] = 0;
            }
        }
    }

    while (1) {
        int a, d, n;
        scan(a, d, n);

        if (!a) return;

        int m;

        while (m < n) {
            if (s[a]) m++;
            a += d;
        }

        a-=d;

        writeln(a);
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

int main(){
    long long n;
    double prev=0,now=0;
    while(cin>>n){
        if(n==-1)break;
        now = n/2.0;
        while(!(abs(pow(now,3) - n ) < (0.00001 * n))){
            prev = now;
            now = prev - (pow(prev, 3) - n)/(3*pow(prev,2));
        }
        printf("%.6f\n", now);
    }
    
}


Measured memory_bytes: 3116
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int l;
  cin >> l;
  string s, t;
  cin >> s >> t;
  int n = (int) s.size(), m = (int) t.size();
  string ans = "{";
  auto make = [] (int x, string s) -> string {
    string res;
    for (int i = 0; i < x; i++) res += s;
    return res;
  };
  for (int i = 0; i * n <= l; i++) {
    if ((l - i * n) % m == 0) {
      ans = min(ans, make(i, s) + make((l - i * n) / m, t));
      ans = min(ans, make((l - i * n) / m, t) + make(i, s));
      break;
    }
  }
  for (int i = l / n; i >= 0; i--) {
    if ((l - i * n) % m == 0) {
      ans = min(ans, make(i, s) + make((l - i * n) / m, t));
      ans = min(ans, make((l - i * n) / m, t) + make(i, s));
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

const LL MOD = 1000000007;
int main() {
  LL N;
  cin >> N;
  VEC<LL> A(N, 0);
  REP(i, 0, N) { cin >> A[i]; }
  VEC<LL> nums(N, 0);
  LL sum = 1;
  REP(i, 0, N) {
    LL p = (A[i] - 1 >= 0 ? nums[A[i] - 1] : 3) - nums[A[i]];
    sum = (sum * p) % MOD;
    // DUMP(nums, p, sum);
    nums[A[i]]++;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1920
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    a = LI()
    b = LI()
    a.sort(reverse = True)
    b.sort(reverse = True)
    if len(set(a)) < n or len(set(b)) < m:
        print(0)
        return
    if a[0] != b[0]:
        print(0)
        return
    ans = 1
    s = 0
    for i in range(1,n*m+1)[::-1]:
        l = 0
        r = n
        while r-l > 1:
            mid = (l+r) >> 1
            if a[mid] >= i:
                l = mid
            else:
                r = mid
        x = l
        l = 0
        r = m
        while r-l > 1:
            mid = (l+r) >> 1
            if b[mid] >= i:
                l = mid
            else:
                r = mid
        y = l
        if a[x] == i:
            if b[y] == i:
                k = 1
            else:
                k = y+1
        else:
            if b[y] == i:
                k = x+1
            else:
                k = (x+1)*(y+1)-s
        ans *= k
        ans %= mod
        s += 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 44636
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
	ll n, d;
	cin >> n >> d;
	ll result = 0;

	rep(i, n) {
		ll x, y;
		cin >> x >> y;
		if (sqrt(x * x + y * y) <= d) {
			result++;
		}
	}
	cout << result << endl;

}


Measured memory_bytes: 3672
#include <stdio.h>

void insertionSort(int *, int);
void output(int *, int);

int main(){
  
  int A[1000], N, i, v; 

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

  output(A,N);
  insertionSort(A, N);
  
  return 0;
}
    
void insertionSort(int A[], int N)
{
  int i, j, v;
  
  for(i=1; i<N; i++){
    v=A[i];
    j=i-1;
    
    while( j>=0 && A[j]>v ){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    output(A,N);
  }
}

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

Measured memory_bytes: 608
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n;
  cin >> n;
  mat x;
  for(ll i=0;i<n;i++){
    ll a;
    cin >> a;
    x.push_back({a,i});
  }

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

  ll b[n]={};

  for(ll i=0;i<n;i++){
    b[x[i][1]]=i+1;
  }

  //for(ll i=0;i<n;i++)cout << b[i] << endl;

  for(ll i=0;i<n;i++){
    if(b[i]<=n/2)cout << x[n/2][0] << endl;
    else cout << x[n/2-1][0] << endl;
  }



  

}

Measured memory_bytes: 15868
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<queue>
#define For(i,j,k)  for(int i=j;i<=k;++i)
#define Dow(i,j,k)  for(int i=k;i>=j;--i)
#define ll long long
#define inf 1e9
#define pb push_back
#define local freopen("in.in","r",stdin);
#define c(x,y)  ((x-1))*m+(y)
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read()
{
	ll t=0,f=1;char c=gc();
	while(!isdigit(c))  {if(c=='-') f=-1;c=gc();}
	while(isdigit(c))   t=t*10+c-'0',c=gc();
	return t*f;
}
inline void write(ll x){if(x<0) {putchar('-');write(-x);return;}if(x>=10)    write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);puts("");}
inline void write_p(ll x){write(x);putchar(' ');}

struct node{ll x,v;}	p[200001];
ll n,c,s[200001],d[200001],s1[200001],s2[200001],d1[200001],d2[200001];
ll ans=0;
inline bool cmp(node x,node y)
{
	return x.x<y.x;
}
int main()
{
	n=read();c=read();
	For(i,1,n)	p[i].x=read(),p[i].v=read();
	sort(p+1,p+n+1,cmp);
	For(i,1,n)	s[i]=s[i-1]+p[i].v;
	Dow(i,1,n)	d[i]=d[i+1]+p[i].v;
	
	For(i,1,n)	s1[i]=s[i]-p[i].x,s2[i]=s[i]-p[i].x*2;
	For(i,1,n)	d1[i]=d[i]-(c-p[i].x),d2[i]=d[i]-(c-p[i].x)*2;
	
	Dow(i,1,n)	d1[i]=max(d1[i],d1[i+1]),d2[i]=max(d2[i],d2[i+1]);
	For(i,1,n)	s1[i]=max(s1[i],s1[i-1]),s2[i]=max(s2[i],s2[i-1]);
	
	For(i,1,n)
	{
//		cout<<s1[i]<<' '<<d1[i]<<' '<<s2[i]<<' '<<d2[i]<<endl;
		ll tmp=max(s1[i],d1[i]);
		if(i!=n)	tmp=max(tmp,s2[i]+d1[i+1]);
		if(i!=1)	tmp=max(tmp,s1[i-1]+d2[i]);
		ans=max(ans,tmp);
	}
	writeln(ans);
}

Measured memory_bytes: 11776
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define rrep(i,m,n) for(int i = m; i >= n; i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    ll a[110];
    cin >> N >> K;
    rep(i,0,N){
        cin >> a[i];
    }
    ll grundy[100010] = {};
    rep(i,0,K+1){
        map<ll,ll> mp;
        rep(j,0,N){
            if(i - a[j] >= 0){
                mp[grundy[i-a[j]]]++;
            }
        }
        ll min_val = 0;
        rep(j,0,N+1){
            if(mp[j] == 0){
                min_val = j;
                break;
            }
        }
        grundy[i] = min_val;
    }
    // printa(grundy, K);
    if(grundy[K] == 0){
        print("Second");
    }else{
        print("First");
    }
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[] a = new int[10];
			for (int i = 0; i < n; i++) {
				int b = scanner.nextInt();
				a[b]++;
			}
			int sum = 0;
			for (int i = 1; i < 5; i++) {
				int c = Math.min(a[i], a[10 - i]);
				sum += c;
				a[i] -= c;
				a[10 - i] -= c;
			}
			sum += a[5] / 2;
			a[5] %= 2;
			ans = -1;
			dfs(1, 0, a, 0);
			System.out.println(sum + ans);
		}

	}

	int ans;

	private void dfs(int i, int sum, int[] a, int now) {
		int rem = sum;
		for (int j = 1; j < 10; j++)
			rem += a[j] * j;
		if (now + rem / 10 <= ans)
			return;
		ans = Math.max(ans, now);
		if (sum == 10) {
			dfs(1, 0, a, now + 1);
			return;
		}
		if (i >= 10)
			return;
		dfs(i + 1, sum, a, now);
		if (a[i] > 0 && sum + i <= 10) {
			a[i]--;
			dfs(i, sum + i, a, now);
			a[i]++;
		}
	}
}

Measured memory_bytes: 30604
//
// Created by yamunaku on 2019/09/28.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    string s;
    cin >> s;
    int m=stoi(s.substr(5,2));
    int d=stoi(s.substr(8,2));
    if(m<4){
        cout << "Heisei" << endl;
    }else if(m==4&&d<=30){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }

    return 0;
}


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

 

signed main(){
   int n,t[26]={};
    string s;
    cin >>n>>s;
    int k=1;
    for(int i=0;i<n;i++){
        t[s[i]-'a']++;
    }
    int ans=1;
    int INF=1e9+7;
    for(int i=0;i<26;i++)if(t[i]!=0)ans=ans*(1+t[i])%(INF);
   cout <<ans-1;



    return 0;
}


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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

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

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

ll thick[55];
ll pate[55];


ll ans=0;
ll x, N;

ll dfs(int p)
{
    ll ret = 0;
    if(x==thick[p])
    {
        x=0;
        return pate[p];
    }
    if(thick[p-1] +1 == x)  //この+1はp次元のbのせい
    {
        ret += pate[p-1];
        x = 0;
        return ret;
    }
    if(thick[p-1] == x)
    {
        ret += pate[p-1];
        if(p==1)  //x!=1のとき，端はbだが，x==1のとき，端がpになるため 
        {
            ret--;
        }    
        x=0;
        return ret;
    }
    if(thick[p-1]+2 <= x)
    {
        ret += pate[p-1]+1; //+1はp次元の真ん中のp
        x -= thick[p-1]+2;
    }
    else
    {
        x--;
    }
    if(x==0)
    {
        return ret;
    }
    ret += dfs(p-1);

    return ret;
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    cin >> N >> x;

    thick[0]=pate[0]=1;

    rep(i, 55)
    {
        thick[i+1]=2*thick[i]+3;
        pate[i+1]=2*pate[i]+1;
    }
    cout << dfs(N) << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, N, M, X, A[101];
	scanf("%d %d %d", &N, &M, &X);
	for (i = 1; i <= M; i++) scanf("%d", &(A[i]));

	int B[101] = {};
	for (i = 1; i <= M; i++) B[A[i]] += 1;

	int neg = 0, pos = 0;
	for (i = X; i >= 0; i--) neg += B[i];
	for (i = X; i <= N; i++) pos += B[i];
	
	if (neg < pos) printf("%d\n", neg);
	else printf("%d\n", pos);
	fflush(stdout);
	return 0;
}

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

int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k%2==0)cout<<a-b<<endl;
    else cout<<b-a<<endl;
    return 0;
}

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


int n, k;
const int MOD = 1e9 + 7;
const int MAX = 1e6;
ll fac[MAX], finv[MAX], inv[MAX];


void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


ll comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void input() {
    cin >> n >> k;
}


int main() {
    comb_init();
    input();
    vector<ll> w(n);
    w[0] = 1;
    for (int i = 1; i < n; i++) {
        w[i] = (w[i-1] + comb(n, i) * comb(n - 1, n - i - 1)) % MOD;
    }
    ll ans = w[min(k, n - 1)];
    cout << ans << endl;
}


Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10,INF=0x3f3f3f3f;
int n,a[N],dp[N],ans[N];
int u,v;
vector<int>e[N];
void dfs(int u,int fa){
    int pos=lower_bound(dp,dp+n,a[u])-dp;
    int x,y;
    x=dp[pos];
    dp[pos]=a[u];
    ans[u]=lower_bound(dp,dp+n,INF)-dp;
    for(int i=0;i<e[u].size();++i){
        int v=e[u][i];
        if(v==fa)continue;
        dfs(v,u);
    }
    dp[pos]=x;
}
int main(){
    memset(dp,INF,sizeof dp);
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<n;++i){
        scanf("%d%d",&u,&v);
        e[u].push_back(v);
        e[v].push_back(u);
    }
    dfs(1,-1);
    for(int i=1;i<=n;++i){
        printf("%d\n",ans[i]);
    }
    return 0;
}


Measured memory_bytes: 31424
// abc138_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<deque<int>> A;
    A.assign(N, deque<int>(N-1, 0));
    REP(i, N) REP(j, N-1){
        cin >> A[i][j]; A[i][j]--;
    }

    int ans = 0;
    while (true) {
        set<P> st;
        bool continuing = false;
        bool updating = false;
        REP(i, N) {
            if (A[i].size() == 0) continue;

            continuing = true;
            P p = i < A[i][0] ? P(i, A[i][0]) : P(A[i][0], i);
            if (st.find(p) != st.end()) {
                A[p.first].pop_front();
                A[p.second].pop_front();
                updating = true;

//                while (true) {
//                    P p = i < A[p.first][0] ? P(p.first, A[p.first][0]) : P(A[p.first][0], p.first);
//                    if (st.find(p) != st.end()){
//                        
//                    }
//                }
            } else {
                st.insert(p);
            }
        }
        if (not continuing) break;

        if (not updating){
            print(-1);
            return 0;
        }
        ans++;
        
        if (ans > 10000){
            print(N * (N-1) / 2);
            return 0;
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  if(A == B)
    cout << C << endl;
  else if(B == C)
    cout << A << endl;
  else
    cout << B << endl;
      
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
bool j(long n , long a ,long b){
    long g = 0;
    while(n!=0){
        g+=n%10;
        n -=n%10;
        n/=10;
    }
    if(g>=a && g<=b)return true;
    else return false;
}


int main(){
    long n ,a ,b;
    scanf("%ld %ld %ld" , &n ,&a, &b);
    long long sum = 0;
    for(int i=1 ; i<=n ;i++){
        if(j(i , a , b)){
            sum += i;
        }
    }
    printf("%lld\n" , sum);
    return 0;
}

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

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int num, slot, i, time, current_time = 0;
	string temp;
	deque<int> d;
	deque<string> d_no;
	deque<int> d_final;
	
	cin >> num >> slot;
	
	for(i = 0; i < num; i++){
		cin >> temp >> time;
		d.push_back(time);
		d_no.push_back(temp);
	}
	
	while(d.size() != 0){
		if(d.front() > slot){
			d.push_back(d.front() - slot);
			d_no.push_back(d_no.front());
			d.pop_front();
			d_no.pop_front();
			current_time += slot;
		}
		else{
			current_time += d.front();
			cout << d_no.front() << " " << current_time << endl;
			d.pop_front();
			d_no.pop_front();
		}
	}
	



	return 0;
}


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

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

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n;
int main() {
    cin >> n;
    for (int i = 1; i < 10; ++i) {
        if (i * 111 >= n) {
            cout << i * 111 << endl;
            exit(0);
        }
    }
    return 0;
}


Measured memory_bytes: 3560
#include <iostream>
using namespace std;
int main()
{
	int n, flag = 1;
	cin >> n;
	while (n--) {
		int x;
		cin >> x;
		if (x % 2 == 0) {
			if (x % 3 == 0 || x % 5 == 0) {

			}
			else flag = 0;
		}
	}

	if (flag) cout << "APPROVED"; else cout << "DENIED";
	return 0;
}

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

namespace Program
{
    public class ABC070D
    {
        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static int NextInt() => int.Parse(NextString());
            public static long NextLong() => long.Parse(NextString());
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static public void Main(string[] args)
        {
            var N = Console_.NextInt();
            var next = new List<Tuple<int, int>>[N];
            for (int i = 0; i < N; ++i)
            {
                next[i] = new List<Tuple<int, int>>();
            }
            for (int i = 0; i < N - 1; ++i)
            {
                var a = Console_.NextInt();
                var b = Console_.NextInt();
                var c = Console_.NextInt();
                next[a - 1].Add(Tuple.Create(b - 1, c));
                next[b - 1].Add(Tuple.Create(a - 1, c));
            }

            var Q = Console_.NextInt();
            var K = Console_.NextInt() - 1;

            var kpath = new long[N];
            var done = new bool[N];
            var queue = new Queue<int>();
            queue.Enqueue(K);
            done[K] = true;
            while (queue.Count != 0)
            {
                var item = queue.Dequeue();
                foreach (var item2 in next[item])
                {
                    if (!done[item2.Item1])
                    {
                        done[item2.Item1] = true;
                        queue.Enqueue(item2.Item1);
                        kpath[item2.Item1] = kpath[item] + item2.Item2;
                    }
                }
            }

            for (int i = 0; i < Q; ++i)
            {
                var x = Console_.NextInt() - 1;
                var y = Console_.NextInt() - 1;
                Console.WriteLine(kpath[x] + kpath[y]);
            }
        }
    }
}


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

using namespace std;

int MM = 10;
int DD = 20;
int DD_ = 19;

int calc(int y, int m, int d) {
	int ret = 0;
	for (int i=1; i<=y; i++) {
		if (i %3 == 0) {
			if (i == y) {
				ret += DD * (m-1) + d;
			} else {
				ret += DD * MM;
			}
		} else {
			if (i == y) {
				int dai = m/2 + m%2, shou = m/2;
				if (m%2==0) ret += DD*dai + DD_*(shou-1) + d;
				if (m%2==1) ret += DD*(dai-1) + DD_*shou + d;
			} else {
				ret += DD*MM/2 + DD_*MM/2;
			}
		}
	}
	return ret;
}

int main() {
	int n; cin >> n;
	
	int kinen = calc(1000, 1, 1);
	for (int i=0; i<n; i++) {
		int y, m, d; cin >> y >> m >> d;
		int birth = calc(y, m, d);
		cout << kinen - birth << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>

#define copy_arr(a, b, n)             \
    do {                              \
        for (int i = 0; i < n; i++) { \
            a[i] = b[i];              \
        }                             \
    } while (0)
int main(void)
{
    char s[100001];
    scanf("%s", s);

    int s_len = strlen(s);

    long reminder[13] = { 1 };

    long digit = 1;

    const int mod = 1000000007;
    for (int i = s_len - 1; i >= 0; i--) {
        long next_reminder[13] = { 0 };

        if (s[i] == '?') {
            for (int j = 0; j < 10; j++) {
                for (int k = 0; k < 13; k++) {
                    next_reminder[(j * digit + k) % 13] += reminder[k];
                    next_reminder[(j * digit + k) % 13] %= mod;
                }
            }
        } else {
            int j = s[i] - '0';
            for (int k = 0; k < 13; k++) {
                next_reminder[(j * digit + k) % 13] += reminder[k];
                next_reminder[(j * digit + k) % 13] %= mod;
            }
        }

        copy_arr(reminder, next_reminder, 13);
        digit *= 10;
        digit %= 13;
    }

    printf("%ld\n", reminder[5]);
    return 0;
}


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

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define ceil(a,b) (a+b-1)/b
#define endl "\n"

#define oa(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define o1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define o2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define o3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define o4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int a,b,n;
    cin>>a>>b>>n;
    n=min(n,b-1);
    cout<<(a*n)/b-a*(n/b);








	
return 0;
}


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

using namespace std;
void print(vector<int> a);
long long int gcd(long long int x,long long int y);

int main(){
    int x,y;
    cin >> x >> y;
    cout << gcd(x,y) << endl;

    return 0;
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

long long int gcd(long long int x, long long int y){
    if (x < y) swap(x,y);
    while (y > 0){
        long long int r = x % y;
        x = y;
        y = r;
    }
    return x;
}

//Sum accumulate(v.begin(),v.end(),0);
//Sort sort(v.begin(),v.end())
//Power pow(base, e)
//Min min = *std::min_element(vec.begin(), vec.end());
//Max max = *std::max_element(vec.begin(), vec.end());



Measured memory_bytes: 3116
S = list(input())
T = list(input())
LS = len(S)
LT = len(T)
for i in reversed(range(LS - LT + 1)):
    for j in range(LT):
        if S[i + j] != T[j] and S[i + j] != "?":
            break
        if j == LT - 1:
            for k in range(LT):
                S[i + k] = T[k]
            s = str("".join(S)).replace("?", "a")
            print(s)
            exit()
print("UNRESTORABLE")


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] n = scanner.next().toCharArray();
			int sum = 0;
			for (int i = 0; i < n.length; i++) {
				sum = (sum + (n[i] - '0')) % 9;
			}
			System.out.println((0 == sum) ? "Yes" : "No");
		}
	}
}


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

int main(){
  map<int,int> m;
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    int d;
    cin>>d;
    for(int j=0;j<d;j++){
      int x;
      cin>>x;
      m[x]++;
    }
  }
  int ans=0;
  for(int i=1;i<=n;i++) if(m[i]==0) ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 3600