akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

struct store
{
 ll a, b;
 bool operator<(const store rhs)
 {
   if(a < rhs.a)
   {
     return 1;
   }
   return 0;
 }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll ans = 0;
    ll n, m;
    cin >> n >> m;
    vector<store> s(n);
    for(int i = 0; i < n; i++)
    {
      cin >> s[i].a >> s[i].b;
    }
    sort(s.begin(), s.end());
    for(int i = 0; i < n; i++)
    {
      if(s[i].b < m)
      {
        ans += s[i].a * s[i].b;
        m -= s[i].b;
      }
      else
      {
        ans += s[i].a * m;
        cout << ans;
        break;
      }
    }

    return 0;
}


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

int main() {
  LL n, k;
  cin >> n >> k;
  vector<LL> a(n);
  vector<LL> b(n);
  pair<LL, LL> c[n];
  for (LL i = 0; i < n; i ++) {
    cin >> a.at(i) >> b.at(i);
    c[i] = make_pair(a.at(i), b.at(i));
  }

  sort(c, c + n);
  LL sum = 0;
  for (LL i = 0; i < n; i ++) {
    sum += c[i].second;
    if (sum >= k) {
      cout << c[i].first << endl;
      return 0;
    }
  }
}


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

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

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    if n < 30:
        s = ''
        for i in range(1, 100):
            if i % 15 == 0:
                s += 'FizzBuzz'
            elif i % 5 == 0:
                s += 'Buzz'
            elif i % 3 == 0:
                s += 'Fizz'
            else:
                s += str(i)
        # print(s)
        return s[n-1:n+19]
    i = 2
    n -= 4 * 4 + 5
    while 1:
        t = 10**i - (10**(i-1))
        s3 = t // 3
        s5 = t // 5
        s15 = t // 15
        sl = s3 + s5 - s15
        tl = (s3 + s5) * 4 + (t - sl) * i
        if tl >= n:
            break
        n -= tl
        i += 1

    si = 10**(i-1) - 1
    for j in range(i-1,0,-1):
        t = 10**j
        for k in range(1,10):
            s3 = (si+t) // 3 - si // 3
            s5 = (si+t) // 5 - si // 5
            s15 = (si+t) // 15 - si // 15
            sl = s3 + s5 - s15
            tl = (s3 + s5) * 4 + (t - sl) * i
            if tl >= n:
                break
            n -= tl
            si += t
    # print('si,n',si,n)
    s = ''
    for i in range(si+1,si+100):
        if i % 15 == 0:
            s += 'FizzBuzz'
        elif i % 5 == 0:
            s += 'Buzz'
        elif i % 3 == 0:
            s += 'Fizz'
        else:
            s += str(i)
    # print(s)

    return s[n-1:n+19]


print(main())



Measured memory_bytes: 9040
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
	int H, W; cin >> H >> W;
	vector<string> b(H);
	for (int i = 0; i < H; i++) cin >> b[i];
	vector<int> dx{ 1, 0, -1, 0 }, dy{ 0, 1, 0, -1 };
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (b[i][j] != '#') continue;
			bool flag = false;
			for (int t = 0; t < 4; t++) {
				if (!(0 <= i + dx[t] && i + dx[t] < H)) continue;
				if (!(0 <= j + dy[t] && j + dy[t] < W)) continue;
				flag |= b[i + dx[t]][j + dy[t]] == '#';
			}
			if (!flag) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC172
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = GetInt();

            Console.WriteLine(a + a * a + a * a * a);
        }

        public static int GetInt() => int.Parse(Console.ReadLine());
        public static int[] GetIntArray() => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static double[] GetDoubleArray() => Console.ReadLine().Split().Select(double.Parse).ToArray();
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static long[] GetLongArray() => Console.ReadLine().Split().Select(long.Parse).ToArray();

    }
}


Measured memory_bytes: 27476
#include <iostream>

using namespace std;

int main()
{
    int c[4][4] = {0};
    bool ansFlag = false;

    int a1, a2, a3, b1, b2, b3;

    for (int i = 1; i <= 3; i++) {
        for (int j = 1; j <= 3; j++) {
            cin >> c[i][j];
        }
    }

    for (int i = 0; i <= 100; i++) {
        // a1 = iで固定した場合のa2, a3, b1〜b3の関係は以下の通り
        a1 = i;
        b1 = c[1][1] - i;
        a2 = c[2][1] - c[1][1] + i;
        b2 = c[1][2] - i;
        a3 = c[3][1] - c[1][1] + i;
        b3 = c[1][3] - i;

        // 上記の関係式を満たすaijであってもcijの関係を満たさない場合がある
        // もし、満たすaijがあれば、答えは"Yes"となる
        if ((a1 + b1 == c[1][1]) && (a1 + b2 == c[1][2]) && (a1 + b3 == c[1][3]) 
             && (a2 + b1 == c[2][1]) && (a2 + b2 == c[2][2]) && (a2 + b3 == c[2][3])
             && (a3 + b1 == c[3][1]) && (a3 + b2 == c[3][2]) && (a3 + b3 == c[3][3])) {
            ansFlag = true;
            break;
        }
    }

    cout << (ansFlag ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
        int arr[1000],start=0,n;
        while(scanf("%d",&n)==1){

           if(n>0){
            arr[start]=n;
            start++;

           }
           else{
            start--;
            printf("%d\n",arr[start]);

           }



        }
        return 0;

}

Measured memory_bytes: 604
// Problem : E - This Message Will Self-Destruct in 5s
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
struct subeet_call_receive_kroo {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		int arr[n+1];
		for(int i=1;i<=n;++i)
		cin>>arr[i];
		unordered_map<int,int,subeet_call_receive_kroo > mpadd,mpsub;
		for(int i=1;i<=n;++i)
		{
			mpsub[i-arr[i]]++;
			mpadd[i+arr[i]]++;
		}
		int ans = 0;
		for(auto x:mpsub)
		{
			ans+= (mpsub[x.first]*mpadd[x.first]);
		}
		cout<<ans;    	
    }
    return 0;
}



Measured memory_bytes: 36588
#include<stdio.h>


int main(void){

  int y, m, d;
  int result;
  char w[7][10]={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};


  while(1){
    scanf("%d %d", &m, &d);
    if(m==0 && d==0) break;

    y=2004;
    if(m==1 || m==2){
      m+=12;
      y--;
    }
    result = y+(y/4);
    result -= (y/100);
    result += (y/400);
    result += ((m*13+8)/5);
    result += d;
    result %= 7;

    printf("%s\n", w[result]);
  }


  return(0);
}



Measured memory_bytes: 2056
#include<bits/stdc++.h>
#define inf 2147483647
#define llinf 9223372036854775807
#define ll long long
using namespace std;
const int maxn = 1e5 + 10;

char s[5];
int cnt = 0, vis[26];

int main()
{
    scanf("%s", s);
    for (int i = 0; i < 4; i++)
    {
        if (vis[s[i] - 'A'] != 0) continue;
        vis[s[i] - 'A'] = 1;
        cnt ++;
    }
    if (cnt == 2) return puts("Yes"), 0;
    puts("No");
    return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
import copy
def knapsack(N,W,weight,value):
  dp=[[999999999999 for i in range(W+1)] for j in range(N+1)]
  dp2=[[0 for i in range(W+1)] for j in range(N+1)]
  for i in range(W+1): dp[0][i]=0
 
  for i in range(N):
    for w in range(W+1):
      if weight[i]<=w:
        if dp[i][w-weight[i]]+value[i]>dp[i][w]:
          dp[i+1][w]=dp[i][w-weight[i]]+value[i]
          dp2[i+1][w]=w-weight[i]
        else:
          dp[i+1][w]=dp[i][w]
          dp2[i+1][w]=w
        
      else:
        dp[i+1][w]=dp[i][w]
        dp2[i+1][w]=w
  
  l=[]
  x=W
  for i in range(n-1,-1,-1):
    if dp2[i+1][x]==x-weight[i]:
      l.append(i)
    x=dp2[i+1][x]
  return dp[N][W],l
 
n,t=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
a=[];b=[]
for i in range(n):
  a.append(l[i][0])
  b.append(l[i][1])
z=knapsack(n,t-1,a,b)
L=[0]*n
for i in range(len(z[1])):
  L[z[1][i]]=1
M=[]
for i in range(n):
  if L[i]==0:
    M.append(l[i][1])
if len(M)==0:
  print(z[0])
else:
  print(z[0]+max(M))

Measured memory_bytes: 192392
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){

	char a[200] = {0};
	while(scanf("%s",a) != EOF){
	    char ans[10000] = {0};
	    int cnt = 0;
        for(int i = 0; i < strlen(a); i++){
            if(a[i] == '@'){
                fill(ans+cnt,ans+cnt+a[i+1]-'0',a[i+2]);
                cnt+=a[i+1]-'0';
                i += 2;
            }
            else{
                ans[cnt] = a[i];
                cnt++;
            }
        }
        cout << ans << endl;
        for(int i = 0; i < 200; i++) a[i] = 0;
	}

	return 0;
}

Measured memory_bytes: 1164
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}

	x := 1
	ct := 0
	for i := range as {
		if as[i] == x {
			x++
		} else {
			ct++
		}
	}
	if ct == n {
		fmt.Println(-1)
	} else {
		fmt.Println(ct)
	}
}


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

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

  if(s[1] == 'B'){
    cout << "ARC" << endl;
  }
  else{
    cout << "ABC" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin>>S;
  if(S=="SUN")
    cout<<7<<endl;
  else if(S=="MON")
   cout<<6<<endl;
  else if(S=="TUE")
   cout<<5<<endl;
  else if(S=="WED")
   cout<<4<<endl;
  else if(S=="THU")
   cout<<3<<endl;
  else if(S=="FRI")
   cout<<2<<endl;
  else if(S=="SAT")
   cout<<1<<endl;
}

Measured memory_bytes: 256
import heapq

n = int(input())
edges = [set((w, j) for j, w in enumerate(map(int, input().split())) if w > -1) for _ in range(n)]


def get_minimum():
    global n, edges
    visited = [False] * n
    visited[0] = True
    queue = list(edges[0])
    heapq.heapify(queue)
    total_cost = 0
    while queue:
        cost, vertex = heapq.heappop(queue)
        if visited[vertex]:
            continue
        visited[vertex] = True
        total_cost += cost
        if sum(visited) == n:
            return total_cost
        queue.extend(edges[vertex])
        heapq.heapify(queue)


print(get_minimum())

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


def ceil(x, y):
    if x % y == 0:
        return x // y
    else:
        return x // y + 1


x, y = 1, 1
for _ in range(N):
    T, A = map(int, input().split())
    p = max(ceil(x, T), ceil(y, A))
    x = T * p
    y = A * p
print(x + y)


Measured memory_bytes: 3060
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
    public void run() {
        double r=sc.nextDouble();
        ln(String.format("%.8f %8f",Math.PI*r*r, Math.PI*2*r));
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
    public static void ln() {
        System.out.println();
    }
}


Measured memory_bytes: 28272
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((int64_t *)a) < *((int64_t *)b) ? -1 : 1;
}

int compare_f2(const void *a, const void *b) {
	return *((uint64_t *)a) > *((uint64_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
	uint64_t result = 1;

	for (uint64_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	size_t N;

	scanf("%zu", &N);

	printf("%zu\n", N * (N + 1) / 2);

	return 0;
}


Measured memory_bytes: 128
function Main(input) {
  "use strict"
  const temp = input.split("\n")

	const n = parseInt(temp.shift());
  const bn = temp.shift().split(" ").map(e => parseInt(e));

  let an = [bn[0]];
  bn.forEach(x => {
    const last = an.pop()
    if(last > x){
      an.push(x);
      an.push(x);
    }else{
      an.push(last);
      an.push(x)
    }
  })
  let sumOfBn = an.reduce((acc, cur) => acc + cur);
  console.log(sumOfBn)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

const long long inf = 1LL<<60;

int main(){
    long long n;
    long long h[100010];
    long long dp[100010];

    cin >> n;
    for(int i=0;i<n;i++) cin >> h[i];

    for(int i=0;i<100010;i++) dp[i] = inf;

    dp[0] = 0;

    for(int i=1;i<n;i++){
        dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1) dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << endl;
}

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

int main() {

    int n, x, t; cin >> n >> x >> t;
    int ans;
    if (n % x == 0) ans = (n / x) * t;
    else ans = (n / x + 1) * t;    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
# coding: utf-8
# Your code here!

S = input()
Q = int(input())

mae = []
usiro = []
count = 0
for i in range(Q):
    query = input().rstrip().split()
    if len(query) == 3:
        if (count + int(query[1])) % 2 == 0:
            mae.append(query[2])
        else:
            usiro.append(query[2])
    else:
        count += 1
        
if count % 2 == 1:
    output = ''.join(mae[::-1]) + S[::-1] + ''.join(usiro)
else:
    output = ''.join(usiro[::-1]) + S + ''.join(mae)
print(output)
        

Measured memory_bytes: 70264
/*そーなのかー
　　　＿
　 '´　　 ヽ
 ./ ﾉﾉ））)）〉
〈《.! ﾟ ヮﾟﾉ》
　⊂!::V::!つ
　 く::::::::〉
　　 し'ﾉ*/
#include <bits/stdc++.h>
using namespace std;

int main() {
  string a,b;
  cin >> a >> b;
  cout << b << a << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<queue>

using namespace std;

typedef pair<int,int> pii;
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)

int main(){
	int n,m;
	char s[5],c;
	scanf("%d",&m);
	for(;;){
		scanf("%s",s);
		c=s[0];
		if(c=='=')break;
		scanf("%d",&n);
		if(c=='+')m+=n;
		else if(c=='-')m-=n;
		else if(c=='*')m*=n;
		else if(c=='/')m/=n;
	};
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
using namespace std;
int main()
{
int N,T;
cin >> N >> T;
int ct[N][2];
int i,p=1001;
for(i=0;i<N;i++) cin >> ct[i][0] >> ct[i][1];
for(i=0;i<N;i++)
{
if(ct[i][1]<=T)
{
  if(p>ct[i][0])
  {
  p=ct[i][0];
  }
}

}

if(p>1000)
{cout << "TLE" << endl;}
else
{
  cout << p << endl;
}
 
return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
arr = list(map(int, input().split()))
cnt = 0
# n = int(input())
# arr = [0 for _ in range(n)]
while True:
    cnt += 1
    new = [0 for _ in range(n)]
    for i in range(n):
        new[max(0, i-arr[i])] += 1

        tmp = i+arr[i]+1
        if tmp < n:
            new[tmp] -= 1

    flag = 1
    for i in range(1, n):
        new[i] += new[i-1]
        if new[i] < n:
            flag = 0

    arr = new
    # print(arr)
    if flag or cnt >= k:
        break
# print(cnt)
for i in arr:
    print(i, end=" ")

Measured memory_bytes: 169384
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i=j; i<k; i+=step)
#define loop(i, j, k) for (int i=j; i<k; i++) 
#define rloop1(i, j, k, step) for (int i=j; i>=k; i-=step)
#define rloop(i, j, k) for(int i=j; i>=k; i--)
#define rep(i, k) for(int i = (0); i < (k); i++ )
#define rrep(i, k) for(int i = k-1; i >= 0; i-- )

#define forall(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define endl "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;


void solve()
{
	int n,i,j,k=0,l,m,r;
	cin>>r;
	double cir;
	cir=2*3.14159265*r;
	cout<<cir<<endl;
}
int  main() 
{
	fast_io;
    int t=1;
    //cin>>t;
    while(t--)
    	solve();
	return 0; 
}

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

int main(){
  int w, h;
  std::cin >> h >> w;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      string s;
      std::cin >> s;
      if(s == "snuke"){
        std::cout <<  char('A' + j) << i + 1 << std::endl;
      }
    }
  }
  return 0;
}


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

int main(){
  long long a,b,n;
  cin >>a>>b>>n;
  if(b<n)cout<<(a*(b-1))/b;
  else if(b>n)cout <<(a*n)/b;
  else if(b==n)cout <<(a*(n-1))/b;
}

Measured memory_bytes: 3580
#include <iostream>

int main() {
	int N, T, A;
	std::cin >> N >> T >> A;
	double h = (T-A)/0.006;
	int ans;
	double min;
	for (int i = 0; i < N; ++i) {
		int H;
		std::cin >> H;
		min = i ? min > abs(H - h) ? ans = i, abs(H - h) : min : abs(H - h);
	}
	std::cout << ans + 1 << std::endl;
}

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

int main() {
    string A, B, C;
    cin >> A >> B >> C;
    if(A.at(A.size()-1) == B.at(0) && 
       B.at(B.size()-1) == C.at(0))
      cout << "YES" << endl; 
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
using System;

public class Hello{
    
    
    
    static int [] ans=new int [100];
    
    
    public static void aiueo(string str)
    {
        for(int i=0;i<str.Length;i++)
        {
            if((int)str[i]<=90&&(int)str[i]>=65)ans[(int)str[i]-65]++;
            else if((int)str[i]>=97&&(int)str[i]<=122) ans[(int)str[i]-97]++;
        }
    }
    
    
    public static void Main(){
        
        
        
        string str=Console.ReadLine();
        
        for(;str!=null;){
            aiueo(str);
            str=Console.ReadLine();
        }
        
        for(int i=97;i<123;i++){
            Console.WriteLine("{0} : {1}",(char)i,ans[i-97]);
        }
        
        
        
    }
}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

// bitmask DP
int dp[1 << 16];
int v[17][17];

int main() {
    for (;;) {
        int n; cin >> n; if (!n) break;
        rep(i, 1, n + 1) rep(j, 0, n + 1) cin >> v[i][j];
        dp[0] = 0;
        rep(i, 1, (1 << n)) dp[i] = 0x3f3f3f3f;
        rep(i, 0, n) rep(mask, 0, 1 << n) if (__builtin_popcount(mask) == i) {
            rep(j, 0, n) if (!(mask & (1 << j))) {
                int dv = v[j + 1][0];
                rep(k, 1, n + 1) if (mask & (1 << k - 1)) dv = min(dv, v[j + 1][k]);
                if (dp[mask] + dv < dp[mask | (1 << j)]) {
                    // cout << "Update " << bitset<7>(mask | (1 << j)) << " to " << dp[mask ]+ dv << endl;
                    dp[mask | (1 << j)] = min(dp[mask | (1 << j)], dp[mask] + dv);
                }
            }
        }
        cout << dp[(1 << n) - 1] << endl;
    }
}


Measured memory_bytes: 3348
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int n, x, y;
    cin >> n >> x >> y;
    cout << ((n+x-1)/x)*y << endl;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{

    	int N;
    	cin>>N;
    	std::set<std::string> str;
    	string str1;
    	for(int i=0;i<N;i++)
    	{
    		cin>>str1;
    		str.insert(str1);
		}
		cout<<str.size();
	}

Measured memory_bytes: 19228
pr = Array.new(10**6,1)
(2..1000).each{|i|
	next if pr[i] == 0
	j = i * i
	while j < 10**6
		pr[j] = 0
		j += i
	end
}
pr[0] = pr[1] = 0
(2..10**6).each{|i|
	pr[i] = pr[i].to_i + pr[i-1].to_i
}
while gets
	p pr[$_.to_i]
end

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

int main()
{
    char s[11], t[12];
    int count = 0;
    int a, i;
    scanf("%s", s);
    scanf("%s", t);
    
    a = strlen(s);
    
    for(i = 0; i < a; i++){
        if(s[i] == t[i]){
            count += 1;
        }
    }
    
    
    
    if(count == a)
        printf("Yes\n");
    else
        printf("No\n");
    
   
    return 0;
}

Measured memory_bytes: 1576
N = int(input())
S = input()

ans = 0
for i in range(1000):
    num = str(i).zfill(3)
    if S.find(num[0]) == -1:
        continue
    S1 = S[S.find(num[0]) + 1:]
    if S1.find(num[1]) == -1:
        continue
    S2 = S1[S1.find(num[1]) + 1:]
    if S2.find(num[2]) == -1:
        continue
    ans += 1

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
	int a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	ll ans = 0;
	if(2*c<a+b)
	{
		int foo = min(x,y);
		ans += foo*2*c;
		x-=foo;
		y-=foo;
	}
	if(2*c<a)
	{
		ans += 2*x*c;
		x=0;
	}

	if(2*c<b)
	{
		ans += 2*y*c;
		y=0;
	}
	ans += a*x;
	ans += b*y;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 a, b, c;
  cin >> a >> b >> c;
  if(a + b + c <= 21) {
    cout << "win" << endl;
  }
  else {
    cout << "bust" << endl;
  }
}


Measured memory_bytes: 256
import numpy as np


def main():
    int(input())
    a = np.array([int(i) for i in input().split()])
    m = a.max() + 1
    p = np.zeros(m, dtype=int)
    for i in range(2, m):
        if p[i] == 0:
            p[i::i] = i
    factors = set()
    for ai in a[a > 1]:
        f = set()
        while ai > p[ai]:
            f.add(p[ai])
            ai //= p[ai]
        f.add(ai)
        if factors & f:
            break
        factors |= f
    else:
        print("pairwise coprime")
        return
    if np.gcd.reduce(a) == 1:
        print("setwise coprime")
    else:
        print("not coprime")


if __name__ == '__main__':
    main()


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

using namespace std;

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

    int arr[n+1];
    int dp[n+1];

    arr[0]=0;
    dp[0]=0;

    for(int i=1;i<=n;i++)
        cin>>arr[i];

    dp[1]=0;

    for(int i=2;i<=n;i++){
        dp[i]=dp[i-1]+abs(arr[i]-arr[i-1]);

        if(i>2){
            dp[i]=min(dp[i],dp[i-2]+abs(arr[i]-arr[i-2]));
        }
    }

    cout<<dp[n]<<endl;


}


Measured memory_bytes: 1024
//
// Created by 肖龙 on 2020/2/20.
//


/*
 * 求点和直线的投影
 */
#include<iostream>
#include <cmath>
#include <iomanip>

using namespace std;

typedef struct point{
    double x,y;
}Point,Vector;

typedef struct line{
    Point x;
    Vector k;
}Line;

double dot(Vector x,Vector y){
    return x.x*y.x+x.y*y.y;
}

Vector getV(Point x,Point y){
    Vector v;
    v.x=y.x-x.x;
    v.y=y.y-x.y;
    return v;
}
//点在直线的投影
Point Projection(Line x,Point y){
    Point answ;
    answ = x.x;

    double len = dot(x.k,getV(x.x,y));
    len/=sqrt(x.k.x*x.k.x+x.k.y*x.k.y);
    Vector temp  = x.k;
    temp.x /=sqrt(x.k.x*x.k.x+x.k.y*x.k.y);
    temp.y/=sqrt(x.k.x*x.k.x+x.k.y*x.k.y);
    answ.x+=temp.x*len;
    answ.y+=temp.y*len;
    return answ;
}
//点与直线的对称点
Point Reflection(Line x,Point y){
    Point half = Projection(x,y);
    Point answ;
    answ.x=y.x+2*(half.x-y.x);
    answ.y=y.y+2*(half.y-y.y);
    return answ;
}

int main(){
    Point p1,p2,p;
    cin>>p1.x>>p1.y>>p2.x>>p2.y;
    int q;
    cin>>q;
    Vector v2;
    v2 = getV(p1,p2);
    Line l;
    l.k=v2;
    l.x=p1;
    for(int i=1;i<=q;i++){
        cin>>p.x>>p.y;
        Point answ = Reflection(l,p);
        cout<<setprecision(10)<<setiosflags(ios::fixed)<<answ.x<<" "<<answ.y<<endl;
    }
    return 0;
}


Measured memory_bytes: 3292
#include<stdio.h>

int main(void){
  int N,M;
  scanf("%d %d",&N,&M);
  int A[M];
  for(int i = 0;i < M;i++){
    scanf("%d",&A[i]);
  }

  int time = 0;
  for(int i = 0;i < M;i++){
    time += A[i];
  }

  int B = N - time;

  if(B < 0){
    printf("-1");
  }
  else{
    printf("%d",B);
  }

  return 0;
}


Measured memory_bytes: 1728
import java.util.*
fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val d = sc.nextInt()
    val e = sc.nextInt()
    var ok = true
    val A = a-a%10+ if (a%10 == 0) 0 else 10
    val B = b-b%10+ if (b%10 == 0) 0 else 10
    val C = c-c%10+ if (c%10 == 0) 0 else 10
    val D = d-d%10+ if (d%10 == 0) 0 else 10
    val E = e-e%10+ if (e%10 == 0) 0 else 10

   // println("$A $B $C $D $E")
    var ar = intArrayOf(a,b,c,d,e)
    val min = ar.minBy { (it-1)%10 }
    var t = min!!%10
    if (t == 0) t = 10
    //val (N,K) = readLine()!!.split(" ").map{it.toInt()}
    //for (i in  0 until N) {
    //}

        println(A+B+C+D+E+t-10)
}


Measured memory_bytes: 34124
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,c,b[105],a[105],call[105]={},cnt=0;
  cin>>n>>m>>c;
  for(int i=0; i<m; i++){
    cin>>b[i];
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      cin>>a[j];
      call[i]=call[i]+(b[j]*a[j]);
    }
    if((call[i]+c)>0){
      cnt++;
   }
 }
 cout<<cnt<<'\n';
 return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<stack>
#include<queue>
using namespace std;
int main()
{
	int sum, num;
	string N;		cin >> N;
	sum = 0; num = 0;
	for (long long i = 0; i < N.size(); i++) {
		num = N[i] - '0';
		sum += num;
	}
	if (sum % 9 == 0) {
		cout <<"Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

const int N=1e5+5;
int H[N];

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);
#endif
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)scanf("%d",H+i);
	for(int i=n;--i;)
	if(H[i]>H[i+1])
	if(--H[i]>H[i+1])
	{
		puts("No");
		exit(0);
	}
	puts("Yes");
}

Measured memory_bytes: 640
from itertools import product
from math import ceil
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(D)]

a = [True, False]
ss = product(a, repeat=D)

li = []
for i in ss:
  lii = []
  for itr, val in enumerate(i):
    if val:
      lii.append(itr)
  li.append(lii)

oneD = set([i for i in range(D)])
    
# print(li)

ans = 10**9
for i in li:
  psum = 0
  cnt = 0
  for j in i:
    psum += (j + 1) * pc[j][0] * 100 + pc[j][1]
    cnt += pc[j][0]
  if psum >= G:
    ans = min(ans, cnt)
  else:
    hoge = max(oneD - set(i))
    if pc[hoge][0] >= ceil((G - psum)/((hoge+1)*100)):
      cnt += ceil((G - psum)/((hoge+1)*100))
      ans = min(ans, cnt)
    
print(ans)

Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility>
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <fstream>
using namespace std;
#define pi acos(-1)
#define N 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))
int r[4010];
int g[4010];
int b[4010];
string s;
int l;
int jud(int a, int b)
{
    int q[4];
    q[0] = a;
    q[1] = b;
    sort(q,q+2);
    int x = q[0]-q[1]+q[0];
    int y = q[1]+q[1]-q[0];
    int z = (q[0]+q[1])/2;
    int cnt = 0;
    if(x>=0&&s[x]=='B') cnt++;
    if(y<l&&s[y]=='B') cnt++;
    if(z*2==x+y&&s[z]=='B') cnt++;
    return cnt;
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n;
    cin >> n;
    cin >> s;
    l = s.length();
    ll sum = 0;
    int k1 = 0;
    int k2 = 0;
    int k3 = 0;
    for(int i = 0; i < l; i++){
        if(s[i]=='R') r[k1++] = i;
        if(s[i]=='G') g[k2++] = i;
        if(s[i]=='B') b[k3++] = i;
    }
    for(int i = 0; i < k1; i++){
        for(int j = 0; j < k2; j++){
            sum += k3;
            if(jud(r[i],g[j])==1) sum--;
            if(jud(r[i],g[j])==2) sum -= 2;
            if(jud(r[i],g[j])==3) sum -= 3;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using Edge = pair<ll,ll>;
using Graph =vector<vector<int>>;
ll inf=1e18;

int main() {
  __int128 ans=1;
  int n;
  cin >>n;
  vector<ll> v(n);
  rep(i,n){
    ll a;
    cin >>a;
    v[i]=a;
  }
  sort(v.begin(),v.end());
  if(v[0]==0){
    cout<<0<<endl;
    return 0;
  }
  rep(i,n){
    ans*=v[i];
    if(inf<ans){
      cout<<-1<<endl;
      return 0;
    }
  }
  if(inf<ans)cout<<-1<<endl;
  else cout<<(ll)ans<<endl;
}


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

int main(){
	int n,m;
	int man[20];
	for(int i=0;i<20;i++){
		man[i] = 0;
	}
	cin >> m >> n;
	for(int j=0;j<m;j++){
		for(int i=0;i<n;i++){
			bool w;
			cin >> w;
			if(w==1)
				man[j]++;
		}
	}
	int max = 0;
	for(int i=0;i<m;i++){
		if(max < man[i])
			max = man[i];
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

Int A,B,C,D;
Int ans;

Int gcd(Int a,Int b) {
    return b == 0 ? a : gcd(b,a%b);
}
int main(void) {
    cin>>A>>B>>C>>D;

    ans = 0;
    A--;
    ans += ((B-(B/C))-(A-(A/C)));
    ans += ((B-(B/D))-(A-(A/D)));

    Int x = (C*D)/gcd(C,D);
    ans -= ((B-(B/x))-(A-(A/x)));
    
    cout<<ans<<endl;

    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    int a , b;cin >> a >> b;
    x -= a;
    x -= (x / b) * b;
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int H, W;
vector<string> S;

vector<vector<int>> L,R,U,D;

int search(int h, int w){

    // 左
    // 一つ左の要素が探索済みの場合
    if (w-1 >= 0 && L[h][w-1] > 0){
        L[h][w] = L[h][w-1] + 1;
    }
    else{
        int count = 0;
        for(int i = 1; i < W; i++){
            if (w-i >= 0 && S[h][w-i] == '.') count++;
            else break;
        }
        L[h][w] = count;
    }

    // 右
    // 一つ左の要素が探索済みの場合
    if (w-1 >= 0 && R[h][w-1] != -1){
        R[h][w] = R[h][w-1] - 1;
    }
    else{
        int count = 0;
        for(int i = 1; i < W; i++){
            if (w+i < W && S[h][w+i] == '.') count++;
            else break;
        }
        R[h][w] = count;
    }

    // 上
    // 一つ上の要素が探索済みの場合
    if (h-1 >= 0 && U[h-1][w] > 0){
        U[h][w] = U[h-1][w] + 1;
    }
    else{
        int count = 0;
        for (int i = 1; i < H; i++){
            if (h-i >= 0 && S[h-i][w] == '.') count++;
            else break;
        }
        U[h][w] = count;
    }

    // 下
    // 一つ上の要素が探索済みの場合
    if (h-1 >= 0 && D[h-1][w] != -1){
        D[h][w] = D[h-1][w] - 1;
    }
    else{
        int count = 0;
        for (int i = 1; i < H; i++){
            if (h+i < H && S[h+i][w] == '.') count++;
            else break;
        }
        D[h][w] = count;
    }

    //cout << h << " " << w << endl;
    //cout << L[h][w] << " " << R[h][w] << " " << U[h][w] << " " << D[h][w] << endl;

    return L[h][w] + R[h][w] + U[h][w] + D[h][w] + 1;
}


int main(){
    cin >> H >> W;
    S.assign(H,"");
    rep(i,H) cin >> S[i];

    L.assign(H, vector<int>(W, -1));
    R.assign(H, vector<int>(W, -1));
    U.assign(H, vector<int>(W, -1));
    D.assign(H, vector<int>(W, -1));
    int ans = 0;
    rep(i,H){
        rep(j,W){
            if (S[i][j] == '.') {
                ans = max(ans, search(i,j));
            }
        }
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 67200
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef pair<int,int> P;
typedef long long ll;

vector<int> d(int n){
	vector<int> x;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			x.push_back(i);
			if(i!=n/i) x.push_back(n/i);
		}
	}

	return x;
}

int main(void){

	int N;
	cin >> N;

	int i;
	for(i=1;;i++){
		int a=d(i).size();
		if(a==N){
			cout << i << endl;
			break;
		}
	}


	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
using namespace std;
typedef long long int ll;

int main(){
	int n; cin >> n;
	vector<ll> a(n),b(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	ll ans=0;
	while(1){
		bool ok=true;
		bool update=false;
		for(int i=0;i<n;i++){
			if(a[i]==b[i])continue;
			else{
				ok=false;
				if(i==0){
					if(b[n-1]+b[1]+a[0]<=b[0]){
						update=true;
						ll m=(b[0]-a[0])/(b[n-1]+b[1]);
						ans+=m;
						b[0]-=(b[n-1]+b[1])*m;
						//cout << i << " " << m << endl;
					}
				}
				else if(i==n-1){
					if(b[n-2]+b[0]+a[n-1]<=b[n-1]){
						update=true;
						ll m=(b[n-1]-a[n-1])/(b[n-2]+b[0]);
						ans+=m;
						b[n-1]-=(b[n-2]+b[0])*m;
						//cout << i << " " << m << endl;
					}
				}
				else{
					if(b[i-1]+b[i+1]+a[i]<=b[i]){
						update=true;
						ll m=(b[i]-a[i])/(b[i-1]+b[i+1]);
						ans+=m;
						b[i]-=(b[i-1]+b[i+1])*m;
						//cout << i << " " << m << endl;
					}
				}
			}
		}
		if(ok)break;
		if(update==false){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;
ll N, K;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
  int n,x,t;
  cin>>n>>x>>t;
  int ans=t*((n+x-1)/x);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 79712
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
vector<int> a;
int main(){
	cin >> N;
	a.resize(N);
	for(int i=0;i<N;i++){
		cin >> a[i];
		a[i]--;
	}
	int ans = 0, cnt= 0;
	for(int i=0;i<N;i++){
		if(a[i]==i){
			ans++;
			if(i<N-1)swap(a[i],a[i+1]);
		}
	}
	cout << ans << endl;
	return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


int w, h;
vector<vec> v;
void dfs(int y, int x){
	if(v[y][x] == 0) return;
	v[y][x] = 0;
	Rep1(i, -1, 1){
		Rep1(j, -1, 1){
			if(y+i < 0 || y+i >= w || x+j < 0 || x+j >= h) continue;
			dfs(y+i, x+j);
		}
	}
}

void solve() {
    while(1){
		cin >> h >> w;
		if(w == 0 & h == 0) break;
		vector<vec> tmp(w, vec(h));
		v = tmp;
		rep(i, w)rep(j, h) cin >> v[i][j];

		int res = 0;
		rep(i, w){
			rep(j, h){
				if(v[i][j]){
					dfs(i, j);
					res++;
				}
			}
		}
		cout << res << endl;
	}
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}



Measured memory_bytes: 7308
#include<stdio.h>
int main(void)
{
    long n,m,k,l;
    long a[200000];
    scanf("%ld",&n);
    for(m=0;m<n;m++)
    {
        scanf("%ld",&a[m]);
    }
    for(m=n-1;m>=0;m=m-2)
        printf("%ld ",a[m]);
    if(n%2==0)
        for(m=0;m<n;m=m+2)
            printf("%ld ",a[m]);
    else for(m=1;m<n;m=m+2)
            printf("%ld ",a[m]);
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL A[300100],S[300100];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&A[i]);
	if(n==2){
		cout<<abs(A[2]-A[1])<<endl;
		return 0;
	}
	for(int i=1;i<=n;i++)S[i]=S[i-1]+A[i];
	LL minm=1e15;
	for(int i=2;i<n;i++){
		if(abs(S[n]-S[i]-S[i])<minm)
			minm=abs(S[n]-S[i]-S[i]);
	}
	cout<<minm<<endl;
}



Measured memory_bytes: 3840