akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "stack"
using namespace std;
 
int n;
string s,c;
stack<char> stk;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 
	cin>>n>>s;
	c=s;
	for(int i=0;i<n;i++){
		if(s[i]=='('){
			stk.push(s[i]);
		}
		else if(s[i]==')' && stk.empty()){
			c = '(' + c;
		}
		else if(s[i]==')' && !stk.empty()){
			stk.pop();
		}
	}
	while(!stk.empty()){
		c+=')';
		stk.pop();
	}
	cout<<c;
	return 0;
}

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

#define N 100
#define A 100

int main(){
  int i, j, n, a[A], minimum, temp1, temp2, count = 0;

  scanf("%d", &n);

  for(i = 0; i < n; i++)
    scanf("%d", &a[i]);

  for(i = 0; i < n; i++){
    minimum = i;
    for(j = i; j < n; j++){

      if(a[j] < a[minimum]){
	minimum = j;
      }
    }
    if(minimum != i){
      temp1 = a[minimum];
      temp2 = a[i];
      a[minimum] = temp2;
      a[i] = temp1;
      count++;
    }
  }

  for(i = 0; i < n; i++){
    if(i == n - 1){
      printf("%d", a[i]);
      continue;
    }

    printf("%d ", a[i]);
  }

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

  return 0;
}



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

int main(){

    int a, b, c;
    cin >> a >> b >> c;

    int diff;
    diff = a - b;

    if (c - diff > 0){
        cout << c - diff << endl;
    }
    else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>
 
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define Sort(x) sort(x.begin(),x.end()); 
#define ll long long
int mod=1e9+7;
const int INF = 1e9;
 
using namespace std;
 
 
 
int main(void) {
	string s;
	int a, b, c, d;
	cin >> s;
	a = (int)(s[0] - '0');
	b = (int)(s[1] - '0');
	c = (int)(s[2] - '0');
	d = (int)(s[3] - '0');
	int sum = 0;
	char cc[3];
	sum = a;
	rep(i, 0, 2) {
		rep(j, 0, 2) {
			rep(k, 0, 2) {
				int summ = sum;
				if (i == 0)summ += b;
				else summ -= b;
 
				if (j == 0)summ += c;
				else summ -= c;
 
				if (k == 0)summ += d;
				else summ -= d;
 
				if (summ == 7) {
					if (i == 0)cc[0] = '+';
					else cc[0] = '-';
 
					if (j == 0)cc[1] = '+';
					else cc[1] = '-';
					if (k == 0)cc[2] = '+';
					else cc[2] = '-';
 
					
				}
			}
		}
	}
 
	cout << a << cc[0] << b << cc[1] << c <<cc[2] << d << "=7" << endl;
 
	return 0;
}

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

int main() {
 
  int64_t a,b,c,d;
  cin >> a >> b >>c >>d;
  int64_t max;
  
  max = a * c;
  if(a * d > max)
    max = a*d;
  
  if(b * c > max)
    max = b*c;
  
  if(b * d > max)
    max = b*d;
  
  if(a<=0 && b>=0){
  	if(max < 0)
    	max = 0;
  }
  
  if(c<=0 && d>=0){
  	if(max < 0)
    	max = 0;
  }
  
 
  cout << max << endl;

  
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int b = 0;
    cin >> b;
    cout << a[b - 1];
}


Measured memory_bytes: 256
#!/usr/bin/env python3

N, K = map(int, input().split())
l_height = list(map(int, input().split()))
# print(N, K)
# print(l_height)

costs = []
if N == K:
    cost = 0
    max_height = l_height[0]
    for i in range(1, N):
        if max_height >= l_height[i]:
            cost += (max_height + 1) - l_height[i]
            l_height[i] = max_height + 1
        max_height = l_height[i]
    costs.append(cost)
else:
    for bits in range(2 ** N):
        buildings = []
        # bit立っている建物の番号のリストを求める
        for i in range(N):
            if bits & (1 << i):
                buildings.append(i)

        l_height_copy = l_height[:]
        cost = 0
        # K色の色を見えるようにしたときのcostを求める
        if len(buildings) == K:
            # print(f"\nbits: {bin(bits)}")
            # print(f"buildings: {buildings}")
            max_height = l_height_copy[0]
            for i in range(1, N):
                if i in buildings:
                    # print(f"i: {i} is in buildings")
                    # print(f"buildings: {buildings}")
                    # print(f"l_height_copy: {l_height_copy}")
                    # print(f"max_height: {max_height}")
                    # print(f"l_height_copy[i]: {l_height_copy[i]}")
                    # 建物iの高さを増やす必要があるとき
                    if max_height >= l_height_copy[i]:
                        # print("max_height >= l_height[i]")
                        # print(f"diff: {(max_height + 1) - l_height_copy[i]}")
                        cost += (max_height + 1) - l_height_copy[i]
                        # print(f"cost: {cost}")
                        l_height_copy[i] = max_height + 1
                        max_height = l_height_copy[i]
                        # print(f"updated max_height: {max_height}")
                    else:
                        max_height = l_height_copy[i]
                else:
                    if l_height_copy[i] > max_height:
                        # print(f"updated max_height: {max_height}")
                        max_height = l_height_copy[i]
            costs.append(cost)

# print(costs)
print(min(costs))

# ----- 方針 -----
# N > Kとする。
# i個目の建物高さを変更するとき1が立つN個のbitsを考える。
# bitが立っている建物の番号のリストを以下で求める。
# buildings = []
# for i in range(N):
#     if bits & (1 << i):
#         buildings.append(i)
# bitsのうち、K個bitが立っているものを考える。
# bitが立っている番号の建物が必ず見えるように高さを増やしたときのcostを求める。


Measured memory_bytes: 43628
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>

#define max 10

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}

int main()
{
    int n, d, i, j, k, x[max][max], cnt=0;
    double jud, ans=0;
    
    scanf("%d %d", &n, &d);
    for (i=0; i<n; i++) {
        for (j=0; j<d; j++) {
            scanf("%d", &x[i][j]);
        }
    }
    
    for (i=0; i<n-1; i++) {
        for (k=i+1; k<n; k++) {
            ans=0;
            for (j=0; j<d; j++) {
                ans=ans+pow(abs(x[k][j]-x[i][j]), 2);
            }
            ans=sqrt(ans);
            //printf("%lf,", ans);
            if(ceil(ans)==floor(ans)){
                cnt++;
            }
        }
    }
    
    printf("%d", cnt);
    
    return 0;
}




Measured memory_bytes: 128
N = int( input() )
A = [ list( map(int, input().split()) ) for i in range(2) ]

ans = 0
for i in range(N):
    sum = 0
    for j in range(N):
        if j <= i: sum += A[0][j]
        if i <= j: sum += A[1][j]
    ans = max( ans, sum )

print( ans )

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
	int n, m, l, a[100][100] = { 0 }, b[100][100] = { 0 };
	long long ans[100][100] = { 0 }, sum;
	cin >> n >> m >> l;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++){
		for (int j = 0; j < l; j++){
			cin >> b[i][j];
		}
	}
	for (int y = 0; y < n; y++){
		for (int x = 0; x < l; x++){
			sum = 0;
			for (int k = 0; k < m; k++){
				sum = sum + a[y][k] * b[k][x];
			}
			ans[y][x] = sum;
		}
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < l; j++){
			cout << ans[i][j];
			if (j != l - 1)
				cout << " ";
		}
		cout << endl;
	}
}


Measured memory_bytes: 3264
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
char a[205];

int judge(int ll)
{
	for(int i = 0; i <= ll / 2 - 1; i++){
		if(a[i] != a[i + ll / 2]) return false;
	}
	return true;
}


int main()
{
	scanf("%s",&a);
	int n = strlen(a);
	for(int i = 1; i <= n; i++){
		if((n - i) % 2) continue;
		else{
			if(judge(n - i)){ printf("%d\n",n - i); break;}
			else continue;
		}
	}
	return 0;
}
	

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

int n, l;

int main() {
    cin >> n >> l;
    long long sum = 0;
    int m = l;
    for(int i = 1; i <= n; i++) {
        sum += l + i - 1;
        if( abs(m) > abs(l + i - 1) )
            m = l + i - 1;
    }
    cout << sum - m << endl;
}

Measured memory_bytes: 256
N,K=map(int, input().split())
A=list(map(int, input().split()))
A.sort()
cnt=0
l=[]
l.append([A[0],0])
for i in range(len(A)):
  if A[i]==l[cnt][0]:
    l[cnt][1]+=1
  else:
    cnt+=1
    l.append([A[i],1])
if len(l) <= K:
  print(0)
else:
  l.sort(key=lambda x: x[1])
  sum=0
  for i in range(len(l)-K):
    sum+=l[i][1]
  print(sum)

Measured memory_bytes: 32960
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>
#include <fstream>
#include <cfloat>
#include <complex>
using namespace std;
int main() {
	int x; cin >> x;
	if (x >= 30) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast",3,"inline")
#include <bits/stdc++.h>
using namespace std;
long long n,m;
long long cnt,ans=1;
int main(){
	ios_base::sync_with_stdio(false);
	cin>>n>>m;
	cnt=n;
	if(m<2){
		cout<<0;
		return 0;
	}
	while(cnt<m){
		ans++;
		cnt+=n-1;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
for x in range(tx-sx):
	print('R',end='')
for y in range(ty-sy):
	print('U',end='')
for x in range(tx-sx):
	print('L',end='')
for y in range(ty-sy):
	print('D',end='')
print('D',end='')
for x in range(tx-sx+1):
	print('R',end='')
for y in range(ty-sy+1):
	print('U',end='')
print('L',end='')
print('U',end='')
for x in range(tx-sx+1):
	print('L',end='')
for y in range(ty-sy+1):
	print('D',end='')
print('R')

Measured memory_bytes: 4468
#-*-coding:utf-8-*-

import sys

def main():
    n = int(input())
    if n==0:
        print(0)
        exit()
    for i in range(11):
        if i*1000 >= n:
            print(i*1000-n)
            break

if __name__ == "__main__":
    main()

Measured memory_bytes: 9160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int p = 0;

		for(int i = 0; i <= B-A; i++) {
			String str = String.valueOf(A+i);
			if(str.charAt(0) == str.charAt(4)
					&& str.charAt(1) == str.charAt(3)) {
				p += 1;
			}
		}
		System.out.println(p);

	}

}

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

int main()
{
    int n,k;
    cin>>n>>k;
    int mx=n*4,mn=n*2;
    if(k%2){
        cout<<"No";
        return 0;
    }
    if(k<=mx&&k>=mn)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<0){
		if(a*-1==b){
			printf("0\n");
		}
		else{
			printf("-1\n");
		}
	}
	else{
		printf("1\n");
	}
	return 0;
}

Measured memory_bytes: 3148
#include <stdio.h>

int main(int argc, char* argv[])
{
	//ABC158 B
	//in N A B
	//先頭からのボール数・1回の青ボール数・1回の赤ボール数
	long long n, a, b;
	long long blue_total = 0;
	long long cnt_loop;


	scanf("%lld %lld %lld", &n, &a, &b);
	cnt_loop = n / (a + b);

	if (cnt_loop > 0) {
		blue_total = cnt_loop * a;
		n -= cnt_loop * (a + b);
	}

	if ((a > 0) && (n > 0)) {
		blue_total += n > a ? a : n;
	}
/*	while (n >= a + b) {
		n -= a;
		blue_total += a;
		n -= b;
	}
	if ((a > 0) && (n > 0)) {
		blue_total += n > a ? a : n;
	}*/

	printf("%lld", blue_total);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n;
int in[6000],ans;
while(cin>>n,n){
for(int i=0;i<n;i++){
cin>>in[i];
}
ans=in[0];
for(int i=0;i<n;i++){
int sum=0;
for(int j=i;j<n;j++){
sum=sum+in[j];
ans=max(sum,ans);
}
}
cout<<ans<<endl;
}
return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,d,a;
    cin>>n>>d>>a;
    vector<pair<ll,ll> > v;
    ll x,h;
    for(int i=0;i<n;i++){
    	cin>>x>>h;
    	v.pb(make_pair(x,h));
    }
    sort(be(v));
    ll p[n],q[n];
    for(int i=0;i<n;i++){
    	p[i]=v[i].first;
    	q[i]=v[i].second;
    }
    ll ans=0;
    ll num=0,maki=0;
    //ll st=0;
    ll c[n];
    memset(c,0LL,sizeof(c));
    //ll index=p[0];
    for(int i=0;i<n;i++){
    	num-=c[i];
    	q[i]-=num;
    	q[i]=max(q[i],0LL);


    	maki=(q[i]+a-1)/a;
    	ans+=maki;
    	maki*=a;
    	num+=maki;
    	q[i]=0;
    	c[upper_bound(p,p+n,p[i]+2*d)-p]+=maki;
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 9196
import qualified Data.ByteString.Char8 as C
import Data.List
import Data.Maybe
import qualified Data.Vector.Unboxed as U
import Data.Vector.Unboxed ((!))

main = sol <$> get <*> get <*> get >>= print

get = U.unfoldr (C.readInt . C.dropWhile (<'0')) <$> C.getLine

sol nmk a b = snd $ U.foldr' f ((n',0),n') sa
  where
  n = nmk!0
  k = nmk!2
  sa = U.takeWhile (<= k) $ U.scanl' (+) 0 a
  sb = U.takeWhile (<= k) $ U.scanl' (+) 0 b
  n' = U.length sa-1
  m' = U.length sb-1
  f s ((i,j),c) = ((i-1,j'),c')
    where
    j' = pred . fromMaybe (m'+1) $ find ((> k-s) . (sb!)) [j..m']
    c' = max c (i+j')

Measured memory_bytes: 18588
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 11 16:48:51 2020

@author: Aruto Hosaka
"""


import math
import collections

K = int(input())
ans = 0
g = []
for a in range(K):
  for b in range(K):
      g.append(math.gcd(a+1, b+1))
G = collections.Counter(g)

for k in range(K):
  for c in range(K):
      ans += math.gcd(k+1, c+1)*G[k+1]
      
print(ans)

Measured memory_bytes: 9628
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };

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

    int M = 0;
    for (int i = 0; i * (i - 1) <= 2 * N; ++i) {
        if (i * (i - 1) == 2 * N) {
            M = i;
        }
    }
    if (M == 0) {
        write("No");
        return 0;
    }
    write("Yes");

    vv<int> ans(M);
    int n = 1;
    rep(i, 0, M - 1) ans[0].push_back(n++);
    rep(i, 1, M - 1) {
        rep(j, 0, i) {
            ans[i].push_back(ans[j][i]);
        }
        rep(j, i, M - 1) ans[i].push_back(n++);
    }
    rep(i, M - 1) ans[M - 1].push_back(ans[i][i]);

    write(M);
    for (auto&& v : ans) {
        cout << v.size();
        for (int n : v) cout << ' ' << n;
        cout << endl;
    }
}

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

#define lp_ui(k,n) for(ui i = (k); i < (n); ++i)
#define lp_ul(k,n) for(ul i = (k); i < (n); ++i)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

using namespace std;

void solve(void)
{
	ui N{};
	cin >> N;

	vector<ui> vc_a(N + 1, 0);
	for (ui i = 1; i < N + 1; ++i) cin >> vc_a[i];

	bool res{ true };

	ui cnt{ 0 };

	for(ui i = N; i > 0; --i)
	{
		bool flag{false};

		for (ui j = i; j < N + 1; j+= i)
		{
			if (vc_a[j] != 0) flag = !flag;
		}

		if (flag)
		{
			++cnt;
			vc_a[i] = 1;
		}
		else
		{
			vc_a[i] = 0;
		}
	}

	if (res)
	{
		cout << cnt << "\n";

		for (ui i = 1; i < N + 1; ++i)
		{
			if(vc_a[i] != 0)
			{
				cout << i << " ";
			}
		}
		if (cnt)
		{
			cout << "\n";
		}
	}
	else
	{
		cout << -1 << endl;
	}

	return;
}

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

	solve();

//	auto ans = solve();
//	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
#define infll 1000000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
#define mod 1000000007
#define N 209
using namespace std;

int n,m,a[N],dp[N][100009];
int main(){
	scanf("%d%d",&n,&m);
	int i,j;
	for (i=1; i<=n; i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	dp[n+1][m]=1;
	for (i=n; i; i--)
		for (j=0; j<=m; j++){
			ad(dp[i][j%a[i]],dp[i+1][j]);
			ad(dp[i][j],(ll)dp[i+1][j]*(i-1));
		}
	int ans=0;
	for (i=0; i<a[1] && i<=m; i++) ad(ans,(ll)dp[1][i]*i);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 79744
import java.io.BufferedReader
import java.io.PrintWriter

class MainKt

val out: PrintWriter = PrintWriter(System.out)

fun main(args: Array<String>) {
    val n = MyScanner.readAsString().ofCountMap()['o']
    val score = if (n == null) 700 else 700 + 100 * n
    out.println(score)
    
    out.flush()
}


class MyScanner {
    companion object {
        private var reader : BufferedReader = System.`in`.bufferedReader()

        init {
            reader.mark(0)
        }

        fun reset(){
            reader.reset()
        }

        fun readAsInt(): Int {
            return Integer.parseInt(reader.readLine())
        }

        // Int
        fun readAsIntArray(delimiters: String = " "): IntArray {
            return reader
                .readLine()
                .split(delimiters)
                .map { s -> Integer.parseInt(s) }
                .toIntArray()
        }

        fun readNTimesAsInt(n: Int): IntArray {
            return (1..n).map { readAsInt() }.toIntArray()
        }

        fun readNTimesAsIntArray(n: Int): Array<IntArray> {
            return (1..n).map { readAsIntArray() }.toTypedArray()
        }

        // long
        // TODO 別の方法を考える
        fun readAsLong(): Long {
            return reader.readLine().toLong()
        }

        fun readAsLongArray(delimiters: String = " "): LongArray {
            return reader.readLine()
                .split(delimiters)
                .map { s -> s.toLong() }
                .toLongArray()
        }

        fun readNTimesAsLong(n: Int): LongArray {
            return (1..n).map { readAsLong() }.toLongArray()
        }

        fun readAsString(): String {
            return reader.readLine()
        }

        fun readAsStringArray(delimiters: String = " "): Array<String> {
            return readAsString().split(delimiters).toTypedArray()
        }

    }
}

/**
 * 要素とその個数を出力
 */
fun <T> Array<T>.ofCountMap(): Map<T, Int> {
    return this.groupBy { it }.mapValues { it.value.count() }
}

/**
 * 文字とその個数を出力
 */
fun String.ofCountMap(): Map<Char, Int> {
    return this.toCharArray().ofCountMap()
}

/**
 * 文字とその個数を出力
 */
fun CharArray.ofCountMap(): Map<Char, Int> {
    return this.groupBy { it }.mapValues { it.value.count() }
}

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

int main()
{
    int a=0,b=0,c;
     scanf("%d%d",&a,&b);
   
    
    if(a>8 || b >8){
        printf(":(");
    }else {
    printf("Yay!");
    }
    return 0;
}


Measured memory_bytes: 128
// #include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
 
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}
     
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution

int32_t main()
{
    IOS
    
        
    string s;
    cin>>s;
    if(s[2]==s[3] and s[4]==s[5])
    {
    	cout<<"Yes"<<endl;
    }
    else
    {
    	cout<<"No"<<endl;
    }
}       


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep (i ,n) for(int i=0;i<(n);i++) 
ll gcd (ll a,ll b) {return b?gcd(b,a%b):a;}   
ll lcm (ll a,ll b) {return a/gcd(a,b)*b;} 
const int mod=1e9+7;
int main(){
		string s;
		cin>>s;
		int cnt=0;
		for(int i=1;i<(int)s.size();i++){
			if(s[i-1]==s[i]){
				cnt++;
				s[i]^=1;
			}
		}
		cout<<cnt<<endl;
		return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main() {
	string S;
	cin >> S;
	for (int i = 0;i < 3;++ i) {
		if (S[3] == S[i]) { // 4文字目とi+1文字目が一致
			if (S[(i + 1) % 3] == S[(i + 2) % 3] && S[3] != S[(i + 1) % 3]) cout << "Yes"; // 3を法として巡回することを考えると楽
			else cout << "No";
			return 0;
		}
	} // 一致する文字が無い時
	cout << "No";
	return 0;
}

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

#define MAX_N (100000)
#define MAX_M (MAX_N - 1)
#define NUM_MOD (1000000007)

int main(int argc, char *argv[]) {
  // read inputs
  int N, M, as[MAX_M];
  scanf("%d %d", &N, &M);
  // printf("N = %d, M = %d\n", N, M);
  for (int i = 0; i < M; i++) {
    scanf("%d", &as[i]);
    // printf("i = %d, as[i] = %d\n", i, as[i]);
  }

  // create boolean array
  int bs[MAX_N + 1] = {};
  for (int i = 0; i < M; i++) {
    bs[as[i]] = 1;
  }

  // solve
  int dps[MAX_N + 1];
  dps[N] = 1;
  for (int i = N - 1; i >= 0; i--) {
    if (bs[i]) {
      dps[i] = 0;
    } else {
      dps[i] = (dps[i + 1] + (i + 2 <= N ? dps[i + 2] : 0)) % NUM_MOD;
    }
  }
  printf("%d\n", dps[0]);

  return 0;
}


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

int main(){
    long double a, b, x;
    cin >> a >> b >> x;
    long double y = x/(a*a);
    long double theta;
    long double ans;

    if(2 * x >= a*a*b){
        theta = atan((2*b - 2*y)/a);
        ans = theta * 180 /M_PI;
    }
    else{
        long double c = 2*a*y/b;
        theta = atan(b/c);
        ans = theta * 180 / M_PI;
    }
    printf("%.10Lf\n", ans);
    return 0;
}

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

int main()
{
	int N;
	cin >> N;
	int A[4];
	A[0] = N / 1000;
	N %= 1000;
	A[1] = N / 100;
	N %= 100;
	A[2] = N / 10;
	N %= 10;
	A[3] = N;

	queue<string> q;
	for (int i = 0; i < 1 << 3; ++i)
	{
		string ops;
		ops.resize(3);
		for (int j = 0; j < 3; ++j)
		{
			if ((i & (1 << j)) != 0)
			{
				ops[j] = '+';
			}
			else
			{
				ops[j] = '-';
			}
		}
		q.push(ops);
	}

	string result;
	do {
		string ops = q.front();
		q.pop();

		int r = A[0];
		for (int i = 0; i < 3; ++i)
		{
			if (ops[i] == '+')
			{
				r += A[i+1];
			}
			else
			{
				r -= A[i+1];
			}
		}

		if (r == 7)
		{
			result = ops;
		}
	} while (!q.empty());

	cout << A[0] << result[0] << A[1] << result[1] << A[2] << result[2] << A[3] << "=7" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		int[] a = new int[m];
		int[] b = new int[m];
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			a[i] = Integer.parseInt(sa[0]) - 1;
			b[i] = Integer.parseInt(sa[1]) - 1;
		}
		int q = Integer.parseInt(br.readLine());
		int[] c = new int[q + 1];
		int[][] dp = new int[11][n];
		for (int i = 1; i <= q; i++) {
			sa = br.readLine().split(" ");
			int v = Integer.parseInt(sa[0]) - 1;
			int d = Integer.parseInt(sa[1]);
			c[i] = Integer.parseInt(sa[2]);
			dp[d][v] = i;
		}
		br.close();

		for (int i = 10; i > 0; i--) {
			for (int j = 0; j < n; j++) {
				dp[i - 1][j] = Math.max(dp[i - 1][j], dp[i][j]);
			}
			for (int j = 0; j < m; j++) {
				dp[i - 1][b[j]] = Math.max(dp[i - 1][b[j]], dp[i][a[j]]);
				dp[i - 1][a[j]] = Math.max(dp[i - 1][a[j]], dp[i][b[j]]);
			}
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < n; i++) {
			pw.println(c[dp[0][i]]);
		}
		pw.flush();
	}
}


Measured memory_bytes: 64040
sx, sy, tx, ty = map(int, input().split(" "))
result = ""
# first s -> t
result += "U" * abs(ty - sy)
result += "R" * abs(tx - sx)
# first t -> s
result += "D" * abs(sy - ty)
result += "L" * abs(sx - tx)
# second s -> t
result += "L" + "U" * (1 + abs(ty - sy))
result += "R" * (1 + abs(tx - sx))
result += "D"
# second t -> s
result += "R" + "D" * (1 + abs(sy - ty))
result += "L" * (1 + abs(sx - tx))
result += "U"
print(result)

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        long A[] = new long[N];
        boolean zero = false;
        for(int i = 0; i < N; i++){
            A[i] = in.nextLong();
            if(A[i] == 0){
                zero = true;
            }
        }
        
        if(zero){
            println(0);
        }
        else{
            /*
                curr = prev * a[i]
                curr <= 1e18
                prev * a[i] <= 1e18
                a[i] <= 1e18/prev
            */

            long limit = (long) 1e18;
            long res = 1;
            for(long a: A){
                if(a <= limit/res){
                    res = res * a;
                }
                else{
                    res = -1;
                    break;
                }
            }

            println(res);
        }
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static int[] readInt(int N) throws IOException { 
    	int arr[] = new int[N];
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    	return arr;
    }
    
    static long[] readLong(int N) throws IOException { 
    	long arr[] = new long[N];
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    	return arr;
    }
    
    static String[] readString(int N) throws IOException { 
    	String arr[] = new String[N];
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    	return arr;
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i] + " "); 
    	} 
    	println(""); 
    }
    
    static void debug(Object ... O) { 
    	for(Object obj: O){
    		System.out.print(obj + " ");
    	}
    	System.out.println();
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

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

int main() {
  int n;
  cin >> n;
  int isYes = 0;
  for(int i = 1; i < 10; i++) {
      int tmp = n/i;
    if(n%i == 0 && tmp < 10 )  {
      isYes = 1;
      break;
    }
  }

  if(isYes) cout << "Yes" << endl;
  else cout << "No" << endl;


  return 0;
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if (a == b || b == c || a == c){
        if(a == b && b == c) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}

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

namespace ConsoleApp14
{
    class Class24
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var T = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int M = int.Parse(Console.ReadLine());
            int[] ans = new int[M];

            for(int i = 0; i < M; i++)
            {
                var read = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var test = new int[N];
                for (int j = 0; j < N; j++)
                    test[j] = T[j];

                test[read[0] - 1] = read[1];
                ans[i] = test.Sum();
            }
            foreach (int i in ans)
                Console.WriteLine(i);
        }
    }
}


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

int main() {
	int p1[2], p2[2], v[2];
	if(scanf("%d%d%d%d", &p1[0], &p1[1], &p2[0], &p2[1]) == 0) return 1;
	v[0] = -(p2[1] - p1[1]);
	v[1] = p2[0] - p1[0];
	printf("%d %d %d %d", p2[0] + v[0], p2[1] + v[1], p1[0] + v[0], p1[1] + v[1]);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
  
  	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int f[] = new int[N];
		int h[] = new int[N];

		for(int i=0;i<N;i++){
			f[i] = Integer.MAX_VALUE;
		}
		
		h[0] = sc.nextInt();
		f[0] = 0;
		

		for(int i=2;i<=N;i++){
			h[i-1] = sc.nextInt();
			
			for(int j=1;j<=K;j++){
				
				if(j > i-1){
					break;
				}
				int f_ik =Math.abs(h[i-1]-h[i-1-j]) + f[i-1-j];
				f[i-1] = Math.min(f[i-1],f_ik);
			}
			

			//f[i-1] = flog2(i-1,K,h,f);
		}

		System.out.println(f[N-1]);
	}
}

Measured memory_bytes: 50668
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

class UnionFind {
public:
    
    vl parent;  // 親ノード
    vl Siz;  // 集合の大きさ

    // コンストラクタ
    UnionFind(ll n): parent(n), Siz(n, 1) {
        rep(i, n) {
            parent[i] = i;
        }
    }

    // n要素で初期化
    void init(ll n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    ll root(ll x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if(x == y) {
            return;
        }
        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }
        Siz[x] += Siz[y];
        parent[y] = x;
    }
    
    // xとyが同じ集合に属するかどうか
    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    ll size(ll x) {
        return Siz[root(x)];
    }
    
};

int main() {
    ll n, K, L;
    cin >> n >> K >> L;

    UnionFind Uni1(n);  // 道路用
    Uni1.init(n);
    rep(i, K) {
        ll p, q;
        cin >> p >> q;
        p--;  q--;
        Uni1.unite(p, q);
    }

    UnionFind Uni2(n);  // 鉄道用
    Uni2.init(n);
    rep(i, L) {
        ll r, s;
        cin >> r >> s;
        r--;  s--;
        Uni2.unite(r, s);
    }

    map<P, ll> mp;
    rep(i, n) {
        mp[make_pair(Uni1.root(i), Uni2.root(i))]++;
    }

    rep(i, n) {
        cout << mp[make_pair(Uni1.root(i), Uni2.root(i))] << " ";
    }

    re0;
}

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

int a[222222], x[222222];
int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i], a[i] + i < n &&x[a[i] + i]++;
    long r = 0;
    for(int i = 0; i < n; i++)
        i > a[i] && (r += x[i - a[i]]);
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 5184
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 

int main() {
  string s;
  cin >> s;
  int N = s.size();
  for (int i = 0; i < N - 1; i++) {
    if (s.substr(i, 2) == "AC") {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forna(i,a,n) for(int i =a; i < n; i++)
#define fornd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push
#define fi first
#define se second
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
typedef long long int unsigned lliu;
typedef long long int lli;
typedef pair<lli,lli> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;

int main(){
    lli a, b, n;
    cin>>n>>a>>b;
    lli suma = a+b;
    lli enteros = n/suma;
    if(n%suma>a)
        cout<<(enteros+1)*a<<endl;
    else
        cout<<enteros*a+n%suma<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 2e5 + 555;
const int MOD = 1e9 + 7;
int n, k;
int chafeng[maxn];
void add(int l, int r) {
    l = max(1, l);
    r = min(n, r);
    chafeng[l]++;
    chafeng[r + 1]--;
}
bool solve(vector<int> &a) {
    for (int i = 1; i <= n + 1; i++)
        chafeng[i] = 0;
    for (int i = 1; i <= n; i++) {
        add(i - a[i], i + a[i]);
    }
    int now = 0;
    bool ok = true;
    for (int i = 1; i <= n; i++) {
        now += chafeng[i];
        a[i] = now;
        ok &= (a[i] == n);
    }
    return ok;
}
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    cout << fixed;
    cin >> n >> k;
    vector<int> V(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> V[i];
    for (int i = 1; i <= k; i++) {
        if (solve(V))
            break;
    }
    for (int i = 1; i <= n; i++)
        cout << V[i] << ' ';
    cout << endl;
    return 0;
}


Measured memory_bytes: 4784
#include<stdio.h>
#include<string.h>
#include <stdlib.h>

int main(){
    int N,SUM=0;
    char S[50];
    scanf("%d %s",&N,S);
    for (int i=0; i<N; i++) {
        if (S[i]=='A') {
            if (S[i+1]=='B' && S[i+2]=='C') {
                SUM++;
            }
        }
    }
    printf("%d\n",SUM);
    return 0;
}

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

int main() {
  int a,b,x;
  cin >> a >> b >> x;
  
  if(a>x) {
    cout << "NO" << endl;
  }
  else {
    if(a+b >= x) {
      cout <<  "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
}



    
  
  


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

int main() {
	string A, S, C;
	cin >> A >> S >> C;

	cout << A[0] << S[0] << C[0] << endl;
}

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

int a,b,c,tmp;
 
int main(){
	cin >> a>>b>>c;
  	tmp = a;
  	a = b;
  	b = tmp;
  	tmp = a;
  	a = c;
  	c = tmp;
	cout<<a<<" "<<b<<" "<<c;
  	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {

	int a, b;
	char op;

	while (1) {
		scanf("%d %c %d", &a, &op, &b);
		if (op == '?') break;

		switch (op) {
		case '+':
			printf("%d\n", a + b);
		}switch (op) {
		case '-':
			printf("%d\n", a - b);
		}switch (op) {
		case '*':
			printf("%d\n", a * b);
		}switch (op) {
		case '/':
			printf("%d\n", a / b);
		}

	}
	return 0;
}


Measured memory_bytes: 2144
def r(x):
  while u[x]>=0:x=u[x]
  return x
(n,m),_,*e=[map(int,t.split())for t in open(0).readlines()]
u=[-1]*n
a=[n*~-n//2]
for x,y in e[::-1]:
  t=a[-1]
  x,y=sorted((r(x-1),r(y-1)))
  if x!=y:
    t-=u[x]*u[y]
    u[x]+=u[y]
    u[y]=x
  a.append(t)
print(*a[::-1],sep='\n')

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

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if (a == b) {
		cout << c << endl;
	} else if (a == c) {
		cout << b << endl;
	} else if (b == c) {
		cout << a << endl;
	}
}


Measured memory_bytes: 256
N = int(input())
T = list(map(int,input().split()))

M = int(input())

for i in range(M):
    p,x = map(int,input().split())
    sum = 0
    for j in range(p - 1):
        sum = sum + T[j]
    sum = sum + x
    for j in range(p , N):
        sum = sum + T[j]
    print(sum)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#define LEN 100005
typedef struct pp{
  char name[100];
  int t;
}P;

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

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

P dequeue(){
  P x = Q[head];
  head=(head+1)%LEN;
  return x;
}
int min(int a,int b){
  if(a<b)return a;
  else return b;

} 
int main(){
  int elaps=0,c;
  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){
    u=dequeue();
    c=min(q,u.t);
    u.t -=c;
    elaps +=c;
    if(u.t>0)enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }

  return 0;
}

Measured memory_bytes: 10756
#include <stdio.h>

int main(void) {
	int N;
	long long int pow = 1, x = 1000000000 + 7;

	scanf("%d", &N);

	for (int i = 1; i <= N; i++) pow = (pow*i) % x;

	printf("%lld\n", pow);

	return 0;
}

Measured memory_bytes: 128
class SegmentTree:
    def __init__(self, size, f=lambda x,y : x+y, default=0):
        self.size = 2**(size-1).bit_length()
        self.default = default
        self.dat = [default]*(self.size*2)
        self.f = f

    def update(self, i, x):
        i += self.size
        self.dat[i] = x
        while i > 0:
            i >>= 1
            self.dat[i] = self.f(self.dat[i*2], self.dat[i*2+1])

    def query(self, l, r):
        l += self.size
        r += self.size
        lres, rres = self.default, self.default
        while l < r:
            if l & 1:
                lres = self.f(lres, self.dat[l])
                l += 1

            if r & 1:
                r -= 1
                rres = self.f(self.dat[r], rres)
            l >>= 1
            r >>= 1
        res = self.f(lres, rres)
        return res

def gcd(a, b):
    if a == 0:
        return b
    else:
        return gcd(b%a, a)

n = int(input())
a = list(map(int, input().split()))
s = SegmentTree(n, gcd)
for i in range(n):
    s.update(i,a[i])

ans = 1
for i in range(n):
    left = s.query(0,i)
    right = s.query(i+1,n)
    res = gcd(left, right)
    if ans < res:
        ans = res
print(ans)

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

class Program
{

    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var inputs = Console.ReadLine().Split(' ');
        var A = new long[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = long.Parse(inputs[i]);
        }

        var ans = 0L;
        for (int i = 0; i < N; i++)
        {
            ans = Gcd(ans, A[i]);
        }
        Console.WriteLine(ans);
    }

    /**
     * ユークリッド互除法(最大公約数)
     * <see cref="https://qiita.com/gushwell/items/e9614b4ac2bea3fc6486"/>
     */
    public static long Gcd(long a, long b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
}



Measured memory_bytes: 20960
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  ll ans = 0, x = 1, y = 1, z = 1;
  rep(i, N) {
    x = (x * 10) % MOD;
    y = (y * 9) % MOD;
    z = (z * 8) % MOD;
  }
  ans = (x - (y * 2 - z)) % MOD;
  if (ans < 0) ans += MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
n=int(input())
s=0
arr=[]
import math
def get_distance(x1, y1, x2, y2):
  d = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
  return d
for i in range(n):
  arr.append(input().split())
arr.append(arr[0])
for i in range(n):
  for j in range(i+1,n):
  	s+= get_distance(int(arr[i][0]),int(arr[i][1]),int(arr[j][0]),int(arr[j][1]))
print(2*s/n)

Measured memory_bytes: 3064
#include <bits/stdc++.h>	//Vacation
using namespace std;
const int N = 100010;
const int INF = 1e9 + 7;

int dp[4][N];
int ac[4][N];

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	memset(dp,0,sizeof(dp));

	int n;
	cin>>n;
	
	for(int i=1;i<=n;++i)
		for(int j=0;j<3;++j)
			cin>>ac[j][i];
	
	for(int i=1;i<=n;++i)	
	{
		for(int j=0;j<3;++j)
		{
			dp[j][i] = max(dp[(j+1)%3][i-1] , dp[(j+2)%3][i-1]) + ac[j][i];
		}
	}

	int ans = 0;
	for(int i=0;i<3;++i)
		ans = max(ans,dp[i][n]);
	cout<<ans<<"\n";
}

Measured memory_bytes: 6352
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;


int main(){
    int X,Y;

    cin >> X >> Y;
    for(int i = 0;i <= X;i++){
        if(i * 2 + (X - i) * 4 == Y){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


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

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

	int n, x = 0, count;
	cin >> n;
	count = n;
	char s[n+1], t[n+1];
	cin >> s >> t;
	s[n] = t[n] = '\0';
	for (int i = 0; i < n; i++)
	{	if (s[i] == t[x]) 
		{	x++;
		}
		
	}
	count += n-x;
	cout << count << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
char str[1100];
int main(){
	int a;scanf("%d",&a);
	while(a--){
		scanf("%s",str);
		int t=strlen(str)+1;
		for(int i=0;str[i];i++)t+=str[i]-'0';
		do{
			int p=0;
			for(int i=0;str[i];i++){
				p+=str[i]-'0';
			}
			sprintf(str,"%d",p);
		}while(str[1]);
		if(t%2==(str[0]-'0')%2)printf("Audrey wins.\n");
		else printf("Fabre wins.\n");
	}
}

Measured memory_bytes: 1044
n = int(input())
al = list(map(int, input().split()))
cnt = len(al)
tmp = al[cnt-1]

for i in range(cnt-1, 1, -1):
    if al[i-1] - tmp >= 2:
        print("No") 
        exit()
    elif al[i-1] - tmp == 1:
        tmp = al[i-1]-1
    else:
        tmp = al[i-1]
print("Yes")

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

signed main() {
  int N, K;
  cin >> N >> K;
  
  double ans = 0;
  
  int ten = 0;
  int sai = 1;
  double renzoku = 1;
  for( int i = 1; i <= N; i++ ){
    ten = i;
    sai = 1;
    while( ten < K ){ //何回サイコロを回せばK点以上になるか
      ten *= 2;
      sai++;
    }
    renzoku = 1.00000000000;
    for( int j = 0; j < sai; j++ ) renzoku /= 2;
    ans += 1.00000000000 / (double)N * renzoku;
  }
  
  cout << fixed << setprecision(10);
  cout << ans*2 << endl;
    
  
}



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

using namespace std;

const int maxN = 2e5;
int a[maxN];
int ans[maxN];
int n;

bool check() {

    for (int i = 0; i < n; i++) {
        if (ans[i] == 0) {
            if (ans[(i + 1) % n] != (a[i] ^ ans[(i - 1 + n) % n])) {
                return false;
            }
        } else {
            if (ans[(i + 1) % n] != ((1 - a[i]) ^ ans[(i - 1 + n) % n])) {
                return false;
            }
        }
    }
    return true;
}


bool go() {
    for (int i = 1; i < n - 1; i++) {
        if (ans[i] == 0) {
            ans[i + 1] = a[i] ^ ans[i - 1];
        } else {
            ans[i + 1] = (1 - a[i]) ^ ans[i - 1];
        }
    }

    return check();
}

void print() {
    for (int i = 0; i < n; ++i) {
        cout << (ans[i] == 0 ? 'S' : 'W');
    }
    cout << endl;
    exit(0);
}


int main(void) {

    cin >> n;
    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;
        a[i] = c == 'o' ? 0 : 1;
    }

    for (int i1 = 0; i1 < 2; i1++) {
        for (int i2 = 0; i2 < 2; i2++) {
            ans[0] = i1;
            ans[1] = i2;
            if (go()) print();
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 1152