akhauriyash/Code-Regression huggingface dataset:
//#define _GRIBCXX_DEBUG
#include <bits/stdc++.h>
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, int>;


struct edge{
  edge(int to, ll cost) : to(to), cost(cost) {};

  int to;
  ll cost;
};

int V, E, r, s, t;
ll d;
vector<ll> dist;
const ll INF = 1LL<<50;


int main() {
  cin >> V >> E >> r;
  vector<edge> G[V];

  rep (i, E) {
    cin >> s >> t >> d;
    G[s].push_back(edge(t, d));
  }


  priority_queue<P, vector<P>, greater<P>> que;
  dist.resize(V); fill(dist.begin(), dist.end(), INF);
  dist[r] = 0;

  que.push(P(0, r));
  while (!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;

    if (dist[v] < p.first) continue;

    rep (i, G[v].size()) {
      edge e = G[v][i];

      if (dist[e.to] > dist[v] + e.cost) {
        dist[e.to] = dist[v] + e.cost;
        que.push(P(dist[e.to], e.to));
      }
    }
  }

  for (ll dist_ : dist) {
    if (dist_ == INF) cout << "INF" << endl;
    else cout << dist_ << endl;
  }

  return 0;
}

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

int main(){
    int n,l;
    cin >> n >> l;
    int i;
    int sum=0;
    int aji[200];
    int near=101;

    for(i=0;i<n;i++){
        sum+=l;
        if(abs(l)<abs(near)){
            near=l;
        }
        l++;
    }
    //cout << near << "," << sum<< endl;
    cout << sum-near << endl;

}

Measured memory_bytes: 256
h, w = list(map(int, input().split()))
s = [input() for _ in range(h)]

INF = 1001001001
di = [-1,0,1,0]
dj = [0,-1,0,1]
ans = 0

def update(i, j, x):
    if dist[i][j] != INF: return
    dist[i][j] = x
    que.put([i,j])

import queue

# スタートの座標全てのパターンについて距離を計算
for si in range(h):
    for sj in range(w):
        if s[si][sj] == '#': continue
        dist = [[INF]*w for i in range(h)]
        que = queue.Queue()
        update(si, sj, 0)
        while que.qsize():
            p = que.get()
            i = p[0]; j = p[1]
            for drc in range(4):
                ni = i+di[drc]; nj = j+dj[drc]
                if ni < 0 or ni >= h or nj < 0 or nj >= w: continue
                if s[ni][nj] == '#': continue
                update(ni, nj, dist[i][j]+1)
        # ゴールの座標全てのパターンについて距離を更新
        for i in range(h):
            for j in range(w):
                if dist[i][j] == INF: continue
                ans = max(ans, dist[i][j])

print(ans)

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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ll sum = 0;
	int n, q;
	cin >> n;
	vll freq(100001);
	M00(i, n) {
		ll x;
		cin >> x;
		freq[x]++;
		sum+=x;
	}
	cin >> q;
	M00(i, q) {
		ll b, c;
		cin >> b >> c;
		sum += (c - b) * freq[b];
		freq[c] += freq[b];
		freq[b] = 0;
		cout << sum << endl;
	}

}


Measured memory_bytes: 4032
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int h, w;
	cin >> h >> w;
	int mt[h][w];
	REP(i, h) REP(j, w) cin >> mt[i][j];
	vector<tuple <int, int, int, int> > ls;
	int nu = 0;
	REP(i, h){
		REP(j, w-1){
			if(mt[i][j] % 2 == 1){
				mt[i][j] --;
				mt[i][j+1]++;
				ls.push_back(make_tuple(i+1, j+1, i+1, j+2));
				nu ++;
			}
		}
	}
	REP(i, h-1){
		if(mt[i][w-1] % 2 == 1){
			mt[i][w-1] --;
			mt[i+1][w-1]++;
			ls.push_back(make_tuple(i+1, w, i+2, w));
			nu ++;
		}
	}
	cout << nu << endl;
	REP(i, nu){
		int aa, bb, cc, dd;
		tie(aa, bb, cc, dd) = ls[i];
		cout << aa << " " <<bb << " " << cc << " " << dd << endl;
	}
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  string s;
  cin >> n >> m >> s;
  
  reverse(s.begin(), s.end());
  
  int now = 0;
  vector<int> x;
  while(now != n){
    if(n - now <= m){
      x.push_back(n - now);
      now = n;
      continue;
    }
    
    bool flag = false;
    for(int i = m; i > 0; i--){
      if(s.at(now + i) == '0'){
        x.push_back(i);
        now += i;
        flag = true;
        break;
      }
    }
    
    if(!(flag)){
      cout << -1 << "\n";
      return 0;
    }
  }
  
  for(int i = x.size() - 1; i >= 0; i--){
    cout << x.at(i) << " ";
  }
  cout << "\n";
}

Measured memory_bytes: 1096
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

const int maxn = 100 + 10;
const int inf = 0x3f3f3f3f;

struct node
{
	string city;
	int res;
};

node da[maxn];
int n, ans[maxn];

int read()
{
	int x;
	scanf("%d", &x);
	return x;
}

bool cmp(node x, node y)
{
	if(x.city == y.city)
	{
		return x.res > y.res;
	}
	else
	{
		return x.city < y.city;
	}
}

void init()
{
	for(int i = 1; i < maxn; i ++)
	{
		ans[i] = i;
	}
}

int main()
{
	init();
	n = read();
	for(int i = 1; i <= n; i ++)
	{
		cin >> da[i].city;
		da[i].res = read();
	}
	for(int i = 1; i <= n; i ++)
	{
		for(int j = 1; j <= n; j ++)
		{
			if(i == j)
			{
				continue;
			}
			int x = ans[i], y = ans[j];
			if(da[x].city == da[y].city)
			{
				if(da[x].res > da[y].res)
				{
					swap(ans[i], ans[j]);
				}
			}
			else
			{
				if(da[x].city < da[y].city)
				{
					swap(ans[i], ans[j]);
				}
			}
		}
	}
	for(int i = 1; i <= n; i ++)
	{
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void)
{
long int n,a,b,d[100001]={0}, i;
long int k, s;

scanf("%ld %ld",&n,&k);

for(i=0; i<n; i++){
scanf("%ld %ld",&a,&b);
d[a] += b;
}

s=0;
for( i=1; i <= 100000; i++){
s += d[i];
if(s >= k){
break;
}
}
printf("%d\n", i);

return 0;
}

Measured memory_bytes: 896
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);


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

    void run() {

        int h = sc.nextInt();
        int w = sc.nextInt();
        char[][] arr = new char[h+1][w+1];

        StringBuilder sb = new StringBuilder();

        for (int i=0; i<h; i++) {
            arr[i] = sc.next().toCharArray();
        }

        List<char[]> list = new ArrayList<>();

        for (int i=0; i<h; i++) {
            int cnt = 0;
            for (int j=0; j<w; j++) {
                if (arr[i][j] == '.') cnt++;
            }
            if (cnt != w) {
                char[] tmp = arr[i];
                list.add(tmp);
            }
        }

//        System.out.println(list);

        for (char[] t: list) {
//            for (int i=0; i<t.length; i++) System.out.println(t[i]);
        }

        char[][] s = new char[list.size()][w];

        for (int i=0; i<list.size(); i++) {
            s[i] = list.get(i);
        }

        List<char[]> list1 = new ArrayList<>();

        for (int i=0; i<w; i++) {
            int cnt = 0;
            for (int j=0; j<list.size(); j++) {
                if (s[j][i] == '.') cnt++;
            }
//            System.out.println(cnt);
//            System.out.println(list.size());
            if (cnt != list.size()) {
                char[] c = new char[list.size()];
                for (int k=0; k<list.size(); k++) {
                    c[k] = s[k][i];
                }
                list1.add(c);
            }

        }

//        System.out.println(list1);


        char[][] res = new char[list1.get(0).length][list1.size()];

//        System.out.println(list1.get(0).length);
//        System.out.println(list1.size());

        for (int i=0; i<list1.size(); i++) {
            for (int j=0; j<list1.get(0).length; j++) {
                res[j][i] = list1.get(i)[j];
            }
        }

        for (int i=0; i<res.length; i++) {
            for (int j=0; j<res[0].length-1; j++) {
                sb.append(res[i][j]);
            }
            sb.append(res[i][res[0].length-1] + "\n");
        }

        System.out.println(sb.toString());




    }
}


Measured memory_bytes: 22228
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    cout << (char) toupper(a[0]) << (char) toupper(b[0]) << (char) toupper(c[0]) << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> pint;
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());
signed main(void){
  int n;cin >> n;
  vint b(n-1);vin(b);
  int ans=b[0];
  
  rep(i,n-2){
    if(b[i]<=b[i+1])ans+=b[i];
    else ans+=b[i+1];
  }
  ans+=b[n-2];

  cout << ans << endl;

}


Measured memory_bytes: 256
N, Y = input().strip().split()
N, Y = int(N), int(Y)

NUMS = list(range(N+1))


ans = [-1, -1, -1]
found = False
for x in NUMS:
  for y in NUMS:
    if N - x - y >= 0:
      z = N - x - y
      m = 10000 * x + 5000 * y + 1000 * z
      if m == Y and x + y + z == N:
        ans = x, y, z
        found = True
        break
  if found:
    break
      
print(' '.join([str(n) for n in ans]))

Measured memory_bytes: 42556
#include <iostream>

using namespace std;
int main() {
	int A[100];
	int n, i, j;
	cin >> n;
	for(i=0; i<n; i++){
		cin >> A[i];
	}
	for(int t=0; t<n-1; t++){
		cout << A[t] << ' ';
	}
	cout << A[n-1] << endl;
	for(i=1; i<n; i++){
		int v = A[i];
		j = i - 1;
		while(j >= 0 && A[j] > v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		for(int t=0; t<n-1; t++){
			cout << A[t] << ' ';
		}
		cout << A[n-1] << endl;
	}
}

Measured memory_bytes: 3096
A,B,C = map(int,input().split())

ans = 0

while True:
    if A%2!=0 or B%2!=0 or C%2!=0:
        print(ans)
        break
    elif A%2==0 and B%2==0 and C%2==0 and A == B == C:
        print('-1')
        break
    A_ = A/2
    B_ = B/2
    C_ = C/2
    A = B_+C_
    B = A_+C_
    C = A_+B_
    ans += 1


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
string s;
cin>>s;
ll n;
cin>>n;
ll q=s.size();
for(ll i=0; i<q; i=i+n){
cout<<s.at(i);}
cout << endl;}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define maxn 100020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

inline int read(){
	register int num = 0;
	register char ch = getchar();
	while ( ch > '9' || ch < '0' ) ch = getchar();
	while ( ch <= '9' && ch >= '0' ) num = num * 10 + ch - '0' , ch = getchar();
	return num;
}
int num[10];
inline void write(int x){
	register int cnt = 0;
	if ( !x ){ printf("0"); return; } //一定要特判0！！！
	while ( x ) num[++cnt] = x % 10 , x /= 10;
	while ( cnt ) putchar(num[cnt--] + '0');
}

int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<b + min(c,a + b + 1)<<endl;
}



Measured memory_bytes: 256
/*
Saurabh Joshi
IIIT Jabalpur
*/
#include<bits/stdc++.h>
#define LL long long int
#define M 1000000007
#define endl "\n"
#define eps 0.00000001
LL pow(LL a,LL b,LL m){ a%=m;LL x=1,y=a;while(b > 0){if(b%2 == 1){x=(x*y);if(x>m) x%=m;}y = (y*y);if(y>m) y%=m;b /= 2;}return x%m;}
LL gcd(LL a,LL b){if(b==0) return a; else return gcd(b,a%b);}
LL gen(LL start,LL end){LL diff = end-start;LL temp = rand()%start;return temp+diff;}
using namespace std;
LL a[404];
LL dp[404][404];
LL psum[401];
LL f(int i,int j) {
    if(i > j)
        return 0;
    if(i == j)
        return 0;
    if(dp[i][j] != -1)
        return dp[i][j];
    LL ans = 1000000000000000000LL;
    for(int k = i; k <= j - 1; k++) {
        ans = min(ans , f(i , k) + f(k + 1 , j) + psum[j] - psum[i - 1]);
    }
    return dp[i][j] = ans;
}
int main()	{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    memset(dp, -1, sizeof(dp));
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        psum[i] = psum[i - 1] + a[i];
    }
    cout << f(1 , n);
}

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

#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define all(x) (x).begin(), (x).end()

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int MOD = 1000000007;

int main() {
    IOS;
    int n, m;
    cin >> n >> m;
    char matrix[n][m];
    ll dp[n][m];
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            dp[i][j] = 0;
            cin >> matrix[i][j];
        }
    }

    for(int i = 1; i < n; i++) {
        if(matrix[i][0] == '#') break;
        dp[i][0] = 1;
    }
    for(int j = 1; j < m; j++) {
        if(matrix[0][j] == '#') break;
        dp[0][j] = 1;
    }
    for (int i = 1; i < n; ++i) {
        for(int j = 1; j < m; j++) {
            if(matrix[i][j] == '.') dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
            dp[i][j] %= MOD;
        }
    }
    cout << dp[n - 1][m - 1];
    return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
vvi E(222222);
ll dp[222222];
ll dfs(ll now,ll par){
  map<ll,ll>MP;
  for(auto a:E[now]){
    if(a==par)continue;
    MP[dfs(a,now)]++;
  }
  if(MP.size()==0)return dp[now]=0;
  else{
    ll num=-1;
    for(auto a:MP){
      ll hoge=a.F;
      ll cnt=a.S;
      if(hoge>num){
	num=hoge+cnt-1;
      }else{
	num+=cnt;
      }
    }
    return dp[now]=num+1;
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  for(int i=0;i<n-1;i++){
    ll a;cin>>a;
    E[--a].pb(i+1);
    E[i+1].pb(a);
  }
  fill(dp,dp+222222,llINF);
  cout<<dfs(0,-1)<<endl;
  return 0;
}


Measured memory_bytes: 24448
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#n = ip()                              #入力整数1つ
#x,y= (int(i) for i in input().split())      #入力整数横2つ
k,a,b = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
left = 0
s = 0
if a >= b or a+1==b or k<=a:
    print(k+1)
else :
    left  = k-a-1
    s+=b
    s+= (left//2)*(b-a)
    if left%2 :s+=1
    print(s)

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

string s, t;
int dp[1001][1001];
int main()
{
    int p;
    cin >> p;
    while(p>0)
    {
        p--;
        cin >> s >> t;
        int n = s.size();
        int m = t.size();
        for (int i = 1; i <= n; i++)
            dp[i][0] = 0;
        for (int i = 1; i <= m; i++)
            dp[0][i] = 0;

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (s[i - 1] == t[j - 1]) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                }
                else if (dp[i - 1][j] >= dp[i][j - 1]) {
                    dp[i][j] = dp[i - 1][j];
                }
                else {
                    dp[i][j] = dp[i][j - 1];
                }
            }
        }
        cout << dp[n][m] << endl;
    }

}

Measured memory_bytes: 5116
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int sum = 0;

    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        for (int k = 1; k <= n; k++) {
          sum += gcd(i, j, k);
        }
      }
    }
    System.out.println(sum);
  }

  private static int gcd(int a, int b, int c) {
    return gcd(gcd(a, b), c);
  }

  private static int gcd(int a, int b) {
    int tmp;
    while ((tmp = a % b) != 0) {
      a = b;
      b = tmp;
    }
    return b;
  }
}


Measured memory_bytes: 27160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.ParseException;

public class Main {
	public static void main(String[] args) throws IOException, ParseException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	String str = br.readLine();
    	final int A = Integer.parseInt(str.split(" ")[0]);
    	final int B = Integer.parseInt(str.split(" ")[1]);

    	if (B % A == 0) {
    		System.out.println(A + B);
    	} else {
    		System.out.println(B - A);
    	}
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <iomanip>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int N, T;
	int c[105], t[105];
	int tle = 0, min, ans;
	cin >> N >> T;
	rep(i, N){ 
		cin >> c[i] >> t[i];
		if(t[i] > T){
			tle++;
		}else{
			if(i == 0 || tle == i){
				min = c[i];
			}else{
				if(min > c[i]){
					min = c[i];
				}
			}
		}
	}
	if(tle == N){
		cout << "TLE" << endl;
	}else{
		cout << min << endl;
	}
}

Measured memory_bytes: 256
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n, m = map(int, input().split())
    l = [list(map(int, input().split())) for _ in range(n)]

    l.sort()
    ans = 0
    for i in l:
        if m<=i[1]:
            ans += m*i[0]
            break
        else:
            ans += i[0]*i[1]
            m -= i[1]
    print(ans)

if __name__=="__main__":
    main()


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

using namespace std;

typedef long long ll;

ll dp[100005];
ll w[100005];
ll v[100005];

int main(){
    ll n, W;

    cin >> n >> W;

    for(ll i=0;i<n;i++){
        cin >> w[i] >> v[i];
    }
    for(ll i=0;i<n;i++){
        for(ll j=100001;j>=w[i];j--){
            dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
        }
    }
    cout << dp[W] << "\n";

    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int x = cin.Int();
			int y = cin.Int();
			int ans = 0;
			if (x == 1) {
				ans += 300000;
			} else if (x == 2) {
				ans += 200000;
			} else if (x == 3) {
				ans += 100000;
			}

			if (y == 1) {
				ans += 300000;
			} else if (y == 2) {
				ans += 200000;
			} else if (y == 3) {
				ans += 100000;
			}

			if (x == 1 && y == 1) {
				ans += 400000;
			}

			Console.WriteLine(ans);
		}
	}


	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


int main(void) {
    ll N, K;
    cin >> N >> K;
    
    if(N>=2*K-1) {
        puts("YES");
    }else {
        puts("NO");
    }
    
    
    
    
}




Measured memory_bytes: 256
//============================================================================
// Name        : ku.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include<iostream>
using namespace std;
int main(){
	double a,b;
	cin>>a>>b;
	if(a>b){
		cout<<"a > b"<<endl;
	}
	else if(a<b){
		cout<<"a < b"<<endl;
	}
	else if(a==b){
		cout<<"a == b"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N; cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  int dir = 0;
  ll ans = 1;
  rep(i,N-1) {
    if(dir == 1) {
      if(A[i] > A[i+1]) {
        ++ans;
        dir = 0;
      }
    } else if (dir == -1) {
      if(A[i] < A[i+1]) {
        ++ans;
        dir = 0;
      }
    } else if (dir == 0) {
      if(A[i] > A[i+1]) dir = -1;
      if(A[i] < A[i+1]) dir = 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM (ll)1000000000
#define modL (ll)MM+7
#define modi (ll)MM+7
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
#define rep(i, n) for(int i = 0; i < n; i++)
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int main(){
    ll n,h; cin >> n >> h;
    ll a[n],b[n];
    ll mx_a = 0;
    vector<ll> v(0);
    ll sum_b = 0;
    for(ll i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        mx_a = max(mx_a, a[i]);
    }
    sort(b,b+n);
    reverse(b,b+n);
    for(ll i = 0; i < n; i++){
        if(b[i] >= mx_a){
            v.push_back(b[i]);
            sum_b += b[i];
            if(sum_b >= h){
                break;
            }
        }
    }
    ll ans = 0; //count
    ans += v.size();
    h -= sum_b;
    if(h <= 0){
        cout << ans << endl;
        return 0;
    }
    if(h%mx_a == 0){
        ans += (h/mx_a);
    } else {
        ans += (h/mx_a)+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2936
#include <iostream>

using namespace std;

int niz[30];
string a;
long long int sol;

inline long long int povrh(int a,int b)
{
	long long int nazivnik=1;
	long long int brojnik=1;
	for(int i=1;i<=b;i++)
	{
		nazivnik*=(a-i+1);
		brojnik*=i;
	}
	return nazivnik/brojnik;
}

int main()
{
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		niz[a[i]-'a']++;
	}
	sol=povrh(a.size(),2);
	for(int i=0;i<30;i++)
	{
		if(niz[i]!=0)
		sol-=povrh(niz[i],2);
	}
	cout<<sol+1;
	
}

Measured memory_bytes: 640
import itertools
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

table = list(itertools.permutations([i for i in range(1, n+1)]))
a = table.index(p)
b = table.index(q)

ans = abs(a-b)
print(ans)

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

typedef long long LL;
typedef unsigned long long uLL;
typedef long double ldb;
typedef pair<int,int> pii;

int A[200001];

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, k;
    cin>>n>>k;
    for(int i = 0; i < n; ++i)
    {
        int inp;
        cin>>inp;
        ++A[inp];
    }
    sort(A, A+n+1);
    reverse(A,A+n+1);
    int ans = 0;
    for(int i = k; i <=n; ++i)
        ans += A[i];
    cout<<ans;
    return 0;
}


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

using namespace std;

const int N=1e6+3;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9;

int n,m,a[N][2],b[N],k,q,u,v,x,y,tc,c,l,r,ans,p,cnt;

char s[N];

bool ok[N];

int main(){
	
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d",&a[i][0],&a[i][1]);
	}
	for(int i=0;i<=999;i++){
		string s;
		int x=i;
		while(x){
			s+=(x%10)+'0';
			x/=10;
		}
		reverse(s.begin(),s.end());
		if (s.empty())
			s+='0';
		if (s.size()!=n)
			continue;
		bool ok=true;
		for(int i=0;i<m;i++){
			int p=a[i][0]-1;
			if (s[p]-'0'!=a[i][1])
				ok=false;
		}
		if (ok)
			return !printf("%s\n",s.c_str());
	}
	printf("-1\n");
}



Measured memory_bytes: 2304
N=int(input())
lis=[]
for i in range(N):
    A,B=input().split()
    B=str(999-int(B))
    lis.append(A+B+'_'+str(i))
               
lis=sorted(lis)
for i in range(N):
    print(int(lis[i].split('_')[1])+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int n;
int ans = 0;

void dfs(ll x, int a, int b, int c) {
    if (n < x) return;
    if (a && b && c) ans++;
    dfs(10 * x + 3, 1, b, c);
    dfs(10 * x + 5, a, 1, c);
    dfs(10 * x + 7, a, b, 1);
    return;

}

int main()
{
    cin >> n;
    dfs(0, 0, 0, 0);
    cout << ans << endl;
    return 0;
}


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

min = Pn[0]
count = 0

# 1より右側は探索不要
Pn = Pn[:Pn.index(1)+1]

for i in range(len(Pn)):
    if min >= Pn[i]:
        # print("min:{} Pi:{}".format(min,Pn[i]))
        count += 1
        min = Pn[i]

print(count)


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

  string s;
  int k;
  cin >>s>>k;
  
  int i=0;
  bool a=0;
  while(s[i]=='1'){
    k--;
  if(k==0){a=1; break;}
    i++;
  }

  
  if(a) cout<< 1<<endl;
else cout<<s[i]<<endl;
}

Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
work = [list(map(int, input().split())) for _ in range(n)]
work.sort()

cd = []
heapq.heapify(cd)
cnt = 0
ans = 0
# b, a
# aの条件
for k in range(m+1):
    # a = kの仕事をheappush

    for i in range(cnt, n):
        a, b = work[i]

        if a == k:
            heapq.heappush(cd, [-b, a])
        else:
            cnt = i
            break

        if i == n-1:
            cnt = n-1

    if not cd:
        continue
    ans -= heapq.heappop(cd)[0]
print(ans)




Measured memory_bytes: 38188
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=0
for i in range(n):
    if a[i]<=b[i]:
        cnt+=a[i]
        b[i]-=a[i]
        if a[i+1]<=b[i]:
            cnt+=a[i+1]
            a[i+1]=0
        else:
            cnt+=b[i]
            a[i+1]-=b[i]
    else:
        cnt+=b[i]
print(cnt)



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

const int INF = 1000000000;

int main() {
    int n, m;
    while(cin >> n >> m) {
        vector<int> coin(m);
        for(auto& d: coin) cin >> d;
        sort(coin.begin(), coin.end());

        vector<int> dp(n + 1, INF);
        dp[0] = 0;
        for(const auto& d: coin) {
            for(int sum = 0; sum + d <= n; ++sum) 
                dp[sum + d] = min(dp[sum + d], dp[sum] + 1);
//             for(int sum = n; sum - d >= 0; sum--) 
//                 dp[sum] = min(dp[sum], dp[sum - d] + 1);
        }
        cout << dp[n] << endl;
    }
}

Measured memory_bytes: 1292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll d, t, s; cin >> d >> t >> s;
    cout << (d <= t * s ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3628
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 1000000007
#define mod MOD
#define sec setprecision
constexpr double eps = 1e-9;
constexpr double PI = 3.141592653589793238462643383279;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
long long com(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a) % mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
}
int main() {
	int x, n;
	cin >> x >> n;
	vector<int>p(n);
	rip(i, n)cin >> p[i];
	int mini = 10000;
	vector<int>b(205,0);
	rip(i, n) {
		b[p[i]+100]++;
	}
	int ans = 0;
	for(int i=104;i>=-100;i--) {
		if (b[i+100] == 0) {
			mini = min(mini, abs(x - i));
			if (mini == abs(x - i)) {
				ans = i;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
//const int mod = 998244353;
 
 
struct mint {
  ll x; // typedef long long ll;
  mint(ll 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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);
 
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数
 
        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
 
        // その結果を push
        res.push_back({a, ex});
    }
 
    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}


int main(int argc, const char * argv[]) {
    
    ll N,X,T; cin >> N >> X >> T;
    
    ll syo = N / X;
    ll amari = N % X;
    
    if(amari==0){
        cout << syo*T << endl;
    }else{
        cout << (syo + 1)*T << endl;
    }
    
    return 0;

}


Measured memory_bytes: 6212
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int judge = 0;
        
        if(N%10 == 3){
                judge = 3;
        }else if(N%10 == 0 ||N%10 == 1 ||N%10 == 6 ||N%10 == 8){
                judge = 2;
        }else{
                judge = 1;
        }
        
        if(judge == 1) System.out.println("hon");
        if(judge == 2) System.out.println("pon");
        if(judge == 3) System.out.println("bon");
    }
}


Measured memory_bytes: 35648
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;

const int N=1e5+7;
const ll mod=998244353;

ll arr[N];
ll ksm(ll x,ll y){
	ll res=1;
	while(y){
		if(y&1) res=res*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return res%mod;
}

int main()
{
	ll n;
	cin>>n;
	ll x;
	ll sum=1;
	ll s=0;
	for(ll i=1;i<=n;i++){
		cin>>x;
		if(i==1&&x!=0) sum=0;
		arr[x]++;
		s=max(x,s);
	}
	for(ll i=s;i>=0;i--){
		if(arr[i]==0) sum=0;
		if(i>1){
			sum=sum*ksm(arr[i-1],arr[i])%mod;
		}
	}
	if(arr[0]>1) sum=0;
	cout<<sum%mod<<endl;
	return 0;
 } 

Measured memory_bytes: 1024
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  string N;

  cin >> N;

  if (N[0] == '9' || N[1] == '9')
    cout << "Yes" << endl;

  else
    cout << "No" << endl;
}


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


int main(void){
  string a,b,c;
  cin>>a>>b>>c;
  if(a.at(a.size()-1)==b.at(0) && b.at(b.size()-1)==c.at(0)){
    cout<<"YES"<<endl;
  }else cout<<"NO"<<endl;


  return 0;
}


Measured memory_bytes: 256
N, M, C = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
ans = 0
N.times do
  sum = gets.split.map(&:to_i).zip(B).inject(0) do |s, (a, b)|
    s += a * b
  end
  ans += 1 if sum + C > 0
end
p ans

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;

const ll mod=1000000007;
const ll inf=1000000000000; 

#define rep(i,m,n) for(ll i=m;i<n;i++)

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

 string s;
  cin >> s;
 ll l=0,r=0;
  ll res=0; 
  rep(i,0,s.size()-1){
   if(s[i]=='<') l++;
   else if(s[i]=='>') r++; 
  
    if(s[i]=='>'&&s[i+1]=='<') {
      res+=l*(l+1)/2+r*(r+1)/2-min(l,r); 
      l=0;
      r=0;
    }
  
  }

  if(s[s.size()-1]=='>') r++;
  else if(s[s.size()-1]=='<') l++;
  res+=l*(l+1)/2+r*(r+1)/2-min(l,r); 
  
  cout << res <<endl;
  
}

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

int main() {

	string S,T;
	cin>>S>>T;
	for(int i=0;i<S.size();i++){
		if(S[i]!=T[i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n,i,j;
	long long a[200005],flag=0;
	cin>>n;
	for(i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	for(i=1;i<n;i++)
	{
		if(a[i]==a[i-1]) {
			flag=1;break;
		}
	}
	if(flag) cout<<"NO";
	else cout<<"YES";
}

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

int main() {
    long long n, k;
    cin >> n >> k;
    vector<long long> s(n+1, 0);
    s[0] = n+1;
    long long maxs = n, mins = 0;
    for (int i=1; i<=n; i++) {
        maxs += n-i; mins += i;
        s[i] = s[i-1] + maxs - mins +1;
    }
    long long ans;
    if (k>=2) ans = s[n] - s[k-2];
    else ans = s[n];
    long long d = 1000000007;
    if (ans >= d) ans %= d;
    cout << ans << endl;
}

Measured memory_bytes: 4848
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include <climits>

long long  INF=LLONG_MAX;
using namespace std;


int main(){
long long  N;
long long T;
cin>>N>>T;
long long A[N];
long long m[N+1];
long long M[N+1];
long long mi=INF;
long long Ma=0;

for(int i=0;i<N;i++){
    cin>>A[i];
    mi=min(mi,A[i]);
    m[i+1]=mi;
}

for(int i=N-1;i>=0;i--){
    Ma=max(A[i],Ma);
    M[i+1]=Ma;
}

long long ans=0,interest;
multimap<long long,long long  >v;
long long p=0;
for(int i=1;i<N;i++){
    interest=max(M[i+1]-m[i],p);
    ans=max(ans,interest);
}

map<long long ,int>mn;
int Ans=0;
for(int i=1;i<N;i++){
    if(max(M[i+1]-m[i],p)==ans && (mn.find(m[i])==mn.end())){
        Ans++;
        mn.insert(make_pair(m[i],i));
    }

}


cout<<Ans<<endl;

 return 0;
}

Measured memory_bytes: 5760
import std.stdio, std.string, std.algorithm, std.array, std.range, std.conv,
    std.typecons, std.math, std.container, std.format, std.numeric;

void main(string[] args)
{
    long n, k;
    readf("%d %d\n", &n, &k);
    auto hs = readln.strip.split.to!(long[]);
    sort(hs);
    foreach (i; 0 .. min(k, n))
    {
        hs[n - i - 1] = 0;
    }
    writeln(hs.sum);
}


Measured memory_bytes: 11112
N,M = map(int,input().split())
l = [0]*M
r = [0]*M
for i in range(M):
    l[i],r[i] = map(int,input().split())

if min(r)-max(l)+1 > 0:
    print(min(r)-max(l)+1)
else:
    print(0)


Measured memory_bytes: 10868
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
#include <algorithm>
#include <string>


using namespace std;
using ll = long long;
using ull = unsigned long long;


#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

int main() {

	string ac = "ACTG";

	string s;
	int m = 0;
	int tempm = 0;
	cin >> s;

	rep(i, 0, s.length()) {
		if (s[i] == 'A' ||
			s[i] == 'C' ||
			s[i] == 'T' ||
			s[i] == 'G') {
			tempm += 1;
		}
		else {
			tempm = 0;
		}
		m = max(tempm, m);
	}

	cout << m << endl;


	return 0;
}



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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int D[110000], n[110000], d[110000];
unordered_map<int, int> mp;
vint ans;
signed main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {cin >> D[i]; n[i] = 1; mp[D[i]] = i;};
    sort(D + 1, D + N + 1); reverse(D + 1, D + N + 1);
    for (int i = 1; i <= N - 1; i++) {
        int s = mp[D[i]];
        int t = mp[D[i] - N + 2 * n[s]];
        n[t] += n[s];
        d[t] += d[s] + n[s];
        ans.push_back(s); ans.push_back(t);
    }
    if (n[mp[D[N]]] != N || d[mp[D[N]]] != D[N]) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 0; i < 2 * (N - 1); i += 2) {
        cout << ans[i] << " " << ans[i + 1] << endl;
    }

}


Measured memory_bytes: 11456
import java.util.Scanner;

// *** at 2018/**/**

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

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		if (N * A < B) {
			System.out.println(N * A);
		} else {
			System.out.println(B);
		}
	}

	private void solveB() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveE() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveF() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

}

Measured memory_bytes: 21844
#include<stdio.h>

int main(void){

	int a[50];
	int i;
	int count;
	int n;

	count = 0;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(i+1 != a[i]){
			count++;
		}
	}

	if(count == 2 || count == 0){
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 128
/*****include*****/
#include <iostream>
#include <fstream>

/*****デバッグ定義*****/
//#define DEBUG
#define INF 10000
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/
typedef struct{
	int time;
	int cost;
}Field;
Field field[100][100];
/*****その他関数置き場*****/
int djikstra(int start,int goal,int num,int order){
	int *dis;
	bool *used;
	dis = new int [num];
	used = new bool [num];
	int station;
	int res;
	for(int i=0;i<num;i++){
		dis[i] = INF;
		used[i] = false;
	}
	dis[start] = 0;
	while(true){
		station = -1;
		for(int i=0;i<num;i++){
			if(!used[i] && (station == -1 || dis[i] < dis[station])){
				station = i;
			}
		}
		if(station == -1)	break;
		used[station] = true;
		for(int i=0;i<num;i++){
			int adder;
			adder = ((order) ? field[station][i].time : field[station][i].cost);
			if(dis[i] > dis[station]+adder){
				dis[i] = dis[station]+adder;
			}
		}
	}
	res = dis[goal];
	delete dis;
	delete used;
	return res;
}
/*****main関数*****/
int main(){
	/*****ファイルオープン*****/
#ifdef DEBUG
	ofstream fout("output.txt");
	ifstream fin("input.txt");
	if(!fout || !fin){
		cout << "Can't open the file.\n";
		return;
	}
#endif
	/*****変数置き場*****/
	int rail_num,sta_num;
	while(1){
		for(int i=0;i<100;i++){
			for(int j=0;j<100;j++){
				field[i][j].time = INF;
				field[i][j].cost = INF;
			}
		}
		cin >> rail_num >> sta_num;
		if(rail_num == 0 && sta_num == 0)	break;
		for(int i=0;i<rail_num;i++){
			int st1,st2,cost,time;
			cin >> st1 >> st2 >> cost >> time;
			field[st1-1][st2-1].cost = cost;
			field[st2-1][st1-1].cost = cost;
			field[st1-1][st2-1].time = time;
			field[st2-1][st1-1].time = time;
			field[st1-1][st1-1].cost = 0;
			field[st2-1][st2-1].time = 0;
		}
		int loop;
		int min;
		cin >> loop;
		for(int i=0;i<loop;i++){
			int order,start,goal;
			cin >> start >> goal >> order;
			if(order==1){
				min = djikstra(start-1,goal-1,sta_num,order);
			}else{
				min = djikstra(start-1,goal-1,sta_num,order);
			}
			cout << min << endl;
		}
	}
	/*****処理部*****/
	
	/*****処理終了後*****/
#ifdef DEBUG
	fout.close();
	fin.close();
#endif
	return 0;
}

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

int main() {
  string s; cin >> s;
  int a_index = -1, z_index = 0;
  for (int i = 0; i < s.size(); i++) {
    if (a_index == -1 && s[i] == 'A') a_index = i;
    else if (s[i] == 'Z') z_index = i;
  }
  int length = z_index - a_index + 1;
  cout << length << endl;
}

Measured memory_bytes: 640
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
int n,m,a,b;
int main(){
	cin>>n>>m>>a>>b;
	cout<<(n-a)*(m-b);
	return 0;
}

Measured memory_bytes: 256