akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n;
P a[100], b[100];
bool bl[100];
int ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i].first >> b[i].second;
	}
	sort(a, a + n);
	sort(b, b + n);
	for (int i = 0; i < n; i++) {
		int x = b[i].first;
		int y = b[i].second;
		int k = -1;
		int cnt = -1;
		for (int j = 0; j < n; j++) {
			if (bl[j] == false && x > a[j].first&&y > a[j].second&&cnt < a[j].second) {
				k = j;
				cnt = a[j].second;
			}
		}
		if (k != -1) {
			ans++;
			bl[k] = true;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

static const int INF = 1e9 + 7;

int n, a, b, c;
vector<int> l;

int dfs(int now, int A, int B, int C){
    if(now == n){
        return !A || !B || !C ? INF : abs(A - a) + abs(B - b) + abs(C - c);
    }
    int res = dfs(now + 1, A, B, C);
    res = min(res, dfs(now + 1, A + l[now], B, C) + (A ? 10 : 0));
    res = min(res, dfs(now + 1, A, B + l[now], C) + (B ? 10 : 0));
    res = min(res, dfs(now + 1, A, B, C + l[now]) + (C ? 10 : 0));
    return res;
}

int main(){
    cin >> n >> a >> b >> c;
    l.resize(n);
    for(auto&& i : l){
        cin >> i;
    }
    cout << dfs(0, 0, 0, 0) << "\n";
}

Measured memory_bytes: 256
from bisect import bisect_right
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline


n, t = map(int, input().split())

shop = []
shop_a0 = []

for i in range(n):
    a, b = map(int, input().split())
    if a != 0:
        shop.append([a, b, a/(b+1)])
    else:
        shop_a0.append(b)

shop = sorted(shop, key=lambda x: -x[2])
shop_a0 = sorted(shop_a0)

n = len(shop)

INF = 10**10
# dp[i][j]:i番目まで見てj個の店を回るのに掛かる所要時間の最小値
dp = [[INF for _ in range(31)] for __ in range(n+1)]
dp[0][0] = 0

m = min(n+1, 30)

for i in range(n):
    for j in range(m):
        if (shop[i][0]+1)*(dp[i][j]+1) + shop[i][1] > t:
            dp[i+1][j+1] = dp[i][j+1]
        else:
            dp[i+1][j+1] = min(dp[i][j+1], (shop[i][0]+1)
                               * (dp[i][j]+1) + shop[i][1])
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])

ss = []
if shop_a0:
    ss.append(1+shop_a0[0])
    for i in range(1, len(shop_a0)):
        ss.append(ss[-1]+1+shop_a0[i])

ans = 0

for i in range(m):
    if t - dp[n][i] >= 0:
        ans = max(ans, bisect_right(ss, t-dp[n][i]) + i)

print(ans)


Measured memory_bytes: 140756
package main

import (
	"fmt"
	"sort"
)

func main() {
	var q, h, s, d, n int
	fmt.Scan(&q, &h, &s, &d, &n)

	doublePrices := []int{8 * q, 4 * h, 2 * s, d}
	sort.Ints(doublePrices)

	var ans int
	if doublePrices[0] == d && n%2 == 1 {
		ans = (n-1)*d/2 + doublePrices[1]/2
	} else {
		ans = n * doublePrices[0] / 2
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1840
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int,  int>;

const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
	int n; cin >>n;
	string ans;
	if(n<1200){ans="ABC";}
    else if(n<2800){ans="ARC";}
    else{ans="AGC";}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll abs2(ll a,ll b){
    return max(a,b) - min(a,b);
}
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    vector<ll> pi(n,0);
    ll ans;
    rep(i,n){
        if(i==0) pi[0] = v[0];
        else pi[i] = pi[i-1] + v[i];
    }
    ans = abs(v[0]- (pi[n-1]-v[0]));
    rep(i,n){
        if(i==0 || i==n-1) continue;
        ans = min(ans,abs2(pi[i],pi[n-1]-pi[i]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
int n;
/*
Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}
*/
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;

  if (y == NIL) {
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z;
  }


}

void inorder(Node u){
  if (u == NIL) {
    return;
  }else{
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if (u == NIL) {
    return;
  }else{
    printf(" %d",u->key );
    preorder(u->left);
    preorder(u->right);
  }
}

int main(){
  int i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      //Node t = treeSearch(root, x);
      //if ( t != NIL ) printf("yes\n");
      //else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } /*
      else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
    */
  }

  return 0;
}



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

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

  map<char,vector<int>> d;
  d['R']={};
  d['G']={};
  d['B']={};

  for(int i=0;i<n;i++){
    d[s[i]].push_back(i);
  }

  long long ans;
  ans=0;

  vector<string> p={"RGB","RBG","BRG","BGR","GRB","GBR"};
  char a,b,c;
  for(int i=0;i<6;i++){
    a=p[i][0];
    b=p[i][1];
    c=p[i][2];
    for(int r=0;r<d[a].size();r++){
      int second = lower_bound(d[b].begin(),d[b].end(),d[a][r]) - d[b].begin();
      for (int g=second;g<d[b].size();g++){
        int third = lower_bound(d[c].begin(),d[c].end(),d[b][g])- d[c].begin();
        ans += (d[c].size() - third);
        if (binary_search(d[c].begin(),d[c].end(),2*d[b][g]-d[a][r])){
          ans-=1;
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define INS(x) x.begin(),x.end()
    

    
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a,b,c;
    cin>>a>>b>>c;

    if (a==b&&c!=a)
        cout<<"Yes\n";
    else if (a==c&&b!=a)
        cout<<"Yes\n";
    else if (b==c&&a!=b)
        cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#define ll long long int
#define pb push_back
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)

using namespace std;

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

ll gcdt(ll i, ll j, ll l){
    ll ans=gcd(i,j);
    ans=gcd(ans,l);
    return ans;
}

void solve(){
    //Miles To Go
    ll k,sum=0;
    cin>>k;
    f1(i,k){
        f1(j,k){
            f1(l,k){
                sum+=gcdt(i,j,l);
            }
        }
    }
    cout<<sum;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
	ll t;
	//cin>>t;
	//while(t--)
	    solve();
	return 0;
}

Measured memory_bytes: 3652
s = input()
k = int(input())

x = 0
ans1 = []
for x in range(len(s)):
    if s[x] == '1':
        ans1.append(x+1)
        x += 1
    else:
        break

if k in ans1:
    print('1')
else:
    print(s[x])

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

class Program
{
    static void Main(string[] args)
    {
        var K = int.Parse(Console.ReadLine());
        var input = Console.ReadLine().Split(" ");
        var A = int.Parse(input[0]);
        var B = int.Parse(input[1]);

        var isOK = false;
        for (int i = A; i <= B; i++)
        {
            if(i % K == 0)
            {
                isOK = true;
                break;
            }
        }

        if (isOK) Console.WriteLine("OK");
        else Console.WriteLine("NG");
    }
}


Measured memory_bytes: 27488
using DataStructures
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  N,D = readint()

  c = 0
  for i in 1:N
    x,y = readint()
    if x^2 + y^2 <= D^2
      c += 1
    end
  end
  println(c)


end

main()

Measured memory_bytes: 219116
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    ll ans  =0;
    if(a[0] > x){
        ans += a[0] - x;
        a[0]= x;
    }

    rep(i,n-1){

        if(a[i] + a[i+1] > x){
            ans += a[i] + a[i+1] - x;
            a[i+1] = x - a[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
long long int* bubbleSort(long long int* N, int len){
  int i,j;
  long long int temp;
  for(i=0; i<len; i++){
    for(j=len-1; j>i; j--){
      if(N[j] < N[j-1]){
        temp = N[j];
        N[j] = N[j-1];
        N[j-1] = temp;
      }
    }
  }

  return N;
}

int main(){
  long int a,b,c,d;
  scanf("%ld %ld %ld %ld", &a, &b, &c, &d);
long long int ans[4];
ans[0] = a*c;
ans[1] = a *d;
ans[2] = b *c;
ans[3] = b *d;
bubbleSort(ans, 4);
printf("%lld\n", ans[3]);
  return 0;
}

Measured memory_bytes: 1712
#include <cstdio>

char a[10];

int main()
{
  int res=700;
  scanf("%s",a);
  for(register int i=0; i<=2; ++i)
    {
      if(a[i]=='o')
	{
	  res+=100;
	}
    }
  printf("%d\n",res);
  return 0;
}


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

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

ll fac[MAX];

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

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

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

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



int main()
{
 
    ll N,M,a,b;
    cin >> N >> M;
    vector<vector<ll>> path(N+1);

    rep(i,M){
         cin >> a >> b;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    ll visited[N+1],ans[N+1];

    rep(i,N+1){
        visited[i] = 0;
    }
    visited[0] = 1;
    visited[1] = 1;

    queue<ll> list;

    ll bit=0,now=1;



    while(1){

        for(ll i:path[now]){
            if(visited[i]!=1){
                    list.push(i);
                    visited[i]=1;
                    ans[i]=now;
                    visited[i]=1;
            }
        }
        if(list.empty()) break;

        now=list.front();
        list.pop();


    }

    rep(i,N+1) bit += visited[i];

    if(bit!=N+1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        for(int i=2;i<N+1;i++) cout << ans[i] << endl;
    }

 
    return 0;

}

Measured memory_bytes: 13648
N, K = map(int, input().split())
p_list = list(map(int, input().split()))
EV_p_list = [0] * len(p_list)

for i in range(len(p_list)):
  EV_p_list[i] = (p_list[i] + 1) / 2

# 最初のsum
sum_EV = 0
for i in range(K):
  sum_EV = sum_EV + EV_p_list[i]

# それ以降の比較
max_EV = sum_EV
for i in range(1, N - K + 1):
  sum_EV = sum_EV - EV_p_list[i - 1] + EV_p_list[i + K - 1]
  if sum_EV > max_EV:
    max_EV = sum_EV

print(max_EV)

Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//


int main() {
    init();
    ll N;
    cin >> N;
    vvc<ll> G(N);
    vc<bool> ded(N), isLeaf(N);
    rep(i, N){
        ll v, c;
        cin >> v >> c;
        if (c == 0) isLeaf[v] = true;
        rep(i, c){
            ll to;
            cin >> to;
            ded[to] = true;
            G[v].eb(to);
        }
    }

    ll root;
    rep(i, N) if (!ded[i]) root = i;

    vl dep(N), par(N);

    auto dfs = [&](auto&& dfs, ll now, ll p, ll d) -> void{
        par[now] = p, dep[now] = d;
        repa(to, G[now]){
            dfs(dfs, to, now, d + 1);
        }
    };

    dfs(dfs, root, -1, 0);

    rep(i, N){
        cout << "node " << i << ": parent = " << par[i] << ", depth = " << dep[i] << ", ";
        cout << (i == root ? "root" : isLeaf[i] ? "leaf" : "internal node") << ", [";
        
        if(G[i].size()>0){
            cout << G[i][0];
            repe(j, 1, G[i].size()){
                cout << ", " << G[i][j];
            }
        }
        cout << ']' << endl;
    }
    
}


Measured memory_bytes: 8060
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    string S, T;
    cin >> S >> T;
    map<char, char> S2T, T2S;
    for (int i = 0, n = static_cast<int>(S.length()); i < n; ++i)
    {
        char s = S[i], t = T[i];
        if (S2T.find(s) != S2T.end())
        {
            if (S2T[s] != t)
            {
                cout << "No" << endl;
                return 0;
            }
        }
        else
        {
            S2T[s] = t;
        }
        if (T2S.find(t) != T2S.end())
        {
            if (T2S[t] != s)
            {
                cout << "No" << endl;
                return 0;
            }
        }
        else
        {
            T2S[t] = s;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 776
#include<cstdio>
#include<string.h>
char s[99];
int main(){
	scanf("%s",&s);
	int l=strlen(s);
	for(int i=0;i<l;i++)
		for(int j=0;j<i;j++)
			if(s[i]==s[j]){
				puts("no");
				return 0;
			}
	puts("yes");
}

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

using namespace std;

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

const int MOD = 998244353;

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    string s, t;
    cin >> s >> t;
    int d = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] != t[i]) {
            ++d;
        }
    }
    cout << d << "\n";
    
    return 0;
}


Measured memory_bytes: 3796
#include <iostream>
#include <cmath>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
typedef unsigned long long ul;
typedef long long ll;
typedef pair<int, int> PAIR;

ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b,a);
	}
	while (b != 0) {
		ll rem = a % b;
		a = b;
		b = rem;
	}
	return a;
}

// 1以上A以下の倍数の数
ll resRange(ll A, ll C){
	return A / C;
}
 

ll res(ll A, ll B, ll C) {
	return resRange(B, C) - resRange(A - 1, C);
}

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

	ll Cbaisu = res(A, B, C);
	ll Dbaisu = res(A, B, D);
	ll lcmw = C * D / gcd(C, D);
	ll CDbaisu = res(A, B, lcmw);
	ll CorDBaisu = Cbaisu + Dbaisu - CDbaisu;
	cout << ((B - A + 1) - CorDBaisu);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

template<int MOD>
struct ModInt {
  ll x;
  ModInt():x(0){}
  ModInt(ll x):x((x%MOD+MOD)%MOD){}
  int getMod() { return MOD; }
  ModInt operator-() const { return ModInt(0) - *this;}
  ModInt& operator+=(const ModInt& a){ if((x+=a.x)>=MOD) x-=MOD; return *this;}
  ModInt& operator-=(const ModInt& a){ if((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
  ModInt& operator*=(const ModInt& a){ (x*=a.x)%=MOD; return *this;}
  ModInt operator+(const ModInt& a)const{ return ModInt(*this) += a;}
  ModInt operator-(const ModInt& a)const{ return ModInt(*this) -= a;}
  ModInt operator*(const ModInt& a)const{ return ModInt(*this) *= a;}
  bool operator<(const ModInt& a)const{ return x < a.x;}
  bool operator==(const ModInt& a)const{ return x == a.x;}
  ModInt pow(ll t) const {
    if (!t) return 1;
    ModInt a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  friend istream & operator >> (istream & in, ModInt & v) {
    ll x;
    in >> x;
    v.x = x;
    return in;
  }
  friend ostream & operator << (ostream & out, ModInt<MOD> const & v) {
    out << v.x;
    return out;
  }
};
const int MOD = 1000000007;
using mint = ModInt<MOD>;

int main() {
  ll n; cin >> n;
  mint ans = mint(10).pow(n);
  ans -= mint(9).pow(n) * 2;
  ans += mint(8).pow(n);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
a, b = [0] * 3, [10] * 3
c = [list(map(int, input().split())) for _ in range(3)]

for i in range(3):
    b[i] = c[0][i] - a[0]

for i in range(1, 3):
    a[i] = c[i][0] - b[0]

for i in range(3):
    for j in range(3):
        if c[i][j] != a[i] + b[j]:
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i) = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int n;cin>>n;
  queue<ll> que;
  rep(i,9)que.push(i+1);
  rep(i,n-1){
    ll x = que.front();que.pop();
    if(x%10 != 0){
      que.push(10*x+x%10-1);
    }
    que.push(10*x+x%10);
    if(x%10 != 9){
      que.push(10*x+1+x%10);
    }
  }
  print(que.front());
  return 0;
}


Measured memory_bytes: 1792
X = int(input())
for i in range(0, 500):
    for j in range(0, 500):
        if i*i*i*i*i-j*j*j*j*j == X:
            print(i, j)
            quit()
        if i*i*i*i*i+j*j*j*j*j == X:
            print(i, -j)
            quit()

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

int main() {
    string s;
    cin >> s;
    int n = s.length();
    
    for (int i = 0; i < n; i++) {
        if ((i+1) % 2 != 0) cout << s[i];
    }
    cout << endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  string s;
  vector<int> ans(4);
  for(int i = 0; i < N; i++){
    cin >> s;
    if(s == "AC") ans.at(0)++;
    else if(s == "WA") ans.at(1)++;
    else if(s == "TLE") ans.at(2)++;
    else ans.at(3)++;
  }
  printf("AC x %d\n",ans.at(0));
  printf("WA x %d\n",ans.at(1));
  printf("TLE x %d\n",ans.at(2));
  printf("RE x %d\n",ans.at(3));
}

Measured memory_bytes: 3732
#coding:UTF-8
def chain(p,n):
    m={}
    for i in range(1,n+1):
        m[i] = {i:0}
         
    for l in range(2,n+1):
        for i in range(1,n-l+2):
            j = i + l -1
            m[i][j] = float("inf")
            for k in range(i,j):
                m[i][j] = min(m[i][j],m[i][k]+m[k+1][j] + p[i-1]*p[k]*p[j])
    print(m[1][n])
    
if __name__=="__main__": 
    p={}
    n = int(input())
    for i in range(1,n+1):
        st = input()
        w = st.split()
        p[i-1] = int(w[0])
        p[i]   = int(w[1])
    chain(p,n)

Measured memory_bytes: 8004
#include<stdio.h>

int main(){
    int c[3];
    for(int i=0;i<3;i++){
        scanf("%d",&c[i]);
    }

    for(int i=0;i<2;i++){
        for(int j=2;j>i;j--){
            if(c[j-1]>c[j]){
                int t=c[j];
                c[j]=c[j-1];
                c[j-1]=t;
            }
        }
    }

    if(c[0]+c[1]==c[2]){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1636
/*
======================
[     ___T_          ]
[    | 6=6 | =>HI :-)] 
[    |__o__|         ]
[ >===]__o[===<      ]
[     [o__]          ]
[      .".           ]
[      |_|           ]
[                    ]
======================
 */
 
#include<bits/stdc++.h>
using namespace std;
using lli = int64_t;
int main() {
	 ios::sync_with_stdio(false);
	 cin.tie(nullptr);
	 cout.tie(nullptr);
	 int T = 1;
	 //~ cin >> T;
	 for(int t = 1; t <= T; t++) {
		 int n;
		 cin >> n;
		 int input[n + 1];
		 int min_number = INT_MAX;
		 for(int i = 1; i <= n; i++){
			 cin >> input[i];
			 min_number = min(min_number,input[i]);
		 }
		 int ans = min_number;
		 for(int i = 1;i <= n; i++){
			 input[i] -= min_number;
		 }
		 bool zero = false;
		 while(!zero){
			 vector<pair<int,pair<int,int>>> find_zero_idx;
			 int start = -1,end = -1,min_number_interval = INT_MAX;
			 for(int i = 1;i <= n; i++){
				 if(input[i] > 0){
					 min_number_interval = min(min_number_interval,input[i]);
					 if(start == -1){
						 start = i;
						 end = i;
					 }else{
						 end = i;
					 }
				 }else{
					 if(start != -1){
						 find_zero_idx.push_back(make_pair(min_number_interval,make_pair(start,end)));
					 }
					 start = -1,end = -1,min_number_interval = INT_MAX;
				 }
			 }
			 if(start != -1){
				 find_zero_idx.push_back(make_pair(min_number_interval,make_pair(start,end)));
			 }
			 for(auto item : find_zero_idx){
				 for(int i = item.second.first; i <= item.second.second; i++){
					 input[i] -= item.first;
				 }
				 ans += item.first;
			 }
			 int one = 0;
			 for(int i = 1; i <= n; i++){
				 one += (input[i] > 0);
				 if(one > 0){
					 break;
				}
			 }
			 cout << "\n";
			 if(one == 0){
				 zero = true;
			 }
		 }
		 cout << ans << "\n";
	 }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int fact(int n)
{
    if(n==0||n==1)
        return 1;
    else
        return (n*fact(n-1));
}
int main()
{
    int n,flag=0,c=0,d=0;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];    
    }
    for(int j=0;j<n;j++)
        cin>>b[j];
    for(int i=0;i<n;i++)
    {
        if(a[i]<b[i])
        {flag=1;break;}
        if(b[i]<a[i])
        {flag=-1;break;}
    }
    if(flag==1)
    {c=0;d=0;
    do
    {
        c=0;
        for(int i=0;i<n;i++)
        {
            //cout<<a[i]<<" ";
            if(a[i]==b[i])
                c++;
            else 
                break;
        }
        //cout<<"   "<<c<<endl;
        if(c==n)
        {break;}
        d++;
    }while(next_permutation(a , a+n));
    }
    
    else if(flag==-1)
    { c=0;d=0;
    do
    {
        c=0;
       
        for(int i=0;i<n;i++)
        {
            //cout<<b[i]<<" ";
            if(b[i]==a[i])
                c++;
        }
        //cout<<"   "<<c<<endl;
        if(c==n)
            break;
        d++;
    }while(next_permutation(b , b+n));
    }
    cout<<d<<endl;
    
           
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define TEST ll t;cin>>t;while(t--)
ll sizes[100001];
ll arr[100001];

bool ok=true;
ll A[100001];
pll B[100001];

ll root(ll i){
    while(i!=arr[i]) i=arr[i];
    return(i);
}
void Union(ll i,ll j){
    ll root_i=root(i),root_j=root(j);
    if(root_i==root_j) return;
    if(sizes[root_i]>sizes[root_j]) swap(root_i,root_j);
    sizes[root_j]+=sizes[root_i];
    arr[root_i]=arr[root_j];
    return;
}
bool prime[10000000];
vector<ll> v;
void era(){
    memset(prime,true,sizeof prime);
    for(int p=2;p*p<=10000000;p++){
        if(prime[p]){
            if(p%5==1) v.push_back(p);
            for(int q=p*p;q<=10000000;q+=p){
                prime[q]=false;
            }
        }
    }
    return;
}


ll dif(string s,string p){
    ll a=(s[0]-'0')*100+(s[1]-'0')*10+(s[2]-'0');
    ll b=(p[0]-'0')*100+(p[1]-'0')*10+(p[2]-'0');
    return(abs(a-b));
}
bool is357(ll i){
    bool a=false,b=false,c=false;
    while(i){
        if(i%10==3) a=true;
        else if(i%10==5) b=true;
        else if(i%10==7) c=true;
        else return(false);
        i/=10;
    }
    return(a&b&c);
}
int main(){
    IO
    ll N,ans=0;
    ll power[11];
    power[0]=1;
    for(int i=1;i<=10;i++) power[i]=power[i-1]*10;
    cin>>N;
    //N=999999999;
    queue<ll> q;
    int dp[11];
    memset(dp,0,sizeof dp);
    dp[0]=0;dp[1]=0;dp[2]=0;dp[3]=6;dp[4]=36;dp[5]=150;dp[6]=540;dp[7]=1806,dp[8]=5796,dp[9]=18150;
    //for(ll i=100000000;i<=999999999;i++) if(is357(i)) cout<<i<<endl;
    //cout<<dp[9];
    ll p=log10(N);

    for(ll i=0;i<=p+1;i++) ans+=dp[i];
    if(N%2==0) N++;
    else N+=2;
    for(ll i=N;i<=power[p+1]-3;i+=2) if(is357(i)) ans--;
    cout<<ans;
    return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ll inf = 1LL << 60;
const ld pi = (acos(-1));
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int n,k; cin >> n >> k;
  vector<int> snk(n);
  rep(i,0,k){
    int d;
    cin >> d;
    rep(i,1,d+1){
      int a;
      cin >> a;
      snk[a-1]++;
    }
  }
  int ans=0;
  rep(i,0,n){
    if(!snk[i]){ans++;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 3672
let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let f m a = Array.fold_left (fun m b -> max m @@ abs @@ a - b) m a_s
let _ = Array.fold_left f 0 a_s |> Printf.printf "%d\n"

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

template <typename T> inline void read (T &x) {bool b = 0; char c; while (!isdigit (c = getchar()) && c != '-');
if (c == '-') c = getchar(), b = 1; x = c - 48; while (isdigit(c = getchar())) x = (x<<3) + (x<<1) + c - 48; if (b)x=-x;}
template <typename T> inline void wrip(T x) {if (x > 9) wrip(x / 10); putchar(x%10 + 48); }

template <typename T> inline void write(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar(' ');}
template <typename T> inline void writeln(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar('\n');}
inline char readch() {char c; do c = getchar(); while (c == '\n' || c == ' '); return c;}
inline void reads(string &s) {char c; while((c=getchar())==' '||c =='\n'); s=c; while((c=getchar())!=' '&&c!='\n') s+=c;}
inline void getlines(string &s) {char c; while((c=getchar())=='\n'); s=c; while((c=getchar())!='\n') s+=c;}
typedef const int csint;

#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair <int, int> ii;
typedef vector <int> vi;

const ld pi = acos(-1);
const ll inf = 1e16,
mod = 1e9 + 7,
N = 1e5 + 11;

int n, m, bac[N], pa[N];
vector <int> ke[N];
queue <int> q;
int main() {
    #ifdef makacha
        freopen("m.inp", "r", stdin);
        freopen("m.out", "w", stdout);
    #endif // makacha
    read(n);
    read(m);
    for (int i = 1, u, v; i < n + m; i++) {
        read(u);
        read(v);
        bac[v]++;
        ke[u].push_back(v);
    }
    for (int i = 1; i <= n; i++)
        if (!bac[i])
            q.push(i);
    while (q.size()) {
        int u = q.front();
        q.pop();
        for (auto v: ke[u])
            if (--bac[v] == 0) {
                pa[v] = u;
                q.push(v);
            }
    }
    for (int i = 1; i <= n; i++)
        writeln(pa[i]);
}


Measured memory_bytes: 7040
#include<stdio.h>
int h,w;
char a[200][200];
int main(void){
    int i,j,k;
    scanf("%d %d",&h,&w);
    for(i=0;i<h;i++){
        scanf("%s",&a[i]);
    }

    for(i=0;i<w+2;i++){
        printf("#");
    }
    printf("\n");

    for(i=0;i<h;i++){
        printf("#%s#\n",a[i]);
    }



    for(i=0;i<w+2;i++){
        printf("#");
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

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

int main() {
  string s, alpha = "abcdefghijklmnopqrstuvwxyz";
  cin >> s;
  sort(s.begin(), s.end());
  rep(i, alpha.size()) {
    if (s.find(alpha[i]) == string::npos) {
      cout << alpha[i] << endl;
      break;
    }
    if (i == (alpha.size() - 1)) cout << "None" << endl;
  }
  return 0;
}


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

using namespace std;

std::vector<long long>A(100010);

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


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

    int zero = 0; 

    for(int i=0;i<N;i++)
    {
        if(A[i]==0)
        {
            zero++;
        }
    }
    if(zero>0)
    {
        cout << 0 << endl;
        return 0;
    }

    long long seki = 1;

    for(int i=0;i<N;i++)
    {
        if(A[i] <= 1000000000000000000/seki)
        {
            seki = seki*A[i];
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << seki << endl;
}


Measured memory_bytes: 3860
N,K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
M = max(A)
m = 1
mid = (M+1)//2
while m<M:
  n = 0
  for a in A:
    n += -(-a//mid)-1
    if n > K:
      m = mid+1
      break
  else:
    M = mid
  mid = (M+m)//2
print(mid)

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

int main() {
while(true){
int H, W;
cin >> H >> W;
if(H == 0 && W == 0){
break;
}
for(int i = 0; i < H; i++){
for(int j = 0; j < W; j++){
cout << "#";
}
cout << endl;
}
cout << endl;


}





}



Measured memory_bytes: 3080
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    var n, S = sc.nextInt
    var count = 0
    while (n != 0 && S != 0) {
      val r = Array.fill(101)(0)
      for (i <- 0 until n) {
        r(sc.nextInt) += 1
      }
      var ans = 0
      for (i <- 0 until 101) {
        for (j <- math.max(i, S - i) + 1 until 101) {
          ans += r(i) * r(j)
        }
        if (i * 2 > S) {
          ans += r(i) * (r(i) - 1) / 2
        }
      }
      println(ans)
      System.gc()
      n = sc.nextInt
      S = sc.nextInt
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 61396
#include <bits/stdc++.h>
using namespace std; 
int main(){
	int N; cin >> N; 
	long long M; cin >> M; 
	long long A[100010]; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	sort(A, A+N); 
	int ok = 0; int ng = 200001; long long cnt = 0; 
	while(ng - ok > 1){
		int mid = (ok + ng) / 2;  
		cnt = 0;  
		for(int i = 0; i < N; i++){
			int a = lower_bound(A, A+N, mid - A[i]) - A;
			cnt += (long long) N - a; 
		}
		if(cnt >= M) ok = mid; 
		else ng = mid; 
	}
	long long S[100010] = {}; 
	S[0] = A[0]; long long cnt2 = 0; 
	for(int i = 1; i < N; i++) S[i] = S[i-1] + A[i]; 
	long long ans = 0; 
	for(int i = 0; i < N; i++){
		int a = lower_bound(A, A+N, ok - A[i]) - A; cnt2 += (long long) N - a; 
		if(a == 0) ans += N * A[i] + S[N-1]; 
		else ans += ((long long) N - a) * A[i] + S[N-1] - S[a-1]; 
	}
	cout << ans - (cnt2 - M) * ok << endl; 
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int main()
{
	long long t;
	cin>>t;
	long long  ans=t/11*2;
	t%=11;
	if(t>=1&&t<=6) ans++;
	if(t>=7&&t<=10) ans+=2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import heapq
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
bef = a[0]
for i in range(1,n):
    if bef == a[i]:
        print("NO")
        break
    bef = a[i]
    if i == n-1:
        print("YES")

Measured memory_bytes: 104116
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#define MODD 1000000007
#define ll long long
using namespace std;

string S1;
string S2;

map<vector<int>,ll> dp[55];

ll Solve(int pos, const vector<int>& pcolors) {
    
    if (pos == S1.size()) {
        return 1;
    }
    
    if (dp[pos].find(pcolors) != dp[pos].end())
        return dp[pos][pcolors];
    
    // S1[pos] == S2[pos]
    
    if (S1[pos] == S2[pos]) {
        ll ans = 0;
        int pmask=0;
        for(int j=0;j<pcolors.size();j++)
            pmask |= (1<<pcolors[j]);
        for(int c=0;c<3;c++) {
            if (!((pmask>>c)&1)) {
                ans += Solve(pos+1, {c});
                ans %= MODD;
            }
        }
        return dp[pos][pcolors]=ans;
    } else {
        ll ans = 0;
        for(int c1=0;c1<3;c1++)
            for(int c2=0;c2<3;c2++) {
                if (c1 == c2)
                    continue;
                if (pcolors.size() == 1 && (pcolors[0]==c1 || pcolors[0]==c2))
                    continue;
                if (pcolors.size() == 2 && (pcolors[0]==c1 || pcolors[1]==c2))
                    continue;
                vector<int> ncolors={c1,c2};
                ans += Solve(pos+2,ncolors);
                ans %= MODD;
            }
        return dp[pos][pcolors]=ans;
    }
    
    
    
    
}

int main() {
    int N;
    cin>>N;
    cin>>S1>>S2;
    cout << Solve(0, vector<int>()) << endl;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  ll ans = 0;
  while(true){
    ll s = 0;
    for(int i=0;i<n;i++){
      s += a[i]/n;
    }
    if(s==0) break;
    ans += s;
    for(int i=0;i<n;i++){
      a[i] = a[i] - (a[i]/n)*n + (s-a[i]/n);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3684
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct {
    char name[100];
    int t;
} Task;

Task Q[LEN];
int head, tail;

void enqueue(Task x) {
    Q[tail] = x;
    tail = (tail+1) % LEN;
}

Task dequeue() {
    Task x = Q[head];
    head = (head+1) % LEN;
    return x;
}

int min(int a, int b) {return a < b ? a : b;}

int main()
{
    int n, q, i;
    int elaps = 0, c;

    scanf("%d %d", &n, &q);

    for (i = 1; i <= n; i++) {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }

    head = 1;
    tail = n+1;

    while(head != tail) {

        Task u = dequeue();

        c = min(q, u.t);
        u.t -= c;
        elaps += c;

        if (u.t > 0)
            enqueue(u);
        else
            printf("%s %d\n", u.name, elaps);
    }
    return 0;
}

Measured memory_bytes: 11836
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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 INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n; cin>>n;
    vl vs(1e4 + 10);
    rep(i, 1e2 + 10) {
        rep(j, 1e2 + 10) {
            rep(k, 1e2 + 10) {
                ll x = i + 1;
                ll y = j + 1;
                ll z = k + 1;
                ll r = x * x + y * y + z * z + x * y + y * z + z * x;
                if (r > n) continue;
                vs[r]++;
            }
        }
    }
    rep(i, n) cout<<vs[i + 1]<<endl;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n,m;
    cin >> n >> m;
    if(n%2 == 0) n--;
    if(m == 1){
        cout << "1 2" << endl;
        return 0;
    }
    rep(i,m/2) cout << 1+i << " " << n/2-i << endl;
    if(m%2 == 0) rep(i,m/2) cout << n/2+1+i << " " << n-i << endl;
    else rep(i,m/2+1) cout << n/2+1+i << " " << n-i << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
void gcd(int,int);
int main(){
  int x,y;
  scanf("%d %d",&x,&y);
  gcd(x,y);
  return 0;
}
void gcd(int x, int y){
  int r,tmp;
  if(x<y){
    tmp=x;
    x=y;
    y=tmp;
  }
  r=x%y;
  while(r!=0){
    x=y;
    y=r;
    r=x%y;
  }
  printf("%d\n",y);
}



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

int main()
{
	string s;
	int a, b;

	cin >> s;

	while (s != "0") {
		a = 0;
		b = 0;

		for (int i = 1; i < (int)s.size(); i++) {
			if (s[i] == 'A')
				a++;
			else if (s[i] == 'B')
				b++;
		}
		if (a > b)
			a++;
		else if (a < b)
			b++;

		cout << a << " " << b << endl;
		cin >> s;
	}

	return 0;
}



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


using namespace std;


void atcoder_beginner_contest999()
{
  string n;
  cin >> n;

  for (int i = 0; i < n.size(); ++i)
  {
    if (n[i] == '1') n[i] = '9';
    else if (n[i] == '9') n[i] = '1';
  }
  cout << n << "\n";
}


int main()
{
  atcoder_beginner_contest999();
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

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

ll powmod(ll x, ll n) { // like pow(x, n)
  ll r = 1;
  while (n) {
    if (n & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return r;
}

vector< vector<int> > tree;
vector<int> dst;  // distance
int r = 0;

void dfs(int now, int p) {
  for (auto x : tree[now]) {
    if (x == p) { continue; }
    dst[x] = dst[now] + 1;
    if (dst[x] > dst[r]) { r = x; }
    dfs(x, now);
  }
}

int main(int argc, char** argv) {
  int N;
  cin >> N;
  tree.resize(N);
  rep(i, N) {
    string S;
    cin >> S;
    rep(j, N) {
      if (j > i) { // consider only this case
        if (S[j] == '1') {
          tree[i].push_back(j);
          tree[j].push_back(i);
        }
      }
    }
  }

  // For Debug
  // rep(i, N) {
  //   for (auto x : tree[i]) {
  //     cout << x << ",";
  //   }
  //   cout << endl;
  // }

  ll ans = 0;

  // bfs from all points. The largest length is answer. If different distance is detected, then answer is -1 (odd cycle exists).
  rep(s, N) {
    vector<int> d(N, -1);
    queue<P> q; // A queue of pairs. A pair is (vertex, prev).
    d[s] = 0;
    q.emplace(s, -1); // start from s.
    while (!q.empty()) {
      P p = q.front(); q.pop();
      for (int u : tree[p.first]) {
        if (u == p.second) { continue; } // skip prev

        if (d[u] == -1) { // u is not visited
          d[u] = d[p.first] + 1;
          q.emplace(u, p.first);
          if (d[u] > ans) { ans = d[u]; } // ans is max distance
          continue;
        }

        // Here, d[u] is already calculated
        if ((d[u] != d[p.first] + 1) && (d[u] != d[p.first] - 1)) { // different distance!
          // For Debug
          // cout << "s: "<<s << endl;
          // cout << "d["<<u<<"]: "<<d[u]<<", d["<<p.first<<"]: "<<d[p.first] << endl;
          cout << -1 << endl;
          return 0;
        }
      }
    }
  }

  cout << ans + 1 << endl;
}


Measured memory_bytes: 512