akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <cassert>
#include <map>
using namespace std;

typedef pair<set<int>, int> result;
#define value first
#define p second
map<string, set<int> > idx;
set<int> U;

result equation(const string &s, int p=0);
result term(const string &s,int p=0);
result factor(const string &s,int p=0);

set<int> op(char c,set<int> s1,set<int> s2) {
    if(c == 'u') {
        for(set<int>::iterator it = s2.begin(); it != s2.end(); ++it)
            s1.insert(*it);
        return s1;
    }else if(c == 'i') {
        map<int,int> ap;
        for(set<int>::iterator it = s1.begin(); it != s1.end(); ++it)
            if(ap.find(*it) == ap.end()) ap[*it] = 1;
            else ap[*it]++;

        for(set<int>::iterator it = s2.begin(); it != s2.end(); ++it)
            if(ap.find(*it) == ap.end()) ap[*it] = 1;
            else ap[*it]++;

        set<int> ss;
        for(map<int,int>::iterator it = ap.begin(); it != ap.end(); ++it) {
            if(it->second == 2) ss.insert(it->first);
        }
        return ss;
    }else if(c == 'd') {
        for(set<int>::iterator it = s2.begin(); it != s2.end(); ++it) {
            if(s1.find(*it) != s1.end()) s1.erase(*it);
        }
        return s1;
    }else if(c == 's') {
        return op('u', op('d', s1, s2), op('d', s2, s1));
    }
    assert(false);
    return set<int>();
}

result equation(const string &s,int p) {
    result r = factor(s, p);
    while(s[r.p] == 'u' || s[r.p] == 'i' || s[r.p] == 'd'
          || s[r.p] == 's') {
        result r_ = factor(s, r.p+1);
        r.value = op(s[r.p], r.value, r_.value);
        r.p = r_.p;
    }
    return r;
}

result factor(const string &s,int p) {
    if(s[p] == 'c') {
        result r = term(s,p+1);
        return result(op('d', U, r.value),r.p);
    }
    return term(s,p);
}

result term(const string &s,int p) {
    if(s[p] == '(') {
        result r = equation(s, p+1);
        r.p++;
        return r;
    } else {
        return result(idx[string(1,s[p])], p+1);
    }
}

int main() {
    string name,l;
    int k,n;
    while(cin>>name>>k) {

        U.clear(); idx.clear();

        if(name == "R") break;
        for(int i=0; i<k; ++i) {
            cin>>n;
            idx[name].insert(n);
            U.insert(n);
        }
        while(true) {
            cin>>name>>k;
            if(name == "R") break;
            for(int i=0; i<k; ++i) {
                cin>>n;
                idx[name].insert(n);
                U.insert(n);
            }
        }

        cin>>l;
        set<int> ss = equation(l).value;
        for(set<int>::iterator it = ss.begin(); it != ss.end(); ++it) {
            if(it != ss.begin()) cout<<" ";
            cout<<*it;
        }
        if(ss.empty()) cout<<"NULL";
        cout<<endl;
    }
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string S, T;

int main()
{
	in >> S >> T;
	S += S;
	rep(i, S.length() / 2)
	{
		auto res = S.substr(i, S.length() / 2);
		if (res == T)
		{
			out << "Yes" << std::endl;
			return 0;
		}
	}
	out << "No" << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int main(){
    int w,a,b;
    cin >> w >> a >> b;
    if(a+w<b){
        cout << b-a-w << endl;
        return 0;
    }
    if(b+w<a){
        cout << a-b-w << endl;
        return 0;
    }
    cout << 0 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
using namespace std;
typedef long long int LL;
vector<int> path[105];
queue<int> q1;
bool used[105];
LL sa[2];

void check(int a,int b){
	int nt;
	int i,j,k;
	LL x,y,z;
	bool ill=false;
	sa[0]=0,sa[1]=1;
	memset(used,false,sizeof(used));
	q1.push(a),used[a]=true;
	if(b!=-1)q1.push(b),used[b]=true,sa[1]=2;
	else ill=true;
	while(!q1.empty()){
		nt=q1.size();
		z=0;
		sa[0]++;
		for(i=0;i<nt;i++){
			x=q1.front(),q1.pop();
			y=path[x].size()-1;
			if(z<y)z=y;
			for(j=0;j<path[x].size();j++){
				y=path[x][j];
				if(used[y])continue;
				q1.push(y),used[y]=true;
			}
		}
		if(ill)z++,ill=false;
		if(z!=0)sa[1]*=z;
	}
}

int main(){
	int n;
	int i,j,k;
	int a,b,c;
	LL s[2];
	cin>>n;
	s[0]=n,s[1]=1;
	for(i=0;i<n-1;i++){
		cin>>a>>b;
		a--,b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	for(i=0;i<n;i++){
		check(i,-1);
		if(sa[0]<s[0])s[0]=sa[0],s[1]=sa[1];
		if(sa[0]==s[0] && sa[1]<s[1])s[1]=sa[1];
		for(j=0;j<path[i].size();j++){
			if(path[i][j]<i)continue;
			check(i,path[i][j]);
			if(sa[0]<s[0])s[0]=sa[0],s[1]=sa[1];
			if(sa[0]==s[0] && sa[1]<s[1])s[1]=sa[1];
		}
	}
	cout<<s[0]<<" "<<s[1]<<endl;
	return 0;
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict
from sys import exit
import math


def main():
    n = getN()
    x = 100
    for i in range(10000):
        x = math.floor(x * 1.01)
        if x >= n:
            print(i + 1)
            return
if __name__ == "__main__":
    main()

Measured memory_bytes: 68304
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int C[10];
int m,n;

int StoI(string a){
  int res=0;
  for(int i=1;i<a.size();i++) res=res*10+a[i]-'0';
  return res;
}

int S,T;
int getIdx(char ch,int a){
  if(ch=='C');
  if(ch=='L') a +=m;
  if(ch=='H') a = S;
  if(ch=='D') a = T;
  return a;
}

typedef pair<int,int> P;
typedef pair<int,P> PP;
vector<P> G[1000];
int D[1<<6][500];
int dijkstra(){
  for(int i=0;i<(1<<6);i++)
    for(int j=0;j<500;j++) D[i][j] = INF;
  
  priority_queue<PP,vector<PP>,greater<PP> > Q;
  Q.push(PP(0,P(0,S)));
  D[0][S] = 0;
  
  int res=INF;  
  while(!Q.empty()){
    PP t = Q.top();Q.pop();
    int cost = t.first;
    int bit = t.second.first;
    int pos = t.second.second;
    if(D[bit][pos]<cost) continue;
    if(pos==T) res=min(res,cost);

    for(int i=0;i<G[pos].size();i++){
      int npos = G[pos][i].first;
      int ncost = cost+G[pos][i].second;
      int nbit = bit;
      if(npos<m){
	if((bit>>npos)&1)continue;
	ncost-=C[npos],nbit|=(1<<npos);
      }
      
      if(D[nbit][npos]<=ncost)continue;
      D[nbit][npos] = ncost;
      Q.push(PP(ncost,P(nbit,npos)));
    }
  }
  return res;
}



int main(){
  while(1){
    for(int i=0;i<1000;i++)G[i].clear();
    int K,d;
    cin>>m>>n>>K>>d;
    if(!m&&!n&&!K&&!d)break;
    S = m+n;
    T = m+n+1;
    for(int i=0;i<m;i++)cin>>C[i];
    
    for(int i=0;i<d;i++){
      string a,b;
      int c;
      cin>>a>>b>>c;
      int A = getIdx(a[0],StoI(a)-1);
      int B = getIdx(b[0],StoI(b)-1);
      G[A].push_back(P(B,c*K));
      G[B].push_back(P(A,c*K));
    }
    cout<<dijkstra()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3276
raw = (input().strip()).split()
number_of_points = int(raw[0])
distance_criteria = int(raw[1])
#print(number_of_points)

cnt = 0

for i in range(number_of_points):
    crdinate = (input().strip()).split()
    x = int(crdinate[0])
    y = int(crdinate[1])
    distance = (x**2 + y**2)**(1/2)
    if distance <= distance_criteria:
        cnt += 1
    else:
        continue

print(cnt)

Measured memory_bytes: 9644
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



int N;
int a[20];
int x[20][20];
int y[20][20];

int main () {
  cin >> N;
  rep(i, N) {
    cin >> a[i];

    rep(k, a[i]) {
      cin >> x[i][k] >> y[i][k];
    }
  }


  int max_bit = 1 << N;

  int ans = 0;

  for (int bits=0;bits<max_bit;++bits) {
    int ct = 0;
    int res[20];

    Rep(i, 20) {
      res[i] = 0;
    }

    //cout << bits << "\n";

    Rep(k, N) {
      //cout << (bits >> k) << "\n";

      if ((bits >> k) % 2 == 1) {
        ct++;
        res[k+1] = 1;
      }
    }

//    Rep(k, N) {
//      cout << res[k+1];
//    }

    //cout << "\n";

    bool flg = true;

    rep(i, N) {
      if (res[i] == 1) {
        rep(k, a[i]) {
          if (res[x[i][k]] != y[i][k]) {
            flg = false;
            break;
          }
        }
      }
    }

    if (flg) {
      //cout << bits << "\n";
      ans = max(ans, ct);
    }
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long dp[101][300001];
int main() {
    ios::sync_with_stdio(false);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n, w;
    cin >> n >> w;
    pair<long long, long long> items[100];
    for (int i = 0; i < n; i++) cin >> items[i].first >> items[i].second;
    for(int i=0; i< n; i++){
        for(int j = 0; j<= 1e5 + 1; j++){
            dp[i][j] = 1e15;
        }
    }
    dp[0][0] = 0;
    dp[0][items[0].second] = items[0].first;
    for (int i = 0; i < n - 1; i++) {
        for (int j = 0; j <= 1e5 + 1; j++) {
            if (dp[i][j] == 1e15) continue;
            dp[i + 1][j + items[i + 1].second] =
                min(dp[i + 1][j + items[i + 1].second],
                    dp[i][j] + items[i + 1].first);
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
        }
    }
    long long ans = 0;
    for (int i = 0; i <= 1e5 + 1; i++) 
        if(dp[n-1][i] <= w)
            ans = i;
    cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  
  int cnt = 0, current = 1;
  for (auto x: A) {
    if (x != current) cnt++;
    else current++;
  }

  cout << ((N == cnt) ? -1 : cnt) << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n){
    cin >> h[i];
  }
  vector<int> l(n+1);
  l[0] = 0;
  rep(i,n){
    l[i+1] = max(l[i],h[i]);
  }
  int count = 1;
  for(int i=1;i<n;i++){
    if (h[i]>=l[i]) count++;
  }
  cout << count << endl;
  return 0;
}


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

using namespace std;

int n, a, b;

vector<unsigned long long> e;
map<pair<unsigned long long, unsigned long long>, unsigned long long> res;
bool div1[100];
bool div2[100];

unsigned long long C(int n, int k) {
    memset(div1, 0, sizeof div1);
    memset(div2, 0, sizeof div2);
    unsigned long long res = 1;
    for (int j = 1; j <= n; j++) {
        res *= j;
        for (int i = 1; i <= n - k; i++) {
            if (res % i == 0 && !div1[i]) {
                res /= i;
                div1[i] = 1;
            }
        }
        for (int i = 1; i <= k; i++) {
            if (res % i == 0 && !div2[i]) {
                res /= i;
                div2[i] = 1;
            }
        }
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> a >> b;
    e.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> e[i];
    }
    sort(e.rbegin(), e.rend());
    for (int sz = a; sz <= b; sz++) {
        unsigned long long sum = 0;
        for (int j = 0; j < sz; j++) {
            sum += e[j];
        }
        unsigned long long t = e[sz - 1];
        unsigned long long cnt1 = 0;
        unsigned long long cnt2 = 0;
        for (int j = 0; j < sz; j++) {
            if (t == e[j]) {
                cnt1++;
            }
        } 
        for (int j = sz; j < n; j++) {
            if (t == e[j]) {
                cnt2++;
            }
        }
        for (int j = 0; j <= min(cnt1, cnt2); j++) {
            unsigned long long t = __gcd(sum, (unsigned long long)sz);
            res[make_pair(sum /t, (unsigned long long)sz / t)] += C(cnt1, j) * C(cnt2, j);
        }              
    }
    
    double res1;
    unsigned long long ch;
    bool f = 0;
    for (auto val : res) {
        if (f == 0) {
            res1 = (double)val.first.first / val.first.second;
            ch = val.second;
            f = 1;
        }      
        else if (res1 < (double)val.first.first / val.first.second) {
            res1 = (double)val.first.first / val.first.second;
            ch = val.second;
        }
    }
    cout << fixed << res1 <<" ";
    cout << ch << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1000000];
int main(){
	int a,b,c,s1,s2;
	cin>>a>>b>>c;
	s1=a;
	a=b;
	b=s1;
	s2=a;
	a=c;
	c=s2;
	cout<<a<<" "<<b<<" "<<c;
	return 0;
}

Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;

long long gcd(long long x, long long y){
			if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> x(N);
    int ans = INF;
    for(int i = 0; i<N; i++){
        cin >> x[i];
    }
    for(int i = 0;i< N-K+1; i++){
         int ans_1=abs(x[i])+abs(x[i]-x[i+K-1]);
         int ans_2=abs(x[i+K-1])+abs(x[i]-x[i+K-1]);

            
           
    ans = min(ans,min(ans_1,ans_2));
    }
    
cout << ans << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int N; 
long long C; 
long long H[200010]; 
long long dp[200010];
long long deq[200010];  
long long F(int j, long long x){
	return -2 * H[j] * x + dp[j] + H[j] * H[j]; 
}
bool check(int F1, int F2, int F3){
	long long A1 = -2 * H[F1], B1 = dp[F1] + H[F1] * H[F1]; 
	long long A2 = -2 * H[F2], B2 = dp[F2] + H[F2] * H[F2]; 
	long long A3 = -2 * H[F3], B3 = dp[F3] + H[F3] * H[F3]; 
	return (A2 - A1) * (B3 - B2) >= (B2 - B1) * (A3 - A2); 
}
int main(){
	cin >> N >> C;
	for(int i = 0; i < N; i++) cin >> H[i]; 
	int s = 0; int t = 1; deq[0] = 0; 
	for(int i = 1; i < N; i++){
		while(s + 1 < t && F(deq[s], H[i]) >= F(deq[s+1], H[i])) s++; 
		dp[i] = H[i] * H[i] + C + F(deq[s], H[i]); 
		while(s + 1 < t && check(deq[t - 2], deq[t - 1], i)) t--; 
		deq[t++] = i;
	}
	cout << dp[N-1] << endl; 
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

int main(void) {
    int N,K;
    vector<int> A;
    cin>>N>>K;
    for(int i = 0;i < N;i++) {
        int temp;
        cin>>temp;
        A.push_back(temp);
    }
    
    N--;
    int count = 0;
    while(N>0) {
        count++;
        N = N-(K-1);
    }

    cout<<count<<endl;

    return 0;
}


Measured memory_bytes: 892
class Problem
  def exec
    while l = gets do
      f = l.to_f
      res = calc f
      puts res
    end
  end

  def calc(f)
    t = f / 9.8
    y = 4.9 * (t ** 2)
    ((y + 5) / 5).ceil
  end
end

p = Problem.new
p.exec

Measured memory_bytes: 8600
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static ConsoleApp.Util;
using static System.Math;

namespace ConsoleApp
{
    class Program
    {

        static void Main(string[] args)
        {
            var arr = ReadLine().Split().Select(int.Parse).ToArray();
            if(arr[0] * 500 >= arr[1]){
                WriteLine("Yes");
            }
            else{
                WriteLine("No");
            }
        }

    }


    static class Util
    {
        public static void ChMin(ref int a, int b)
        {

            if (a > b)
            {
                a = b;
            }
        }


        public static void ChMax(ref long a, long b)
        {
            if (a < b)
            {
                a = b;
            }
        }




    }
}


Measured memory_bytes: 13268
import sys
from collections import deque
s=sys.stdin.readlines()
q=int(s[0].split()[1])
f=lambda x,y:(x,int(y))
d=deque(f(*e.split())for e in s[1:])
t=0
while d:
 k,v=d.popleft()
 if v>q:v-=q;t+=q;d.append([k,v])
 else:t+=v;print(k,t)


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

typedef long long ll;
typedef pair<int, int> ii;

int n, m, sum;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    int arr[n];
    for (int i = 0; i < n; ++i) {
      cin >> arr[i];
      sum += arr[i];
    }

    nth_element(arr, arr + m - 1, arr + n, greater<int>());
    if (arr[m - 1] * 4 * m < sum) {
      puts("No");
    } else {
      puts("Yes");
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int k, p, last;
ll A, B, bin[70], ans;
int main(){
	scanf("%lld%lld", &A, &B);
	bin[0]=1; for(int i=1; i<=60; i++)bin[i]=bin[i-1]<<1;
	k=-1;
	for(int i=60; i>=0; i--)
		if((A&bin[i])==(B&bin[i])){
			if(A&bin[i]){A-=bin[i]; B-=bin[i];}
		}else{k=i; break;}
	if(k==-1){printf("1"); return 0;}
	ans=bin[k]-A;
	p=-1; for(int i=0; i<=k-1; i++)if(B&bin[i])p=i;
	for(int i=k-1; i>=-1; i=last-1){
		if(i<=p){ans+=bin[i+1]; break;}
		if(A&bin[i]){
			last=i; while(last>=1&&A&bin[last-1])last--;
			ans+=bin[p+1];
			ans+=bin[last]-(A&(bin[last]-1)); break;
		}else{
			last=i;
			ans+=bin[i];
		}
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
 
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main() {
  int A, P;
  cin >> A >> P;
  
  cout << (int)((A*3+P)/2) << endl;
  return 0; 
}

Measured memory_bytes: 256
s = gets.chomp
akb = "AKIHABARA"
n = akb.length
a = []
n.times do |i|
  a << i if akb[i] == "A"
end

if s == akb
  puts "YES"
  exit
else

  1.upto(4) do |i|
    a.combination(i) do |x|
      w = []
      n.times do |j|
        if x.include?(j)
          next
        else
          w << akb[j]
        end
      end
      if s == w.join("")
        puts "YES"
        exit
      end
    end
  end
end
puts "NO"

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int N;
	cin >> N;

	map<int, int> mp;
	rep(i, N){
		int a;
		cin >> a;

		auto itr = mp.find(a);
		if(itr == mp.end()){
			mp[a] = 0;
		}
		mp[a]++;
		if(mp[a] == 2) mp[a] = 0;
	}

	int ans = 0;
	for(auto itr = mp.begin(); itr != mp.end(); itr++){
		int val = itr->second;
		if(val == 1) ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	ll h; cin >> h;
	ll ans = 0;
	for (int i = 0; h != 0; i++) {
		ans += pow(2, i);
		h /= 2;
	}
	cout << ans;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(void){
	double n;
	while(cin >> n){
		if (n<=48)
			cout << "light fly" << endl;
		else if(n<= 51)
			cout << "fly" << endl;
		else if(n<=54)
			cout << "bantam" << endl;
		else if(n<= 57)
			cout << "feather" << endl;
		else if(n<= 60)
			cout << "light" << endl;
		else if(n<= 64)
			cout << "light welter" << endl;
		else if(n<= 69)
			cout << "welter" << endl;
		else if(n<= 75)
			cout << "light middle" << endl;
		else if(n<= 81)
			cout << "middle" << endl;
		else if(n<= 91)
			cout << "light heavy" << endl;
		else
			cout << "heavy" << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, A[100001], cnt=1;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> A[i];
    }

    sort(A+1, A+N+1);

    for(i=2; i<=N; i++){
        if(A[i-1]!=A[i]) cnt++;
    }

    if(cnt%2==0) cout << cnt-1 << endl;
    else cout << cnt << endl;

    return 0;
}

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

using namespace std;

int main(){
    int ans;
    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    sort(a, a + 3);
    
    ans = 10 * a[2] + a[0] + a[1];

    cout << ans << endl;

    return 0;
}

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

#define int long long

using namespace std;

class Solver{};

signed main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0)break;

		int sum = 0;
		for (int i = 1; i * i <= n; i++) {
			if (n % i != 0)continue;

			int other = n / i;
			if (i == n)continue;
			sum += i;
			if (other == i || other == n)continue;
			sum += other;
		}

		if (sum < n) {
			cout << "deficient number" << endl;
		}
		else if (sum == n) {
			cout << "perfect number" << endl;
		}
		else {
			cout << "abundant number" << endl;
		}
	}
}


Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
int main() {
	string a, b;
	cin >> a;
	b = a;
	reverse(b.begin(), b.end());
	for(int i = 0; i < b.size(); i++) {
		if(b[i] == 'b') b[i] = 'd';
		else if(b[i] == 'd') b[i] = 'b';
		else if(b[i] == 'p') b[i] = 'q';
		else if(b[i] == 'q') b[i] = 'p';
	}
	cout << (b == a ? "Yes" : "No");
}

Measured memory_bytes: 512
#include<stdio.h>

int n, A[50];

int solve(int i, int m){
  if(m == 0) return 1;
  if(i >= n) return 0;

  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main(){
  int q, M, i;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  scanf("%d", &q);

  for(i = 0; i < q; i++){
    scanf("%d", &M);
    if(solve(0, M)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}



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

using ll = long long;
using pii = pair<int, int>;

constexpr int vec[4] = {-1, 1, -4, 4};

vector<int> move_bubble(vector<int> const& v) {
    auto res = v;
    queue<pii> bubbles;
    for(int i = 0; i < 16; ++i) {
        if(res[i] >= 5) {
            res[i] = 0;
            for(int d = 0; d < 4; ++d) {
                bubbles.push(make_pair(i, d));
            }
        }
    }
    while(!bubbles.empty()) {
        queue<pii> next;
        while(!bubbles.empty()) {
            pii b = bubbles.front();
            bubbles.pop();
            int to = b.first + vec[b.second];
            if(to < 0 || 16 <= to) {
                continue;
            }
            if((b.second == 0 || b.second == 1) && to / 4 != b.first / 4) {
                continue;
            }
            if(res[to] != 0) {
                res[to]++;
            } else {
                next.push(make_pair(to, b.second));
            }
        }
        for(int i = 0; i < 16; ++i) {
            if(res[i] >= 5) {
                res[i] = 0;
                for(int d = 0; d < 4; ++d) {
                    next.push(make_pair(i, d));
                }
            }
        }
        bubbles = move(next);
    }
    return res;
}

int main() {
    vector<int> fld(16);
    for(int i = 0; i < 16; ++i) {
        cin >> fld[i];
    }

    using state = pair<vector<int>, int>;
    map<state, int> memo;
    memo[make_pair(fld, 0)] = 0;
    queue<state> que;
    que.push(make_pair(fld, 0));
    int res = -1;
    while(!que.empty()) {
        auto now = que.front();
        que.pop();
        if(count(now.first.begin(), now.first.end(), 0) == 16) {
            res = now.second;
            break;
        }
        if(now.second >= 5) {
            continue;
        }
        for(int i = 0; i < 16; ++i) {
            auto next = now;
            next.second += 1;
            auto& nf = next.first;
            nf[i] += 1;
            if(nf[i] >= 5) {
                nf = move_bubble(nf);
            }
            if(memo.count(next) == 0) {
                memo[next] = memo[now] + 1;
                que.push(next);
                
            }
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 16300
#include <cstdio>

int main(){
    long long int N, M;
    scanf("%lld %lld", &N, &M);
    if(N == 1 && M == 1){
        printf("1");
        return 0;
    }else if(N == 1){
        printf("%lld", M - 2);
        return 0;
    }
    else if(M == 1){
        printf("%lld", N - 2);
        return 0;
    }else{
        printf("%lld", (N - 2) * (M - 2));
    }
}

Measured memory_bytes: 256
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (ll)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

void solve(){
	ll n,m;
	ll odd=0,even=0;
	cin>>n>>m;
	vector<ll> a(n);
	rep(i,0,n){
		cin>>a[i];
		a[i]/=2; 
		if(a[i]&1){
			odd = 1;
		}else{
			even = 1;
		}
	}
	
	ll ans=a[0];
	rep(i,1,n){
		if(ans>m){
			cout<<0<<endl;
			return ;
		}
		if(ans%a[i]){
			ans = ans*a[i]/__gcd(ans,a[i]);
		}
	}
	for(auto x:a){
		if(ans/x%2==0){
			cout<<0;
			return ;
		}
	}
	ll res=0,cnt=1;
	while(ans*cnt<=m)res++,cnt+=2;
	cout<<res;
	//cout<<1+(m-ans)/(2*ans);
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





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

int main(){
  int N; cin >> N;
  vector<int> div(N + 1);
  rep1(x, N) {
    for (int i = x; i <= N; i += x) div[i]++;
  }
  long long ans = 0;
  rep1(i, N) ans += (long long)i * div[i];
  cout << ans << endl;
}

Measured memory_bytes: 42276
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node{
  int key;
  struct Node *right, *left, *parent;
};

struct Node *root, *NIL;
void insert(int);
void inorder(struct Node*);
void preorder(struct Node*);
int main(){
  int n, i, x;
  char com[50];
  int cnt = 0;
  

  scanf("%d",&n);
  if(n > 500001)
   exit(1);

  for(i = 0; i < n; i++){
    scanf("%s",com);
    
    if(strcmp(com,"insert") == 0){
      scanf("%d",&x);
      if(x < -2000000000 || x > 2000000000)
	exit(1);
      insert(x);
    }
    else if(strcmp(com,"print") == 0){
      cnt++;
      if(cnt > 10)
	exit(1);
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void insert(int k){
  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z;

  z = (struct Node*)malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else
      x = x->right;
  }

  z->parent = y;
  
  if(y == NIL)
    root = z;
  else{
    if(z->key < y->key)
      y->left = z;
    else
      y->right = z;
  }
}

void inorder(struct Node *u){
  if(u == NIL)
    return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u == NIL)
    return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}



Measured memory_bytes: 25196
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define fi first
#define se second
#define reset(n,k) memset((n),k,sizeof(n))
#define all(n) n.begin(),n.end()
#define pb push_back
using namespace std;
using ll=long long;
using pii=pair<int,int>;
ll n,q,ope,a,b;
char c;
string s;
ll bit[28][500005];
void add(int ar,int pos,int num){
	for(int i=pos;i<=n;i+=i&-i){
		bit[ar][i]+=num;
	}
}
int que(int ar,int pos){
	int ans = 0;
	for(int i=pos;i;i-=i&-i){
		ans += bit[ar][i];
	}
	return ans; 
}

int main(){
	IOS;
	cin>>n;
	cin>>s;
	s = " " + s;
	int siz = s.size();
	
	for(int i=1;i<siz;i++){
		add(s[i]-'a',i,1);
	}
	
	cin>>q;
	while(q--){
		cin>>ope;
		if(ope == 1){
			cin>>a>>c;
			add(s[a]-'a',a,-1);
			s[a] = c;
			add(s[a]-'a',a,1);
		}
		else{
			cin>>a>>b;
			int ans = 0;
			for(int i=0;i<26;i++){
				if(que(i,b) - que(i,a-1)) ans ++;
			}
			cout<<ans<<'\n';
		}
	}


}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(b%a==0){
    cout << a+b << endl;
    return 0;
  }else{
    cout << b-a << endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int MAX_N=10e4;
int num[9]={2,5,5,4,5,6,3,7,6};
int a[9];
int dp[10][MAX_N];
int main(void){
	int N,M;
		cin >> N >> M;
	for(int i=0;i<M;i++)
		cin >> a[i];
	for(int i=1;i<=N;i++)
		dp[0][i]=-1;
	sort(a,a+M);

	
	
	
	for(int i=0;i<M;i++){
		for(int j=1;j<=N;j++){
			if(j-num[a[i]-1]<0 || dp[i+1][j-num[a[i]-1]]==-1)
				dp[i+1][j]=dp[i][j];
			else if(dp[i+1][j-num[a[i]-1]]+1>dp[i][j])
				dp[i+1][j]=dp[i+1][j-num[a[i]-1]]+1;
			else
				dp[i+1][j]=dp[i][j];
		}
	}
	
	int i=M,j=N;
	while(dp[i][j]>0){
		if(j-num[a[i-1]-1]<0 || dp[i][j-num[a[i-1]-1]]==-1)
			i--;
		else if(dp[i][j]==dp[i][j-num[a[i-1]-1]]+1){
			cout << a[i-1];
			j-=(num[a[i-1]-1]);
		}
		else
			i--;
	}
	cout << endl;
	
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define int long long


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

    int n,h; cin >> n >> h;
    vector<int> a(n),b(n);
    for(int i = 0;i < n;i ++){
        cin >> a.at(i) >> b.at(i);
    }

    sort(a.begin(),a.end(),greater<int>());
    sort(b.begin(),b.end(),greater<int>());

    
    int ans = 0;

    while(h > 0){
        if(ans < n && a.at(0) < b.at(ans)){
            h -= b.at(ans); 
        }else{
            h -= a.at(0);
        }

        ans ++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

w, h = read_line(int, int)

c = []
for _ in range(10):
    c.append(read_line(int, int, int, int, int, int, int, int, int, int))

for k in range(10):
    for i in range(10):
        for j in range(10):
            if i != j:
                c[i][j] = min(c[i][j], c[i][k] + c[k][j])

cost = 0
for _ in range(w):
    for a in read_line(*([int] * h)):
        if a >= 0:
            cost += c[a][1]

print(cost)


Measured memory_bytes: 40812
#include <iostream>

using namespace std;

const int MAXN = 100 + 10;
const int MAXV = 1e3 + 10;
int v[MAXN];
int w[MAXN];
long long dp[MAXN][MAXV * MAXN];

int main()
{
    int N, W;
    cin >> N >> W;

    for (int i = 1; i <= N; i++)
        cin >> w[i] >> v[i];

    dp[0][0] = 0;
    for (int i = 1; i <= (MAXN * MAXV); i++)
        dp[0][i] = 1e9 + 10;

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < (MAXV * MAXN); j++) {
            if (j >= v[i])
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }

    int ans = 0;
    for (int i = 1; i < (MAXV * MAXN); i++)
        if (dp[N][i] <= W)
            ans = max(ans, i);
    cout << ans;
    return 0;
}

Measured memory_bytes: 88320
#include<stdio.h>
int main(void)
{
    int a,b,c,i,x,ans=0;
 
    while(scanf("%d",&a)!=EOF){
    x=600/a;
    c=a;
    for(i=0;i<x-1;i++){
        b=c*c;
        ans+=a*b;
        c+=a;
    }
    printf("%d\n",ans);
    ans=0;
    c=0;
    }
    return 0;
}

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

int main() {
  int A,B,C,N;
  cin>>A>>B>>C>>N;
  int b=0;
  for(int i=0;i<=A;i++){
    for(int j=0;j<=B;j++){
      for(int k=0;k<=C;k++){
        if(i*500+j*100+k*50==N){
          b++;
        }
      }
    }
  }
  cout<<b<< endl;
}


Measured memory_bytes: 256
/*starting with the name of almighty ALLAH*/
/*solved by RAKIB JOY*/
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define vc vector
#define vi vc<int>
#define vl vc<ll>
#define dbg(x) cout<<x<<endl;
#define mp(x,y) make_pair(x,y)
#define yes dbg("YES")
#define no dbg("NO")
#define tst int t;cin>>t;while(t--)
#define srt(v) sort(v.begin(),v.end());
#define rsrt(v) sort(v.begin(),v.end(),greater<int>());
#define rj ios::sync_with_stdio(false);cin.tie(0);
#define rvs(v) reverse(v.begin(),v.end());
#define F first
#define S second
using namespace std;
int main()
{
    rj
    int a,b,i,j;
    map<int,int>m;
    cin>>a;
    for(j=1 ;j<a ;j++)
    {
       cin>>b;
       m[b]++;
    }
    for(i=1 ;i<=a ;i++)
    {
       cout<<m[i]<<endl;
    }




    return 0;
}


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

using namespace std;

int main(void)
{
    vector<char> in,out;
    int n;

    cin>>n;
    string s;
    cin>>s;
    int left = 0;
    int right = 0;

    for(int i = n - 1; i >= 0;i--) {
	if(s[i] == ')')
	    left++;
	else
	    left--;
	left = left >= 0 ? left : 0;
    }

    for(int i = 0;i < n;i++)
    {
	if(s[i] == '(')
	    right++;
	else
	    right--;
	right = right >= 0 ? right : 0;
    }

    cout<<string(left,'(')<<s<<string(right,')')<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());
    //rep (i, n) cout << v[i] << ' ';
    cout << v[n / 2] - v[n / 2 - 1] << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	vector<int>v(3);
	for (int i = 0;i < 3;i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	
		cout << v[0]<<" "<<v[1]<<" "<<v[2] << endl;
	

}

Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    cout << N * N * N << endl;

    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M, K;
  cin >> N >> M >> K;
  vector<int> A(N), B(M);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }
  vector<int64_t> X = {0}, Y = {0};
  for (auto a : A) {
    X.emplace_back(X.back() + a);
  }
  for (int b : B) {
    Y.emplace_back(Y.back() + b);
  }
  int res = 0;
  for (int i = 0; i < N + 1; i++) {
    if (X[i] > K) continue;
    auto it = upper_bound(Y.begin(), Y.end(), K - X[i]) - 1;
    res = max(res, i + (int)(it - Y.begin()));
  }
  cout << res << '\n';
  return 0;
}


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

using namespace std;

int main(){
    string s;
    cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0; 
}

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

int main(){
  int N; cin >> N;
  vector<int> A(N),B(N);
  for(int i=0; i<N; i++){
    cin >> A[i] >> B[i];
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  if(N%2==0){
    cout << B[N/2]+B[N/2-1]-A[N/2]-A[N/2-1]+1 << endl;
  }else{
    cout << B[(N-1)/2]-A[(N-1)/2]+1 << endl;
  }
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
 
using namespace std;
#define int long long
const int MAX = 2001;
const int MOD = 1000000007;
 
 



 
signed main(){
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    for(int i=0;i<n;i++){
        if(a[i]==b[n-1])cout<<b[n-2]<<endl;
        else cout<<b[n-1]<<endl;
    }

    return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <list>
#include <string>
using namespace std;
  
class Task {
public:
  void input() {
    cin >> name >> time;
  }
  string name;
  int time;
};
  
int main() {
  int n, q;
  list<Task> tasks;
  
  cin >> n >> q;
  for (int i=0; i<n; i++) {
    auto task = Task();
    task.input();
    tasks.push_back(task);
  }
  
  list<Task>::iterator current;
  int time = 0;
  
  while ((current = tasks.begin()) != tasks.end()) {
    if (current->time > q) {
      time += q;
      current->time -= q;
      tasks.splice(tasks.end(), tasks, current);
    } else {
      time += current->time;
      cout << current->name << " " << time << endl;
      tasks.erase(current);
    }
  }
}

Measured memory_bytes: 7788
#include <bits/stdc++.h>
using namespace std;
#define REP(asd,fgh) for(int asd=0; asd < fgh; asd++)
 
int main(void){
  int t;
  cin >> t;
  double p = 0;
  while(t--){
    vector<pair<int, double> > me;
    int n, m;
    cin >> n >> m;
    REP(i, m){
      pair<int,double> tmp;
      cin >> tmp.first >> tmp.second;
      me.push_back(tmp);
    }
    double w = 1;
    REP(i, m){
      w -= me[i].second;
    }
    //cout << w << endl;
    double tp = 0;
    REP(i, m){
      tp += me[i].first * (me[i].second/(1.0-w));
    }
    p = max(p, tp);
  }
 
  vector<pair<int, double> > me;
  double op = 0;
  int pp;
  int q;
  cin >> pp >> q;
  REP(i, q){
    pair<int, double> tmp;
    cin >> tmp.first >> tmp.second;
    me.push_back(tmp);
  }
  double w = 1;
  REP(i, q){
    w -= me[i].second;
  }
  REP(i, q){
    op += me[i].first * (me[i].second/(1.0-w));
  }
 
  if(p - op > 0.0000001) cout << "YES" << endl;
  else cout << "NO" << endl;
 
  return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <cstring>
using namespace std;
#define INF (1<<21)
int dp[101][2] , data[101][2];

int n;
int dfs(int height,int bill,int cur){
	if(height >= n || dp[height][bill] <= cur) return INF;
	else dp[height][bill] = cur;
	
	if(height == n-1 && data[height][bill] != 2) return cur;
	
	int ans = INF;
	
	if(data[height][bill] == 0 || (data[height][bill] == 1 && data[height+1][bill] != 1) ){
		ans = min( ans , dfs( height+0 , bill^1 , cur+1 ));
		ans = min( ans , dfs( height+1 , bill^1 , cur+1 ));
		ans = min( ans , dfs( height+2 , bill^1 , cur+1 ));
	}else if(data[height][bill] == 1){
		ans = min( ans , dfs( height+1 , bill   , cur));
	}else if(data[height][bill] == 2){
		ans = min( ans , dfs( height-1 , bill   , cur));
	}
	
	return ans;
}

int main(){
	while(cin >> n , n){
		for(int i = 0 ; i < 101 ; i++)
			dp[i][0] = dp[i][1] = INF;
		
		for(int j = 0 ; j < 2 ; j++)
			for(int i = 0 ; i < n ; i++)
				cin >> data[i][j];
		int res = min( dfs(0,0,0) , dfs(0,1,0) );
		if(res == INF) cout << "NA" << endl;
		else cout << res << endl;
	}
}

Measured memory_bytes: 0
N, X = map(int, input().split())

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

min_kona = 0
for val in m:
    min_kona += val

min_donut = min(m)
cnt = (X - min_kona) // min_donut + len(m)
print(cnt)

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  if (d[0] != 0) {
    cout << 0 << endl;
    return 0;
  }

  int d_max = *max_element(d.begin(), d.end());
  vector<int> f(d_max+1);
  rep(i, n) {
    f[d[i]]++;
  }
  if (f[0] != 1) {
    cout << 0 << endl;
    return 0;
  }

  const ll mod = 998244353;
  ll ret = 1;
  rep(i, d_max) {
    rep(j, f[i+1]) { 
      ret *= f[i]; 
      ret %= mod;
    }
  }
  cout << ret << endl;
  return 0;
}


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

namespace AtTest.ForYellow
{
    class AGC045_A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int t = ReadInt();
            for(int i = 0; i < t; i++)
            {
                int n = ReadInt();
                long[] array = ReadLongs();
                string s = Read();

                List<long> bases = new List<long>();
                bool can = true;
                for(int j = n - 1; j >= 0; j--)
                {
                    long val = array[j];
                    bases.Sort();
                    bases.Reverse();
                    for(int k = 0; k < bases.Count; k++)
                    {
                        val = Min(val, val ^ bases[k]);
                    }

                    if (s[j] == '0')
                    {
                        if (val > 0)
                        {
                            bases.Add(val);
                        }
                    }
                    else
                    {
                        if (val > 0)
                        {
                            can = false;
                            break;
                        }
                    }
                }

                WriteLine(can ? 0 : 1);
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main(){
  int N;
  cin>>N;
  vector<double> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  
  bool flag=true;
  for(int i=0;i<N-1;i++){
    if(A.at(i)==A.at(i+1)){
      flag=false;
      break;
    }
  }
  
  if(flag){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n; cin>>n;
	vector<int> dp(3);
	for(int day=0;day<n;day++)
	{
		vector<int> c(3);
		vector<int> new_dp(3,0);
		for(int i=0;i<3;i++)
		{
			cin>>c[i];
		}
		for(int i=0;i<3;i++)
		{
			for(int j=0;j<3;j++)
			{
				if(i!=j)
				{
					if(new_dp[j]<(dp[i]+c[j]))
					{
						new_dp[j]=dp[i]+c[j];
					}
				}
			}
		}
		for(int i=0;i<3;i++)
		{
			dp[i]=new_dp[i];
		}
	}
	if(dp[0]>=dp[1]&&dp[0]>=dp[2])
	{
		cout<<dp[0];
	}
	else if(dp[1]>=dp[0]&&dp[1]>=dp[2])
	{
		cout<<dp[1];
	}
	else if(dp[2]>=dp[1]&&dp[2]>=dp[0])
	{
		cout<<dp[2];
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

int a[101];

bool f(int x,int y,int z){
	vi v;
	v.emplace_back(a[x]);
	v.emplace_back(a[y]);
	v.emplace_back(a[z]);
	sort(v.begin(), v.end());
	if(v[0] == v[1] or v[1] == v[2]) return 0;
	return v[0] + v[1] > v[2];
}

int32_t main(){
    fast_io;
    int n;
    cin>>n;
    for (int i = 0; i < n; ++i)
    {
    	cin>>a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
    	for (int j = i+1; j < n; ++j)
    	{
    		for (int k = j+1; k < n; ++k)
    		{
    			if(f(i,j,k)) ans++;
    		}
    	}
    }
    show(ans);
    return 0;
}

Measured memory_bytes: 3656
import sys
import math
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, h = map(int, input().split())
    A, B = [], []
    for _ in range(n):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)

    B =sorted(B, reverse=True)
    max_a = max(A)
    res = 0
    for i in range(n):
        if B[i] > max_a:
            h -= B[i]
            res += 1
        if h <= 0:
            break

    res += max(0, math.ceil(h / max_a))
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 58712
N = int(input())
lis = []
lis_append = lis.append
for i in range(N):
    a,b = map(int,input().split(" "))
    lis_append((b,a))
lis.sort()
#dp[n][k]　n問解いたときにk問FACのときの最小の秒数
dp = [2**60]*(N+1)
dp[0] = 0
for b,a in lis:
    tmp = list(dp)
    for i in range(1,N+1):
        if dp[i-1]+a <= b:
            tmp[i] = min(dp[i],dp[i-1]+a)
    dp = tmp
ans = 0
for i in range(N+1):
    if dp[i] < 2**60:
        ans = i
print(ans)


Measured memory_bytes: 5600