akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define s second
#define f first
#define mk make_pair
using namespace std;
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int h,w,c,a[9][9];
int check(int a[9][9]){
	queue<pair<int,int> >q;
	int used[9][9]={},res=0;
	used[0][0]=1;
	q.push(mk(0,0));
	while(!q.empty()){
		pair<int,int>p=q.front();q.pop();
		res++;
		r(i,4){
			int x=dx[i]+p.s,y=dy[i]+p.f;
			if(x>=0&&y>=0&&x<w&&y<h)
				if(!used[y][x]&&a[y][x]==c){
					used[y][x]=1;
					q.push(mk(y,x));
				}
		}
	}
	return res;
}
int dfs(int d,int a[9][9]){
	int b[9][9],res=0;
	if(d==5){
		if(a[0][0]=c)return check(a);
		return 0;
	}
	for(int i=1;i<7;i++){
		r(k,h)r(j,w)b[k][j]=a[k][j];
		queue<pair<int,int> >q;
		int used[h][w]={};
		q.push(mk(0,0));
		used[0][0]=1;
		while(!q.empty()){
			pair<int,int>p=q.front();q.pop();
			b[p.f][p.s]=i;
			r(j,4){
				int x=dx[j]+p.s,y=dy[j]+p.f;
				if(x>=0&&x<w&&y>=0&&y<h)
					if(!used[y][x]&&b[y][x]==a[0][0]){
						used[y][x]=1;
						q.push(mk(y,x));
					}
			}
		}
		res=max(res,dfs(d+1,b));
	}
	return res;
}
int main(){
	while(cin>>h>>w>>c,c){
		int a[9][9];
		r(i,h)r(j,w)cin>>a[i][j];
		cout<<dfs(0,a)<<endl;
	}
}

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

using namespace std;

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

  for (int i = N; i <= 999; ++i) {
    if (i / 100 == i % 100 / 10 and i % 100 / 10 == i % 10) {
      cout << i;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s, t, ans;
    cin >> n >> s >> t;
    rep(i, 1, n) {
        ans += s[i - 1];
        ans += t[i - 1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


int main(){
    int N, C, K; cin >> N >> C >> K;
    VI T(N);
    REP(i, N) cin >> T[i];
    SORT(T);
    int prv(0), cnt(0), gnum(0);
    REP(i, N){
        if(T[i] > prv || gnum == C){
            ++cnt; prv = T[i] + K; gnum = 1;
        }else{
            ++gnum;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

  // 割り算なし
  vector<ll> v = divisor(n - 1);
  ll ans = v.size() - 1;

  // 割り算あり
  vector<ll> yakusu = divisor(n);
  REP(i, yakusu.size()) {
    if (yakusu[i] == 1) continue;
    ll k = yakusu[i];
    ll tmpn = n;
    while (true) {
      if (tmpn % k == 0) {
        tmpn /= k;
      } else {
        break;
      }
    }
    if (tmpn % k == 1) {
      ans++;
    }
  }

  ANS(ans);

  return 0;
}


Measured memory_bytes: 384
import sys



def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    ng = 0
    ok = 10 ** 9 + 1

    while ok - ng > 1:
        mid = (ok + ng) // 2
        ans=0
        for i in A:
            a,b =divmod(i,mid)
            ans +=a-1
            if b!=0:
                ans+=1
            if ans >K:
                break

        if ans <= K:
            ok = mid
        else:
            ng = mid

    print(ok)


if __name__ == "__main__":
    main()


Measured memory_bytes: 104608
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 1000005
#define M 200005
#define seed 23333
#define Mo 1000000007

using namespace std;
int i,j,m,n,p,k,fac[N],inv[N],ans,now;
int power(int x,int y)
{
		int sum=1;
		for (;y;y>>=1)
		{
				if (y&1) sum=1ll*sum*x%Mo;
				x=1ll*x*x%Mo;
		}
		return sum;
}
int C(int x,int y)
{
		return 1ll*fac[x]*inv[y]%Mo*inv[x-y]%Mo;
}
void jia(int &x,int y)
{
		x+=y; if (x>=Mo) x-=Mo;
}
void work(int len)
{
	if (len==0) now=1;
	else 
	if (len<=k)
		now=now*2%Mo;
	else if (len<=m)
		now=(now*2%Mo-C(len-1,len-k-1)+Mo)%Mo;
	else
	{
		now=(now*2%Mo-C(len-1,len-k-1)+Mo)%Mo;
		now=(now-C(len-1,m)+Mo)%Mo;
	}
}
int main()
{
		scanf("%d%d%d",&n,&m,&k); if (m<k) swap(m,k);
		fac[0]=1; for (i=1;i<N;++i) fac[i]=1ll*fac[i-1]*i%Mo;
		inv[N-1]=power(fac[N-1],Mo-2);
		for (i=N-2;i>=0;--i) inv[i]=1ll*inv[i+1]*(i+1)%Mo;
		for (i=n;i<=n+m+k;++i)
			work(i-n), 
			jia(ans,1ll*C(i-1,n-1)*power(3,n+m+k-i)%Mo*now%Mo);
		printf("%d\n",ans);
}


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

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

    int cost1 = 0;
    int cost2 = 0;
    for(int i=0; i<M; i++){
        if(A[i] < X){
            cost1 += 1;
        } else {
            cost2 += 1;
        }
    }

    int ans = (cost1 > cost2)? cost2 : cost1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3528
// https://atcoder.jp/contests/abc068/tasks/abc068_b

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int x = 1;
    while ((x << 1) <= n)
    {
        x <<= 1;
    }
    cout << x << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int N;

void dfs(string s, char mx) {
    if (s.size() == N) {
        cout << s << endl;
        return;
    }

    for (char c = 'a'; c <= mx + 1; c++) {
        string t = s + c;
        dfs(t, max(mx, c));
    }
}

int main() {
    cin >> N;
    dfs("", 'a' - 1);
}


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

using namespace std;

struct table{
    string city;
    int score;
    int num;
};

bool cmp(const table &a, const table &b)
{
    if(a.city == b.city) return a.score > b.score;
    else return a.city < b.city;
}


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

    vector<table> citytable(n);

    for(int i = 0; i<n ;i++){
        cin >> citytable[i].city >> citytable[i].score;
        citytable[i].num = i+1;
    }
    sort(citytable.begin(), citytable.end(),cmp);
    for(int i = 0; i<n ;i++)
        cout << citytable[i].num << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

template<class Func>
ll binarySearchR(long long l, long long r, Func f){
    long long m;
    while (r - l > 1) {
        m = (l + r) >> 1;
        (f(m) ? r: l) = m;
    }
    return r;
};

ll N, A, B, h[100001];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> A >> B;
    rep(i, N)cin >> h[i];

    auto f = [&](ll x) {
        ll y = 0;
        rep(i, N) {
            ll s = h[i] - y*B;
            if (s > x * A) {
                return false;
            } else if (s > x*B) {
                ll z = (s - x*B + A - B - 1) / (A - B);
                x -= z; y += z;
            }
        }
        return true;
    };
  
    ll ans = binarySearchR(0, ((ll)1e9 + B - 1) / B, f);
    cout << ans << endl;
}


Measured memory_bytes: 1024
require 'pp'
IS_DEBUG = true
# IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

require 'pp'

INT_MAX = 999999999999999999999999

S=gets.chomp.split('')
w,d=gets.chomp.split(' ').map{|n| n.to_i}

puts S.each_with_index.select{|s,i| i%w==0}.map{|s,i| s}.join("")


Measured memory_bytes: 2172
#!python3

# input
S = input()
X, Y = list(map(int, input().split()))


def judge(l, m):
    s = sum(l)
    t = s - m if m > 0 else s + m
    if t < 0 or t % 2 == 1:
        return False

    t //= 2
    n = len(l)
    w = [[False] * (t + 1) for _ in range(n + 1)]
    w[0][0] = True
    for i in range(1, n + 1):
        for j in range(t + 1):
            if w[i - 1][j]:
                w[i][j] = True
                if j + l[i - 1] <= t:
                    w[i][j + l[i - 1]] = True

    return w[-1][-1]                


def main():
    n = len(S)
    d = 0
    for s in S:
        if s == "F":
            d += 1
        else:
            break

    dx, dy = [], []
    side = True
    i = d
    while i < n:
        # change
        while i < n and S[i] == "T":
            side = not side
            i += 1
        
        # forward
        c = 0
        while i < n and S[i] == "F":
            c += 1
            i += 1
        if side:
            dx.append(c)
        else:
            dy.append(c)
    
    b1 = judge(dx, X - d)
    b2 = judge(dy, Y)
    ans = "Yes" if b1 and b2 else "No"
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 16628
import math
N, D = map(int, input().split())
Spot = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
for i in range(N):
    for j in range(i+1, N):
        distance = 0
        for k in range(D):
            distance += (Spot[i][k] - Spot[j][k])**2
        if math.sqrt(distance).is_integer():
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      char[] c = sc.next().toCharArray();
      int cnt = 0;
      for(int i = 0;i < c.length-1;i++){
      	if(c[i]!=c[i+1])cnt++;
      }
      System.out.println(cnt);
    }
}


Measured memory_bytes: 26924
n=int(input())
s=input()
k=int(input())
a=s[k-1]
for i in range(n-1):
    if s[i]!=a:
        print("*",end="")
    else:
        print(s[i],end="")
if s[n-1]!=a:
    print("*")
else:
    print(s[n-1])

Measured memory_bytes: 3060
def main():
  while True:
    n = int(input())
    if n == 0:break
    def spin(dice, direct):
      l, r, f, b, d, u = dice
      if direct == "R":
        return [d, u, f, b, r, l]
      if direct == "L":
        return [u, d, f, b, l, r]
      if direct == "B":
        return [l, r, d, u, b, f]
      if direct == "F":
        return [l, r, u, d, f, b]
    
    def move(x, y, direct):
      if direct == "R":
        return x + 1, y
      if direct == "L":
        return x - 1, y
      if direct == "B":
        return x, y + 1
      if direct == "F":
        return x, y - 1
    
    update_lst = []
    for _ in range(n):
      x, y = map(int, input().split())
      dice = list(map(int, input().split()))
      rot = input()
      update_point = {}
      update_point[(x, y)] = dice[-2]
      for direct in rot:
        dice = spin(dice, direct)
        x, y = move(x, y, direct)
        update_point[(x, y)] = dice[-2]
      update_lst.append(update_point)
    
    used_lst = [set() for _ in range(2 ** n)]
    mask = 1
    for i in range(n):
      keys = set(update_lst[i].keys())
      for j in range(2 ** n):
        if not (mask & j): continue
        used_lst[j] |= keys
      mask <<= 1
  
    add_score = {}
    mask = 1
    for i in range(n):
      update_point = update_lst[i]
      for j in range(2 ** n):
        if mask & j: continue
        used_point = used_lst[j]
        add = 0
        for k, v in update_point.items():
          if k not in used_point:
            add += v
        add_score[(j, mask)] = add
      mask <<= 1
    
    dic = {}
    end = 2 ** n - 1
    def max_score(stat):
      if stat in dic:return dic[stat]
      if stat == end:return 0
      
      ret = 0
      mask = 1
      for i in range(n):
        if stat & mask:
          mask <<= 1
          continue
        ret = max(ret, add_score[(stat, mask)] + max_score(stat | mask))
        mask <<= 1
      dic[stat] = ret
      return ret
    
    print(max_score(0))

main()


Measured memory_bytes: 257444
N,K = map(int,input().split())
S = list(input())

# nums[i]: iが偶数なら1の個数 奇数なら0の個数
nums = []

if S[0] == "0":
    nums.append(0)

# 尺取り法
left = 0
while left < N:
    right = left
    while right < N and S[right] == S[left]:
        right += 1
    nums.append(right - left)
    left = right

if S[-1] == "0":
    nums.append(0)

from itertools import accumulate

nums = [0] + list(accumulate(nums))

ans = 0
for left in range(0, len(nums), 2):
    right = min(len(nums) - 1, left + 2 * K + 1)
    ans = max(ans, nums[right] - nums[left])

print(ans)

Measured memory_bytes: 9384
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
struct node{
	int x;
	int y;
	int sum;
}no[maxn];
bool cmp(node a,node b)
{
	return a.sum>b.sum;
}
int main()
{
	int n;
	long long ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>no[i].x>>no[i].y;
		no[i].sum=no[i].x+no[i].y;
		ans-=no[i].y;
	} 
	sort(no,no+n,cmp);
	for(int i=0;i<n;i+=2)
		ans+=no[i].sum; 
	cout<<ans<<"\n";
	return 0;
} 

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int v[]={0,6000,4000,3000,2000};
  for(Int i=0;i<4;i++){
    Int t,x;
    cin>>t>>x;
    cout<<v[t]*x<<endl;
  }
  return 0;
}



Measured memory_bytes: 3108
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	K = int(input())

	div = [] #約数のリスト
	#場合分け
	if ((K ** 0.5) // 1) ** 2 == K:
		n = int((K ** 0.5) // 1)
		for i in range(1, n):
			if K % i == 0:
				div.append(i)
		d = len(div)
		for i in range(d):
			div.append(K // div[i])
		div.append(int((K ** 0.5) // 1))

	else:
		n = int((K ** 0.5) // 1)
		for i in range(1, n + 1):
			if K % i == 0:
				div.append(i)
		d = len(div)
		for i in range(d):
			div.append(K // div[i])

	# print(div)
	ans = 0
	for i in div:
		if i == 1:
			continue
		N = K
		while True:
			if N % i == 0:
				N = int(N // i)
			else:
				if N % i == 1:
					ans += 1
				break

	K = K - 1
	if ((K ** 0.5) // 1) ** 2 == K:
		n = int((K ** 0.5) // 1)
		for i in range(1, n):
			if K % i == 0:
				ans += 2
		ans += 1

	else:
		n = int((K ** 0.5) // 1)
		for i in range(1, n + 1):
			if K % i == 0:
				ans += 2

	print(ans - 1)



if __name__ == '__main__':
	main()

Measured memory_bytes: 39280
#include <bits/stdc++.h>
#define DEBUG

using namespace std;

const int N = 17;

int m, k;
vector<int> v, vk;

void dfs(int cur, int now)
{
    if (cur >= m) {
        v.push_back(now);
        return;
    }
    dfs(cur+1, now);
    if ((k&(1<<cur)) == 0) dfs(cur+1, now+(1<<cur));
}

void dfsk(int cur, int now)
{
    if (cur >= m) {
        vk.push_back(now);
        return;
    }
    dfsk(cur+1, now);
    if (k&(1<<cur)) dfsk(cur+1, now+(1<<cur));
}

int main()
{
    cin >> m >> k;
    if (k == 0) {
        for (int i = 0; i < (1<<m); ++i) {
            cout << i << " " << i << " ";
        }
        cout << endl;
        return 0;
    }
    if (k >= (1<<m) || (k == 1 && m == 1)) {
        cout << -1 << endl;
        return 0;
    }
    dfs(0, 0);
    dfsk(0, 0);
    sort(vk.begin(), vk.end());
    for (int i : vk) {
        if (k-i < i) break;
        for (int j : v)
            cout << i+j << " " << k-i+j << " ";
    }
    for (int i : vk) {
        if (k-i < i) break;
        for (int j : v)
            cout << k-i+j << " " << i+j << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2424
n,m=map(int,input().split())
a=list(map(int,input().split()))
x=[2,5,5,4,5,6,3,7,6]
dp=[0 for i in range(n+1)]
for i in range(1,n+1):
  l=[-99999999]
  for j in range(m):
    if i-x[a[j]-1]>=0:
      l.append(dp[i-x[a[j]-1]]+1)
  dp[i]=max(l)

a.sort()
a.reverse()
ans=[]
y=n
for i in range(dp[n],0,-1):
  for j in range(m):
    if y-x[a[j]-1]>=0:
      if dp[y-x[a[j]-1]]>=i-1:
        ans.append(str(a[j]))
        y-=x[a[j]-1]
        break
print(''.join(ans))

Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int a, ans, i;

    scanf("%d", &a);

    ans = 0;
    for (i = 0; i < 3; i++) {
        ans = (ans + 1) * a;
    }

    printf("%d\n", ans);
    
    return 0;
}

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

int main() {
	int N; cin >> N;
	vector<ll> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	for (int i = 0; i < N - 1; i++) a[i + 1] += a[i];

	ll ans = abs(a[N - 1] - 2 * a[0]);
	for (int i = 1; i < N - 1; i++) {
		ans = min(ans, abs(a[N - 1] - 2 * a[i]));
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
def main():
    BTC = 380000.0
    N = int(input())
    res = 0
    for _ in range(N):
        x, u = input().split()
        x = float(x)
        if u == 'JPY':
            res += x
        else:
            res += BTC * x
    print(res)
    

main()

Measured memory_bytes: 2940
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

const int N = 1e5 + 5;

vector <int> g[N];
int cnt[N];

void solve() {
  int n; cin >> n;
  int m; cin >> m;
  for(int i = 0; i < n; i++) {
    int x; cin >> x;
    g[x % m].push_back(x);
  }
  int ans = 0;
  for(int i = 0; i < m; i++) {
    sort(g[i].begin(), g[i].end());
    int pv = -1;
    for(auto x : g[i]) {
      if(pv == x) {
        cnt[i]++;
        pv = -1;
      } else pv = x;
    }
  }
  ans += (int)g[0].size() / 2;
  if(m % 2 == 0) ans += (int)g[m / 2].size() / 2;
  for(int p = 1, q = m - 1; p < q; p++, q--) {
    int cur = min(g[p].size(), g[q].size());
    ans += cur;
    ans += min(cnt[p], ((int)g[p].size() - cur) / 2);
    ans += min(cnt[q], ((int)g[q].size() - cur) / 2);
  }
  print(ans);
}

int main() {
  int t; t = 1;
  while(t--) solve();
}




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

#define int long long
#define double long double

const int INF=2147483647;
const int MOD=1000000007;
const int mod=998244353;
const double eps=1e-18;

using namespace std;

int n;
int a[200001],b[200001];
int ca[200001],cb[200001];
int l,r;

signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        ca[ a[i] ]++;
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
        cb[ b[i] ]++;
    }

    for(int i=1;i<=n;i++){
        if(ca[i]+cb[i]>n){
            cout<<"No"<<endl;
            return 0;
        }
    }

    reverse(b,b+n);

    l=INF;
    for(int i=0;i<n;i++){
        if(a[i]==b[i]){
            l=min(l,i);
            r=i;
        }
    }

    cout<<"Yes"<<endl;

    for(int i=l;i<=r;i++){
        int tmp=b[i];
        b[i]=b[ (i+(n/2))%n ];
        b[ (i+(n/2))%n ]=tmp;
    }

    for(int i=0;i<n;i++){
        cout<<b[i]<<" ";
    }

    return 0;
}


Measured memory_bytes: 9832
#include<stdio.h>
#define NUM 100
int main()
{
  int n,a,b,c,x;
  int i;
  int judge[NUM];
  int clear;
  while(1)
    {
      scanf("%d%d%d%d%d",&n,&a,&b,&c,&x);
      if((n==0)&&(a==0)&&(b==0)&&(c==0)&&(x==0)) break;
      for(i=0;i<n;i++) scanf("%d",&judge[i]);
      clear=0;
      for(i=0;i<=10000;i++)
	{
	  if(x==judge[clear]) clear++;
	  if(clear==n) break;
	  x=(a*x+b)%c;
	}
      if(i>10000) i=-1;
      printf("%d\n",i);
    }
  return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int n; cin >> n;
        vector<tuple<string, int, int>> a(n);
        for (int i = 0; i < n; i++) {
                cin >> get<0>(a[i]) >> get<1>(a[i]);
                get<2>(a[i]) = i + 1;
                get<1>(a[i]) = -get<1>(a[i]);
        }

        sort(all(a));
        for (int i = 0; i < n; i++) cout << get<2>(a[i]) << '\n';
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3624
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u64 = read();
    let mut vec: Vec<u64> = vec![];;
    for _ in 0..n {
        vec.push(read());
    }
    vec.reverse();
    let mut before = 0;
    for (i, v) in vec.into_iter().enumerate() {
        if i == 0 {
            before = v;
            continue;
        }
        if before >= v {
            before = v;
            continue;
        } else if before < v - 1 {
            println!("No");
            return;
        } else {
            before = v - 1;
        }
    }
    println!("Yes");
    return;
}


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



int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	LL x;
	cin>>x;
	
	for(LL i=-300;i<=300;i++) {
		for(LL j=-300;j<=300;j++) {
			if(pow(i,5)-pow(j, 5) == x){
				cout<<i<<" "<<j;
				return 0;	
			}
		}
	}
	
}

Measured memory_bytes: 4116
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int f1[10] = {};
  int f2[100] = {};
  int f3[1000] = {};
  REP(i, N) {
    int s = S[i] - '0';
    REP(j, 100) {
      f3[j*10+s] = f2[j];
    }
    REP(j, 10) {
      f2[j*10+s] = f1[j];
    }
    f1[s]  = true;
  }
  int r = 0;
  REP(i, 1000) {
    r += f3[i];
  }
  cout << r << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(void)
{
  string s,t;
  cin>>s>>t;
  int nt=0;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]!=t[i])
      nt++;
  }
  cout<<nt<<"\n";
  return 0;
}

Measured memory_bytes: 3896
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

a,b,c=map(int,input().split())

print(b+min(a+b+1,c))

Measured memory_bytes: 9744
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using namespace std;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int q;
    cin >> q;
    bool flag = true;

    string tmp1 = "", tmp2 = "";

    rep(i, q) {
        int t;
        cin >> t;
        if (t == 1) {
            flag = !flag;
        }
        else {
            int f;
            string c;
            cin >> f >> c;

            if (flag) {
                if (f == 1) tmp1 = c + tmp1;
                else tmp2 += c;
            }
            else {
                if (f == 1) tmp2 += c;
                else tmp1 = c + tmp1;
            }
        }
    }

    //cout << flag << endl;
    //cout << tmp2 << ", " << tmp1 << endl;
    if (!flag) {
        reverse(tmp1.begin(), tmp1.end());
        reverse(tmp2.begin(), tmp2.end());
        reverse(s.begin(), s.end());
        cout << tmp2 + s + tmp1 << endl;
    }
    else {
        cout << tmp1 + s + tmp2 << endl;
    }
}


Measured memory_bytes: 1592
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; 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 sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int x;
  cin >> x;
  if(x == 1) {
    cout << "Hello World" << endl;
  } else {
    int A,B;
    cin >> A >> B;
    cout << A+B << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int , int> pii;
typedef pair <ll , ll> pll;

#define print(a) {for(auto xxxxx : (a)) cout << xxxxx << ' '; cout << '\n';}
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin() , (a).end()
#define rall(a) (a).rbegin() , (a).rend()

ll next(){ll x; cin >> x;return x;}
const int maxn = 2e5 + 2 , intf = 2e9;
const ll inf = 2e18 , mod = 1e9 + 7;
const ld eps = 1e-9;


void solve(){
    string s; cin >> s;
    if (s[2] == s[3] && s[4] == s[5]){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20);
    
    for (int t = 1; t--;) solve();

	return 0;
}
/*


*/



Measured memory_bytes: 256
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define md 998244353
#define trace(...)
#define ll long long int
#define ld long double
#define fi first
#define se second
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,b,a) for(ll i=b;i>=a;i--)
#define mem(a) memset(a, 0, sizeof(a))
#define vpi std::vector<pair<int,int>>
#define pii pair<int,int>
#define pb push_back
#define sall(v) sort(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define minf -10000000
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
ll power(ll x, ll y,ll p) { 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {  
        if (y & 1) // If y is odd, multiply x with result
            res = (res*x) % p;  
        y = y>>1; // y = y/2 // y must be even now
        x = (x*x) % p;   
    } 
    return res; 
}
ll power(ll x, ll y) { 
    ll res = 1;      // Initialize result 
    while (y > 0) {    
        if (y & 1)// If y is odd, multiply x with result 
            res = (res*x) ;  
        y = y>>1; // y = y/2 // y must be even now 
        x = (x*x);   
    } 
    return res; 
}
 
ll max3(ll a,ll b,ll c){
    return max(a,max(b,c));
}
ll min3(ll a,ll b,ll c){
    return min(a,min(b,c));
}
bool isPrime(ll n) { // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}

void solve() {
    int n,l;
    cin>>n>>l;
    int arr[n+1];
    fr(i,1,n)arr[i]=l+i-1;
    int sum=0;
    fr(i,1,n)sum+=arr[i];
    int mx=infi;
    int idx;
    fr(i,1,n){
        if(abs(arr[i])<mx){
            mx=abs(arr[i]);
            idx=i;
        }
    }
    cout<<sum-arr[idx]<<endl;
    return ;
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stack>
int main()
{
	char*p,s[128],*q;
	while(q=fgets(s,128,stdin),*s-'.')
	{
		std::stack<int>c;
		for(p=s;*p;++p)
		{
			if(strchr("[(",*p))c.push(*p);
			if(strchr("])",*p))if(c.empty()||c.top()!=*p-(*p-')'?2:1))q=0;
			else c.pop();
		}
		if(!c.empty())q=0;
		puts(q?"yes":"no");
	}
	return 0;
}

Measured memory_bytes: 0
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();
		long count =0;
		long temp = N/K;
		count +=temp*(temp-1)*(temp-2)+temp+temp*(temp-1)*3;
		if (K%2==0) {
			temp = N/(K/2)-N/K;
			count +=temp*(temp-1)*(temp-2)+temp+temp*(temp-1)*3;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35688
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; i++)
static const long long INF = 1000000;
using p = pair<int,int>;
int main(){
    char s;
    cin >> s;
    char ans;
    ans = s + 1;
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    long long x, a, b;
    cin >> x >> a >> b;
    long long past = b - a;
    if(x < past){
        cout << "dangerous" << endl;
    }else if(past > 0 && x >= past){
        cout << "safe" << endl;
    }else if(past <= 0){
        cout << "delicious" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr,0,sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9+7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t  main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        cout << n / 2 + n % 2 << '\n';
    } 
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

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

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	
	int count = 0;
	int rank = 1;
	rep(i, n){
		if(s[i] == 'a'){
			if(count < a + b){
				cout << "Yes" << endl;
				count++;
			}
			else{
				cout << "No" << endl;
			}
		}
		else if(s[i] == 'b'){
			if(count < a + b && rank <= b){
				cout << "Yes" << endl;
				count++;
				rank++;
			}
			else{
				cout << "No" << endl;
			}
		}
		else{
			cout << "No" << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 896
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
bool grid[21][21];
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};

int main(void){
  int N,M;
  while(cin>>N){
    if(N==0) break;
    int px,py,l,r=-1;
    int x=10, y=10;
    char d;
    memset(grid,0,sizeof(grid));
    REP(i,N){
      cin>>px>>py;
      grid[py][px] = true;
    }
    grid[y][x] = false;
    cin>>M;
    REP(i,M){
      cin>>d>>l;
      if(d=='N') r = 0;
      else if(d=='E') r=1;
      else if(d=='S') r=2;
      else if(d=='W') r=3;
      else cout<<"ERROR"<<endl;
      REP(k,l){
        x+=dx[r];
        y+=dy[r];
        grid[y][x] = false;
      }
    }
    bool yes = true;
    REP(y,21)REP(x,21)if(grid[y][x]) yes=false;
    if(yes) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import sys

class Node:
    def __init__(self, node_num):
        self.node_num = node_num
        self.connect = []
    def add_node(self, node):
        self.connect.append(node)
    def delete_node(self, node):
        self.connect.remove(node)

def is_connect(node_list):
    check_list = [0]
    stack = [node_list[0]]
    while len(stack) != 0:
        if len(check_list) == N:
            return True
        current = stack.pop()
        for ii in current.connect:
            if ii not in check_list:
                check_list.append(ii)
                stack.append(node_list[ii])
    return (len(check_list) == N)
        
N, M = list(map(int, sys.stdin.readline().strip().split(" ")))
node_list = [Node(i) for i in range(N)]
edge_list = []

for i in range(M):
    n, m = list(map(int, sys.stdin.readline().strip().split(" ")))
    node_list[n - 1].add_node(m - 1)
    node_list[m - 1].add_node(n - 1)
    edge_list.append((n-1, m-1))
    
res = 0
prev_edge = None
for e in edge_list:
    if prev_edge is not None:
        node_list[prev_edge[0]].add_node(prev_edge[1])
        node_list[prev_edge[1]].add_node(prev_edge[0])
    prev_edge = e
    node_list[e[0]].delete_node(e[1])
    node_list[e[1]].delete_node(e[0])
    if not is_connect(node_list):
        res += 1

print(str(res))


Measured memory_bytes: 3064
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int K, N; scanf("%lld%lld", &K, &N);

    deque<int> deq;
    if(K % 2 == 0) {
        for(int i=0; i<N; i++) {
            if(i == 0) deq.push_back(K/2);
            else deq.push_back(K);
        }
    }
    else {
        int mid = (K+1)/2;
        for(int i=0; i<N; i++) deq.push_back(mid);

        for(int i=0; i<N/2; i++) {
            if(deq.back() == 1) deq.pop_back();
            else {
                int val = deq.back(); deq.pop_back();
                deq.push_back(val-1);

                while(deq.size() != N) deq.push_back(K);
            }
        }
    }

    for(size_t i=0; i<deq.size(); i++) {
        printf("%lld%c", deq[i], i+1==deq.size() ? '\n' : ' ');
    }
    return 0;
}

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

int main() {
  int x;
  cin >> x;
  int X=x;
  int y=0;
  while(x>0){
    y+=x%10;
    x/=10;
  }
  if(X%y==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

using namespace std;

int main(){
    int N;
    vector <int> C, S, F;
    int sub;
    
    C.push_back(0);
    S.push_back(0);
    F.push_back(0);
    
    cin >> N;
    for(int i = 1; i <= N - 1; i++){
        cin >> sub;
        C.push_back(sub);
        cin >> sub;
        S.push_back(sub);
        cin >> sub;
        F.push_back(sub);
    }

    vector <int> ans(N + 1, 0);
    for(int i = 1; i < N; i++){
        for(int j = i; j < N; j++){
            if(ans[i] < S[j]){
                ans[i] = S[j];
            }
            else if(ans[i] % F[j] == 0)     ;
            else{
                ans[i] = ans[i] + F[j] - ans[i] % F[j];
            }
            ans[i] += C[j];
        }
    }
    
    for(int i = 1; i <= N; i++){
        cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int x, cnt;
	
	cnt = 1;
	
	while (1) {
		scanf("%d", &x);
		if (x == 0) break;
		
		printf("Case %d: %d\n", cnt, x);

		cnt++;
	}
	
	return 0;
}

Measured memory_bytes: 600
N, M = map(int, input().split())
Bs = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(M)]

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

uf = UnionFindEx(N)

ans = [N*(N-1)//2]

for a, b in reversed(Bs):
    if uf.getRootID(a) == uf.getRootID(b):
        ans.append(ans[-1])
    else:
        ans.append(ans[-1] - uf.getGroupSize(a)*uf.getGroupSize(b))
    uf.connect(a, b)

print(*reversed(ans[:-1]), sep='\n')




Measured memory_bytes: 24080
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.append(0)
ans = 0
for i in range(n + 1):
    m = min(a[i], b[i - 1])
    a[i] -= m
    b[i - 1] -= m
    ans += m
    m = min(a[i], b[i])
    a[i] -= m
    b[i] -= m
    ans += m
print(ans)

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

using namespace std;

typedef long long ll;

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

	int a[3];
	cin >> a[0] >> a[1] >> a[2];

	sort(a, a+3);
	if(a[0] == 5 && a[1] == 5 && a[2] == 7){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 string S,T;
  cin>>S>>T;
  for(ll i=0;i<T.size();i++) {
cout<<S[i]<<T[i];
  }
  if(S.size()!=T.size()) {
cout<<S.back();
  }
  
  cout<<endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=25005,M=405;
const int mo=1000000007;
int n,k,m,a[N];
int pr,su,vis[M];
int f[N][M],g[M];
bool check1(){
	For(i,1,m-k+1){
		memset(vis,0,sizeof(vis));
		bool ok=1;
		For(j,i,i+k-1)
			if (vis[a[j]]) ok=0;
			else vis[a[j]]=1;
		if (ok) return 1;
	}
	return 0;
}
bool check2(){
	memset(vis,0,sizeof(vis));
	For(i,1,m)
		if (!vis[a[i]])
			vis[a[i]]=1,++pr;
		else break;
	memset(vis,0,sizeof(vis));
	Rep(i,m,1)
		if (!vis[a[i]])
			vis[a[i]]=1,++su;
		else break;
	return pr==m;
}
int power(int x,int y){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s;
}
namespace solver1{
	void solve(){
		int ans=1ll*(n-m+1)*power(k,n-m)%mo;
		printf("%d\n",ans);
		exit(0);
	}
}
void init(){
	f[1][1]=k;
	For(i,2,n){
		memset(g,0,sizeof(g));
		Rep(j,k-1,1) g[j]=(g[j+1]+f[i-1][j])%mo;
		For(j,1,k-1) f[i][j]=(g[j]+1ll*f[i-1][j-1]*(k-j+1))%mo;
	}
}
namespace solver2{
	int h[N][M];
	void solve(){
		int ans=1ll*(n-m+1)*power(k,n-m)%mo;
		int inv=1;
		For(i,1,m) inv=1ll*inv*(k-i+1)%mo;
		inv=power(inv,mo-2)%mo;
		h[1][1]=(m==1?1:0);
		For(i,2,n){
			memset(g,0,sizeof(g));
			Rep(j,k-1,1) g[j]=(g[j+1]+h[i-1][j])%mo;
			For(j,1,k-1) h[i][j]=(g[j]+1ll*h[i-1][j-1]*(k-j+1))%mo;
			For(j,m,k-1) h[i][j]=(h[i][j]+1ll*f[i][j]*inv)%mo;
		}
		For(j,1,k-1)
			ans=(ans+mo-h[n][j])%mo;
		printf("%d\n",ans);
		exit(0);
	}
}
namespace solver3{
	void solve(){
		int ans=1ll*(n-m+1)*power(k,n-m)%mo;
		int inv1=1,inv2=1;
		For(i,1,pr) inv1=1ll*inv1*(k+1-i)%mo;
		For(i,1,su) inv2=1ll*inv2*(k+1-i)%mo;
		inv1=power(inv1,mo-2);
		inv2=power(inv2,mo-2);
		//printf("%d %d\n",pr,su);
		//printf("%d\n",ans);
		For(i,0,n-m){
			int l1=i+pr,l2=n-i-m+su,s1=0,s2=0;
			For(j,pr,k-1) s1=(s1+f[l1][j])%mo;
			For(j,su,k-1) s2=(s2+f[l2][j])%mo;
			//printf("%d %d %d\n",i,s1,s2);
			s1=1ll*s1*inv1%mo;
			s2=1ll*s2*inv2%mo;
			//printf("%d %d %d\n",i,s1,s2);
			ans=(ans+mo-1ll*s1*s2%mo)%mo;
		}
		printf("%d\n",ans);
		exit(0);
	}
}
int main(){
	scanf("%d%d%d",&n,&k,&m);
	For(i,1,m) scanf("%d",&a[i]);
	if (check1()) solver1::solve();
	init();
	if (check2()) solver2::solve();
	solver3::solve();
}

Measured memory_bytes: 79360