akhauriyash/Code-Regression huggingface dataset:
class UnionFind():
    #要素数nで初期化
    #インスタンス変数の初期化
    def __init__(self, n):
        #root : 木の要素数
        #rnk : 木の高さ(rank)
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    
    """ノードxのrootノードを見つける"""
    def Find_Root(self, x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x]) 
            return self.root[x]
    
    """木の合併"""
    def Union(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        
        #既に同じ木に所属する場合
        if (x==y):
            return 
        
        #異なる木に所属する場合
        elif (self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            
            #rnkが同じ場合
            if self.rnk[x]==self.rnk[y]:
                self.rnk[y] += 1
    
    """xとyが同じグループに所属するか"""
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    
    """ノードxが属する木のサイズ"""
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
    
n,m = map(int,input().split())
uf = UnionFind(n)
for i in range(m):
    x,y,z = map(int,input().split())
    uf.Union(x-1, y-1)
tank = set([])
for i in range(n):
    tank.add(uf.Find_Root(i))
print(len(tank))

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

int main()
{
    int N,K,Q,x,count=0;
    cin>>N>>K>>Q;

    vector <int> a(N);

    for(int i=0;i<a.size();i++)
    {
        a[i]=K;
    }
    for(int i=0;i<Q;i++)
    {
        cin>>x;
        a[x-1]+=1;
        count++;
    }

    for(int i=0;i<a.size();i++)
    {
        if(a[i]-count<=0)
        {
            cout<<"No"<<endl;
        }
        else
        {
            cout<<"Yes"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 100005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

vector<int> gr[lim];
ll dp[lim][2] = {};

void dfs(int u, int pa){
	dp[u][0] = dp[u][1] = 1;
	for(int v:gr[u]) if(v!=pa){
		dfs(v,u);
		dp[u][0] = (dp[u][0] * ((dp[v][0] + dp[v][1])%mod))%mod;
		dp[u][1] = (dp[u][1] * dp[v][0])%mod;
	}
}

int main()
{
	int i,j,n,u,v,ans = 0;
	cin>>n;
	
	for(i=1; i<n; i++){
		cin>>u>>v;
		gr[u].pb(v);
		gr[v].pb(u);
	}
	
	dfs(1,0);

	cout<<(dp[1][0] + dp[1][1])%mod;
}


Measured memory_bytes: 14208
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

struct BIT {
    int n;
    vector<int> bit; // 1-indexd

    BIT(int sz) {
        bit.resize(sz + 1);
        n = sz;
    }

    int sum(int i) {
        int s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, int x) {
        while (i <= n) {
            bit[i] += x;
            i += i & -i;
        }
    }
};

bool check(const vector<int>& a, int x) {
    vector<int> sum(a.size() + 1);
    REP(i, a.size()) {
        int val = a[i] >= x ? 1 : -1;
        sum[i + 1] = sum[i] + val;
    }

    BIT bit(sum.size() * 2 + 2);

    int num = 0;
    int offset = sum.size() + 1;
    REP(i, sum.size()) {
        num += bit.sum(sum[i] + offset);
        bit.add(sum[i] + offset, 1);
    }

    int total = (int) a.size() * ((int) a.size() + 1) / 2LL;
    int val = (total + 1) / 2;
    return num >= val;
}

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

    int n;
    cin >> n;

    vector<int> v(n);
    REP(i, n) cin >> v[i];

    int l = 1;
    int r = 1e9 + 7;
    while (r - l > 1) {
        int m = (r + l) / 2;
        if (check(v, m)) {
            l = m;
        } else {
            r = m;
        }
    }

    cout << l << endl;

    return 0;
}


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

int main(){
    int h, w, k; cin >> h >> w >> k;
    int A[10][1000], B[10][1000];
    int ans = h+w-2;
    for (int i = 0; i < h; i++)
    {
        string s; cin >> s;
        for (int j = 0; j < w; j++)
        {
            A[i][j] = B[i][j] = s[j]-'0';
        }
        
    }
    for (int i = 0; i < 1<<h-1; i++)
    {
        int sum = 0, x = 0;
        while (i>>x!=0)
        {
            sum += (i>>x)&1;
            x++;
        }
        bool flag = false;
        for (int j = 0; j < h; j++)
        {
            for (int l = 0; l < w; l++)
            {
                A[j][l] = B[j][l];
            }
            
        }
        for (int j = 0; j < w; j++)
        {
            for (int l = 0; l < h-1; l++)
            {
                if (((i>>l)&1) == 0)
                {
                    A[l+1][j] += A[l][j];
                }

                if (A[l+1][j] > k)
                {
                    flag = true;
                }
                
            }
            
        }
        if(flag)continue;
        for (int j = 1; j < w; j++)
        {
            flag = true;
            for (int l = 0; l < h; l++)
            {
                if (A[l][j] + A[l][j-1] > k)
                {
                    sum++;
                    flag = false;
                    break;
                }
                
            }
            if (flag)
            {
                for (int l = 0; l < h; l++)
                {
                    A[l][j] += A[l][j-1];
                }

            }
            
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define endl        '\n'
#define db          double
#define ld          long double
#define ll          long long
#define ull         unsigned long long
#define sqr(x)      (x) * (x)
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)   ((a/gcd(a,b)) * b)
#define pf(x) 		push_front(x)
#define pb(x)       push_back(x)
#define eb(x)		emplace_back(x)
#define all(x)      (x).begin(), (x).end()
#define rall(x) 	(x).rbegin(), (x).rend()
#define sz(x) 		(int)x.size()
#define debug(x) 	cerr << #x << " = " << (x) <<endl
#define unsyncIO    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ld PI = acos((ld)-1);
const int MOD = 1e9+7;
const ll INF = 1e18; 

using namespace std;

int main()
{
    //freopen("/home/taalpatar_shepai/Documents/my_codes/out.txt", "w", stdout);
    for (int  i = 1; i <= 5; i++) {
        int t;
        cin >> t;
        if (t == 0) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    bool vis[100005];
    int a[100005],n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        for(int i=0;i<=n;i++)a[i]=1;
        memset(vis,false,sizeof(vis));
        vis[1]=true;
        int x,y;
        while(m--)
        {
            scanf("%d%d",&x,&y);
            a[x]--;
            a[y]++;
            if(vis[x])vis[y]=true;
            if(a[x]==0)vis[x]=false;
        }
        int ans=0;
        for(int i=1;i<=n;i++)if(a[i]&&vis[i])ans++;
        printf("%d\n",ans);
    }
}


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

//+=と=+に注意
//バケツは{0}で初期化しないと不具合を生じる

const int INF = 1001000000;

int main(){
  int n,m,a[100]={0},b[100]={0},c[100]={0};
  cin >> n >> m;
  for(int i=1;i<=m;++i){
    cin >> a[i] >> b[i];
  }
  for(int i=1;i<=m;i++){
    c[a[i]]++;
    c[b[i]]++;
  }
  for(int i=1;i<=n;i++)cout << c[i] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string std;
  cin >> std;
  char c1 = std[2];
  char c2 = std[3];
  char c3 = std[4];
  char c4 = std[5];
  if(c1 == c2 && c3 == c4)
    cout << "Yes";
  else
    cout << "No";

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) (i%(ll)(1e9 + 7))


string s;
ull ans = 0;

ull stl(string ss){
    ull ans = 0;

    rep(i,0,ss.size()){
        ans *= 10;
        ans += (int)(ss[i] - '0');
    }
   
    return ans;
}

ull calc(string ss){
    ull sum = 0;
    string tmp = "";
    rep(i,0,ss.size()){
        if(ss[i] != '+')tmp += ss[i];
        else {
            sum += stl(tmp);
            tmp = "";
        }
    }
    sum += stl(tmp);

    return sum;
}
void dfs(string ss,int num){
    if(num >= s.size()-1){
        ss += s[num];
        //cout << ss << endl;
        ans += calc(ss);
        return ;
    }
    ss+= s[num];
    dfs(ss,num+1);
    dfs(ss+'+',num+1);
}
int main(){
	
    cin >> s;
    dfs("",0);
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*ॐ नमो भगवते वासुदेवाय नमः*/
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).rend()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a, n) sort(a, a + n)
#define sortvec(V) sort(all(V))

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

typedef unordered_map<int, int, custom_hash> u_map;
typedef unordered_set<int, int, custom_hash> u_set;
typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef priority_queue<int> p_queue;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

int binpow(int a, int b, int m) {
    a %= m;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int inverse(int x){
    return binpow(x, MOD - 2, MOD);
}

void solve()
{
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans += (n/i);
        if(n % i == 0)  ans--;
    }
    cout << ans << endl;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n ";
}

Measured memory_bytes: 3736
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cstring>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
void run_case()
{
    int n, r;
    cin >> n >> r;
    if (n >= 10)
        cout << r << "\n";
    else
        cout << r + 100 * (10 - n) << "\n";
}
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
#define pqasc priority_queue<long long, vector<long long>, greater<long long>>

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ul = unsigned long;

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

class UnionFind{
private:
  vector<int> Parent; 
 public:
  UnionFind(int N){
    Parent = vector<int>(N, -1);
  }
  
  int root(int A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  int size(int A){
    return -Parent[root(A)]; 
  }
  
  bool connect(int A, int B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(int A, int B){
    return root(A) == root(B);
  }
};

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

long long ngcd(vector<long long> a) {
  long long res = a[0];
  for(int i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int a,b; cin>>a>>b;
  cout<<lcm(a,b)<<endl;
}

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

int main() {

  // 現在の rating
  int R;

  // 目標の rating
  int G;

  cin >> R >> G;

  // 取るべき performance: P
  //  G = (R + P)/2
  int P = 2*G - R;  // 整数 - 整数なので P も整数

  //cout << R << G << endl;
  cout << P << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
    int a;
    int b;
    char buf[128];

    if (argc == 3)
    {
        sscanf(argv[1], "%d", &a);
        sscanf(argv[2], "%d", &b);
    }

    if (argc == 1)
    {
        scanf("%d %d" , &a , &b);
        if(b == '\0')
        scanf("%d", &b);
    }

if(a<1||b<1) {
    printf(":(\n");
}
else if(a>=9||b>=9) {
    printf(":(\n");
}
else {
    printf("Yay!\n");
}
    return 0;
}


Measured memory_bytes: 128
while True:
	H, W = map(int, input().split())
	if H == 0 and W == 0:
		break
	for i in range(H):
		for j in range(W):
			if (i + j) % 2 == 0:
				print("#", end = '')
			else:
				print(".", end = '')
		print()
	print()



Measured memory_bytes: 7008
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int count = 0;

		for (int aIdx = 0; aIdx <= a ; aIdx ++) {
			for(int bIdx = 0; bIdx <= b ; bIdx ++) {
				for(int cIdx = 0; cIdx <= c ; cIdx ++) {
					if(x== (aIdx * 500) + (bIdx * 100) + (cIdx * 50)) {
						count += 1;
					}
				}
			}
		}
		System.out.print(count);
		}
}


Measured memory_bytes: 21844
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAXN 16
int N;
int A[MAXN][MAXN];
llong C[1<<MAXN];

const llong INF = 1e18 + 1e9;
bool cached[1<<MAXN];
llong memo[1<<MAXN];
llong go(int mask) {
   if (mask == 0)
      return 0;

   llong& res = memo[mask];
   if (!cached[mask]) {
      res = -INF;
      for (int s = mask; s; s = (s - 1) & mask) {
         llong cur = go(mask ^ s) + C[s];
         res = max(res, cur);
      }
      cached[mask] = true;
   }
   return res;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   cin >> N;
   REP(i, N) REP(j, N)
      cin >> A[i][j];

   FOR(mask, 1, (1<<N)-1) {
      C[mask] = 0;
      REP(i, N) {
         if (!(mask & (1<<i))) continue;
         FOR(j, i+1, N-1) {
            if (!(mask & (1<<j))) continue;
            C[mask] += A[i][j];
         }
      }
   }

   memset(memo, -1, sizeof(memo));
   llong res = go((1<<N)-1);
   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 1408
#include<iostream>

using namespace std;

int main()
{
char c;
cin >> c;

if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
} else {
    cout << "consonant" << endl;
}

}


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



def main():
    N = int(readline())
    A = [0] + list(map(int, readline().split())) + [0]
    total = 0
    for i in range(N+1):
        total += abs(A[i+1]-A[i])
    for i in range(1,N+1):
        print(total-abs(A[i]-A[i-1]) - abs(A[i+1]-A[i]) + abs(A[i+1]-A[i-1]))






if __name__ == '__main__':
    main()

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

int main()
{
	int n;
	cin>>n;
	if(n<1200)
	{
		cout<<"ABC";
		return 0;
	}
	if(n<2800)
	{
		cout<<"ARC";
		return 0;
	}
	cout<<"AGC";
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from itertools import product
from bisect import bisect
from collections import deque
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
A, B = inpl()
if max(A, B) <= 9:
    print(A*B)
else:
    print(-1)

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

namespace ABC043A
{
	class Program
	{
		static void Main(string[] args)
		{
			int N;
			int S = 0;
			N = int.Parse(Console.ReadLine());

			for (int i = 1; i <= N; i++)
			{
				S += i;
			}
				Console.WriteLine(S);
				Console.ReadKey();
		}
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
const int MOD = 1e9+7;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int A[N]; rep(i,N) cin >> A[i];
    int b[3]; rep(i,3) b[i]=0;
    int ans=1;
    rep(i,N){
        int cnt=0;
        rep(j,3){
            if(b[j]==A[i]){
                if(!cnt) b[j]++;
                cnt++;
            } 
        }
        ans=(ans*cnt)%MOD;
    }
    cout << ans << endl;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  string s;
  cin >> s;

  if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main(){
    int n;
    cin >> n;
    
    vector<vector<vector< int > > > v(4, vector<vector< int > >(3, vector< int >(10)));
    for(int i = 0; i < n; i++){
        int b, f, r, p;
        cin >> b >> f >> r >> p;        
        v[b - 1][f - 1][r - 1] += p;
    }

    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 10; k++){
                cout << " " << v[i][j][k];
                if(k == 9){
                    cout << endl;
                }
            }
            if(i != 3 && j == 2){
                cout << "####################" << endl;
            }
        }
    }    
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;

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

ll binomial(int N, int K) {
  if(K < 0 || N < K) return 0;
  ll ret = 1;
  for(ll i = 1; i <= K; ++i) {
    ret *= (ll)N--;
		ret %= MOD;
    ret *= modinv(i);
		ret %= MOD;
  }
  return ret;
}

ll modpow(ll a, ll n ) {
  ll res = 1;
  while(n > 0) {
    if(n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans = modpow(2, n) - 1;
	ans = mod(ans - (binomial(n, a) % MOD), MOD);
	ans = mod(ans - (binomial(n, b) % MOD), MOD);
	cout << ans % MOD << '\n';
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){


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


Measured memory_bytes: 2056
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<queue>
#include<deque>
#include<vector>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
using namespace std;

signed main() {
	int n, a, b; cin >> n >> a >> b;
	if ((b - a) & 1) {
		puts("Borys");
	}
	else {
		puts("Alice");
	}
}

Measured memory_bytes: 256
s = input()
yy = int(s[:len(s)//2])
mm = int(s[len(s)//2:])

if 1 <= yy <= 12 and 1 <= mm <= 12:
    print("AMBIGUOUS")
elif 1 <= yy <= 12:
    print("MMYY")
elif 1 <= mm <= 12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define LL long long
#define NUM 1000000007

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n), ans;
    for (auto& i : v)
    {
        cin >> i;
    }
    for (auto& i : v)
    {
        size_t index = &i - &v[0];
        if (v.size() % 2 == 0)
        {
            if (index % 2 == 0)
            {
                ans.insert(ans.end(), i);
            }
            else
            {
                ans.insert(ans.begin(), i);
            }
        }
        else
        {
            if (index % 2 != 0)
            {
                ans.insert(ans.end(), i);
            }
            else
            {
                ans.insert(ans.begin(), i);
            }
        }

    }
    for (auto& i : ans)
    {
        cout << i;
        size_t index = &i - &v[0];
        if (index != ans.size() - 1)
        {
            cout << " ";
        }
        else
        {
            cout << endl;
        }
    }
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  int a;
  cin>>a;
  vector<int> b(a);
  rep(i,a)
    cin>>b[i];
  int c=0;
  rep(i,a)
    c+=b[i];
  int d=1e9;
  rep(i,a){
  if(b[i]%10!=0&&d>b[i])
    d=b[i];
  }
  if(c%10==0){
  if(d==1e9)
    cout<<0<<endl;
    else
      cout<<c-d<<endl;
  }
    else
      cout<<c<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, n;
  cin >> N;
  n = N;
  vector<char> S(N);
  for (int i = 0; i < N; i++) {cin >> S.at(i);}
  for (int i = 0; i < N - 1; i++) {
    if (S.at(i) == S.at(i + 1)) {n--;}
  }
  cout << n << endl;
}

Measured memory_bytes: 3672
object Main extends App{

  	var list = List[Int]()
  	for (i <- 1 to 10) {
  		list = io.StdIn.readLine().toInt :: list
  	}

  	list = list.sorted.reverse

  	println(list(0) + "\n" + list(1) + "\n" + list(2))
}

Measured memory_bytes: 43696
H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]

ans = [[0 for _ in range(W)] for _ in range(H)]
move = [(-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)]

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      ans[i][j] = "#"
    else:
      for x, y in move:
        nx, ny = i+x, j+y
        if nx < 0 or H <= nx or ny < 0 or W <= ny:
          continue
        elif S[nx][ny] == "#":
          ans[i][j] += 1
          
for a in ans:
  for i in range(W):
    a[i] = str(a[i])
  print("".join(a))

Measured memory_bytes: 9256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll ans,m,n,k;
void get(){
	for (ll x=1;x<n;x++){
		for (ll y=0;y<m-1;y++){
			if (x*y>2*k+n-2) break;
			ll b=2*k-2-x*y+__gcd(n,y),c=b/n;
			if (c+y<m-1){if (n*(c+1)<=b+__gcd(x,c+1)+__gcd(n-x,c+y+1))c++;}
			else c=m-1-y;
			if (y==0)ans+=c*2;else ans+=c*4;
		}
	}
}
int main(){
	cin>>n>>m>>k;
	get();swap(m,n);get();cout<<ans<<endl;
	return 0;
}

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

int main(int argc, char* argv[]) {
	int n, b, f, r, v;
	int a[4][3][10] = {0};
	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> b >> f >> r >> v;
		a[b-1][f-1][r-1] += v;
	}

	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				printf(" %d", a[i][j][k]);
			}
			printf("\n");
		}
		if(i != 3) printf("####################\n");
	}

	return 0;
}

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

using namespace std;

int main() {
    int n;
    bool test = true;
    cin >> n;
    vector<int> stairs(n);
    for (int i = 0; i < n; ++i) {
        cin >> stairs.at(i);
    }
    for (int j = 0; j < n - 1; ++j) {
        if (stairs.at(j) + 1 <= stairs.at(j + 1)) {
            stairs.at(j + 1)--;
        } else if (stairs.at(j) == stairs.at(j + 1)) {
            // do nothing
        } else {
            test = false;
            break;
        }
    }
    if (test) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> a;
    REP(i, h) {
        string s;
        cin >> s;
        if(s != string(w, '.')) a.push_back(s);
    }

    vector<bool> is_white(w, true);
    REP(i, a.size())REP(j, a[i].size()) {
        if(a[i][j] == '#') is_white[j] = is_white[j] & false;
    }
    REP(i, a.size()) {
        REP(j, a[i].size()) {
            if(not is_white[j]) cout << a[i][j];
        }
        cout << endl;
    }

    return 0;
}


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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define roop(i, n) for(int i = 0;i < n;i++)

int main(void){

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int ans1, ans2;

    ans1 = (c+b-1)/b;
    ans2 = (a+d-1)/d;

    cout << (ans1 <= ans2 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3620
import sys
#input = sys.stdin.buffer.readline
 
def main():
    s = input()
    l = len(s)
    
    count = 0
    for i in range(l-1):
        if s[i] != s[i+1]:
            count += 1
            
    print(count)
    
if __name__ == "__main__":
    main()


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

using namespace std;

int main(){
  int n;
  cin >>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin >>vec.at(i);
  }
  int count =0;
  for(int i=1;i<n-1;i++){
    if(vec.at(i)>vec.at(i-1) && vec.at(i)<vec.at(i+1)){
      count++;
    }
    else if(vec.at(i)<vec.at(i-1) && vec.at(i)>vec.at(i+1)){
      count++;
    }
  }
  cout <<count<<endl;
}



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

int main() {
    long long n,n1,x;
    cin>>n;
    long long ans=0;
    
    if(n%2==0){
        n1=n;
        while(n>=10){
            ans+= n/10;
            n=n%10;
        }
        x = 50;
        while(x<=n1){
            ans+= n1/x;
            x*=5;
        }
        cout<<ans<<endl;
    }
    else{
        cout<<"0"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
local floor = math.floor
-- binary search
-- https://golang.org/src/sort/search.go?s=2246:2286#L49
local function find_min_true(n, f)
    local function loop(i, j)
        if i == j then
            return i
        end
        local h = floor((i + j) / 2)
        if f(h) then
            return loop(i, h)
        else
            return loop(h + 1, j)
        end
    end
    return loop(1, n + 1)
end


local N = io.read("*n", "*l")
local S = io.read("*l")
local sub = string.sub
local find = string.find
local function search()
    -- false if len is OK
    local function judge(len)
        for l1=1,N+1-2*len do
            local subst = sub(S, l1, l1+len-1)
            local result = find(S, subst, l1+len, true)
            --print("len", len, "l1", l1, "subst", subst, "result", result)
            if result then
                return false
            end
        end
        return true -- len is NG
    end
    return find_min_true(2500, judge)
end
local ans = search()
if ans == 0 then
    print(0)
else
    print(ans-1)
end

Measured memory_bytes: 760
#include <iostream>
#include <vector>
#include<algorithm>
#include<map>
#include<cmath>
#include<set>
using namespace std;
#define rep(i,n) for(int i =0;i < n;i++)
int digsum(int n) {
    int res = 0;
    while (n > 0) {
        res += n % 10;
        n /= 10;
    }
    return res;
}
int main() {
    int n, d, ans = 0,a;
    int x[10][10];
    cin >> n >> d >> a;
    for (int i = 1; i <= n;i++) {
        if (digsum(i) <= a && digsum(i) >= d)
            ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;

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

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		StringBuilder sb = new StringBuilder();  //??????????????????
		int i = 1;

		while(true){
		int a = Integer.parseInt(br.readLine());
		if( a == 0 ){
		break;
			}

		sb.append("Case ").append(Integer.toString(i++)).append(": ").append(Integer.toString(a)).append("\n");
	 	}
	System.out.print(sb);
	}
}

Measured memory_bytes: 31444
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
int N, Q, K;
vector<pair<int, ll> > edges[100001];
ll D[100001];

int main() {
    cin >> N;

    for (int i = 0; i < N - 1; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;

        edges[a].push_back(make_pair(b, c));
        edges[b].push_back(make_pair(a, c));
    }

    cin >> Q >> K;
    K--;

    vector<pair<ll, pair<int, int> > > stack;
    stack.push_back(make_pair(0, make_pair(K, K)));

    while (!stack.empty()) {
        auto e = stack.back();
        stack.pop_back();
        auto p = e.second.first;
        auto c = e.second.second;
        auto cost = e.first;
        D[c] = cost;

        for (int i = 0; i < edges[c].size(); i++) {
            if (edges[c][i].first == p) {
                continue;
            }
            stack.push_back(make_pair(cost + edges[c][i].second,
                                      make_pair(c, edges[c][i].first)));
        }
    }

    for (int i = 0; i < Q; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        cout << D[x] + D[y] << endl;
    }
}


Measured memory_bytes: 10864
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define MAX 100005
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';


int main() {

	LL n, i, j, k, arr[1000], ans = 0;

	cin>>n;
	
	for(i = 0; i < n; i++) {
		cin>>arr[i];
	}

	//sort(arr, arr+n);

	for(i = 0 ; i < n ; i++) {
		for(j = i+1; j < n; j++) {
			for(k = j+1; k < n; k++) {

				if(arr[i] != arr[j] && arr[j] != arr[k] && arr[k] != arr[i] && arr[i] + arr[j] > arr[k] && arr[i] + arr[k] > arr[j] && arr[j] + arr[k] > arr[i]) {
//					cout<<i+1 << " " <<j+1 << " " << k+1<<endl;
					ans++;
				}
			}
		} 
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3628
#[macro_use]extern crate text_io;

fn main(){
    let n:i32 = read!();

    let mut a:Vec<i32> = Vec::with_capacity((n-1) as usize);
    for _ in 2..=n { a.push(read!()); }

    let mut ans:Vec<i32> = Vec::with_capacity(n as usize);
    for _ in 0..n { ans.push(0) }

    for i in a.iter() {
        *ans.get_mut((*i - 1) as usize).unwrap() += 1;
    }

    for i in ans.iter() { println!("{}",i); }
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define mem(a, v) memset(a, v, sizeof(a))
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> matrix;
const ll MOD = 1000000007LL;

char arr[10][10];

int main()
{
    int n, m;
    cin>>n>>m;
    for(int i=0; i<n; i++) {
        cin>>arr[i];
    }   
    int cnt = 0;
    for(int i=0; i<n; i++) {
        for(int j=0; j<m; j++) {
            if(arr[i][j] == '#') cnt++;
        }
    }
    int cur = 0;
    for(int i=0, j=0; i<n && j<m;) {
        if(arr[i][j] == '#') {
            cur++;
        }
        else break;
        if(arr[i][j+1] == '#') j++;
        else if(arr[i+1][j] == '#') i++;
        else break;
    }
    if(cur == cnt) {
        cout<<"Possible\n";
    }
    else {
        cout<<"Impossible\n";
    }
    return 0;
}

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

int main() {
    ll x;
    cin >> x;
    ll a = x / 500;
    x = x - 500 * a;
    ll b = x / 5;
    cout << a * 1000 + b * 5 << endl;
}


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

int main(void){
    string a,b;
    cin >> a >> b;
    
    int x = stoi(a+b);
    
    bool can = false;
    for(int i=1;i<=1000;i++){
        if(i*i == x) {
          can = true;
          break;
        }
    }
    
    
    if(can)cout << "Yes";
    else cout << "No";
    
    return 0;
}

Measured memory_bytes: 3640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long amax = A.Max();
		Array.Sort(B);
		Array.Reverse(B);
		
		long[] sum = new long[N+1];
		for(int i=0;i<N;i++){
			sum[i+1] = B[i] + sum[i];
		}
		
		long min = (long)1e18;
		for(int i=0;i<=N;i++){
			long h = H;
			long b = sum[i];
			if(b >= h){
				min = Math.Min(i,min);
			} else {
				long an = ((h - b) +(amax - 1)) / amax;
				min = Math.Min(i + an, min);
			}
		}
		
		Console.WriteLine(min);
		
		
		
	}
	int N;
	long H;
	long[] A,B;
	public Sol(){
		var d = ria();
		N = d[0]; H = d[1];
		A = new long[N];
		B = new long[N];
		for(int i=0;i<N;i++){
			d = ria();
			A[i] = d[0]; B[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 17736
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 9223372036854775807
#define MOD 1000000007
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

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

#define MAX 10000

int main(void) {
  bool f;
  cin >> s;

  if (s == "zyxwvutsrqponmlkjihgfedcba") {
	cout << "-1" << endl;
	return 0;
  }

  if (s.length() == 26) {
	flag = true;
  }
  else {
	flag = false;
  }

  if (!flag) {
	for (char c = 'a';c <= 'z';c++) {
	  f = false;
	  FOR(i, 0, s.length()) {
		if (c == s[i]) {
		  f = true;
		  break;
		}
	  }
	  if (!f) {
		s += c;
		cout << s << endl;
		return 0;
	  }
	}
  }

  char c;
  RFOR(i, 1, s.length()) {
	if (s[i] > s[i - 1]) {
	  c = s[i - 1];
	  temp = i - 1;
	  break;
	}
  }

  RFOR(i, temp + 1, s.length()) {
	if (c < s[i]) {
	  s[temp] = s[i];
	  break;
	}
  }

  ll len = s.length();
  FOR(i, temp + 1, len) {
	s.pop_back();
  }

  cout << s << endl;

  return 0;
}

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

temp_list = []
for _ in range(N):
    temp = list(map(int, input().split()))
    temp_list.append(temp)

sort_after = sorted(temp_list, key=lambda x: x[0])

yen_min = 0
for yen, honsu in sort_after:
    if M - honsu > 0:
        yen_min += yen * honsu
        M -= honsu
    else:
        yen_min += M * yen
        break

print(yen_min)


Measured memory_bytes: 29792
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=int(2e5);
int n;
ll X;
ll dst_sum[N+5];
int main(){
	scanf("%d%lld",&n,&X);
	for(int i=1,dst;i<=n;i++){
		scanf("%d",&dst);
		dst_sum[i]=dst_sum[i-1]+dst;
	}
	ll ans=ll(1e18);
	for(int k=1;k<=n;k++){ //决定丢多少次垃圾
		ll now=0,cof=1;
		for(int i=n;i>=1;i-=k){
			now+=(dst_sum[i]-dst_sum[max(i-k,0)])*max((cof+=2),5ll);
			if(now>ans) break; //最优性剪枝 
		}
		now+=(n+k)*X;
		ans=min(ans,now);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;

int main() {
	string chk = "yuiophjklnm";
	string n;
	while(cin >> n, n != "#") {
		string ed = "";
		for(int i=0; i<n.size(); i++) {
			bool flg = false;
			for(int j=0; j<chk.size(); j++) {
				if(n[i] == chk[j]) {
					flg = true;
					ed.push_back('1');
					break;
				}
			}
			if(!flg) ed.push_back('0');
		}
		int cnt = 0;
		for(int i=1; i<n.size(); i++)
			if(ed[i-1] != ed[i]) cnt++;

		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>

int main (){
  int h,w,i,hi,wi;

  for ( i = 1; 1; i++){
    scanf("%d %d",&h, &w);
    if ( h ==0 && w == 0)
      break;
    for ( hi = 0; hi < h; hi++){
      for ( wi = 0; wi < w; wi++){
        if ( hi == 0 || hi == h - 1 || wi == 0 || wi == w -1 ){
          printf("#");
        } else {
          printf(".");
        }
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}

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

int main()
{
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	
	vector<long long> dp((int)1e5+1);
	for(int i=0;i<=(int)1e5;i++)
	{
		dp[i] = max(0,x-i)*a + max(0,y-i)*b + i*2*c*1LL;
	}
	cout<<*min_element(dp.begin(),dp.end());
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<queue>
using namespace std;
 
#define what_is(x) cout << #x << " is " << x << endl; 
#define PI acos(-1)
#define hell 1000000007
#define HELL 998244353
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define mset(a,n) memset(a,n,sizeof a)
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define renn(i,a,b,p) for(__typeof((a) i=(a);i>=(b);i-=p)
#define ADD(a,b,c) ((a)%c+(b)%c)%c
#define SUB(a,b,c) ((a)%c-(b)%c+c)%c
#define MUL(a,b,c) (((a)%c)*((b)%c))%c
#define lbd lower_bound
#define ubd upper_bound
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(v) (v).begin(), (v).end()
#define sz(x) (ll)x.size()
// #define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define bug(n) {outl(n);return;}
#define pii pair<int,int>
#define lim 9223372036854775805
#define ninf -9223372036854775802
#define M 1000000007
#define eps 1e-6
#define MAX 5
#define N 500001
#define db(a) for(auto it:a) {cout<<it<<" ";}cout<<endl;
ll prime[MAX]; 
ll fact[MAX];

const long long INF64 = 1e18;
ll vpow(ll a,ll b,ll p){
    if(b==0)
        return 1;
    if(b==1)
            return a;
    ll temp=vpow(a,b/2,p);
    temp*=temp;
    temp%=p;
    if(b%2==0)
        return temp;
    temp=temp*a;
    temp%=p;
    return temp;
}

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

 
ll inverseMod(ll a,ll b,ll p){
    if(b==0)
        return 1;
    ll temp=vpow(b,p-2,p);
    ll ans=temp*a;
    ans%=p;
    return ans;
}
void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (ll i = 2; i < MAX; i++) { 
        if (prime[i] == 0) {
            for (int j = i * 2; j < MAX; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
}

void factorial(){
    fact[0]=1;
    fact[1]=1;
    rep(i,2,MAX){
        fact[i]=(fact[i-1]*i);
        // fact[i]%=M;
    }
}
// string s="689";
// // string ans="";
// // string rec(vll &power,ll lvl,ll n,ll tot){
// // 	if(tot+power[lvl]>=n){
// // 		return (string)""+s[(n-tot)/(power[lvl-1])]+rec(power,lvl-1,)
// // 	}
// // 	n%=power[lvl];

// // }
// string recc(ll n){
// 	if(n==0)
// 		return "";
// 	n--;
// 	if(n<3)
// 		return (string )""+s[n];

// 	return (string )""+s[n%3]+recc(n/3);
// }

void solve(ll ttt){
	ll n;
	cin>>n;
	vll a(n);
	rep(i,0,n)
		cin>>a[i];
	ll sum=0,ans=0;
	ren(i,n-1,0){
		ans+=(a[i]*sum)%M;
		sum+=a[i];
		sum%=M;
		
		ans%=M;
	}
	cout<<ans<<endl;
}

int main(){
    io;
   
    // sieve();
    // factorial();
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    //freopen("output1.txt","w",stdout);
#endif
    ll t=1;
    //cin>>t;
    fix(12);
    rep(q,1,t+1){
        // cout<<"Case #"<<q<<": ";
         solve(q);
        //solve2();
    }
    return 0;
    
}


Measured memory_bytes: 4764
#
# itp1 11d
#
import random


class Cube:
    def __init__(self, u, s, e, w, n, d):
        self.u = u
        self.s = s
        self.e = e
        self.w = w
        self.n = n
        self.d = d

    def rotate(self, dic):
        if dic == "N":
            tmp = self.u
            self.u = self.s
            self.s = self.d
            self.d = self.n
            self.n = tmp
        elif dic == "E":
            tmp = self.u
            self.u = self.w
            self.w = self.d
            self.d = self.e
            self.e = tmp
        elif dic == "W":
            tmp = self.u
            self.u = self.e
            self.e = self.d
            self.d = self.w
            self.w = tmp
        else:
            tmp = self.u
            self.u = self.n
            self.n = self.d
            self.d = self.s
            self.s = tmp


def main():
    N = int(input())
    cubeL = []
    for i in range(N):
        u, s, e, w, n, d = map(int, input().split())
        cube = Cube(u, s, e, w, n, d)
        cubeL.append(cube)

    ret = "Yes"
    for i in range(N):
        for j in range(i+1, N):
            flag = True
            for k in range(100):
                cubeL[j].rotate(random.choice("NEWS"))
                if cubeL[i].u == cubeL[j].u and cubeL[i].n == cubeL[j].n and cubeL[i].w == cubeL[j].w and cubeL[i].e == cubeL[j].e and cubeL[i].s == cubeL[j].s and cubeL[i].d == cubeL[j].d:
                    flag = False
                    break
            if not flag:
                break
        if not flag:
            ret = "No"
            break
    print(ret)


if __name__ == '__main__':
    main()



Measured memory_bytes: 8212