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

int s[100010];

int main(){
  int N; cin >> N;
  for( int i = 0; i < N; i++ ) cin >> s[i];
  int q; cin >> q;
  int ans = 0;
  for( int i = 0; i < q; i++ ){
    int t;cin >> t;
    int left = 0;
    int right = N;
    while( right - left > 1 ){
      int mid = ( right + left ) / 2;
      if( t < s[mid] ){
	right = mid;
      }else{
	left = mid;
      }
    }
    if( s[left] == t ) ans++;
  }

  cout << ans << endl;
			       
}



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

vector<int> s;
vector<unsigned long long int> dp;
vector<unsigned long long int> dpsum;
vector<int> l;
vector<int> r;
vector<int> tmp;
long long mod = 998244353;

int main() {

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

	for (int i = 0; i < k; i++) {
		int t1, t2;cin >> t1 >> t2;
		l.push_back(t1);r.push_back(t2);
	}

	dp.resize(n+1, 0);
	dpsum.resize(n+1, 0);
	dp[1] = 1;
	dpsum[1] = 1;

	for (int i = 2; i <= n; i++) {
		for (int j = 0; j < k; j++) {  
			int ll = i - r[j];
			ll = max(ll, 1);
			int rr = i - l[j];
			if (rr < 0) continue;
			dp[i] += dpsum[rr] - dpsum[ll-1];
			dp[i] = (dp[i]) % mod;
		}
		dpsum[i] = dpsum[i - 1] + dp[i];
	}

	cout << dp[n] << endl;

}

Measured memory_bytes: 6380
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]

signed main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(ALL(a));
    cout << a[n-1] << endl;
    rep(i,n){
        int p=lower_bound(ALL(a),a[n-1]/2)-a.begin();
        if(p==0){
            cout << a[p] << endl;
            return 0;
        }
        p--;
        if(a[n-1]-2*a[p]<2*a[p+1]-a[n-1]||p==n-2) cout << a[p] << endl;
        else cout << a[p+1] << endl;
        return 0;
    }
}


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

int main(){
    int a, b;
    cin >> a >> b;
    if(a>b){
        for (int n = 0; n < a;n++){
            cout << b;
        }
        cout << endl;
    }
    if(b>=a){
        for (int n = 0; n < b; n++)
        {
            cout << a;
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);
    long n, count;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextLong();
	    count = 0;
	    if(n!=0) solve();
	}
    }

    void solve(){
	while(n!=1){
	    if(n%2==0) n = n/2;
	    else n = n*3+1;
	    count++;
	}
	System.out.println(count);
    }
}

Measured memory_bytes: 17204
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main() {
    int x; cin >> x;
    if (x < 1200) {
        cout << "ABC" << endl;
    } else {
        cout << "ARC" << endl;
    }
}


Measured memory_bytes: 256
/*
Author: CNYALI_LK
LANG: C++
PROG: b.cpp
Mail: cnyalilk@vip.qq.com
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG printf("Passing [%s] in LINE %lld\n",__FUNCTION__,__LINE__)
#define Debug debug("Passing [%s] in LINE %lld\n",__FUNCTION__,__LINE__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double pi=acos(-1.0);
typedef long long ll;
typedef pair<ll,ll> pii;
template<class T>ll chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>ll chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
ll read(){
	ll s=0,base=1;
	char c;
	while(!isdigit(c=getchar()))if(c=='-')base=-base;
	while(isdigit(c)){s=s*10+(c^48);c=getchar();}
	return s*base;
}
char WritellBuffer[1024];
template<class T>void write(T a,char end){
	ll cnt=0,fu=1;
	if(a<0){putchar('-');fu=-1;}
	do{WritellBuffer[++cnt]=fu*(a%10)+'0';a/=10;}while(a);
	while(cnt){putchar(WritellBuffer[cnt]);--cnt;}
	putchar(end);
}
ll a[102424];
int main(){
#ifdef cnyali_lk
	freopen("b.in","r",stdin);
	freopen("b.out","w",stdout);
#endif
	ll k,l,r;
	k=read();
	for(ll i=1;i<=k;++i)a[i]=read();
	l=r=2;
	for(ll i=k;i;--i){
		l=((l-1)/a[i]+1)*a[i];
		r=r/a[i]*a[i];
		if(l>r){printf("-1\n");return 0;}
		r=r+a[i]-1;
	}
	printf("%lld %lld\n",l,r);
	return 0;
}



Measured memory_bytes: 1152
from collections import deque
n, m = map(int, input().split())
g = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

ans = [None]*(n+1)
q = deque([1])
ans[1] = 0

while q:
    now = q.popleft()
    for next in g[now]:
        if ans[next] == None:
            ans[next] = now
            q.append(next)

print("Yes")
for i in range(2, n+1):
    print(ans[i])


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

bool isprime(int x) {
    if (x % 2 == 0) return false;
    for (int a = 3; a < x; a+=2) {  //2ずつ増える a+=2; 3から始める
        // cout << x << a << endl;
        if (x % a == 0) return false;  //割り切れたらだめ
    }
    return true;    //最後に置く
}

int main () {
    int x;
    cin >> x;
    if (x == 2) {
        cout << 2 << endl;;
    }
    else if(x == 1) {
        cout << 1 << endl;
    }
    else {
        for (int j = x; j > 0; j++) {
            if(isprime(j)) {
                cout << j << endl;
                break;
            }
        }
    }
}

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

int main(){
//input
 int N,M;
 std::cin>>N>>M;
 std::vector<std::vector<int>> G(N);
 for(int i=0;i<M;i++){
  int a,b;
  std::cin>>a>>b;
  G[a-1].emplace_back(b-1);
  G[b-1].emplace_back(a-1);
  
 }

//structure
 std::vector<int> dist(N,-1);
 std::queue<int> q;
 std::vector<int> pre(N,-1);
 pre[0]=0;
 dist[0]=0;
 q.push(0);

//BFS
 while(!q.empty()){
  int v=q.front();
  q.pop();
  //std::cout<<v<<std::endl;
  for(int i=0;i<G[v].size();i++){
   if(dist[G[v][i]]<0){
    dist[G[v][i]]=dist[v]+1;
    pre[G[v][i]]=v;
    q.push(G[v][i]);
   }
  }
 }

 int flag=0;
 for(int i=0;i<pre.size();i++){
  if(pre[i]<0){
   flag=1;
  }
 }
 flag=0;
 if(flag){
  std::cout<<"No"<<std::endl;
 }else{
  std::cout<<"Yes"<<std::endl;
  for(int i=1;i<N;i++){
   std::cout<<pre[i]+1<<std::endl;
  }
 }

}

Measured memory_bytes: 10516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll cnt[100010];
int main() {
	ll n,k;
	cin>>n>>k;
	ll r,s,p;
	cin>>r>>s>>p;
	string t;
	cin>>t;
	for(ll i=0;i<n;i++){
		char now=t[i];
		if(i-k>=0){
			if(cnt[i-k]!=0&&t[i-k]==now){
			continue;
			}
		}
		if(now=='r'){
			cnt[i]=p;
		}
		else if(now=='s'){
			cnt[i]=r;
		}
		else{
			cnt[i]=s;
		}
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		ans+=cnt[i];
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 4520
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i(0);i<n;i++)
#define chmin(x,y) x = min(x,y)
const int INF = 1001001001;

using namespace std;
int main(){
    int n,m,l;
    cin >> n >> m >> l;

    vector<vector<int>> dist(n, vector<int>(n,INF));
    rep(i,n) dist[i][i] = 0;
    rep(i,m){
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        dist[a][b] = dist[b][a] = c;
    }

    rep(k,n)rep(i,n)rep(j,n) chmin(dist[i][j], dist[i][k]+dist[k][j]);

    vector<vector<int>> dist2(n, vector<int>(n,INF));
    rep(i,n)rep(j,n){
        if(dist[i][j] <= l) dist2[i][j] = 1;
    }

    rep(k,n)rep(i,n)rep(j,n) chmin(dist2[i][j], dist2[i][k]+dist2[k][j]);
    
    int q;
    cin >> q;
    rep(qi,q){
        int s, t;
        cin >> s >> t;
        --s; --t;
        int ans = dist2[s][t]-1;
        if(dist2[s][t] == INF) ans = -1;
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1280
import java.util.*;
import java.io.*;

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

	void solve(){

		Scanner cin = new Scanner(System.in);
		while(true)
		{
			int h = cin.nextInt();
			int d = cin.nextInt();
			if(h==0) return;
			int[] a = new int[h];
			int[] b = new int[d];
			for(int i=0;i<h;i++){
				a[i] = cin.nextInt();
			}
			for(int i=0;i<d;i++){
				b[i] = cin.nextInt();
			}
			int ret = 0;
			boolean[] acheck = new boolean[h];
			boolean[] bcheck = new boolean[d];
			for(int i = 20;i >= 1; i--){
				boolean flag = false;
				do{
					flag = false;
					for(int j=0;j<h;j++){
						if(!acheck[j] && a[j] == i){
							acheck[j] = true;
							flag = true;
							break;
						}
					}
					for(int j=0;j<d;j++){
						if(!bcheck[j] && b[j] == i){
							bcheck[j] = true;
							flag = true;
							break;
						}
					}
					
					if(flag) ret += i;
				}while(flag);
			}
			System.out.println(ret);
			
		}
	}
}

Measured memory_bytes: 12000
//--- pA ---//
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Scanner scanner;
	public Solution() {
		scanner = new Scanner(System.in);

		// scanner.nextLine();
		while (scanner.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		// scanner.nextLine();
		String line = scanner.nextLine();

		int N = Integer.parseInt(line.split("\\s+")[0]);
		int R = Integer.parseInt(line.split("\\s+")[1]);

		if (N < 10) {
			int diff = 100 * (10 - N);
			System.out.println(R + diff);
		} else {
			System.out.println(R);
		}

		return;
	}

	private int[] strToIntArray(String str) {
	    String[] vals = str.split("\\s+");
	    int sz = vals.length;
	    int[] res = new int[sz];
	    for (int i=0; i<sz; i++) {
	        res[i] = Integer.parseInt(vals[i]);
	    }
	    return res;
	}
}


Measured memory_bytes: 21844
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
m=b[0]

for i in range(1,n):
    if a[i]==a[i-1]+1:
        m+=b[i]+c[a[i-1]-1]
    else:
        m+=b[i]
print(m)

Measured memory_bytes: 3064
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long

#define pn			printf("\n")
#define nl			cout<<'\n'
#define sf(N)       scanf("%lld",&N)
#define pf(N)       printf("%lld",N)
#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))

#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define Frst	first
#define Sec		second
#define Dup erase(unique(V.begin(),V.end()),V.end())

#define Inf     1000000000000000
#define mod		1000000007
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    opt;

    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    lli N,M,i,j;
    cin>>N>>M;
    
    lli a[N][N];
    
    rep(i,0,N)
    {
        rep(j,0,N)
        {
            a[i][j]=0;
        }
    }
    
    while(M--)
    {
        lli x,y;
        cin>>x>>y;
        
        x--;
        y--;
        
        a[x][y]++;
        a[y][x]++;
    }
    
    /*rep(i,0,N)
    {
        rep(j,0,N)
        {
            cout<<a[i][j];sl;
        }
        nl;
    }
    nl;*/
    
    rep(i,0,N)
    {
        lli cnt=0;
        
        rep(j,0,N)
        {
            cnt+=a[i][j];
        }
        
        cout<<cnt;
        nl;
    }
    
    
    



 return 0;
}


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

#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
  int n,dp[32];
  
  dp[0] = 1;
  dp[1] = 1;
  dp[2] = 2;
  for (int i=3; i<=30; i++){
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
  }
  
  while (cin >> n){
    int ans;
    if (n==0) break;
    ans = ((dp[n]+9)/10+364)/365;
    cout << ans << endl;
  }
  return 0;
}
  
  



Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define mod 998244353
#define SYOU(x) fixed<<setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol n,m,k;
  string s,w;
  cin >>k>>n;
  lol a[200010];
  for(int i=0;i<n;i++) cin >>a[i];
  lol ans=mod;
  for(int i=1;i<n;i++){
    ans=min(ans,k-(a[i]-a[i-1]));
  }
  ans=min(ans,a[n-1]-a[0]);
  cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>
#include <functional>
#include <iomanip>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	string s;
	cin >> s;
	
	if( s.back() == 's' ) {
		cout << s << "es" << endl;
	} else {
		cout << s << 's' << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    priority_queue<int> hoge;
    for(int i=0;i<n;i++){
        int fuga;
        cin>>fuga;
        hoge.push(fuga);
    }
    
    int a=0;
    int b=0;
    for(int i=0;i<n;i++){
        if(i%2==0) a+=hoge.top();
        else b+=hoge.top();
        hoge.pop();
    }
    
    cout<<a-b<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n;
signed main() {
  cin >> n;
  vector<long double> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  long double s = 1e18;
  long double ans = 1;
  for (int i = 0; i < n; i++) {
    ans *= a[i];
    if (ans > s) {
      cout << "-1\n";
      return 0;
    }
  }
  cout << (long long)ans << "\n";
}

Measured memory_bytes: 4816
#include <iostream>
using namespace std;
int main(){
int A,B,C,D,P,X,Y;
cin>>A>>B>>C>>D>>P>>X>>Y;
    X=A*P;
    if(P<=C)
        Y=B;
    else
        Y=B+(P-C)*D;
      
    if(X>Y)
        cout<<Y<<endl;
    else
        cout<<X<<endl;
    
return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    string a;
    cin >> a;
    int n = 0;
    int m = 0;
    for (int i = 0; i < a.size(); i++) {
        if (a.at(i) == '0' && i % 2 == 0)n++;
        else if (a.at(i) == '1' && i % 2 == 1)n++;
        else m++;
    }
    cout << min(n, m) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <sstream>
 
int main(void)
{
    std::string S;
    int64_t Q;

    std::cin >> S >> Q;

    std::deque<char> deq;
    for (auto c : S) {
        deq.push_back(c);
    }

    bool is_reverse = false;
    for (int64_t i = 0; i < Q; ++i) {

        int64_t T;
        std::cin >> T;
        if (T == 1) {
            is_reverse = is_reverse ? false : true;
            continue;
        }

        int64_t F;
        char C;
        std::cin >> F >> C;
        if ((!is_reverse && F == 1) || (is_reverse && F == 2)) {
            deq.push_front(C);
        } else {
            deq.push_back(C);
        }
    }

    if (!is_reverse) {
        for (auto c : deq) {
            std::cout << c;
        }
    } else {
        for (int64_t i = deq.size()-1; i >= 0; --i) {
            std::cout << deq.at(i);
        }
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 896
n, m, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = Array.new(n + 1, 0)
n.times do |i|
  c[i + 1] = c[i] + a[i]
end
d = Array.new(m + 1, 0)
m.times do |i|
  d[i + 1] = d[i] + b[i]
end
cnt = 0
0.upto(n) do |i|
  break if c[i] > k
  e = d.bsearch_index{_1 > k - c[i]}
  if e.nil?
    cnt = i + m if cnt < i + m
  else
    cnt = i + e - 1 if cnt < i + e - 1
  end
end
puts cnt

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

using namespace std;
#define MAX 10000

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,q,command,t,x;
    vector<int> vec[MAX];
    cin >> n >> q;
    
    for (int i = 0;i < q;++i) {
        cin >> command >> t;
        switch(command){
                // push back
            case 0:
                cin >> x;
                vec[t].push_back(x);
                break;
                // dump
            case 1:
                for(int i = 0;i < vec[t].size();++i){
                    cout << vec[t].at(i);
                    if(i + 1 < vec[t].size()){
                        cout << " ";
                    }
                }
                cout << endl;
                break;
                // clear
            case 2:
                vec[t].clear();
                break;
        }
    }
}



Measured memory_bytes: 6240
#include<bits/stdc++.h>
using namespace std;
int main()
{
   // freopen("in.txt","r",stdin);
    int sum=0;
    string num;
    cin>>num;
    for(int i=0;i<num.size();i++)
    {
        sum+=(num[i]-'0');
        //cout<<sum<<endl;
        if(sum%3==0)
            sum=0;
        else if(sum%3==1)
            sum=1;
        else 
            sum=2;
    }
    if(sum%3==0)
        cout<<"Yes"<<endl;
    else 
        cout<<"No"<<endl;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
template<typename T>
T gcd(T x, T y){
    if ((x==1)||(y==1)) return 1;
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}

ll goch(ll a){
    for (ll i = 0; i*i*i*i*i <= a; i++) {
        if (i*i*i*i*i == a) {
            return i;
        }
    }
    return -1;
}


int main() {
    IN(int, n);
    IN(int, w);
    vector<pii> a(n);
    REP(i, n){
        cin >> a[i].first >> a[i].second;
    }
    vi2 dp(n+1,vi(w+1,0));
    REPS(i, n){
        REPS(j, w){
            if (j-a[i-1].second>=0) {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-a[i-1].second]+a[i-1].first);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    COUT(dp[n][w]);
}



Measured memory_bytes: 6752
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
	cout.precision(11);
	double  a,b,x;
	cin >>a>>b>>x;
	if(x<=a*a*b/2){
		cout << 90-180*atan((2*x)/(a*b*b))/acos(-1.0) <<endl;
	}
	else cout << 90-180*atan((a*a)/(2*a*b-2*x/a))/acos(-1.0)<<endl;
	return 0;
}

Measured memory_bytes: 4044
n = int(raw_input())
mod = 10**9 + 7
prime = [True for i in range(n + 1)]

res = 1
for i in range(2, n + 1):
	if prime[i]:
		curr = i * i
		while curr <= n:
			prime[curr] = False
			curr += i

		curr = i
		exponent = 0

		while curr <= n:
			exponent += n / curr
			curr *= i

		res *= (exponent + 1)
		res %= mod

print res

Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;



int main(){
  int n;
  cin >>n;
  int a[n];
  rep(i,n)cin >> a[i];
  sort(a,a+n);
  ll ans=0;
  for(int i=0;i<n;i++){
    for(int i2=1+i;i2<n;i2++){
      for(int i3=i2+1;i3<n;i3++){
        if(a[i]+a[i2]>a[i3])ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main()
{
  char c;
  cin>>c;
  switch(c)
  {
    case 'S':
     cout<<"Cloudy";
      break;
    case 'C':
     cout<<"Rainy";
      break;
    case 'R':
      cout<<"Sunny";
        break;
     
  }
}

Measured memory_bytes: 256
n,m,x = map(int,input().split())
books = [list(map(int,input().split())) for _ in range(n)]
ans = 12 * (10**5) + 1
for i in range(2**n):
    kingaku = 0
    rikaido = [0] * m
    for j in range(n):
        if (i >> j) & 1:
            kingaku += books[j][0]
            for k in range(m):
                rikaido[k] += books[j][k+1]
    if all((a >= x for a in rikaido)):
        ans = min(ans,kingaku)
if ans != 12 * (10**5) + 1:
    print(ans)
else:
    print("-1")

Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<string> ss(n);
  vector<Int> ts(n);
  for(Int i=0;i<n;i++) cin>>ss[i]>>ts[i];
  string x;
  cin>>x;
  Int ans=0,flg=0;
  for(Int i=0;i<n;i++){
    ans+=flg*ts[i];
    if(ss[i]==x) flg=1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 892
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int n1 = sc.nextInt();
        int n2 = sc.nextInt();
        String ans = "unsafe";
        
        if(n1>n2){
            ans = "safe";
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 35724
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n, k;
	cin >> n >> k;
	
	V<ll> sum(n + 1, 0);
	rep(i, n) { int a;cin >> a;sum[i + 1] = sum[i] + a; }

	queue<ll> que;
	rep(i, n + 1)rep(j, n + 1) {if (i <= j)continue;que.push(sum[i] - sum[j]);}

	ll ans = 0;

	rep(i, 64) {

		int q = que.size();
		queue <ll> match;
		rep(j,q) {
			ll a = que.front();que.pop();que.push(a);
			if (a >> (63 - i) & 1)match.push(a);
		}
		if (match.size() >= k) {
			ans += 1LL << (63 - i);
			que = match;
		}

	}

	cout << ans << endl;

}

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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream& operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template <typename T>
inline void printV(vector<T>& a, int n) { for(int i=0; i<n; i++) { cerr<<a[i]<<" "; } cerr<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a) { for(int i=0; i<sz(a); i++) { cerr<<a[i]<<"\n"; } cerr<<"\n"; }
template <typename T>
inline void clearVV(vector<vector<T>>& a) { for(auto &x : a) { x.clear(); } a.clear(); }
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val) { for(int i=0; i<sz(a); i++) { a[i].assign(sz(a[i]), val); } }
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	int n, k;
	cin>>n>>k;
	vector<pii> edges;
	for(int i=1; i<=n; i++) {
		for(int j=i+1; j<n; j++) {
			edges.push_back(MP(i, j));
		}
	}
	if(k > sz(edges)) {
		cout<<"-1\n";
		return 0;
	}
	vector<pii> ans;
	for(int i=1; i<n; i++) {
		ans.push_back(MP(i, n));
	}
	for(int i=k; i<sz(edges); i++) {
		ans.push_back(edges[i]);
	}
	cout<<sz(ans)<<"\n";
	for(int i=0; i<sz(ans); i++) {
		cout<<ans[i].first<<" "<<ans[i].second<<"\n";
	}
	cout<<"\n";
    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long

int getS(vector<int>&H){
    int N=H.size();
    vector<int>L(N),R(N);
    stack<int>S;
    for(int i=0;i<N;i++){
        while(!S.empty()&&H[i]<=H[S.top()])S.pop();
        L[i]=S.empty()?0:(S.top()+1);
        S.push(i);
    }
    S=stack<int>();
    for(int i=N-1;i>=0;i--){
        while(!S.empty()&&H[i]<=H[S.top()])S.pop();
        R[i]=S.empty()?N:S.top();
        S.push(i);
    }
    int ma=0;
    for(int i=0;i<N;i++)ma=max(ma,(R[i]-L[i])*H[i]);
    return ma;
}

int H,W;
vector<int>V[500];
void solve(){
    fill_n(V,H,vector<int>(W,0));
    int ma=0;
    for(int i=0;i<H;i++){
        char fld[510];
        cin>>fld;
        for(int j=0;j<W;j++){
            if(fld[j]=='*')continue;
            V[i][j]=(i?V[i-1][j]:0)+1;
        }
        ma=max(ma,getS(V[i]));
    }
    cout<<ma<<endl;
}
signed main(){
    while(cin>>H>>W,H||W)solve();
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <tuple>
#include <utility>
#include <string>

using namespace std;

int main() {
  int h, w;
  cin >> h;
  cin >> w;
  string a[2000];
  //cout << h << "|" << w << endl;
  char s = 'z';
  for(int i = 0; i < h; ++i) {
    cin >> a[i];
  }
  
  //pair<int, int> b[2000][2000];
  auto b = new pair<int, int>[2000][2000];
  auto b2 = new pair<int, int>[2000][2000];
  //b[1][6].first = (b[2][3]).first + 1;
  //cout << b[1][6].first << endl;
  //cout << b[13][13].second << endl;
  //cout << (a[0][2] == '.') << endl;
  
  //int* b2[] = new int[2000][10];
  /*
  int b3[10][20][30];
  b3[3][4][5] = 91;
  cout << b3[3][4][5] << endl;
  cout << b3[3][4][6] << endl;
  auto b4 = new int[2000][2000];
  b4[33][34] = 35;
  cout << b4[33][34];
  delete []b4;
  */

  for(int i = 0; i < h; ++i) {
    for(int j = 1; j < w; ++j) {
      if(a[i][j - 1] == '.') {
        b[i][j].first = (b[i][j - 1]).first + 1;
      } else {
        b[i][j].first = 0;
      }
    }
  }

  for(int i = 0; i < h; ++i) {
    for(int j = w - 2; j >= 0; --j) {
      if(a[i][j + 1] == '.') {
        b[i][j].second = (b[i][j + 1]).second + 1;
      } else {
        b[i][j].second = 0;
      }
    }
  }

  for(int i = 1; i < h; ++i) {
    for(int j = 0; j < w; ++j) {
      if(a[i - 1][j] == '.') {
        b2[i][j].first = (b2[i - 1][j]).first + 1;
      } else {
        b2[i][j].first = 0;
      }
    }
  }

  for(int i = h - 2; i >= 0; --i) {
    for(int j = 0; j < w; ++j) {
      if(a[i + 1][j] == '.') {
        b2[i][j].second = (b2[i + 1][j]).second + 1;
      } else {
        b2[i][j].second = 0;
      }
    }
  }

  int res = 0;
  for(int i = 0; i < h; ++i) {
    for(int j = 0; j < w; ++j) {
      int t = b[i][j].first + b[i][j].second + b2[i][j].first + b2[i][j].second;
      if(a[i][j] == '.') {
        res = max(res, t);
      } else {
        t = 0;
      }
      //cout << t << "|";
    }
    //cout << endl;
  }

  delete []b;
  delete []b2;

  cout << res + 1;

}


Measured memory_bytes: 66944
def main(istr, ostr):
    n = int(istr.readline())
    types = ["AC", "WA", "TLE", "RE"]
    counts = dict((t, 0) for t in types)
    for i in range(n):
        t = istr.readline().strip()
        counts[t] += 1
    for k, v in counts.items():
        print(f"{k} x {v}", file=ostr)


if __name__ == "__main__":
    import sys

    main(sys.stdin, sys.stdout)


Measured memory_bytes: 9136
#!usr/bin/env python3

import sys


def main():
    while True:
        m, f, r = [int(score) for score in sys.stdin.readline().split()]
        if m == f == r == -1:
            break
        if m == -1 or f == -1:
            print('F')
        elif m+f >= 80:
            print('A')
        elif 80 > m+f >= 65:
            print('B')
        elif 65 > m+f >= 50:
            print('C')
        elif 50 > m+f >= 30:
            if r >= 50:
                print('C')
            else:
                print('D')
        elif m+f < 30:
            print('F')


if __name__ == '__main__':
    main()

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


int MOD=1000000007;


int main() {
	int n,co=0;
	cin >> n;
	int p[n+10];
	for(int i=0; i<n; i++) cin >> p[i];
	for(int i=1; i<n-1; i++){
		if(p[i-1]<=p[i] && p[i]<=p[i+1] || p[i-1]>=p[i] && p[i]>=p[i+1]){
		co+=1;
		}
	}
	cout << co << endl;
}

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

using namespace std;

string S, T;

int main(void) {

	cin >> S >> T;

	int N = S.size();

	int sign = 0;

	for (int i = 0; i < N; i++) {
		string str = S.substr(i) + S.substr(0, i);
		if (str == T) { sign = 1; break; }
	}

	if (sign == 1) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
	
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a + b >= c){
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

#define dame cout << 0 << endl; return 0

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

    int n;
    cin >> n;
    vi l(n);
    rep(i, n) cin >> l[i];
    vi r(n);
    rep(i, n) cin >> r[i];

    vi a(n);
    a[0] = l[0];
    rep2(i, 1, n) {
        if (l[i] != l[i-1]) {
            a[i] = l[i];
        }
    }
    vi b(n);
    b[n-1] = r[n-1];
    for (int i = n-2; i >= 0; i--) {
        if (r[i] != r[i+1]) {
            b[i] = r[i];
        }
    }

    rep(i, n) {
        if (a[i] > 0 && b[i] > 0 && a[i] != b[i]) {
            dame;
        }
        if (a[i] == 0 && b[i] > 0) {
            a[i] = b[i];
        }
    }

    vi lt(n);
    lt[0] = a[0];
    rep2(i, 1, n) {
        lt[i] = max(lt[i-1], a[i]);
    }
    if (l != lt) {
        dame;
    }
    vi rt(n);
    rt[n-1] = a[n-1];
    for (int i = n-2; i >= 0; i--) {
        rt[i] = max(rt[i+1], a[i]);
    }
    if (r != rt) {
        dame;
    }

    // printV(a);

    int ans = 1;
    rep(i, n) {
        if (a[i] == 0) {
            (ans *= min(l[i], r[i])) %= mod;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <functional>

std::pair<int, int> delta[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

int main() {
	int h, w, k, sx, sy;
	std::cin >> h >> w >> k;
	std::vector<std::string> s(h);
	for (int i = 0; i < h; i++) {
		std::cin >> s[i];
		for (int j = 0; j < w; j++) {
			if (s[i][j] == 'S') { sx = i; sy = j; }
		}
	}
	
	std::function<int(int, int)> f = [&] (int i, int j) {
		return std::abs(i - sx) + std::abs(j - sy);
	};
	
	bool seen[h][w] = {};
	std::queue<std::pair<int, int>> que;
	que.emplace(sx, sy);
	
	while (not que.empty()) {
		auto [x, y] = que.front(); que.pop();
		if (seen[x][y]) continue;
		seen[x][y] = true;
		for (std::pair<int, int> &p : delta) {
			int dx = x + p.first, dy = y + p.second;
			if (dx < 0 or h <= dx or dy < 0 or w <= dy) continue;
			if (s[dx][dy] == '#' or seen[dx][dy]) continue;
			que.emplace(dx, dy);
		}
	}
	
	int ans = (1 << 30);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (not seen[i][j]) continue;
			if (f(i, j) > k) continue;
			int dist = std::min(std::min(i, j), std::min(h - 1 - i, w - 1 - j));
			int res = dist / k + !!(dist % k);
			ans = std::min(ans, res + 1);
		}
	}
	
	std::cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 5060
(* parser ????????????
exp    = term _exp
_exp   = + term _exp | eps
term   = factor _term
_term  = * factor _term | eps
factor = ( exp ) | num
num    = digit(digit)*
digit  = 0-9
*)

let s = ref ""
let length = ref 0
let cur = ref 0

let str_access n =
  if ( n < !length ) then (String.get !s n)
  else '#'

let digit ()=
  let a = Char.escaped (str_access !cur)  in
  (cur:=!cur+1;int_of_string a)

let rec number () =
  let n = ref (digit()) in
  while (!cur < !length && (str_access !cur) >= '0' && (str_access !cur) <= '9') do
    n := 10 * !n + digit()
  done ; !n

and factor ()=
  match (str_access !cur) with
    '(' -> (cur := !cur+1;let n=expr() in cur := !cur+1; n)
  | _   -> number()

and term ()=
  let n = factor() in (_term n)

and _term m =
  match (str_access !cur) with
    '*' -> (cur := !cur+1;let n = m*(factor()) in (_term n))
  | '/' -> (cur := !cur+1;let n = m/(factor()) in (_term n))
  | _   -> m

and expr ()=
  let n = term ()in (_expr n)

and _expr m =
  match (str_access !cur) with
    '+' -> (cur := !cur+1;let n = m+(term()) in (_expr n))
  | '-' -> (cur := !cur+1;let n = m-(term()) in (_expr n))
  | _   -> m

and parse () = expr ();;

(* main *)

(*
ignore ( read_line () )
let rec loop() =
  try
    s := read_line();
    length := String.length !s;
    cur := 0;
    print_int @@ parse ();print_newline();
    loop()
  with End_of_file -> ()
let () = loop()
*)
let nn = int_of_string @@ read_line()
let () =
for i = 1 to nn do
  s := read_line();
  length := String.length !s;
  cur := 0;
  print_int @@ parse ();print_newline();
done

Measured memory_bytes: 2596
=begin
N M
A1 B1
...
An Bn
=end

n, m = gets.chomp.split(" ").map(&:to_i)

abs = n.times.map do
  gets.chomp.split(" ").map(&:to_i)
end

abs.sort_by! do |a, b|
  a
end

cost = 0
drinks = 0

abs.each do |a, b|
  if drinks + b >= m
    cost += (m - drinks) * a
    break
  else
    drinks += b
    cost += b * a
  end
end

puts cost


Measured memory_bytes: 12664
#include <iostream>

using namespace std;

int SumOfDigits(int n) {
    int sum = 0;
    while(n >0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int n;
    cin >> n;
    if (n % SumOfDigits(n) == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.BitSet;
import java.util.NoSuchElementException;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}

	static int[][]f;
	static final int[]dx={-1,0,1,0},dy={0,-1,0,1};
	public static void main(String[]$){
		int n=getInt();
		long r=1;

		PrimeIterator pr=new PrimeIterator(n);

		for(int p:pr) {
			int c=1;
			for(int j=p;j<=n;j*=p) {
				c+=n/j;
			}
			r*=c;
			r%=1000000007;
		}
		System.out.println(r);
	}
	public static class PrimeIterator implements Iterable<Integer>,PrimitiveIterator.OfInt{
		private BitSet	bs;
		private int		curv,limit;

		//todo
		//public PrimeIterator(int from,int limit);
		public PrimeIterator(int limit){
			curv=0;
			bs=new BitSet(limit+1);
			this.limit=limit;
			constructBS();
		}
		private final void constructBS(){
			bs.set(0,limit+1);
			bs.clear(0);
			bs.clear(1);
			if(limit<2) return;

			int i=2;
			while(sieve(i=bs.nextSetBit(i)))
				i++;
		}
		protected boolean sieve(int v){
			final long sievestart=1L*v*v;
			if(4>sievestart||sievestart>limit)
				return false;
			IntStream.iterate(v*v,i->i+v).limit(limit/v-v+1).forEach(bs::clear);
			return true;
		}
		@Override
		public boolean hasNext(){
			final int r=getNextValue();
			return 0<=r&&r<=limit;
		}
		private int getNextValue(){
			return bs.nextSetBit(curv+1);
		}
		@Override
		public int nextInt(){
			final int r=getNextValue();
			if(r<0||limit<r) throw new NoSuchElementException();
			return curv=r;
		}
		@Override
		public OfInt iterator(){
			return this;
		}
		public BitSet getClonedBitSet(){
			return bs.get(0,limit+1);
		}
	}
}

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

a = [0] * M
b = [0] * M

for i in range(M):
    a[i], b[i] = map(int, input().split())

top = min(b) #ｒの最小、上限
under = max(a) #ｌの最大、下限

if top >= under:
    ans = top - under + 1
if top < under:
    ans = 0

print(ans)


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

int main() {
  

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

    float sum=0;
    for(int i=0;i<n;i++)
    {
    	sum=sum+(1/a[i]);
    }
    cout<<(1/sum)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
using namespace std;

int main()
{
    vector<int> order(5);
    cin >> order[0] >> order[1] >> order[2] >> order[3] >> order[4];

    int last = order[0] % 10,last_n = 0;
    for(int i = 0;i < 5;i++){
        if(last > order[i] % 10 && order[i] % 10 != 0){
            last = order[i] % 10;
            last_n = i;
        }
    }

    int ans = 0;
    for(int i = 0;i < 5;i++){
        if(i != last_n){
            if(order[i] % 10 == 0){
                ans += order[i];
            }
            else{
                ans += (order[i] / 10 + 1) * 10;
            }
        }
        else{
            ans += order[i] - last;
            ans += last;
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define pob pop_back
#define ff first
#define ss second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define int long long
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
/* 	1) order_of_key (k) : Number of items strictly smaller than k .
	2) find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace __gnu_pbds;
using namespace std;
using LD = long double;

const int maxs = 1e6+1;
const int mod = 1e9+7;
const int INF = 1e18;
int row[8] = {1,1,0,-1,-1,-1,0,1};
int col[8] = {0,-1,-1,-1,0,1,1,1};

typedef long long ll;


const ll N = 2005;
vector<ll> A;
ll dp[N];
bool vis[N];

ll go(ll sum){
    if(sum < 0)
        return 0;
    if(sum == 0)
        return 1;
    if(vis[sum]){
        return dp[sum];
    } 
    vis[sum] = true;
    ll ans=0;
    for(auto it : A){
        ans += go(sum-it);
        ans %= mod;
    }
    return dp[sum] = ans;
}

void solve(){

    int s;
    cin >> s;
    for(int i=3;i<=s;i++){
        A.push_back(i);
    }
    reverse(all(A));
    ll ans = go(s);
    cout << ans;

}
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t = 1,i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


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

using namespace std;

const int max_n = 100111, inf = 1000111222;

int n, a[max_n];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int ans = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
        ans += abs(a[i - 1] - a[i]);
    }
    ans += abs(a[n]);
    for (int i = 1; i <= n; ++i) {
        int x = ans;
        x -= abs(a[i - 1] - a[i]);
        x -= abs(a[i + 1] - a[i]);
        x += abs(a[i + 1] - a[i - 1]);
        printf("%d\n", x);
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long A;
  cin >> A;
  string S;
  cin >> S;
  int B100 = (S[0] - '0') * 100 + (S[2] - '0') * 10 + (S[3] - '0');
  long long ans = A * B100;
  if (ans < 100){
    cout << 0 << endl;
  } else {
    string S2 = to_string(ans);
    int N = S2.size();
    for (int i = 0; i < N - 2; i++){
      cout << S2[i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 3696