akhauriyash/Code-Regression huggingface dataset:
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

char bufr[2000007];
int bufrl;

#define getchar_unlocked() bufr[bufrl++]

int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }

int main(void){
	read(STDIN_FILENO, bufr, sizeof(bufr));
	int n=nextint();
	long ans=1;
	bool f=false;
	for(int i=0; i<n; i++){
		long a=nextlong();
		if(a==0){
			f=false;
			ans=0;
			break;
		}
		if(!f){
			if(__builtin_smull_overflow(ans, a, &ans) || ans>1000000000000000000L){
				f=true;
			}
		}
	}
	printf("%ld\n", f?-1:ans);
}


Measured memory_bytes: 3388
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str;
        str = scan.nextLine();
        StringBuilder sb = new StringBuilder();
        for (int i=0; i<str.length(); i++) {
            char c = str.charAt(i);
            if (Character.isUpperCase(c)) {
                c += 32;
                sb.append(c);
            }
            else if(Character.isLowerCase(c)){
                c -= 32;
                sb.append(c);
            }else{
                sb.append(c);
            }
        }
        System.out.println(sb.toString());
        scan.close();
    }

}



Measured memory_bytes: 26192
class UnionFind:
  def __init__(self, size):
    self.table = [-1 for _ in xrange(size)]

  def find(self, x):
    while self.table[x] >= 0: x = self.table[x]
    return x

  def union(self, x, y):
    s1 = self.find(x)
    s2 = self.find(y)
    if s1 != s2:
      if self.table[s1] >= self.table[s2]:
        self.table[s1] += self.table[s2]
        self.table[s2] = s1
      else:
        self.table[s2] += self.table[s1]
        self.table[s1] = s2
      return True
    return False

def hash(n, s, g):
  return n*s+g

def dehash(n, hs):
  return [(hs-hs%n)/n, hs%n]

def kruskal(n, path):
  path = sorted(path.items(), key=lambda x:x[1])
  selected = {}
  union = UnionFind(n)
  for i in xrange(len(path)):
    k,v = path[i]
    s,g = dehash(n, k)
    if union.union(s, g):
      selected[k] = v
  return selected

# main
while True:
  n,m = map(int, raw_input().split())
  if n==m==0:
    break
  path = {}
  for _ in xrange(m):
    a,b,c = map(int, raw_input().split())
    path[hash(n, a, b)] = c
  result = kruskal(n, path)
  sumcost = 0
  for v in result.values():
    sumcost += v
  print sumcost

Measured memory_bytes: 6524
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
string s;
cin>>s;
if(s=="SAT"){
    cout<<1<<endl;
}
if(s=="FRI"){
    cout<<2<<endl;
}
if(s=="THU"){
    cout<<3<<endl;
}
if(s=="WED"){
    cout<<4<<endl;
}
if(s=="TUE"){
    cout<<5<<endl;
}
if(s=="MON"){
    cout<<6<<endl;
}
if(s=="SUN"){
    cout<<7<<endl;
}
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int L, R, d;
  cin >> L >> R >> d;

  int ret = 0;
  REP(i,L,R+1){
    if(i>=d && i%d==0) ret++;
  }
  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 3588
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int> > Matrix;


int main(){
  int a, b, k;
  cin >> a >> b >> k;
  vector<bool> d(b+1);
  for (int i = a; i < a+k; i++) if(i < b+1) d[i] = true;
  for (int i = b-k+1; i <= b; i++) if (i >= a) d[i] = true;

  rep(i, b+1) if(d[i]) cout << i << endl;
}

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

#define COUT(x) cout << #x << " = " << (x) << ", "
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
typedef long long ll;
const int MOD = 1000000007;

int main(){
  int N,C;
  cin >> N >> C;
  int D[C][C];
  for(int i = 0; i < C; i++){
    for(int j = 0; j < C; j++){
      cin >> D[i][j];
    }
  }
  int c[N][N];
  vector<vector<int>> cost(3, vector<int>(C, 0));
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      cin >> c[i][j];
      c[i][j]--;
      for(int k = 0; k < C; k++){
	cost[(i + j + 2) % 3][k] += D[c[i][j]][k];
      }
    }
  }
  int res = MOD;
  for(int i = 0; i < C; i++){
    for(int j = 0; j < C; j++){
      for(int k = 0; k < C; k++){
	if(i == j || i == k || j == k) continue;
	int tmp = cost[0][i] + cost[1][j] + cost[2][k];
	if(tmp < res) res = tmp;
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main()
{
	int l[100001],r[100001],n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>l[i]>>r[i];
		ans+=r[i]-l[i]+1;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(); // #join
    int R = sc.nextInt(); // #disp rating

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


Measured memory_bytes: 23348
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n, sum = 0;

    cin >> n;

    int arr[n];

    for (int i = 0; i < n; i++) {

        cin >> arr[i];
    }

    for (int i = 0; i < n; i++) {

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

            sum += arr[i]*arr[j];
        }
    }

    cout << sum;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;

    int a[M], b[M];
    for(int i=0; i<M; i++) cin >> a[i] >> b[i];

    int values[N];
    for(int i=0; i<N; i++) values[i] = 0;
      
    for(int i=0; i<M; i++){
      for(int j=0; j<N; j++){
        if(a[i] == j+1) values[j]++;
        else if(b[i] == j+1) values[j]++;
      }
    }

    for(int i=0; i<N; i++) cout << values[i] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Gacha | diff Gacha.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Gacha.cpp && ./a.out

/*
 
 4/26/2020
 
 5:06-
 
 */

const int MAX_N=1e6+1;
string S[MAX_N];
int N;

void solve() {
  set<string> ss(S,S+N);
  cout<<SZ(ss)<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>S[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 50540
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9;

int main()
{long long int n,w;
cin>>n>>w;
vector<long long int> dp(w+1);
for(long long int item=0;item<n;item++)
{
   long long  int weight,value;
    cin>>weight>>value;
    for(long long int  already=w-weight;already>=0;already--)
    {dp[already+weight]=max(dp[already+weight],dp[already]+value);


    }



}
long long int answer=0;
for(long long int i=0;i<=w;i++)
{
    answer=max(answer,dp[i]);
}
cout<<answer<<endl;


}


Measured memory_bytes: 4044
package main

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

var score []int
var g [][]int
var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, q := scanInt(), scanInt()
	g = make([][]int, n)
	for i := 0; i < n-1; i++ {
		a, b := scanInt(), scanInt()
		a--
		b--
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	score = make([]int, n)
	for i := 0; i < q; i++ {
		p, x := scanInt(), scanInt()
		p--
		score[p] += x
	}

	dfs(0, -1)

	for _, s := range score {
		fmt.Printf("%d ", s)
	}
}

func dfs(v, p int) {
	for _, nv := range g[v] {
		if nv == p {
			continue
		}
		score[nv] += score[v]

		dfs(nv, v)
	}
}


Measured memory_bytes: 50048
#include <bits/stdc++.h>
typedef long double LD;

int main() {
  LD n, d, x, Ans = 0;
  scanf("%Lf %Lf %Lf", &n, &d, &x);
  while (n) {
    LD Begin = d;
    LD End = d + (n * 2 - 1) * x;
    LD Sum = (Begin + End) * n;
    Ans += Sum / (n * 2);
    d = d + (d * 2 + x * 5) / (n * 2);
    x = x + (x * 2) / n;
    --n;
  }
  printf("%.15Lf\n", Ans);
  return 0;
}

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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int stk[11111];
int tail;

void push(int n){
    stk[tail++]=n;
}
int top(){
    assert(tail);
    return stk[tail-1];
}
void pop(){
    assert(tail);
    tail--;
}

signed main(){
    string s;
    while(cin>>s){
        if(isdigit(s[0])){
            stringstream ss(s);
            int tmp;ss>>tmp;
            push(tmp);
        }
        else{
            int b=top();pop();
            int a=top();pop();
            if(s[0]=='+')a+=b;
            else if(s[0]=='-')a-=b;
            else a*=b;
            push(a);
        }
    }
    cout<<top()<<endl;
    return 0;
}

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

int main() {
    int n; cin >> n;
    int minr, maxr=-1000000000;
    vector<int> r(n);
    for (int i=0; i<n; i++) cin >> r.at(i);
    minr = r.at(0);
    for (int i=1; i<n; i++) {
        maxr = max(maxr, r.at(i) - minr);
        minr = min(minr, r.at(i));
    }
    cout << maxr << endl;
}


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

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
      
print(num2alpha(n).lower())

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

int main(){
    int K, S;
    cin >> K >> S;

    int res = 0;

    for(int x = 0; x <= K; ++x){

        for(int y = 0; y <= K; ++y){
            int z = S - x - y;

            if(0 <= z and z <= K) res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int D,N;
  cin >> D >> N;
  int ans = 0;
  int c = N / 100;
  rep(i,N+c) {
    int x = pow(100,D);
    ans += pow(100,D);
  }
  cout << ans << endl;
  return 0;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amin(T& a,T2 b){ if(a > b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	
	vector<vector<pii>> r(n), r2(n);
	rep(i, m){
		int a, b, c; cin >>a >>b >>c;
		r[a-1].emplace_back(b-1, -c);
		r2[b-1].emplace_back(a-1, c);
	}
	const ll inf = 1LL<<60;
	VI used(n);
	auto f = [&](auto f, int s, int z) ->void{
		auto& rcc = z==1? r: r2;
		if(used[s] & z) return;
		used[s] |= z;
		for(auto v:rcc[s]) f(f, v.first, z);
	};
	
	
	auto bellman = [&](int s){
		vector<ll> ds(n, inf);
		ds[s] =0;
		for(int i =0, nxt =1; i<n+3 && nxt>0 ; i++){
			nxt = 0;
			rep(j, n) for(auto z: r[j]) if(used[z.first]>=3){
				if(ds[j] != inf && ds[z.first] > ds[j] + z.second){
					ds[z.first] = ds[j] + z.second;
					nxt = 1;
				}
			}
			if(i>n ) {ds[s] = inf; return ds;}
		}
		return ds;
	};
	
	f(f, 0, 1); f(f, n-1, 2);
	auto ans = bellman(0);
	if(ans[0] ==inf) puts("inf");
	else cout << -(ans[n-1]) <<"\n";
	return 0;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n,m int
	Fscan(in, &n,&m)
	Fprintln(out, n*m)
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 1828
h, w = map(int, input().split())
field = []
dp = [[0 for _ in range(w)] for _ in range(h)]
dp[0][0] = 1
for _ in range(h):
    field.append(input())
for column in range(1,w):
    dp[0][column] = int(field[0][column] != '#')*dp[0][column-1]
for row in range(1,h):
    dp[row][0] = int(field[row][0] != '#')*dp[row-1][0]
for row in range(1,h):
    for column in range(1,w):
        if field[row][column] == '#':
            dp[row][column] = 0
        else:
            dp[row][column] = (dp[row-1][column] + dp[row][column-1]) % 1000000007
print(dp[h-1][w-1])


Measured memory_bytes: 44628
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  string n;
  cin>>n;
  if(n[0]=='9' || n[1]=='9'){
    cout<<"Yes"<<"\n";
  }
  else{
    cout<<"No"<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3656
#include<math.h>
#include<stdio.h>
typedef unsigned long long ll;

int check(int a,int b,int max){
    float ret;
    if (a>b){
        printf("err");
    }
    ret = a+b-(2.0*max/(b-a+1));
    if(ret>0){
        return 1;
    }
    else if(ret<0){
        return -1;
    }
    else{
        return 0;
    }
}


int main(void){
    ll N=1000000000;
    ll b=0;
    int f=0;
    int check_ret=0;
    while(1){
        scanf("%lld",&b);
        if(b==0){
            break;
        }
        else{
            f=0;
            ll max_wid = (ll)(sqrt(b*2))+2;
            ll low,high,mid;
            for(ll wid=max_wid;wid>=1;wid--){
                low=1;
                high=N;
                while(low<=high){
                    mid =(ll)((low+high)/2);
                    check_ret = check(mid,mid+wid,b);
                    if (check_ret>0){
                        high = mid-1;
                    }
                    else if(check_ret<0){
                        low = mid+1;
                    }
                    else{
                        printf("%lld %lld\n",mid,wid+1);
                        f=1;
                        break;
                    }
                }
                if(f==1){
                    break;
                }
            }
            if(f==0){
                printf("%lld %d\n",b,1);
            }
        }
    }
    return 0;
}



Measured memory_bytes: 2032
n,m = map(int,input().split())
a = [0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
sortsecond = lambda val : val[0]
a.sort(key=sortsecond)
count = 0
for i in range(n):
    if a[i][1] <= m:
        count += a[i][1]*a[i][0]
        m -= a[i][1]
    else:
        count += m*a[i][0]
        break
print(count)

Measured memory_bytes: 29024
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 507 * 507;
int n, sz;
int ans[N];
struct data {
	int p, id;
	bool operator <(const data &rhs) const {
		return p < rhs.p;
	}
}t[N];
int get1(int a) {
	while(a <= sz && ans[a]) ++a;
	return a;
}
int get2(int a) {
	while(a && ans[a]) --a;
	return a;
}
int main() {
#ifdef fwat
#endif
	n = gi(), sz = n * n;
	rep(i, 1, n) {
		t[i].p = gi(), t[i].id = i;
		ans[t[i].p] = i;
	}
	sort(t + 1, t + 1 + n);
	rep(i, 1, n - 1) if(t[i].p == t[i + 1].p) return puts("No"), 0;
	int L = get1(1), R = get2(sz);
	rep(i, 1, n) {
		int x = t[i].id - 1;
		for(; x; --x, L = get1(L + 1)) {
			if(L > t[i].p) return puts("No"), 0;
			ans[L] = t[i].id;
		}
	}
	for(int i = n; i; --i) {
		int x = n - t[i].id;
		for(; x; --x, R = get2(R - 1)) {
			if(R < t[i].p) return puts("No"), 0;
			ans[R] = t[i].id;
		}
	}
	puts("Yes");
	rep(i, 1, sz) printf("%d%c", ans[i], i == sz ? '\n':' ');
	return 0;
}

Measured memory_bytes: 2176
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int k = int.Parse(input[0]);
        int cnt = 0;
        for(uint i = 1; i <= 3234566667; i++)
        {
          char[] str = i.ToString().ToCharArray();
          bool flg = true;
          bool notbegin = true;
          for(int j = 0; j < str.Length - 1; j++)
          {
            if(notbegin && str[j] == '0') continue;
            notbegin = false;
            byte sm = byte.Parse(str[j].ToString());
            byte bg = byte.Parse(str[j+1].ToString());
            if(sm < bg-1 || sm > bg+1)
            {
              flg = false;
              if(j != str.Length - 2)
              {
                i += (uint)Math.Pow(10, str.Length - 2 -j);
                i--;
              }
              break;
            }
          }
          if(flg) cnt++;
          if(cnt == k)
          {
            Console.WriteLine(i);
            return;
          }
        }
	}
}

Measured memory_bytes: 17292
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<int> vi;

signed main(){
    double x,t;
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> t >> x;
    cout << t/x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int s = a + b + c;
    if(s < 22) cout << "win" << endl;
    else cout << "bust" << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    ll A,B,N;
    cin >> A >>B >> N;
    ll C=0;

    if(N<B){cout<< ll((double)A*(double)N/(double)B) << endl; }
    else{
        
        C = B-1;
        cout << ll((double)A*(double)C/(double)B) -A*ll(double(C)/double(B)) << endl;
    }

    // ll left = 1;
    // ll right = N;
    // ll l_ans = 0;
    // ll r_ans = 0;

    // while(left<right){
    //     ll mid = left+(right-left)/2;
    //     l_ans = ll((double)A*(double)left/(double)B) -A*ll(double(left)/double(B));
    //     cout << l_ans << "l" << endl;
    //     r_ans = ll((double)A*(double)right/(double)B) -A*ll(double(right)/double(B));
    //     cout << r_ans << "r" << endl;
    //     if(l_ans>r_ans){left=left; right=right/2;}
    //     else if(r_ans>l_ans){left = right/2+1;right = right;}
    //     else{break;}
    // } 
    
    // cout << l_ans << endl;
    
    return 0;
}


Measured memory_bytes: 3648
n, border = map(int, input().split())

boxes = [int(x) for x in input().split(' ')]

count = 0
for  i in range(n):
    if(boxes[i] > border):
        count += boxes[i] - border
        boxes[i] = border

for i in range(n-1):
    if(boxes[i] + boxes[i+1] > border):
        count += boxes[i] + boxes[i+1] - border
        boxes[i+1] -= boxes[i] + boxes[i+1] - border
        
print(count)

Measured memory_bytes: 14132
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int mod = 1e9+7;

ll dp [60][60][3000];

int main() {
    int N, A;
    cin >> N >> A;
    int x[N];
    for (int i = 0; i < N; i++) cin >> x[i];
    dp[0][0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < 3000; k++) {
                if (dp[i][j][k] == 0) continue;
                // xiを使う場合
                dp[i+1][j+1][k+x[i]] += dp[i][j][k];
                // xiを使わない場合
                dp[i+1][j][k] += dp[i][j][k];
            }
        }
    }
    
    ll sum = 0;
    for (int i = 1; i <= N; i++) sum += dp[N][i][A*i];

    cout << sum << endl;
    return 0;
}


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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long X, long long A) {
  if( X < A ) cout << 0 << endl;
  else cout << 10 << endl;
}

int main() {
  long long X;
  scanf("%lld", &X);
  long long A;
  scanf("%lld", &A);
  solve(X, A);
  return 0;
}


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

int main(){
  int A;cin >> A;
  vector<int> a(4);
  for(int i=0;i<4;i++){
    a[i]=A%10;
    A/=10;
  }
  if(a[3]+a[2]+a[1]+a[0]==7)cout<<a[3]<<'+'<<a[2]<<'+'<<a[1]<<'+'<<a[0]<<'='<<7;
  else if(a[3]+a[2]+a[1]-a[0]==7)cout<<a[3]<<'+'<<a[2]<<'+'<<a[1]<<'-'<<a[0]<<'='<<7;
  else if(a[3]+a[2]-a[1]+a[0]==7)cout<<a[3]<<'+'<<a[2]<<'-'<<a[1]<<'+'<<a[0]<<'='<<7;
  else if(a[3]-a[2]+a[1]+a[0]==7)cout<<a[3]<<'-'<<a[2]<<'+'<<a[1]<<'+'<<a[0]<<'='<<7;
  else if(a[3]+a[2]-a[1]-a[0]==7)cout<<a[3]<<'+'<<a[2]<<'-'<<a[1]<<'-'<<a[0]<<'='<<7;
  else if(a[3]-a[2]+a[1]-a[0]==7)cout<<a[3]<<'-'<<a[2]<<'+'<<a[1]<<'-'<<a[0]<<'='<<7;
  else if(a[3]-a[2]-a[1]+a[0]==7)cout<<a[3]<<'-'<<a[2]<<'-'<<a[1]<<'+'<<a[0]<<'='<<7; 
  else if(a[3]-a[2]-a[1]-a[0]==7)cout<<a[3]<<'-'<<a[2]<<'-'<<a[1]<<'-'<<a[0]<<'='<<7;   
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
  int n;
  cin >> n;
  
  int h[n];
  rep(i,n) cin >> h[i];
  
  int ans = 1;
  int flag = 0;
  for(int i = 1; i < n; i++){
    for(int j = 0; j < i; j++){
      if(h[i] < h[j]){
        flag = 1;
      }//if
    }//for
    if(flag == 0){
      ans++;
    }
    flag = 0;
  }//for
  
  cout << ans << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    int N;
    std::cin >> N;
    std::vector<double> v(N);
    for(int i=0; i<N; i++) scanf(" %lf", &v[i]);

    std::sort(v.begin(), v.end(), std::greater<double>());
    for(int i=0; i<N-1; i++){
        // for(auto &&itr = v.begin(); itr != v.end(); itr++) std::cout << *itr << std::endl;
        double z = v.back();
        // printf("%lf\n", z);
        v.pop_back();
        z = 1.0 * (z + v.back()) / 2;
        // printf("%lf\n", z);
        v.pop_back();
        v.push_back(z);
    }
    std::cout << v.front() << std::endl;
}

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

int main(){
	double a,b,c,d,e,f;
	while(cin>>a>>b>>c>>d>>e>>f){
		double det = a*e-b*d;
		double x = 1/det*(c*e - b*f);
		double y = 1/det*(-c*d + a*f);	
		x = round(1000*x) / 1000;
        y = round(1000*y) / 1000;
        if(x==0)x=0;
        if(y==0)y=0;

		cout << fixed << setprecision(3) << x << ' ' << y <<endl;
	}
	return 0;
}

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

typedef long long Long;
const int mod = 1000000000 + 7;

Long f[100010];
Long inv[100010];
int last[100010];
int a[100010];

Long modpow(Long b, Long e) {
	if(e == 0) {
		return 1;
	}
	if(e & 1) return (modpow(b, e-1) * b) % mod;
	Long m = modpow(b, e >> 1);
	return (m * m) % mod;
}
Long inverse(Long x) {
	return modpow(x, mod - 2);
}

Long nCr(int n, int r) {
	if(n < r) return 0;
	Long num = f[n];
	Long den = (inv[n - r] * inv[r]) % mod;
	return (num * den) % mod; 
}

int main (int argc, char const* argv[])
{
	f[0] = inv[0] = 1;
	for(int i = 1; i <= 100005; i++) {
		f[i] = f[i - 1] * i;
		f[i] %= mod;
		inv[i] = inverse(f[i]); 
	}
	int n;
	scanf("%d", &n);
	++n;
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	int p, q;
	for(int i = 1; i <= n; i++) {
		if(last[a[i]] != 0) {
			p = last[a[i]];
			q = i;
			break;
		}
		last[a[i]] = i;
	}
	int len = q - p + 1;
	for(int k = 1; k <= n; k++) {
		int ans = nCr(n, k) - nCr(n - len, k - 1);
		if(ans < 0) ans += mod;
		printf("%d\n", ans);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

bool comp(P a, P b){
    return a.second<b.second;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,m;
    cin>>n>>m;
    vector<P> p;
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        p.emplace_back(a,b);
    }

    sort(ALL(p),comp);

    ll ans=0;
    ll end=0;
    rep(i,m){
        P &now = p[i];
        if(now.fi>=end){
            ans++;
            end = now.se;
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 2420
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions

import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n = ni()
    a = na()

    c = collections.Counter(a)

    ans = 0
    for k, v in c.items():
        if k < v:
            ans += v - k
        if k > v:
            ans += v

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 86308
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int N;
        cin >> N;

        int S=N;
        int res;
        while (S != 0)
        {
                res += S % 10;
                S = S / 10;
        }

        if (N%res==0)
        {
                cout << "Yes" << endl;
        } else{
                cout << "No" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
dp=[0]*(N+3)
dp[0]=1
a=[0]*(N+3)
for i in range(M):
    a[int(input())]=1
mod=10**9+7

for i in range(N+1):
    if a[i+1] != 1:
        dp[i+1]+=dp[i]
        dp[i+1]%=mod
    if a[i+2] != 1:
        dp[i+2]+=dp[i]
        dp[i+2]%=mod

print(dp[N])

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

#define inf 0x7f7f7f7f
#define maxn 100006
#define mod 1000000007
#define N 1
#define P 2


typedef long long ll;
typedef struct {
    int u, v, next, w;
} Edge;
Edge e[1];
int cnt, head[1];

inline void add(int u, int v,int w) {
    e[cnt].u = u;
    e[cnt].v = v;
    e[cnt].w = w;
    // e[cnt].f=f;
    e[cnt].next = head[u];
    head[u] = cnt++;
    e[cnt].u = v;
    e[cnt].v = u;
    e[cnt].w = w;
    //    e[cnt].f=-f;
    e[cnt].next = head[v];
    head[v] = cnt++;
}

inline void write(int x) {
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')
            f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

int root,n,cot[30][100005],flag;
string s;


int find(int x,int y,int val,int j){
    int l=x,r=y;
    while(l<r){
        int mid=(l+r)>>1;
        cout<<mid<<" "<<l<<" "<<val<<" "<<cot[mid][j]<<" "<<j<<endl;
        if(l-r>=2&&cot[mid][j]-val>(mid-x)/2){
            cout<<x<<" "<<mid<<endl;
            flag=1;
            return 1;
        }else r=mid;
    }
    return l;
}
int main(){
        cin>>s;
        if(s.size()==1){
            cout<<-1<<" "<<-1<<endl;
            return 0;
        }
        s+='0';
        for(int i=0;i<s.size()-1;i++){
            if(s[i]==s[i+1]){
                cout<<i+1<<" "<<i+2<<endl;
                return 0;
            }else if(s[i]==s[i+2]){
                cout<<i+1<<" "<<i+3<<endl;
                return 0;
            }
        }
        cout<<-1<<" "<<-1<<endl;
}




Measured memory_bytes: 512
#include<stdio.h>

int main(){

  int x,y,z=1;

  scanf("%d%d",&x,&y);

  if(x<y){
    z=y;
    y=x;
    x=z;
  }
  while(z!=0){
    z=x%y;
    x=y;
    y=z;
  }
  printf("%d\n",x);

  return 0;
}

Measured memory_bytes: 592
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      String S = sc.next();
      String T = sc.next();
      
      // 一致する文字数の最大値を取得
      int max = 0;
      int lenS = S.length();
      int lenT = T.length();
      for(int i = 0; i < lenS-lenT+1; i++){
        String subS = S.substring(i, i+lenT);
        int count = matchStr(subS, T);
        if(count > max){
          max = count;
        }
      }
      
      // 出力
      System.out.println(lenT - max);
    }
    
    // 2つの文字列の一致する文字数を数える関数
    public static int matchStr(String str1, String str2){
      int len = str1.length();
      int count = 0;
      for(int i = 0; i < len; i++){
        if(str1.charAt(i) == str2.charAt(i)){
          count++;
        }
      }
      return count;
    }

}

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

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

	n /= 2;
	bool ans = false;
	if (n) {
		string s1 = str.substr(0, n);
		if (str == s1 + s1) ans = true;
	}
	cout << (ans ? "Yes\n" : "No\n");
}

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

int N, M;
int main(){
    while(cin >> N >> M && N+M>0){
        pair<int,int> a[N];
        long long r = 0;
        for (int i = 0; i < N; ++i){
            int D, P;
            cin >> D >> P;
            a[i] = make_pair(P, D);
            r += D * P;
        }
        sort(a, a+N, greater<pair<int,int> >());
        /*for(int i = 0; i < N; ++i){
            cout << a[i].first << " " << a[i].second << endl;
        }*/
        for(int i = 0; i < N; ++i){
            if(a[i].second >= M){
                r -= M * a[i].first;
                M = 0;
            }else{
                r -= a[i].first * a[i].second;
                M -= a[i].second;
            }
            if(M == 0) break;
        }
        cout << r << endl;
    }
}

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

int main(){
  int A,B,H,M;
  cin >> A >> B >> H >> M;
  
  double pi = 3.1415926535897932384626433832;
  double theta = H*30.0 + M*(1.0/2.0) - M*6.0;
  double C =A*A + B*B - 2*A*B*cos(theta/180.0*pi);
  cout << fixed << setprecision(20) << sqrt(C) << endl;
  return 0;
}

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

int main() {
	string s;
	cin >> s;
	string d = "dream", dr = "dreamer", e = "erase", er = "eraser";
	string t = "";
	int end = s.size();
	while (1) {
		if (end < 7)
			break;
		if (s.substr(end - 5, 5) == d) {
			t = d + t;
			end -= 5;
			continue;
		}
		else if (s.substr(end - 7, 7) == dr) {
			t = dr + t;
			end -= 7;
			continue;
		}
		else if (s.substr(end - 5, 5) == e) {
			t = e + t;
			end -= 5;
			continue;
		}
		else if (s.substr(end - 6, 6) == er) {
			t = er + t;
			end -= 6;
			continue;
		}
		else {
			cout << "NO" << endl;
			return 0;
		}
	}
	if (t == s || d + t == s || dr + t == s || e + t == s || er + t == s)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

int res = 0;

void bubble(vector<int> &a, int n)
{
    bool f = true;
    while (f)
    {
        f = false;
        for (int j = n - 1; j >= 1; j--)
        {
            if (a[j] < a[j - 1])
            {
                swap(a[j], a[j - 1]);
                f = true;
                res++;
            }
        }
    }
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    bubble(a, n);
    printv(a);
    cout << res << endl;
}



Measured memory_bytes: 3216
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(void){

  int i,j,k,t,tmp;
  string s;
  int a,b,c;

  cin>>a>>b>>c;

  if(a==b&&b==c) cout<<1;
  else if((a==b&&b!=c)||(b==c&&c!=a)||(a==c&&c!=b)) cout<<2;
  else cout<<3;

  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
function main(input) {
  var H = input[0]-0;
  var W = input[1]-0;
  var N = input[2]-0;
  var ans = 0;
  while(N>0){
    if(H>W){
      W--;
      N-=H;
    }else{
      H--;
      N-=W;
    }
    ans+=1;
  }
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
#define fori(i,s,n) for(ll i=s;i<=n;i++)
#define ford(j,s,n) for(int i=n;i>=s;i--)
#define pb push_back
#define TEST int t; cin>>t; for(int T=1;T<=t;T++)
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,cnt=0;
    double d,x,y,k;
    cin>>n>>d;
    while(n--){
        cin>>x>>y;
        k=sqrt(pow(x,2)+pow(y,2));
        //cout<<k<<" ";
        if(d>=k)
            cnt++;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
int main(void){
    char s[10];
    string ans;
    cin >> s;
    for(int i=0;i<10;i++){
        if(s[i] == '0') ans += '0';
        else if(s[i] == '1') ans += '1';
        else if(s[i] == 'B'){
            if(ans.empty()) continue;
            else ans.pop_back() ;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "damage", long, "cost");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, k;
    scan(n, k);
    auto p = aryread!(real)();
    foreach (i; iota(n))
    {
        p[i] = (p[i] + 1) / 2;
    }
    auto com = new real[](n + 1);
    com[0] = 0;
    foreach (i; iota(1, n + 1))
    {
        com[i] = com[i - 1] + p[i - 1];
    }
    real ans = 0;
    foreach (i; iota(n - k + 1))
    {
        auto s = com[i + k] - com[i];
        ans = max(s, ans);
    }
    writefln("%.15s", ans);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

vector<int> graph[1000005];
int color[1000005];

int dfs(int v)
{
    color[v] = 1;
    for(auto i:graph[v])
    {
        if(color[i] == 0)
            dfs(i);
    }
    return 0;
}
signed main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    int n,m;
    cin >>n>>m;
    for(int i = 0; i<m;i++)
    {
        int a,b;
        cin >>a>>b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    dfs(1);
    int ans = 0;
    for(int i = 1; i<=n;i++)
    {
        if(color[i] == 0)
        {
            ans++;
            dfs(i);
        }
    }
    cout <<ans<<endl;
}


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

int main(){
  int N,K;
  cin>>N>>K;
  
  int A[N]={0};
  int d;
  int index;
  for(int i=0;i<K;i++){
    cin>>d;
    for(int j=0;j<d;j++){
      cin>>index;
      A[index-1]++;
     
    }
  }
  
  int ans=0;
  for(int i=0;i<N;i++){
    if(A[i]==0)ans++;
  }
  cout<<ans<<endl;


}

Measured memory_bytes: 3624