akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
void N(int dice[]);
void E(int dice[]);
void S(int dice[]);
void W(int dice[]);
int main(void){
	int dice1[6];
	int n,a,b,i,j,ans;
	scanf("%d %d %d %d %d %d",&dice1[0],&dice1[1],&dice1[2],&dice1[3],&dice1[4],&dice1[5]);
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&a,&b);
		for(j=0;j<6;j++){
			if(a==dice1[j]){
				switch(j){
				case 0:
					break;
				case 1:
					N(dice1);
					break;
				case 2:
					W(dice1);
					break;
				case 3:
					E(dice1);
					break;
				case 4:
					S(dice1);
					break;
				case 5:
					N(dice1);
					N(dice1);
					break;
				}
				break;
			}
		}
		if(dice1[1]==b) ans=dice1[2];
		if(dice1[2]==b) ans=dice1[4];
		if(dice1[4]==b) ans=dice1[3];
		if(dice1[3]==b) ans=dice1[1];
		printf("%d\n",ans);
	}
	return 0;
}
void N(int dice[]){
	int tmp;
	tmp=dice[0];
	dice[0]=dice[1];
	dice[1]=dice[5];
	dice[5]=dice[4];
	dice[4]=tmp; 
}
void E(int dice[]){
	int tmp;
	tmp=dice[0];
	dice[0]=dice[3];
	dice[3]=dice[5];
	dice[5]=dice[2];
	dice[2]=tmp;
}
void S(int dice[]){
	int tmp;
	tmp=dice[0];
	dice[0]=dice[4];
	dice[4]=dice[5];
	dice[5]=dice[1];
	dice[1]=tmp;
}
void W(int dice[]){
	int tmp;
	tmp=dice[0];
	dice[0]=dice[2];
	dice[2]=dice[5];
	dice[5]=dice[3];
	dice[3]=tmp;
}

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

int main(void)
{
    queue<long> que;
    long N;
    cin >> N;
    long min = N;
    for (long i = 1; i <= sqrt(N); i++) {
        if (!(N % i)) {
            que.push(i + N / i - 2);
        }
    }
    while (!que.empty()) {
        if (min > que.front()) {
            min = que.front();
        }
        que.pop();
    }
    cout << min << endl;
}



Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
sumA = sum(A)

for i in range(N):
  num = min(A[i], B[i])
  A[i] -= num
  B[i] -= num
  
  if B[i]:
    num = min(A[i+1], B[i])
    A[i+1] -= num
    
print(sumA - sum(A))

Measured memory_bytes: 18468
#if defined(__GNUC__)
#include <bits/stdc++.h>
#define __int32 __int32_t
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(ALL(x), greater<decltype(x)::value_type>())
#define RSORT2(x, T) sort(ALL(x), greater<T>())
#define REVERSE(x) reverce(ALL(x))
#define ACM(x, y) accumulate(ALL(x), y)

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)
#define FCT(x) [](int a) -> int {int r = 1; REP(i, a){r *= i;} return r;}(x)

// デバッグ用
#define PUT_LIST(x, y) std::copy(ALL(x), ostream_iterator<decltype(x)::value_type>(cout, y))

const int kMod = 1e9 + 7;

itn main() {
	ios::sync_with_stdio(false);

	int n;

	cin >> n;

	cout << (n + 1) / 2;

	return 0;
}


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

int main(){
    long long h, n;
    cin >> h >> n;
    long long sum_A = 0;
    for (int i = 0; i < n; i++)
    {
        int a; cin >> a;
        sum_A += a;
    }
    if (sum_A >= h)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using P = pair<int,int>;
#define MOD 1000000007
#define INF 1000000
#define PI 3.14159265358979323846264338327950L
#define MAX_N 100010

/*
Union Find Tree

何回でもスワップできるので、
スワップできるのもの同士を同じグループにする
同じグループだったら好きなところに移動できるって証明できる・・・？？
直感的にはできるぽい
*/

int par[MAX_N];//親の番号
int rnk[MAX_N];//ランク

void init(int n)
{
  //根の定義・・・par[i]=iの時iを根という
  //最初全てが根
  for (int i=0;i<n;i++){
    par[i]=i;
    rnk[i]=0;
  }
}

//木の根を求める
int root(int x){
  if (par[x]==x){  //xが根の時
    return (x); 
  }else{
    par[x]=root(par[x]);//xを、xの親の根につなぎ直す
    return par[x]; //経路圧縮
  }
}

//x,yが同じ集合に属しているか、つまり同じ根に繋がっているか
bool same(int x,int y){
  return ( root(x)==root(y) );
}

//x,yの属する集合を合併する
bool merge(int x, int y) {
   x = root(x); y = root(y);
   if (x == y) return false;
   if (rnk[x] < rnk[y]) swap(x, y);
   if (rnk[x] == rnk[y]) rnk[x]++;
   //ランクがxの方が大きい時はrnk[x]に変わりがないが、同じ時は変わるので++が必要
   par[y] = x; //ランクが大きい方に小さい方を繋げる
   return true;
}

int main()
{
  int N,M;cin>>N>>M;
  vector<ll> p(N+1);
  for (int i=1;i<=N;i++)
    cin>>p[i];
  
  init(N);
  
  for (int i=1;i<=M;i++)
  {
    int x,y;cin>>x>>y;
    //p[x],p[y]はスワップできるので同じグループに
    merge(p[x],p[y]);
  }
  
  int count=0;
  for (int i=1;i<=N;i++)
  {
    //p[i],iが同じ木にいたら、p[i]はi番目に移動できる
    if (same(p[i],i)) count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 1792
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}
void M1(){
  cout << "-1\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  string t;
  cin >> t;
  for(auto&& e: t){
    if(e == '?'){
      e = 'D';
    }
  }
  print(t);
}


Measured memory_bytes: 3736
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,k,i;
    for(;cin>>n>>k,n;){
        vector<int>vec(n);
        for(i=0;i<n;i++)vec[i]=i+1;
        i=0;
        for(;vec.size()>1;vec.erase(vec.begin()+i))if(i+=(k-1)%vec.size(),i>=vec.size())i-=vec.size();
        cout<<vec[0]<<endl;
    }
}

Measured memory_bytes: 1216
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i,sum;
    char num[1001];
        
    for(;;){
        scanf("%s", &num);
        if(num[0] == '0') break;
            
        sum = 0;
        for(i=0;num[i]!='\0';i++)
            sum += num[i] - '0';
        printf("%d\n", sum);
    }
        
    return 0;
}



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

int n,memo[100005];
multiset<pair<int,long long>> edge[100005];

void dfs(int now)
{
	for (auto i = edge[now].begin(); i != edge[now].end(); ++i)
	{
		auto p=*i;
		if (memo[p.first]==-1)
		{
			memo[p.first]=memo[now];
			if (p.second%2LL==1)
			{
				++memo[p.first];
				memo[p.first]%=2;
			}
			dfs(p.first);
		}
	}
}

int main(int argc, char const *argv[])
{
	cin>>n;
	int u,v;
	long long w;
	for (int i = 0; i < n-1; ++i)
	{
		cin>>u>>v>>w;--u;--v;
		edge[u].insert(make_pair(v,w));
		edge[v].insert(make_pair(u,w));
	}
	for (int i = 0; i < n; ++i)
	{
		memo[i]=-1;
	}
	memo[0]=0;
	dfs(0);
	for (int i = 0; i < n; ++i)
	{
		cout<<memo[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 19456
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
gap = float("inf")
for i in range(n):
    if abs(t - h[i] * 0.006 - a) < gap:
        ans = i + 1
        gap = abs(t - h[i] * 0.006 - a)
print(ans)

Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
public class Main {
	static FastScanner stdIn=new FastScanner();
	public static void main(String[] args) {
		int N=stdIn.nextInt();
		int A[][]=new int[N][2];
		int max=0;
		for(int i=0;i<2;i++){
			for(int j=0;j<N;j++){
				if(i==0){
					if(j==0)
						A[j][i]=stdIn.nextInt();
					else
						A[j][i]=A[j-1][i]+stdIn.nextInt();
				}
				else
					A[j][i]=stdIn.nextInt();
			}
		}
		for(int i=N-2;i>=0;i--){
			A[i][1]+=A[i+1][1];
		}
		for(int i=0;i<N;i++){
			if(max<A[i][1]+A[i][0])
				max=A[i][1]+A[i][0];
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;
int p = 1e9 + 7;

int32_t main()
{	
	IOS;
	int n;
	cin>>n;
	int a[2*n+1];
	for(int i=1;i<=2*n;i++)
		cin>>a[i];
	sort(a+1,a+2*n+1);
	int ans=0;
	for(int i=1;i<=2*n;i+=2)
		ans+=a[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int bian(int x){
	if(x == 1) x  = 14;
	return x;
}

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	a = bian(a);
	b = bian(b);
	if(a == b) printf("Draw");
	if(a > b) printf("Alice");
	if(a < b) printf("Bob");
	return 0;
}

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

int main()
{
	vector<int> v;
	int q;
	cin >> q;

	for (int i = 0; i < q; i++) {
		int query;
		cin >> query;
		switch (query)
		{
		case 0:
			int x;
			cin >> x;
			v.push_back(x);
			break;
		case 1:
			int p;
			cin >> p;
			cout << v[p] << endl;
			break;
		case 2:
			v.pop_back();
			break;
		default:
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3928
#include<bits/stdc++.h>
	using namespace std;
	using ll=unsigned long long int;
	int const m=1000000007;
	int main(){

	int n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll s=0;
	for(int i=1;i<n;i++){
		if(a[i]<a[i-1]){
			s+=(a[i-1]-a[i]);
			a[i]=a[i-1];
		}
	}
	cout<<s;
	return 0;
	}


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


int main() {
  int N, M;
  cin >> N >> M;
  
  vector <ll> A(N), A_sort(N), A_operated(N);
  
  // A_sort, A 初期化
  rep(i,N){
    cin >> A.at(i);
    A_sort.at(i) = A.at(i);
  }
  
  sort(A_sort.begin(), A_sort.end());
  
  //A_operated 初期化
  rep(i,N){
    A_operated.at(i) = A_sort.at(i);
  }

  
  int B, C;  
  vector<pair<int, int>> CB_pair(M);
  rep(i,M){
    cin >> B >> C;
    CB_pair.at(i) = make_pair(C, B);
  }
    
  sort(CB_pair.begin(), CB_pair.end());
  
  int i_start = M-1;
  int number_of_C = CB_pair.at(M-1).second;
  //summary_tempに対して後ろから、B (枚数) を足し続ける。
  
  while(number_of_C < N && i_start > 0){
    number_of_C += CB_pair.at(i_start-1).second;
    i_start--;
  }
  
  vector <int> C_all(number_of_C);
  int k = 0;  
  REP(i, i_start, M){
     rep(j, CB_pair.at(i).second){
      C_all.at(k++) = CB_pair.at(i).first;
    }
  }
    
  int i = 0;
  while (i < min(N,number_of_C) && A_operated.at(i) < C_all.at(number_of_C-1-i)){
    A_operated.at(i) = C_all.at(number_of_C-1-i);
    i++;
  }
    
      
  ll answer1;
  
  rep(i,N){
    answer1 += A_operated.at(i);
  }
  
  cout << answer1 << endl;
    
}

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

int main(){
 //char a;
 string a;
 getline(cin,a);
 for(int i=0;i<a.size();i++){
	 //cin>>a;
	 //getline(cin,a);
	 if(a[i]>='a'&&a[i]<='z')cout<<(char)(a[i]-32);
	 else if(a[i]>='A'&&a[i]<='Z')cout<<(char)(a[i]+32);
	 else cout<<a[i];
	}
	cout<<endl;
 return 0;
 }



Measured memory_bytes: 3096
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n; cin>>n;
  vector<int> h(n);
  rep(i,n) cin >>h[i];
  ll count =0;
  rep2(i,1,101){
    ll key=0;
    if(h[0]>=i)key++;
    rep(j,n-1){
       if((h[j]<i)&&(h[j+1]>=i)) key++;
     }
    count+=key;
  }
  cout <<count<<endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
n = I()
d = defaultdict(int)
a = LI()
for i in a:
    d[i] += 1
d = list(d.items())
d.sort(key = lambda x:-x[0])
l = 0
k = 0
for i,j in d:
    if j >= 2:
        if l == 0:
            l = i
        else:
            k = i
        if j >= 4:
            k = i
    if k != 0:break
print(l*k)
"""

#D
n = I()
s1 = S()
s2 = S()
ans = 0
i = 0
key = 1
d = defaultdict(int)
while i < n:
    if s1[i] == s2[i]:
        if not d[s1[i]]:
            d[s1[i]] = 1
            if i == 0:
                ans = 3
            else:
                if key:
                    ans *= 2
        key = 1
    else:
        if not d[s1[i]] and not d[s2[i]]:
            d[s1[i]] = 1
            d[s2[i]] = 1
            if i == 0:
                ans = 6
            else:
                if key:
                    ans *= 2
                else:
                    ans *= 3
        if not d[s1[i]]:
            d[s1[i]] = 1
            if not key:
                ans *= 2
        if not d[s2[i]]:
            d[s2[i]] = 1
            if not key:
                ans *= 2
        key = 0
        i += 1
    i += 1
    ans %= mod
print(ans)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38844
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
char s[N];
int n,a[N],b[N];
int solve(int mx)
{
    int add=0;
    for(int i=1;i<=n;i++)
        if(s[i]!='?') b[i]=s[i]=='1'?1:-1;
        else
        {
            if(a[i]+add+2<=mx)
                b[i]=1,add+=2;
            else b[i]=-1;
        }
    for(int i=1;i<=n;i++) b[i]+=b[i-1];
    int mn=0;mx=0;
    for(int i=1;i<=n;i++)
        mn=min(mn,b[i]),mx=max(mx,b[i]);
    return mx-mn;
}
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++) a[i]=a[i-1]+(s[i]=='1'?1:-1);
    for(int i=n-1;i>=1;i--) a[i]=max(a[i],a[i+1]);
    int ans=min(solve(a[1]),solve(a[1]+1));
    ans=min(ans,solve(a[1]+2));
    printf("%d\n",ans);
}


Measured memory_bytes: 12616
# Python3 code to Maximize volume of 
# cuboid with given sum of sides 

# Return the maximum volume. 
def maxvolume( s ): 

	# finding length 
	length = (s / 3) 
	
	s -= length 
	
	# finding breadth 
	breadth = s / 2
	
	# finding height 
	height = s - breadth 
	
	return (length * breadth * height) 
	
# Driven Program 
s = int(input())
print( maxvolume(s) ) 

# This code is contributed by "Sharad_Bhardwaj". 


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define forn(i, a, b) for (int i = a; i < b; ++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}

int main() {
#ifdef LOCAL
  freopen("i.txt", "r", stdin);
// freopen("main.txt", "w", stdout);
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
  ios::sync_with_stdio(0);
  cin.tie(0);
#define endl '\n'
#define dbg(...) 18
#endif
  ll a, b, c;
  cin >> a >> b >> c;
  for (int i = 0; i < 10; i++) {
    c = a * c - b;
    cout << c << endl;
  }
  return 0;
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<int> H(N);
    REP(i, N) cin >> H[i];

    int ans = 0;
    int tmp = 0;
    for (int i = 0; i < N-1; i++) {
        if (H[i] >= H[i+1]) {
            tmp++;
        } else {
            ans = max(ans, tmp);
            tmp = 0;
        }
    }
    ans = max(ans, tmp);
    print(ans);
}

signed main() {
    solve();
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

int main(){
    ll x;
    cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

typedef long long ll;
const ll InF = 1e15;

int main() {
  int n;
  cin>>n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin>>a[i];
    a[i] -= (i + 1);
  }
  sort(a.begin(),a.end());
  ll mid = a[(n - 1)/2];
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll res = abs(a[i] - mid);
    ans += res;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi = acos(-1.0);
#define memset(a,b) memset(a,b,sizeof(a))
const int mod = (1 ? 1000000007 : 998244353);
const int inf = (1 ? 0x3f3f3f3f : 0x7fffffff);
const int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
const ll INF = (1 ? 0x3f3f3f3f3f3f3f3f : 0x7fffffffffffffff);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll poww(ll a, ll b, ll mod) { ll s = 1; while (b) { if (b & 1)s = (s * a) % mod; a = (a * a) % mod; b >>= 1; }return s % mod; }


const int N = 1e5 + 10;
ll n, m;


void solve()
{
	cin >> n;
	cout << !n << endl;
	

}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	ll T = 1;
	//cin >> T;
	while (T--)solve();
	//while (cin >> n)solve();//HDU
	return 0;

}

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

int N;

int main() {
    cin >> N;

    for(int i = 1; i <= 9; i++) {
        for(int j = 1; j <= 9; j++) {
            if(i * j == N) {
                printf("Yes\n");
                return 0;
            }
        }
    }

    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
def prime_factorize(n):
    dic = {}
    while n % 2 == 0:
        if 2 in dic:
            dic[2] += 1
        else:
            dic[2] = 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            if f in dic:
                dic[f] += 1
            else:
                dic[f] = 1
            n //= f
        else:
            f += 2
    if n != 1:
        if n in dic:
            dic[n] += 1
        else:
            dic[n] = 1
    return dic

n = int(input())
dic = prime_factorize(n)
ans = 0
for value in dic.values():
    left = 1 # 可能
    right = value # 不可能
    while left + 1 < right:
        mid = (left+right)//2
        if mid * (mid+1) / 2 <= value:
            left = mid
        else:
            right = mid
    ans += left

print(ans)

Measured memory_bytes: 62984
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	s := getNextString(scanner)
	t := getNextString(scanner)

	var indexes [26][]int
	var ll [26]int

	for i := 0; i < 26; i++ {
		indexes[i] = make([]int, 0)
	}

	n := len(s)
	for i := 0; i < n; i++ {
		indexes[s[i]-'a'] = append(indexes[s[i]-'a'], i)
	}
	for i := 0; i < 26; i++ {
		ll[i] = len(indexes[i])
	}

	tn := len(t)
	now := 0
	var ans int64
	for i := 0; i < tn; i++ {
		ch := int(t[i] - 'a')
		l := 0
		r := ll[ch]
		if r == 0 {
			ans = -1
			break
		}
		for l < r {
			m := (l + r) >> 1
			if indexes[ch][m] < now {
				l = m + 1
				continue
			}
			r = m
		}
		if l == ll[ch] {
			ans += int64(n - now)
			now = 0
			i--
			continue
		}
		ans += int64(indexes[ch][l] - now + 1)
		now = indexes[ch][l] + 1
	}

	fmt.Fprintln(writer, ans)

	writer.Flush()
}


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

void fnInput(vector<int>& rvnSeq)
{
  int nSeqSiz;
  cin >> nSeqSiz;
  rvnSeq.resize(nSeqSiz);

  for (int& rnSeq : rvnSeq)
    cin >> rnSeq;
}
  
string fnDistinctChk(const vector<int>& cnrvnSeq)
{
  set<int> seDistinct;

  for (int nSeq : cnrvnSeq)
    seDistinct.insert(nSeq);

  if (cnrvnSeq.size() == seDistinct.size())
    return "YES";
  else
    return "NO"; 
}
  
int main()
{
  vector<int> vnSeq;

  fnInput(vnSeq);
  cout << fnDistinctChk(vnSeq) << endl;

  return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
template <typename T>
using V = std::vector<T>;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

const i64 INF = 1LL << 40;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  V<i64> A(N);
  i64 mina = INF, maxa = -INF;
  int mini = -1, maxi = -1;
  REP(i, N) {
    cin >> A[i];
    if (mina > A[i]) {
      mina = A[i];
      mini = i;
    }
    if (maxa < A[i]) {
      maxa = A[i];
      maxi = i;
    }
  }

  V<pair<int, int>> ans;
  if (maxa > -mina) {
    REP(i, N) {
      if (A[i] < 0) {
        ans.emplace_back(maxi, i);
        A[i] += maxa;
      }
    }
    for (int i = 1; i < N; ++i) {
      if (A[i] < A[i - 1]) {
        ans.emplace_back(maxi, i);
        A[i] += maxa;
        if (A[i] > maxa) {
          maxa = A[i];
          maxi = i;
        }
      }
    }

  } else {
    REP(i, N) {
      if (A[i] > 0) {
        ans.emplace_back(mini, i);
        A[i] += mina;
      }
    }
    for (int i = N - 2; i >= 0; --i) {
      if (A[i] > A[i + 1]) {
        ans.emplace_back(mini, i);
        A[i] += mina;
        if (A[i] < mina) {
          mina = A[i];
          mini = i;
        }
      }
    }
  }
  cout << ans.size() << endl;
  for (auto [x, y] : ans) {
    cout << x + 1 << ' ' << y + 1 << '\n';
  }
}


Measured memory_bytes: 3616
import java.lang.*;
import java.io.*;
import java.util.*;


public class Main {

	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {

	public void solve(InputReader in, PrintWriter out) {
		int a = in.nextInt(), b = in.nextInt(), h = in.nextInt();
		int ans = (a + b) * (h / 2);
		out.println(ans);
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;

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

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

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

Measured memory_bytes: 21588
#include <bits/stdc++.h>
typedef long long LL;
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define RALL(X) (X).rbegin(), (X).rend()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

using namespace std;

vector<VI> cs;
VI parite;

void dfs(int i){
    assert(parite[i]>=0);
    for (auto c:cs[i]){
        if (parite[c]==-1){
            parite[c]=parite[i]^1;
            dfs(c);
        }
    }
}

int main(){
    DRI(n);
    cs=vector<VI>(n,VI(0));
    parite=VI(n,-1);
    REP(i,n-1){
        DRII(x,y);
        x--; y--;
        cs[x].PB(y);
        cs[y].PB(x);
    }
    parite[0]=0;
    dfs(0);
    int nbi=0;
    REP(i,n){nbi+=parite[i];}
    int smaller=0;
    VI res(n,-1);
    if (nbi<n-nbi) smaller=1;
    int masize=(smaller)?(nbi):(n-nbi);
    int nb1=(n-1)/3+1;
    int nb3=(n)/3;
    int nb2=(n-2)/3+1;
    //cout<<masize<<" "<<smaller<<" "<<nb1<<" "<<nb2<<" "<<nb3<<endl;
    if (nb1<=masize){
        REP(i,n){
            if (parite[i]==smaller){
                if (nb1){
                    res[i]=3*(--nb1)+1;
                }
                else{
                    res[i]=3*(nb3--);
                }
            }
            else{
                if (nb2){
                    res[i]=3*(--nb2)+2;
                }
                else{
                    res[i]=3*(nb3--);
                }

            }
        }
    }
    else{
        REP(i,n){
            res[i]=(parite[i]==smaller)?(3*(nb3--)):-1;
        }
        REP(i,n){
            if (parite[i]!=smaller){
                if (nb1) {
                    res[i]=3*(--nb1)+1;}
                else{
                    if (nb2){
                        res[i]=3*(--nb2)+2;
                    }
                    else{
                        res[i]=3*(nb3--);
                    }
                }
            }
        }
    }

    REP(i,n){
        printf("%d%c",res[i],(i==n-1)?'\n':' ');
    }
    
}


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

#define FOR(i,a,b) for(i=a;i<=b;i++)
#define FOD(i,b,a) for(i=a;i>=b;i--)
#define pa pair<int,int>
#define fi first
#define se second
#define task "x"

typedef long long ll;
const ll M=1e6+1;
const ll N=1e4+1;
using namespace std;

ll i, j, n, ans = 0, a[N], e;
string s;

void input()
{
    cin >> n;
    FOR(i,1,n) cin >> a[i];

}

bool kt(ll i, ll j, ll k)
{
    if(a[i] + a[j] > a[k] && a[k] + a[j] > a[i] && a[i] + a[k] > a[j])
        return true;
    else return false;
}

void solve()
{
    FOR(i,1,n-2)
      FOR(j,i+1,n-1)
        FOR(e,j+1,n)
        {
            if(a[i]!=a[e] && a[e]!=a[j] && a[j]!=a[i])
                if(kt(i,j,e)) ans++;
        }

    cout<<ans;
}

int main()
{
  	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	if(fopen(task".inp","r"))
        {
 	  freopen(task".inp","r",stdin);
 	  freopen(task".out","w",stdout);
	}
	input();
	solve();


   return 0;
}



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

//int _; 

int n,m,a[100020],sum=0;
bool ans[100020];

int main()
{
	//for(scanf("%d",&_);_;_--)
	cin >> n >> m;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		ans[i]=true;
	}
	for(int i=0;i<m;i++)
	{
		int b,c;
		cin >> b >> c;
		b--;
		c--;
		if(a[b] >= a[c])
			ans[c]=false;
		if(a[c] >= a[b])
			ans[b]=false; 
	}
	for(int i=0;i<n;i++)
		if(ans[i])
			sum++;
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 4124
N,M=map(int,input().split())
H=list(map(int,input().split()))
connect=[[] for i in range(N)]

for i in range(M):
    A,B=map(int,input().split())
    connect[A-1].append(H[B-1])
    connect[B-1].append(H[A-1])

count=0
for i in range(N):
    if not connect[i]:
        count+=1
    elif H[i]>max(connect[i]):
        count+=1
# for i in range(N):
#     print(connect[i])
print(count)

Measured memory_bytes: 22912
def f(x,y):
    if x%y==0:
        return y
    x,y=y,x%y
    return f(x,y)

def main():
    K=int(input())
    sum=0
    for a in range(1,K+1):
        sum+=a
    for a in range(1,K):
        for b in range(a+1,K+1):
            sum+=6*f(a,b)
    for a in range(1,K-1):
        for b in range(a+1,K):
            for c in range(b+1,K+1):
                sum+=f(a,f(b,c))*6
    return sum

print(main())

Measured memory_bytes: 9220
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    ll ans = (x/11LL)*2;
    if((x%11)==0){

    }else if((x%11)<=6){
        ans += 1;
    }else{
        ans += 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3572
n,k=map(int,input().split())

aa=list(map(int,input().split()))

fumi = set([0])
start = None
end = None
aab = [0]
for i in range(10**18):
    next = aa[aab[-1]] - 1
    if next in fumi:
        if start is None:
            start = i
            fumi = set()
        else:
            end = i
            break

    aab.append(next)
    fumi.add(next)
    if i+1 == k:
        print(next+1)
        exit(0)

random_first = len(aab) - 2*(end - start)
#print(aab, start, end, aab[start+1:end+1], aab[:random_first])

first = aab[:random_first]
one_cicle = aab[start+1:end+1]
if k <= len(first):
    print(first[k]+1)
else:
    k = k-len(first)
    print(one_cicle[k%len(one_cicle)]+1)

Measured memory_bytes: 35468
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#define fo(i,j,k) for(int i=j;i<=k;++i)
#define fd(i,j,k) for(int i=j;i>=k;--i)
using namespace std;
const int N=1e5+10;
typedef pair<int,int> pr;
map<pr,int> mp;
multiset<int> b[N];
queue<pr> q;
typedef multiset<int>::iterator it;
int f[N];
int find(int x){
	return !f[x]?x:f[x]=find(f[x]);
}
void link(int x,int y){
	b[x].insert(y),b[y].insert(x);
}
pr mkpr(int x,int y){
	if(x>y) swap(x,y);
	return make_pair(x,y);
}
int main()
{
	int n;
	scanf("%d",&n);
	fo(i,1,n*2-2){
		int x,y;
		scanf("%d %d",&x,&y);
		link(x,y);
		pr t=mkpr(x,y);
		++mp[t];
		if(mp[t]==2) q.push(t);
		if(mp[t]>2) return printf("NO"),0;
	}
	fo(ch,2,n){
		if(q.empty()) return printf("NO"),0;
		int x=0,y=0;
		for(;x==y;x=find(q.front().first),y=find(q.front().second),q.pop());
		if(b[x].size()>b[y].size()) swap(x,y);
		f[x]=y;
		for(it i=b[x].begin();i!=b[x].end();i++){
			int v=find(*i);
			b[v].erase(b[v].find(x));
			if(v==y) continue;
			link(v,y);
			pr t=mkpr(v,y);
			++mp[t];
			if(mp[t]==2) q.push(t);
		}
		b[x].clear();
	}
	printf("YES");
}


Measured memory_bytes: 38912
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
   
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    string s;
    cin>>s;
    ll i,j,k,l,n=s.length();
    for(i=0;i<n;i++){
        if(s[i]=='?'){
            s[i]='D';
        }
    }
    cout<<s<<endl;
    return 0;   
}

Measured memory_bytes: 3752
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int k = saori.saori_hayami() - 1;
		String[] s = saori.nextHayami().split("");
		s[k] = s[k].toLowerCase();
		for(int i = 0;i < s.length;i++){
			System.out.print(s[i]);
		}
		System.out.println("");
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  vector<int>b(n);
  int d=0;
  for(int i=0;i<n;i++){
    cin>>b.at(i);
    d+=b.at(i);
  }
  vector<int>c(n-1);
  for(int k=0;k<n-1;k++){
    cin>>c.at(k);
  }
  for(int j=1;j<n;j++){
    if(a.at(j)==a.at(j-1)+1){
      d+=c.at(a.at(j-1)-1);
    }
  }
  cout<<d;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	while(cin>>n>>m,n){
		ll ans=0;
		vector<pll> v(n);
		rep(i,n) cin>>v[i].fs>>v[i].sc;
		sort(all(v),[](auto &a,auto&b){
			return a.sc>b.sc;
		});
		rep(i,n){
			ll sub=min(m,v[i].fs);
			m-=sub;v[i].fs-=sub;
			ans+=v[i].sc*v[i].fs;
		}
		cout<<ans<<"\n";
	}
}



Measured memory_bytes: 3356
#include <vector>
#include <queue>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
const int INF = 1 << 29;

// Dinic を信じろ

template <typename T>
struct Edge {
    int to; T cap, cost; int rev;
    Edge(int t, T c, int r) : to(t), cap(c), rev(r) {}
    Edge(int t, T ca, T co, int r) : to(t), cap(ca), cost(co), rev(r) {}
};

template <typename T>
using Graph = vector< vector< Edge<T> > >;

template<typename T>
struct Dinic {
    int N, M;
    Graph<T> G;
    vector<int> level, iter;
    Dinic(int n, int m) : N(n), M(m) {
        G.resize(N);
        level.resize(N);
        iter.resize(N);
    }
    void add_edge(int from, int to, T cost) {
        G[from].push_back(Edge<T>(to  , cost, G[to  ].size()    ));
        G[to  ].push_back(Edge<T>(from, cost , G[from].size() - 1));
    }
    void readGraph() {
        for(int i=0; i<M; i++) {
            int a, b; T c;
            cin >> a >> b >> c;
            // a--; b--;
            add_edge(a, b, c);
        }
    }
    void bfs(int s) {
        fill(level.begin(), level.end(), -1);
        queue<int> que; que.push(s);
        level[s] = 0;
        while(!que.empty()) {
            int temp = que.front(); que.pop();
            for(size_t i=0; i<G[temp].size(); i++) {
                Edge<T> &e = G[temp][i];
                if(e.cap > 0 && level[e.to] < 0) {
                    level[e.to] = level[temp] + 1;
                    que.push(e.to);
                }
            }
        }
    }
    T dfs(int v, int t, T f) {
        if(v == t) return f;
        for(int &i = iter[v]; i<(int)G[v].size(); i++) {
            Edge<T> &e = G[v][i];
            if(e.cap > 0 && level[v] < level[e.to]) {
                T d = dfs(e.to, t, min(f, e.cap));
                if(d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    T max_flow(int s, int t) {
        T flow = 0.0, f;
        while(1) {
            bfs(s);
            if(level[t] < 0) return flow;
            fill(iter.begin(), iter.end(), 0);
            while( (f = dfs(s, t, INF)) > 0 ) flow += f;
        }
    }
};

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

    Dinic<int> fl(N, M);
    map< pair<int, int>, int > edges;
    for(int i=0; i<M; i++) {
        int u, v; cin >> u >> v;
        u--; v--;

        edges[make_pair(u, v)] = i + 1;
        fl.add_edge(u, v, 1);
    }

    int S, T; cin >> S >> T;
    S--; T--;

    cout << fl.max_flow(S, T) << endl;
    vector<int> vertices;
    for(int i=0; i<N; i++) {
        for(auto e : fl.G[i]) {
            int u = i, v = e.to;

            if(edges.count(make_pair(v, u))) {
                if(e.cap == 0) vertices.push_back(edges[ make_pair(v, u) ]);
            }
        }
    }
    cout << vertices.size() << endl;
    sort(vertices.begin(), vertices.end());
    for(auto x : vertices) cout << x << endl;
    return 0;
}




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

long long int n;
int m;
int q;

#define MAX 1000002
int room[MAX][7];
int id[MAX][7];

bool flag[MAX];

struct UF{
	vector<int> belong;
	vector<int> size;
	void resize(int n){
		belong.assign(n + 1, -1);
		size.assign(n + 1, 1);
	}
	inline int root(int b){
		if (belong[b] == -1){
			return b;
		}
		belong[b] = root(belong[b]);
		return belong[b];
	}
	void merge(int a, int b){
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (a < b)swap(a, b);
		belong[a] = b;
		size[b] += size[a];
	}
};
UF uf;
int dx[] = { 0, 0, 1, -1 };
int dy[] = { 1, -1, 0, 0 };

vector<int> v;

void solve(int N){
	long long int sum = 0;
	if (n <= v.size()){
		for (int i = 0; i < n; i++){
			sum += v[i];
		}
		printf("%lld\n", sum);
		return;
	}
	long long int W = 0;
	for (int i = 1; i < v.size(); i++){
		W += v[i];
	}
	n--;
	W *= (n / N);
	n %= N;
	for (int i = 1; i <= n; i++){
		W += v[i];
	}
	W += v[0];
	printf("%lld\n", W);
}
int main(){
	cin >> n >> m >> q;
	for (int i = 0; i < q; i++){
		int a;
		scanf("%d", &a);
		flag[a] = true;
	}
	int num = -1;
	int nnn = -1;
	int N;
	bool exi = false;
	for (int i = 0; i < MAX; i++){
		for (int j = 0; j < 7; j++){
			num++;
			nnn++;
			id[i][j] = nnn;
			num %= m;
			if (i && (j == 0 && num == 0)){
				N = i;
				for (int j = 0; j < 7; j++){
					room[i][j] = room[0][j];
					id[i][j] = nnn;
					nnn++;
				}
				exi = true;
				break;
			}
			if (flag[num]){
				room[i][j] = true;
			}
		}
		if (exi)break;
	}
	if (0){

	}
	else{
		uf.resize(7 * (N+1));
		for (int i = 0; i <= N; i++){
			for (int j = 0; j < 7; j++){
				if (room[i][j] == true)continue;
				for (int k = 0; k < 4; k++){
					int ii = i + dx[k];
					int jj = j + dy[k];
					if (ii >= 0 && jj >= 0 && ii <= N&&jj < 7){
						if (room[i][j] == false && room[ii][jj] == false){
							uf.merge(id[i][j], id[ii][jj]);
						}
					}
				}
			}
		}
		for (int i = 0; i <= N; i++){
			int inc = 0;
			for (int j = 0; j < 7; j++){
				if (room[i][j] == false){
					if (uf.root(id[i][j]) == id[i][j]){
						inc++;
					}
				}
			}
			v.push_back(inc);
		}
		solve(N);
	}
	return 0;
}

Measured memory_bytes: 15740