akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<(int)N;i++)
#define p(S) cout<<(S)<<endl
#define ck(n,a,b) (a<=(n)&&(n)<b)
typedef long long ll;
using namespace std;
const int inf=1e9;
 
 
int main(){
    int n;
    cin>>n;
    int dp[100010];//no-visit inf, NG -inf,
    int effect[100010];
    REP(i,0,n) cin>>effect[i];
    REP(i,0,n) dp[i]=inf;
    queue<int> q;
    dp[0]=0;
    q.push(0);
    //bfs
    while(!q.empty()){
        int now=q.front();q.pop();
        REP(i,1,7){
            int next=now+i;
            if(next>n-1) break;
            if(dp[next]==inf){
                set<int> s;//check
                while(1){
                    s.insert(next);
                    next+=effect[next];
                    if(effect[next]==0){
                        s.insert(next);
                        for(auto itr=s.begin();itr!=s.end();itr++) {
                            dp[*itr]=min(dp[*itr],dp[now]+1);
                        }
                        q.push(next);
                        break;
                    }
                    if(s.find(next)!=s.end()||dp[next]!=inf){
                        for(auto itr=s.begin();itr!=s.end();itr++) dp[*itr]=inf-1;
                        break;
                    }
                }
            }
        }
        if(dp[n-1]<inf-1){
            break;
        }
    }
    p(dp[n-1]);
    return 0;
}

Measured memory_bytes: 7764
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, ab: [(usize, usize); n]);
    let mut a = ab.iter().map(|x| x.0).collect::<Vec<_>>();
    a.sort();
    let low = if n % 2 == 0 {
        a[n / 2] + a[n / 2 - 1]
    } else {
        a[n / 2]
    };

    let mut b = ab.iter().map(|x| x.1).collect::<Vec<_>>();
    b.sort();
    let high = if n % 2 == 0 {
        b[n / 2] + b[n / 2 - 1]
    } else {
        b[n / 2]
    };
    println!("{}", high + 1 - low);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 12764
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;cin>>s;
int t[4];
for(int i=0;i<4;i++) t[i]=s[i]-'0';
for(int i=0;i<8;i++){
  int cnt=t[0];
  char c[3];
  for(int j=0;j<3;j++){
    int f=(i>>j)&1;
    if(f==1){cnt+=t[j+1];c[j]='+';}
    else{cnt-=t[j+1];c[j]='-';}
  }
  if(cnt==7){
    for(int k=0;k<3;k++) cout<<t[k]<<c[k];
    cout<<t[3]<<"=7"<<endl;
    return 0;
  }
}
}

Measured memory_bytes: 256
x = int(input())
y = [int(i) for i in input().split()]

def fun(y):
  cnt = 0

  for i in y:
    if (i % 2) != 0:
      cnt += 1

  return cnt

def fun2(y):
  tmp = [i/2 for i in y]
  return tmp

ans = 0

while True:
  res = fun(y)
  if res >= 1:
    print(ans)
    break
  else:
    ans += 1
    y = fun2(y)

Measured memory_bytes: 3064
import java.io.ByteArrayInputStream;
import java.util.*;
import java.util.concurrent.TimeUnit;

class Solver{
    public static void main(String[] args){
        Random rand = new Random();
        StringJoiner sb = new StringJoiner("\n");
        sb.add("100000");
        for(int i = 0; i < 100000; i++){
            sb.add(rand.ints(10, 'a', 'z' + 1).collect(StringBuilder::new, (s, c) -> s.append((char) c), StringBuilder::append));
        }
        String s = sb.toString();
        System.setIn(new ByteArrayInputStream(s.getBytes()));
        System.out.println(s);
        Timer timer = new Timer();
        timer.schedule(new TimerTask(){
            @Override
            public void run(){
                System.err.println("TLE");
            }
        }, TimeUnit.SECONDS.toMillis(2));
        Main.main(args);
        timer.cancel();
    }

    private final String[] S;

    Solver(Scanner in){
        int N = in.nextInt();
        S = new String[N];
        for(int i = 0; i < N; i++){
            S[i] = in.next();
        }
    }

    void solve(){
        long[] hashes = new long[S.length];
        for(int i = 0; i < S.length; i++){
            String s = S[i];
            char[] chars = s.toCharArray();
            int[] count = new int['z' - 'a' + 1];
            for(char c : chars){
                count[c - 'a']++;
            }
            long hash = 0;
            for(int value : count){
                hash |= (1L << (Long.SIZE - Long.numberOfLeadingZeros(hash))) << value;
            }
            hashes[i] = hash;
        }
        Arrays.sort(hashes);
        long current = hashes[0];
        int count = 1;
        long result = 0;
        for(int i = 1; i < hashes.length; i++){
            if(current == hashes[i]){
                count++;
            }else {
                current = hashes[i];
                result += count * (count - 1L) / 2;
                count = 1;
            }
        }
        result += count * (count - 1L) / 2;
        System.out.println(result);
    }
}

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

        new Solver(in).solve();

        in.close();
    }
}

Measured memory_bytes: 56804
#include <stdio.h>
#define MAX 101

int main(void){
	int a[MAX][MAX], r, c, i, j;
	scanf("%d %d", &r, &c);	
	a[r][c] = 0;
	for(i = 0; i < r; i++){
		for(j = 0; j < c; j++){
			scanf("%d", &a[i][j]);
			a[r][c] += a[i][j];
		}
	}

	for(i = 0; i < r; i++){
			a[i][c] = 0;
		for(j = 0; j < c; j++){
			a[i][c] += a[i][j]; 
		}
	}

	for(j = 0; j < c; j++){
			a[r][j] = 0;
		for(i = 0; i < r; i++){
			a[r][j] += a[i][j];
		}
	}
	
	for(i = 0; i <= r; i++){
		for(j = 0; j <= c; j++){
			if(j < c){
				printf("%d ", a[i][j]);
			}
			else{
				printf("%d\n", a[i][j]);
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>S>>T;
    string ans = "No";
    N = S.size();
    string c;
    rep(i,N){
        if(S == T) ans = "Yes";
        c = S[N-1];
        S.erase(N-1);
        S.insert(0,c);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t n, x, t; cin >> n >> x >> t;

	cout << (n + x - 1) / x * t << endl;

	return 0;
}

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

using namespace std;

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int MILLION = 1000000;
int main(){
    int result=1000000;
    int input;
    bool flag=true;
    while(cin >> input && input){
	for(int i=0; i*i*i<=input; i++){
	    for(int j=0; j*j<=input-i*i*i; j++){
//		    if(i*i*i+j*j+k==input)
		int k = input - i*i*i - j*j;
		int temp = i+j+k;
		result = min(result, temp);

		}
	    }
	cout << result << endl;
	result = 1000000;
    }
    return 0;
}

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

long long int gcd(long long int a, long long int b) {
  if(a < b) return gcd(b, a);
  long long int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    long long int a, b, c, d, e, gross, acnt, bcnt, ans;
    cin >> a >> b >> c >> d;
    e = c * d / gcd(c, d);
    acnt = (a-1) / c + (a-1) / d - (a-1) / e;
    bcnt = b / c + b / d - b / e;
    gross = b - a + 1;
    ans = gross - bcnt + acnt;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <sstream>
#include <iostream>
#include <time.h>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <string.h>
#include <bitset>
#define sf scanf
#define pf printf
#define lf double
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define ll long long
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define eps 1e-7
#define zero(x) (((x) > 0? (x):(-x)) < eps)
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <sstream>
#include <iostream>
#include <time.h>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <string.h>
#include <bitset>

using namespace std;
//https://codeforces.com/contest/1238/problems
//https://codeforces.com/contest/1238/submit

string a;
int dp[1000005];
int b[100005];
stack<int> s;
int main() {
    int n,m;
    s(n) s(m)
    cin >> a;
    for(int i = 0; i < 100004; i ++){
        b[i] = 1000000000;
    }
    for(int i = 1; i <= m; i ++){
        if(a[i] == '0'){
            b[i] = 1;
            dp[i] = i;
        }
    }
    for(int i = m+1; i <= n; i ++){
        if(a[i] == '0'){
            for(int j = i-m; j < i; j ++){
                if(b[i] > b[j]+1){
                    b[i] = min(b[j]+1,b[i]);
                    dp[i] = j;
                }
            }
        }
    }
    /*for(int i = 1; i <= n;i  ++){
        cout << v[i].size() << " ";
        for(int j = 0; j < v[i].size(); j ++){
            cout << v[i][j] << " ";
        }
        cout << endl;
    }*/

    //cout << b[n] << endl;
    if(b[n] == 1000000000){
        cout << -1 << endl;
    }else{
        int x = n;
        while(dp[x] != x){
            s.push(x-dp[x]);
            x = dp[x];
        }
        s.push(x);
        cout << s.top();
        s.pop();
        while(!s.empty()){
            cout << " "<<s.top();
            s.pop();
        }
            /*cout <<v[n][0];
            for(int j = 1; j < v[n].size(); j ++){
            cout << " "<< v[n][j]-v[n][j-1] ;
            }*/
    }
    return 0;
}


Measured memory_bytes: 1740
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N, i;
  cin >> N >> i;
  cout << N+1-i << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define m 1e9+7
#define lld long long int 
#define ull unsigned long long int 
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forrev(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forrand(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define endl "\n"

using namespace std;

typedef pair<lld, lld> pii;
typedef vector<lld> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef unordered_map<lld ,lld > mpii;
typedef unordered_map<char ,lld > mpci;
typedef unordered_map<lld ,char > mpic;
typedef unordered_map<string ,lld > mpsi;

//useful utility functions
bool cmp(lld a ,lld b){ return ( a>b? true : false);}
bool pair_cmp(pii a,pii b){return (a.first>b.first? true : false);}
lld mpow(lld a,lld b,lld p=m){a=a%p;lld res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
 lld count_factors(lld c){lld cnt=0; for(lld i=1; i*i<=c; i++){ if(c%i==0){if(c/i==i)cnt++;else cnt+=2; } } return cnt;}
//gcd function __gcd()
/*
It is not a disgrace if you don't reach the stars,
But a disgrace if you don't have stars to reach.
*/

lld t;

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

        lld n,k,i,j,cnt=0,c=0;
        cin>>n;
         double a[n],b;
        for0(i,n){
            cin>>a[i];
            b+=1/a[i];
        }
        //logic here
        cout<<setprecision(9)<<1/b;


	return 0;
}

Measured memory_bytes: 256
#coding:utf-8

if __name__ == "__main__":
    N = int(input())

    points = []
    for i in range(N):
        points.append(int(input()))

    points.sort()

    total_point = sum(points)
    if total_point % 10 != 0:
        print(total_point)
    elif sum(map(lambda x: x % 10, points)) == 0:
        print(0)
    else:
        for point in points:
            if point % 10 != 0:
                print(total_point - point)
                break


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void codeforces()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
int32_t main()
{
    
    // w(t)
    {
        string s;
        cin>>s;
        cout<<s.substr(0, 3);
        
    }
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
	int n,r;
	while(1){
		scanf("%d",&n);
		if(n==-1){
			break;
		}else if(n<10){
			r=1150;
		}else if(n<20){
			r=1150+125*(n-10);
		}else if(n<30){
			r=2400+140*(n-20);
		}else{
			r=3800+160*(n-30);
		}
		printf("%d\n",4280-r);
	}
	return 0;
}

Measured memory_bytes: 2752
import sys
sys.setrecursionlimit(2*10**9)
N, Q = map(int, input().split())
A = [[] for _ in range(N)]
for _ in range(N-1):
    i, k = map(int, input().split())
    A[i-1].append(k-1)
    A[k-1].append(i-1)
n_P = [0] * N
for _ in range(Q):
    k, n = map(int, input().split())
    n_P[k-1] += n
ans = [0] * N
visited = [0] * N
def make(num, p):
    ans[num] += n_P[num] 
    ans[num] += p
    visited[num] = 1
    for i in A[num]:
        if visited[i] == 0:
            make(i,ans[num])
    return
make(0, ans[0])
print(*ans)

Measured memory_bytes: 228100
X,Y,A,B,C = list(map(int, input().split()))
red = list(map(int, input().split()))
green = list(map(int, input().split()))
white = list(map(int, input().split()))

red = sorted(red, reverse=True)[:X]
green = sorted(green, reverse=True)[:Y]
ans = sum(red) + sum(green)

white = sorted(white, reverse=True)
for i in range(len(white)):
    current = white[i]
    if len(red) != 0 and len(green) != 0:
        if red[-1] < green[-1] and current > red[-1]:
            ans += current - red[-1]
            red.pop(-1)
        elif red[-1] >= green[-1] and current > green[-1]:
            ans += current - green[-1]
            green.pop(-1)
        else:
            break
    elif len(red) != 0:
        if current > red[-1]:
            ans += current - red[-1]
            red.pop(-1)
    elif len(green) != 0:
        if current > green[-1]:
            ans += current - green[-1]
    else:
        break

print(ans)

Measured memory_bytes: 106980
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int q; cin >> q;
	deque<int> a;
	VI print;
	rep(i, q) {
		int x, y, z;
		cin >> x;
		if (x == 0)cin >> y >> z;
		else cin >> y;

		if (x == 0) {
			if (y == 0)a.push_front(z);
			else if (y == 1)a.push_back(z);
		}
		else if (x == 1) {
			print.pb(a[y]);
		}
		else if (x == 2) {
			if (y == 0)a.pop_front();
			else if (y == 1)a.pop_back();
		}
	}
	for (auto ans : print) {
		cout << ans << endl;
	}
}


Measured memory_bytes: 4576
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

n=int(input())
p=input_array()

count=0
for i in range(1,n-1):
	if p[i-1]<p[i] and p[i]<p[i+1]:
		count+=1
	elif p[i+1]<p[i] and p[i]<p[i-1]:
		count+=1
	else:
		continue
print(count)

Measured memory_bytes: 9048
#include <cstdio>
#include <vector>
using namespace std;

int main() {
    int N; scanf("%d", &N);
    vector< vector<int> > G(N);
    for(int i=0; i+1<N; i++) {
        int u, v; scanf("%d%d", &u, &v);
        u--; v--;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    vector< vector<int> > dp(N, vector<int>(2));
    auto dfs = [&](auto &&self, int cur, int par) -> void {
        int cnt[2] = {}, deg = 0;
        for(auto to : G[cur]) {
            if(to == par) continue;
            self(self, to, cur);
            deg++;
            for(int k=0; k<2; k++) cnt[k] += dp[to][k];
        }

        dp[cur][0] = 1;
        for(auto to : G[cur]) {
            if(to == par) continue;
            dp[cur][0] &= dp[to][1];
            dp[cur][1] |= (dp[to][0] and deg - 1 == cnt[1] - dp[to][1]);
        }
        // fprintf(stderr, "cur = %d, dp = (%d, %d)\n", cur, dp[cur][0], dp[cur][1]);
    };

    dfs(dfs, 0, -1);
    printf("%s\n", (dp[0][1] ? "Second" : "First"));
    return 0;
}


Measured memory_bytes: 11264
import java.util.*;

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

	double[] x;
	double[] y;
	int n;
	void calc(){
		Scanner cin = new Scanner(System.in);
		while(true){
			n = cin.nextInt();
			if(n==0) break;
			x = new double[n];
			y = new double[n];
			int i,j;
			for(i=0;i<n;i++){
				x[i] = cin.nextDouble();
				y[i] = cin.nextDouble();
			}
			int ret = 0;
			for(i=0;i<n;i++){
				ret = Math.max(ret, getnum(x[i],y[i]));
				for(j=i+1;j<n;j++){
					if(Math.hypot(x[i]-x[j], y[i]-y[j]) > 2) continue;
					ret = Math.max(ret, getmax(new int[]{i,j}));
					ret = Math.max(ret, getmax(new int[]{j,i}));
				}
			}
			System.out.println(ret);
		}
	}

	int getmax(int[] nums){
		double nx = 0;
		double ny = 0;
		for(int a : nums){
			nx += x[a]/nums.length;
			ny += y[a]/nums.length;
		}
		double vx = nx-x[nums[0]];
		double vy = ny-y[nums[0]];
		double d = Math.hypot(vx, vy);
		double nokori = Math.sqrt(1-d*d);
		vx/=d; vy/=d;
		nx += vy * nokori;
		ny -= vx * nokori;
		return getnum(nx,ny);
	}

	int getnum(double nx, double ny){
		int ret = 0;
		for(int i = 0;i < n;i++){
			if((nx-x[i])*(nx-x[i])+ (ny-y[i]) * (ny-y[i])<=1+1e-6) ret++;
		}
		return ret;
	}

}

Measured memory_bytes: 13000
v, e = gets.split.map(&:to_i)
ret = []
set = Array.new(v){ |i| i }
g = Array.new(v){ Array.new }
rg = Array.new(v){ Array.new }
e.times do
  s,t = gets.split.map(&:to_i)
  g[s] << t
  rg[t] << s
end
empset = []
v.times{ |i| empset << i if rg[i].empty? }
until set.empty?
  n = empset.shift
  set.delete(n)
  ret << n
  g[n].each do |m|
    rg[m].delete(n)
    if rg[m].empty?
      set << m
      empset << m
    end
  end
end
ret.each{|v| p v}

Measured memory_bytes: 13240
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll Mod=998244353;
const int maxn=310;
int n,m;
bitset<maxn> p[maxn],b;
ll pw(ll x,ll y)
{
	ll res=1;
	while (y)
	{
		if (y&1)
		{
			res=res*x%Mod;
		}
		x=x*x%Mod;
		y>>=1;
	}
	return res;
}
int main()
{
	scanf("%d%d",&n,&m);
	int r=0;
	for (int i=1;i<=n;i++)
	{
		b.reset();
		for (int j=1;j<=m;j++)
		{
			int x;
			scanf("%d",&x);
			if (x)
			{
				b.set(j);
			}
		}
		for (int j=m;j;j--)
		{
			if (!b[j])
			{
				continue;
			}
			if (!p[j].any())
			{
				p[j]=b;
				break;
			}
			b^=p[j];
		}
		if (!b.any())
		{
			r++;
		}
	}
	cout<<(pw(2,n)-pw(2,r)+Mod)%Mod*pw(2,m-1)%Mod<<endl;
	return 0;
}

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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const ll NN = 1e10 + 7;
const int N = 1e4;
const int M = 11;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;
const int B = sqrt(N);

void solve1()
{
    int n,c,k;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector < int > l;
    deque < int > r;
    for( int i = 0; i < n; i++ ){
        if( s[i] == 'o' ){
            l.push_back(i);
            i += c;
        }
        if( (int)l.size() > k )break;
    }
    for( int i = n - 1; i >= 0; i-- ){
        if( s[i] == 'o' ){
            r.push_front(i);
            i -= c;
        }
        if( (int)r.size() > k )break;
    }
    for( int i = 0; i < k; i++ ){
        if( l[i] == r[i] )cout << l[i] + 1 << "\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


Measured memory_bytes: 3340
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    vector<long long> b;
    b.push_back(-1);
    int blen = 1;
    int kind = 0;
    int zero = 0;
    vector<long long> a(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i);
        if(a.at(i) == 0) {
            zero++;
        }
        if(kind <= 3) {
            bool dub = false;
            for(int j = 0; j < blen; ++j) {
                if(b.at(j) == a.at(i)) {
                    dub = true;
                }
            }
            if(!dub) {
                kind++;
                b.push_back(a.at(i));
                blen++;
            }
        }
    }

    if(kind == 1) {
        if(zero == n) {
            cout << "Yes" << endl;
            return 0;
        }
    }else if(kind == 2) {
        if(n % 3 == 0) {
            if(n / 3 == zero) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }else if(kind == 3) {
        if(n % 3 == 0) {
            int fuck = b.at(1) ^ b.at(2);
            fuck ^= b.at(3);
            if(fuck == 0) {
                int fst = 0;
                int snd = 0;
                int thd = 0;
                for(int i = 0; i < n; ++i) {
                    if(a.at(i) == b.at(1)) {
                        fst++;
                    }else if(a.at(i) == b.at(2)) {
                        snd++;
                    }else {
                        thd++;
                    }
                }
                if(fst == snd) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "No" << endl;
}

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

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

int main(){

  int x[5];
  rep(i,5) cin>>x[i];

  rep(i,5)if(x[i]==0){
    cout<<i+1<<endl;
  }

  //cout << ans << endl;
}


Measured memory_bytes: 3632
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Diagnostics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            //ここに記述
            //データはストリームによて読み込まれており、' 'によって分割されている場合はキュー型のリストに蓄積れる
            // ' 'によって区切られていない場合、次の行を読み込むようになるので、そのまま記述してよい
            //var = cin.ReadInt; イント型

            var a = cin.ReadInt;
            var b = cin.ReadInt;
            var c = cin.ReadInt;

            if (a == b && a == b && b == c) WriteLine("Yes");
            else WriteLine("No");

        }

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}

Measured memory_bytes: 11220
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(i==0||i==h-1||j==0||j==w-1)
	  cout << "#";
	else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}



Measured memory_bytes: 3084
#include <cstdio>

using namespace std;
typedef long long ll;

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

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

int main() {
    ll a, b, c, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    ll oa = a, ob = b, g = gcd(c, d);
    a = (a - 1) / g, b = b / g, c /= g, d /= g;
    ll l = lcm(c, d);
    ll qc = b / c - a / c, qd = b / d - a / d, qcd = b / l - a / l;
    printf("%lld\n", ob - oa + 1 - (qc + qd - qcd));
    return 0;
}


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

using namespace std;

int main(){
    string c = "CODEFESTIVAL2016";
    string s;
    cin >> s;
    int count = 0;
    for(int i=0;i<s.size();i++){
        if(c[i] != s[i]){
            count++;
        }
    }
    cout << count;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		for (int i = a; i <= b; i++) {
			if (i % k == 0) {
				System.out.println("OK");
				return;
			}
		}
		System.out.println("NG");

	}
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

int F(int a, int b){
    return max(to_string(a).length(),to_string(b).length());
}

signed main() {
    int n; cin >> n;
    int ans = INT_MAX;
    for(int i = 1; i*i <= n; i++) {
        if(n % i == 0) {
            ans = min(ans, F(i,n/i));
        }
    }
    cout << ans << endl;
}

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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;
vector<ll> cost(100000,-1);
vector<pair<int, ll> > e[100000];

void dfs(int v, ll c){
    for(int i = 0; i < e[v].size(); i++){
        if(cost[e[v][i].first] == -1){
            cost[e[v][i].first] = c+e[v][i].second;
            dfs(e[v][i].first, cost[e[v][i].first]);
        }
    }
}

signed main(){
    int n; cin >> n;
    for(int i = 0; i < n-1; i++){
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        e[a].push_back(make_pair(b,c));
        e[b].push_back(make_pair(a,c));
    }
    int q, k; cin >> q >> k;
    k--;
    cost[k] = 0;
    dfs(k, 0);
    for(int z = 0; z < q; z++){
        int x, y; cin >> x >> y;
        x--; y--;
        ll ans = cost[x] + cost[y];
        cout << ans << endl;
    }

    return 0;
}



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

using namespace std;
#define For(i,l,r) for (int i = l; i <= r; ++i)
#define Cor(i,l,r) for (int i = l; i >= r; --i)

int n;
char A[555][555];
int full[555];
int main() {
	cin >> n;
	For(i,1,n) scanf("%s", A[i] + 1);
	int full_col = 0;
	bool full_row = 0;
	For(i,1,n) {
		bool x = true;
		For(j,1,n) if (A[i][j] == '.') { x = false ; break ; }
		full_row |= x;
		x = true;
		For(j,1,n) if (A[j][i] == '.') { x = false ; break ; }
		full_col += x;
		full[i] = x;
	}
	int ans = n + n + 1;
	if (full_row) {
		ans = n - full_col;
	} else {
		For(i,1,n) For(j,1,n) if (A[i][j] == '#') {
			int leak = 0;
			For(k,1,n) if (A[j][k] == '.') {
				++leak;
			}
			ans = min(ans, leak + n - full_col);
			leak = 0;
			For(k,1,n) if (A[i][k] == '.') {
				++leak;
			}
			ans = min(ans, leak + n - full_col + 1);
		
		}
	}
	if (ans > n + n) puts("-1"); else cout << ans << endl;
	return 0;
}

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

#define MOD (1000 * 1000 * 1000 + 7)
typedef long long ll;
typedef long double ld;

int nums[10];

int main() {
	
	int n, k;
	scanf("%d%d", &n, &k);
	
	for(int i = 0; i < k; ++i) {
		int temp;
		scanf("%d", &temp);
		nums[temp] = 1;
	}
	
	
	int trenutno = n;
	
	while(true) {
		bool found = true;
		int a = trenutno;
		
		while(a > 0) {
			int d = a % 10;
			a /= 10;
			if(nums[d] == 1) {
				found = false;
				break;
			}
		}
		if(found) {
			printf("%d\n", trenutno);
			break;
		}
		
		++trenutno;
	}
	

	
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
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;}

string s;
int main(){
    cin >> s;
    int m = atoi(s.substr(5,7).c_str());
    int d = atoi(s.substr(8,10).c_str());
    if(m<=4){
        put("Heisei");
    }else{
        put("TBD");
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N=0;
    string S;
    cin>>S;

    for(int i=0;i<S.size();i++){
        if(S[i]=='+'){
            N++;
        }else{
            N--;
        }
    }

    cout<<N<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H, W;

    for (int i = 0;; i++) {
      H = sc.nextInt();
      W = sc.nextInt();
      if (H == 0 && W == 0) break;
      for (int h = 0; h < H; h++) {
        if (h % 2 == 0) {// # start
          for (int w = 0; w < W; w++) {
            if (w % 2 == 0) {
              System.out.printf("#");
            } else {
              System.out.printf(".");
            }
          }
          System.out.printf("\n");
        } else {// . start
          for (int w = 0; w < W; w++) {
            if (w % 2 == 0) {
              System.out.printf(".");
            } else {
              System.out.printf("#");
            }
          }
          System.out.printf("\n");
        }
      }
      System.out.printf("\n");
    }

    sc.close();
  }
}



Measured memory_bytes: 62868
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>

#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

// Debug Vector
template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v){
    if(!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}
//---------


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
////    CLion Standard Input for DEBUG
////    --------------------------------------------------------------------------
//    ifstream in("/Users/ryo/Dropbox/competition/CompetitivePrograming/Problems/atcoder/ABC/064/in.txt");
//    cin.rdbuf(in.rdbuf());
////    --------------------------------------------------------------------------

    int n;
    cin >> n;
    string s;
    cin >> s;
    string ans = s;
    int left = 0, right = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '(') left++;
        else right++;
        if(right - left > 0) {
            ans = '(' + ans;
            left++;
        }
    }

    if(left - right){
        for(int i = 0; i < left - right; i++){
            ans = ans + ')';
        }
    }


    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<Integer>();
        for(int i=0;i<N;i++){
            list.add(sc.nextInt());
        }
        Collections.sort(list);
        // System.out.println(Arrays.toString(list.toArray()));
        double tmp = list.get(0);
        double ans = 0;
        for(int i=1;i<N;i++){
            int p=list.get(i);
            tmp = (tmp+p)/2;
        }
        System.out.println(tmp);
    }
}

Measured memory_bytes: 21716
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    r = int(input())
    print(r**2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5624
delta = [[0,1],[1,0],[0,-1],[-1,0]]
def search(s):
    visited = [[0 for _ in range(W)] for __ in range(H)]
    queue = [[0,0]]
    visited[0][0] = 1
    while queue:
        [i,j] = queue.pop(0)
        for k in range(4):
            i_next = i + delta[k][0]
            j_next = j + delta[k][1]
            if i_next in range(H) and j_next in range(W) and s[i_next][j_next]=='.' and visited[i_next][j_next]==0:
                visited[i_next][j_next] = visited[i][j]+1
                queue.append([i_next,j_next])
    if visited[-1][-1]==0:
        print(-1)
#        for l in range(H):
#            print(visited[l])
        exit()
    else:
        return visited[H-1][W-1]

H, W = map(int, input().split())
s = [input() for _ in range(H)]

white = 0
for i in range(H):
    white += len(s[i].replace('#',''))

print(white - search(s))

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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)

#define L(x) ((x)*2)
#define R(x) ((x)*2+1)

#ifndef __SOULTCH
#define endl '\n'
#define debug(x) 
#else
#define debug(x) cout << " [+] " << #x << " = " << x << endl
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << pai.first << ' ' << pai.second;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    rep(i, sz(v)) cout << v[i] << ' ';
    return os;
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> s) {
    for (T p : s) cout << p << ' ';
    return os;
}

template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> s) {
    for (auto p : s) cout << '(' << p << ") ";
    return os;
}

template<typename T, typename V>
istream &operator>>(istream &is, pair<T, V> &pai) {
	is >> pai.first >> pai.second;
	return is;
}

int N, A, B;
int p;

void trans(int c) {
    int b1 = (c&(1<<p))>0;
    int b2 = (c&(1<<(N-1)))>0;
    if (b1 != b2) c^=((1<<p)|(1<<(N-1)));

    cout << (c^A) << ' ';
}

int ava[100];

void print(int n, int a, int b) {
    if (n == 1) {
        cout << a << ' ' << b << ' ';
        return;
    }

    int p1, p2;
    rep(i, N) if ((a^b)&(1<<i) and !ava[i]) {
        ava[p1 = i] = 1;
        break;
    }
    rep(i, N) if (!ava[i]) {
        p2 = i;
    }

    print(n-1, a, a^(1<<p2));
    print(n-1, a^((1<<p1)|(1<<p2)), b);
    ava[p1] = 0;
}

int cc(int t) {
    int cnt = 0;
    for (int i = 0; (1<<i) <= t; i++) {
        cnt += (t&(1<<i))>0;
    }
    return cnt;
}

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> N >> A >> B;
    
    if ((abs(cc(A)-cc(B))&1)==0) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;

    print(N, A, B);
    cout << endl;
}







Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
	int i=0,count[101]={0},max=0;
	while(scanf("%d",&i)!=EOF)
	{
		count[i]++;
		if(count[i]>max)
		{
			max=count[i];
		}
	}
	for(i=1;i<=100;i++)
	{
		if(max==count[i])
			printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<ll, int>> a(n);
    vector<int> b(n);
    REP(i,n){
        cin >> a[i].first >> a[i].second;
    }
    SORT(a);
    ll res = 0;
    int cnt = 0;
    REP(i,n){
        if(cnt+a[i].second<=m){
            res += a[i].first*a[i].second;
            cnt += a[i].second;
        }else{
            res += a[i].first*(m-cnt);
            cnt += m-cnt;
        }
    }
    put(res);
    return 0;
}


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

using namespace std;

int main(void) {
	int n, k;
	int now = 1;

	cin >> n >> k;

	for (int i = 1; i <= n; i++) {
		now = min(now * 2, now + k);
	}

	cout << now << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string a;
    int cnt = 0;
    string c = "";
    cin >> a;
    int b = a.size();
    vector<int> v(b,0);
    for(int i=0;i<b;i++){
        if(a[i] == 'A' or a[i] == 'T' or a[i] == 'G' or a[i] == 'C') c += '1';
        else c += '0';
    }
    for(int i=0;i<b;i++){
        if(c[i] == '1') v[cnt]++;
        else cnt++;
    }
    sort(v.begin(), v.end());
    cout << v[b-1] << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define mov(x) (1<<(x))

using namespace std;

template <typename T> void cmin(T &x, const T &y)
{
	if(y < x) x = y;
}

template <typename T> void cmax(T &x, const T &y)
{
	if(y > x) x = y;
}

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

int n, m, sum;
int grp[mov(15)];
int w[15][15];
int f[mov(15)][15];

int main()
{
	read(n), read(m);
	memset(w, 0x9f, sizeof(w));
	for(int i=1; i<=m; i++)
	{
		int a, b, c;
		read(a), read(b), read(c);
		w[a-1][b-1] = c;
		w[b-1][a-1] = c;
		sum += c;
	}
	memset(f, 0x9f, sizeof(f));
	for(int s=1; s<mov(n); s++)
		for(int i=0; i<n; i++)
			if(s & mov(i))
				for(int j=i+1; j<n; j++)
					if(s & mov(j))
						if(w[i][j] > 0)
							grp[s] += w[i][j];
	for(int s=1; s<mov(n); s++)
		if(s & 1)
			f[s][0] = grp[s];
	for(int s=1; s<mov(n); s++)
		for(int i=0; i<n; i++)
			if(mov(i) & s)
			{
				int u = ((~s)&(mov(n)-1));
				for(int t=u; t; t=((t-1)&u))
					for(int j=0; j<n; j++)
						if(mov(j) & t)
							if(w[i][j] > 0)
								cmax(f[s|t][j], f[s][i] + w[i][j] + grp[t]);
			}
	printf("%d\n", sum-f[mov(n)-1][n-1]);
	return 0;
}


Measured memory_bytes: 2432
h, w = map(int,input().split())
s = [list(input().split()) for i in range(h)]
ALP = [chr(i) for i in range(65, 65+26)]

for i in range(w):
    for j in range(h):
        if s[j][i] == "snuke":
            print(ALP[i] + str(j+1))
            exit()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MA=4294967295;
const int mod=1000000007;

int main(){
	int n,m;
	cin>>n>>m;
	int brok[n+1]={};
	int a[m];
	for(int i=0;i<m;i++){
		cin>>a[i];
		brok[a[i]]=1;
	}
	int dp[n+1];
	dp[0]=1;
	dp[1]=0;
	if(!brok[1]){
		dp[1]=1;
	}
	for(int i=2;i<=n;i++){
		if(!brok[i]){
			dp[i]=dp[i-1]+dp[i-2];
			dp[i]=dp[i]%mod;
		}
		else{
			dp[i]=0;
		}
		// cout<<dp[i]<<" ";
	}
	// cout<<endl;
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1408
from sys import stdin
readline = stdin.readline

N, M = map(int, readline().split())

ab = [[] for _ in range(N + 1)]
for _ in range(M):
    a, b = map(int, readline().split())
    ab[a].append(b)

dp = [0] * (N + 1)
for i in range(1, N + 1):
    dp[i] = max(dp[i], dp[i - 1])
    for j in ab[i]:
        dp[j] = max(dp[j], dp[i] + 1)

print(dp[N])


Measured memory_bytes: 23300
#include <stdio.h>

int main(){
int H,W,i,j;
while(1){
scanf("%d %d",&H,&W);
if(H==0&&W==0) break;
for(i=1;i<=H;i++){
   if(i==1||i==H){
      for(j=1;j<=W;j++){
         printf("#");
      }
   }else{
      for(j=1;j<=W;j++){
         if(j==1||j==W){
            printf("#");
         }else{
            printf(".");
         }
      }
   }
   printf("\n");
}
printf("\n");
}
return 0;
}

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

int main() {
  int h,w;
  cin>>h>>w;
  for (int k =0; k<w+2; k++){
    cout<< "#";
  }
  cout << endl;
  for(int i =0; i<h; i++){
    vector<string> a(100);
    cout << "#";
    cin>> a.at(i);
    cout << a.at(i);
    cout << "#" <<endl;
  }
  for (int l =0; l<w+2; l++){
    cout << "#";
  }
  cout << endl;
}


Measured memory_bytes: 256