akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int n;
V< V< P<int, int> > > edges;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    edges.resize(n);
    V<int> deg(n, 0);
    int maxd = 0, maxi = -1;
    for (int i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b;
        a--, b--;
        edges[a].emplace_back(b, i);
        edges[b].emplace_back(a, i);
        deg[a]++, deg[b]++;
        if (chmax(maxd, deg[a])) maxi = a;
        if (chmax(maxd, deg[b])) maxi = b;
    }

    cout << maxd << '\n';
    V< set<int> > col(n);
    queue<int> que; que.push(maxi);
    V<int> ans(n - 1, -1);
    while (!que.empty()) {
        int q = que.front(); que.pop();
        int tmpc = 1;
        for (P<int, int> e: edges[q]) {
            if (ans[e.second] != -1) continue;
            while (col[q].find(tmpc) != col[q].end() || col[e.first].find(tmpc) != col[e.first].end()) tmpc++;
            ans[e.second] = tmpc;
            col[e.first].insert(tmpc);
            col[q].insert(tmpc);
            tmpc++;
            que.push(e.first);
        }
    }

    for (int i = 0; i < n - 1; i++) cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 21376
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////


int main() {
	ll N;
	cin >> N;

	vector<ll> A(N + 1);
	repn(i, N) cin >> A[i];

	//sort(++A.begin(), A.end());

	ll M = 150000;

	
	vector<vector<bool>> dp(N + 1, vector<bool>(2*M+1, 0));
	dp[0][M] = 1;

	repn(i, N) {
		rep(j, 2*M+1) {
			if (j > A[i] && dp[i - 1][j - A[i]]) { dp[i][j] = 1; }
			if (j + A[i] <= 2 * M&&dp[i - 1][j + A[i]]) { dp[i][j] = 1; }
		}
	}

	ll S = 0;
	repn(i, N)S += A[i];

	ll t = 0;
	rep(i, M+1) {
		if (dp[N][M + i]) { t = i; break; }
	}

	cout << (S + t) / 2 << endl;

	

	system("PAUSE");
}

Measured memory_bytes: 75776
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int  h1,h2,m1,m2;
    int k;
    cin>>h1>>m1>>h2>>m2>>k;
    h1 = h1*60+m1;
    h2 = h2*60+m2;
   int temp = h2-h1;
   int flag = (h2-h1)-k;
   if(flag < 0)
   {
       printf("0");
   }
   else
   {
       printf("%d",flag);
   }
    return 0;
}



Measured memory_bytes: 3748
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(LL x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(LL x){write(x);putchar('\n');}

const int MAX_N=20;
int bin[MAX_N];
#define pr pair<int,int>
#define FR first
#define SE second
#define MP make_pair
int a[1<<MAX_N];pr b[1<<MAX_N];
int gmax(int x,int y){return a[x]>a[y]?x:y;}
pr merge(pr x,pr y)
{
	if(a[x.FR]>a[y.FR]) return MP(x.FR,gmax(x.SE,y.FR));
	else return MP(y.FR,gmax(x.FR,y.SE));
}
void fwt(int n)
{
	for(int i=0;i<n;i++)
		for(int j=bin[n]-1;j>=0;j--) if(j&bin[i])
				b[j]=merge(b[j],b[j^bin[i]]);
}
int main()
{
	bin[0]=1;for(int i=1;i<MAX_N;i++) bin[i]=bin[i-1]<<1;
	
	int n;scanf("%d",&n);a[bin[n]]=0;
	for(int i=0;i<bin[n];i++) scanf("%d",&a[i]),b[i]=MP(i,bin[n]);
	fwt(n);
	int lst=0;
	for(int i=1;i<bin[n];i++)
	{
		lst=max(a[b[i].FR]+a[b[i].SE],lst);
		printf("%d\n",lst);
	}
}
/*
4
75 26 45 72 81 47 97 97 2 2 25 82 84 17 56 32
*/


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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int A,B; cin >> A >> B;
    int ans = 0;

    for (int n = A; n <= B; n++) {
        if (n/10000==n%10 && (n/1000)%10==(n/10)%10) {
            //cout << n << endl;
            ans++;
        }
    }

    cout << ans << endl;

}


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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define int long long

using namespace std;
using P = pair<int, int>;
using ll = long long;
const ll INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

bool isprime(int x){
	rep(i,1,sqrt(x)+1)if(gcd(i,x)!=1)return false;
	return true;
}

signed main(){
    int x;
	cin>>x;
	while(1){
		if(isprime(x)){
			cout<<x<<endl;
			break;
		}
		x++;
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

char s[3][2001];
int n[3];
int f[3][3][2000];

void calc(int x, int y) {
    int i, j;
    
    for (i = 0; i <= n[x]; i++) {
        f[x][y][i] = 1;
        
        for (j = 0; i + j < n[x] && j < n[y]; j++) {
            if (s[x][i + j] == '?') continue;
            if (s[y][j] == '?') continue;
            if (s[x][i + j] != s[y][j]) {
                f[x][y][i] = 0;
                break;
            }
        }
    }
}

bool check(int x, int y, int z, int p, int q) {
    if (f[x][y][p] == 0) return false;
    if (q <= n[x] && f[x][z][q] == 0) return false;
    if (q - p <= n[y] && f[y][z][q - p] == 0) return false;
    return true;
}

int get(int x, int y, int z) {
    int ans = 1e9, i, j;
    
    for (i = 0; i <= n[x]; i++) {
        for (j = i; j <= max(n[x], i + n[y]); j++) {
            if (check(x, y, z, i, j)) ans = min(ans, max(n[x], max(i + n[y], j + n[z])));
        }
    }
    
    return ans;
}

int main() {
    int ans = 1e9, i, j;
    vector <int> v;
    
    for (i = 0; i < 3; i++) {
        scanf("%s", s[i]);
        
        n[i] = strlen(s[i]);
    }
    
    for (i = 0; i < 3; i++) {
        for (j = 0; j < 3; j++) {
            if (i == j) continue;
            
            calc(i, j);
        }
    }
    
    for (i = 0; i < 3; i++) v.push_back(i);
    
    do {
        ans = min(ans, get(v[0], v[1], v[2]));
    } while (next_permutation(v.begin(), v.end()));
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
//#pragma GCC optimize(2)

using namespace std;

#define LL long long
#define Re register
#define U unsigned
#define forn(i,a,b) for(int i = a;i <= b;++i)
#define nfor(i,a,b) for(int i = a;i >= b;--i)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define pb push_back
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dirx[8]={1,0,-1,0,1,-1,-1,1};
int diry[8]={0,1,0,-1,1,1,-1,-1};

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    int k,x;
    cin>>k>>x;
    for(int i=x-k+1;i<=x+k-1;i++)
        cout<<i<<" ";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define INFTY 1000000001
void mergeSort(int [],int,int);
void merge(int [],int,int,int);
int count = 0;
int A[500002];
int L[250001];
int R[250001];

int main(){
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    mergeSort(A,0,n);
    for(i=0;i<n;i++){
        if(i<n-1) printf("%d ",A[i]);
        else printf("%d\n",A[i]);
    }
    printf("%d\n",count);
    return 0;
}
void merge(int A[],int left,int mid,int right){
    int n1,n2,i,j,k;
    n1 = mid - left;
    n2 = right - mid;
    for(i=0;i<n1;i++){
        L[i] = A[left + i];
    }
    for(i=0;i<n2;i++){
        R[i] = A[mid+i];
    }
    L[n1] = INFTY;
    R[n2] = INFTY;
    i = 0;
    j = 0;
    for(k = left;k<right;k++){
        if(L[i] <= R[j]){
            A[k] = L[i];
            i = i + 1;
            count++;
        }
        else{
            A[k] = R[j];
            j = j + 1;
            count++;
        }
    }
}
void mergeSort(int A[],int left,int right){
    int mid;
    if(left+1 < right){
        mid = (left + right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}


Measured memory_bytes: 5644
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int m1,m2,d1,d2;
	cin>>m1>>d1;
	cin>>m2>>d2;
	int m[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	if(d1==m[m1-1])
	{
		cout<<"1";
	}
	else
	{
		cout<<"0";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            map.compute(a, (k, v) -> v == null ? 1 : v + 1);
        }

        int res = 0;
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            int key = entry.getKey();
            int value = entry.getValue();
            if (key < value) {
                res += value - key;
            } else if (key > value) {
                res += value;
            }
        }
        System.out.println(res);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 66448
#include<stdio.h>
//小さい順にソート
long long int c[200010];
void merge(long long i,long long j,long long int *s){
  if(i!=j){
    merge(i,(i+j)/2,s);
    merge((i+j)/2+1,j,s);
    long long a=i,b=(i+j)/2+1;
    long long d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        c[d]=s[b];
        b++;
      }
      else if(j<b){
        c[d]=s[a];
        a++;
      }
      else if(s[a]<s[b]){
        c[d]=s[a];
        a++;
      }
      else{
        c[d]=s[b];
        b++;
      }
    }
    for(d=i;d<=j;d++)
      s[d]=c[d];
  }
}

int main(){
  long long n;
  scanf("%lld",&n);
  long long i,j,a[n+2],l[n+2],r[n+2],count=0;
  for(i=1;i<=n;i++){
    scanf("%lld",&a[i]);
    l[i]=a[i]+i;
    r[i]=i-a[i];
  }
  merge(1,n,l);
  merge(1,n,r);
  i=1;
  j=1;
  while(i<=n && j<=n){
    if(l[i]>r[j])
      j++;
    else if(l[i]<r[j])
      i++;
    else{
      long long lnum=1,rnum=1;
      i++;
      j++;
      while(l[i]==l[i-1] && i<=n){
        lnum++;
        i++;
      }
      while(r[j]==r[j-1] && j<=n){
        rnum++;
        j++;
      }
      count+=lnum*rnum;
    }
  }
  printf("%lld\n",count);
  return 0;
}


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define INF2 (1e18)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long mod = 998244353;

int main(){
    int n;
    cin >> n;
    vi d(n);
    rep(i, n) cin >> d[i];
    rep(i, n) {
        if ((i==0&&d[i]!=0) || (i>0&&d[i]==0)) {
            cout << 0 << endl;
            return 0;
        }
    }
    vi cnt(n);
    rep(i, n) cnt[d[i]]++;
    ll ans = 1;
    rep1(i, n-1) {
        rep(j, cnt[i]) ans = ans * cnt[i-1] % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3976
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000007;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int p, q, r;

  cin >> p >> q >> r;

  cout << min(p + q, min(p + r, q + r)) << endl;
  return 0;
}



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



public class Main {
	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int n=fs.nextInt();
		
		if(n == 0) {
			System.out.println(1);
		} else if (n == 1 ) {
			System.out.println(0);
		} else {
			
		}
	}
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

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

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

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


Measured memory_bytes: 32608
# coding:UTF-8
import sys
from math import factorial

MOD = 10 ** 9 + 7
INF = float('inf')

N = int(input())    # 数字
S = input()     # 文字列

res = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            src = i
            num = 0
            for s in S:
                if int(s) == src:
                    if num == 0:
                        src = j
                        num = 1
                    elif num == 1:
                        src = k
                        num = 2
                    elif num == 2:
                        res += 1
                        break

print("{}".format(res))


Measured memory_bytes: 68504
# ABC141D - Powerful Discount Tickets
from heapq import heapify, heappop, heappush
pop_max, push_max = lambda A: -heappop(A), lambda A, x: heappush(A, -x)


def main():
    N, M, *A = map(int, open(0).read().split())
    H = [-i for i in A]
    heapify(H)
    for _ in range(M):
        x = pop_max(H)
        push_max(H, x // 2)
    ans = -sum(H)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14180
import java.util.Scanner;
import java.util.TreeSet;

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

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		TreeSet<Integer> list = new TreeSet<Integer>();

		for(int i = 0; i < n; i++) {
			int a = scan.nextInt();
			int b = scan.nextInt();

			switch(a) {
			
			case 0:
				list.add(b);
				System.out.println(list.size());
				break;

			case 1:
				System.out.println(list.contains(b) ? "1" : "0");
				break;
				
			case 2:
				list.remove(b);
				break;
				
			case 3:
				int c = scan.nextInt();
				list.subSet(b, true, c, true).forEach(d -> System.out.println(d));
//				for(int value : list) {
//					System.out.println(value);
//				}
//				list.subSet(b, true, c, true);
				break;
			}
		}
	}
}



Measured memory_bytes: 187268
n,t=map(int, input().split())
keiro_list=[]
for i in range(n):
  keiro=list(map(int, input().split()))
  if keiro[1] <= t:
    keiro_list.append(keiro)

if len(keiro_list)==0:
  print('TLE')
else:
  keiro_list = sorted(keiro_list)
  print(keiro_list[0][0])
    

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

int main(int argc, char const *argv[]) {
    int n, d;
    cin >> n >> d;
    vector<vector<int> > x(n, vector<int>(d));
    for (int i = 0; i < n; i++) for (int j = 0; j < d; j++) cin >> x[i][j];

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            int dist = 0;
            for (int k = 0; k < d; k++) {
                dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            for (int l = 1; l*l <= dist; l++) {
                if (l*l == dist) ans++;
            }
        }
    }

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


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

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

using ll = long long;
using ull = unsigned long long;

int main() {
  string s, op, p;
  int a, b, q;
  cin >> s >> q;
  rep(i, q) {
    cin >> op;
    if (op == "print") {
      cin >> a >> b;
      cout << s.substr(a, b - a + 1) << endl;
    }
    if (op == "reverse") {
      cin >> a >> b;
      string rev_s = s.substr(a, b - a + 1);
      reverse(rev_s.begin(), rev_s.end());
      s = s.substr(0, a) + rev_s + s.substr(b + 1, s.size() - b);
    }
    if (op == "replace") {
      cin >> a >> b >> p;
      s = s.substr(0, a) + p + s.substr(b + 1, s.size() - b);
    }
  } 
  return 0;
}



Measured memory_bytes: 3204
H, W, D = [int(i) for i in input().split()]
B = [(-1, -1) for _ in range(H * W)]
for h in range(H):
    A = [int(i) - 1 for i in input().split()]
    for w in range(W):
        B[A[w]] = (h, w)

C = [0] * (H * W)
for i in range(D, H * W):
    h, w = B[i - D]
    nh, nw = B[i]
    C[i] = C[i - D] + abs(nh - h) + abs(nw - w)

Q = int(input())
for l, r in [[int(i) - 1 for i in input().split()] for _ in range(Q)]:
    print(C[r] - C[l])


Measured memory_bytes: 32412
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int main() {
    int w,h,n;
    cin>>w>>h>>n;
    int x[n],y[n],a[n];
    for(int i=0;i<n;++i) {
        cin>>x[i]>>y[i]>>a[i];
    }
    int l=0,r=w,b=0,t=h;
        for(int i=0;i<n;++i){
            switch(a[i]){
                case 1:
                    if(l<x[i]) l=x[i];
                    break;
                case 2:
                    if(x[i]<r) r=x[i];
                    break;
                case 3:
                    if(b<y[i]) b=y[i];
                    break;
                case 4:
                    if(y[i]<t) t=y[i];
                    break;
            }
        }
    int s=(r-l)*(t-b);
    if(r-l>0&&t-b>0){
        cout<<s<<endl;
    }else{cout<<0<<endl;
        
    }
    return 0;
}

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

static const double EPS = 1e-9;
static const int MOD = 256;

int I[257];
int R[257];
int O[257];

int main(){
  int N;

  while(cin >> N && N){
    for(int i = 1; i <= N; i++){
      cin >> I[i];
    }
    
    int ansS, ansA, ansC;
    double ansH = 100000000.0;

    for(int S = 0; S <= 15; S++){
      for(int A = 0; A <= 15; A++){
        for(int C = 0; C <= 15; C++){
          
          double H = 0;
          R[0] = S;
          memset(O, 0, sizeof(O));
          
          for(int i = 1; i <= N; i++){
            R[i] = (A * R[i - 1] + C) % MOD;
            O[ (I[i] + R[i]) % MOD ]++;
          }

          for(int i = 0; i < 256; i++){
            if(O[i] != 0) H -= (O[i] / (double)(N) * log(O[i] / (double)(N)));
          }
          
          if(H + EPS < ansH){
            ansH = H;
            ansS = S;
            ansA = A;
            ansC = C;
          }
        }
      }
    }

    cout << ansS << ' ' << ansA << ' ' << ansC << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1204
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { 
        sc.nextInt()
     }

     abc155b(a)
}

fun abc155b(a: List<Int>) {
    var ans = "APPROVED"

    var ok = false
    a.filter { it % 2 == 0 }.forEach { 
        if (it % 3 != 0 && it % 5 != 0) {
            ok = true
        }
    }
    if (ok) {
        ans = "DENIED"
    }


    println(ans)
}


Measured memory_bytes: 31524
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="SUN")	printf("7\n");
	else if(s=="MON")	printf("6\n");
	else if(s=="TUE")	printf("5\n");
	else if(s=="WED")	printf("4\n");
	else if(s=="THU")	printf("3\n");
	else if(s=="FRI")	printf("2\n");
	else	printf("1\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define For(i, s, e) for(int i = s;i <= e;i++)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;



int main() {
    int k,a,b;cin >> k >> a >>b;
    bool f = false;
    For(i,a,b) {
        if(i%k == 0) f = 1;
    }
    if(f)cout << "OK";
    else cout << "NG";
}


Measured memory_bytes: 3632
class Tree
	def initialize(key)
		@key = key
		@left = nil
		@right = nil
	end

	def insert(k)
		if @key > k
			if !@left
				@left = Tree.new(k)
			else
				@left.insert(k)
			end

		else
			if !@right
				@right = Tree.new(k)
			else
				@right.insert(k)
			end
		end
	end

	def inorder(list)
		if @left
			list = @left.inorder(list)
		end
		list << @key
		if @right
			list = @right.inorder(list)
		end
		list
	end

	def preorder(list)
		list << @key
		if @left
			list = @left.preorder(list)
		end
		if @right
			list = @right.preorder(list)
		end
		list
	end

	def find(key,bool)
		if @key == key
			bool = "yes"
		else
			if @left && @key > key
				bool = @left.find(key,bool)
			end

			if @right && @key < key
				bool = @right.find(key,bool)
			end
		end
		bool
	end
end

n = gets.to_i
head = nil

n.times do
	num = gets.to_s.chomp!
	if num == "print"
		puts " #{head.inorder([]).join(" ")}"
		puts " #{head.preorder([]).join(" ")}"
	else
		num = num.split
		if num[0].to_s == "insert"
			if head
				head.insert(num[1].to_i)
			else
				head = Tree.new(num[1].to_i)
			end
		else
			puts head.find(num[1].to_i,"no")
		end

	end

end

Measured memory_bytes: 53132
import sys
# from collections import defaultdict, deque
# import math
# import copy
# from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 1000000007

def solve():
    sx, sy, tx, ty = getList()
    dx = tx - sx
    dy = ty - sy
    ans = []
    for i in range(dy):
        ans.append("U")
    for i in range(dx):
        ans.append("R")
    for i in range(dy):
        ans.append("D")
    for i in range(dx):
        ans.append("L")

    ans.append("L")
    for i in range(dy+1):
        ans.append("U")
    for i in range(dx+1):
        ans.append("R")
    ans.append("D")

    ans.append("R")
    for i in range(dy + 1):
        ans.append("D")
    for i in range(dx + 1):
        ans.append("L")
    ans.append("U")
    print("".join(ans))

def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    # main()
    solve()


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

using namespace std;

int main()
{
	int N;
	int a[100];
	cin >> N;
	for (int i = 0; i < N; i++) 
		cin >> a[i];
	sort(a, a + N);
	cout << (a[N - 1] - a[0]) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int solve(int *arr,int n,int k){
    //cout<<k<<endl;
  int dp[n+1];
  for(int i=0;i<=n;i++){
      dp[i]=INT_MAX;
  }
  dp[0]=0;
  dp[1]=abs(arr[1]-arr[0]);
  
  for(int i=2;i<=n;i++){
         for(int j=k;j>=1;j--){
             if(i-j>=0){
          dp[i]=min(dp[i],abs(arr[i]-arr[i-j])+dp[i-j]);
             
      }
    //  cout<<op1<<" "<<op2<<" "<<i<<endl;
    }
  }
//   for(int i=0;i<=n;i++){
//       cout<<dp[i]<<" ";
//   }
 // cout<<endl;
    return dp[n];
}
// int dp_solve(int *arr,int n,int k){
//     int dp[n+1];
//     dp[0]=0;
//     for(int i=1;i<=n;i++){
//         for(int j=1;j<=k;j++){
//             if(i-j>=0&&i-2>=0){
//                 dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],;
//             }
//             else if(i-1>=0){
//                 dp[i]=abs(arr[i]-arr[i-1])+dp[i-1];
//             }
//             else if(i-2>=0){
//                 dp[i]=abs(arr[i]-arr[i-2])+dp[i-2];
//         }
//         }
//     }
//     // for(int i=0;i<=n;i++){
//     //     cout<<dp[i]<<" ";
//     // }
//     return dp[n];
// }
int main(){
int n,k;
cin>>n>>k;
int arr[n];
for(int i=0;i<n;i++){
    cin>>arr[i];
}
cout<<solve(arr,n-1,k)<<endl;
 return 0;
} 

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

int main() {
    const int INF = 100000;
    int N, M;
    cin >> N >> M;
    int map[N][N];
    int edgeState[N][N]; //0:辺なし 1:辺あり 2:不要辺
    rep(i, N) rep(j, N) {
        map[i][j] = (i == j) ? 0 : INF;
        edgeState[i][j] = 0;
    }
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        map[a][b] = c;
        map[b][a] = c;
        edgeState[a][b] = 1;
        edgeState[b][a] = 1;
    }
    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                if (i == k || i == j || j == k) {
                    continue;
                }
                if (map[i][k] == INF || map[k][j] == INF) {
                    continue;
                }
                int d = map[i][k] + map[k][j];
                if (d < map[i][j]) {
                    if (edgeState[i][j] == 1) {
                        edgeState[i][j] = 2;
                    }
                    map[i][j] = d;
                }
            }
        }
    }
    int count = 0;
    rep(i, N) {
        loop(j, i + 1, N) {
            if (edgeState[i][j] == 2) {
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	static int p,q,a,n,count;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);

		while(true){
			count=0;
			p=sc.nextInt();
			q=sc.nextInt();
			a=sc.nextInt();
			n=sc.nextInt();
			if(p+q+a+n==0) break;
			search(1,0,0,1);
			System.out.println(count);
		}
	}
	static void search(int deno,int nume,int k,int t){
		if(n<k) return;
		if(p*deno==q*nume){
			count++;
			return;
		}
		if(p*deno<q*nume) return;
		for(int i=t;i*deno<=a;i++){
			int de=deno*i;
			int nu=(nume*i)+deno;
			if(i*deno<=a)
				search(de,nu,k+1,i);
		}
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
#define FOR(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

int a[100];

int main(){
	int w,n;
	cin>>w>>n;
	rep(i,w)a[i]=i+1;
	rep(i,n){
		int x,y;
		scanf("%d,%d",&x,&y);
		int t=a[x-1];
		a[x-1]=a[y-1];
		a[y-1]=t;
	}
	rep(i,w)cout<<a[i]<<endl;
	return 0;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  cout << n - k + 1 << endl;
}


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

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        int p;
        cin >> p;
        if (p != i) cnt++;
        if (cnt > 2) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
import sys

N,K=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())
A=map(lambda a: (a-1)%K, A)

S=[0]
for a in A:
    S.append( (S[-1]+a)%K )   #累積和

d=dict()    #要素：要素の数を持つ

ans=0
for i in range(N+1):
    x=S[i]%K
    if i==0:
        d[x]=1
    else:
        if x in d:
            if 2<=K:    #K=1の時は自分の値も見てはいけない
                ans+=d[x]   #自分より前に同じ出現した、自分と同じ要素の数を答えに追加
            d[x]+=1
        else:
            d[x]=1      
        if 0<=i-K+1:
            x_head=S[i-K+1]%K  #長さK-1の範囲で配列Sを見るため、１つ進んだら一番先頭の要素を辞書から削除する
            d[x_head]-=1

print ans


Measured memory_bytes: 80368
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	ll n,k; cin>>n>>k;
	VI a(n); rep(i,n) cin>>a[i], a[i]--;
	bool flg=true; int next=0;
	VI b; b.PB(0);
	int visited[n]; rep(i,n) visited[i]=-1; visited[0]=0;
	int loop=-1;
	int cnt=1;
	while(flg){
		if(visited[a[next]]!=-1) flg=false, loop=visited[a[next]];
		else{
			b.PB(a[next]); visited[a[next]]=cnt; next=a[next]; cnt++;
		}
	}
	// cerr<<loop<<endl;
	// rep(i,b.size()) cerr<<b[i]<<' '; cerr<<endl;
	if(k<loop) cout<<b[k]+1<<endl;
	else{
		k-=loop;
		cout<<b[loop+k%(b.size()-loop)]+1<<endl;
	}
	// cout<<b[k%(b.size())]+1<<endl;
	return 0;
}


Measured memory_bytes: 5912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, n;
  in(n);
  a = 1;
  while(true){
    if(a * (a + 1) / 2 >= n){
      out(a);
      memi;
      return 0;
    }
    else
      a++;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
double x[1100];
double y[1100];
double eps=1e-9;
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%lf%lf",x+i,y+i);
		double gx,gy;scanf("%lf%lf",&gx,&gy);
		double low=999999999;
		for(int i=0;i<a;i++){
			double t=gx/x[i];
			low=min(low,-4.9*t*t+y[i]*t);
		}
		double left=-999999999;
		double right=999999999;
		for(int i=0;i<100;i++){
			double M=(left+right)/2;
			double at=0;
			for(int j=0;j<a;j++){
				if(x[j]*M>y[j])continue;
				double dx=(y[j]/x[j]-M)*(x[j]*x[j]/9.8);
				at+=dx;
			}
			if(at>gx){
				left=M;
			}else{
				right=M;
			}
		}
		double ty=0;
		for(int i=0;i<a;i++){
			if(x[i]*left>y[i])continue;
			double dx=(y[i]/x[i]-left)*(x[i]*x[i]/9.8);
			ty+=-4.9/x[i]/x[i]*dx*dx+y[i]/x[i]*dx;
		}
		//printf("%f %f\n",low,ty);
		if(low-eps<gy&&gy<ty+eps)printf("Yes\n");
		else printf("No\n");
	}
}

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

using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define pf 				push_front
#define mp              make_pair
#define pii             pair<int,int>
#define MAX 			1000000
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
void c_p_c()
{
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
const int Max = 1e7;
int32_t main()
{
	//c_p_c();
	int n;
	cin >> n;
	int a[n];
	int i;
	for (i = 0; i < n; i++)
		cin >> a[i];
	if (is_sorted(a, a + n))
		cout << "Yes";
	else
	{
		for (i = n - 1; i > 0; i--)
		{
			if (a[i] >= a[i - 1])
			{
				continue;
			}
			else if (abs(a[i] - a[i - 1]) == 1)
			{
				a[i - 1] -= 1;
			}
			else
			{
				cout << "No";
				return 0;
			}
		}
		cout << "Yes";
	}

}


Measured memory_bytes: 4344
#include <iostream>
#include <set>
#include <utility>
#include <algorithm>
#include <vector>
#define llint long long
#define inf 1e18
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n, d;
llint m[105];
llint c[105][10005], s[105][10005];
vector<llint> G[2000005];
bool used[2000005];
vector<llint> topo;

void tpsort(int v)
{
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		if(!used[G[v][i]]) tpsort(G[v][i]);
	}
	topo.push_back(v);
}

int main(void)
{
	while(1){
		cin >> n >> d;
		if(n == 0 && d == 0) break;
		
		for(int i = 1; i <= n; i++){
			cin >> m[i];
			for(int j = 1; j <= m[i]; j++){
				cin >> c[i][j];
				s[i][j] = s[i][j-1] + c[i][j];
			}
		}
		
		for(int i = 0; i < 2000005; i++) G[i].clear();
		
		llint M = 10005;
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= m[i]; j++){
				G[i*M+j].push_back(i*M+(j-1));
			}
		}
		for(int i = 1; i <= n; i++){
			for(int j = 0; j < m[i]; j++){
				llint S = s[i][j];
				for(int k = 1; k <= n; k++){
					if(i == k) continue;
					llint p = upper_bound(s[k], s[k]+m[k]+1, S+d) - s[k] - 1;
					G[k*M+p].push_back(i*M+j);
				}
			}
		}
		
		topo.clear();
		for(int i = 0; i < 2000005; i++) used[i] = false;
		for(int i = 0; i < 2000005; i++) if(!used[i]) tpsort(i);
		reverse(topo.begin(), topo.end());
		
		for(int i = 0; i < 2000005; i++) used[i] = false;
		for(int i = 0; i < topo.size(); i++){
			int v = topo[i];
			used[v] = true;
			for(int j = 0; j < G[v].size(); j++){
				if(used[G[v][j]]){
					cout << "No" << endl;
					goto end;
				}
			}
		}
		cout << "Yes" << endl;
		end:;
	}
	return 0;
}


Measured memory_bytes: 86360
def solve():
    N = int(input())
    S = input()
    dict = {}
    for cand in range(1000):
        cand_zero = str(cand).zfill(3)
        if cand_zero[0] in S:
            i = S.index(cand_zero[0])
            if cand_zero[1] in S[i+1:]:
                j = len(S[:i+1]) + S[i+1:].index(cand_zero[1])
                if cand_zero[2] in S[j+1:]:
                    k = len(S[:j+1]) + S[j+1:].index(cand_zero[2])
                    if cand_zero not in dict.keys():
                        dict[cand_zero] = 1
    print(len(dict.keys()))



if __name__ == "__main__":
    solve()


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


void solve(long long N, long long A, long long B){
    if(N*A >= B)
        cout << B << endl;
    else
        cout << N*A << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
ans = 0
for i in range(1, a+1):
    for j in range(1, b+1):
        j1 = j // 10
        j2 = j % 10

        if(j1 * j2 == i and j1 >= 2 and j2 >= 2):
            ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) (flag)?1:0
#define yn(f) cout<<(f?"yes":"no")<<endl
#define Yn(f) cout<<(f?"Yes":"No")<<endl
#define YN(f) cout<<(f?"YES":"NO")<<endl
#define COUT(x) cout<<(x)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

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

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  vec<int> v(3); cin>>v; SORT(v);
  if(v[0]==v[1]) COUT(v[2]);
  else COUT(v[0]);
}













Measured memory_bytes: 256
from collections import deque

n, q = map(int, input().split())

g = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

c = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    c[p-1] += x

q = deque([0])
flag = [False] * n
while q:
    v = q.pop()
    flag[v] = True
    for e in g[v]:
        if flag[e]:
            continue
        c[e] += c[v]
        q.append(e)

print(*c)

Measured memory_bytes: 56088
import sys
from collections import defaultdict
from copy import deepcopy
import itertools
input = sys.stdin.readline
# 文字列の場合は普通のinput()を使うか下を使う
# input = sys.stdin.readline().rstrip()

N, K = map(int, input().split())
A = list(map(int, input().split()))
S = [0] + list(itertools.accumulate(A))
"""
「iからjまで」--->「0からjまで」-「0から(i - 1)まで」
に分解すれば、求める条件は
(S[j] - S[i]) % K = j - i
と書ける。これを式変形して
S[j] - j = S[i] - i mod K "with j - i < K"
とすれば、次を示せばよい：

For 1 <= j <= N, count the number of j - K < i < j
such that S[j] - j = S[i] - i mod K
"""

if K == 1:
    print(0)
    exit()

d = defaultdict(int)
d[(S[0] - 0) % K] = 1

ans = 0
for j in range(1, N + 1):
    x = (S[j] - j) % K
    ans += d[x]
    d[x] += 1
    if j - K >= -1:
        y = (S[j - K + 1] - (j - K + 1)) % K
        d[y] -= 1

print(ans)

Measured memory_bytes: 104908
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()

using namespace std;

ll mod = 1e9+7;
inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

inline ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
        
        dividend %= mod;
        divisor %= mod;
    }
    return (dividend %mod) / (divisor%mod);
}

inline vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

inline bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
ll facctorialMethod(ll k){
    ll sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
    }
    
    ll res = 0;
    
    ll pos1 = 0, pos2 = n-1;
    rep(i, n){
        if(res <= 0){
            res += a[pos1];
            pos1 ++;
        }else{
            res -= a[pos2];
            pos2 --;
        }
    }
    
    res = abs(res);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define INFTY (1<<30)
#define MAX 100005

int n;
vector<int> d(MAX);
vector<vector<pair<int,int>>> G(MAX,vector<pair<int,int>>(0));


void bfs(int s){
    for(int i=0;i<n;i++){
        d[i]=INFTY;
    }
    queue<int> Q;
    Q.push(s);
    d[s]=0;
    while(!Q.empty()){
        int u=Q.front();
        Q.pop();
        for(int i=0;i<G[u].size();i++){
            auto v=G[u][i];
            if(d[v.first]==INFTY){
                d[v.first]=d[u]+v.second;
                Q.push(v.first);
            }
        }
    }
}

void solve(){
    bfs(0);
    int t,M=0;
    for(int i=0;i<n;i++){
        if(d[i]!=INFTY&&M<d[i]){
            M=d[i];
            t=i;
        }
    }

    bfs(t);
    M=0;
    for(int i=0;i<n;i++){
        if(d[i]!=INFTY&&M<d[i]){
            M=d[i];
        }
    }
    cout<<M<<endl;
}

int main(){
    int a,b,c;
    cin>>n;
    for(int i=0;i<n-1;i++){
        cin>>a>>b>>c;
        G[a].push_back(make_pair(b,c));
        G[b].push_back(make_pair(a,c));
    }

    solve();
}


Measured memory_bytes: 9560
n = int(raw_input())
G = []

for i in range(39):
    G.append([])
    for j in range(39):
        G[i].append(0)

ans = 0
    
for i in range(n):
    c2 = 0
    c5 = 0
    s = raw_input()
    if not '.' in s:
        p = int(s) * (10**18)
    else:
        a,b = s.split('.')
        x = len(b)
        p = int(a+b)*(10**(18-x))
    #print p
    while (p%2==0):
        p/=2
        c2+=1
    while (p%5==0):
        p/=5
        c5+=1
    c2 = min(c2,36)
    c5 = min(c5,36)
    for j in range(37):
        for k in range(37):
            if (j+c2 >= 36 and k+c5 >= 36):
                ans += G[j][k]
    G[c2][c5] += 1
print ans
    
    
    


Measured memory_bytes: 74200