akhauriyash/Code-Regression huggingface dataset:
import sys

readline = sys.stdin.readline

ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))

def solve():
  n, m = nm()
  G = [list() for _ in range(n)]
  for _ in range(m):
    a, b = nm()
    a -= 1; b -= 1
    G[a].append(b)
    G[b].append(a)
  Q = int(input())
  queries = [tuple(nm()) for _ in range(Q)][::-1]
  dp = [[Q]*11 for _ in range(n)]
  for i in range(Q-1, -1, -1):
    v, d, _ = queries[i]
    dp[v-1][d] = i
    
  for d in range(10, 0, -1):
    for v in range(n):
      for x in G[v] + [v]:
        if dp[x][d-1] > dp[v][d]:
          dp[x][d-1] = dp[v][d]
          
  queries.append((-1, -1, 0))
  color = [queries[dp[v][0]][2] for v in range(n)]
  print(*color, sep='\n')
  return

solve()

Measured memory_bytes: 57580
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int maxn = 1e5 + 5;
int pre[maxn], sum[maxn], x[maxn], y[maxn];
long long ans[maxn];
int find(int x)
{
    return x == pre[x] ? x : pre[x] = find(pre[x]); 
}
void join(int a, int b)
{
    a = find(a), b = find(b);
    if(a != b)
    {
        sum[a] += sum[b];
        sum[b] = 0;
        pre[b] = a;
    }
}
int main()
{
    int n, m;
    while(cin >> n >> m)
    {
        for(int i = 0; i < maxn; i++) sum[i] = 1, pre[i] = i;
        memset(ans, 0, sizeof(ans));
        for(int i = 1; i <= m; i++)
        {
            scanf("%d%d", &x[i], &y[i]);
        }
        long long cnt = n;
        ans[m+1] = cnt * (cnt-1) / 2;
        for(int i = m; i >= 2; i--)
        {
            int xx = find(x[i]), yy = find(y[i]);
            if(xx != yy)
            {
                ans[i] = ans[i+1] - sum[xx] * sum[yy];
                join(x[i], y[i]);
            }
            else
                ans[i] = ans[i+1];
        }
        for(int i = 2; i <= m+1; i++)
            printf("%lld\n", ans[i]);
    }

    return 0;
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt(), b = s.nextInt(), c = s.nextInt();
		if (a+b+c > 21) {
			System.out.println("bust");
		}else {
			System.out.println("win");
		}
	}

}


Measured memory_bytes: 21332
///ShzFahad
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin >> t;
    ll ac=0,wa=0,re=0,tl=0;
    while(t--)
    {
        string s;
        cin >> s;
        if(s=="AC")
            ac++;
        else if(s=="TLE")
            tl++;
        else if(s=="WA")
            wa++;
        else
            re++;

    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tl << endl;
    cout << "RE x " << re << endl;

}



Measured memory_bytes: 3620
#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;

int S[100000];
int T[50000];

int Fukasa(int l, int r, int n, int q,int* S,int* T){
  int count = 0;
  for(int i=0;i<q;i++){
    l = 0;
    r = n;
    while(1){

      if(r - l <= 1){
        if(S[r] == T[i]){
          count++;
          break;
        } else if(S[l] == T[i]){
          count++;
          break;
        }
        break;
      }

      if(S[(l+r)/2] > T[i]){
        r = (r+l)/2;
      }else if(S[(l+r)/2] < T[i]){
        l = (l+r)/2;
      }else{
        count++;
        break;
      }
    }
  }
  return count;
}

int main(){
  int n;
  int q;

  int l,r;

  cin>>n;

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

  cin>>q;

  for(int j=0;j<q;j++){
    cin>>T[j];
  }

  l=0;
  r=q-1;

  cout << Fukasa(l,r,n,q,S,T) << endl;

  return 0;

}



Measured memory_bytes: 3640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
#include <iterator>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
const  long long INF = 1LL << 60;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}



int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

map<ll,ll> mp;

auto findFactors(ll num){
	
    ll i;
    while (num % 2 == 0){ // 偶数の素数は2のみ
        if(mp.count(2)){
			mp[2] = mp[2] + 1;
		}
		else{
			mp[2] = 1;
		}
        num /= 2;
    }
    for (i = 3; i <= num; i++){ // 他の素数で割っていく
        while (num % i == 0){
			if(mp.count(i)){
			mp[i] = mp[i] + 1;
		}
		else{
			mp[i] = 1;
		}
            num /= i;
        }
    }
    return 0;
}
ll kaizyou(ll n){
    if(n == 1){
        return 1;
    }
    else{
        return (n * kaizyou(n-1)) % 1000000007;
    }
}



int main(){
int N,M; cin >> N >> M;
vector<int> h(N);
rep(i,N) cin >> h[i];
sort(all(h));
int cnt = 1000000009;
rep(i,N-M+1){
    chmin(cnt,h[i+M-1] -h[i]);
}
cout << cnt << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007 
#define pb push_back
//#define mp make_pair
#define INF 2000000011LL
#define INFLL 1000000000000000011LL
#define eps 1e-9
#define pp pair < pair<ll,ll> , ll> 
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define foll(i,j,k) for(ll i=j;i<=k;i++)
#define clr(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vll vector<ll>
#define sz(a) a.size()
#define len(a) a.length()
#define all(a) a.begin(),a.end()
#define io_file freopen("Contest/input_file.in", "r", stdin); freopen("Contest/output_file.in", "w", stdout)

const int MAXN = 2e5+5;
using namespace std;
ll power(ll x, ll y)
{
  ll res = 1;
  while(y>0)
  {
    if(y&1)
       {
         res = (res*x)%mod;
        }
     x = (x*x)%mod;
     y = y>>1;
  }
    return res;
}
// std::vector<ll> divi[100004];
// void divisor(int n)
// {
//    for(ll i=1;i<=n;i++)
//    {
//      for(ll j=i;j<=n;j+=i)
//      {
//        divi[j].pb(i);
//      }
//    }
// }



ll n;
ll fact[1000005];
ll rev[1000005];

ll factorial(int x)
{
  if(x < 0) return 0;
  return fact[x];
}
ll revfact(int x)
{
  if(x< 0) return 0;
  return rev[x];
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    fact[0] = 1;
    rev[0] = 1;
    int n;
    cin>>n;
    for(int i=1;i<1000005;i++)
    {
      fact[i] = (fact[i-1]*(ll)i)%mod;
      rev[i] = (rev[i-1]*power((ll)i,mod-2))%mod;
    }
    ll ans = ((n-1)*fact[n-1])%mod;
    for(int i = 2;i<=n;i++)
    {

      ans = (ans - (((factorial(n-i)*factorial(n-i-1))%mod)*revfact(n-2*i))%mod + mod)%mod;
    }
    cout<<ans<<endl;
    return 0;

}



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

// 簡易UF
struct UF{
    vector<int> p;
    int n;

    UF(int siz){
        n = siz;
        p.resize(n, 0);
        for(int i = 0; i < n; i++)  p[i] = i;
    }

    int parent(int x){
        if(p[x] != x)   p[x] = parent(p[x]);
        return p[x];
    }

    bool same(int x, int y){
        return parent(x) == parent(y);
    }
    
    void unite(int x, int y){
        x = parent(x), y = parent(y);
        p[x] = y;
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    UF uf(n);
    while(m--){
        int a, b;
        cin >> a >> b;
        a--, b--;
        uf.unite(a,b);
    }
    set<int> ps;
    for(int i = 0; i < n; i++)  ps.insert(uf.parent(i));
    cout << ps.size()-1 << endl;
    return 0;
}

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

int main(){
	double prob;
    int N;
  	cin >> N;
  	if(N==1)
      	cout << 1;
  	else if(N%2==0)
      	cout << 0.5;
  	else{
    	prob = (double) (N/2+1)/N;
      	cout << prob;
    }
    return 0;  	
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;
vector<int> graph[MAX_N];

priority_queue<int> c_que;

int d[MAX_N];

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 1; i <= n - 1; ++i) {
    int a, b;

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

    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  for (int i = 1; i <= n; ++i) {
    int c;
    scanf("%d", &c);

    c_que.push(c);
  }

  int bias = c_que.top();

  queue<int> que;
  fill_n(d, n + 3, 0);

  que.push(1);

  int score = 0;

  while (!que.empty()) {
    int cur_node = que.front();
    que.pop();

    int cur_c = c_que.top();
    c_que.pop();

    d[cur_node] = cur_c;
    score += cur_c;

    for (auto e: graph[cur_node]) {
      if (d[e] > 0) continue;

      que.push(e);
    }
  }

  score -= bias;

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

  for (int i = 1; i <= n; ++i) {
    printf("%d ", d[i]);
  }

  printf("\n");

  return 0;
}


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

long a[222222];
int main() {
    long n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    long l = -1e18, r = 1e18;
    while(l + 1 < r) {
        long m = (l + r) / 2, s = 0;
        for(int i = 0; i < n; i++) {
            if(a[i] > 0)
                s += upper_bound(a, a + n,
                                 (m + (abs(m) + a[i]) / a[i] * a[i]) / a[i] -
                                     (abs(m) + a[i]) / a[i]) -
                     a;
            else if(a[i])
                s += n + a -
                     lower_bound(a, a + n,
                                 (-a[i] * ((abs(m) - a[i]) / -a[i] + 1) - m -
                                  1) / -a[i] -
                                     (abs(m) - a[i]) / -a[i]);
            else if(m >= 0)
                s += n;
            if(a[i] * a[i] <= m)
                s--;
        }
        if(s < k + k)
            l = m;
        else
            r = m;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections.Generic;

class Program {

    static long[] memo = Enumerable.Repeat(-1L, 50).ToArray();

    static void Main(string[] args) {

        long  l = long.Parse ( Console.ReadLine());

        for (int i = 0; i < l; i++) {
            string inp1 = Console.ReadLine();
            string inp2 = Console.ReadLine();

            Console.WriteLine(lcs(inp1, inp2));
        }

    }


    const int N = 1000;

    static long lcs(string x, string y) {
        int[,] c = new int[N + 1, N + 1];
        int m = x.Length;
        int n = y.Length;
        int maxl = 0;

        x = " " + x;
        y = " " + y;
        for (int i = 0; i < m; i++) c[i, 0] = 0;
        for (int j = 0; j < n; j++) c[0, j] = 0;

        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                if (x[i] == y[j]) {
                    c[i, j] = c[i - 1, j - 1] + 1;
                }
                else {
                    c[i, j] = Math.Max(c[i - 1, j], c[i, j - 1]);
                }
                maxl = Math.Max(maxl, c[i, j]);
            }
        }

        return maxl;
    }
}



Measured memory_bytes: 37428
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String[] line = sc.nextLine().split(" ");
		int num[] = new int[6];
		for(int i=0;i<6;i++){
			num[i]=Integer.parseInt(line[i]);
		}
		int q = Integer.parseInt(sc.nextLine());
		Dice dice = new Dice(num);
		
		for(int i=0;i<q;i++){
			line= sc.nextLine().split(" ");
			int upper = Integer.parseInt(line[0]);
			int s = Integer.parseInt(line[1]);
			
			if(dice.getLower()==s){
				dice.moveN();
			}else if(dice.getN()==s){
				dice.moveN();
				dice.moveN();
			}else if(dice.getE()==s){
				dice.moveE();
				dice.moveN();
			}else if(dice.getW()==s){
				dice.moveW();
				dice.moveN();
			}else if(dice.getUpper()==s){
				dice.moveS();
			}
			
			if(dice.getLower()==upper){
				dice.moveW();
				dice.moveW();
			}else if(dice.getW()==upper){
				dice.moveE();
			}else if(dice.getE()==upper){
				dice.moveW();
			}
			
			System.out.println(dice.getE());
		}
	}
}
class Dice{
//
	private final int lavel1,lavel2,lavel3,lavel4,lavel5,lavel6;
	private int w,s,e,n;
	private int upper,lower;
//	
	Dice(int[] i){
		lavel1=i[0];
		lavel2=i[1];
		lavel3=i[2];
		lavel4=i[3];
		lavel5=i[4];
		lavel6=i[5];
		
		w=lavel4;
		s=lavel2;
		e=lavel3;
		n=lavel5;
		
		upper=lavel1;
		lower=lavel6;
	}
	
	public int getUpper(){
		return upper;
	}
	public int getW(){
		return w;
	}
	public int getS(){
		return s;
	}
	public int getE(){
		return e;
	}
	public int getN(){
		return n;
	}
	public int getLower(){
		return lower;
	}
	
	public void moveW(){
		int i=lower;
		lower=w;
		w=upper;
		upper=e;
		e=i;
	}
	public void moveS(){
		int i=lower;
		lower=s;
		s=upper;
		upper=n;
		n=i;
	}
	public void moveE(){
		int i=lower;
		lower=e;
		e=upper;
		upper=w;
		w=i;
	}
	public void moveN(){
		int i=lower;
		lower=n;
		n=upper;
		upper=s;
		s=i;
	}
}

Measured memory_bytes: 26364
import scala.io.StdIn.{readLine,readInt}
import scala.math.pow

object Main {
  val N = 1000000007

  def multi(m:Long, n:Long) = { ( (m%N) * (n%N) ) % N }

  def pow(m:Long, n:Long, b1:Long, b2:Long, b3:Long):Long = {
    n match {
      case 0 => 1
      case 1 => multi(b1,b3)
      case _ =>
        val c = b2 match {
          case 1 => m % N
          case _ => multi(b2,b2)
        }
        pow(m, n/2, multi(b1,b1), c, (if (n%2==0) 1 else c) * (b3 % N))
    }
  }

  def main(args: Array[String]) = {
    val l = readLine().split(" ").map(_.toLong)
    val (m,n) = (l(0),l(1))
    println(pow(m,n,m,1,1))
  }
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int32 N;
	int64 a, b;
	cin >> N;
	a = 1; b = 1;
	REP(i, N){
		int64 x, y;
		cin >> x >> y;
		int64 z = max((a+x-1)/x, (b+y-1)/y);
		a = z*x; b = z*y;
	}
	cout << a+b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// ABCテンプレート

#define rep(i,n) for (int i = 0; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
#define keta(n) cout << fixed << setprecision((n));
using ll = int64_t;
using v = vector<int>;

int main() {
  string s;
  cin >> s;
  int a=s.size();
  if(s.at(a-1)=='s') cout << s+"es";
  else cout << s+"s";
}

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

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

  int count=0;
  string ans ="No";
  for(int i=0;i<n.size();i++){
    count+=int(n.at(i)-'0');
  }
  if(count%9==0){
    ans = "Yes";
  }
  cout << ans <<endl;
  
}

Measured memory_bytes: 3720
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int i, bottom, top, number, count = 0;
    bottom = Integer.parseInt(sc.next());
    top = Integer.parseInt(sc.next());
    number = Integer.parseInt(sc.next());
    for(i = bottom; i <= top; i++) {
      if(number % i == 0) count++;
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 26256
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    n,*a=map(int,open(0).read().split())
    ans=0
    for i in range(3,n+1):
        if a[i-3:i][1]==sorted(a[i-3:i])[1]:
            ans+=1
    print(ans)
if __name__ == '__main__':
    main()

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

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

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

ll t,i,x,j,y,z,k,n;

cin>>x>>y;
ce(6-x-y)
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                9000000000000000000
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 long double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr(a,n)           for(ll i=0;i<n;i++){ cin>>a[i]; }
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= mod;} b >>= 1; x *= x; x %= mod;} return p % mod;}
using namespace std;
# define INF 1e15
struct lex_compare {
    bool operator() (const pair<db,ll>  p1, const pair<db,ll> p2){
        return (p1.first ==  p2.first) ? p1.ss < p2.ss : p1.first > p2.first;
    }
};

int main(){
    FIO;
    ll n; cin >> n;
    ll arr[n];
    forn(i,0,n) cin >> arr[i];
    ll totalXor = 0;
    forn(i,0,n) totalXor ^= arr[i];
    forn(i,0,n){
        cout << (totalXor^arr[i]) << " " ;
    }
    return 0;
}


Measured memory_bytes: 5196
n,x=map(int,input().split())
l=list(map(int,input().split()))
s=[0]
d=0
y=0
for i in range(n):
    d=d+l[i]
    s.append(d)
for i in range(n+1):
    if s[i]<=x:
        y+=1
print(y)

Measured memory_bytes: 3060
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las
   

main = do
    n <- readInt
    let isOk a = (n `mod` a == 0) && (n `div` a < 10)
    if any isOk [1..9] then putStrLn "Yes" else putStrLn "No"

Measured memory_bytes: 380
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
 int a, b, c, i;//aは相手、ｂは種類
 int t[1000000];// 必殺のダメージ
 c = 0;
 cin >> a >> b;

 for (auto i = 0; i < b; i++) {
	 cin >> t[i];
 }

 for (i = 0; i < b; i++) {
	 c = c + t[i];
 }
 i = a % b;
 if (c >= a) {
	 cout << "Yes";
	}
 else {

	 cout << "No";
	}
}

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

typedef long long ll;

const int INF=1e+9;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)
using Graph = vector<vector<int>>;

int main(){
    int N, M; cin >> N >> M;
    Graph G(N);
    vector<int> ans(N,-1);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> dist(N, -1);
    queue<int> que;
    dist[0] = 0;
    que.push(0);
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            que.push(nv);
            ans[nv]=v+1;
        }
    }
    cout << "Yes" << endl;
    REP2(i,1,N) cout << ans[i] << endl;
    
}

Measured memory_bytes: 10564
#include<bits/stdc++.h>
using namespace std;
const double pi=atan(1.0)*4;
typedef long long ll;
const ll mod=1e9+7; 
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	ll ans=0;
	for(int i=k;i<=n+1;i++){
		ans=(ans+(ll)i*(2*n-i+1)/2-(ll)i*(i-1)/2+1)%mod;
	} 
	printf("%lld\n",ans);
	return 0;
} 


Measured memory_bytes: 3824
#include <iostream>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

struct problem{
  int d;
  int v;
};

void solve(int T, int D, int L){
  int t,t_wet = 0,t_rem = -INF,x[T+1];

  FOR(t,1,T+1){
    cin>>x[t];
  }

  FOR(t,1,T){
    if(x[t] >= L) t_rem = t;
    if(t_rem+D > t && t >0) t_wet++;
  }

  cout<<t_wet<<endl;
}

int main(){
  int T,D,L;

  while(1){
    cin>>T>>D>>L;
    if(T == 0 && D == 0 && L == 0) break;
    solve(T,D,L);
  }

  return 0;
}


Measured memory_bytes: 3456
n, k = map(int, input().split())
a = list(map(int, input().split()))

route ={1}
cur = 1
for i in range(k):
    goto = a[cur - 1]
    x = len(route)
    route.add(goto)
    y = len(route)
    if x == y:
        route = list(route)
        pre_goto = route.index(goto)
        dif = len(route) - pre_goto
        rest_step = (k - pre_goto) % dif
        print(route[pre_goto + rest_step])
        break
    cur = goto
else:
    route = list(route)
    print(route[k])

Measured memory_bytes: 106292
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

bool solve() {

	int r;
	cin >> r;
	cout << 3 * r * r << endl;

	return true;
}

signed main() {
	solve();

	return 0;
}

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

using namespace std;

typedef long long ll;

ll calc1(ll h, ll w){
    ll ret = numeric_limits<ll>::max();
    for (int i = 1; i <= w - 2; ++i) {
        vector<ll> x(3);
        x[0] = i;
        x[1] = (w - i) / 2;
        x[2] = (w - i + 1) / 2;
        sort(x.begin(), x.end());
        ret = min(ret, x[2] - x[0]);
    }

    if(ret == numeric_limits<ll>::max()) h = 1;
    return ret * h;
}

ll calc2(ll h, ll w){
    ll ret = numeric_limits<ll>::max();
    for (int i = 1; i <= w - 1; ++i) {
        vector<ll> x(3);
        x[0] = h * i;
        x[1] = h / 2 * (w - i);
        x[2] = (h + 1) / 2 * (w - i);
        sort(x.begin(), x.end());
        ret = min(ret, x[2] - x[0]);
    }

    return ret;
}

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

    ll ans = min(calc1(h, w), calc1(w, h));
    ans = min(ans, min(calc2(h, w), calc2(w, h)));

    cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  var (a, b, c, d) = readLine()!!.split(" ").map { it.toInt() }

  while (true) {
    //高橋
    c -= b
    if (c <= 0) {
      println("Yes")
      return
    }

    // 青木
    a -= d
    if (a <= 0) {
      println("No")
      return
    }
  }
}


Measured memory_bytes: 36420
use proconio::input;

fn main() {
    input! {
        n: usize,
        l: [i64; n],
    };
    let mut ans = 0_i64;
    for i in 0..n {
        for j in i + 1..n {
            for k in j + 1..n {
                if l[i] != l[j]
                    && l[i] != l[k]
                    && l[j] != l[k]
                    && std::cmp::max(std::cmp::max(l[i], l[j]), l[k])
                        < (l[i] + l[j] + l[k] - std::cmp::max(std::cmp::max(l[i], l[j]), l[k]))
                {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    bool can = false;
    for(int i=0; i<s.size(); i++){
        if(s==t){
            can = true;
            break;
        }
        s = s[s.size()-1] + s.substr(0, s.size()-1);
    }
    if(can){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x;cin >> x;return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
void solve(){
    ll n = nxt(), d = nxt();
    ll ans = 0;
    fo(i, n){
        ll x, y;
        cin >> x >> y;
        ll dof = sq(x) + sq(y);
        if(dof <= sq(d))ans++;
    }
    ANS;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    //cin>>TC;
    while(TC--){
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
ll mod = 1e9+7;
ll inf = 1e10;

ll gcd(ll a, ll b){
  return (b != 0) ? gcd(b, a%b) : a;
}

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  ll ans = 0;
  rep1(i, s.size()){
    rep(j, s.size()-i+1){
      ll plus;
      if(j == 0 || j == s.size()-i) plus = 1;
      else plus = 2;
      ll num = stol(s.substr(j, i));
      ans += num*pow(2, s.size()-plus-i);
    }
  }
  ans += stol(s);
  cout << ans << "\n";
  return 0;
}   

Measured memory_bytes: 256
x, y = map(int, input().split())

#x, y = 51, 100
#b = (y - 2 * x) // 2
#a = x - b
#print(a, b)

if y - 2 * x >= 0 and (y - 2 * x) % 2 == 0 and x - (y - 2 * x) // 2 >= 0 :
    print('Yes')
else:
    print('No')



Measured memory_bytes: 9012
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

x = [True for _ in range(n)]

ans = 0
for i in range(n):
    if k <= i and x[i - k] and t[i] == t[i - k]:
        x[i] = False
    else:
        if t[i] == 'r':
            ans += p
        elif t[i] == 's':
            ans += r
        else:
            ans += s
print(ans)

Measured memory_bytes: 4212
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int h = in.nextInt();
		while (n != 0 || h != 0) {
			long all = n * n * n - h * n;
			Integer[][] lines = new Integer[h][];
			Set<Integer> aaa = new HashSet<Integer>();
			for (int i = 0; i < h; i++) {
				aaa.clear();
				String o = in.next();
				Integer[] block;
				Integer a = Integer.valueOf(in.nextInt());
				Integer b = Integer.valueOf(in.nextInt());
				if ("xy".equals(o)) {
					block = new Integer[] { a, b, null };
					for (int j = 0; j < i; j++) {
						Integer[] other = lines[j];
						if (other[2] != null && (a.equals(other[0]) || b.equals(other[1]))) {
							aaa.add(other[2]);
						}
					}
				} else if ("xz".equals(o)) {
					block = new Integer[] { a, null, b };
					for (int j = 0; j < i; j++) {
						Integer[] other = lines[j];
						if (other[1] != null && (a.equals(other[0]) || b.equals(other[2]))) {
							aaa.add(other[1]);
						}
					}
				} else {
					block = new Integer[] { null, a, b };
					for (int j = 0; j < i; j++) {
						Integer[] other = lines[j];
						if (other[0] != null && (a.equals(other[1]) || b.equals(other[2]))) {
							aaa.add(other[0]);
						}
					}
				}
				lines[i] = block;
				all += aaa.size();
			}
			Arrays.toString(lines);
			System.out.println(all);
			n = in.nextInt();
			h = in.nextInt();
		}
	}

}

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

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <long long> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>
#define PI acos(-1)

int mod = 1e9 + 7;

using namespace std;
int k;

bool check(string s) {

    int l = 0;
    int r = s.size()/2;

    while(r != s.size()) {
        if(s[l] != s[r]) {
            return false;
        }
        l++;
        r++;
    }

    return true;
}

vector<long long> fac(20 + 1);

void fact() {
    fac[0] = 1;
    for(int i = 1; i <= 20; i++) {
        fac[i] = fac[i - 1] * i;
    }
}

void solve() {
    int s;
    cin >> s;

    vii ans(s + 1, 0);

    ans[0] = 1;

    for(int i = 3; i <= s; i++) {
        ans[i] = (ans[i - 1] + ans[i - 3]) % mod;
    }

    cout << ans[s] << endl;
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    //fact();
    int t = 1;
    //cin >> t;

    for(k = 1; k <= t; k++) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3588
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        s: String,
    }
    let len = s.len();
    let mut ans = false;

    if len == 7 && s == "keyence" {
        ans = true;
    }
    'outer: for i in 0..(len + 1) {
        for j in i + 1..(len + 1) {
            let mut str: String = s[0..i].to_string();
            str.push_str(&s[j..]);
            if str == "keyence" {
                ans = true;
                break 'outer;
            }
        }
    }
    if ans {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 2132
#include <stdio.h>
#include <stdlib.h>
int main(void){
  int a,b,c,d,e,k,ans;
  ans=0;
  scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
 int h[5]={a,b,c,d,e};
  for(int i=0;i<5;i=i+1){
    for(int ii=0;ii<5;ii=ii+1){
      if(abs(h[i]-h[ii])>k){
      ans=ans+1;
      
      }
    }
  }
  if(ans==0){
    printf("Yay!");
  }else{
    printf(":(");
  }
    return 0;
  }

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int gcd(int k, int l) {
    if(k%l == 0) {
        return(l);
    } else {
        return(gcd(l, k%l));
    }
}

int main() {
    ll K;
    int a, b, c, gcda;
    ll all = 0;

    cin >> K;

    for(a=1; a<=K; a++) {
        for(b=1; b<=K; b++) {
            for(c=1; c<=K; c++) {
                 gcda = gcd(a,b);
                 all += gcd(c, gcda);
            }
        }
    }

    cout << all;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
typedef vector<ll> vll;
typedef pair<ll, ll> Pll;

const int MAXN = 100000 + 10;

ll N;

int main() {
    cin >> N;
    vll A(N);
    vll B(N);
    vll C(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i] >> B[i] >> C[i];
    }
    vector<vector<ll>> dp(N + 10, vector<ll>(3));
    dp[0][0] = A[0];
    dp[0][1] = B[0];
    dp[0][2] = C[0];
    for (int i = 1; i < N; ++i) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + B[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + C[i];
    }
    cout << max({dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]}) << endl;
    return 0;
}

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

int main(){
	long long A, B, C, K;
	cin >> A >> B >> C >> K;
	long long ans;
	if (K < A) ans = K;
	else if(K >= A && K < A + B) ans = A;
	else ans = 2 * A - K +B;
	cout << ans << endl;
	return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int arr[200000];
	memset(arr,0,sizeof(arr));
	for(long long int i=2;i*i<200000;i++){
		for(long long int j=(i*i);j<200000;j+=i){
			if(arr[j]==0){
				arr[j]=1;
			}
		}
	}
	long long int n;
	cin>>n;
	for(long long int i=n;i<200000;i++){
		if(arr[i]==0){
			cout<<i;
			break;
		}
	}
	return 0;
}

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

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long

//constant
const int MOD = 1000000009;
//const int INF = INT_MAX / 3;

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int main() {
	int n, r;
	while (cin >> n >> r, n) {
		vi st(n);
		REP(i, n)
			st[i] = n-i ;

		REP(i, r) {
			vi sw(n);
			REP(i, n)
				sw[i] = st[i];
			int p, c;
			cin >> p >> c;
			REP(j, c)
				sw[j] = st[p-1  + j];
			REP(j, p-1)
				sw[j + c] = st[j];


			REP(i, n)
				st[i] = sw[i];

		}

		cout << st[0] << endl;
	}

	return 0;
}

Measured memory_bytes: 2996
#include <bits/stdc++.h>
#define nmax 100005

using namespace std;

bool visited[nmax]={};
vector <int> a;
vector <int> sa,sb;
vector <int> g[nmax];

void dfs(int u){
    visited[u]=1;
    sa.push_back(u);
    sb.push_back(a[u]);
    for(auto v:g[u]){
        if(!visited[v]){
            dfs(v);
        }
    }
    return;
}

int solve(){
    unordered_map<int,int>m;
    for(int i=0;i<sa.size();i++){
        m[sa[i]]++;
    }
    for(int i=0;i<sb.size();i++){
        m[sb[i]]--;
    }
    int ans=0;
    for(auto x:m){
        if(x.second==0){
            ans++;
        }
    }
    return ans;
}

int main(){
    int n,m;
    cin >> n >> m;
    a.resize(n+1);
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    while(m--){
        int u,v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(!visited[i]){
            dfs(i);
        }
        ans+=solve();
        sa.clear();
        sb.clear();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14140
/*input
10
3 3 3 3 4 4 4 5 5 5
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;
unordered_map<int,int> freq;
int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=0,sum=0,p,x=-1,y=-1;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>a[i];
		++freq[a[i]];
	}
	sort(a,a+n);
	for(int i=n;i--;){
		if(freq[a[i]]>1){
			if(x==-1) {
				x=a[i];
				freq[a[i]]-=2;
			}
			else if(y==-1) {
				y=a[i];
				freq[a[i]]-=2;
			}
		}
	}
	if(y!=-1) cout<<x*y;
	else cout<<0;
}

Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    int cnt=0;
    cin>>s;
    cin>>t;
    int len=s.size();
    for(int i=0;i<len;i++)
    {
       if(s[i]==t[i])
       cnt++;
    }
    if(cnt==len)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <queue>
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;
typedef pair<string,int> P;
int n,qt;
vector<P> vec;


int main(void)
{
    cin>>n>>qt;
    queue<P> que;
    for(int i=0; i<n; i++)
    {
        string s;
        int t;
        cin >> s >> t;
        que.push(P(s,t));
    }
    int now=0;
    while(que.size())
    {
        P q=que.front();
        que.pop();
        if(q.second<=qt)
        {
            vec.push_back(P(q.first,now+q.second));
            now+=q.second;
        }
        else
        {
            now+=qt;
            que.push(P(q.first,q.second-qt));
        }
    }
    for(int i=0; i<n; i++)
    {
        cout << vec[i].first << " " << vec[i].second << endl;
    }
    return 0;
}



Measured memory_bytes: 7036
#include <iostream>
#include <string>
#include <map>
#include <sstream>
using namespace std;

int main()
{
  map<char, string> c2s;
  c2s[' '] = "101";
  c2s['\''] = "000000";
  c2s[','] = "000011";
  c2s['-'] = "10010001";
  c2s['.'] = "010001";
  c2s['?'] = "000001";
  c2s['A'] = "100101";
  c2s['B'] = "10011010";
  c2s['C'] = "0101";
  c2s['D'] = "0001";
  c2s['E'] = "110";
  c2s['F'] = "01001";
  c2s['G'] = "10011011";
  c2s['H'] = "010000";
  c2s['I'] = "0111";
  c2s['J'] = "10011000";
  c2s['K'] = "0110";
  c2s['L'] = "00100";
  c2s['M'] = "10011001";
  c2s['N'] = "10011110";
  c2s['O'] = "00101";
  c2s['P'] = "111";
  c2s['Q'] = "10011111";
  c2s['R'] = "1000";
  c2s['S'] = "00110";
  c2s['T'] = "00111";
  c2s['U'] = "10011100";
  c2s['V'] = "10011101";
  c2s['W'] = "000010";
  c2s['X'] = "10010010";
  c2s['Y'] = "10010011";
  c2s['Z'] = "10010000";

  map<string, char> s2c;
  s2c["00000"] = 'A';
  s2c["00001"] = 'B';
  s2c["00010"] = 'C';
  s2c["00011"] = 'D';
  s2c["00100"] = 'E';
  s2c["00101"] = 'F';
  s2c["00110"] = 'G';
  s2c["00111"] = 'H';
  s2c["01000"] = 'I';
  s2c["01001"] = 'J';
  s2c["01010"] = 'K';
  s2c["01011"] = 'L';
  s2c["01100"] = 'M';
  s2c["01101"] = 'N';
  s2c["01110"] = 'O';
  s2c["01111"] = 'P';
  s2c["10000"] = 'Q';
  s2c["10001"] = 'R';
  s2c["10010"] = 'S';
  s2c["10011"] = 'T';
  s2c["10100"] = 'U';
  s2c["10101"] = 'V';
  s2c["10110"] = 'W';
  s2c["10111"] = 'X';
  s2c["11000"] = 'Y';
  s2c["11001"] = 'Z';
  s2c["11010"] = ' ';
  s2c["11011"] = '.';
  s2c["11100"] = ',';
  s2c["11101"] = '-';
  s2c["11110"] = '\'';
  s2c["11111"] = '?';

  string s;
  while (getline(cin, s)) {
    string e1 = "";
    for (unsigned int i = 0; i < s.size(); ++i) {
      if (c2s.find(s[i]) != c2s.end())
	e1 += c2s[s[i]];
    }

    while (e1.size()%5 != 0)
      e1 += "0";

    string e2 = "";
    for (int i = 0; i < e1.size(); i += 5)
      e2 += s2c[e1.substr(i, 5)];
    cout << e2 << endl;
  }
  return 0;
}

Measured memory_bytes: 0
r, c = map(int, input().split())
matrix = []
sum_ = []
for i in range(r):
    list_ = list(map(int, input().split()))
    matrix.append(list_)
    matrix[i].append(sum(list_))

for i in range(c+1):
  res = 0
  for j in range(r):
    res += matrix[j][i]
  sum_.append(res)
matrix.append(sum_)
for i in range(r+1):
  print(' '.join(map(str, matrix[i])))
    


Measured memory_bytes: 5700
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		double dept = 100000;
		int keta = 1000;
		
		Scanner scan = new Scanner(System.in);
		
		int k = scan.nextInt();
		
		for(int i=0;i<k;i++){
			dept = dept * 1.05;
			dept = dept / keta;
			dept = keta* (Math.ceil(dept));
		}
		System.out.println((int)dept);
	}
	
}

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

const int64_t MOD= 1000000007;
const int Nfac= 2000007;
#define MEMORY 0 // 1/0: 階乗を配列に格納をする前処理をする/しない
/* 剰余環 Z/nZ */
struct mint{ // Z/nZ に関する演算(n:素数の場合は除算も)をサポートする構造体
  int64_t rep; // 出力すべき代表元 rep \in {0,1,..,MOD- 1}
  mint(int64_t x=0): rep(((x%MOD)+ MOD)% MOD){}
  mint operator-() const { return mint(-rep);}
  mint& operator+=(const mint& x){
    rep+= x.rep; 
    if(rep>= MOD) rep-= MOD;
    return *this;
  }
  mint& operator-=(const mint& x){
    rep-= x.rep;
    if(rep< 0) rep+= MOD;
    return *this;
  }
  mint& operator*=(const mint& x){
    rep*= x.rep; rep%= MOD;
    return *this;
  }
  mint operator+(const mint x) const {
    mint ans(*this);
    ans+= x;
    return ans;
  }
  mint operator-(const mint x) const {
    mint ans(*this);
    ans-= x;
    return ans;
  }
  mint operator*(const mint x) const {
    mint ans(*this);
    ans*= x;
    return ans;
  }

  mint pow(int64_t d) const{ // d \geq 0
    if(d==0) return 1;
    else{
      mint ans= pow(d>>1);
      ans*= ans;
      if(d&1){ ans*= *this; }

      return ans;
    }
  }

  friend istream& operator >> (istream &is, mint& x) noexcept{
    int64_t a;
    is >> a;
    x= a;
  }
  friend ostream& operator << (ostream &os, const mint& x) noexcept{
      return os << x.rep;
  }
  // MOD が素数(<=> Z/nZ が体)のとき
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint& x){
    *this *= x.inv();
    return *this;
  }
  mint operator/(const mint x) const {
    mint ans(*this);
    ans/= x;
    return ans;
  }
};

/* 階乗,二項係数 */
#if (MEMORY==1)
// 前処理として,階乗を配列に格納をするver.
vector<mint> mfac(Nfac+1), ifac(Nfac+1);
void fact_modp_init(int N= Nfac){
  mfac.at(0)= 1;
  mint buf;
  for(int i=1; i<=N; i++){
    buf= i;
    mfac.at(i)= mfac.at(i-1)* buf;
  }

  ifac.at(N)= mfac.at(N).inv();
  for(int i=N; i>0; i--){
    buf= i;
    ifac.at(i-1)= ifac.at(i)* buf;
  }
}
#else
// 前処理を回避するver.
void fact_modp_init(int N= Nfac){}
mint mfac(int N){
  mint ans= 1;
  mint buf;
  for(int i=1; i<=N; i++){
    buf= i;
    ans*= buf;
  }

  return ans;
}
#endif

mint binom_modp(int n, int k){
  if(n < 0 || min(k,n-k) < 0) return 0;
  else{
#if (MEMORY==1)
    return mfac.at(n)* ifac.at(k)* ifac.at(n-k);
#else
    k= min(k, n-k);
    mint ans= 1;
    for(int i=1; i<=k; i++){
      mint num= n-i+1;
      ans*= num;
    }
    ans/= mfac(k);

    return ans;
#endif
  }
}

mint multiset_modp(int n, int r){
  if(n==0 && r==0) return 1;
  else{
    return binom_modp(n+r-1, r);
  }
}
// ^^^ テンプレここまで ^^^
int main(){
  int64_t N,M;
  cin >> N >> M;

  mint ans= (N==M)        ? mfac(N)* mfac(M)* 2
           :(abs(N-M)==1) ? mfac(N)* mfac(M)
                          : 0;
  cout << ans << endl;
}

Measured memory_bytes: 256