akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
int N,M;
double dp[16][1<<16],p[16][16];
int main(){
	cin>>N>>M;
	rep(i,N) rep(j,M) cin>>p[i][j];
	for(int j=M-1;j>=0;j--){
		for(int i=(1<<N)-1;i>=0;i--){
			double mx=0;
			rep(k,N) if(((i>>k)&1)==0){
				double e=0,pp=1;
				for(int h=j;h<M;h++){
					e+=pp*(1-p[k][h])*dp[h][i+(1<<k)];
					pp*=p[k][h];
				}
				e+=pp;
				mx=max(mx,e);
			}
			dp[j][i]=mx;
		}
	}
	printf("%.12f\n",dp[0][0]);
}

Measured memory_bytes: 9440
#include<bits/stdc++.h>
using namespace std;
string a;
int b;
int main()
{
cin>>a;
b=a.size();
if(a[0]==a[b-1])
{
if(b%2==0)
{
cout<<"First"<<endl;
return 0;
}
else
{
cout<<"Second"<<endl;
return 0;
}
}
else
{
if(b%2==0){
cout<<"Second"<<endl;
return 0;
}
else
{
cout<<"First"<<endl;
return 0;
}
}
}

Measured memory_bytes: 512
R,G,B,N=map(int,input().split())

ans=0
for r in range(3000+1):
    if N < r*R:
        break
    for g in range(3000+1):
        if N < r*R+g*G:
            break
        if (N-r*R-g*G)%B==0:
#            print('({0}-{1}*{2}-{3}*{4})%{5}'.format(N,r,R,g,G,B))
            ans+=1
print(ans)

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

A = list(map(int, input().split())) # N番目に食べた料理
B = list(map(int, input().split())) # N番目に食べた料理の満足度
C = list(map(int, input().split())) # N番目の直後にN+1番目を食べた時の追加の満足度

point = sum(B)

for i in range(1, len(A)):
    if A[i] - A[i-1] == 1:
        point += C[A[i-1]-1]

print(point)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
int read(){
	int l=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){l=(l<<1)+(l<<3)+(ch^'0');ch=getchar();}
	return f?l:-l;
}
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b&&b==c)puts("No");
	else if(a==b||b==c||a==c)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
n = int(input())
h = list(map(lambda x: int(x), input().split()))
count = 0
count_list = [0]
for i in range(n - 1) :
    if h[i] >= h[i+1] :
        count += 1
        count_list.append(count)
    else:
        count = 0

print(max(count_list))


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

import sys
import os

for s in sys.stdin:
    target = int(s)

    use = []
    W = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1]
    for w in W:
        if target >= w:
            target -= w
            use.append(w)

    print(*reversed(use))

Measured memory_bytes: 7476
#include<iostream>
using namespace std;
int main(int x, int y){
    while (true){
        cin >> x >> y;
        if(x == 0 && y == 0){
            break;
        }
        else if(x < y){
            cout << x << " " << y << endl;
        }
        else{
            cout << y << " " << x << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3068
import sys

MOD = 10 ** 9 + 7

def make_table(size=10**6, p=MOD):
    fac = [None] * (size + 1)
    fac[0] = 1
    for i in range(size):
        fac[i+1] = fac[i] * (i + 1) % p
    ifac = [None] * (size + 1)
    ifac[size] = pow(fac[size], p-2, p)
    for i in range(size, 0, -1):
        ifac[i-1] = ifac[i] * i % p
    return fac, ifac

fac, ifac = make_table()

def comb(n, r, mod=MOD):
    if r > n or r < 0:
        return 0
    return fac[n] * ifac[r] % mod * ifac[n-r] % mod

from collections import defaultdict
from math import floor, sqrt
def prime_factorize(n):
    res = defaultdict(int)
    while n % 2 == 0:
        res[2] += 1
        n //= 2
    if n == 1:
        return res
    for i in range(3, floor(sqrt(n))+1, 2):
        while n % i == 0:
            res[i] += 1
            n //= i
        if n == 1:
            return res
    res[n] += 1
    return res

n, m = map(int, sys.stdin.readline().split())

def main():
    pfacts = prime_factorize(m)
    res = 1
    for v in pfacts.values():
        res *= comb(n-1+v, v)
        res %= MOD
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

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

typedef long long lint;

const int inf = 1000;
int n, a[55], b[55];
lint x[55];
int m[55][55];

int dp(int x, int y) {
	if (x==y) return 0;
	if (x>y) return inf;
	if (m[x][y]) return m[x][y];
	m[x][y] = inf;
	for (int i=1; i<55; i++) if (dp(x, y%i) != inf) {
		return m[x][y] = i;
	} return m[x][y];
}

int main()
{
	cin >> n;
	for (int i=0; i<n; i++) cin >> a[i], x[i] |= (1ll << a[i]);
	for (int i=0; i<n; i++) cin >> b[i];

	lint ans = 0;
	while (true) {
		int mx = 0;
		for (int i=0; i<n; i++) {
			int mn = inf;
			for (int k=0; k<55; k++) if ((x[i] >> k) & 1ll) mn = min(mn, dp(b[i], k));
			mx = max(mx, mn);
		}
		if (mx == inf) {
			cout << "-1\n";
			return 0;
		}
		if (!mx) break;
		ans |= (1ll << mx);

		for (int i=0; i<n; i++) {
			for (int k=55; k>=mx; k--) if ((x[i] >> k) & 1ll) x[i] |= 1ll << (k%mx);
		}
	}

	cout << ans << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    // D - Knapsack 1
    public static long knapsack1(int[] weights, long[] values, int W) {
        // recursive with memo
        long[][] memo = new long[weights.length][W+1];
        return knapsack_recursive_memo(weights, values, W, 0, memo);
    }

    // recursive with memo
    public static long knapsack_recursive_memo(int[] weights, long[] values, int W, int index, long[][] memo) {
        if (W <= 0 || index >= weights.length) return 0;

        if (memo[index][W] != 0) return memo[index][W];

        long ret;
        if (W >= weights[index]) {
            long tmp1 = knapsack_recursive_memo(weights, values, W, index+1, memo);
            long tmp2 = knapsack_recursive_memo(weights, values, W-weights[index], index+1, memo) + values[index];
            ret = Math.max(tmp1, tmp2);
        } else {
            ret = knapsack_recursive_memo(weights, values, W, index+1, memo);
        }

        memo[index][W] = ret;
        return ret;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int W = in.nextInt();

        int[] weights = new int[N];
        long[] values = new long[N];
        for (int i = 0; i < N; i++) {
            weights[i] = in.nextInt();
            values[i]  = in.nextLong();
        }
        in.close();

        // call function hear
        long ret = knapsack1(weights, values, W);
        System.out.println(ret);
    }
}

Measured memory_bytes: 126932
#include <iostream>
#include <string>
using namespace std;
int main() {
    int a,b;
    cin >> a >> b;
  int x = a+b;
    if(x%2 == 0){
     cout << x/2 <<endl;
    }else{
     ++x;
     cout << x/2 <<endl;
    }
    
}

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

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

    string s; cin >> s;
    deque< char > pre, pos;
    int q; cin >> q;
    int r = 0;
    while(q--) {
        int t; cin >> t;
        if(t == 1) {
            r ^= 1;
        }
        else {
            int f; char c;
            cin >> f >> c;
            f--;
            f ^= r;
            if(f == 0) {
                pre.push_front(c);
            }
            else {
                pos.push_back(c);
            }
        }
    }
    if(r) {
        reverse(s.begin(), s.end());
        swap(pre, pos);
        reverse(pre.begin(), pre.end());
        reverse(pos.begin(), pos.end());
    }

    for(char c : pre) cout << c;
    cout << s;
    for(char c : pos) cout << c;
    cout << '\n';
    
    return 0;
}

Measured memory_bytes: 848
// https://atcoder.jp/contests/abc148/tasks/abc148_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    if (N % 2 == 0) {
        int sum = 0;
        N /= 10;
        while (N > 0) {
            sum += N;
            N /= 5;
        }
        cout << sum << endl;
    } else {
        cout << "0\n";
    }

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8


def euclid(n, m):

    def rec(n, m):
        if n % m == 0:
            return m
        
        return rec(m, n % m)
    
    return rec(n, m)


def main():
    K = int(input())

    ans = 0
    memo = {}
    for a in range(1, K+1):
        for b in range(a, K+1):
            for c in range(b, K+1):
                key_ab = f"{a}_{b}"
                if key_ab in memo:
                    euc_ab = memo[key_ab]
                else:
                    euc_ab = euclid(a, b)
                    memo[key_ab] = euc_ab
                
                x, y = sorted([euc_ab, c])

                key_xy = f"{x}_{y}"
                if key_xy in memo:
                    euc_xy = memo[key_xy]
                else:
                    euc_xy = euclid(x, y)
                    memo[key_xy] = euc_xy

                if a == b == c:
                    ans += euc_xy
                elif (a == b and b != c) or (b == c and c != a) or (c == a and a != b):
                    ans += euc_xy * 3
                else:
                    ans += euc_xy * 6

    return ans


print(main())


Measured memory_bytes: 10924
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int n,k;
    while(true){


        cin>>n>>k;
        if(n==0&&k==0)break;
        deque<pair<int,int>> q;
        for(int i=0;i<n;i++){
            q.push_back({i,0});
        }


        int cha=k;
        while(true){
            pair<int,int> pl;
            pl=q.front();
            q.pop_front();
            if(pl.second==k){
                if(q.front().first!=0){
                    cout<<q.front().first-1<<endl;
                }else{
                    cout<<n-1<<endl;
                }
                break;
            }
            if(cha==0){
                if(pl.second>0){
                    cha+=pl.second;
                    pl.second=0;
                    q.push_back(pl);
                }else{
                    q.push_back(pl);

                }
            }else{
                cha--;
                pl.second++;
                q.push_back(pl);
            }


        }



    }



    return 0;
}



Measured memory_bytes: 3020
#include <stdio.h>
#include <math.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];

int prim()
{
  int i, u, v, minv, sum;
  int d[MAX], p[MAX], color[MAX];

  for( i=0; i<n; i++ )
    {
      d[i] = INFINITY;
      p[i] = -1;
      color[i] = WHITE;
    }

  d[0] = 0;

  while(1)
    {
      minv = INFINITY;
      u = -1;
      for( i=0; i<n; i++ )
	{
	  if( minv > d[i] && color[i] != BLACK )
	    {
	      u = i;
	      minv = d[i];
	    }
	}
      if( u == -1 ) break;
      color[u] = BLACK;
      for( v=0; v<n; v++ )
	{
	  if( color[v] != BLACK && M[u][v] != INFINITY )
	    {
	      if( d[v] > M[u][v] )
		{
		  d[v] = M[u][v];
		  p[v] = u;
		  color[v] = GRAY;
		}
	    }
	}
    }

  sum = 0;
  for( i=0; i<n; i++ )
    {
      if( p[i] != -1 ) sum += M[i][p[i]];
    }

  return sum;
}


int main()
{
  int i, j, x;
  
  scanf("%d", &n);

  for( i=0; i<n; i++ )
    {
      for( j=0; j<n; j++ )
	{
	  scanf("%d", &x);
	  if( x == -1 )
	    {
	      M[i][j] = INFINITY;
	      continue;
	    }
	  M[i][j] = x;
	}
    }

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

  return 0;
}





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

bool submitted[31] = {false};

int main(){
    int n;
    for (int i = 1; i <= 28; i++){
	cin >> n;
	submitted[n] = true;
    }
    for (int i = 1; i <= 30; i++){
	if (!submitted[i]) cout << i << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T> inline T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

vector<bool> eratosthenes(int N)
{ 
    vector<bool> v(N + 1, true);
    v.at(1) = false;
    for (int i = 2; i * i < N + 1; i++)
    {
        if (v.at(i) == true)
        {
            for (int j = i * i; j < N + 1; j += i)//i^2からスタートしてよい
            {
                v.at(j) = false;
            }
        }
    }
    return v;
}

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll x;cin>>x;
  V<bool> v=eratosthenes(mpow(10,6));

  rep(i,x,INF){
    if(v[i]){
      cout<<i<<ENDL;
      return 0;
    }
  }
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  int result = 0;

  result += (min(N, 9) - 1) + 1;
  if (N > 99) {
    result += (min(N, 999) - 100) + 1;
    if (N > 9999) {
      result += (min(N, 99999) - 10000) + 1;
    }
  }
  cout << result;
}
#endif


Measured memory_bytes: 3652
import collections
import math


if __name__ == '__main__':
    N= int(input())
    a = list(map(int, input().split()))
    c = collections.Counter(a)
    result = 0
    for i in set(a):
        # c[i]の中から2個選ぶ
        result += (c[i]*(c[i]-1))/2

    for i in a:
        d = c[i]
        print(int(result - (d*(d-1))/2 + ((d-1)*(d-2))/2))

Measured memory_bytes: 26780
package main

import (
	"fmt"
	"sort"
)


func main() {
	var n int
	fmt.Scan(&n)
	pf := make([]int, 1010)
	mod := int(1e9 + 7)
	for i := 2; i <= n; i++ {
		primeFactor(i, pf)
	}
	ans := 1
	for j := 1; j < len(pf); j++ {
		if pf[j] >= 1 {
			ans = (ans * (pf[j] + 1)) % mod
		}
	}
	fmt.Println(ans)
}
func primeFactor(n int, pf []int) {
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			n /= i
			pf[i]++
		}
	}
	if n > 1 {
		pf[n]++
	}
}


	// 約数列挙
func enumDivisions(n int) []int {
	var res []int
	for i := 1; i * i <= n; i++ {
		if n % i == 0 {
			res = append(res, i)

			// 重複しないならばiの相方である n/i もappend
			if n/i != i {
				res = append(res, n/i)
			}
		}
	}
	// 小さい順に並び替える
	sort.Ints(res)
	return res
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#define N_MAX 101
using namespace std;

int N;
string word[N_MAX];
int length[N_MAX];

int main()
{
    cin >> N;

    for(int i = 0; i < N; i++)
        cin >> word[i];

    for(int i = 0; i < N - 1; i++)
        for(int j = i + 1; j < N; j++){
            if(word[i] == word[j]){
                cout << "No\n";
                    return 0;
            }
        }
    

    for(int i = 0; i < N - 1; i++){
        if(word[i].back() != word[i + 1].front()){
            cout << "No\n";
            return 0;
        }
    }
    
    cout << "Yes\n";

}


Measured memory_bytes: 256
import numpy

MOD = 10**9+7
N, K = [int(x) for x in input().split()]

cum = numpy.cumsum(range(N+1), dtype='int64')
count = 0

for i in range(K, N+1):
    min_num = cum[i-1]
    max_num = cum[-1] - cum[-i-1]

    count += (max_num - min_num + 1)
    count %= MOD

print(count + 1)


Measured memory_bytes: 36068
N,M=map(int,input().split())

ablist=[]
for i in range(N):
  a,b=map(int,input().split())
  ablist.append((a,b))
  
cdlist=[]
for i in range(M):
  c,d=map(int,input().split())
  cdlist.append((c,d))
  
for i in range(N):
  a,b=ablist[i]
  min_dist_arg=-1
  min_dist=float("inf")
  for j in range(M):
    c,d=cdlist[j]
    if min_dist>abs(a-c)+abs(b-d):
      min_dist_arg=j+1
      min_dist=abs(a-c)+abs(b-d)
  print(min_dist_arg)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
	int n,m,a,b,i;
	int ans[60];
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		ans[i]=0;
	}
	for(i=0;i<m;i++){
		scanf("%d%d",&a,&b);
		ans[a]++;
		ans[b]++;
	}
	for(i=1;i<=n;i++){
		printf("%d\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
	Scanner w = new Scanner ( System.in) ;
	String s = w.next();;
	String t = w.next();
	int a = w.nextInt();
	
	int b = w.nextInt();
	
	String u = w.next();
	
	
	if (u.equals(s) ) {
		a = a-1;
	}
	else if (u.equals(t) ) { 
		b = b-1;
	}
	System.out.print(a + " "+ b);
	}
}


Measured memory_bytes: 21972
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int ans = 0;
    rep(i, n) {
        if ( p[i] == i + 1 ) {
            if ( i == n - 1 ) {
                swap(p[i], p[i-1]);
                ++ans;
                if ( p[i-1] == i ) {
                    swap(p[i-1], p[i-2]);
                    ++ans;
                }
                break;
            }
            swap(p[i], p[i+1]);
            ++ans;
        }
    }
//    rep(i, n) cout << p[i] << " ";
//    cout << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
//https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_c
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};


int main(){
    LL K,A,B;
    cin>>K>>A>>B;
    LL ret=K+1;
    if(B-A>=2){
        LL cnt = 1;
        {
            LL k=min(A-1,K);
            K-=k;
            cnt+=k;
        }
        if(cnt>=A){
            cnt+=(B-A)*(K/2);
            K-=(K/2)*2;
        }
        cnt+=K;
        chmax(ret,cnt);
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define per(i,n) for ((i)=n;(i)>=(1);(i)--)
using namespace std;
int n,m,i,j,fa[100005],a[100005],b[100005],ta[100005],tb[100005],sa,sb,ans,vis[100005];
vector<int> all;
int fnd(int x){if(fa[x]==x) return x;return fa[x]=fnd(fa[x]);}
int main()
{
	cin>>n;rep(i,n+1) fa[i]=i;
	rep(i,n){cin>>a[i];ta[i]=a[i];sa^=a[i];}
	rep(i,n){cin>>b[i];tb[i]=b[i];sb^=b[i];}
	n++;a[n]=ta[n]=sa;b[n]=tb[n]=sb;
	sort(ta+1,ta+n+1);sort(tb+1,tb+n+1);
	rep(i,n)if(ta[i]!=tb[i]) break;
	if(i<=n){puts("-1");return 0;}
	rep(i,n)if(a[i]!=b[i]) break;
	if(i>n){puts("0");return 0;}
	rep(i,n) all.push_back(a[i]);sort(all.begin(),all.end());
	all.resize(unique(all.begin(),all.end())-all.begin());
	rep(i,n)
	{
		a[i]=upper_bound(all.begin(),all.end(),a[i])-all.begin();
		b[i]=upper_bound(all.begin(),all.end(),b[i])-all.begin();
		if(a[i]!=b[i])
		{
			if(i<n)ans++;
			fa[fnd(a[i])]=fnd(b[i]);
			vis[a[i]]=vis[b[i]]=1;
		}
	}
	vis[a[n]]=vis[b[n]]=1;
	rep(i,n) if(vis[i]&&fa[i]==i) ans++;
	cout<<ans-1<<endl;
	return 0;
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s,t; cin>>s>>t;
    int a,b; cin>>a>>b;
    string u; cin>>u;

    if(s==u) --a;
    else --b;
    cout << a << ' ' << b << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int m, n;
	int[] a, b;

	void run(){
		for(;;){
			m=sc.nextInt();
			n=sc.nextInt();
			if((m|n)==0){
				break;
			}
			a=new int[m];
			b=new int[n];
			for(int i=0; i<m; i++){
				a[i]=sc.nextInt();
			}
			for(int i=0; i<n; i++){
				b[i]=sc.nextInt();
			}
			solve();
		}
	}

	V[] vs;

	void solve(){
		vs=new V[n+m+2];
		for(int i=0; i<n+m+2; i++){
			vs[i]=new V();
		}

		int s=n+m, t=s+1;

		for(int i=0; i<m; i++){
			vs[s].add(vs[i], 1);
		}

		for(int i=0; i<n; i++){
			vs[m+i].add(vs[t], 1);
		}

		for(int j=0; j<n; j++){
			for(int i=0; i<m; i++){
				if(gcd(a[i], b[j])>1){
					vs[i].add(vs[m+j], 1);
				}
			}
		}
		println(maxFlow(vs[s], vs[t])+"");
	}

	int maxFlow(V s, V t){
		int flow=0;
		for(;;){
			for(V v : vs){
				v.used=false;
			}
			int f=dfs(s, t, INF);
			if(f==0){
				return flow;
			}
			flow+=f;
		}
	}

	int dfs(V v, V to, int f){
		if(v==to){
			return f;
		}
		v.used=true;
		for(E e : v.es){
			if(!e.to.used&&e.cap>0){
				int d=dfs(e.to, to, min(f, e.cap));
				if(d>0){
					e.cap-=d;
					e.rev.cap+=d;
					return d;
				}
			}
		}
		return 0;
	}

	class V{
		LinkedList<E> es=new LinkedList<E>();
		boolean used;

		void add(V to, int cap){
			E e=new E(to, cap), rev=new E(this, 0);
			e.rev=rev;
			rev.rev=e;
			es.add(e);
			to.es.add(rev);
		}
	}

	class E{
		V to;
		E rev;
		int cap;

		E(V to, int cap){
			this.to=to;
			this.cap=cap;
		}
	}

	int gcd(int m, int n){
		for(; n!=0;){
			int t=m%n;
			m=n;
			n=t;
		}
		return m;
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

const int N = 1e2 + 5;

#define st first
#define nd second
#define make(a,b) make_pair(a,b)

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

int ile[2];

long long newt[N][N];

void licz() {
	for (int i = 0; i < N; i ++) {
		newt[i][0] = 1;
	}
	for (int i = 1; i < N; i ++) {
		for (int k = 1; k <= i; k ++) {
			newt[i][k] = newt[i-1][k] + newt[i-1][k-1];
		}
	}
}

int main()
{
	int n, p;
	scanf("%d%d", &n, &p);
	for (int i = 0; i < n; i ++) {
		int a;
		scanf("%d", &a);
		ile[a % 2] ++;
	}
	p %= 2;
	licz();
	long long wynik = 0;
		for (int i = 0; i < 50; i ++) {
			wynik += pow(2, ile[0]) * newt[ile[1]][2 * i + p];
		}
	printf("%lld\n", wynik);
}


Measured memory_bytes: 1020
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n;
string str;

int main(){
	cin >> str;
	n = str.size();
	
	ll cntp = 0;
	ll cntg = 0;
	ll cntw = 0;
	for(ll i = 0; i <= n-1; i++){
		if(str[i] == 'p'){
			if(cntp+1 <= cntg){cntp++;}
			else{cntg++; cntw--;}
		}
		else{
			if(cntp+1 <= cntg){cntp++; cntw++;}
			else{cntg++;}
		}
	}
	
	cout << cntw << endl;
	return 0;
}

Measured memory_bytes: 512
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,m,k;
int main()
{
	get3(n,m,k);
	if(n%2==0||m%2==0||k%2==0)puts("0");
	else printendl(min(1ll*n*m,min(1ll*n*k,1ll*m*k)));
	return 0;
}

Measured memory_bytes: 256
import bisect
n,d,a = map(int,input().split())
lst = []
x = []
for i in range(n):
    xi,hi = map(int,input().split())
    lst.append([xi,hi,0])
    x.append(xi)
lst.sort()
x.sort()
count = 0
cur = 0
for i in range(n):
    if lst[i][1]-cur > 0:
        num = -(-(lst[i][1]-cur)//a)
        count += num
        damage = a * num
        cur += damage
        index = bisect.bisect(x,x[i]+2*d)
        if index != n:
            lst[index-1][2] += damage
    cur -= lst[i][2]
print(count)

Measured memory_bytes: 44884
#!/usr/bin/env python2
# coding: utf-8

def caesar(s, n):
    d = {}
    for c in (65, 97):
        for i in range(26):
            d[chr(i+c)] = chr((i+n) % 26 + c)

    return "".join([d.get(c, c) for c in s])


while True:
    try:
        encrypt_txt = raw_input()
    except EOFError:
        break

    for i in range(26):
        t = caesar(encrypt_txt, i)
        if  "the" in t or "this" in t or "that" in t:
            print t
            break

Measured memory_bytes: 6380
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >> getLine >>= print . maximum . scanl (+) 0 . map f

f 'I' = 1
f 'D' = -1

Measured memory_bytes: 508
#include<stdio.h>
using namespace std;
int main()
{
    int m,f,r;
    char grade;
    while(true)
    {
        scanf("%d %d %d",&m,&f,&r);
        if(m==-1&&f==-1&&r==-1)
            break;
        if(m==-1||f==-1)
        {
            grade='F';
        }
        else if(m+f>=80)
        {
            grade='A';
        }
        else if(m+f>=65)
        {
            grade='B';
        }
        else if(m+f>=50)
        {
            grade='C';
        }
        else if(m+f>=30)
        {
            grade=(r>=50)?'C':'D';
        }
        else
        {
            grade='F';
        }
        printf("%c\n",grade);
    }
}



Measured memory_bytes: 2692
n=int(input())
abc = [list(map(int, input().split())) for i in range(n)]
#[[10,40,70],[20,50,80],[30,60,90]]
ABC=[[0,0,0]]
#A = [0]
#B = [0]
#C = [0]
for i in range(n):
  a = abc[i][0] + max(ABC[-1][1], ABC[-1][2])#10+max(0,0),20+max(40,70)=90,30+max(120,120)=150
  b = abc[i][1] + max(ABC[-1][0], ABC[-1][2])#40+max(0,0),50+max(10,70)=120,60+max(90,120)=180
  c = abc[i][2] + max(ABC[-1][0], ABC[-1][1])#70+mac(0,0),80+max(10,40)=120,90+max(90,120)=210
  ABC += [[a,b,c]]
  #A += [a]#0,10,90,150
  #B += [b]#0,40,120,180
  #C += [c]#0,70,120,210
print(max(ABC[-1]))

Measured memory_bytes: 49988
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b;
    cin >> n>>a>>b;
    if(a>=b){
        cout << b << endl;
    }
    else{
        cout << a << endl;
    }

    if((a+b-n)<0){
        cout << 0 << endl;
    }
    else{
        cout << a+b-n<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int N;
bool a[1010];
const int INF=1000000007;
long long int mod=1;

int func(int b,int M){
        if(b>M)return 0;
	else return M/b+func(b,M/b);
}
int main(){
    cin>>N;
    fill(a,a+(N+1),true);
    for(int i=2;i<=N;i++){
        if(a[i]){
	   for(int j=i*2;j<=N;j+=i){
	       a[j]=false;
	   }
	   
	    mod=(mod*(func(i,N)+1))%INF;
	}
    }
    cout<<mod<<endl;
    
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		//int[] s=sc.Ia;
		int n=sc.I,ans=int.MaxValue,w=0;
		string s=" "+sc.S;
		int[] a=new int[n+1];
		for(int i = 1;i<=n;i++) {
			if(s[i]=='#'){a[i]++;}
			a[i]+=a[i-1];
		}
		ans=n-a[n];
		for(int i = n;i>0;i--) {
			ans=Math.Min(ans,a[i]+w);
			if(s[i]=='.'){w++;}
		}
		Console.WriteLine("{0}",a[n]==n?0:ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 14944
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    int N, K;
    string S;
    cin >> N >> S >> K;
    string ans = "";
    char letter = S[K - 1];
    for (int i = 0; i < N; i++) {
        if (S[i] == letter) {
            ans += letter;
        } else {
            ans += "*";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int a,b,c,d;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	a + b > c + d ? cout << "Left" << endl : a + b == c + d ? cout << "Balanced" << endl: cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define ll long long
#define ld long double
#define fi first
#define se second
#define INF 10000000000
const ll mod = 1000000000+7;
const int N = 100000+50;

ll dp[100+4][N];
ll w[N],v[N];

ll go(int x, int t)
{
	if(x==0&&t>0)return INF;
	if(x==0||t<=0)return 0;
	if(dp[x][t] != -1)return dp[x][t];
	return dp[x][t] = min(go(x-1,t),w[x] + go(x-1,t-v[x]));
}

main()
{ 
	SPEED;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n ;
	int W;
	cin >> n >> W;
	memset(dp,-1,sizeof(dp));
	for(int i = 1 ; i <=n ; i++){
		cin >> w[i] >> v[i];
	}
	int ans = 0;
	for(int i = 0; i<N;i++)
	{
		for(int j = 1;j<=n; j++)
		{
			if(go(j,i)<=W)ans = i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 81536
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#define max 8
#define exist -1
#define not 1

int num;
int mat_r[max],mat_c[max],dp[2*max-1],dn[2*max-1];
struct Input{
  int r,c;
}in[max];
int queen[max][max];

void iniesta(){
 int i,j;
    for(i=0;i<max;i++){
        mat_r[i]=exist;
        mat_c[i]=exist;
    }
    for(i=0;i<2*max-1;i++){
        dp[i]=exist;
        dn[i]=exist;
    }
}

void print_queen(){
    int i,j;
    for(i=0;i<max;i++){
        for(j=0;j<max;j++){
            if(queen[i][j]){
                if(mat_r[i]!=j){
                    return ;
                }
            }
        }
    }
    for(i=0;i<max;i++){
        for(j=0;j<max;j++){
        if(mat_r[i]==j){
        printf("Q");
        }else{
            printf(".");
        }
     }
     printf("\n");
    }
    return ;
}
void solve_queen(int i){
    int j;
if(i==max){
    print_queen();
    return;
}
for(j=0;j<max;j++){
    if(mat_c[j]==not || dp[i+j]==not || dn[i-j+max-1]==not){
        continue;
    }
    mat_r[i]=j;
    mat_c[j]=not;
    dp[i+j]=not;
    dn[i-j+max-1]=not;
    solve_queen(i+1);
    mat_r[i]=exist;
    mat_c[j]=exist;
    dp[i+j]=exist;
    dn[i-j+max-1]=exist;
}
}
int main(){
  int i,j,r,c;
  //初期化
  for(i=0;i<max;i++){
    for(j=0;j<max;j++){
      queen[i][j]=0;
    }
  }
  iniesta();
  scanf("%d",&num);
  for(i=0;i<num;i++){
      scanf("%d %d",&in[i].r,&in[i].c);
      queen[in[i].r][in[i].c]=1;
    }
  //printf("%d,%d\n",in[0].r,in[0].c);
  solve_queen(0);
  return 0;
}



Measured memory_bytes: 2108
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int answer = 0;
    int h1 = sc.nextInt();
    int m1 = sc.nextInt();
    int h2 = sc.nextInt();
    int m2 = sc.nextInt();
    int k = sc.nextInt();
    int minute1 = (h1 * 60) + m1;
    int minute2 = (h2 * 60) + m2;
    if (minute2 > minute1) {
      answer = minute2 - minute1 - k;
    } else {
      answer = (24 * 60) + minute2 - minute1 - k;
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 35596
import math
N = int(input())
ans = N - 1 #初期値、√Nの中に答えがなかったときはこれ
t = int(math.ceil(N**0.5))

for i in range(1,t+1):
    j = N / i
    if N % i == 0:
        step = i + j -2
        if step < ans:
            ans = int(step)
print(ans)

Measured memory_bytes: 9440
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;

    ll k, a[112345];

    cin >> n >> k;
    REP(i, n)
    cin >> a[i];

    ll res = 0;

    for (int i = 50; i >= 0; i--)
    {
        if ((ll)1 << i > k)
            continue;

        int cnt = 0;
        REP(j, n)
        {
            if (a[j] & ((ll)1 << i))
                cnt++;
        }

        if (cnt > n - cnt)
        {
        }
        else
        {
            res += ((ll)1 << i);
            k -= ((ll)1 << i);
        }
    }

    ll r = 0;

    REP(i, n)
    {
        r += a[i] ^ res;
    }

    cout << r << endl;

    return 0;
}

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

using namespace std;

#define TC ll t; cin >> t; while(t--)
typedef long long ll;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll a; cin >> a;
    cout << (a)+(a*a)+(a*a*a) << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <iomanip>


int main()
{
	long long n, m;

	std::cin >> n >> m;

	std::vector<long long> v(m);
	for (long long i = 0; i < m; i++) {
		std::cin >> v[i];
	}

	long long price = n;
	while (1) {
		long long temp = price;
		while (temp) {
			long long num = temp % 10;
			for (size_t i = 0; i < v.size(); i++) {
				if (num == v[i]) {
					num = -1;
					break;
				}
			}
			if (num == -1) {
				break;
			}
			temp /= 10;
		}
		if (temp == 0) {
			break;
		}
		price++;
		//std::cout << price << std::endl;
	}

	std::cout << price << std::endl;
	return 0;
}

Measured memory_bytes: 256
import math
A, B = map(int, input().split())
h = 100/8
l1 = h*A
l2 = 10*B

l = l1 if l1 > l2 else l2

u1 = h*A + h
u2 = 10*B+10

u = u1 if u1 < u2 else u2

cand = math.ceil(l)
if cand < u:
    print(cand)
else:
    print(-1)

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using static System.Console;
using static System.Math;

namespace abc_91_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());

            int[][] red = new int[n][];
            int[][] blue = new int[n][];

            for(int i = 0; i<n; i++)
            {
                int[] input = ReadLine().Split().Select(int.Parse).ToArray();
                red[i] = input;
            }

            for(int i = 0; i<n; i++)
            {
                int[] input = ReadLine().Split().Select(int.Parse).ToArray();
                blue[i] = input;
            }

            red = red.OrderByDescending(a => a[1]).ToArray();
            blue = blue.OrderBy(a => a[0]).ToArray();
            int count=0;

            for(int i=0; i<n; i++)
            {
                for(int j=0; j<n; j++)
                {
                   if(red[j] == null) continue;
                   if(red[j][0] < blue[i][0] && red[j][1] < blue[i][1])
                   {
                       count++;
                       red[j] = null;
                       break;
                   }
                }
            }
            WriteLine(count);
        }
    }
}

Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in(), K = in();
    ll answer = 0;
    REPS(i,N){
        if(i < K){
            i = K-1;
            continue;
        }
        answer += (N/i)*(i-K) + (K == 0 ? N%i : max(0,N%i-K+1));
    }
    cout << answer << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


int main() {
  string s,t;
  cin>>s>>t;
  int cnt=0;
  for(int i=0;i<(int)s.size();i++){
    if(s[i]!=t[i])cnt++;
  }
  cout<<cnt<<"\n";

  return 0;
}


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

using namespace std;

#define int long long

constexpr int INF = 1LL << 60;
constexpr double EPS = 1.0e-11;

typedef pair<int, int> pii;
typedef pair<int, pii> pipii;

constexpr int MAX_N = 5 * 100005;

int n;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(16);
    cout << fixed;

    cin >> n;
    cout << (n - 1) / 2 << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

ans = 0

def dfs(i, sw):
    global ans
    if i == n:
        if judge(sw):
            ans += 1
    else:
        dfs(i+1, sw+'0')
        dfs(i+1, sw+'1')

def judge(sw):
    """
    全ての電球が点灯するかどうかを判定
    """
    for values in ks:
        cnt = 0
        for i in values[1:]:
            if sw[i-1] == '1':
                cnt += 1
        if cnt%2 != p[ks.index(values)]:
            return False
    return True

dfs(0, '')
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#define pb push_back

using namespace std;
int main(void){
  int i,j,n;
  string s;
  int t,tmpi;
  while(cin>>n,n){
    vector<string> a;
    for(i=0;i<n;i++){
      cin>>s;
      a.pb(s);
    }
    
    for(i=0;i<n;){
      tmpi=i+1;
      t=0;
      while(t<5){
	t+=a[i].size();
	i++;
      }
      if(t>5) {i=tmpi;continue;}
      //cout<<":5"<<endl;
      t=0;
      while(t<7){
	t+=a[i].size();i++;
      }
      if(t>7) {i=tmpi;continue;}
      //cout<<":7"<<endl;
      t=0;
      while(t<5){
	t+=a[i].size();i++;
      }
      if(t>5) {i=tmpi;continue;}
      //cout<<":5"<<endl;
      t=0;
      while(t<7){
	t+=a[i].size();i++;
      }
      if(t>7) {i=tmpi;continue;}
      //cout<<":7"<<endl;
      t=0;
      while(t<7){
	t+=a[i].size();i++;
      }
      if(t>7) {i=tmpi;continue;}
      //cout<<":7"<<endl;
      if(t==7) break;
    }
    cout<<tmpi<<endl;
  }
  return 0;
}

Measured memory_bytes: 3072
s = int(input())

def f(n):
    if n % 2:
        return n * 3 + 1
    else:
        return n // 2

a = s
a_set = set([s])
for i in range(2, 10000):
    a = f(a)
    if a in a_set:
        print(i)
        exit()

    # print(a)
    a_set.add(a)




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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
	IOS;
    cout.precision(30);
    int m,d; cin >> m >> d;
    ll ans=0;
    for (int i=1;i<=m;i++)
    {
        for (int j=22;j<=d;j++)
        {
            string s=to_string(j);
            if (s[0]-'0'>=2 && s[1]-'0'>=2 && (s[0]-'0')*(s[1]-'0')==i)
                ans++;
        }
    }
    cout << ans;
    return 0;
}


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

int main() {
  int N;
  int d[110];
  cin >> N;
  rep(i, N) cin >> d[i];

  int num[110] = {0};
  rep(i, N) num[d[i]]++;

  int res = 0;
  for (int i=0; i <= 100; i++) {
    if (num[i]) ++res;
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (ll)(s); i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;

int main(){
    int n,k; cin>>n>>k;
    string s; cin>>s;

    vector<int> num;
    int conti=1;
    if(s[0]=='0') num.push_back(0);
    rep(i,0,n-1){
        if(s[i]==s[i+1]){
            conti++;
        }else{
            num.push_back(conti);
            conti=1;
        }
    }
    num.push_back(conti);
    if(s[n-1]=='0') num.push_back(0);

    vector<int> cum(num.size());
    cum[0]=num[0];
    rep(i,0,num.size()-1){
        cum[i+1]=cum[i]+num[i+1];
    }

    if((cum.size()-1)/2<k){
        cout<<s.size()<<endl;
        return 0;
    }
    int ans=0;

    for(int i=0; i+2*k<cum.size(); i+=2){
        int temp;
        if(i==0){
            temp=cum[2*k];
        }else{
            temp=cum[i+2*k]-cum[i-1];
        }
        ans=max(ans,temp);
    }

    cout<<ans<<endl;
    
}

Measured memory_bytes: 1272
n = int(input())
result_dict = {'AC':0,'WA':0,'TLE':0,'RE':0}
for i in range(n):
    s = input()
    result_dict[s] += 1
 
print('AC'+' x '+str(result_dict['AC']))
print('WA'+' x '+str(result_dict['WA']))
print('TLE'+' x '+str(result_dict['TLE']))
print('RE'+' x '+str(result_dict['RE']))

Measured memory_bytes: 9212