akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case, unused)]
use std::collections::*;

////////// missing functions in 1.15.1 //////////
macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}
/////////////////////////////////////////////////
pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

fn run() {
	let (N, W) = read!(usize, usize);
	let mut crt = vec![0; W + 1];
	for (w, v) in read!(usize, i64; N) {
		for i in (w..W+1).rev() {
			let tmp = crt[i - w] + v;
			crt[i].setmax(tmp);
		}
	}
	println!("{}", crt[W]);
}


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

int main()
{
    int N, T;
    vector<int> c, t;
    cin >> N >> T;
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        c.push_back(x);
        t.push_back(y);
    }
    int route = -1;
    int route_cost = 9999;
    for (int i = 0; i < N; i++) {
        if (t[i] <= T && c[i] < route_cost) {
            route = i;
            route_cost = c[i];
        }
    }
    if (route == -1) cout << "TLE" << endl;
    else cout << route_cost << endl;
    return 0;
}

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

#define SLAY ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define LL long long
#define PII pair<int , int>
#define PLL pair<long long , long long>
#define INPUT freopen("/Users/amrfahmy/Documents/Problem solving/CF/CF/input.txt", "r", stdin);
using namespace std;
 
const LL MOD = 1000000007;
LL a[1000000];
LL b[1000000];
LL n,q,c,cnt,mx,m,temp,k;
string str;
vector< int > dp;

bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){
    return (a.first < b.first);
}

bool isprime(LL x){
    for(int i = 2 ; i * i <= x ;i++)
        if(x%i==0)return false;
    return true;
}


int main()
{
    bool readfromfile=false; if(!readfromfile){SLAY} else{INPUT}
    
 

//    cin>>n;
//    cin>>n>>m;
//    for(int i = 0 ; i < n ; i++)cin>>a[i];
//    for(int i = 0 ; i < n ; i++)cin>>b[i];

//    string str1 , str2;
//    cin>>str1>>str2;
//    cout<<str2<<str1;
    
    LL x ;
    
    cin>>x;
    
    while (!isprime(x++)) {
        
    }
    cout<<x-1;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y))
#define PI 3.14159265359
typedef long long LL;
typedef vector<vector<int>> Graph;
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
template <class T> inline T mpower(T x, T n) {
    if(n == 0) {
        return 1;
    } else if(n % 2 == 0) {
        return mpower(x * x % MOD, n / 2);
    } else {
        return x * mpower(x, n - 1) % MOD;
    }
}
LL mfrac(LL x) {
    LL res = 1;
    for(LL i = x; i >= 1; i--) {
        res *= i;
        res %= MOD;
    }
    return res;
}
LL mcomb(LL n, LL r) {

    if(n == 0 and r == 0) {
        return 1;
    } else if(n < r || n < 0) {
        return 0;
    }

    LL res = mfrac(n) * mpower(mfrac(r), MOD - 2) % MOD;
    res *= mpower(mfrac(n - r), MOD - 2) % MOD;

    return res;
}

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

    int ans = 0;
    for(int n = 1; n < dup(N, 2); n++) {
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
#include <math.h>
int ans;
int main(int argc, char* argv[]){
  long int a=0,b,c;
  scanf("%ld %ld %ld",&a,&b,&c);
  if (b/a<=c) {
    printf("%d\n",b/a);
    return 0;
  }
  printf("%d\n",c);
}


Measured memory_bytes: 128
anslist = []

while(1):
    s = input()
    if s == "-":
        for ans in anslist:
            print(ans)
        break
    m = int(input())
    hlist = []
    for _ in range(m):
        h = int(input())
        hlist.append(h)

    for h in hlist:
        s = s[h - len(s):] + s[:h]
    anslist.append(s)



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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 200010

int N, Q;
vector<int> graph[MAX_N];
vector<int> ans;

// ノード i を見ていて、親が par, 現在の値が cur
void dfs(int i, int par, int cur) {
    ans[i] += cur;
    for(auto& next_i : graph[i]) {
        if(par == next_i) { continue; }
        dfs(next_i, i, ans[i]);
    }
}

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

    cin >> N >> Q;
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    ans.assign(N, 0);

    REP(i, Q) {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }

    dfs(0, -1, 0);

    REP(i, ans.size()) {
        printf("%lld%c", ans[i], (i == ans.size()-1) ? '\n' : ' ');
    }


    return 0;
}


Measured memory_bytes: 24320
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define mp make_pair
#define maxn 250005
using namespace std;
const int inf = 0x3f3f3f3f;
const int neginf = 0xc0c0c0c0;
typedef long long ll;
typedef pair<int,int> P;
int n,x0[maxn],x1[maxn],y0_[maxn],y1_[maxn];
int sum,h,w,a[505][505];
int main(){
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			scanf("%d",&a[i][j]);
			sum = ((sum + a[i][j]) & 1);
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(i == h && j == w) break;
			if(a[i][j] & 1){
				n++;
				x0[n] = i,y0_[n] = j;
				if(j == w){
					x1[n] = i + 1,y1_[n] = j;
				}else{
					x1[n] = i,y1_[n] = j + 1;
				}
				a[x0[n]][y0_[n]]--;
				a[x1[n]][y1_[n]]++;
			}
		}
	}
	printf("%d\n",n);
	for(int i=1;i<=n;i++){
		printf("%d %d %d %d\n",x0[i],y0_[i],x1[i],y1_[i]);
	}
	return 0;
}


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

int main(){
  int a[5],r; int min=10; int p; 
  for(int i=0; i<5; i++){
    cin >> a[i]; r=a[i]%10;
    if(r!=0 && r<min){min = r; p=i;}
  }
  
  int sum=0;
  for(int i=0; i<5; i++){
    if(i!=p){
      sum = sum + 10*(a[i]/10);
      if(a[i]%10!=0){sum+=10;}
    }
    else{sum += a[i];}
  }
  
  cout << sum;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		int ans = 0;
		ans = Math.max(0,A - 2*B);
		System.out.println(ans);
		
	}

}


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

using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n));
    for(int i=0; i<n; ++i) {
        for(int j=0; j<n; ++j) {
            cin >> a[i][j];
        }
    }
    vector<vector<int>> sum(n, vector<int>(n+1));
    for(int i=0; i<n; ++i) {
        for(int j=0; j<n; ++j) {
            sum[i][j+1] += sum[i][j] + a[i][j];
        }
    }
    int res = -1e9;
    for(int i=0; i<=n; ++i) {
        for(int j=i+1; j<=n; ++j) {
            int t = 0;
            for(int k=0; k<n; ++k) {
                if(t < 0) {
                    t = sum[k][j] - sum[k][i];
                } else {
                    t += sum[k][j] - sum[k][i];
                }
                res = max(res, t);
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3240
#include "bits/stdc++.h"
using namespace std;
 
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
 
int main(){
  string s;
  int i;
  char c;
  for(i=0;i<4;i++){
    cin>>c;
    s.push_back(c);
  }
  if(s=="YAKI"){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

using namespace std;

typedef long long ll;


int main() {
    int n;
    string s;

    cin >> n;
    cin >> s;

    for (int i=0; i<s.size(); i++) {
        cout << (char)((s.at(i) + n - 65) % 26 + 65);
    }
    cout << endl;
}


Measured memory_bytes: 256
import collections

N,M = map(int,input().split())
A = [list(map(int,input().split())) for i in range(N)]
favorite = []
count = 0

for i in range(1,A[0][0]+1):
    favorite.append(A[0][i])
for j in range(1,N):
    for k in range(1, A[j][0]+1):
        if A[j][k] in favorite:
            favorite.append(A[j][k])

a = collections.Counter(favorite)
for key,value in a.items():
    if value == N:
        count += 1
print(count)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main(){
    int N,K;cin>>N>>K;
    string S;cin>>S;
    char initial = S[0];
    int cnt = 0, ans = 0,last = 0;
    char find;
    if(S[0] == 'L') find = 'R';
    else find = 'L';
    rep(i,N-1) {
        if(S[i+1]==find) {
            if(find == initial) cnt++;
            if(cnt>=K) {
                last = i+1;
                // cout<<last<<endl;
                break;
            }
            if(find == 'L') find = 'R';
            else find = 'L';
        }
        if(i==N-2&&find==initial) {
            last = N-1;
            // cout<<last<<endl;
        }
        if(i==N-2&&cnt<K) {
            // cout<<cnt<<endl;
            last = N-1;
        }
    }
    // cout<<last<<endl;
    ans += last;
    char now = S[last];
    for(int j = last+1;j<N;j++) {
        if(S[j] == now) {
            ans++;
        }
        now = S[j];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3756
N = int(input())
a = N % 100
b = a % 10
if b == 2 or b == 4 or b == 5 or b == 7 or b == 9:
  print('hon')
elif b == 0 or b == 1 or b == 6 or b == 8:
  print('pon')
else:
  print('bon')

Measured memory_bytes: 9184
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int a[10][7]={{0,1,1,1,1,1,1},{0,0,0,0,1,1,0},{1,0,1,1,0,1,1},{1,0,0,1,1,1,1},{1,1,0,0,1,1,0},{1,1,0,1,1,0,1},{1,1,1,1,1,0,1},{0,1,0,0,1,1,1},{1,1,1,1,1,1,1},{1,1,0,1,1,1,1}};
  int b[7],c[100],n;
  while(cin>>n&&n!=-1){
    for(i=0;i<n;i++)
      cin>>c[i];
    memset(b,0,sizeof(b));
    for(i=0;i<n;i++){
      for(j=0;j<7;j++){
	cout<<(b[j]^a[c[i]][j]);
	b[j]=(b[j]+(b[j]^a[c[i]][j]))%2;
      }
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
from sys import stdin, stdout
from bisect import bisect
def rint():
   return map(int, stdin.readline().split())

n = int(input())

a = list(rint())
b = list(rint())
c = list(rint())
a.sort()
b.sort()
c.sort()
bc = [0 for _ in range(n)]
cc = [0 for _ in range(n)]

ci = 0
for i in range(n):
   ii = bisect(b, a[i])
   if ii >= n:
      for iii in range(ci+1, ii):
         bc[iii] += bc[ci]
      ci = n
      break
   bc[ii] += 1
   for iii in range(ci+1, ii+1):
      bc[iii] += bc[ci]
   ci = ii
if ci < n-1:
   for iii in range(ci+1, n):
      bc[iii] += bc[ci]
ci = 0
for i in range(n):
   ii = bisect(c, b[i])
   if ii >= n:
      for iii in range(ci+1, ii):
         cc[iii] += cc[ci]
      ci = n
      break
   cc[ii] += bc[i]
   for iii in range(ci+1, ii+1):
      cc[iii] += cc[ci]
   ci = ii

if ci < n-1:
   for iii in range(ci+1, n):
      cc[iii] += cc[ci]

print(sum(cc))


Measured memory_bytes: 24656
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;

int main() {
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;

    bool just = true;
    vector<int> dp(n);
    map<int, vector<int>> ma;
    for (int i = 0; i < n; i++) {
        if (i > 0)dp[i] = dp[i - 1];
        if (s[i] == 'o') {
            if (i <= c)dp[i] = max(dp[i], 1);
            else dp[i] = max(dp[i], dp[i - (c + 1)] + 1);
            ma[dp[i]].push_back(i);
        }
        if (dp[i] > k)just = false;
    }

    if (just) {
        vector<int> ret;
        vector<int> route(k);
        int pos = 1145141919;
        for (int i = k; i > 0; i--) {
            int index = upper_bound(ma[i].begin(), ma[i].end(), pos - (c + 1)) - ma[i].begin() - 1;
            if (index == 0)ret.push_back(ma[i][0]);
            route[i - 1] = ma[i][index], pos = ma[i][index];
        }
        sort(ret.begin(), ret.end());

        for (int i = 0; i < k - 1; i++) {
            assert(route[i + 1] - route[i] > c);
        }

        for (auto x:ret)cout << x + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 26104
#include <bits/stdc++.h>
#define dcout cout << fixed << setprecision(15)
#define rep(i, a) for(int i = 0; i < a; i++)
#define arep(i, x) for(auto i : x)
#define all(v) v.begin(), v.end()
#define int long long
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
using namespace std;
signed main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    ans += k;
    rep(i, n - 1) {
        ans *= k - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split(" "))
S = input()
t = [0]*(N+1)
#N+1個の0を持つリスト
for i in range(N):
    if S[i:i+2] == "AC":
        #S[x, y]は文字列Sのx番目からy-1番目までの文字列
        t[i + 1] = t[i] + 1
    else:
        t[i + 1] = t[i]
#S=0123...
#T=0123...

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1]-t[l-1])
#l, r = 123...
#r番目までのときのACの数はt[r-1]

Measured memory_bytes: 6060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int n; 
int b = 0, c = 0;
int f(int x){
	return n * x * x + b * x + c;
}

int main(){
	scanf("%d", &n);
	REP(i, n){
		int x; scanf("%d", &x);
		b += -x * 2;
		c += x * x;
	}
	int ans = INT_MAX;
	int z = -b / 2 / n;
	FOR(i, z-1, z+2){
		SML(ans, f(i));
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
//CPU的循环调度：多个任务排成一列，每个任务最多被处理 q ms(时间片），
//如果 q ms之后任务尚未完成，那么该任务将被移动至队伍最末尾，
//CPU随即开始处理下一个任务
#include<iostream>
using namespace std;

#define maxx 100005
typedef struct node{
	char name[100];
	int time;
}p;
p queue[maxx];

int head,tail;
int cnt=0;
void enqueue(p qq)
{
	queue[tail]=qq;
	//queue[tail].name=qq.name;
	//queue[tail].time=qq.time;
	tail=(tail+1)%maxx;
}

p dequeue()
{
	p ttq=queue[head];
	head=(head+1)%maxx;
	return ttq;
}

bool isEmpty()
{
	return tail==head;
}

//为区分满与空，规定head与tail相隔一个空位为队列满 
 
bool ifFull()
{
	return head==(tail+1)%maxx;
}

int main()
{
	head=0;
	tail=0;
	int n,q;
	cin>>n>>q;
	p ttt;
	for(int i=0;i<n;i++)
	{
		cin>>ttt.name>>ttt.time;
		enqueue(ttt);
		//cout<<head<<" "<<tail;
	}
	while(!isEmpty())
	{
		p qq=dequeue();
		//cpu执行任务也可以封装为一个函数，就是对任务时间的处理上。 
		if(qq.time<=q)
		{
			//cout<<"...."<<endl;
			cnt+=qq.time;
			cout<<qq.name<<" "<<cnt<<endl;
		
			
		}
		else
		{
			//cout<<"!!!!"<<endl;
			cnt+=q;
			qq.time-=q;
			enqueue(qq);
		}
		//cout<<head<<" "<<tail<<endl;
	}
	return 0;
}


Measured memory_bytes: 13188
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 




////////////////////////////////////////////////////////


int main() {
    ll n; cin >> n;
    ll a = n%10;
    if(a == 3) co("bon");
    else{
        if(a == 0 || a == 1 || a == 6 || a == 8) co("pon");
        else co("hon");
    }

    return 0;
}


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

in_str = ''

for n in range(N):
    in_str = in_str + input()

ans_ac = str(in_str.count('AC'))
ans_wa = str(in_str.count('WA'))
ans_tle = str(in_str.count('TLE'))
ans_re = str(in_str.count('RE'))

print('AC x ' + ans_ac)
print('WA x ' + ans_wa)
print('TLE x ' + ans_tle)
print('RE x ' + ans_re)


Measured memory_bytes: 9392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
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; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
int main(){
  int n,m; cin >> n >> m;
  vector<pair<int,int>> p(n); rep(i,n)cin >> p[i].first >> p[i].second;
  sort(p.begin(),p.end());
  ll cnt=0,ans=0;
  rep(i,n){
    while(p[i].second){
      p[i].second--;
      cnt++;
      ans += p[i].first;
      if(cnt==m) { cout << ans; return 0; }
    }
  }

  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g,c;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[200010];//適宜変える(ecnt)
//	int inv[200010];//逆辺のindex(ecnt)
	int id[100010];//適宜変える(vcnt)
}G;
G g;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}
//int csort(const void*a,const void*b){ll p=(*(E*)a).c,q=(*(E*)b).c;return p<q?-1:p>q?1:0;}
//void makeinvedge();
void readgraph(){
	//適宜変える
	ll n;
	scanf("%lld",&n);
	rep(i,0,n-1){
		ll x,y,c;
		scanf("%lld%lld%lld",&x,&y,&c);
		x--,y--;
		g.e[2*i].s=x;
		g.e[2*i].g=y;
		g.e[2*i].c=c;
		g.e[2*i+1].s=y;
		g.e[2*i+1].g=x;
		g.e[2*i+1].c=c;
	}
	g.vcnt=n;
	g.ecnt=2*n-2;
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}


double p,tot;
//dfs
double dfs(int v,int pre){
	double s=0;
	rep(i,g.id[v],g.id[v+1]){
		if(g.e[i].g!=pre)s+=dfs(g.e[i].g,v)+g.e[i].c;
	}
	return s*p+tot;
}

int main(){
	scanf("%lf",&p);
	readgraph();
	tot=dfs(0,-1);
	printf("%.9f\n",dfs(0,-1));
}


Measured memory_bytes: 13180
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int x = i;
        if (x % 3 == 0)
        {
            cout << " " << i;
            continue;
        }
        while (x)
        {
            if (x % 10 == 3){
                cout << " " << i;
                break;
            }
            x /= 10;
        }
    }
    cout << endl;
    return 0;
}


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

int main(){
  int T;
  cin >> T;
  
  for(int i = 0; i < T; ++i){
    ll n, m, a, b;
    std::cin >> n >> m >> a >> b;
    std::cout << floor_sum(n, m, a, b) << std::endl;
  }
}


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

int max(int a,int b){
  if (a>b) return a;
  else return b;
}

char x[1001],y[1001];

int LCS(){
  int C[1001][1001];
  int n,m,i,j;
  m=strlen(x);
  n=strlen(y);
  int l=0;
  
  for(i=1;i<=m;i++)C[i][0]=0;
  for(j=1;j<=n;j++)C[0][j]=0;


  for(i=1;i<m;i++){
    for(j=1;j<n;j++){
      if(x[i]==y[j])C[i][j]=C[i-1][j-1]+1;
      else C[i][j]=max(C[i-1][j],C[i][j-1]);
      l=max(l,C[i][j]);
    }
  }

  return l;
}

int main(){
  int n,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    x[0]=' ';
    y[0]=' ';
    scanf("%s%s",&x[1],&y[1]);
    printf("%d\n",LCS());
  }

  return 0;
}



Measured memory_bytes: 5664
#include<stdio.h>
int main()
{	int i,j,x;
	int N;
	int count=0;

	scanf("%d",&N);
	int A[N];
	for (i = 0; i < N; i++)
	{
		scanf("%d",&A[i]);
	}
	for(i=0;i<N;i++){
		for(j=N-1;j>=i+1;j--){
			if(A[j]<A[j-1]){
				x=A[j];
				A[j]=A[j-1];
				A[j-1]=x;
				count++;
			}
		}
	}

	for(i=0;i<N-1;i++){
		printf("%d",A[i]);
		printf(" ");
		}
		printf("%d\n",A[i]);
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 1852
#include <iostream>

using namespace std;

char A,B,C,D;

int multi[8][4] = {{1,1,1,1},{1,1,1,-1},{1,1,-1,1},{1,1,-1,-1},{1,-1,1,1},{1,-1,1,-1},{1,-1,-1,1},{1,-1,-1,-1}};
int main()
{
    cin >> A >> B >> C >> D;

    int a = (int)(A - '0');
    int b = (int)(B - '0');
    int c = (int)(C - '0');
    int d = (int)(D - '0');

    int i , sum ;
    for (i = 0, sum = 0; i < 8 && sum != 7; i++){
        sum = a*multi[i][0] + b*multi[i][1] + c*multi[i][2] + d*multi[i][3];
    }

    i -= 1;
    cout << A ;
    if (multi[i][1] == 1)
        cout << '+';
    else
        cout << '-';
    cout << B ;
    if (multi[i][2] == 1)
        cout << '+';
    else
        cout << '-';
    cout << C ;
    if (multi[i][3] == 1)
        cout << '+';
    else
        cout << '-';
    cout << D ;
    cout << "=7" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
struct union_find2_2{//経路圧縮で高速化
    vector<int> par;//parは添字の親（または自分が根の時自身）を示す。
    union_find2_2(int sz){
        par.resize(sz);
        for(int i=0;i<sz;++i) par[i]=i;
    }
    int find(int a){//根を探す
        if(par[a]==a) return a;
        else return par[a] = find(par[a]); //経路圧縮！！！
    }
    void unite(int a,int b){
        int root_a = find(a),root_b = find(b);  //aの根,bの根を調べて代入。
        par[root_a] = root_b;                   //根aの親をbにする
    }
    bool same(int a,int b){
        return find(a)==find(b);
    }
};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,q;
  cin >> n >> q;
  union_find2_2 uf(n);
  REP(i,q){
    int com,x,y;
    cin >> com >> x >> y;
    if(com==0){
      uf.unite(x,y);
    }else{
      cout << uf.same(x,y) << endl;
    }
  }
}




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

int main() {
	int n, m;
	cin >> n >> m;
	int lres = 1;
	int rres = n;
	for (int i = 0; i < m; i++) {
	    int l, r;
	    cin >> l >> r;
	    if (l > lres) lres = l;
	    if (r < rres) rres = r;
	}
	if (rres >= lres) cout << rres - lres + 1;
	else cout << 0;
}

Measured memory_bytes: 256
import sys


s = input()
alpha = [chr(i) for i in range(97, 97+26)]
if s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
else:
    res = ""
    for i in alpha:
        if i not in s:
            res = i
            break
    if res != "":
        print(s+res)
        sys.exit()

    tmp_res = s
    for i in s[::-1]:
        if i == "z":
            tmp_res = tmp_res[:-1]
        elif i != "z":
            for j in alpha[alpha.index(i)+1:]:
                if tmp_res.count(j) == 0:
                    print(tmp_res.replace(i, j))
                    sys.exit()
            tmp_res = tmp_res[:-1]


Measured memory_bytes: 3064
using System;
using static System.Console;
using static MyUtil;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main()
    {
        int input = int.Parse(ReadLine());
        WriteLine(input * 2 * Math.PI);

#if DEBUG
        ReadKey();
#endif
    }
}

static class MyUtil
{
    /// <summary>
    /// 指定の桁のビットを取得します。
    /// </summary>
    /// <param name="num"></param>
    /// <param name="count">取得する桁。</param>
    /// <returns></returns>
    public static int GetBit(this int num, int count)
    {
        int mask = (int)Math.Pow(2, count - 1);
        return (num & mask) == 0 ? 0 : 1;
    }

    /// <summary>
    /// <c>int</c>を2進数ビット配列に変換します。
    /// </summary>
    /// <param name="num"></param>
    /// <returns></returns>
    public static int[] ToBitArray(this int num)
    {
        const int size = sizeof(int) * 8;
        var array = new int[size];
        for (int i = 0; i < size; i++)
        {
            array[i] = num.GetBit(size - i);
        }
        return array;
    }

    public static long[] ReadlongArray()
    {
        return ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
    }

    public static int[] ReadintArray()
    {
        return ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    }

    /// <summary>
    /// <see cref="IEnumerable{T}"/>の各要素を並べてコンソールに出力します。各要素の間には半角スペースが一つ入ります。
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="ts"></param>
    public static void WriteToConsole<T>(this IEnumerable<T> ts)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (T t in ts)
        {
            stringBuilder.Append(t.ToString());
            stringBuilder.Append(" ");
        }
        stringBuilder.Remove(stringBuilder.Length - 1, 1);
        Console.WriteLine(stringBuilder.ToString());
    }
}


Measured memory_bytes: 18500
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] point = new int[n + 1];
		int[] diff = new int[n];
		int ans = 1000000000;

		point[n] = x;

		for (int i = 0; i < n; i++) {
			point[i] = sc.nextInt();
		}

		Arrays.sort(point);

		for (int i = 0; i < n; i++) {
			diff[i] = point[i + 1] - point[i];
			if (diff[i] < ans) {
				ans = diff[i];
			}
		}
		
		for (int i = 0; i < n; i++) {
			if (diff[i] % ans != 0) {
				ans = diff[i] % ans;
			}
		}

		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 60704
#include <bits/stdc++.h>
using namespace std;
long long fac[200010], finv[200010], inv[200010]; 
long long P = 1000000007;
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 200005; i++) {
        fac[i] = fac[i - 1] * i % P;
        inv[i] = P - inv[P % i] * (P / i) % P;
        finv[i] = finv[i - 1] * inv[i] % P;
    }
}
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % P) % P;
}
int main(){
	int H, W, N; 
	cin >> H >> W >> N; 
	pair<int, int> A[3010]; 
	for(int i = 0; i < N; i++){
		cin >> A[i].first >> A[i].second; 
		A[i].first --; A[i].second--; 
	}
	A[N].first = H-1; A[N].second = W-1; 
	sort(A, A+N+1); 
	COMinit(); 
	long long dp[3010] = {}; // 初めてi番目の点でぶつかる場合の数
	for(int i = 0; i <= N; i++){
		dp[i] = COM(A[i].first + A[i].second, A[i].first); 
		for(int j = 0; j < i; j++){
			dp[i] += P - dp[j] * COM(A[i].first + A[i].second - A[j].first - A[j].second, A[i].first - A[j].first) % P; 
			dp[i] %= P; 
		}
	}
	cout << dp[N] << endl; 
}

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

int main() {
    int ans[26] = {0};
    char ch;
    while(cin >> ch) {
        if('a' <= ch && ch <= 'z') {
            ++ans[ch-'a'];
        }
        else if('A' <= ch && ch <= 'Z') {
            ++ans[ch-'A'];
        }
    }
    for(int i = 0; i < 26; ++i) {
        printf("%c : %d\n", 'a'+i, ans[i]);
    }
    return 0;
}


Measured memory_bytes: 3216
#include <cstdio>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>

using namespace std;


int main(void) {

	int A, B, max = 0;
	int result[3] = { 0 };

	cin >> A;
	cin >> B;

	result[0] = A + B;
	result[1] = A - B;
	result[2] = A * B;

	max = result[0];

	for (int i = 1; i < 3; i++) {
		if (max < result[i])
			max = result[i];
	}

	cout << max << endl;

	
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d;
	cin >> c;
	a=c/3600;
	c=c%3600;
	b=c/60;
	c=c%60;
	cout << a << ":" << b << ":" << c << endl;
	return 0;
}

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

MAP=[[0]*N for i in range(N)]
S=[0]*N
for i in range(M):
    a,b=map(int,input().split())
    MAP[a-1][b-1]+=1
    MAP[b-1][a-1]+=1
    S[a-1]+=1
    S[b-1]+=1

c=-1
s=0
while(True):
    c+=1
    if(c==N):
        break
    if S[c] == 1 :
        for i in range(N):
            if MAP[c][i] == 1 :
                MAP[c][i] = 0
                MAP[i][c] = 0
                S[c]-=1
                S[i]-=1
                s+=1
                c=-1
                break

print(s)


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

static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
  stack<int> S;
  S.push(r);
  color[r] = c;
  while (!S.empty()) {
    int u = S.top();
    S.pop();
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if (color[v] == NIL) {
        color[v] = c;
        S.push(v);
      }
    }
  }
};

void assignColor() {
  int id = 1;
  for (int i = 0; i < n; i++) {
    color[i] = NIL;
  }
  for (int u = 0; u < n; u++) {
    if (color[u] == NIL) dfs(u, id++);
  }
};


int main() {
  int s, t, m, q;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();

  cin >> q;

  for (int i = 0; i < q; i++) {
    cin >> s >> t;
    if (color[s] == color[t]) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
};



Measured memory_bytes: 8932
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define mp make_pair
const int mod=1e9+7;
void solve()
{
  int n;
  cin>>n;
  if(n%1000==0)
  {
    cout<<0<<" ";
    return;
  }
  int k=n/1000;
  k=(k+1)*1000;
  cout<<k-n<<endl;
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 3612
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<utility>
#define lint long long
#define P(x,y) ((lint)x*n+y)
#define mp make_pair
#define fir first
#define sec second
#define N 100010
using namespace std;
typedef pair<int,int> pii;
map<lint,int> f;
set<int> g[N];
queue<pii> q;
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=2*n-2;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		f[P(x,y)]++,f[P(y,x)]++;
		g[x].insert(y),g[y].insert(x);
		if(f[P(x,y)]==2) q.push(mp(x,y));
	}
	int ans=0;
	while(!q.empty())
	{
		int x=q.front().fir,y=q.front().sec;q.pop();
		if(f[P(x,y)]==2)
		{
			if(g[x].size()<g[y].size()) swap(x,y);
			while(!g[y].empty())
			{
				int t=*g[y].begin();
				f[P(x,t)]+=f[P(y,t)],f[P(y,t)]=0;
				f[P(t,x)]+=f[P(t,y)],f[P(t,y)]=0;
				g[x].insert(t),g[t].insert(x);
				g[y].erase(t),g[t].erase(y);
				if(f[P(x,t)]==2) q.push(mp(x,t));
			}
			ans++;
		}
	}
	if(ans==n-1) printf("YES\n");
	else printf("NO\n");return 0;
}

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

using namespace std;

const int N = 2e5 + 7;
int n;
int m;
vector < int > vt;


int main() {
    std :: ios :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cout << 81 * 80 * 201 << endl;
    cin >> n;
    vt.resize(n);
    for(int i = 0 ; i < n ; ++i) {
        cin >> vt[i];
    }
    long long ans = 1000;
    for(int i = 0 ; i + 1 < n ; ++i) {
        if(vt[i] >= vt[i + 1]) {
            continue;
        }
        long long dp = ans / vt[i];
        ans -= dp * vt[i];
        ans += vt[i + 1] * dp;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3648
from bisect import bisect_left , bisect_right
def main():
	n = int(input())
	a = list(map(int , input().split()))
	b = list(map(int, input().split()))
	c = list(map(int ,input().split()))
	a.sort()
	b.sort()
	c.sort()
	ans=0
	for i in b:
		k = bisect_left(a,i)
		l = bisect_right(c,i)
		ans = ans+(k*(n-l))
	print(ans)
if __name__=="__main__":
	main()

Measured memory_bytes: 105292
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine

getIntList = readIntList <$> BS.getLine

createTuple :: [[Int]] -> [(Int, Int)]
createTuple [] = []
createTuple (xs : xss)
  | length xs >= 2 = (head xs, length xs) : createTuple xss
  | otherwise = createTuple xss

main = do
  n <- getInt
  as <- getIntList
  let as' = createTuple (group (reverse(sort as)))
  if length as' == 0
    then print 0
    else do
      let c = snd (head as')
      let n
            | c >= 4 = (fst (head as')) ^ 2
            | c >= 2 && snd (head (tail as')) >= 2 = fst (head as') * fst (head (tail as'))
            | otherwise = 0
      print n


Measured memory_bytes: 20948
use std::io::stdin;
use std::vec::Vec;

mod utils {
    use std::io::BufRead;
    use std::str::{self, FromStr};

    pub struct StdinReader<R: BufRead> {
        reader: R,
        buf: Vec<u8>,
    }

    impl<R: BufRead> StdinReader<R> {
        pub fn new(reader: R) -> StdinReader<R> {
            StdinReader {
                reader: reader,
                buf: Vec::new(),
            }
        }

        #[allow(unused)]
        #[inline]
        pub fn reads<T: FromStr>(&mut self) -> T {
            self.read_until(b' ')
        }

        #[allow(unused)]
        #[inline]
        pub fn readl<T: FromStr>(&mut self) -> T {
            self.read_until(b'\n')
        }

        #[allow(unused)]
        #[inline]
        pub fn read_vec<T: FromStr>(&mut self) -> Vec<T> {
            return self.read_until::<String>(b'\n').trim().split_whitespace().map(|c| c.parse().ok().unwrap()).collect();
        }

        #[inline]
        pub fn read_until<T: FromStr>(&mut self, delim: u8) -> T {
            loop {
                self.buf.clear();
                let len = self.reader
                    .read_until(delim, &mut self.buf)
                    .expect("failed reading bytes");
                match len {
                    0 => panic!("early eof"),
                    1 if self.buf[0] == delim => (),
                    _ => {
                        if self.buf[len - 1] == delim {
                            self.buf.truncate(len - 1);
                        }
                        break;
                    }
                }
            }

            let elem = unsafe { str::from_utf8_unchecked(&self.buf) };
            elem.parse().unwrap_or_else(|_| panic!(format!("failed parsing: {}", elem)))
         }
    }
}


fn main(){
    let stdin = stdin();
    let mut r = utils::StdinReader::new(stdin.lock());

    let n:usize = r.reads();
    let k:usize = r.readl();

    let h_s:Vec<i64> = r.read_vec();

    let mut dp = vec![std::u64::MAX;n];
    dp[0] = 0 as u64;
    dp[1] = (h_s[1] - h_s[0]).abs() as u64;

    for i in 1..n {
        let mut left = 0;
        if(i > k){
            left = i-k;
        } 
        for j in left..i {
            if(dp[j] + ((h_s[i] - h_s[j]).abs() as u64) < dp[i]) {
                dp[i] = dp[j] + ((h_s[i] - h_s[j]).abs() as u64);
            }
        }
    }

    println!("{}", dp[n-1]);
}


Measured memory_bytes: 8444
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int a, b, k; cin >> a >> b >> k;
  rep(i, k) {
    if (i % 2 == 0) {
      if (a % 2 == 1) a--;
      a /= 2;
      b += a;
    } else {
      if (b % 2 == 1) b--;
      b /= 2;
      a += b;
    }
  }
  cout << a << " " << b << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char str[100];
	int i, j;
	int flag;
	int len;
	
	while (scanf("%s", str) != EOF){
		i = 0;
		flag = 0;
		len = 0;
		while (str[i] != '\0'){
			if (len > 0){
				for (j = 0; j < len; j++){
					printf("%c", str[i]);
				}
				len = 0;
			}
			else if (flag == 1){
				len = str[i] - '0';
				flag = 0;
			}
			else if (str[i] == '@' && flag == 0){
				flag = 1;
			}
			else {
				printf("%c", str[i]);
			}
			
			i++;
		}
		printf("\n");
	}
	
	return (0);
}

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

int main() {
    short int n;
    cin >> n;
    int x[8], y[8];
    double s = 0.0;
    int f = 1;
    for (int i = 1; i <= n - 2; ++i) f *= i;
    for (short int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        for (short int j = 0; j < i; ++j) {
            s += 2 * (n - 1) * f * sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
        }
    }
    s /= f * (n - 1) * n;
    printf("%.10f", s);
    return 0;
}

Measured memory_bytes: 256
use std::io::*;

fn println<T: std::fmt::Display>(s: T) {
    println!("{}", s);
}

// ------------------------------------------------------------------------

/** Replaces B, C to D */
fn replace_bytes(bytes: &mut Vec<u8>) {
    const B: u8 = b'B';
    const C: u8 = b'C';
    const D: u8 = b'D';

    let mut read_index = 0;
    let mut write_index = 0;

    let len = bytes.len();
    let replace_end_index = len - 1;

    while read_index < len {
        if read_index < replace_end_index && bytes[read_index] == B && bytes[read_index + 1] == C {
            bytes[write_index] = D;
            read_index += 2;
        } else {
            bytes[write_index] = bytes[read_index];
            read_index += 1;
        }
        write_index += 1;
    }
    bytes.resize(write_index, 0);
    bytes.shrink_to_fit();
}

fn count_contiguous_a_and_d(
    bytes: &Vec<u8>,
    start_index: usize,
    end_index: usize,
) -> (usize, Vec<usize>) {
    const A: u8 = b'A';
    const D: u8 = b'D';
    let mut d_position_list: Vec<usize> = Vec::new();

    if bytes[start_index] != A {
        return (0, d_position_list);
    }

    let mut len = 1;

    for index in start_index + 1..end_index {
        if bytes[index] == A {
            len += 1;
            continue;
        }

        if bytes[index] == D {
            d_position_list.push(len);
            len += 1;
            continue;
        }

        break;
    }

    return (len, d_position_list);
}

fn main() {
    let stdin = stdin();
    let mut s: Vec<u8> = stdin.lock().bytes().map(|b| b.unwrap()).collect();

    if s.len() < 3 {
        println(0);
        return;
    }

    replace_bytes(&mut s);  // BC -> D
    let len = s.len();

    const A: u8 = b'A';

    let mut operation_count = 0;
    let mut index = 0;

    while index < len {
        if s[index] != A {
            index += 1;
            continue;
        }

        let (a_and_d_len, d_position_list) = count_contiguous_a_and_d(&s, index, len);

        index += a_and_d_len;

        operation_count += d_position_list
            .into_iter()
            .enumerate()
            .fold(0, |acc, cur| acc + cur.1 - cur.0);
    }

    println(operation_count);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first<<"\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main(){
    int n;
    cin >> n;
    put(n*n*n);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {
  int a,b;
  cin>>a>>b;
  b/=1000;
  
  ll ans=0;

  if(a*10<b || a>b) cout << "-1 -1 -1" << endl;
  else {
    rep(i,b/10+1) {
      if ((b-a-9*i)%4==0 && 0<=(b-a-9*i)/4 && (b-a-9*i)/4<=a-i) {
        cout << i << " "<< (b-a-9*i)/4 << " " << a-i-(b-a-9*i)/4 << endl;
        return 0;
      }
      if(i==b/10) cout << "-1 -1 -1" << endl;
    }
  }


}

Measured memory_bytes: 256