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

long long n;
string s;

string solve();

int main() {
  while(1) {
    cin >> n;
    if(n == 0) break;
    cin >> s;
    cout << solve() << endl;
  }
  return 0;
}

string solve() {
  string res;
  long long a = 1LL << 52, now = 0, expo = 0;
  for(int i = 0; i < 52; ++i)
    if(s[51 - i] == '1') a += 1LL << i;
  now = a;
  while(a && n) {
    long long cnt = (1LL << 53) - now + a - 1;
    cnt /= a;
    now += a * min(cnt, n);
    if(min(cnt, n) == cnt) {
      ++expo;
      now >>= 1;
    }
    n -= min(cnt, n);
    if(n == 0) break;
    a >>= 1;
  }
  for(int i = 0; i < 12; ++i)
    res += '0' + (expo >> (11 - i) & 1);
  for(int i = 0; i < 52; ++i)
    res += '0' + (now >> (51 - i) & 1);
  return res;
}


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

int main() {
  string s;
  cin>>s;
  int max=0;
  for(int i=0;i<s.size()-2;i++){
    int a=100*(s[i]-'0')+10*(s[i+1]-'0')+(s[i+2]-'0');
    if(abs(753-max)>abs(753-a)) max=a;
  }
  
  cout<<abs(753-max)<<endl;

}


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

int N, M;
long long K;
long long x[100000], a[100000];

struct Perm {
  int n;
  vector<long long> xs;
  Perm(int n) : n(n) {
    for (int i=1; i<=n; i++) xs.push_back(i);
  }
  Perm(vector<long long> xs) : xs(xs) {
    n = xs.size();
  }
  Perm mult(const Perm b) {
    vector<long long> ret;
    for (int i=1; i<=n; i++) {
      ret.push_back(b.xs[xs[i-1]-1]);
    }
    return Perm(ret);
  }
  Perm pow(long long k) {
    Perm a(n), x(xs);
    while (k) {
      if (k & 1) a = a.mult(x);
      x = x.mult(x);
      k >>= 1;
    }
    return a;
  }
};

int main() {
  cin >> N;
  for (int i=0; i<N; i++) cin >> x[i];
  cin >> M >> K;

  vector<long long> d;
  for (int i=1; i<N; i++) {
    d.push_back(x[i]-x[i-1]);
  }
  Perm s(N-1);
  for (int i=0; i<M; i++) {
    int a; cin >> a;
    swap(s.xs[a-2], s.xs[a-1]);
  }
  Perm tr = s.pow(K);

  long long c = x[0];
  for (int i=0; i<N; i++) {
    cout << c << ".0\n";
    if (i < N-1) c += d[tr.xs[i]-1];
  }
  return 0;
}


Measured memory_bytes: 9320
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

int n;
string t;
set<string> s;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	
	while (n--){
		cin>>t;
		s.insert(t);
	}
	
	cout<<s.size();
}


Measured memory_bytes: 19140
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

void addWordCount(const vector<string>& cards, map<string, int>& wordCount);
void subWordCount(const vector<string>& cards, map<string, int>& wordCount);
int getMaxValue(const map<string, int>& wordCount);


int main() {
    int numOfBlueCard = 0;
    cin >> numOfBlueCard;
    vector<string> blueCards;
    for (int i = 0; i < numOfBlueCard; ++i) {
        string blueCard;
        cin >> blueCard;
        blueCards.push_back(blueCard);
    }

    int numOfRedCard = 0;
    cin >> numOfRedCard;
    vector<string> redCards;
    for (int i = 0; i < numOfRedCard; ++i) {
        string redCard;
        cin >> redCard;
        redCards.push_back(redCard);
    }
    
    map<string, int> wordCount;
    addWordCount(blueCards, wordCount);
    subWordCount(redCards, wordCount);
    
    cout << getMaxValue(wordCount) << endl;
}

void addWordCount(const vector<string>& cards, map<string, int>& wordCount) {
    for (string card : cards) {
        ++wordCount[card];
    }
}

void subWordCount(const vector<string>& cards, map<string, int>& wordCount) {
    for (string card : cards) {
        --wordCount[card];
    }
}

int getMaxValue(const map<string, int>& wordCount) {
    int maxValue = 0;
    for (auto word : wordCount) {
        if (word.second > maxValue) maxValue = word.second;
    }
    return maxValue;
} 

Measured memory_bytes: 3636
s = input()
a=0


for x in range(len(s)):
    if x%2 == 0:
        if s[x]=="R" or s[x]== "U" or s[x]== "D":
            a=a
        else:

            a=a+1
    else:
        if s[x] == "L" or s[x]== "U" or s[x]== "D":
            a=a
        else:
            a=a+1

if a==0 :
    print("Yes")

else:
    print("No")

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    string S;
    cin >> S;
    cout << S.substr(0, 3) << endl;
    return 0;
}



Measured memory_bytes: 3592
#include <stdio.h>

int main(void){
    int n,m;
    int score[101];
    int tgtID[101];
    int tmp,bonus;
    
    scanf("%d",&n);
    scanf("%d",&m);
    for (int i=1; i<=n; i++) score[i]=0;
    for (int i=1; i<=m; i++) scanf("%d", &tgtID[i]);
    
    for (int i=1; i<=m; i++){
        bonus=0;
        for (int j=1; j<=n; j++){
            scanf("%d", &tmp);
            if (tmp == tgtID[i]) score[j]++;
            else bonus++;
        }
        score[tgtID[i]]+=bonus;
    }
    
    for (int i=1; i<=n; i++) printf("%d\n", score[i]);
    
       
    return 0;
}

Measured memory_bytes: 1024
from collections import Counter
from functools import reduce
import fractions
import math
import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # greatest common divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # least common multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))


li = LI()
k = II()
ans = []

def calc(a, b, c, count):

    if count == k:
        val = a+b+c
        ans.append(val)
        count -= 1
        return

    count += 1
    calc(a*2, b, c, count)
    calc(a, b*2, c, count)
    calc(a, b, c*2, count)


calc(li[0], li[1], li[2], 0)
print(max(ans))
# 変だな


Measured memory_bytes: 7740
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

k = int(input())
a,b = map(int,input().split())
for i in range(a,b+1):
    if i%k == 0:
        print("OK")
        sys.exit()
print("NG")

Measured memory_bytes: 9416
#include <iostream>
#include <set>
#include <functional>
#include <cstdio>
using namespace std;

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

struct Team {
  char name;
  int win,lose,id;
  Team(int i):win(0),lose(0),id(i){}
  bool operator>(const Team& a) const {
    if (win == a.win && lose == a.lose) return id < a.id;
    if (win != a.win) return win > a.win;
    return lose < a.lose;
  }
};

int n;

void solve() {
  set<Team, greater<Team> > teams;
  rep(i,n) {
    Team team(i);
    cin>>team.name;
    rep(j,n-1) {
      int t; cin>>t;
      if (t == 0) team.win++;
      else if (t == 1) team.lose++;
    }
    teams.insert(team);
  }
  
  set<Team>::iterator it = teams.begin();
  while (it != teams.end()) {
    cout<<it->name<<endl;
    it++;
  }
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define vec(x) vector<x>
ll gcd(ll a,ll b){while(b){ll tmp = a % b;a = b;b = tmp;}return a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) for(auto i : x) cout << i << " "; cout << endl;
#define outln(x) for(auto i : x) cout << i << " " << endl;
#define vec_cpy(to,from) copy(all(to),back_inserter(from))
#define ary_cpy(to,from) memcpy(to, from, sizeof from)
#define mod = 1000000007; 
#ifdef DEBUG
#define debug_echo(e) cout << "l" << __LINE__ << ": " << e << endl
#define debug_var(e) cout << "l" << __LINE__ << ": " << #e << " = " << e << endl
#else
#define debug_echo(e)
#define debug_var(e)
#endif

#define M 1000000007
string t;
string b;


int main() {
  cin >> t;
  cin >> b;

  vector<ll> dp(b.size()+1);
  dp[0] = 1LL;
  
  rep(i, t.size()) {
    vector<ll> P = dp;
    rep(j, b.size()) {
      if (b[j] == t[i]) {
        dp[j+1] += P[j];
        dp[j+1] %= M;
      }
    }
  }
  cout << dp[b.size()] << endl;
}

Measured memory_bytes: 3204
import java.util.Scanner;
class Main {
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		while(true){ 
		int H = scanner.nextInt();
		int W = scanner.nextInt();
		
		if ( H == 0 && W == 0 ){
			break;
			}
			else{
				int smallh;
				int smallw;
				
				for( smallh = 0; smallh < H; smallh++  ) {
					
					for( smallw = 0; smallw < W; smallw++ ) {
						if(smallh % 2 == 0 ){
							if(smallw % 2 == 0){
							System.out.print("#");
							}
							else{
							System.out.print(".");	
							}
						}
						else{
							if(smallw % 2 == 0){
							System.out.print(".");
							}
							else{
							System.out.print("#");
							}
						}
				
						/*if(smallh % 2 == 1 && smallw % 2 == 0){
						System.out.print(".");
						}else{
							System.out.print("#");		
						}
						*/					
				 }
				 System.out.println();
			}	
		}
		System.out.println();
		}
	}
}

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

int main(){
    char s[2];
    cin >> s;
    
        if(s[0]=='A')
        cout << 'T' << endl;
        if(s[0]=='T')
        cout << 'A' << endl;
        if(s[0]=='C')
        cout << 'G' << endl;
        if(s[0]=='G')
        cout << 'C' << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    private static void solve(Scanner in) {
        int N = in.nextInt();
        int x = in.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = in.nextInt();
        }
        // b[k(magic)][i]
        long[][] b = new long[N][N];
        long ans = 0;

        // no magic
        for (int i = 0; i < N; i++) {
            b[0][i] = a[i];
            ans += b[0][i];
        }

        for (int k = 1; k < N; k++) {
            long sumb = 0;
            for (int i = 0; i < N; i++) {
                b[k][i] = Math.min(b[k - 1][i == 0 ? N - 1 : i - 1], a[i]);
                sumb += b[k][i];
            }
            ans = Math.min(ans, (long) k * x + sumb);
        }
        System.out.println(ans);
    }
}

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

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  
  if(b-a<=0){ //賞味期限過ぎていない
    cout << "delicious" << endl;
  }else{ //賞味期限切れ
    if(x>=(b-a)) cout << "safe" << endl;
    if(x<(b-a)) cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
mt19937 rnd(1337);
#define rall(x) (x).rbegin(), (x).rend()
#define all(x) (x).begin(), (x).end()
#define pNN pair <Node *, Node *>
#define SZ(x) (int)(x).size()
#define pii pair <int, int>
#define pb push_back
#define rev reverse
#define ins insert
#define ers erase
#define S second
#define F first
#define int ll
const int N = 1e5 + 10, INF = 1e9 + 10;

void solve() {
	int n, m;
	cin >> n >> m;
	vector <int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int sum = 0;
	for (auto x : a) {
		sum += x;
	}
	sort(rall(a));
	for (int i = 0; i < m; ++i) {
		if (a[i] < ((sum + m * 4 - 1) / (m * 4))) {
			cout << "No";
			exit(0);
		}
	}
	cout << "Yes";
}
 
signed main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(12);
    #ifdef Solenoid555
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1;
    //cin >> t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[203];
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=2*n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+1+n+n);
	for(int i=1;i<=2*n;i+=2)
	{
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}

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

#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl

typedef long long ll;

using namespace std;

void solve() {
    double a, b, x;
    cin >> a >> b >> x;

    double PI = acos(-1);

    double half = a * a * b / 2.0;
    if (x > half) {
        double out = 2.0 * (a*a*b - x) / (a*a*a);
        double ans = 180.0 * atan(out) / PI;
        cout << fixed << setprecision(10) << ans << endl;
    } else {
        double out = a*b*b / (2.0 * x);
        double ans = 180.0 * atan(out) / PI;
        cout << fixed << setprecision(10) << ans << endl;
    }
}

signed main() {
    solve();
}


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

int main(){
    int N; cin >> N;
    vector <int> P(N);
    rep(i,N) cin >> P[i];
    
    ll ans=1;
    ll min=P[0];
    rep(i,N-1){
        if (min>=P[i+1]){
            ans++;
            min=P[i+1];
        }
    }
    cout << ans ;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
#define int long long
signed main(){
  int N;
  cin >> N;
  unordered_map<string,int> min;
  int A[200020];
  for(int i = 1;i <= N;i++){
    cin >> A[i];
    min[to_string(i - A[i])] = 0;
  }
  for(int i = 1;i <= N;i++){
    min[to_string(i - A[i])]++;
  }
  int ans = 0;
  for(int i = 1;i <= N;i++){
    ans += min[to_string(A[i] + i)];
  }
  cout << ans;
}


Measured memory_bytes: 31476
import java.util.PriorityQueue;
import java.util.Scanner;

//Authentication Level
public class Main{

	class E implements Comparable<E>{
		int k, i, j;
		public E(int k, int i, int j) {
			this.k = k;
			this.i = i;
			this.j = j;
		}
		public int compareTo(E o) {
			return k-o.k;
		}
	}
	
	int[][] d = {{-1,0},{0,1},{1,0},{0,-1}};
	int[] f(int h, int w, int[][] a, int si, int sj){
		int[] r = new int[w*h+1];
		boolean[][] mark = new boolean[h][w], u = new boolean[h][w];
		int id = 1, L = -1;
		mark[si][sj] = true;
		PriorityQueue<E> q = new PriorityQueue<E>();
		q.add(new E(a[si][sj], si, sj));
		while(!q.isEmpty()){
			E e = q.poll();
			if(L<e.k)L = e.k;
			u[e.i][e.j] = true;
			r[id++] = L;
			for(int k=0;k<4;k++){
				int ni = e.i+d[k][0], nj = e.j+d[k][1];
				if(0<=ni&&ni<h&&0<=nj&&nj<w&&!mark[ni][nj]){
					mark[ni][nj] = true;
					q.add(new E(a[ni][nj], ni, nj));
				}
			}
		}
		return r;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int R = sc.nextInt();
			if(R==0)break;
			int[][] a = new int[2][];
			for(int k=0;k<2;k++){
				int w = sc.nextInt(), h = sc.nextInt(), sj = sc.nextInt()-1, si = sc.nextInt()-1;
				int[][] m = new int[h][w];
				for(int i=0;i<h;i++)for(int j=0;j<w;j++)m[i][j]=sc.nextInt();
				a[k] = f(h, w, m, si, sj);
			}
			int res = 1<<29;
			for(int r=0;r<=Math.min(R, a[0].length-1);r++){
				if(a[1].length<=R-r)continue;
				res = Math.min(res, a[0][r]+a[1][R-r]);
			}
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#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 <ctime>
#include <cstring>

using namespace std;

typedef long long ll;

void go() {
	int n;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	reverse(a.begin(),a.end());
	ll x,y;
	x = y = 2;
	for(ll i : a) {
		ll u,v;
		u = (x+i-1)/i;
		v = y/i;
		if(u*i>y || v*i+i-1<x) {
			cout << -1 << endl;
			return;
		}
		x = u*i;
		y = v*i+i-1;
	}
	cout << x << " " << y << endl;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	// int t; cin >> t; for(;t--;)
	go();
	return 0;
}



Measured memory_bytes: 1024
import java.io.*;

public class Main{
  public static void main(String[] args){
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String a;
    try{
      a = reader.readLine();
      char[] c = a.toCharArray();
      //System.out.printf("%s\n", a);
      for(char cs: c){
        //System.out.printf("%c\n", cs);
        if(Character.isLowerCase(cs)) System.out.printf("%c", Character.toUpperCase(cs));
        else if(Character.isUpperCase(cs)) System.out.printf("%c", Character.toLowerCase(cs));
        else System.out.printf("%c", cs);
      }
      System.out.printf("\n");
    }
    catch(IOException e) {
      //例外処理 たとえば数字以外のものが入力された時など
      System.out.println(e);
    }
  }
}


Measured memory_bytes: 28004
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    string s;
    cin >> s;
    int sum = 0;
    for (int i = 0; i < (int) s.size(); i++){
        sum += (s[i] - '0');
    }
    if (sum % 9) cout << "No\n";
    else cout << "Yes\n";
}

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

    //int t; cin >> t; while (t--)
        solve();
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int64_t ans=0;
	for(int i=0,j,k,p;i<(1<<s.size()-1);++i){
		for(j=0,k=0,p=1;j<(s.size()-1);++j){
			if(i&(1<<j)){
				ans+=stol(s.substr(k,p));
				k=j+1;
				p=0;
			}
			++p;
		}
		ans+=stol(s.substr(k,p));
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define DESS(X) cout <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 10007;
const ll INF = 20000000000;
typedef std::pair<ll,ll> P;


	ll ans=0;
	ll N,M,K,X;
	ll A,B,as,bs;
	// ll L[200010],R[200010];
	ll deff[200010];
	string S,T;
	ll id=0;
	ll sum;bool F=true;
	P Q[100010];
int main(){
	ios_base::sync_with_stdio(false);
	cin>>N>>M;
	REP(i,N){
		ll a,b;
		cin>>a>>b;
		Q[i]={a,b};
	}
	sort(Q,Q+N);
	ll count=0;
	REP(i,N){
		if(count+Q[i].second>=M){
			ans+=(M-count)*Q[i].first;
			break;
		}else{
			count+=Q[i].second;
			ans+=Q[i].second*Q[i].first;

		}
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Split(bufio.ScanWords)
	var A, B, M int

	A = nextInt()
	B = nextInt()
	M = nextInt()

	a := make([]int, A)
	b := make([]int, B)
	x := make([]int, M)
	y := make([]int, M)
	c := make([]int, M)
	coup := make([]int, M)

	for i := 0; i < A; i++ {
		a[i] = nextInt()
	}
	for i := 0; i < B; i++ {
		b[i] = nextInt()
	}
	for i := 0; i < M; i++ {
		x[i] = nextInt()
		y[i] = nextInt()
		c[i] = nextInt()
		coup[i] = a[x[i]-1] + b[y[i]-1] - c[i]
	}

	sort.Ints(coup)
	sort.Ints(a)
	sort.Ints(b)
	// fmt.Println(coup)
	// fmt.Println(a)
	// fmt.Println(b)

	if a[0]+b[0] < coup[0] {
		fmt.Println(a[0] + b[0])
	} else {
		fmt.Println(coup[0])
	}
}

func nextInt() int {
	stdin.Scan()
	i, err := strconv.Atoi(stdin.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextStr() string {
	stdin.Scan()
	i := stdin.Text()
	// if err != nil {
	// 	panic(err)
	// }
	return i
}


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

    while(scanf("%d%d",&A,&B)==2)
    {
        if(A>=1&&A<=9&&B>=1&&B<=9)
            printf("%d",A*B);
        else
            printf("-1");

    }



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void read(i64 &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int N=1010,mod= 1e9 + 7;
inline int powmod(int a,i64 b){
	int res=1;
	for(;b;b>>=1){
		if(b&1)res=1ll*res*a%mod;
		a=1ll*a*a%mod;
	}return res;
}
int n,m,black,lr,ud;
i64 K;
char s[N][N];

int main(){
	read(n);read(m);read(K);
    rep(i,0,n-1) scanf("%s",s[i]);
    rep(i,0,n-1) rep(j,0,m-1) black += s[i][j] == '#';
    rep(i,0,n-1) lr += s[i][0] == '#' && s[i][m-1] == '#';
    rep(i,0,m-1) ud += s[0][i] == '#' && s[n-1][i] == '#';
    K--;
    if(K<=0||(lr*ud>0)) printf("%d\n",1);
    else {
        int out = lr+ud , in = 0;
        if(lr) rep(i,0,n-1) rep(j,1,m-1) in += s[i][j] == '#' && s[i][j-1] == '#';
        else if(ud) rep(i,1,n-1) rep(j,0,m-1) in += s[i-1][j] == '#' && s[i][j] == '#';
        int ans = powmod(black,K) , del = ((powmod(black,K) - powmod(out,K))%mod+mod)%mod;
        del = 1ll*del*powmod(black-out,mod-2)%mod*in%mod;
        ans -= del;if(ans < 0) ans += mod;
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
 using namespace std;
 int m=1000000007,n,x,y,z;
 unsigned long long f[41][131075],ne[131075][11],i,j,k;
 int main()
{
	scanf("%d%d%d%d",&n,&x,&y,&z);
	y+=x; z+=y;
	for(i=1;i<=1<<z;i++)
	 for(j=1;j<=10;j++)
	  {
		ne[i][j]=1;
		for(k=0;k+j<=z;k++)if(i&(1<<k))
		 if(!(k<x&&k+j>x)&&!(k<y&&k+j>y))ne[i][j]|=1<<(j+k);
		if((i==(1<<z))||ne[i][j]>=1<<z)ne[i][j]=1<<z;
	  }
	f[0][1]=1;
	for(i=1;i<=n;i++)
	 for(j=1;j<=1<<z;j++)
	  for(k=1;k<=10;k++)
	   f[i][ne[j][k]]=(f[i][ne[j][k]]+f[i-1][j])%m;
	cout<<f[n][1<<z];
	return 0;
}

Measured memory_bytes: 53504
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)

main :: IO ()
main = do
    n <- readLn
    ab <- sortOn snd <$> replicateM n rp
    putStrLn $ solve 0 ab

solve :: Int -> [(Int,Int)] -> String
solve ac []         = "Yes"
solve ac ((a,b):xs) = if a+ac <= b then solve (a+ac) xs else "No"



Measured memory_bytes: 77180
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
	#define int long long
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int l = c*d/(__gcd(c,d));
	int ans = (b-((b/d)+(b/c)-b/l))-((a-1)-(((a-1)/c)+((a-1)/d)-((a-1)/l)));
	cout << ans << "\n";
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	long long n; cin >> n;
	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}
	long long prv = n;
	long long ans = 0;
	for (long long x = 1; x * x <= n; x++) {
		long long start = prv, end = n / (x + 1) + 1;
		prv = min(end, start) - 1;
		if (start < end) continue;
//		cout << start << " " << end << endl;
		swap(start, end);
		--start; ++end;
		while (end - start > 1) {
			long long mid = (end + start) >> 1;
			if (n % mid < x) end = mid;
			else start = mid;
		}
		if (n % start == x) ans += start;
//		cout << n << " " << x << " " << start << " " << n / start << " " << n % start << endl;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_m

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 100;
const int K_MAX = 1e5;
const int MOD = 1e9+7;

int N, K;
int a[N_MAX];

int dp0[K_MAX + 1];
int dp1[K_MAX + 1];
int acc[K_MAX + 2];

void solve() {
  auto cur = dp0;
  auto nxt = dp1;
  cur[0] = 1;
  REP(i, N) {
    fill(acc, acc + K + 2, 0);
    FOR(j, 0, K) acc[j + 1] = (acc[j] + cur[j]) % MOD;
    fill(nxt, nxt + K + 1, 0);
    FOR(j, 0, K) {
      nxt[j] = (MOD + acc[j + 1] - acc[max(j - a[i], 0)]) % MOD;
    }
    swap(cur, nxt);
  }
  printf("%d\n", cur[K]);
}

void input() {
  scanf("%d%d", &N, &K);
  REP(i, N) scanf("%d", a + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;


void solve(long long X){
    long long tmp=100;
    long long count=0;
    while (true)
    {   
        count++;
        tmp=tmp*1.01;
        //cout<<tmp<<endl;
        if(tmp>=X){
            cout<<count<<endl;
            return;
        }
    }
    
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


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

int main() {

  long long int a, b;
  cin >> a >> b;

  if ( a == 1 ) a += 13;
  if ( b == 1 ) b += 13;

  if ( a < b ) {
    cout << "Bob" << endl;
  }else if ( a > b ) {
    cout << "Alice" << endl;
  }else {
    cout << "Draw" << endl;
  }

  return 0;

}


Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS


#include <stdio.h>
#include <cstdio>
#include <string>
#include <math.h>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

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

std::vector<int> Data;




int main()
{
	int X, Y, Z;

	scanf("%d%d%d", &X, &Y, &Z);

	X -= Z;

	printf("%d\n", X / (Y + Z));
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
N=int(input())
S=[input() for _ in range(N)]
M=int(input())

for _ in range(M):
    try:
        S.remove(input())
    except:
        pass

if S==[]:
    print(0)
else:
    S_=Counter(S)
    print(S_.most_common()[0][1])


Measured memory_bytes: 3444
#include<stdio.h>
int max(int i, int j) {
    return i > j ? i : j;
}
int max_3(int i, int j, int k) {
    return max(max(i, j), k);
}
int main() {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    printf("%d\n", a + b + c + max_3(a, b, c) * 9);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>

using namespace std;

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  bool bb = true;
  if (abs(a - c) <= d)
  {
    bb = true;
  }
  else
  {
    if (abs(a - b) > d) bb = false;
    if (abs(b - c) > d) bb = false;
  }
  if (bb) cout << "Yes" << endl;
  else    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
// Binary Indexed Tree (Fenwick Tree)
template <typename T>
struct BITsum {
    ll n, s = 0;
    vector<T> d;
    BITsum(ll n = 0) : n(n), d(n + 1) {}
    void add(ll i, T x = 1) {
        for (i++; i <= n; i += i & -i) {
            d[i] += x;
            d[i] %= MOD;
        }
        s = (s + x) % MOD;
    }
    T sum(ll i) {
        T x = 0;
        for (; i; i -= i & -i) {
            x += d[i];
        }
        x %= MOD;
        return (s - x + MOD) % MOD;
    }
};
// Binary Indexed Tree (Fenwick Tree)
template <typename T>
struct BITmax {
    ll n;
    vector<T> d;
    BITmax(ll n = 0) : n(n), d(n + 1) {}
    void add(ll i, T x = 1) {
        for (i++; i <= n; i += i & -i) {
            chmax(d[i], x);
        }
    }
    T sum(ll i) {
        T x = 0;
        for (i++; i; i -= i & -i) {
            chmax(x, d[i]);
        }
        return x;
    }
};

int main() {
    init();
    ll N;
    cin >> N;
    vc<pair<ll, ll>> D(N);
    rep(i, N) cin >> D[i].first >> D[i].second;
    sort(all(D));

    vl X(N);
    rep(i, N) X[i] = D[i].first;

    vc<ll> dp(N);
    BITsum<ll> bt(N + 1);
    BITmax<ll> btm(N + 1);
    bt.add(N, 1);
    rep(i,N+1)btm.add(i,i);
    // i番目を起動したときにありうる状態数を右から考える
    repr(i,N){
        ll li = lower_bound(all(X), D[i].first + D[i].second) - X.begin();
        ll max_r = btm.sum(li - 1);
        dp[i] = bt.sum(max_r+1);
        bt.add(i, dp[i]);
        btm.add(i, max_r);
    }

    ll ans = bt.s;
    cout << ans << endl;
}

Measured memory_bytes: 9600
x = int(input())
ans = 0

a = (10**x)%1000000007
b = (9**x)%1000000007
c = (8**x)%1000000007

d = ((a-b)*2)%1000000007
e = (a-c)%1000000007
ans = (d-e)%1000000007
print(ans)

Measured memory_bytes: 10728
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heappop,heappush

t = int(readline())
q = list(map(int,read().split()))

now = 0
ans = [0] * t
for cyc in range(t):
    n = q[now]
    klr = q[now+1: now+1+3*n]
    now = now+1+3*n

    it = iter(klr)
    lc = []
    rc = []
    min_p = 0
    for x,y,z in zip(it,it,it):
        if(y==z):
            min_p += y
        elif(y>z):
            min_p += z
            lc.append((x,y-z))
        else:
            min_p += y
            rc.append((n-x,z-y))

    res = min_p
    lc.sort()
    rc.sort()

    for cam in [lc,rc]:
        hq = []
        for i in range(n,0,-1):
            if(len(cam)>0):
                while(cam[-1][0] == i):
                    x,p = cam.pop()
                    heappush(hq,p*-1)
                    if(len(cam)==0):
                        break
            if(hq):
                res += heappop(hq)*-1

    ans[cyc] = res

print('\n'.join(map(str,ans)))

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main()
{
    int n;
    string N;
    cin >> n;

    
    N = to_string(n);
    int sum = 0;
    for(int i = 0; i < N.length(); i++)
    {
        sum += ctoi(N[i]);
    }
    
    if(n%sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>


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

  int v,e;
  cin>>v>>e;
  int es[20][20]={};
  rep(i,20){
    rep(j,20){
      if(i==j) continue;
      es[i][j]=inf;
    }
  }

  rep(i,e){
    int s,t,d;
    cin>>s>>t>>d;
    es[s][t]=d;
  }

  int dp[1<<v][v];
  rep(i,1<<v){
    rep(j,v){
      dp[i][j]=inf;
    }
  }
  dp[0][0]=0;

  rep(i,1<<v){
    rep(j,v){
      if(i&(1<<j)) continue;
      rep(k,v){
        if(j==k) continue;
        dp[i|(1<<j)][j]=min(dp[i|(1<<j)][j],dp[i][k]+es[k][j]);
      }
    }
  }


  cout<<(dp[(1<<v)-1][0]==inf?-1:dp[(1<<v)-1][0])<<endl;


}


Measured memory_bytes: 7024
#define rep(v, s, e) for(int v=(s);v<(e);v++)
#define res(v, s, e) for(int v=(s);(e)<=v;v--)
#include <algorithm>
#include <array>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
using Line = array<char, 5>;
using Puzzle = vector<Line>;

void newline() {cout << endl;}
template <typename T>
void put(T input){cout << input;}
template <typename T>
void putl(T input){put(input); newline();}

int n;
int point;
Puzzle puzzle;

void swap_rec(int column, int row){
  if(0<column){
    swap(puzzle[column][row], puzzle[column-1][row]);
    swap_rec(column-1, row);
  }
}

void drop(){
  Puzzle prev_puzzle = puzzle;
  res(column, puzzle.size()-1, 0)
    res(row, puzzle[column].size()-1, 0)
      if(puzzle[column][row] == '#'){
        swap_rec(column, row);break;break;}
  if(puzzle != prev_puzzle) drop();
}

int clear(Line &line, int n, char c){
  if(line[n] == c){
    line[n]='#';
    if(1 <= n && n < line.size()-1){
      return int(c)-int('0')+clear(line, n+1, c)+clear(line, n-1, c);
    }else{
      return int(c)-int('0');
    }
  }
  return 0; 
}


int solve(){
  Puzzle prev_puzzle = puzzle;
  for(Line &line: puzzle)
    rep(k, 1, line.size()-1)
      if(line[k] != '#' && line[k-1] == line[k] && line[k] == line[k+1])
        point+=clear(line, k, line[k]);
  drop();
  if(prev_puzzle != puzzle) solve();
  return point;
}

int main() {
  while(cin>>n && n){
    point=0; puzzle={}; puzzle.reserve(n);
    rep(ic, 0, n){
      Line line;
      rep(lc, 0, line.size()){
        char s; cin >> s; line[lc]=s;
      }
      puzzle.push_back(line);
    }
    putl(solve());
  }
}

Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std ;
using ll = long long ;

int main(){
    int n ; cin >> n ;
    ll g,h ;
    vector<ll> x(n),y(n),z(n) ;
    for(int i=0;i<n;i++) cin >> x.at(i) >> y.at(i) >> z.at(i) ;
    for(ll i=0;i<=100;i++){
        for(ll j=0;j<=100;j++){
            bool ok = true ;
            h = -1 ;
            g = 1000000100 ;
            for(int k=0;k<n;k++){
                ll X = max(i,x.at(k))-min(i,x.at(k)) ;
                ll Y = max(j,y.at(k))-min(j,y.at(k)) ;
                if(z.at(k)==0){
                    g = min(g,X+Y) ;
                }else{
                    ll H = X+Y+z.at(k) ;
                    if(h==-1) h = H ;
                    else if(h!=H){
                        ok = false ;
                        break ;
                    }else if(h>g){
                        ok = false ;
                        break ;
                    }
                }
            }
            if(ok){
                bool okok =true ;
                for(int k=0;k<n;k++){
                    ll X = max(i,x.at(k))-min(i,x.at(k)) ;
                    ll Y = max(j,y.at(k))-min(j,y.at(k)) ;
                    if(z.at(k)!=max(h-X-Y,(ll)0)){
                        okok = false ;
                        break ;
                    }
                }
                if(!okok) continue ;
                cout << i << " " << j << " " << h << endl ;
                return 0 ;
            }
        }
    }
}


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

namespace _0306
{
    class Program
    {
        static string[] chars = new string[] { "-", "0", "+" };

        static void Main(string[] args)
        {
            Console.WriteLine(WAr(Print(RInt()).Reverse(),""));
        }

        private static IEnumerable<string> Print(int w)
        {
            while (w > 0)
            {
                yield return chars[(w + 1) % 3];
                w = (w + 1) / 3;
            }            
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 18320
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
using namespace std;

#define max_n 50
#define max_m 50
#define max_w 1000
#define max_h 1000
#define max_k 5000
#define max_l 10000
#define INF 9999999

typedef long long lint;

int main()
{
    int n,m;
    cin>>n>>m;
    int road[max_m][2];
    int ans[max_n]={0};
    
    for(int i=0;i<m;i++){
        cin>>road[i][0]>>road[i][1];
        for(int j=1;j<=n;j++){
            if(road[i][0]==j){
                ans[j-1]++;
            }
            if(road[i][1]==j){
                ans[j-1]++;
            }
        }
    }
    for(int i=0;i<n;i++) printf("%d\n",ans[i]);
    
    return 0;
    
}

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

int main(){
    int ans=0,n,k,MIN=1000000001;
    cin >>n>>k;
    int data[n];
    for (int i = 0; i < n; i++){
        cin >> data[i];
    }
    sort(data,data+n,greater<int>());

    for (int i = 0; i <= n-k; i++){
        MIN =min(MIN,data[i]-data[k+i-1]);
    }
    
    cout << MIN <<endl;
    return 0;
}


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

int main() {
    int n, k; cin >> n >> k;

    double ans=0;
    for(int i=1; i<=n; i++){
        ll a=i;
        ll cnt=0;
        while(k>a){
            cnt++;
            a *= 2;
        }

        ans += 1/pow(2,cnt)/(double)n;
    }

cout << fixed << setprecision(13) << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 Q, H, S, D, N;
  std::cin >> Q >> H >> S >> D >> N;

  const i64 optimum_H = std::min(2 * Q, H);
  const i64 optimum_S = std::min(2 * optimum_H, S);
  const i64 optimum_D = std::min(2 * optimum_S, D);

  std::cout << (N / 2) * optimum_D + (N % 2) * optimum_S << std::endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			int n = Integer.parseInt(input.readLine());
			
			String[] line = input.readLine().split(" ");
			int min = Integer.MAX_VALUE;
			int max = Integer.MIN_VALUE;
			long sum = 0;
			for (int i = 0; i < n; i++) {
				int a = Integer.parseInt(line[i]);
				if (a < min) min = a;
				if (max < a) max = a;
				sum += a;
			}
			String answer = String.valueOf(min) + " " + String.valueOf(max) + " " + String.valueOf(sum);
			System.out.println(answer);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 25572
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  vector<ll> ans;
  ans.push_back(a * c);
  ans.push_back(a * d);
  ans.push_back(b * c);
  ans.push_back(b * d);

  cout << *max_element(ans.begin(), ans.end()) << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int a[7] = { 1,3,5,7,8,10,12 }, b[4] = { 4,6,9,11 }, x, y;
	cin >> x >> y;
	for (int i = 0; i < 7; i++) {
		for (int j = 0; j < 7; j++) {
			if (x == a[i] && y == a[j]) {
				cout << "Yes" << endl;
				goto loop1;
			}
			else if (i < 4 && j < 4 && x == b[i] && y == b[j]) {
				cout << "Yes" << endl;
				goto loop1;
			}
		}
	}
	cout << "No" << endl;
loop1:;
	int z;
	cin >> z;
}

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

using namespace std;

#define pt pair<int, int>
#define x first
#define y second
#define what_is(x) cerr << #x << " is " << x << endl;
#define endl '\n'
#define int long long

signed main()
{
	cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);

	int n;
	cin >> n;
	double ans = ((n + 1) / 2 + 0.0) / n;
	cout << fixed << setprecision(20) << ans << endl;

	return 0;
}


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

int main(void) {
    int n;
    cin >> n;
    int a = 0, b = 0, c = 0, d = 0;
    string tmp;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        if (tmp == "AC") {
            a++;
        } else if (tmp == "WA") {
            b++;
        } else if (tmp == "TLE") {
            c++;
        } else if (tmp == "RE") {
            d++;
        }
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cctype>
#include <stdio.h>
using namespace std;

int main(){
	char sentence;

	while(true){
		scanf("%c", &sentence);
		if(islower(sentence)){
			sentence = toupper(sentence);
		}else if(isupper(sentence)){
			sentence = tolower(sentence);
		}else{
			sentence = sentence;
		}

		cout << sentence;

		if(sentence == '\n') break;
	}
	return 0;
}

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

int main(){
    long long N,M;
    cin >> N >> M;
    long long x,y;
    double A,r,rans;
    long long ans;

    x=1900;
    y=100;
    A=(double) (M*x+(N-M)*y);
    A= A / pow(2,M);
    r= 1-1/pow(2,M);

    rans=A/( (1-r)*(1-r) );
    ans=(long long) rans;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512