akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;

template<uint32 MOD>
class modint {
public:
	uint32 a;
	modint() :a{ 0 } {}
	modint(int64 x) :a{ norms(x%MOD + MOD) } {}
	static uint32 norms(const uint32 &x) { return (x < MOD) ? x : x - MOD; }
	static modint make(const uint32 &x) { modint ret;ret.a = x;return ret; }
	const modint operator+(const modint &o) const { return make(norms(a + o.a)); }
	const modint operator-(const modint &o) const { return make(norms(a + MOD - o.a)); }
	const modint operator*(const modint &o) const { return make((uint64)a*o.a%MOD); }
	const modint operator/(const modint &o) const { return make((uint64)a*~o%MOD); }
	modint &operator+=(const modint &o) { return *this = *this + o; }
	modint &operator-=(const modint &o) { return *this = *this - o; }
	modint &operator*=(const modint &o) { return *this = *this * o; }
	modint &operator/=(const modint &o) { return *this = *this / o; }
	modint &operator^=(const uint32 &o) { return *this = *this^o; }
	const modint operator~() const { return *this ^ (MOD - 2); }
	const modint operator-() const { return make(norms(MOD - a)); }
	const modint operator++() { return *this = make(norms(a + 1)); }
	const modint operator--() { return *this = make(norms(a + MOD - 1)); }
	const bool operator!() const { return !a; }
	const bool operator==(const modint &o) const { return a == o.a; }
	const bool operator!=(const modint &o) const { return a != o.a; }
	const bool operator<(const modint &o) const { return a < o.a; }
	const bool operator<=(const modint &o) const { return a <= o.a; }
	const bool operator>(const modint &o) const { return a > o.a; }
	const bool operator>=(const modint &o) const { return a >= o.a; }
	const modint operator^(const uint32 &x) const {
		uint64 t = (uint64)a;uint32 u = 0;
		for (uint32 i = 0;i < 31;++i) { if (x >> i & 1) u = norms(u + t);t = (t*t) % MOD; }
		return make(u);
	}
};

using mint = modint<1000000007>;
int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	std::string s;
	std::cin >> n >> s;
	mint dp[5003][5003] = {};
	dp[0][0] = 1;
	for (uint32 i = 1;i <= n;++i) {
		dp[i][0] = dp[i - 1][1] + dp[i - 1][1] + dp[i - 1][0];
		for (uint32 j = 1;j <= i;++j) {
			dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j + 1] + dp[i - 1][j + 1];
		}
	}
	std::cout << dp[n][s.length()].a << "\n";
	return 0;
}

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

int gcd(int x,int y){
	if(y==0) return x;
	else return gcd(y,x%y);
}

int lcm(int x,int y){
	return x*y/gcd(x,y);
}
 
signed main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=1;i<n;i++){
		if(a[i-1]==a[i]){
			ans++;
			a[i]=1000000000;
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;

int main()
{
    int n,counter=0,x;
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>x;
        if (x&1 && i&1)
            counter++;
    }
    cout<<counter;

    return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int t = sc.nextInt();
    
    if(X-t >= 0){
    	System.out.println(X-t);
    }else{
    	System.out.println(0);
    }
   
  }
}

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

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

    int n;
    cin >> n;

    int sa = 0;
    int now_x = 0;
    int now_y = 0;
    int now_t = 0;

    rep(i, n) {
        int t, x, y;
        cin >> t >> x >> y;

        if((abs(x-now_x)+abs(y-now_y)) > (t-now_t)) {
            cout << "No" << endl;
            return 0;
        }
        if((t-now_t) % 2 != (abs(x-now_x)+abs(y-now_y)) % 2) {
            cout << "No" << endl;
            return 0;
        }
        now_x = x;
        now_y = y;
        now_t = t;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3616
import sys
input = sys.stdin.readline
from itertools import accumulate


def read():
    N = int(input().strip())
    return N,


def solve(N, MOD=10**9+7):
    return (pow(10, N, MOD) - pow(9, N, MOD) - pow(9, N, MOD) + pow(8, N, MOD)) % MOD


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if((C+B-1)/B<=(A+D-1)/D){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    for(int j = N - 1; j > 0; j--){
        
        cout << a.at(j) << " ";
    }
    cout << a.at(0) << endl;
}


Measured memory_bytes: 3084
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AChangingACharacter solver = new AChangingACharacter();
        solver.solve(1, in, out);
        out.close();
    }

    static class AChangingACharacter {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt() - 1;

            String s = in.next();

            StringBuilder sb = new StringBuilder();
            sb.append(s);
            sb.replace(k, k + 1, sb.substring(k, k + 1).toLowerCase());

            out.println(sb);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21844
N=int(input())
A=list(map(int,input().split()))
count=0
while(len(A)!=count):
    if(A[count]%2==0):
        pass
    else:
        A.pop(count)
        count=-1
    count+=1
ans="APPROVED"
for i in A:
    if(i%3==0 or i%5==0):
        pass
    else:
        ans="DENIED"
        break
print(ans)

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

int main(void){
    string S, T;
    int count = 0;
    cin >> S;
    cin >> T;
    for(int i = 0;i < 3;i++){
        if(S.at(i) == T.at(i)) count++;
    }
    cout << count << endl;
    return 0;
}


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9;
const LL LINF = INF * INF;

int n;
const int MAX = 1 << 17;
int a[MAX];
int b[MAX];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

	cin >> n;
	FOR(i, 0, n)
		cin >> a[i];
	FOR(i, 0, n)
		cin >> b[i];
	
	LL su = 0;
	FOR(i, 0, n)
		su += b[i];
	LL s = 0;
	FOR(i, 0, n)
		s += a[i];
	
	if (su > s)
	{
		cout << -1 << endl;
		return 0;
	}
	
	VI brak, zab;
	FOR(i, 0, n)
		if (a[i] < b[i])
			brak.PB(b[i] - a[i]);
		else
			if (a[i] > b[i])
				zab.PB(a[i] - b[i]);
	
	sort(ALL(zab));
	reverse(ALL(zab));
	int ans = SZ(brak);
	LL suma = 0;
	for(auto i: brak)
		suma += i;
	
	LL vje = 0;
	FOR(i, 0, SZ(zab))
	{
		if (vje >= suma)
			break;
		ans++;
		vje += zab[i];
	}	
	
	cout << ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <numeric>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

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

int main(){
	ll A,B,C,D;
	cin >> A >> B >> C >> D;
	ll CD = (D/gcd(C,D))*C;
	ll sowa = B-A+1;
	ll Cans = B/C - (A-1)/C;
	ll Dans = B/D - (A-1)/D;
	ll CDans = B/CD - (A-1)/CD;
	cout << sowa - Cans - Dans + CDans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int taroPoint = 0;
        int hanakoPoint = 0;
        scanner.nextLine();
        
        for(int i=1;i<=n;i++){
            String input = scanner.nextLine();
            String inputArr[] = input.split(" ");
            int check = inputArr[0].compareTo(inputArr[1]);
            if(check > 0){
                taroPoint += 3;
            } else if(check == 0){
                taroPoint += 1;
                hanakoPoint += 1;
            } else {
                hanakoPoint += 3;
            }
        }
        System.out.println(Integer.toString(taroPoint) + " " + Integer.toString(hanakoPoint));
    }
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int h = sc.nextInt();
        int a[] = new int[n];
        int b[] = new int[n];
        int amax = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if (amax < a[i]) {
                amax = a[i];
            }
            b[i] = sc.nextInt();
        }
        Arrays.sort(a);
        Arrays.sort(b);

        int anscnt = 0;
        int i = 0;
        while (h > 0) {
            if (n - 1 - i >= 0) {
                int nage = b[n - 1 - i];
                i++;
                if (nage > amax) {
                    h = h - nage;
                } else {
                    h = h - amax;
                }
            } else {
                h = h - amax;
            }
            anscnt++;
        }
        System.out.println(anscnt);
    }
}

Measured memory_bytes: 86548
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
		}
		
		int count = 0;
		int p = 1;
		for(int i=0;i<N;i++) {
			if(A[i] != p) {
				count++;
			}else {
				p++;
			}
		}
		if(p==1) {
			System.out.println(-1);
		}else {
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 65376
<?php

function input(string $func = null) {
    if ($func === null) {
        return trim(fgets(STDIN));
    } else {
        return $func(trim(fgets(STDIN)));
    }
}

function input_array(string $func = null) {
    if ($func === null) {
        return explode(' ', trim(fgets(STDIN)));
    } else {
        return array_map(function($v) use ($func) {
            return $func($v);
        }, explode(' ', trim(fgets(STDIN))));
    }
}

$ns = input_array('intval');
sort($ns);

if ($ns === [1, 4, 7, 9]) {
    echo "YES\n";
} else {
    echo "NO\n";
}

Measured memory_bytes: 4856
import java.util.*;

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

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] cnt = new int[N];
		for(int i=0; i<M*2; i++) {
			cnt[sc.nextInt()-1]++;
		}
		
		boolean ok = true;
		for(int i=0; i<N; i++) {
			if(cnt[i]%2!=0) {
				ok = false;
				break;
			}
		}
		
		System.out.println(ok ? "YES" : "NO");
		
		sc.close();
	}
}


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

using namespace std;

#define Decimal fixed<<setprecision(20)

double ans;

void dfs(double d,double x,int n){
	if(n == 0)return;
	double next_d = ((n + 2) * d + 5 * x) / n;
	double next_x = ((n + 4) * x) / n;
	ans += (2 * d + (n - 1) * x) / 2;
	dfs(next_d,next_x,n-2);
}
int main(){
	int n;
	double d,x;
	cin >> n >> d >> x;
	dfs(d,x,n*2);
	cout << Decimal << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#-*- coding: utf-8 -*-
a, b, c, x, y = map(int, input().split())
m = min(x, y)
ans = 0
if (a + b) >= c * 2:
    ans += c * 2 * min(x, y)
    x -= m
    y -= m

if a >= c * 2:
    ans += c * 2 * x
    x = 0
if b >= c * 2:
    ans += c * 2 * y
    y = 0
print(ans + x*a + y*b)


Measured memory_bytes: 3060
#include <stdio.h>
int main(void)
{
	int n, d, a, b;
	
	scanf("%d %d", &n, &d);
	
	a = n / (2 * d + 1);
	b = n % (2 * d + 1);
	
	if(b == 0){
		a = a - 1;
	}
	
	printf("%d", a + 1);
	 
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
	int in1,in2,keep;
	while(1){
	scanf("%d %d",&in1,&in2);
	
	if( in1 == 0 && in2 ==0) break;

	if( in1 > in2 ){
		keep = in1;
		in1 = in2;
		in2 = keep;
	}

	printf("%d %d\n",in1,in2);
	}

	return 0;
}

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

int main(){
  ll n, k, q;
  cin >> n >> k >> q;
  vector<int> a(q+1);
  for(int i=1; i<=q; i++){
  	cin >> a[i];
  }
  vector<ll> score(n+1, 0);
  for(int i=1; i<=q; i++){
  	score[a[i]] += 1;
  }
  
  for(int i=1; i<=n; i++){
  	if(k - q + score[i] > 0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
typedef std::pair<int,int> P;
const int N=1e5+5;
struct Edge {
    int u,v,c;
    bool operator < (const Edge &b) const {
        return c<b.c;
    }
    void input() {
        scanf("%d%d%d",&u,&v,&c);
    }
}e[N];bool vis[N];
int n,m,par[N],a[N],rank[N];long long sum[N];
void init() {
    for(int i=1;i<=n;i++) par[i]=i,sum[i]=a[i],rank[i]=0;
}
int fd(int x) {
    while(x!=par[x]) x=par[x];
    return x;
}
std::vector<P> ans;
void unite(int x,int y) {
    x=fd(x);y=fd(y);
    if(x==y) return;
    if(rank[x]>rank[y]) std::swap(x,y);
    ans.push_back(P(x,y));
    par[x]=y;
    sum[y]+=sum[x];
    if(rank[x]==rank[y]) rank[y]++;
}
int main() {
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    for(int i=0;i<m;i++) e[i].input();
    init();std::sort(e,e+m);
    int tot=0;
    for(int i=0;i<m;i++) {
        int u=fd(e[i].u),v=fd(e[i].v);
        if(u==v) continue;
        tot++;vis[i]=1;
        unite(u,v);
    }
    int now=n-2;
    for(int i=m-1;~i;i--) if(vis[i]) {
        int u=fd(e[i].u);
        if(e[i].c>sum[u]) {
            tot--;
            int x=ans[now].first,y=ans[now].second;
            sum[y]-=sum[x];
            par[x]=x;
        }
        --now;
    }
    for(int i=0;i<m;i++) if(!vis[i]) {
        int u=fd(e[i].u),v=fd(e[i].v);
        if(u!=v) continue;
        if(sum[u]>=e[i].c) tot++;
    }
    printf("%d\n",m-tot);
    return 0;
}


Measured memory_bytes: 4600
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int INTMAX = 2147483647;
const int INTMIN = -2147483648;
const unsigned int UINTMAX = 4294967295;
const long LONGMAX = 9223372036854775807;
const long LONGMIN = -9223372036854775808;
const unsigned long ULONGMAX = 18446744073709551615;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}

long a[200010];

bool chk(int l, int r){
  int rp=0;
  FOR (i,l,r){
    if (rp&a[i]) return false;
    rp+=a[i];
  }
  return true;
}

int main(){
  int a,c5=0,c7=0;
  REP(i,3){
    cin >> a;
    if(a==5){
      c5++;
    }
    if(a==7){
      c7++;
    }
  }
  YN(c5==2&&c7==1);
  return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7
cnt=0
for i in range(n-1):
    for j in range(i+1,n):
        if A[i]>A[j]:
            cnt+=1
Aij=A+A
l=len(Aij)
cntij=0
for i in range(l-1):
    for j in range(i+1,l):
        if Aij[i]>Aij[j]:
            cntij+=1
cntij-=2*cnt
Tii=cnt*k
Tij=cntij*(k*(k-1)//2)
print((Tii+Tij)%mod)


Measured memory_bytes: 9204
def solve(w,v,tv,W):
    dp=[float('inf')]*(tv+1)
    dp[0]=0
    for i in range(len(w)):
        for j in range(tv-v[i],-1,-1):
            dp[j+v[i]]=min(dp[j+v[i]],dp[j]+w[i])
    maxx=0
    for i in range(tv+1):
        if dp[i]<=W:
            maxx=max(maxx,i)
    return maxx
if __name__=='__main__':
    n,W=map(int,input().split())
    w=[]
    v=[]
    for i in range(n):
        p,q=map(int,input().split())
        w.append(p)
        v.append(q)
    print(solve(w,v,sum(v),W))

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

int main() {
  int a,b;
  char op;
  while(cin>>a&&cin>>op&&cin>>b&&op!='?'){
   if(op=='+'){ cout<<a + b<<endl;}
   else if(op=='-'){ cout<<a - b<<endl;}
   else if(op=='/'){ cout<<a / b<<endl;}
   else if(op=='*'){ cout<<a * b<<endl;}
  }
  return 0;
}


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

#define ll long long
#define ar array

const int mxN=1e7;
int n, c[mxN+1];

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

	cin >> n;
	for(int i=1; i<=n; ++i)
		for(int j=0;j<=n;j+=i )
			++c[j];

	ll ans=0;
	for(int i=1; i<=n; ++i)
		ans+=(ll)i*c[i];
	cout << ans;
}


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

typedef struct pp{ //struct and link the quantum and name
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P);
P dequeue(void);


int main(){
  int elaps = 0;
  int i, q;
  P u;


  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){
    
    if(Q[head].t<=q){
      elaps += Q[head].t;
      u=dequeue();
      printf("%s %d\n",u.name,elaps);
   
    }

    else{
      elaps += q;
      Q[head].t -= q;
      enqueue(Q[head]);
      dequeue();
    }
  }  

 
  return 0;
  
}

void enqueue(P x){ 
  Q[tail]=x;
  
  if(tail==LEN){
    tail = 1;
  }
  else{
    tail++;
  }
}

P dequeue(){
  P x;
  x = Q[head];

  if(head == LEN){
    head = 1;
  }
  else{
    head++;
  }
  return x; 
}

Measured memory_bytes: 10756
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

void solve()
{
    int N; cin >> N;
    int t=0, x=0, y=0;
    int nt,nx,ny;
    for (int i = 0; i < N; i++){
        cin >> nt >> nx >> ny;
        if (abs(nx-x) + abs(ny-y) > nt-t){
            cout << "No" << endl;
            return;
        }
        if ((abs(nx-x) + abs(ny-y)) % 2 != (nt-t) % 2){
            cout << "No" << endl;
            return;
        }
        t=nt, x=nx, y=ny;
    }
    cout << "Yes" << endl;
    return;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    // input();
    solve();
    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int H, W;
  cin >> H >> W;
  
  VVI xs(H, VI(W));
  cin >> xs;
  REP(y,H) REP(x,W){
	xs[y][x] ^= 1;
	if(xs[y][x]) xs[y][x] += (y>0? xs[y-1][x]: 0);
  }

  int ans = 0;
  REP(y,H){
	stack<PII> s;
	REP(x,W){
	  int lx = x;
	  while(!s.empty() && s.top().FF > xs[y][x]){
		maxi(ans, s.top().FF*(x-s.top().SS));
		lx = min(lx,s.top().SS);
		s.pop();
	  }
	  if(xs[y][x]) s.emplace(xs[y][x], lx);
	}
	while(!s.empty()){
	  maxi(ans, s.top().FF*(W-s.top().SS));
	  s.pop();
	}
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 10452
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut bc = vec![0; 60];
    let nn = n as i64;
    for i in 0..60 {
        for j in 0..n {
            if (a[j] & 1 << i) != 0 {
                bc[i] += 1;
            }
        }
    }
    let mut tot = 0;
    let mut cur: i64 = 1;
    const MOD: i64 = 1_000_000_007;
    for i in 0..60 {
        let tmp = bc[i] * (nn - bc[i]) % MOD;
        tot = (tot + tmp * cur) % MOD;
        cur = cur * 2 % MOD;
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    while(m--) {
        ll x; cin >> x;
        n -= x;
    }
    cout << max(-1ll,n) << endl;
    return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
vector<pair<ll,ll> > cost;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	ll n,m; cin>>n>>m;
	cost.resize(n);
	for(int i=0; i<n; i++) {
		cin>>cost[i].first>>cost[i].second;
	}
	sort(cost.begin(),cost.end());
	ll anss=0;

	int j=0;
	while(m) {
		ll ans=min(cost[j].second,m);
		//cout<<ans<<endl;
		m-=ans;
		anss+=1ll*ans*cost[j].first;
		j++;
	}

	cout<<anss<<endl;


	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;

string subsum(int* A,int n,int m){
  bitset<2010> E(1);

  rep(i,0,n){
    E |= (E<<A[i]);
  }

  if(E.test(m)) return "yes";
  else return "no";
}

int main(){
  int n; cin>>n;
  int a[n],b[n],c[n];
  ll ans=0;
  rep(i,0,n) cin>>a[i];
  rep(i,0,n) cin>>b[i];
  rep(i,0,n) cin>>c[i];

  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);

  rep(i,0,n){
    ll key=b[i];
    ll ida=lower_bound(a,a+n,b[i])-a;
    ll idc=n-(upper_bound(c,c+n,b[i])-c);
    //cout<<ida<<" "<<idc;
    ans+=ida*idc;
  }

  cout<<ans<<endl;
}



Measured memory_bytes: 1408
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)a- *(int*)b;
}

int main()
{
	
	int cnt = 0;
	int n;
	string j;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		j = to_string(i);
		if (j.size() % 2 != 0) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
//const ll MOD=1000000007LL;
const ll MOD=998244353;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}


class UnionFind{
  vector<int> par,siz;
  //0-indexed
  void init(int n){
    component = n;
    par.resize(n);
    for(int i=0;i<n;++i)par[i]=i;
    siz.resize(n,1);
    msiz = 1;
  }
public:
  int msiz,component;
  UnionFind(int n_){init(n_);}
  int root(int x){
    if(par[x]==x)return x;
    return par[x] = root(par[x]);
  }
  void unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x==y)return;
    siz[y] += siz[x];
    siz[x] = 0;
    par[x] = y;
    msiz = max(msiz,siz[y]);
    component--;
  }
  int size(int x){
    return siz[root(x)];
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
};

int main(){

  ll N,Q;
  cin >> N >> Q;

  UnionFind uf(N+3);

  FOR(q,0,Q){
    ll a,b,t;
    cin >> t >> a >> b;
    if(t){
      cout << uf.same(a,b) << endl;
    }else{
      uf.unite(a,b);
    }
  }

}



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

MX = 10**4
ans = {}
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            tmp = x**2+y**2+z**2+x*y+x*z+y*z
            if tmp > MX:
                break
            if not(tmp in ans):
                ans[tmp] = 1
            else:
                ans[tmp] += 1

for i in range(1, N+1):
    if i in ans:
        print(ans[i])
    else:
        print(0)


Measured memory_bytes: 9720
n, m, x = map(int, input().split())
a = list(map(int, input().split()))

fee = 0
flist = []
for i in range(len(a)):
    if a[i] < x:
        fee += 1
    else:
        flist.append(fee)
        flist.append(len(a) - i)
        break

print(min(flist))
        

Measured memory_bytes: 2940
# coding: utf-8
# Your code here!
N,K = list(map(int,input().split()))
rate = 0
for i in range (N):
    count = 0
    init_num = i+1
    while init_num < K:
        init_num *= 2
        count += 1
    rate += (0.5 ** count)/N
        
print (rate)

Measured memory_bytes: 2940
#include <iostream>
#include <string>

using namespace std;

int main() {
	string S;
	cin >> S;
	int nedan = 700;
	if (S[0] == 'o') nedan += 100;
	if (S[1] == 'o') nedan += 100;
	if (S[2] == 'o') nedan += 100;
	cout << nedan;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp18
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a1 = int.Parse(str[0]);
            int b1 = int.Parse(str[1]);
            int @int1 = a1 / b1;
            int @int2 = a1 % b1;
            decimal a2 = decimal.Parse(str[0]);
            decimal b2 = decimal.Parse(str[1]);
            decimal @decimal = a2 / b2;
            Console.WriteLine("{0} {1} {2}", @int1, @int2, @decimal);
        }
    }
}

Measured memory_bytes: 9444
# ABC120D - Decayed Bridges
class UnionFind:
    __slots__ = ["size", "first_idx", "parents"]

    def __init__(self, size: int, first_index: int = 0) -> None:
        self.size = size
        self.first_idx = first_index
        self.parents = [-1] * (size + first_index)

    def find(self, x: int) -> int:
        """Find the group (root) of vertex x"""
        if self.parents[x] < 0:
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def is_same(self, x: int, y: int) -> bool:
        """Return whether two vertices x and y are in the same group or not."""
        return self.find(x) == self.find(y)

    def unite(self, x: int, y: int) -> None:
        """Unite two groups of vertices x and y."""
        x, y = self.find(x), self.find(y)
        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def get_size(self, x: int) -> int:
        """Get the size of the group vertex x belongs"""
        return self.parents[self.find(x)]

    @property
    def groups(self) -> int:
        """Return the number of groups."""
        return len({self.find(x) for x in range(self.first_idx, self.size + self.first_idx)})


def main():
    N, M, *AB = map(int, open(0).read().split())
    uf = UnionFind(N, 1)
    current_unreachable = N * (N - 1) // 2
    ans = []
    for a, b in zip(*[iter(AB[::-1])] * 2):
        ans.append(current_unreachable)
        if not uf.is_same(a, b):
            current_unreachable -= uf.get_size(a) * uf.get_size(b)
        uf.unite(a, b)
    print("\n".join(map(str, ans[::-1])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 25332
#include <iostream>
#include <algorithm>
#include "stdio.h"
using namespace std;
static const int MAX = 200000;

int main() {
	int n, num[MAX];
	cin >> n;
	for(int i = 0; i < n; i ++) {
		scanf("%d", &num[i]);
	}
	int max = -2000000000;
	int min = num[0];
	for(int i = 1; i < n; i ++) {
		if(num[i] - min > max) {
			max = num[i] - min;			
		}
		if(num[i] < min) {
			min = num[i];
		}
	}
	
	printf("%d\n", max);

	return 0;
}

Measured memory_bytes: 4016
#include<stdio.h>
#include<string>
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int lent;
int sum;
string t;
char s[100002];
int main()
{
	cin>>t;
	lent=t.length();
	if(t[0]=='1')
	{
		for(int i=0;i<lent;i++)
		{
			if(i%2==0)s[i]='1';
			if(i%2!=0)s[i]='0';
		}
	}
	if(t[0]=='0')
	{
		for(int i=0;i<lent;i++)
		{
			if(i%2==0)s[i]='0';
			if(i%2!=0)s[i]='1';
		}
	}
	/*for(int i=0;i<lent;i++)
	cout<<s[i];
	cout<<endl;*/
	for(int i=0;i<lent;i++)
	{
		if(t[i]!=s[i])
			sum++;
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
    int i;
    int height[10];
    int temp, flag;

    for(i = 0; i < 10; i++){
        scanf("%d", &height[i]);
    }
    do{
        flag = 0;
        for(i = 0; i < 9; i++){
            if(height[i] > height[i + 1]){
                flag = 1;
                temp = height[i + 1];
                height[i + 1] = height[i];
                height[i] = temp;
            }
        }
    }while(flag);

    printf("%d\n%d\n%d\n", height[9], height[8], height[7]);

    return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = l[0], b = l[1], c = l[2], d = l[3];

            if (Math.Abs(a-c)<=d || (Math.Abs(a-b)<=d&&Math.Abs(b-c)<=d))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13396
import itertools

n, m, q = map(int, input().split())
listi = []
for i in range(q):
    listi.append(list(map(int, input().split())))

listn = []
for i in range(m):
    listn.append(i+1)
list_ex = list(itertools.combinations_with_replacement(listn, n))

ans = 0
for i in range(len(list_ex)):
    list_ex2 = list_ex[i]
    ans2 = 0
    for j in range(q):
        listi2 = listi[j]
        ai = listi2[0]-1
        bi = listi2[1]-1
        ci = listi2[2]
        if (list_ex2[bi] - list_ex2[ai] == ci):
            ans2 += listi2[3]
    if (ans < ans2):
        ans = ans2

print(ans)

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

#define int long long
#define double long double
#define pq priority_queue
#define pb push_back
#define mp make_pair

int root(int dsu[],int x)
{
  while(dsu[x]!=x)
  {
    dsu[x]=dsu[dsu[x]];
    x=dsu[x];
  }
  return x;
}

void init(int dsu[], int n)
{
  for(int i=0;i<=n;i++)
  {
    dsu[i]=i;
  }
}

void un(int dsu[],int x,int y)
{
  int a=root(dsu,x);
  int b=root(dsu,y);
  dsu[a]=dsu[b];
}

void printprecise(double l,int precision){
    std::cout << std::fixed;
    std::cout << std::setprecision(precision);
    std::cout << l <<endl;
}

int gcd(int x,int y)
{
  if(x==0)
  {
    return y;
  }
  else
  {
    return gcd(y%x,x);
  }
}

int lcm(int x,int y)
{
  return (x*y)/gcd(x,y);
}

main() 
{

  
  string a,b;
  cin>>a>>b;
  int arr[a.length()+1][b.length()+1];
  for(int i=0;i<=a.length();i++)
  {
    for(int j=0;j<=b.length();j++)
    {
      if(i==0||j==0)
      {
        arr[i][j]=0;
      }
      else if(a[i-1]==b[j-1])
      {
        arr[i][j]=arr[i-1][j-1]+1;
      }
      else
      {
        arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
      }
    }
  }
  int x=a.length(),y=b.length();
  string ans="";
  while(x>0&&y>0)
  {
    if(a[x-1]==b[y-1])
    {
      ans=ans+a[x-1];
      x--;y--;
    }
    else if(arr[x-1][y]>arr[x][y-1])
    {
      x--;
    }
    else
    {
      y--;
    }
  }
  reverse(ans.begin(),ans.end());
  cout<<ans;


}

  // #ifndef ONLINE_JUDGE
  // cout << "\nTime Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  // #endif
// }
// #ifndef ONLINE_JUDGE
// cout << "\nTime Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
// #endif

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

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


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

    COMinit();
 
    int N;
    cin >> N;
    int A[N];
    rep(i,N) cin >> A[i];
    int ans = 0;
    for(int i=1;i<N;i++){
      ans += (A[i]-A[i-1]) * finv[i];
      ans %= MOD;
    }
    ans *= fac[N-1];
    ans %= MOD;
    cout << ans << endl;

}

Measured memory_bytes: 13056
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

const ll mod=1e9+7;

ll divinMODworld(ll x) {
  ll a=1,b=x, m_=mod-2;
  while(m_ != 0) {
    if(m_&1) a=(a*b)%mod;
    b=b*b%mod;
    m_=m_>>1;
  }
  return a;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,a,b;cin>>n>>a>>b;
  ll na=1,nb=1,afrac=1,bfrac=1,n_=n;
  rep(i,a) {
    na=(na*n_)%mod; --n_;
    afrac=(afrac*(i+1))%mod;
  }
  n_=n;
  rep(i,b) {
    nb=(nb*n_)%mod; --n_;
    bfrac=(bfrac*(i+1))%mod;
  }
  const ll anum=(na*divinMODworld(afrac))%mod;
  const ll bnum=(nb*divinMODworld(bfrac))%mod;
  ll tot_=1,tot=1,rt=floor(sqrt(n)),rem=n-rt*rt;
  rep(i,rt) tot_=(tot_*2)%mod;
  rep(i,rt) tot=(tot*tot_)%mod;
  rep(i,rem) tot=(tot*2)%mod;
  ll ans=tot-anum-bnum-1;
  while(ans<0) ans+=mod;
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define ALL(a) (a.begin(), a.end())
using ll = long long;
template<typename T> void Out(T x) { cout << x << endl; }

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  for (int i = 0; i < s.size() -1; i++) {
    if (s[i] != s[i+1]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        String ans = ":(";

        if( a <= 8 && b <= 8){
            ans = "Yay!";
        }
        System.out.println(ans);

    }
}

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

using namespace std;

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

int main() {
    // code
    int k;
    cin >> k;
    long long ans = 0;
    for (int a = 1 ; a <= k; a++){
        for (int b = 1; b <= k; b++){
            for (int c = 1; c <= k; c++){
                ans += gcd(a,gcd(b,c));
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<map>
#include<queue>
#include<stack>

using namespace std;
int mp[110][110];
int color[10005];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
        cin>>n;
        for(int i=1; i<=n; i++)
            scanf("%d",&color[i]);
        int k=1,x=1,i,j;
        for(i=0,j=0; ; )
        {
            if(color[k]!=0)
            {
                mp[i][j]=k;j+=x;
                if(j==w)
                {
                    j=j-1;
                    x=-x;
                    i++;
                    if(i==h)
                        break;
                }
                if(j==-1)
                {
                    j=0;
                    x=-x;
                    i++;
                    if(i==h)
                        break;
                }
                color[k]--;
                if(color[k]==0)
                    k++;
            }
        }
        for(int i=0;i<h;i++)
            for(int j=0;j<w;j++)
            printf("%d%c",mp[i][j],j==w-1?'\n':' ');
    }
    return 0;
}


Measured memory_bytes: 384
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

s = input()
s = list(reversed(s))

mods = [0 for _ in range(13)]
mods[0] = 1

x = 1
MOD = 10 ** 9 + 7
for c in s:
    new_mods = [v for v in mods]
    val = 0
    if c == '?':
        for i in range(1, 10):
            val = i * x % 13
            for j in range(13):
                new_mods[j] += mods[j - val] % MOD
    else:
        val = int(c) * x % 13
        for i in range(13):
            new_mods[i] = mods[i - val] % MOD

    mods = new_mods
    # print(mods)
    x *= 10
    x %= 13
print(mods[5] % MOD)
# print(total_mod % 13)



Measured memory_bytes: 48104
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define all(c) begin(c),end(c)
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	int N, M;
	while (true)
	{
		cin >> N >> M;
		if (N == 0 && M == 0)break;
		vector<int> C = vector<int>(M);
		for (int i = 0; i < M; i++)
		{
			cin >> C[i];
		}
		vector<vector<ll>> dp = vector<vector<ll>>(N + 1, vector<ll>(256, LLONG_MAX / 3));
		dp[0][128] = 0;
		int x;
		for (int i = 0; i < N; i++)
		{
			cin >> x;
			for (int j = 0; j < 256; j++)
			{
				for (int k = 0; k < M; k++)
				{
					int l = min(max(j + C[k], 0), 255);
					chmin(dp[i + 1][l], dp[i][j] + (x - l) * (x - l));
				}
			}
		}
		ll ans = LLONG_MAX;
		for (int i = 0; i < 256; i++)
		{
			chmin(ans, dp[N][i]);
		}
		cout << ans << endl;
	}
}

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


Measured memory_bytes: 43800
n = int(input())
num_list = [int(i) for i in input().split()]

k = 0
for i in range(len(num_list)):
    if i == 0:
        temp_min = num_list[i]
    else:
        temp_min = min(temp_min, num_list[i])
        
    if i != len(num_list)-1:
        if temp_min == num_list[i]:
            k += 1
    else:
        if temp_min == num_list[i]:
            k += 1
    
print(k)

Measured memory_bytes: 25768
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#define _USE_MATH_DEFINES

#include<math.h>
#include<unordered_map>

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

	void East(int a[])
	{//1364 4136
		int temp = a[0];
		a[0] = a[3];
		a[3] = a[5];
		a[5] = a[2];
		a[2] = temp;
	}

	void Western(int a[])
	{//1364 3641
		int temp = a[0];
		a[0] = a[2];
		a[2] = a[5];
		a[5] = a[3];
		a[3] = temp;
	}

	void North(int a[])
	{//1562 2156
		int temp = a[0];
		a[0] = a[1];
		a[1] = a[5];
		a[5] = a[4];
		a[4] = temp;
	}

	void South(int a[])
	{
		//1562 5621
		int temp = a[0];
		a[0] = a[4];
		a[4] = a[5];
		a[5] = a[1];
		a[1] = temp;
	}

	void Right(int a[])
	{
		//1243 2431
		int temp = a[1];
		a[1] = a[2];
		a[2] = a[4];
		a[4] = a[3];
		a[3] = temp;
	}

	void Left(int a[])
	{
		//1243 3124
		int temp = a[1];
		a[1] = a[3];
		a[3] = a[4];
		a[4] = a[2];
		a[2] = temp;
	}
int main()
{
	int a[100][6];
	int n;
	cin >> n;
	for (int k = 0; k < n; k++)
	{
		for (int i = 0; i < 6; i++)
		{
			cin >> a[k][i];
		}
	}

	for (int x = 0; x < n; x++)
	{
		for (int y = x + 1; y < n; y++)
		{
			bool isSame = false;

			for (int k = 0; k < 6; k++)
			{
				switch (k)
				{
				case 1:
					North(a[x]);
					break;
				case 2:
					North(a[x]);
					break;
				case 3:
					North(a[x]);
					break;
				case 4:
					East(a[x]);
					break;
				case 5:
					East(a[x]);
					East(a[x]);
					break;
				}
				int i1 = -1;
				for (int i = 0; i < 6; i++)
				{
					if (a[x][0] == a[y][i])
					{
						i1 = i;
						break;
					}
				}
				if (i1 == -1)
				{
					break;
				}

				if (i1 == 1) { North(a[y]); }
				if (i1 == 2) { Western(a[y]); }
				if (i1 == 3) { East(a[y]); }
				if (i1 == 4) { South(a[y]); }
				if (i1 == 5) { North(a[y]); North(a[y]); }

				int i2 = -1;
				for (int i = 1; i < 5; i++)
				{
					if (a[x][1] == a[y][i])
					{
						i2 = i;
						break;
					}
				}
				if (i2 == -1)
				{
					break;
				}

				if (i2 == 2) { Right(a[y]); }
				if (i2 == 3) { Left(a[y]); }
				if (i2 == 4) { Right(a[y]); Right(a[y]); }

				bool _isSame = true;
				for (int i = 0; i < 6; i++)
				{
					if (a[x][i] != a[y][i])
					{
						_isSame = false;
					}
				}

				if (_isSame)
				{
					isSame = true;
					break;
				}
			}

			if (isSame)
			{
				printf("No\n");
				return 0;
			}
		}
	}

	printf("Yes\n");

	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N-1);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  for(int i=0; i<N; i++){
    cin >> B.at(i);
  }
  for(int i=0; i<N-1; i++){
    cin >> C.at(i);
  }
  int Ans=0;
  for(int i=0; i<N; i++){
    Ans+=B.at(A.at(i)-1);
    if(i!=0 && A.at(i)==A.at(i-1)+1){
      Ans+=C.at(A.at(i-1)-1);
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256