akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

const int INF = 1e9;

using Weight = int;
using Capacity = int;
struct Edge {
    int src, dst; Weight weight;
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

int n;
Graph g;
int k;

int num[100010];

bool pality_check(int u, int p, int x){
    if(num[u] != -1 && num[u]%2 != x){
        return false;
    }

    for(auto &e : g[u]){
        int v = e.dst;
        if(v == p) continue;
        if(!pality_check(v, u, 1-x)){
            return false;
        }
    }

    return true;
}

int lb[100010], ub[100010];

void get_range(int u, int p){
    int mi = -INF;
    int ma = INF;
    for(auto &e : g[u]){
        int v = e.dst;
        if(v == p) continue;
        get_range(v, u);
        mi = max(mi, lb[v]);
        ma = min(ma, ub[v]);
    }

    --mi;
    ++ma;

    pair<int,int> res;
    if(mi > ma){
        lb[u] = +INF;
        ub[u] = -INF;
    } else {
        if(num[u] != -1){
            if(mi <= num[u] && num[u] <= ma){
                lb[u] = num[u];
                ub[u] = num[u];
            } else {
                lb[u] = +INF;
                ub[u] = -INF;
            }
        } else {
            lb[u] = mi;
            ub[u] = ma;
        }
    }
}

void paint(int u, int p, int pc){
    int c = lb[u] <= pc-1 && pc-1 <= ub[u] ? pc-1 : pc+1;
    num[u] = c;
    for(auto &e : g[u]){
        int v = e.dst;
        if(v == p) continue;
        paint(v, u, c);
    }
}

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

    cin >> n;
    memset(num, -1, sizeof num);
    g.assign(n, {});
    rep(i,n-1){
        int x,y;
        cin >> x >> y;
        --x; --y;
        g[x].emplace_back(x,y,1);
        g[y].emplace_back(y,x,1);
    }

    cin >> k;
    rep(i,k){
        int v,p;
        cin >> v >> p;
        --v;
        num[v] = p;
    }

    int r = -1;
    rep(i,n) if(num[i] != -1) r = i;

    bool yes = [&]{
        if(!pality_check(r, -1, num[r]%2)) return false;
        get_range(r, -1);
        if(lb[r] > ub[r]) return false;
        paint(r, -1, lb[r]-1);
        return true;
    }();

    if(!yes){
        cout << "No" << '\n';
    } else {
        cout << "Yes" << '\n';
        rep(i,n) cout << num[i] << '\n';
    }
}


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

int main(void) {
    string str[2];
    int n, point[2] = {};

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> str[0] >> str[1];
        if (str[0] > str[1]) {
            point[0] += 3; 
        } else if (str[0] < str[1]) {
            point[1] += 3; 
        } else {
            point[0] += 1; 
            point[1] += 1; 
        }
    }
    cout << point[0] << " " << point[1] << endl;

    return 0;
} 

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

int main() {
  int N, W[105];

  cin >> N;
  rep(i, N) cin >> W[i + 1];

  int ans = INF;
  for (int i = 1; i < N; i++) {
    int s1, s2;
    s1 = s2 = 0;
    for (int j = 1; j <= i; j++) {
      s1 += W[j];
    }
    for (int j = i + 1; j <= N; j++) {
      s2 += W[j];
    }

    ans = min(ans, abs(s1 - s2));
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main(void){
	int r,g,b;
	scanf("%d %d %d", &r,&g,&b);
	int n = r*100 + g*10 + b;
	if (n % 4 == 0 ) {
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 128
N,C =[int(x) for x in input().split()]
D = [[int(x) for x in input().split()] for _ in range(C)]
c = [[int(x) for x in input().split()] for _ in range(N)]
c1 = []
c2 = []
c3 = []
for i in range(1,N+1):
  for j in range(1,N+1):
    if (i+j)%3==0:
      c1.append(c[i-1][j-1])
    elif (i+j)%3==1:
      c2.append(c[i-1][j-1])
    elif (i+j)%3==2:
      c3.append(c[i-1][j-1])
su = 0
ans = 100000000000000
import collections as col
c1 = col.Counter(c1)
c2 = col.Counter(c2)
c3 = col.Counter(c3)
#print(c1,c2,c3)
for i in range(C):
  for j in range(i+1,C):
    for k in range(j+1,C):
      for a,b,c in [[i,j,k],[j,i,k],[k,j,i],[i,k,j],[k,i,j],[j,k,i]]:
        su = 0
        for l in range(1,C+1):
          #print(c1[l],c2[l],c3[l])
          su += D[l-1][a]*c1[l]+D[l-1][b]*c2[l]+D[l-1][c]*c3[l]
        ans = min(ans,su)
print(ans)

Measured memory_bytes: 56796
// https://atcoder.jp/contests/abc156/tasks/abc156_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, R;
  cin >> N >> R;

  if (N >= 10) drop(R);

  ll res = R + 100 * (10 - N);
  drop(res);
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

int main(){
    
  string row;
  int ac=0;
  int azc=0;
  
  cin>>row;
  
  for(int i=0;i<(int)row.size();i++){
    char ch=row[i];
  }
  for(int i=0;i<(int)row.size();i++){
    if(row[i]=='Z'&&ac==0)continue;
    if(row[i]=='A'){
      ac++;
    }
    if(row[i]=='Z'&&ac>0){
      azc++;
      ac=0;
    }
  }
  
    if(azc==0)cout<<-1<<endl;
   
    else for(int i=0;i<azc;i++){
      cout<<"AZ";
      if(i==azc-1)cout<<endl;
    }
  
  
  return 0;
  
}



Measured memory_bytes: 3224
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, P):
    ans = 0
    for i in range(N-2):
        if P[i] < P[i+1] < P[i+2]:
            ans += 1 
        elif P[i] > P[i+1] > P[i+2]:
            ans += 1
            

    return ans


def main():
    N = read_int()
    P = read_int_n()
    print(slv(N, P))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7484
def q2():
    import math
    n, d = map(int, input().split())
    points = [[int(v) for v in input().split()] for v in range(n)]

    res = [math.sqrt((x**2 + y**2)) <= d for x, y in points]
    print(sum(res))



if __name__ == "__main__":
    # q1()
    q2()


Measured memory_bytes: 43896
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int n,m,a,b,c,t,i;
V M(const V &x,const V &y){
	V z(n*n);
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(x[slice(i*n,n,1)]*y[slice(j,n,n)]).sum()%m;
	return z;
}
V E(const V &x,const int &n){
	if(n==1)return x;
	if(n&1)return M(E(x,n-1),x);
	V y=E(x,n>>1);
	return M(y,y);
}
V s,x;
void O(const V &r){
    for(i=0;i<n-1;i++)printf("%d ",(r[slice(i*n,n,1)]*s).sum()%m);
    printf("%d\n",(r[slice(i*n,n,1)]*s).sum()%m);
}
main(){
	for(;scanf("%d%d%d%d%d%d",&n,&m,&a,&b,&c,&t),n;){
		s.resize(n);
		for(i=0;i<n;i++)scanf("%d",&s[i]);
		x.resize(0);
		x.resize(n*n);
		if(t){
			x[0]=b;
			x[1]=c;
			for(i=1;i<n-1;i++){
				x[i*n+i-1]=a;
				x[i*n+i]=b;
				x[i*n+i+1]=c;
			}
			x[i*n+i-1]=a;
			x[i*n+i]=b;
			O(E(x,t));
		}else{
			for(i=0;i<n;i++)x[i*n+i]=1;
			O(x);
		}
	}
}

Measured memory_bytes: 1088
import math
from functools import reduce

def gcd(a):
    return reduce(math.gcd, a)

a=[0,0,0]
N = int(input())

wa=0
for i in range(1, N+1):
    a[0]=i
    for j in range(1,N+1):
        a[1]=j
        for k in range(1,N+1):
            a[2]=k
            
            wa=wa+gcd(a)

print(wa)


Measured memory_bytes: 69772
N, K = map(int, input().split())
As = list(map(int, input().split()))
Ns = {}
for A in As:
  if not(A in Ns):
    Ns[A] = 0
  Ns[A] += 1
Ns2 = sorted(Ns.values())
#print(Ns2)
if len(Ns2) <= K:
  print(0)
  exit()
r = sum(Ns2[:-K])
print(r)


Measured memory_bytes: 32188
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define f first
#define s second
#define pb push_back
#define pp push
#define RETURN exit(0)
#define pow(x,y) (int)(pow(x,y))
#define ceil(x) (int)(ceil(x))
#ifndef ONLINE_JUDGE
#define debug(x) cout<<x<<endl;
#else
#define debug(x) 42
#endif
const int MAX=1e4;
const int MOD=1e9+7;
const int MAAX=1e18;
const long double EPS=1e-6;
const int N=1e5+10;
int power(int x,int y)
{
    if (y == 0)
        return 1;
    int a=power(x,y/2);
    if (y % 2 == 0)
        return a * a % MOD;
    else
        return x * a * a % MOD;
}
bool check(int x){

}
int binary(int x,int y){
    int s=x,e=y,mid;
    while(s<e){
        mid=ceil((s+e)/2.0);
        if(check(mid))
            s=mid;
        else
            e=mid-1;
    }
    return s;
}
vector<int> primes;
bool visted[N+5];
void sieve(){
    visted[0]=visted[1]=1;
    for(int i=2;i*i<=N;i++){
        if(visted[i]==0){
            primes.pb(i);
            for(int j=i*i;j<=N;j+=i){
                visted[i]=1;
            }
        }
    }
    for(int i=sqrt(N)+1;i<=N;i++){
        if(visted[i]==0)
            primes.pb(i);
    }
    return;
}

pair<int,int> arr[100010];

in main()
{
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    int tc=1;
    //scanf("%lld",&tc);
    //sieve();
    while(tc--)
    {
        int n;
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>arr[i].f;
            arr[i].s=i+1;
        }
        sort(arr,arr+n);
        for(int i=0;i<n;i++){
            cout<<arr[i].s<<" \n"[i==n-1];
        }
    }
    ///matensa4 tegarab el sample w te7ot el freopen w te3mel SCANF
    RETURN;
}


Measured memory_bytes: 2432
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
struct A {
	int h, p;
	bool operator<(const A& a) {
		return h + p < a.h + a.p;
	}
};
A a[100000];
int dp[5005][5005];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i].h >> a[i].p;
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= n; j++) {
			dp[i][j] = Inf;
		}
		dp[i][0] = 0;
	}
	dp[0][1] = a[0].p;
	for (int i = 1; i < n; i++) {
		for (int j = 1; j <= i + 1; j++) {
			dp[i][j] = dp[i - 1][j];
			if (dp[i - 1][j - 1] > a[i].h) continue;
			dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + a[i].p);
		}
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		if (dp[n - 1][i] < Inf) ans = i;
		else break;
	}
	cout << ans << endl;
}

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

int main()
{
  int N; cin >> N;
  long A[200005];
  long total_len = 0;
  for (int i = 1; i <= N; i++)
  {
    cin >> A[i];
  }
  
  long half1 = 0, half2 = 0;
  int cnt = 0, i = 1, j = N;
  
  while (cnt < N)
  {
    if (half1 <= half2)
    {
      half1 += A[i];
      cnt++;
      i++;
    }
    else // (half1 > half2)
    {
      half2 += A[j];
      cnt++;
      j--;
    }
  }
  
  cout << abs(half1 - half2) << endl;
  return 0;
}

Measured memory_bytes: 1792
n = int(input())
a_list = sorted(list(map(int, input().split())))
 
a_i_index = len(a_list) - 1
a_i = a_list[-1]
max = 0
max_j_index = None
 
nobori = True
 
tmp = a_list[0]
koeta = None
for j_index in range(n):
    if a_list[j_index] * 2 > a_i:
        koeta = j_index
        break
    else:
        tmp = j_index
 
comb2 = 0
if n == 2:
    print(*[a_list[1], a_list[0]])
elif koeta == 0:
    print(*[a_i, a_list[koeta]])
elif (a_list[koeta]- a_i/2) > (a_i/2 - a_list[koeta-1]):
    print(*[a_i,a_list[koeta-1]])
else:
    print(*[a_i, a_list[koeta]])

Measured memory_bytes: 62704
#include<stdio.h>
int main (void){
  int kame,turu,x,y,i,j,ans=0;;
  scanf("%d%d",&x,&y);
  //総当たり
  /*
  for(kame=0;kame<=x;kame++){
    turu=x-kame;
    if(kame*4+turu*2==y){ans=1;}
    
  }
  if(ans==1){printf("Yes\n");}
  else{printf("No\n");}
  */
  //条件を求める
  if(y%2==0&&(x*2<=y&&y<=x*4)){printf("Yes\n");}
  else{printf("No\n");}
  
  return 0;
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
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;
}

int main() {
  Int n, m;
  cin >> n >> m;
  vector<Int> as(n), bs(n);
  for (Int i = 0; i < n; i++) cin >> as[i] >> bs[i];

  vector<vector<Int> > G(m + 1);
  for (Int i = 0; i < n; i++)
    if (as[i] <= m) G[m - as[i]].emplace_back(bs[i]);

  Int ans = 0;
  priority_queue<Int> pq;
  for (Int i = m; i >= 0; i--) {
    for (Int x : G[i]) pq.emplace(x);
    if (!pq.empty()) {
      ans += pq.top();
      pq.pop();
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9900
void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], a = tmp[1], b = tmp[2];
    min(a*n, b).writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using G = vector<vector<int>>;
    
template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

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

    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 21720
<?php
$N = intval(trim(fgets(STDIN)));
$A = array_map("intval", explode(" ", trim(fgets(STDIN))));
$B = array_map("intval", explode(" ", trim(fgets(STDIN))));
$dp = array_fill(0, 1<<$N, array_fill(0,51,PHP_INT_MAX));
$dp[0][0] = 0;
for($bit = 0, $NN = 1<<$N; $bit < $NN; ++$bit){
    $con = 0;
    $x = $bit;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
     
    $ords = [];
    $iter = $con - 1;
    for($i = 0; $i < $N; ++$i)
        if(!($bit & (1<<$i)))
            $ords[$i] = ++$iter;
    for($s = 0; $s <= 50; ++$s){
        if($dp[$bit][$s] == PHP_INT_MAX)continue;
        foreach($ords as $p0 => $p1){
            $ns = ($p0-$con) & 1 ? $B[$p0] : $A[$p0];
            if($ns >= $s){
                $nb = $bit | (1<<$p0);
                $dp[$nb][$ns] = min($dp[$nb][$ns], $dp[$bit][$s] + abs($p1 - $con));
            }
        }
    }
}
$min = min($dp[(1<<$N)-1]);
if($min == PHP_INT_MAX){
    echo -1;
}else{
    echo $min;
}


Measured memory_bytes: 682488
package main

import (
	"fmt"
	"strings"
)

func main() {
	var (
		n, k int
		s    string
	)
	fmt.Scan(&n, &s, &k)

	r := rune(s[k-1])

	for i, v := range s {
		if v != r {
			s = strings.Replace(s, string(s[i]), "*", 1)
		}
	}

	fmt.Println(s)
}


Measured memory_bytes: 640
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    num = ord(input())
    if num >= 65 and num <= 90:
        print('A')
    else:
        print('a')

if __name__ == '__main__':
    main()

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

int main(){
  ll A,B,C;cin >> A >> B >> C;
  if(C<A+B){
    cout << "No" << endl;
    return 0;
  }
  if(4*A*B<(C-A-B)*(C-A-B)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;

int main() {
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    
    int ans = 0;
    for (int i=0; i<n-1; i++)
        ans = max(a[i+1] - a[i], ans);
    cout << k-max(ans, k-a[n-1]+a[0]) << endl;
}


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

#define int long long 
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define lbound lower_bound 
#define ubound upper_bound
#define pqueue priority_queue
#define umap unordered_map
#define uset unordered_set
#define len(a) (int)a.size()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using namespace std ;

using vi   = vector<int> ;
using vvi  = vector<vi> ;
using pii  = pair<int,int> ;
using vpii = vector<pii>  ;
using mii  = map<int, int>;
using umii = umap<int, int>; 

template<class T> bool mini(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool maxi(T &a, T b) { return a < b ? (a = b, true) : false; }

int32_t main(){
    ios::sync_with_stdio(false); 
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("D:/Coding/in.txt", "r", stdin);
    freopen("D:/Coding/out.txt", "w", stdout);
#endif
    int n ;
    cin >> n;
    vi a(n);
    for (int i = 0; i < n; ++i)
         cin >> a[i];
    sort(all(a));
    int mid = n / 2;
    if(a[mid] == a[mid - 1]){
         cout << 0 ; 
    } else{
         cout << a[mid] - a[mid - 1];
    }


#ifndef ONLINE_JUDGE  
    cerr << "\n\nTime elapsed: " << 1.0 * clock() /CLOCKS_PER_SEC<< " s.\n";
#endif
    return 0;
}

Measured memory_bytes: 3992
n = int(input())
a = list(map(int,input().split()))
x = 0
for i in range(n):
    if a[i]<0:
        x += 1
for i in range(n):
    a[i]=abs(a[i])


if x%2 == 0:
    print(sum(a))
else:
    m = min(a)
    print(sum(a)-2*m)

Measured memory_bytes: 14332
<?php
// B
fscanf(STDIN, '%d %d', $n, $m);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
rsort($a);
$sum = array_sum($a);
for ($i = 0; $i < $n; $i++) {
    if ($a[$i] < $sum * 1 / (4 * $m)) {
        $i--;
        break;
    }
}
echo ($i + 1 >= $m) ? 'Yes' : 'No';

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

int main()
{
    int N, M;
    cin >> N;
    vector<string> blue(N);
    vector<string> red(M);
    rep(i, N) cin >> blue.at(i);
    cin >> M;
    rep(i, M) cin >> red.at(i);
    int ans = 0;
    rep(i, N)
    {
        int tmp = 0;
        string word = blue.at(i);
        rep(j, N) if (word == blue.at(j)) tmp++;
        rep(j, M) if (word == red.at(j)) tmp--;
        ans = max(ans, tmp);
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int k;
  cin >> k;
  long long ans = 0;
  for (int a = 1; a <= k; a++) for (int b = 1; b <= k; b++) for (int c = 1; c <= k; c++) {
    ans += gcd(a, gcd(b, c));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
struct stu{
	int start,end;
}arr[N];
int ans[N];
int main(){
	memset(ans,0,sizeof(ans));
	string s;
	cin>>s;
	int n=s.length();
	bool flag=false ;
	int pos=0;
	for(int i=0;i<n ;i++){
		if(s[i]=='R'){
			if(!flag){
				arr[++pos].start=i;
				arr[pos].end=i;
				flag=true;
			}
			else arr[pos].end=i;
		}
		else	flag=false ;
	}
	arr[pos+1].start=n;
	for(int i=1;i<=pos;i++){
		int disr=arr[i].end-arr[i].start+1;//r的长度
		int disl=arr[i+1].start-arr[i].end-1;
		if(disr&1){
			ans[arr[i].end]+=disr/2 +1;
			ans[arr[i].end+1]+=disr/2;
		}
		else {
			ans[arr[i].end]+=disr/2;
			ans[arr[i].end+1]+=disr/2;			
		}
		if(disl&1){
			ans[arr[i].end]+=disl/2;
			ans[arr[i].end+1]+=disl/2+1;			
		}
		else {
			ans[arr[i].end]+=disl/2;
			ans[arr[i].end+1]+=disl/2;
		}
	}
	for(int i=0;i<n;i++) cout<<ans[i]<<" ";
	
	return 0;
} 

Measured memory_bytes: 1408
n, k = map(int, input().split())
h = list(map(int, input().split()))

def frog(n, k, h):
    import math
    d = [float('inf')] * n
    d[0] = 0
    
    for i in range(1, n):
        
        d[i] = min(d[j] + abs(h[i] - h[j]) for j in range(max(i-k, 0), i))
    return d[n-1]
    
print(frog(n, k, h))

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

using namespace std;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    n%=10;
    if(n==3){
        cout << "bon" << endl;
    }else if(n==0||n==1||n==6||n==8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
  ll a[3],k;
  cin>>a[0]>>a[1]>>a[2]>>k;
  sort(a,a+3);
  cout<<a[0]+a[1]+a[2]*(1<<k)<<endl;
  return 0;
}

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

const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int d[200000];
int main(){
	int n;cin>>n;
	rep(i,n)scanf("%d",&d[i]);
	if(d[0]!=0){
		puts("0");return 0;
	}
	sort(d,d+n);
	int cur=0,cnt=1;
	int ncnt=0;
	ll ans=1;
	for(int i=1;i<n;i++){
		if(d[i]==cur+1){
			(ans*=cnt)%=MOD;
			ncnt++;
		}
		else if(d[i]==cur+2){
			cur++;
			cnt=ncnt;
			ncnt=1;
			(ans*=cnt)%=MOD;
		}
		else{
			puts("0");return 0;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<pii,int> ppiii ;
typedef unsigned long long ull ;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
vi p;
int main(){
	ll x;
	cin>>x;
	ll hoge=x/(ll)11;
	hoge=hoge*(ll)2;
	ll a=x%11;
	if(a>=1&&a<=6)hoge++;
	else if(a>6)hoge+=2;
	cout<<hoge<<endl;
	
	
}

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

using namespace std;

int main() {
	int a[4] = {0, 0, 0, 0};
	for (int i = 0; i < 6; i++) {
		int x;
		cin >> x;
		a[x - 1] += 1;
		if (a[x - 1] == 3) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
int gcd(int a, int b);
using namespace std;
int main() {

	int x;
	cin >> x;
	cout << 360 / gcd(360, x) << endl;

	return 0;
}
int gcd(int a, int b) {
	if (a == 0) {
		return b;
	}
	else if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}



Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>

using namespace std;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Vsort(a) sort(a.begin(), a.end())
#define rep(i,n) for(int i = 0; i < (n); i++)
#define Srep(i,a,n) for(int i = (a); i < (n); i++)
#define ll long long
#define P pair<int, int>
using namespace std;

int main(){
  int k,a,b,judge=0;
  cin >> k >> a >> b;
  for(int i = a; i < b + 1; i++){
    if(i % k == 0) judge++;
  }
  if(judge != 0) cout << "OK" << endl;
  else cout << "NG" << endl;
}


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

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    int M, N;
    unsigned long sum{0};
    std::vector<unsigned long> A;
    std::cin >> N >> M;
    
    for(int i = 0 ; i < N ; i++){
        unsigned long a;
        std::cin >> a;
        sum += a;
        A.push_back(a);
    }
    std::sort(A.begin(), A.end(), std::greater<int>());
    for(int i = 0 ; i < M ; i++){
        if( 4 * M *A[i] < sum){
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;
    return 0;
}

Measured memory_bytes: 256
def getIsPrimes(n):
    isPrimes = [False]*2 + [True]*(n-1)
    for i in range(2, int(n**0.5)+1):
        if isPrimes[i]:
            for x in range(i*i, n+1, i):
                isPrimes[x] = False
    return isPrimes

X = int(input())

isPrimes = getIsPrimes(10**6)

for i in range(X, 10**6):
    if isPrimes[i]:
        print(i)
        break


Measured memory_bytes: 18676
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;int i;
    cin>>a;
    b=a;
    reverse(a.begin(),a.end());
    for(i=0;i<a.size();++i)
    {
        if(a[i]=='b')a[i]='d';
        else if(a[i]=='d')a[i]='b';
        else if(a[i]=='p')a[i]='q';
        else if(a[i]=='q')a[i]='p';
    }
    if(a==b)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 512
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  n <- readLn
  txys <- map (map readInt . BS.words) . BS.lines <$> BS.getContents
  putStrLn $ if solve n txys then "Yes" else "No"

solve :: Int -> [[Int]] -> Bool
solve _ txys = all travelable $ zip ([0, 0, 0]:txys) txys

travelable :: ([Int], [Int]) -> Bool
travelable ([t, x, y], [t', x', y']) = dx + dy <= dt && even (dt - dx - dy) where
  dx = x' - x
  dy = y' - y
  dt = t' - t

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt


Measured memory_bytes: 4348
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<double> p(n);
  for(int i=0;i<n;i++){
    cin>>p.at(i);
    p.at(i)=(p.at(i)+1)/2;
  }
  double s=0;
  for(int i=0;i<k;i++)
    s+=p.at(i);
  double m=s;
  for(int i=k;i<n;i++){
    s=s-p.at(i-k)+p.at(i);
    m=max(m,s);
  }
  cout<<fixed<<setprecision(10);
  cout<<m<<endl;
}

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

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  cin >> n;
  cout << n*n;
  return 0;
} //good night.

Measured memory_bytes: 256
n = int(input())
s = input()

ans = 0

suji = str(0)

for i in range(1000):
    if i <= 9:
        suji = '00' +str(i)
    elif i <= 99:
        suji = '0' + str(i)
    else:
        suji = str(i)
    keta = 0
    for j in range(n):
        if keta == 3:
            ans += 1
            break
        if s[j] == suji[keta]:
            keta += 1
            if keta == 3:
                ans += 1
                break
            
print(ans)

Measured memory_bytes: 41292
#include <iostream>
using namespace std;
int main()
{
	int n[5], k;
	for (int i = 0; i < 5; i++)cin >> n[i];
	cin >> k;
	for (int i = 0; i < 5; i++)
	{
		for (int j = 1; j < 5; j++)
		{
			if (n[j] - n[i] > k)
			{
				cout << ":(" << endl;
				exit(0);
			}
		}
	}
	cout << "Yay!" << endl;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

bool city_smaller_point_greater(const pair<string,int>& left, const pair<string,int>& right) {
    if (left.first==right.first) return left.second > right.second;
    else return left.first < right.first;
}

int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    int N; cin >> N;
    vs S(N);vi P(N);
    REP(i, N) cin >> S[i] >> P[i];

    map<int, int> mp;
    REP(i,N) {
        mp[P[i]] = i + 1;
    }

    vector<pair<string, int>> r;
    REP(i, N) r.push_back(pair<string, int>(S[i], P[i]));

    sort(r.begin(), r.end(), city_smaller_point_greater);

    for (auto p : r) { 
        cout << mp[p.second] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;

    char S[H][W];
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cin >> S[i][j];
        }
    }

    int Tate[H][W], Yoko[H][W];

    for (int i = 0; i < H; i++){
        int count = 0;
        int start = 0, end = 0;

        for (int j = 0; j < W; j++){
            if (S[i][j] == '.'){
                count ++;

                if (j == W - 1){
                    for (int k = start; k < W; k++){
                        Yoko[i][k] = count;
                    }
                }
            }else{
                end = j - 1;
                for (int k = start; k <= end; k++){
                    Yoko[i][k] = count;
                }
                Yoko[i][j] = 0;
                count = 0;
                start = j + 1;
            }
        }
    }

    for (int i = 0; i < W; i++){
        int count = 0;
        int start = 0, end = 0;

        for (int j = 0; j < H; j++){
            if (S[j][i] == '.'){
                count ++;

                if (j == H - 1){
                    for (int k = start; k < H; k++){
                        Tate[k][i] = count;
                    }
                }
            }else{
                end = j - 1;
                for (int k = start; k <= end; k++){
                    Tate[k][i] = count;
                }
                Tate[j][i] = 0;
                count = 0;
                start = j + 1;
            }
        }
    }

/*
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cout << Tate[i][j];
        }
        cout << endl;
    }
    
    cout << endl;

    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cout << Yoko[i][j];
        }
        cout << endl;
    }

*/


    int ans = 0;
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            if (Tate[i][j] + Yoko[i][j] - 1 > ans){
                ans = Tate[i][j] + Yoko[i][j] - 1;
            }
        }
    }
    cout << ans << endl;
    


    return 0;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	char b;
	cin>>b;
	map<char,char> mp;
	mp['A'] = 'T';mp['T'] = 'A';mp['C'] = 'G';
	mp['G'] = 'C'; 
	cout<<mp[b]<<endl;
}

Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 


int main(){

	int n,k;
	cin>>n>>k;

	vector<int> d(10);
	for(int i=0;i<k;i++){
		int x;
		cin>>x;
		d[x]++;
	}

	for(int i=n;;i++){
		string s=to_string(i);
		bool ok=true;
		for(int j=0;j<s.size();j++){
			if( d[s[j]-'0'] ) ok=false;
		}
		if(ok){
			cout<<i<<endl;
			break;
		}
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    
    int N,B,A;
    cin >> N >> A >> B;
    if(N*A>B){
        cout << B << endl;
    }else{
        cout << A*N << endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 256
n, k = [int(i) for i in input().split()]
w = []
for ni in range(n):
    w.append(int(input()))

def countPackages(P):
    i = 0
    for ki in range(k):
        sum = 0
        while i < n and sum + w[i] <= P:
            sum += w[i]
            i += 1
    return i

P_min = 0
P_max = 100000 * 10000
while P_min < P_max:
    P = (P_max + P_min)//2
    if countPackages(P) < n:
        P_min = P + 1
    else:
        P_max = P
print(P_min)



Measured memory_bytes: 9564
/*
  Author - KISHAN TIWARI
  Dream bigger. Do bigger.
  Wake up with determination. Go to bed with satisfaction.
*/
//Sometimes later becomes never. Do it now.
#include<bits/stdc++.h>
using namespace std;
#define ll           long long
#define f(i,a,b)     for(ll i=a;i<b;i++)
#define mod          1000000007
#define fi           first
#define se           second
#define pa           pair <ll,ll>
#define mp           make_pair
#define pb           push_back
#define ve           vector<ll>
#define vep          vector< pa >
#define all(a)       a.begin(), a.end()
#define sz(x)        (ll)x.size()
#define c(t)         cout<<t<<"\n"
using namespace std;
void solve()
{  ll n;
cin>>n;
ll a[n];
f(i,0,n)
cin>>a[i];
for(ll i=n-1;i>=1;i--)
{
    if(a[i-1]-a[i]==1)
        a[i-1]=a[i-1]-1;
}
ll g=0;
f(i,0,n-1)
{
    if(a[i]>a[i+1])
    {
        g=2;
        break;
    }
}
if(g==0)
    cout<<"Yes\n";
else
    cout<<"No\n";
}
int main()
{
    ios::sync_with_stdio(true);
   //freopen ("input.txt","r",stdin);
   //freopen ("output.txt","w",stdout);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {

        solve();
    }
return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int sum(int n,int m,int i,int k){
    int a,l;
    if(n == 0){
        if(m == 0){return 1;}
        else{return 0;}
    }
    else{
        l = k;
        for(a=i+1;a<10;a++){
            if(m-a>=0){k+=sum(n-1,m-a,a,l);}
        }
    }
    return k;
}
int main(){
    int low[10];
    int k,n,m,i;
    for(;;){
        scanf("%d %d",&n,&m);
        if(n == 0 && m == 0){break;}
        k = 0;
        for(i=0;i<10;i++){
            if(m-i>=0){k += sum(n-1,m-i,i,0);}
        }
        printf("%d\n",k);
    }
    return 0;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if (a == b)
    {
        cout << c << endl;
    }
    else if (b == c)
    {
        cout << a << endl;
    }
    else if (c == a)
    {
        cout << b << endl;
    }
}

Measured memory_bytes: 256
n,m = map(int, input().split())
if m==1:
    print(1)
    exit()
def fact(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

def find_power(n,mod=10**9+7):
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist
def find_inv_power(n,mod=10**9+7):
    powlist=find_power(n)
    check=powlist[-1]
    first=1
    uselist=[0]*(n+1)
    secondlist=[0]*30
    secondlist[0]=check
    secondlist[1]=check**2
    for i in range(28):
        secondlist[i+2]=(secondlist[i+1]**2)%(10**9+7)
    a=format(10**9+5,"b")
    for j in range(30):
        if a[29-j]=="1":
            first=(first*secondlist[j])%(10**9+7)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(10**9+7)
    return uselist

mod = 10**9+7
NUM = (4*10**5)+100
p_lis=find_power(NUM,mod)
ip_lis=find_inv_power(NUM,mod)

def comb(n,r,mod=10**9+7):
    if n<r:
        return 0
    elif n>=r:
        return (p_lis[n]*ip_lis[r]*ip_lis[n-r])%(mod)

ans=1
for itm in fact(m):
    _, x = itm
    ans*=comb(x+n-1,n-1)
    ans%=mod

print(ans)

Measured memory_bytes: 84660
#include<bits/stdc++.h>
 using namespace std;
 
#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0)
#define mod                     1000000007
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define in(a,b)                 ( (b).find(a) != (b).end())
#define pb                      push_back
#define fill(a,v)               memset(a, v, sizeof a)
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define mp                      make_pair
#define minin(a)                *min_element (all(a))
#define maxin(a)                *max_element(all(a))
#define asort(c)                sort(all(c))
#define dsort(c)                sort(all(c), greater<int>()) 
typedef  long long                   ll;
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  set<int>                    si;
typedef  unordered_map<int, int>    mii;
typedef  vector<ll>                 vll;

const int N=2e5+5;
ll a[N],b[N];

int main()
{
  FIO;
  
  
 
  int n;
  cin>>n;
 
  rep(i,1,n)
  {
    cin>>a[i];
    b[i]=a[i]-i;
  }
  
  ll med;
  ll sum=0;
  sort(b+1,b+1+n);
  if(n&1)
  {
    med=b[n/2 + 1];
  }
  else
    med = (b[n/2]+b[n/2 + 1])/2;
  rep(i,1,n)
  {
    sum+=abs(b[i]-(med));
  }

  cout<<sum;

 return 0;
}

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

struct position{
    int y, x;
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int H, W, D;
    cin >> H >> W >> D;
    position number_position[H * W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            int num;
            cin >> num;
            number_position[num - 1] = {i, j};
        }
    }
    int need_magic_cost[H * W];
    for(int i = H * W - D; i < H * W; i++){
        need_magic_cost[i] = 0;
    }
    for(int i = H * W - D - 1; i >= 0; i--){
        need_magic_cost[i] = need_magic_cost[i + D] + abs(number_position[i].y - number_position[i + D].y) + abs(number_position[i].x - number_position[i + D].x);
    }
    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int left, right;
        cin >> left >> right;
        cout << need_magic_cost[left - 1] - need_magic_cost[right - 1] << endl;
    }
}


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

struct student
{
	int i;
	int ai;
};


student stu[100010];
bool cmp(student& a, student& b)
{
	return a.ai < b.ai;
}

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		stu[i].i = i + 1;
		cin >> stu[i].ai;
	}
	sort(stu, stu + n, cmp);
	for (int i = 0; i < n; i++)
	{
		cout << stu[i].i << " ";
	}
}

Measured memory_bytes: 1536