akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

ll x,y;

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

	cin>>x>>y;
	if(x%y==0) cout<<-1<<endl;
	else cout<<x<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;//不能用define，
//用define的话mod变成了double类型，
//所以要用const 来声明int类型的mod; 
map<int,int>d;//因为数据太大，数组开不下，n^18;
inline int read() //快读，不过多解释
{
    char ch=getchar();
    int x=0,q=1;
    while(ch>'9' || ch<'0')q=ch==45?-1:q,ch=getchar();
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=getchar();
    return x*q;
}
inline int solve(int x)//递归函数
{
    if(d[x]!=0)
        return d[x];
    else
    return d[x]=((solve(x/2)+solve((x-1)/2)+solve((x-2)/2)))%mod;
}
signed main()
{
    //初始条件
    d[0]=1;//a=b=0一组 
    d[1]=2; //a=b=0一组 ，a=b=1第二组； 
    int n;
    n=read(); 
    int ans=solve(n);
    printf("%lld\n",ans);
    return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> cost(n,2000);
    vector<int> vote(n, 0);
    for(int i = 0;i<n;i++){
        cin >> cost[i];
    }
    for(int i = 0;i<m;i++){
        int temp;
        cin >> temp;
        for(int j = 0;j<n;j++){
            if(temp >= cost[j]){
                vote[j]++;
                break;
            }
        }
    }
    int max_index = 0;
    for(int i = 0;i<n;i++){
        if(vote[max_index] < vote[i]){
            max_index = i;
        }
    }
    cout << max_index + 1 << endl;
    return 0;
}

Measured memory_bytes: 3096
S = input()
dp = [0] * (len(S) + 1)
dp[0] = 1

words = ["dream", "dreamer", "erase", "eraser"]
done = 'NO'

for i in range(len(S)):
    if dp[i] == 0:
        continue
    for w in words:
        if S[i:i+len(w)] == w:
            dp[i+len(w)] = 1
    
    if dp[len(S)] == 1:
        done = 'YES'
        break

print(done)

Measured memory_bytes: 3956
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){

        unsigned long long X;
        double m;
        unsigned long long out;
        double temp;
        scanf("%llu",&X);
        m = 0.5*(-1.0 + sqrt(1.0+8.0*X));
        out = m;
        temp = out;
        if( temp  <  m) out++;
        printf("%llu\n",out);
        return 0;
}

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

int main() {
    ll A,B,C,K;
    cin >> A >> B >> C >> K;

bool ans = false;
    rep(i,K){
        if(B*pow(2,i) > A && C*pow(2,K-i) > B*pow(2,i)){
            ans = true;
            break;
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }    
}

Measured memory_bytes: 4096
# coding:utf-8
# AOJ 2808 RUPC 2017 Password

import itertools

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


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


class RollingHash:
    def __init__(self, s, base, mod):
        self.s = s
        self.length = length = len(s)
        self.base = base
        self.mod = mod
        self.h = h = [0] * (length + 1)
        for i in range(length):
            h[i + 1] = (h[i] * base + ord(s[i])) % mod
        self.p = p = [1] * (length + 1)
        for i in range(length):
            p[i + 1] = pow(base, i + 1, mod)

    def get(self, l, r):
        mod = self.mod
        return ((self.h[r] - self.h[l] * self.p[r - l]) + mod) % mod


def solve():
    N = int(input())
    hash_list = []
    for _ in range(N):
        s = input()
        h1 = RollingHash(s, 103, MOD)
        hash_list.append((len(s), h1))

    ss = 'abcdefghijklmnopqrstuvwxyz'
    hash_set = set()
    for i in range(4 * 10 ** 5):
        for length, h1 in hash_list:
            for l in range(length - i):
                v1 = h1.get(l, l + i + 1)
                if v1 not in hash_set:
                    hash_set.add(v1)

        for s in itertools.product(ss, repeat=i + 1):
            v1 = RollingHash(s, 103, MOD).get(0, len(s))
            if v1 not in hash_set:
                return ''.join(s)

    return -1


print(solve())



Measured memory_bytes: 83824
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

/*
 N 1e5
 K 1e9
 Q 1e5
 */

int main(){
  
  // read problem
  long long int N, K, Q, tmp;
  std::vector<long long int> A, score;
  
  scanf("%lld%lld%lld", &N, &K, &Q);
  for(long long int i = 0; i < Q; i++){
    scanf("%lld", &tmp);
    A.push_back(tmp);
  }
  
  // solve problem
  for(long long int i = 0; i < N; i++){
    score.push_back(K);
  }
  
  for(long long int i = 0; i < Q; i++){
    score[A[i]-1]++;
  }
  
  // if score[i] > Q, the score left is positive
  for(long long int i = 0; i < N; i++){
    if(score[i] > Q){
      std::cout << "Yes" << std::endl;
    }
    else{
      std::cout << "No" << std::endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t;cin >> t;
    int n;cin >> n;
    vector<ll> s(n),e(n),sum(n+1);
    ll ans=0;
    for(int i=0;i<n;i++){
        cin >> s[i] >> e[i];
        sum[i+1]=sum[i]+e[i]-s[i];
    }
    for(int i=0;i<n;i++){
        int u=lower_bound(s.begin(),s.end(),s[i]+t)-s.begin();
        int v=lower_bound(e.begin(),e.end(),s[i]+t)-e.begin();
        if(u==v){
            chmax(ans,sum[u]-sum[i]);
        }
        else{
            chmax(ans,sum[v]-sum[i]+t+s[i]-s[v]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5220
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
char s[10000];
int main(){
	cin >> s;

	ll n = strlen(s);

	cout << s[0] << n - 2 << s[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> A = new ArrayList<Integer>();

        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
        int[][] A = new int[n][m];
        int[][] B = new int[m][l];
        long[][] C = new long[n][l];

        for (int i=0; i<n; i++) {
            for (int j=0; j<m; j++) {
                A[i][j] = sc.nextInt();
            }
        }

        for (int i=0; i<m; i++) {
            for (int j=0; j<l; j++) {
                B[i][j] = sc.nextInt();
            }
        }

        for (int i=0; i<n; i++) {
            for (int j=0; j<l; j++) {
                for (int k=0; k<m ; k++) {
                    C[i][j] += A[i][k] * B[k][j];
                }
                System.out.print(C[i][j]);
                if (j != l-1)
                    System.out.print(" ");
                else
                    System.out.println();
            }
        }



    }
}


Measured memory_bytes: 54028
N = int(input())
S = list(map(int,input().split()))
count = 0
color = list()

for i in range(len(S)):
  if S[i] < 400:
    S[i] = "grey"
    
  elif S[i] < 800:
    S[i] = "blown"
    
  elif S[i] < 1200:
    S[i] = "green"
  
  elif S[i] < 1600:
    S[i] = "water"
    
  elif S[i] < 2000:
    S[i] = "blue"
  
  elif S[i] < 2400:
    S[i] = "yellow"
  
  elif S[i] < 2800:
    S[i] = "orange"
   
  elif S[i] < 3200:
    S[i] = "red"
    
  elif 3200 <= S[i]:
    S[i] = "wanwan"
    count += 1
  color.append(S[i])


color_set = set(color)

if count == 0:
  print(len(color_set),len(color_set))
elif count >= 1 and len(color_set) == 1:
  print(len(color_set),len(color_set) + count -1)
else:
  print(len(color_set) -1,len(color_set) + count -1)
    
  
         

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        long n = scanner.nextLong();
        long m = scanner.nextLong();
        long d = scanner.nextLong();

        long a = n * n;
        long b = 0;
        if (d == 0) {
            b = n;
        } else {
            b = (n - d) * 2;
        }

        long total = n*n;
        long hit = b;

        double ans = ((double)hit / (double)total) * (m-1);

        //System.out.println("total="+total);
        //System.out.println("hit="+hit);
        System.out.println(ans);
    }

    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () { s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in)); }
        public String next() {
            try {
                if (i < s.length) return s[i++]; String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0); i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int main() {
    ios :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    long long a, b; cin >> n >> a >> b;
    long long ans = 0;
    int old; cin >> old;
    for (int i = 1; i < n; ++ i) {
        int x; cin >> x;
        ans += min(1LL * (x - old) * a, b);
        old = x;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>):Unit {
    var (n, q) = readLine()!!.split(' ').map(String::toInt)
    while (n!=0 || q!=0){
    val list = Array(n) { 0 }
        val size = list.size
        var pos = 0
        var stock = q
        while (list.filter { it != 0 }.size != 1 || stock !=0) {
            if (stock > 0) {
                list[pos]++
                stock--
            } else {
                stock = list[pos]
                list[pos] = 0
            }
            pos = if (pos == size - 1) 0 else pos + 1
        }
        println(list.indexOfFirst { it != 0 })
        readLine()!!.split(' ').map(String::toInt).apply {
            n = first()
            q = last()
        }
    }
}


Measured memory_bytes: 218796
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  priority_queue<P> que, que2;
  priority_queue<P, vector<P>, greater<P>> que3;

  for(int i = 0; i < A; i++){
    int x;
    cin >> x;
    que.push(P(x, 1));
  }
  for(int i = 0; i < B; i++){
    int x;
    cin >> x;
    que.push(P(x, 2));
  }
  for(int i = 0; i < C; i++){
    int x;
    cin >> x;
    que2.push(P(x, 0));
  }

  ll ans = 0;
  while((X > 0 || Y > 0) && !que.empty()){
    int px, py;
    px = que.top().first;
    py = que.top().second;
    que.pop();

    if(py == 1){
      if(X > 0){
        ans += (ll)px;
        X--;
        que3.push(P(px, 1));
      }
    }
    else if(py == 2){
      if(Y > 0){
        ans += (ll)px;
        Y--;
        que3.push(P(px, 1));
      }
    }
  }

  while(X > 0 || Y > 0){
    
    int pxx = que2.top().first;
    int pyy = que2.top().second;
    if(X > 0){
      ans += pxx;
      que2.pop();
      X--;
    }
    else if(Y > 0){
      ans += pxx;
      que2.pop();
      Y--;
    }
  }

  while(true){
    if(que2.empty()) break;
    int pxx = que2.top().first;
    int pyy = que2.top().second;
    int px, py;
    px = que3.top().first;
    py = que3.top().second;
    if(pxx > px){
      ans -= px;
      ans += pxx;
      que3.pop();
      que2.pop();
    }
    else break;
  }

  cout << ans << endl;

}


Measured memory_bytes: 6000
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
int main(){
  ll n; cin >> n;
  if(n == 0){
    cout << 0 << endl;
    return 0;
  }
  string s = "";
  ll d = 1;
  while(n != 0){
    //cerr << n << " " << d << " " << s << endl;
    if(n % (d*2) == 0)
      s += '0';
    else{
      s += '1';
      n -= d;
    }
    d *= -2;
  }
  reverse(ALL(s));
  cout <<  s << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
$array = explode(' ', trim(fgets(STDIN)));

$count = 0;

if (isGusu($array)) {
  while (true) {
    $count++;
    for ($i = 0; $i < $n; $i++) {
      $array[$i] = $array[$i] / 2;
    }
    if (isGusu($array) == false) {
      break;
    }
  }
}

function isGusu($array) {
  $len = count($array);
  for ($i = 0; $i < $len; $i++) {
    if ($array[$i] % 2 == 1) {
      return false;
    } 
  }
  return true;
}

echo $count;

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


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


Measured memory_bytes: 256
def x_yet_another_die_game(x: int)->int:
    n = x // 11
    if x == n * 11:
        return 2 * n
    if x <= n * 11 + 6:
        return 2 * n + 1
    return 2 * n + 2


if __name__ == "__main__":
    x = int(input())
    ans = x_yet_another_die_game(x)
    print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		char[] arrayc = input.toCharArray();
		int[] a = new int[arrayc.length];

		for(int i = 0; i < arrayc.length; i++) {
			a[i] = Character.getNumericValue(arrayc[i]);
		}

		if(a[0] + a[1] + a[2] + a[3] == 7) {
			System.out.println(a[0] + "+" + a[1] + "+" + a[2] + "+" + a[3] + "=" + "7");

		} else if(a[0] + a[1] + a[2] - a[3] == 7) {
			System.out.println(a[0] + "+" + a[1] + "+" + a[2] + "-" + a[3] + "=" + "7");

		} else if(a[0] + a[1] - a[2] + a[3] == 7) {
			System.out.println(a[0] + "+" + a[1] + "-" + a[2] + "+" + a[3] + "=" + "7");

		} else if(a[0] + a[1] - a[2] - a[3] == 7) {
			System.out.println(a[0] + "+" + a[1] + "-" + a[2] + "-" + a[3] + "=" + "7");

		} else if(a[0] - a[1] - a[2] - a[3] == 7) {
			System.out.println(a[0] + "-" + a[1] + "-" + a[2] + "-" + a[3] + "=" + "7");

		} else if(a[0] - a[1] - a[2] + a[3] == 7) {
			System.out.println(a[0] + "-" + a[1] + "-" + a[2] + "+" + a[3] + "=" + "7");

		} else if(a[0] - a[1] + a[2] - a[3] == 7) {
			System.out.println(a[0] + "-" + a[1] + "+" + a[2] + "-" + a[3] + "=" + "7");

		} else if(a[0] - a[1] + a[2] + a[3] == 7) {
			System.out.println(a[0] + "-" + a[1] + "+" + a[2] + "+" + a[3] + "=" + "7");
		}



	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        A[i] *= 2;
        if (i != 0) A[i] += A[i-1];
    }
    auto it = lower_bound(A.begin(), A.end(), A[N-1]/2);
    long long ans = INT64_MAX;
    if (it != A.end()) ans = abs(A[N-1]/2-*it);
    if (it != A.begin()) {
        it = prev(it);
        ans = min(ans, abs(A[N-1]/2-*it));
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1792
from bisect import bisect_left

N = int(input())

A = [int(input()) for _ in range(N)]

LIS = [A[0]]                            # i番目の成分 = 長さ i+1 の増加部分列の最後の要素の値

for a in A[1:]:
    if a > LIS[-1]:                     # 最大の長さの増加部分列の最後の要素より大きい値なら、これを用いて１つ長い増加部分列を作ることができる。
                                        # 更新前の最長増加部分列 = [..., L[-1]]、更新後の最長増加部分列 = [..., L[-1], a]
        LIS.append(a)
    else:
        LIS[bisect_left(LIS, a)] = a    # 最長ではない増加部分列の最後の要素を小さい値に更新。これにより、a > LIS[-1] を満たす可能性が増える。

print(len(LIS))


Measured memory_bytes: 11136
#include<stdio.h>
int main(void)
{

int a,b,c,d;
 
scanf("%d %d %d",&a,&b,&c);

if(a>b)
{
 d=a;
 a=b;
 b=d;
 
}


if(a>c)
{
 d=a;
 a=c;
 c=d;
}

if(b>c)
{
 d=b;
 b=c;
 c=d;
}
printf("%d %d %d\n",a,b,c);
return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan  = new Scanner(System.in);
		int N = scan.nextInt();
		int X = scan.nextInt();
		int[] distance = new int[N];
		for (int i = 0; i < distance.length; i++) {
			distance[i] = Math.abs(X - scan.nextInt());
		}
		System.out.println(exGcd(distance));
	}

	public static int exGcd(int[] a) {
		if (a.length == 1) {
			return a[0];
		}

		int gcdResult = gcd(a[0], a[1]);
		for (int i = 2; i < a.length; i++) {
			gcdResult = gcd (gcdResult, a[i]);
		}
		return gcdResult;
	}

	public static int gcd(int a, int b) {
		if (a < b) {
			int temp = a;
			a = b;
			b = temp;
		}

		int c = a % b;
		if (c == 0) {
			return b;
		}

		return gcd(b, c);

	}
}


Measured memory_bytes: 49408
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;


#define ll          long long
#define pb          push_back
#define pii         pair<int ,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int



int solve( ){
 

ll n,m;
cin>>n>>m;
vector< pair<ll,ll> > v;
rep(i,0,n)
 {
  ll x,y;
  cin>>x>>y;
  v.pb({x,y});
 }
 sort(all(v));
 ll sum=0;

 rep(i,0,n)
 {
      if(v[i].SS>=m)
      {
       
        sum+=m*v[i].FF;
         m=-1;
      }
      else
      {
        m-=v[i].SS;
        sum+=(v[i].FF*v[i].SS);
      }
      if(m<=0)break;

 }
 cout<<sum;

return 0;
}
int main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);

  
  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
   while(t--)
     {solve();
     }

         time_req = clock() - time_req;
   // cout << "Processor time taken is "
     //  << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}


Measured memory_bytes: 2420
#include <cstdio>
#include <algorithm>

#define REP(i,n) for(int i=0;i<n;i++)
int N, M;
int K;

bool flag[31][31];

int main() {
  scanf("%d %d\n", &N, &M);

  REP(i, 31) {
    REP(j, 31) flag[i][j] = false;
  }

  REP(i, N) {
    scanf("%d", &K);
    REP(j, K) {
      int tmp;
      scanf("%d", &tmp);
      flag[i][tmp-1] = true;
    }
    scanf("\n");
  }
  int ans = 0;
  REP(i, M) {
    bool f = true;
    REP(j, N) f = f && flag[j][i];
    if (f) ans++;
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 128
s = gets.chomp
t = gets.chomp

wd = {}
s.chars.each.with_index do |c, i|
  wd[c] ||= []
  wd[c] << i
end

cnt = p = 0
fst = true
t.chars.each do |c|
  d = wd[c]

  if d.nil?
    puts -1
    exit
  end

  if fst
    fst = false
    next if d[0] == 0
  end

  if d[-1] <= p
    p = d[0]
    cnt += 1
    next
  end

  if d[0] > p
    p = d[0]
    next
  end

  p = d.bsearch { |i| i > p }
end

puts s.length * cnt + p + 1

Measured memory_bytes: 14840
#define rep(i,x) for (int i = 0; i < x; i++)
#define mod 1000000007
#define MOD 998244353
#define INF 1<<62
#define inf 1<<30
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;


int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	vector<int> b;
	rep(i, n) {
		int max = 0;
		rep(j, a.size()) {
			if (a[j] == j+1) max = j+1;
		}
		if (max == 0) {
			cout << -1 << endl;
			return 0;
		}
		else {
			b.push_back(max);
			a.erase(a.begin() + max-1);
		}
	}
	rep(i, n) {
		cout << b[n - i - 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
from math import sqrt
from collections import Counter

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n, y = MI()

    for i in range(n + 1):
        for j in range(n + 1 - i):
            otoshidama = 10000 * i + 5000 * j + 1000 * (n - i - j)
            if otoshidama == y:
                print("{} {} {}".format(i, j, n - i - j))
                exit()
    print("-1 -1 -1")

    pass


if __name__ == "__main__":
    main()


Measured memory_bytes: 38768
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using o_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) find_by_order(i)
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define mod 998244353
#define rep(i, a, b) for(int i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
// #define int ll
vl ft(1, 1LL);

/*======================================================================*/
ll power(ll x, ll y) {
    ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
ll add(ll a, ll b){a += b; return a>=mod?a-mod:a;}
ll sub(ll a, ll b){a -= b; return (a<0?a+mod:a);}
ll mult(ll a, ll b){return (a*b)%mod;}
int dp[305][305][305];
void solve(){
    fact(1000);
    string s;
    int steps, n, len;
    cin >> s >> steps;
    n = s.length();
    vi last;
    rep(i, 0, n)if(s[i] == '0')last.pb(i+1);
    len = last.size();
    if(len == 0){
        cout << 1;
        return;
    }
    steps = min(steps, n-len);
    dp[0][0][0] = 1;
    int prevj = 0;
    rep(i, 1, len+1){
        int l = last[i-1];
        for(int cur = n-len+i; cur >= l; cur--){
            for(int j = prevj; j < cur; j++){
                int lim =max(0, (cur-j) - (l-prevj));
                for(int k = 0; k + lim <= steps; k++){
                    dp[i][cur][k+lim] = add(dp[i][cur][k+lim], dp[i-1][j][k]);
                }
            }
        }
        prevj = l;
    }
    int ans = 0;
    for(int i = last[len-1]; i <= n; i++){
        rep(j, 0, steps+1){
            ans = add(ans, dp[len][i][j]);
        }
    }
    cout << ans;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 30452
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")

# https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/all/DSL_1_B
import sys
sys.setrecursionlimit(1000000)

A,V = map(int,sys.stdin.readline().split())
B,W = map(int,sys.stdin.readline().split())
T = int(sys.stdin.readline().rstrip())

if A==B:
    print("YES")
    exit()
if W-V>=0:
    print("NO")
    exit()
if abs(A-B)/(V-W)<=T:
    #print(abs(A-B)/(V-W))
    print("YES")
    exit()
print("NO")


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

typedef pair<int,int> P;

int h,w,s,all;
int u[35][35] = {0};
int f[35][35] = {0};
// ツδ?δつ可サ, DP
P dp[35][35][35][35];

// [x1,x2] && [y1,y2] ツづ個療個暗ヲツづ個堕債和ツづーツ計ツ算ツつキツづゥ.
int sum(int x1, int y1, int x2, int y2){
	x2++; y2++;
	return f[y2-1][x2-1] - f[y2-1][x1-1] - f[y1-1][x2-1] + f[y1-1][x1-1];
}

// ツ渉可甘コツ可サ.
void init(){
	for(int i=0 ; i < 35 ; i++ ){
		for(int j=0 ; j < 35 ; j++ ){
			for(int k=0 ; k < 35 ; k++ ){
				for(int l=0 ; l < 35 ; l++ ){
					dp[i][j][k][l].first = dp[i][j][k][l].second = 0;
				}
			}
		}
	}
}

// ツδ?δつ可サツ催?帰, P.first := ツ催?妥・ツグツδ仰ーツプツ青? P.second := ツ催?妥・ツ予ツ氾オツ療?
P dfs(int lx, int ly, int rx, int ry){
	if( dp[lx][ly][rx][ry].first != 0 ) return dp[lx][ly][rx][ry];
	
	P res = P( 1 , s - (all - sum(lx,ly,rx,ry)) );
	
	// ツ青?閉スツづ可閉ェツ環?
	for(int y=ly ; y < ry ; y++ ){
		if( all - s > sum(lx,ly,rx,y) ) continue;
		if( all - s > sum(lx,y+1,rx,ry) ) continue;
		P a = dfs( lx , ly  , rx , y );
		P b = dfs( lx , y+1 , rx , ry );
		P now = P( a.first + b.first , min(a.second,b.second) );
		res = max( res , now );
	}
	
	// ツ青つ陳シツづ可閉ェツ環?
	for(int x=lx ; x < rx ; x++ ){
		if( all - s > sum(lx,ly,x,ry) ) continue;
		if( all - s > sum(x+1,ly,rx,ry) ) continue;
		P a = dfs(lx,ly,x,ry);
		P b = dfs(x+1,ly,rx,ry);
		P now = P( a.first + b.first , min(a.second,b.second) );
		res = max( res , now );
	}
	return dp[lx][ly][rx][ry] = res;
}

int main(){
	while( cin >> h >> w >> s, h || w || s ){
		//ツ禿シツ療?+ ツ療敖静渉和ツ可サ
		for(int y = 1 ; y <= h ; y++ ){
			for(int x = 1 ; x <= w ; x++ ){
				cin >> u[y][x];
				f[y][x] = u[y][x] + f[y][x-1];
			}
		}
		for(int y = 1 ; y <= h ; y++ ){
			for(int x = 1 ; x <= w ; x++ ){
				f[y][x] += f[y-1][x];
			}
		}
		init();
		all = sum(1,1,w,h);
		P ans = dfs( 1 , 1 , w , h );
		cout << ans.first << " " << ans.second << endl;
	}
}

Measured memory_bytes: 12000
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

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

int main() {
    int A, B;
    cin >> A >> B;

    for(int i=1; i<=2000; ++i) {
        int ret1 = (double)i * (double)0.08;
        int ret2 = (double)i * (double)0.1;
        if(ret1 == A && ret2 ==B) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}


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

public class Main {

    static int dp[];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int count = 0;
        dp = new int[N+1];
        Arrays.fill(dp,-1);

        System.out.println(dpfunc(N));

    }

    static int dpfunc(int n ){
        if(dp[n] != -1) return dp[n];
        if(n==0) return 0;

        int min = Integer.MAX_VALUE;
        if(n-1>=0){
            int res = dpfunc(n-1);
            min = res<min?res:min;
        }
        int num = 1;
        while(n-Math.pow(6,num) >=0){
            int res = dpfunc((int)(n-Math.pow(6,num)) );
            min = res<min?res:min;
            num++;
        }
        num = 1;
        while(n-Math.pow(9,num) >=0){
            int res = dpfunc((int)(n-Math.pow(9,num)) );
            min = res<min?res:min;
            num++;
        }

        dp[n]= min+1;
        return min+1;
    }

}


Measured memory_bytes: 30780
#include<iostream>
using namespace std;
int main(){
int a,b,c,i,j;
while(cin>>a>>b,a) {
int d[20][20]={0};
bool e[20][20]={0};
cin>>c;
while(c--){
cin>>i>>j;
e[i][j]=1;
}
d[1][1]=1;
for(i=1;i<=a;i++){
for(j=1;j<=b;j++){
if(e[i][j])continue;
d[i][j]+=d[i-1][j]+d[i][j-1];
}
}
cout<<d[a][b]<<endl;
}
}

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

int main() {
    int n, c=0;
    cin >> n;
    for (int i = 1; i <= n; i+=2) {
        int y = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) y++;
        }
        if (y == 8) c++;
    }
    cout << c << endl;
}

Measured memory_bytes: 256
n,m,q = gets.split.map(&:to_i)
shr = Array.new(n,0)
tem = Array.new(m,0)
que = Array.new(q,0)
n.times {|i| shr[i] = gets.to_i}
m.times {|i| tem[i] = gets.to_i}
q.times {|i| que[i] = gets.to_i}
shr.push(10**10+1)
tem.push(10**10+1)
for i in 0..q-1
  check = []
  ok = n
  ng = -1
  while (ok - ng).abs > 1
    mid = (ok + ng) / 2
    if shr[mid] < que[i]
      ng = mid
    else
      ok = mid
    end
  end
  check[0] = ok
  ok = m
  ng = -1
  while (ok - ng).abs > 1
    mid = (ok + ng) / 2
    if tem[mid] < que[i]
      ng = mid
    else
      ok = mid
    end
  end
  check[1] = ok
  a = [shr[check[0]],tem[check[1]]].max - que[i]
  b = que[i] - [shr[check[0]-1],tem[check[1]-1]].min
  c = que[i] - shr[check[0]-1]*2 + tem[check[1]]
  d = que[i] - tem[check[1]-1]*2 + shr[check[0]]
  e = shr[check[0]]*2 - que[i] - tem[check[1]-1]
  f = tem[check[1]]*2 - que[i] - shr[check[0]-1]
  if check[0] == 0
    b = 10**12
    c = 10**12
    f = 10**12
  end
  if check[1] == 0
    b = 10**12
    d = 10**12
    e = 10**12
  end
  if check[0] == n
    a = 10**12
    d = 10**12
    e = 10**12
  end
  if check[1] == m
    a = 10**12
    c = 10**12
    f = 10**12
  end
  ans = [a,b,c,d,e,f].min
  puts ans
end


Measured memory_bytes: 5500
#!/usr/bin/python3
# abc121_a
"""
White Cells
"""

def main():
    """
    全体から塗った分を引く。
    """
    H, W = map(int, input().split())
    h, w = map(int, input().split())
    print((H-h) * (W-w))

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n = int(input())
people = [[] for i in range(n)]
for i in range(n):
  a = int(input())
  for j in range(a):
    say = tuple(map(int,input().split()))
    people[i].append(say)

ans = 0
for i in range(2**n):
  TF = [ 1 & i >> j for j in range(n)]
  bool = True
  for j in range(n):
    if TF[j] == 1:
      for says in people[j]:
        if TF[says[0]-1] == says[1]:
          pass
        else:
          bool = False
          break
    else:
      pass

  if bool:
    ans = max(ans,TF.count(1))

print(ans)
    

Measured memory_bytes: 3064
n = int(input())

dic = {}
for i in range(n):
    #a_L.append(input())
    dic[i+1] = int(input())

ans = 0
b = 1
for _ in range(n+1):
    b = dic[b]
    ans += 1
    if b == 2:
        print(ans)
        exit()

print(-1)

Measured memory_bytes: 55384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double DB;

#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define R(i,n) for(int i=0;i<(n);++i)
#define fill(a,b) memset(a,b,sizeof(a))

const int maxn = 1e5 + 10;
char s[maxn];

int main()
{
	//freopen("test.txt","r",stdin);
	scanf("%s",s);
	int n = strlen(s);
	R(i,n-1) 
	{
		if(s[i] == s[i+1])
		{
			printf("%d %d\n",i+1,i+2);
			return 0;
		}
		if(i+2 < n && s[i] == s[i+2])
		{
			printf("%d %d\n",i+1,i+3);
			return 0;
		}
	}
	puts("-1 -1");
	return 0;
}


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

main()
{
	multiset<pair<int,int> > ms;
	multiset<pair<int,int> >::iterator it;
	int array[12347];
	priority_queue<int> q;
	int n,m,i,j,len,a,b;
	int flag=0;
	int cou=0;
	int max=0;
	long long k;
	scanf("%d %lld",&n,&k);
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&a,&b);
		ms.insert({a,b});
	}
	for(it=ms.begin();it!=ms.end();it++)
	{
		k-=it->second;
		if(k<=0)
		{
			printf("%d",it->first);
			break;
		}
	}
	
//	printf("%d",*it);
	
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A==B) {
    cout << C << endl;
  }
  else {
    if (B==C) {
      cout << A << endl;
    }
    else {
      cout << B << endl;
    }
  }
}


Measured memory_bytes: 3616
from collections import deque
n, Q = map(int, input().split())
edges = [[] for _ in range(n+1)]
count = [0]*(n+1)
q = deque()
q.append((1, 0))

for _ in range(n-1):
    a, b = map(int, input().split())
    edges[a].append(b)
    edges[b].append(a)
for _ in range(Q):
    p, x = map(int, input().split())
    count[p] += x

while(q):
    k = q.popleft()
    count[k[0]] += count[k[1]]
    for i in edges[k[0]]:
        if not i == k[1]:
            q.append((i, k[0]))

print(*count[1:])


Measured memory_bytes: 105804
#include <iostream>
using namespace std;
#define x1 (long long)1e9
int main()
{
	long long s;
	cin >> s;
	long long y2=(s+x1-1)/x1;
	cout << "0 0 " << x1 << ' ' << 1 << ' ' << x1*y2-s << ' ' << y2;
}

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

using namespace std;

using ll = long long;

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

    ll n, sum = 0;

    cin >> n;
    ll tmp = n;
    while (tmp) {
        sum += (tmp % 10);
        tmp /= 10;
    }

    if (n % sum == 0) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100
using namespace std;
typedef pair<int,int> PII;
int n,tot,anstot;
PII S[MAXN*MAXN+5],edges[MAXN*MAXN+5];
void AddEdge(int u,int v)
{
	edges[++anstot]=PII(u,v);
}
int main()
{
	scanf("%d",&n);
	if(n%2==0)
	{
		for(int i=1;i<=n/2;i++)
			S[tot++]=PII(i,n-i+1);
		for(int i=0;i<tot;i++)
		{
			if(tot==2&&i==tot-1)
				break;
			AddEdge(S[i].first,S[(i+1)%tot].second);
			AddEdge(S[i].second,S[(i+1)%tot].first);
			AddEdge(S[i].first,S[(i+1)%tot].first);
			AddEdge(S[i].second,S[(i+1)%tot].second);
		}
	}
	else
	{
		for(int i=1;i<=n/2;i++)
			S[tot++]=PII(i,n-i);
		S[tot++]=PII(n,n);
		for(int i=0;i<tot;i++)
		{
			if(tot==2&&i==tot-1)
				break;
			AddEdge(S[i].first,S[(i+1)%tot].second);
			AddEdge(S[i].second,S[(i+1)%tot].first);
			if(i!=tot-1&&i!=tot-2)
			{
				AddEdge(S[i].first,S[(i+1)%tot].first);
				AddEdge(S[i].second,S[(i+1)%tot].second);
			}
		}
	}
	printf("%d\n",anstot);
	for(int i=1;i<=anstot;i++)
		printf("%d %d\n",edges[i].first,edges[i].second);
	return 0;
}

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

int	main()
{
	int64_t	N, K;
	cin >> N >> K;
	int64_t	A;
	Graph	graph(N);
	for (int64_t i = 0; i < N; ++i) {
		cin >> A;
		--A;
		graph.at(i).push_back(A);
	}
	int64_t	cycle_size = -1;
	vector<int64_t>	cost(N, -1);
	vector<int64_t>	order(N, -1);
	order.at(0) = 0;
	cost.at(0) = 0;
	queue<int64_t>	que;
	que.push(0);
	int64_t	head_cycle = -1;
	while (!que.empty()) {
		int64_t	s = que.front();
		que.pop();
		for (int64_t d : graph.at(s)) {
			int64_t	cost_d = cost.at(s) + 1;
			if (cost.at(d) >= 0) {
				cycle_size = cost_d - cost.at(d);
				head_cycle = d;
				break;
			}
			if (cost.at(d) == -1) {
				cost.at(d) = cost_d;
				order.at(cost.at(d)) = d;
				que.push(d);
			}
		}
		if (cycle_size > 0)
			break;
	}
	int64_t	goal;
	int64_t	len_in_cycle = K - cost.at(head_cycle); 
	if (len_in_cycle > 0) {
		goal = order.at(len_in_cycle % cycle_size + cost.at(head_cycle));
	} else {
		goal = order.at(K);
	}
	cout << goal + 1 << endl;
}







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

int main(){
  int n;
  cin >> n;
  bool flag = 0;
  rep(i,3){
    int d = n % 10;
    if(d == 7) flag = 1;
    n = n / 10;
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c, d, N, ans=0;
    vector<int> v(3);
    vector<char> L(3);
    char tmp, tmp2;
    string S, S2, S3;
    bool flag=true;
    
    cin >> a >> b;
    ans = a<=b ? a:a-1;
    

    
    // ans = min(A, B) + min(C, D);
    cout << ans<< endl;

    // if(S[1]==S[2] &&(S[0]==S[1] | S[2]==S[3]))
    // 	cout << "Yes" <<endl;
    // else
    // 	cout << "No" <<endl;

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(flag)
    // 	puts("YES");
    // else
    // 	puts("NO");
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7; //10の9乗

int main(){
    //C2つでSが作れる
    ll N, M;
    cin >> N >> M;

    //Sが多い時
    if(N * 2 > M) {
        cout << M / 2;
        return 0;
    }

    //Cが多いとき
    ll count = 0;
    M -= N * 2;
    count += N;
    count += M / 4;
    cout << count << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

ll INF = (1ll << 32);
double EPS = 1e-4;

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

  vi s(N), t(N), c(N);
  for (ll i = 0; i < N; i++) {
    cin >> s[i] >> t[i] >> c[i];
  }

  {
    vpii v;
    for (ll i = 0; i < N; i++) {
      v.push_back(make_pair(s[i], i));
    }
    sort(v.begin(), v.end());

    vi v1(N), v2(N), v3(N);
    for (ll i = 0; i < N; i++) {
      v1[i] = s[v[i].second];
      v2[i] = t[v[i].second];
      v3[i] = c[v[i].second];
    }

    s.swap(v1);
    t.swap(v2);
    c.swap(v3);
  }

  for (ll i = 1; i <= C; i++) {
    vpii v(i);
    bool ok = true;

    for (ll j = 0; j < i; j++) {
      v[j] = make_pair(0, 0);
    }

    ll cnt = 0;

    for (ll j = 0; j < N; j++) {
      for (ll k = 0; k < i; k++) {
        if (v[k].second == c[j]) {
          if (v[k].first <= s[j]) {
            cnt += 1;
            v[k] = make_pair(t[j], c[j]);
            break;
          }
        } else {
          if (v[k].first < s[j]) {
            cnt += 1;
            v[k] = make_pair(t[j], c[j]);
            break;
          }
        }
      }
    }

    if (cnt == N) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 6512
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;

int main(){
    string S;
    cin >> S;
    if (S.size() < 2){
        cout << 0;
        return 0;
    }
    int cnt0=0, cnt1=0;
    for(int i=0; i<S.size(); ++i){
        if(S[i] == '1') ++cnt1;
        else ++cnt0;
    }
    int ans = cnt0 < cnt1 ? cnt0 : cnt1;
    cout << ans * 2;
    return 0;
}

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

int main() {
    int N;
    int max = 0;
    int min = 1100000000;
    cin >> N;
    int A[110];
    for(int i = 0; i < N; ++i) {
        cin >> A[i];
        if(max < A[i]) max = A[i];
        if(A[i] < min) min = A[i];
    }
    cout << max - min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;


vector<bool> seen(7);

int main()
{
    int n;
    cin >> n;
    vector<int> a(4);
    rep(i,4)a[i]=0;
    rep(i,n){
        string s;
        cin>>s;
        if(s=="AC")a[0]++;
        else if(s=="WA")a[1]++;
        else if(s=="TLE")a[2]++;
        else a[3]++;
    }

    cout<<"AC x "<<a[0]<<endl;
    cout<<"WA x "<<a[1]<<endl;
    cout<<"TLE x "<<a[2]<<endl;
    cout<<"RE x "<<a[3]<<endl;
    return 0;
}


Measured memory_bytes: 3624
N = list(int(i) for i in input())
A = []
for i in range(2):
    for j in range(2):
        for k in range(2):
            x = N[0]
            if i == 0:
                x += N[1]
            else:
                x -= N[1]

            if j == 0:
                x += N[2]
            else:
                x -= N[2]

            if k == 0:
                x += N[3]
            else:
                x -= N[3]
            if x == 7:
                A.append(i)
                A.append(j)
                A.append(k)
                break
ans = str(N[0])
for l in range(3):
    if A[l] == 0:
        ans += "+"
    else:
        ans += "-"
    ans += str(N[l+1])
ans += "=7"
print(ans)

Measured memory_bytes: 3064
H,W=[int(x) for x in input().split()]
import heapq
A=[]
temp=0
for i in range(H):
	s=input()
	A.append(s)
	for j in range(W):
		if s[j]==".":
			temp+=1


B=[[1000000000000000 for i in range(W)] for j in range(H)]

#print(A)

queue=[]
heapq.heapify(queue)
heapq.heappush(queue,[1,0,0])
#print(queue)
ans=100000000000000000000
B[0][0]=1
while queue:
	#print(queue)
	count,x,y=heapq.heappop(queue)
	#print(count,x,y)
	if x==H-1 and y==W-1:
		ans=min(ans,count)
	else:
		if (x+1<=H-1 and A[x+1][y]==".") and B[x+1][y]>count+1:
			heapq.heappush(queue,[count+1,x+1,y])
			B[x+1][y]=count+1
		if (0<=x-1 and A[x-1][y]==".") and B[x-1][y]>count+1:
			heapq.heappush(queue,[count+1,x-1,y])
			B[x-1][y]=count+1
		if (y+1<=W-1 and A[x][y+1]==".") and B[x][y+1]>count+1:
			heapq.heappush(queue,[count+1,x,y+1])
			B[x][y+1]=count+1
		if (0<=y-1 and A[x][y-1]==".") and B[x][y-1]>count+1:
			heapq.heappush(queue,[count+1,x,y-1])
			B[x][y-1]=count+1
if ans==100000000000000000000:
	print(-1)
else:
	print(temp-ans)
	




Measured memory_bytes: 45548
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)






int main(void)
{

	long long a;
	cin >> a;
	long long  pow = 1;

	for (int i = 1; i <= a;i++)
	{
		pow *= i;
		pow %= 1000000007;
	}

	cout<<pow<<endl;


}


Measured memory_bytes: 256
import math

n = int(input()) 
total = 0
for a in range(1, n + 1):
    for b in range(1, n + 1):
        g = math.gcd(a ,b)
        if g == 1:
            total += n
        else:
            for c in range(1, n + 1):
                total += math.gcd(g, c)

print(total)    

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

using namespace std;

int main(void){
  int N;
  cin >> N;
  vector<int> H;
  H.resize(N);
  for (int i = 0; i < N;i++){
    cin >> H[i];
  }

  int count = 1;

  for (int i = 1; i < N; i++){
    bool flag = true;

    for (int j = 0; j < i; j++){
      if(H[j]>H[i]){
        flag = false;
        continue;
      }
    }
    if(flag==true){
      count++;
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll dsum(ll d, ll a) {
	ll ret = 0;
	while(a > 0) {
		ret += a % d;
		a /= d;
	}
	return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, s;
	cin >> n >> s;
	FOR(i, 2, n + 1) {
		if(i <= round(sqrt(n))) {
			if(dsum(i, n) == s) {
				cout << i << endl;
				return 0;
			}
		} else {
			ll k = n / i, d = n % i;
			if(k + d >= s && s >= k && (k + d - s) % k == 0) {
				cout << i + (k + d - s) / k << endl;
				return 0;
			}
			i = n / k;
		}
	}
	if(s == n) {
		cout << n + 1 << endl;
	} else {
		cout << -1 << endl;
	}
	return 0;
}

/* --------------------------------------- */


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

class Student:
    def __init__(self, id, toukou):
        self.id = id
        self.toukou = toukou


def solve():
    N = int(input())
    As = list(map(int, input().split()))
    ans = []
    for i, a in enumerate(As):
        ans.append(Student(i+1, a))

    ans.sort(key=lambda x: x.toukou)

    ans1 = []
    for student in ans:
        ans1.append(student.id)

    print(*ans1)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 30692