akhauriyash/Code-Regression huggingface dataset:
ans = {"AC": 0, "WA": 0, "TLE": 0, "RE":0}
N = int(input())
for i in range(N):
  inpt = input()
  if(inpt == "AC"):
    ans["AC"] += 1
  elif(inpt == "WA"):
    ans["WA"] += 1
  elif(inpt == "TLE"):
    ans["TLE"] += 1
  else:
    ans["RE"] += 1
for key, value in ans.items():
  print("{0} x {1}".format(key, value))

Measured memory_bytes: 9196
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

typedef pair<int, pair<int, int>> T;
typedef vector<T> V;

V v;

#define M 1000000007LL

int main() {
    int n = gi();
    int m = gi();
    for (int i = 0; i < n; i++)
        v.push_back({gi(), {i, 0}});
    for (int i = 0; i < m; i++)
        v.push_back({gi(), {i, 1}});
    sort(v.begin(), v.end(), std::greater<T>());

    V::size_type vj = 0;
    ll res = 1LL;
    int n0 = 0, n1 = 0, nu = 0;
    for (int i = n*m; i >= 1; i--) {
        int v0 = -1, v1 = -1;
        while (vj < v.size() && v[vj].first == i) {
            pair<int, int> &p = v[vj++].second;
            if (p.second) {
                if (v1+1) {
                    cout << 0 << endl;
                    return 0;
                }
                v1 = p.first;
            } else {
                if (v0+1) {
                    cout << 0 << endl;
                    return 0;
                }
                v0 = p.first;
            }
        }

        if (v0 == -1 && v1 == -1) {
            res *= n0*n1 - nu; res %= M;
        } else if (v0 == -1) {
            n1++;
            res *= n0; res %= M;
        } else if (v1 == -1) {
            n0++;
            res *= n1; res %= M;
        } else {
            n0++;
            n1++;
        }

        nu++;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const int maxn = 1e2 + 5;
char str[maxn];
int len;
int getcnt(int x)
{
    int cnt = 0;
    map<char, int> f;
    for(int i=1; i<=x; i++)
        f[str[i]] = 1;
    for(int i=x+1; i<=len; i++)
    {
        if(f[str[i]] == 1)
            cnt ++;
        f[str[i]] = 0;
    }
    return cnt;
}

int main()
{
    int maxs = 0;
    scanf("%d%s", &len, str+1);
    for(int i=1; i<=len; i++)
        maxs = max(maxs, getcnt(i));
    printf("%d\n", maxs);
    return 0;
}
/****
6
aabbca
****/


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

if N==1:
  print(1)
  exit()

S2=[]
signs=[]
if S[0]=='1':
  sign=1
else:
  sign=0
count = 1
for i in range(1,N):
  if S[i] != S[i-1]:
    S2.append(count)
    signs.append(sign)
    sign = 1- sign
    count = 0
  count += 1
  
S2.append(count)
signs.append(sign)
  
cumS = [0]
for i in range(len(S2)):
  cumS.append(cumS[-1]+S2[i])
  
k = K*2+1
if len(S2)>=k:
  MAX=0
  for i in range(len(S2)-k+1):
    if signs[i] == 1:
      tmp = cumS[i+k]-cumS[i]
      if tmp > MAX:
        MAX = tmp
  
  if signs[0]==0:
    MAX = max(MAX,cumS[k-1]-cumS[0])
  if signs[-1]==0:
    MAX = max(MAX,cumS[-1]-cumS[-k])
    
else:
  MAX=cumS[-1]
  
print(MAX)

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> t(n-1);
    for (int i = 0;i < n-1;++i) t[i] = abs(s[i]-s[i+1]);
    bool f = false;
    for (int i = 0;i < n-1;++i) if (t[i] == 1) {f = true;break;}
    if (f) for (int i = 0;i < n-1;++i) t[i] &= 1;
    int m = n-2,a = 0,b = 0;
    bool g = false;
    for (int i = 0;i < n-1;++i) {
        int j = i,k = m-i+1;
        if (i) {
            while (j%2 == 0) j /= 2,b++;
            while (k%2 == 0) k /= 2,a++;
        }
        if (t[i] && a == b) {
            g = !g;
        }
    }
    if (g) cout << (f ? 1 : 2) << endl;
    else cout << 0 << endl;
}

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

using namespace std;


// Bismilahir Rahmanir Rahim


typedef unsigned int ui;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef short int si;
typedef unsigned short int usi;
typedef pair <int, int> pii;


#define CASE false
#define TEST false
#define BUFFER true
#define TIME false
#define DEBUG true
#define SET_GEN false
#define _ << " " <<
#define __ << "\n"
#define ff first
#define ss second
#define RANGE(a, b) (rand() % (b-a+1) + a)


const double pi = acos(-1.);
const double eps = 1e-7;
const int high = 2e9;
const int inf = 2147483647;
const int _inf = -2147483648;
const lli INF = 1e18;
const int mod = 1e9+7;


void delay(int sec); // DEBUG

const int maxn = 1000;
char grid[maxn][maxn];
int dp[maxn][maxn];
int n, m;

bool valid(int r, int c) {return (bool)(r < n )&& (r >= 0 )&& (c < m )&& (c >= 0 )&& (grid[r][c] != '#');}

int path(int r, int c)
{	
	if (!valid(r, c)) return 0;
	if (dp[r][c] != -1) return dp[r][c];
	
	int ans = path(r, c+1) + path(r+1, c);
	ans %= mod;
	
	return dp[r][c] = ans;
}

void solution(void)
{	
	cin >> n >> m;
	
	memset(dp, -1, sizeof(dp));
	dp[n-1][m-1] = 1;
	
	for(int i = 0; i < n; ++i) 
		for(int j = 0; j < m; ++j) 
			cin >> grid[i][j];
		
		
	cout << path(0, 0) __;


    return ;
}

int main(int argc, char *arv[])
{
    #if BUFFER
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #endif

    #if SET_GEN
    srand((unsigned int) time(0));
    #endif

    int t = 1;

    #if CASE
    int cnt = 1;
    #endif

    #if TEST
    cin >> t;
    #endif

    #if TIME
    clock_t start_time, end_time;
    double time_elapsed;
    #endif


    while(t--) {

        #if TIME
        start_time = clock();
        #endif

        #if CASE
        cout << "Case " << cnt++ << ": ";
        #endif

        solution();

        #if TIME
        end_time = clock();

        time_elapsed = (double) (end_time - start_time) / CLOCKS_PER_SEC;

        cout << "\nRuntime: " << fixed << setprecision(7) << time_elapsed << "\n";
        #endif
    }


    return 0;
}

void delay(int sec)
{
    int mili_sec = 1000 * sec;

    clock_t start_time = clock();

    while (clock() < start_time + mili_sec);

    return ;
}


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

using namespace std;

char alpha[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
                'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};

int main(){

    int n;
    cin >> n;

    string s;
    cin >> s;

    for(int i=0; i<(int)s.size(); i++){
        s[i] = alpha[(((s[i] - 'A') + n) % 26)];
    }

    cout << s << endl;

}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

ll gcd(ll a,ll b) {
    while(b) {
        a %= b;
        swap(a,b);
    }
    return a;
}

ll lcm(ll a,ll b) {
    return a/gcd(a,b)*b;
}

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    ll l = 1;
    for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = 0;i < n;++i) {
        l = lcm(l,a[i]/2);
        if (l > m) {
            cout << 0 << endl;
            return 0;
        }
    }
    int cnt = 0;
    while (a[0]%2 == 0) cnt++,a[0] /= 2;
    for (int i = 1;i < n;++i) {
        int c = 0;
        while (a[i]%2 == 0) c++,a[i] /= 2;
        if (cnt != c) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (m/l+1)/2 << endl;
    return 0;
}

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

int n;
int x[10], y[10];

double dist(int i, int j){
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main(){
    cin >> n;
    for( int i=1; i<=n; i++){
        cin >> x[i] >> y[i];
    }
    double sum=0.0;
    vector<int>v(n);
    for( int i=0; i<n; i++){
        v[i] = i+1;
    }
    do{
        for(int i=0; i<n-1; i++){
            sum += dist(v[i],v[i+1]);
        }
    }while(next_permutation(v.begin(),v.end()));
    int factorial=1;
    for( int i=2; i<=n; i++) factorial *= i;
    cout << fixed << setprecision(10) << sum/factorial << endl;
}




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

sum_prob = 0
for init_num in range(1, N + 1):
    if init_num < K:
        n_trial_lower = 0
        while init_num * (2**n_trial_lower) < K:
            n_trial_lower += 1
        prob = 1 / N * (0.5**n_trial_lower)
    else:
        prob = 1 / N
    sum_prob += prob

print(sum_prob)


Measured memory_bytes: 2940
a,b,c=map(int,input().split())
nowpoint=0
day=0
while 1:
    if c-nowpoint<=a*6:
        day+=(c-nowpoint+a-1)//a
        break
    elif c-nowpoint<=a*7+b:
        day+=7
        break
    day+=7
    nowpoint+=a*7+b
print(day)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){
	
	int N;
	cin>>N;
	
	vector<long long> a(N),b(N);
	
	for(int i=0;i<N;i++)cin>>a[i];
	for(int i=0;i<N;i++)cin>>b[i];
	
	long long cnt = 0;
	
	for(int i=0;i<N;i++){
		if(a[i]>b[i])continue;
		long long c = b[i]-a[i];
		cnt += (c+1)/2;
		a[i] += ((c+1)/2)*2;
	}
	
	for(int i=0;i<N;i++){
		cnt -= a[i] - b[i];
	}
	
	if(cnt>=0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 512
N = int(input())
abc = [list(map(int, input().split())) for i in range(N)]
abc.append([0, 0, 0])

dp = [[-1] * 4 for i in range(N + 1)]
dp[0] = [0, 0, 0]
for i in range(1, N + 1):
    dp[i][0] = max([dp[i - 1][1] + abc[i - 1][1], dp[i - 1][2] + abc[i - 1][2]])
    dp[i][1] = max([dp[i - 1][0] + abc[i - 1][0], dp[i - 1][2] + abc[i - 1][2]])
    dp[i][2] = max([dp[i - 1][1] + abc[i - 1][1], dp[i - 1][0] + abc[i - 1][0]])

print(max(dp[N]))


Measured memory_bytes: 74584
// ABC179C.cpp

#include <iostream>
using namespace std;
using ll = long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
int main()
{
    int n;
    cin >> n;

    int ans = 0;
    // (n+a-1)/aを求めて、bの個数は(n+a-1)-1となる
    for (int a = 1; a <= n; a++) {
        int add = (n + a - 1) / a - 1;
        ans += add;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3188
#include<stdio.h>

main() {
	int H[1000], W[1000],i,kkn=0,j,k;
	for (i = 0;i < 10000;i++) {
		scanf("%d %d", &H[i], &W[i]);
		if (H[i] == 0 && W[i] == 0) break;
		kkn++;

	}
	for (i = 0;i < kkn;i++) {
		for (j = 0;j < H[i];j++) {
			if (j == 0 || j+1== H[i]) {
				for (k = 0;k < W[i];k++) {
					putchar('#');
				}
			}
			else {
				putchar('#');
				for (k = 1;k +1< W[i];k++) {
					putchar('.');

				}
				putchar('#');
			}
				putchar('\n');
			}
		
		
		printf("\n");
		
	}
}


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

public class Hello
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string[] s_data = Console.ReadLine().Split(' ');
        int[] data = new int[N];

        //Alice と Bobの得点
        int Alice_point = 0;
        int Bob_point = 0;

        for (int i = 0; i < N; i++) data[i] = int.Parse(s_data[i]);

        Array.Sort(data);
        Array.Reverse(data);

        for(int i = 0; i < N; i++)
        {
            if (i % 2 == 0) Alice_point += data[i];
            else Bob_point += data[i];
        }

        Console.WriteLine(Alice_point - Bob_point);
    }
}

Measured memory_bytes: 11092
n = int(input())
aa = tuple(map(int, input().split()))

balls = set()
for i in range(n, 0, -1):
    r = aa[i - 1]
    
    x = 0
    for j in range(i, n + 1, i):
        if j in balls:
            x += 1
    if x % 2 != r:
        balls.add(i)
print(len(balls))
if balls:
    print(' '.join(map(str, balls)))

Measured memory_bytes: 21548
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Main m = new Main();
    m.exec();
  }

  private void exec() {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int sum = 0;
    for (int i = 0; i < n; i++) {
      int l = scan.nextInt();
      int r = scan.nextInt();
      sum += r - l + 1;
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 25544
#include <iostream>
int main(){
    using namespace std;
    int n,m,i,j,x;
    long long int c;
    cin >> n >> m;
    int a[n][m];
    int b[m];
    for(j=0;j<n;j++){
        for(i=0;i<m;i++){
            cin >> x;
            a[j][i] = x;
        }
    }
    for(i=0;i<m;i++){
        cin >> x;
        b[i] = x;
    }
    for(j=0;j<n;j++){
        c = 0;
        for(i=0;i<m;i++){
            c += a[j][i]*b[i];
        }
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    long long count=0;
    cin>>n;
    for(int i=1;i*i<=n;i++){
        for(int j=i;i*j<n;j++){
            if((n-(i*j))<=0){
                break;
            }
            if(i==j)
                count++;
            else
                count+=2;
        }
    }
    cout<<(count);
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
int main()
{
	SPEED
	ll n, d;
	cin >> n >> d;
	d = d*d;

	ll ans = 0;
	ll x, y;
	for (int i = 0; i < n; ++i)
	{
		cin >> x >> y;
		ll dist = x*x + y*y;
		if (dist<=d)
		{
			ans++;
		}
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int comb[3005][3005];
int a[3005];
ll ans[3005];

ll mod_pow(ll x,ll n,ll p){
	ll ans=1;
	while(n>0){
		if(n&1){
			ans=ans*x%p;
		}
		x=x*x%p;
		n>>=1;
	}
	return ans;
}

int main(void){
	int p;
	scanf("%d",&p);
	for(int i=0;i<p;i++){
		scanf("%d",&a[i]);
	}
	comb[0][0]=1;
	for(int i=1;i<=p;i++){
		for(int j=1;j<i;j++){
			comb[i][j]=(comb[i-1][j]+comb[i-1][j-1])%p;
		}
		comb[i][0]=1;
		comb[i][i]=1;
	}
	for(int i=0;i<p;i++){
		if(a[i]==1){
			ans[0]++;
			for(int j=0;j<p;j++){
				ll val=comb[p-1][j];
				val=val*mod_pow(i,p-1-j,p);
				if(j%2==0){
					ans[j]+=p-val;
				}else{
					ans[j]+=val;
				}
			}
		}
	}
	for(int i=0;i<p;i++){
		ans[i]%=p;
		printf("%lld%c",ans[i],i+1==p?'\n':' ');
	}
	return 0;
}


Measured memory_bytes: 34304
package main

import "fmt"

func main()  {
	var s string
	
	fmt.Scan(&s)
	if s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi" {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n = I()
a = LI()
a = list(map(lambda x: x - 1, a))
b = LI()
c = LI()

ans = 0
for i in range(n):
    ans += b[a[i]]
    if i > 0 and a[i - 1] + 1 == a[i]:
        ans += c[a[i - 1]]
print(ans)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * for (int i = 0; i < N; i++) {}
 * System.out.println();
 * HashMap<Integer, Integer> hm = new HashMap<>();
 * int[] s = new int[M];
 * ArrayDeque<Integer> deq = new ArrayDeque<>();
 *
 */
public class Main implements Runnable { //クラス名はMain1

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 1024 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	public void run() {
		FastScannerMainB sc = new FastScannerMainB(System.in);

		try {
			String S = sc.nextLine().trim();
			int N = S.length();
			int hN = N / 2;

			int N1 = (N - 1) / 2;
			int N2 = (N + 3) / 2;
			//int[] a = new int[N];
			//long l = sc.nextLong();
			//ArrayList<Integer> arr = new ArrayList<Integer>();
			//for (int i = 0; i < N; i++) {}

			boolean con1 = true;
			boolean con2 = true;
			boolean con3 = true;

			for (int i = 0; i < hN; i++) {
				String s1 = S.substring(i, i + 1);
				String s2 = S.substring(N - i - 1, N - i);
				//System.out.println("s1:" + s1 + " s2:" + s2);
				if (!s1.equals(s2)) {
					con1 = false;
				}
			}

			for (int i = 0; i < N1; i++) {
				String s1 = S.substring(i, i + 1);
				String s2 = S.substring(N1 - i - 1, N1 - i);
				//System.out.println("s1:" + s1 + " s2:" + s2);
				if (!s1.equals(s2)) {
					con2 = false;
				}
			}

			int count = 0;
			for (int i = N2 - 1; i < N; i++) {
				String s1 = S.substring(i, i + 1);
				String s2 = S.substring(N - count - 1, N - count);
				//System.out.println("s1:" + s1 + " s2:" + s2);
				if (!s1.equals(s2)) {
					con3 = false;
				}
				count++;
			}

			if (con1 && con2 && con3) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}

		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}

//高速なScanner
class FastScannerMainB {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMainB(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


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

int main(void){
    int n; cin >> n;
    int ans=0;
    for(int i=1; i<=n; i++){
        if(i==105 || i==135 || i==165 || i==189 || i==195) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int n;
int a[224514];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	int memo = 1;
	rep(i, n) {
		if (a[i] == memo) {
			memo++;
		}
	}
	if (memo == 1)puts("-1");
	else cout << n - memo + 1 << endl;
	ggr
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		while(a % 2 == 0){
			a /= 2;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [A, B, C, D] = input[0].map(Number);

  const L = A + B;
  const R = C + D;

  return L === R ? "Balanced" : L > R ? "Left" : "Right";
};

console.log(main(read()));


Measured memory_bytes: 29596
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

const double PI = acos(-1);
constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class Task{
public:
    void solve(istream& in, ostream& out){
        int N;
        const lint MX = ten(18);
        in>>N;
        bool zero = false, ovr = false;
        vc<lint> A(N);
        for(auto& a : A) in>>a;
        lint ans = 1;
        for(auto& a : A){
            if(a==0) zero = true;
            else if(ans>MX/a){
                ovr = true;
                ans = 1;
            }
            ans *= a;
        }
        if(zero) out<<"0\n";
        else if(ovr) out<<"-1\n";
        else out<<ans<<'\n';
    }
};

int main(){
    istream& in(cin);
    ostream& out(cout);
    ios_base::sync_with_stdio(false);
    in.tie(nullptr), out.tie(nullptr);
    Task solver;
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 3992
#include <iostream>
using namespace std;
int main(){
	string s, t="CODEFESTIVAL2016";
	cin >> s;
	int count = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i]!=t[i])count++;
	}
	cout << count << endl;
	return 0;
}


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

int N;
int A[210];

int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> A[i];
  
  int res = 0;
  
  while(true) {
    bool exist_odd = false;
    for(int i = 0; i < N; ++i) {
      if (A[i] % 2 != 0) exist_odd = true;
    }
    
    if (exist_odd) break;
    
    for (int i = 0; i < N; ++i) {
      A[i] /= 2;
    }
    ++res;
  }
  
  cout << res << endl;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin>>a[i];

	int cnt = 0;
	vector<int> ans(0);
	for(int i = n - 1; i >= 0; i--){
		if(a[i] % 2){
			cnt++;
			ans.push_back(i+1);

			int num = i + 1;
			for(int j = 1; j * j <= num; j++){
				if(num % j == 0){
					a[j-1]++;
					int neko = num / j;
					if(j * j != num)a[neko-1]++;
				}
			}
		}
	}
	SORT(ans);
	cout << cnt << endl;
	rep(i,cnt) cout << ans[i] << endl;
}


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

int main()
{   int m1,d1,m2,d2;
    scanf("%d%d%d%d",&m1,&d1,&m2,&d2);
    if(m1==m2){
        printf("0");
    }else{
        printf("1");
    }
    return 0;
}


Measured memory_bytes: 128
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, W = map(int, readline().split())
    dp = [0]*(W+1)
    for _ in range(N):
        v, w = map(int, readline().split())
        if w<=W:
            for i in range(0,W-w+1):
                dp[i+w] = max(dp[i+w], dp[i]+v)
    print(dp[W])

if __name__ == '__main__':
    main()




Measured memory_bytes: 5916
#include<bits/stdc++.h>
#define QS ios_base::sync_with_stdio(false);
typedef long long ll;
const ll INF = 1e18;
const int MOD = 1e9+7;
using namespace std;


int main(){
//freopen("output.txt", "w", stdout);
    QS
    cin.tie(NULL);
    int n, k; cin >> n >> k;
    ll H[n+2]; H[0] = 0;
    for(int i = 1; i <= n; ++i){
        cin >> H[i];
    }
    H[n+1] = 0;
    ll dp[n+2][k+2];
    for(int i = 0; i < n + 2; ++i){
        for(int j = 0; j < k + 2; ++j){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(int i = 0; i <= n + 1; ++i){
        for(int j = 0; j <= k; ++j){
            for(int _k = 0; _k <= j; ++_k){
                int pos = i - _k - 1;
                if(pos < 0) continue;
                dp[i][j] = min(dp[i][j], dp[pos][j - _k] + max(0LL, H[i]-H[pos]));
            }
        }
    }
    ll ans = INF;
    for(int i = 0; i <= k; ++i){
        ans = min(ans, dp[n+1][i]);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1024
from itertools import permutations

N, C = map(int, input().split())

D = []
for _ in range(C):
  Ds = list(map(int, input().split()))
  D.append(Ds)

grid = []
for _ in range(N):
  c = list(map(lambda x: int(x)-1, input().split()))
  grid.append(c)

color = [[0]*C for _ in range(3)]

for i in range(N):
  for j in range(N):
    color[(i+j)%3][grid[i][j]] += 1

INF = 10**9
ans = INF

for cols in permutations(range(C), 3):
  temp = 0
  for i, Y in enumerate(cols):
    for X, cnt in enumerate(color[i]):
      temp += D[X][Y] * cnt
  ans = min(ans, temp)

print(ans)

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

int main()
{
  int n, c1=0, c2=0, c3=0, c4=0;
  string s;
  cin>>n;
  while(n--)
  {
    cin>>s;
    if(s=="AC") c1++;
    else if(s=="WA") c2++;
    else if(s=="TLE") c3++;
    else c4++;
  }
  cout<<"AC x "<<c1<<endl;
  cout<<"WA x "<<c2<<endl;
  cout<<"TLE x "<<c3<<endl;
  cout<<"RE x "<<c4;
  return 0;
}

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

int main() {
    int n, a;
    cin >> n;
    int ans = 1, diff = 1;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a % 2 == 0) diff *= 2;
        ans *= 3;
    }
    ans -= diff;
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

struct GCD
{
    using type = int;
    static type id() { return 0; }
    static type op(const type &l, const type &r) { return gcd(l, r); }
};

template <typename M>
class SegmentTree
{
    using T = typename M::type;
    int n;
    std::vector<T> node;

  public:
    // v を基に初期化
    SegmentTree(const std::vector<T> &v)
    {
        // n は v.size() 以上の最小の2冪
        n = 1;
        while (n < int(v.size()))
            n *= 2;
        node.resize(2 * n, M::id());

        // i の子 -> 2*i+1, 2*i+2 , 親 -> (i-1)/2
        for (int i = 0; i < int(v.size()); i++)
            node[i + n] = v[i];
        for (int i = n - 1; i >= 0; i--)
            node[i] = M::op(node[2 * i], node[2 * i + 1]);
    }
    // Monoid::id 初期化
    SegmentTree(int _n)
    {
        // n は v.size() 以上の最小の2冪
        n = 1;
        while (n < _n)
            n *= 2;
        node.resize(2 * n, M::id());
    }
    // x 番目を val に更新
    void update(int x, T val)
    {
        x += n;
        node[x] = val;
        while (x >>= 1)
        {
            node[x] = M::op(node[2 * x], node[2 * x + 1]);
        }
    }
    // v[x] を M::op(v[x], val) に更新
    void operation(int x, T val)
    {
        x += n;
        node[x] = M::op(node[x], val);
        while (x >>= 1)
        {
            node[x] = M::op(node[2 * x], node[2 * x + 1]);
        }
    }
    // [a, b) の op
    T query(int l, int r)
    {
        l += n;
        r += n;
        T retl = M::id(), retr = M::id();
        while (l < r)
        {
            if (l & 1)
                retl = M::op(retl, node[l++]);
            if (r & 1)
                retr = M::op(node[--r], retr);
            l >>= 1;
            r >>= 1;
        }
        return M::op(retl, retr);
    }
};

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

    int n;
    cin >> n;
    vector<int> a(n);
    SegmentTree<GCD> st(100010);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        st.update(i, a[i]);
    }
    int ret = 1;
    for (int i = 0; i < n; i++)
    {
        int l = st.query(0, i), r = st.query(i + 1, n);
        ret = max(ret, gcd(l, r));
    }
    cout << ret << endl;
}


Measured memory_bytes: 1664
#include<stdio.h>

int main(){
  int x, a, b, dis_a, dis_b;
  
  scanf("%d %d %d", &x, &a, &b);
  
  dis_a = (a - x > 0) ? a - x : x - a;
  dis_b = (b - x > 0) ? b - x : x - b;
  
  if(dis_a > dis_b){
    printf("B\n");
  } else {
    printf("A\n");
  }
  
  return 0;
}

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

int h, w;
int n;
int ma[101][101];
int a[10001];

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    cin >> h >> w >> n;
    vector<int> list;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        for (int j = 0; j < a[i]; j++) {
            list.push_back(i);
        }
    }

    for (int i = 0; i < h * w; i++) {
        if ((i / w) % 2 == 0) {  // 홀수행
            ma[i / w][i % w] = list[i];
        } else {
            ma[i / w][w - i % w - 1] = list[i];
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << ma[i][j] << ' ';
        }
        cout << '\n';
    }


    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

/*

*/

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

        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        double b = sc.nextDouble();

        long std = a;
        if (a >= 100) {
        	a = a/100;
        }
        double ans = Math.floor(a * b);
        if (std >= 100) {
        	ans = ans*100;
        }
        System.out.println((long)ans);

    }
}

Measured memory_bytes: 37480
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long long x, y;
	cin >> x >> y;
	x *= -1;
	long long ans = 100000000007;
	if (y >= x) {
		if (ans > y - x + 1) {
			ans = y - x + 1;
		}
	}
	y *= -1;
	if (y >= x) {
		if (ans > y - x + 2) {
			ans = y - x + 2;
		}
	}
	x *= -1;
	if (y >= x) {
		if (ans > y - x + 1) {
			ans = y - x + 1;
		}
	}
	y *= -1;
	if (y >= x) {
		if (ans > y - x) {
			ans = y - x;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
nx = gets.chomp.split(" ").map(&:to_i)

a = gets.chomp.split(" ").map(&:to_i)

carry = 0

(a.size-1).times do |i|
  rem =  -nx[1] + (a[i+1] + a[i])
  if rem > 0
    rem = a[i+1] if rem > a[i+1]
    a[i+1] -= rem
    carry += rem
    rem = -nx[1] + (a[i] + a[i+1])
    if rem > 0
      a[i] -= rem
      carry += rem
    end
  end
end
p carry


Measured memory_bytes: 9612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
   ll n;cin>>n;
   map<ll,ll> mp;
   for(ll i=2;i<=sqrt(n);i++){
       while(n%i==0){
           mp[i]++;
           n/=i;
       }
   }
   if(n>1)mp[n]++;
   ll res=0;
   for(auto& p:mp){
       ll x=p.second;
       ll tmp=1;
       while(tmp<=x){
           x-=tmp;
           tmp++;
           res++;
       }
   }
   cout<<res<<endl;
}


Measured memory_bytes: 3728
#include <iostream>

using namespace std;

string s;
long n;

int main()
{
    int min = 0;
    int black = 0;
    int white = 0;
    cin >> n;
    cin >> s;

    long tmp;

    for (int i = 0; i < n; i++)
    {
        if (s[i] == '.')
            white++;
    }
    min = white;

    for (long i = 0; i < n; i++)
    {
        if (s[i] == '.')
        {
            white--;
        }
        else
        {
            black++;
        }
        if (min > white + black)
            min = white + black;
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.*;
class Main{

     public static void main(String []args){
      Scanner scan = new Scanner(System.in);
      int m = scan.nextInt() ;
      int arr[] = new int[m] ;
      ArrayList<Integer> a = new ArrayList<>() ;
      for(int i =0 ;i<m ; i++){
          arr[i] = scan.nextInt() ;
          if(!a.contains(arr[i])){
              a.add(arr[i]) ;
          }
      }
      System.out.println(a.size());
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

typedef signed long long ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) x.begin(),x.end()

//#define DEBUG

int main()
{
	string s;
	bool ans = false;

	//input
	cin >> s;

	//solve
	sort(all(s));
	if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) ans = true;

#ifdef DEBUG
	cout << s << endl;
#endif
	if(ans)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a == b && a != c) {
			System.out.println("Yes");
		} else if (a == c && a != b) {
			System.out.println("Yes");
		} else if (b == c && b != a) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}

}


Measured memory_bytes: 35696
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
//#define mod 1000000007
#define mod 998244353
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modinv(ll a){
	return powm(a,mod-2)%mod;
}

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
    {
    	string s;
    	cin>>s;
    	if(s=="ABC")
    	cout<<"ARC";
    	else
    	cout<<"ABC";
	}

}

Measured memory_bytes: 3672
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 200_003
R = 2  # primitive root

@njit((i8[:], ), cache=True)
def precompute(A):
    exp = np.zeros(MOD - 1, np.int64)
    log = np.zeros(MOD, np.int64)
    exp[0] = 1
    for k in range(1, MOD - 1):
        exp[k] = exp[k - 1] * R % MOD
        log[exp[k]] = k
    # r^k の個数を B[k] に入れる
    B = np.zeros(MOD - 1, np.int64)
    for x in A:
        if x != 0:
            B[log[x]] += 1
    return exp, log, B

@njit((i8[:], i8[:], i8[:], i8[:]), cache=True)
def get_ans(A, C, exp, log):
    # 順序対について集計
    ans = 0
    for i in range(len(C)):
        x = exp[i % (MOD - 1)]
        ans += x * C[i]
    for a in A:
        x = a * a % MOD
        ans -= x
    return ans // 2

A = np.array(read().split(), np.int64)[1:]

exp, log, B = precompute(A)
fft, ifft = np.fft.fft, np.fft.ifft
fft_len = 420_000
FB = fft(B, fft_len)
C = np.rint(ifft(FB * FB, fft_len)).astype(np.int64)

print(get_ans(A, C, exp, log))


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

void merge_sort(long long x[], int n)
{
	static long long y[100001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N;
	long long A[100001], B[100001], C[100001];
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%lld", &(A[i]));
	for (i = 0; i < N; i++) scanf("%lld", &(B[i]));
	for (i = 0; i < N; i++) scanf("%lld", &(C[i]));
	
	int j, k;
	long long ans = 0, count[100001] = {};
	merge_sort(A, N);
	merge_sort(B, N);
	merge_sort(C, N);
	for (j = 0, k = 0; j < N; j++) {
		for (; C[k] <= B[j] && k < N; k++);
		count[j] = N - k;
	}
	for (j = N - 2; j >= 0; j--) count[j] += count[j+1];
	for (i = 0, j = 0; i < N; i++) {
		for (; B[j] <= A[i] && j < N; j++);
		if (j < N) ans += count[j];
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 4096
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>





#define MAX_INT 2147483647
#define MIN_INT -2147483648




int main(void)
{
	int i,j;
	int N, A, B;
	scanf("%d %d %d", &N, &A, &B);

	if(A*N<=B)
	{
		printf("%d\n", A*N);
	}
	else
	{
		printf("%d\n", B);
	}
	return 0;
}


Measured memory_bytes: 128
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

N = iIn()

fN = sum(list(map(int, list(str(N)))))

ans = 'Yes' if N % fN == 0 else 'No'

print(ans)

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()

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

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main() { 
    int N, K;
    cin >> N >> K;
    vector<long long> a(N);
    REP(i, N) {
        cin >> a[i];
    }

    int S = 1 << N;
    long long ans = llINF;
    REP(ss, S) {
        long long tmp = 0, h = 0;
        int cnt = 0;
        REP(i, N) {
            if ((ss >> i) & 1) {
                cnt += 1;
            }
        }

        if (cnt < K) {
            continue;
        }

        REP(i, N) {
            if ((ss >> i) & 1) {
                if (h >= a[i]) {
                    tmp += h + 1 - a[i];
                    h += 1;
                } else {
                    h = a[i];
                }
            } else {
                h = max(h, a[i]);
            }
        }

        ans = min(tmp, ans);
    }

    cout << ans << endl;
    return 0; 
}

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

int main(){
    ll n; cin >> n;
    vector<ll> a(n), b(n); rep(i,n) cin >> a[i];

    ll x = a[0];

    for(long long i = 1; i < n; i++){
        x = x xor a[i];
    }

    for(long long i = 0; i < n; i++){
        cout << (x xor a[i]) << " ";
    }
    cout << endl;
}

Measured memory_bytes: 6268
import java.util.Deque;
import java.util.ArrayDeque;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nt = br.readLine().split(" ");
        int n = Integer.parseInt(nt[0]);
        int t = Integer.parseInt(nt[1]);
        int[][] cts = new int[n][2];
        
        for (int i = 0; i < n; i++) {
            String[] ct = br.readLine().split(" ");
            cts[i][0] = Integer.parseInt(ct[0]);
            cts[i][1] = Integer.parseInt(ct[1]);
        }
        
        int min = 1000;
        boolean beback = false;
        for (int i = 0; i < n; i++) {
            if (cts[i][1] <= t) {
                beback = true;
                if (cts[i][0] < min) {
                    min = cts[i][0];
                }
            }
        }
        
        if (beback) System.out.println(min);
        else System.out.println("TLE");
    }
}


Measured memory_bytes: 23120
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC153C - Fennec vs Monster

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();   // モンスターの数
        int k = sc.nextInt();   // 必殺技の回数

        int[] h = new int[n];

        long hp = 0;
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
            hp += h[i];
        }

        Arrays.sort(h);

        if (k > n) k = n;
        
        for (int i = n - 1; i >= n - k; i--) {
            hp -= h[i];
        }

        System.out.println(hp);
    }
}

Measured memory_bytes: 88288
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    string S,T;
    cin >> S >> T;
    vector<int> ssum(S.length()+1);
    vector<int> tsum(T.length()+1);
    for(int i = 0;i < S.length();i++){
        ssum[i+1] = ssum[i] + (S[i]=='A'?1:2);
    }
    for(int i = 0;i < T.length();i++){
        tsum[i+1] = tsum[i] + (T[i]=='A'?1:2);
    }
    int Q,a,b,c,d;
    cin >> Q;
    for(int i = 0;i < Q;i++){
        cin >> a >> b >> c >> d;
        if((ssum[b]-ssum[a-1]) % 3 == (tsum[d]-tsum[c-1]) % 3){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}

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

using namespace std;

bool vizl[13], vizc[13];
int r[13], c[13];
char ch[13][13];
int n, m; bool lin[13][13], col[13][13];

void ok () {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (ch[r[i]][c[j]] != ch[r[n + 1 - i]][c[m + 1 - j]])
        return;
  cout << "YES";
  exit(0);
}

void backt2 (int lol, int t) {
  if (lol == 0) {
    ok();
    return;
  }
  if (t) {
    for (int i = 1; i <= m; i++) {
      vizc[i] = true;
      c[lol] = i;
      backt2(lol - 1, 0);
      vizc[i] = false;
    }
  }
  else {
    for (int i = 1; i <= m; i++)
      if (!vizc[i])
        for (int j = i + 1; j <= m; j++)
          if (!vizc[j] && col[i][j]) {
            vizc[i] = vizc[j] = true;
            c[lol] = i;
            c[m + 1 - lol] = j;
            backt2(lol - 1, 0);
            vizc[i] = vizc[j] = false;
          }
  }
}

void backt1 (int lol, int t) {
  if (lol == 0) {
    backt2((m + 1) / 2 , m % 2);
    return;
  }
  if (t) {
    for (int i = 1; i <= n; i++) {
      vizl[i] = true;
      r[lol] = i;
      backt1(lol - 1, 0);
      vizl[i] = false;
    }
  }
  else {
    for (int i = 1; i <= n; i++)
      if (!vizl[i])
        for (int j = i + 1; j <= n; j++)
          if (!vizl[j] && lin[i][j]) {
            vizl[i] = vizl[j] = true;
            r[lol] = i;
            r[n + 1 - lol] = j;
            backt1(lol - 1, 0);
            vizl[i] = vizl[j] = false;
          }
  }
}

int main()
{
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    cin >> (ch[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      string x, y;
      lin[i][j] = lin[j][i] = true;
      for (int k = 1; k <= m; k++) {
        x += ch[i][k];
        y += ch[j][k];
      }
      sort (x.begin(), x.end());
      sort (y.begin(), y.end());
      if (x != y)
        lin[i][j] = lin[j][i] = false;
    }
  for (int i = 1; i <= m; i++)
    for (int j = i + 1; j <= m; j++) {
      string x, y;
      for (int k = 1; k <= n; k++) {
        x += ch[k][i];
        y += ch[k][j];
      }
      sort (x.begin(), x.end());
      sort (y.begin(), y.end());
      col[i][j] = col[j][i] = true;
      if (x != y)
        col[i][j] = col[j][i] = false;
    }
  backt1((n + 1) / 2, n % 2);
  cout << "NO";
  return 0;
}


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

    int N;
    cin >> N;

    int i = 1;

    while(i <= N)
    {
        if((i*2) <= N)
        {
            i *=2;
        }
        else
        {
            break;
        }      
    }

    cout << i;

    return 0;
}

Measured memory_bytes: 256