akhauriyash/Code-Regression huggingface dataset:
import heapq

N, M = map(int, input().split())
A = list(map(lambda x:-int(x), input().split()))
#print([bin(val) for val in A])

heapq.heapify(A)
#print(A)

for _ in range(M):
    temp = -heapq.heappop(A) // 2
    heapq.heappush(A, -temp)
    #print(A)
print(-sum(A))


Measured memory_bytes: 72088
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


int main(){
    
    int N,M; cin >> N >> M;
    vector<int> a(N);
    int k;
    int s;
    
    rep(i,M){
        cin >> k;
        rep(j,k){
            cin >> s;
            s--;
            a[s] |= (1<<i);
        }
    }
    
    int f = 0;
    int p;
    rep(i,M){
        cin >> p;
        f |= (p<<i);
    }
    int ans = 0;
    rep(i,1<<N){
        int b = 0;
        rep(d,N){
            if ((i>>d)&1){
                b ^= a[d];
            }
        }
        if (b==f){
            ans++;
        }
    }
    cout << ans;
    
    rn 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <array>
#include <cassert>
#include <cstring>
#include <vector>
#include <list>
#include <algorithm>

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define mp make_pair

template <typename T>
bool uax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template <typename T>
bool uin(T& a, T b) { if (b < a) { a = b; return true; } return false; }

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef list<int> li;
typedef vector<li> vli;
typedef vector<vpi> vvpi;
typedef long long i64;

const int inf = 1e9;

int sum_base(int n, int b = 10) {
  int s = 0;
  while (n) { s += n % b; n /= b; }
  return s;
}

void solve_a() {
  int n; cin >> n;
  int r = inf;
  fore(a, 1, n - 1) uin(r, sum_base(a) + sum_base(n - a));
  cout << r << endl;
}

void solve_b() {
  int n; cin >> n;
  i64 a, b; cin >> a >> b;
  i64 k; cin >> k;
  const int mod = 998244353;
  auto mul = [] (int a, int b) {
    return a * 1ll * b % mod;
  };
  auto sum = [] (int a, int b) {
    if ((a += b) >= mod) a -= mod;
    return a;
  };
  auto power = [&] (int a, i64 n) {
    int r = 1; while (n) {
      if (n&1) r = mul(r, a);
      if (n/=2) a = mul(a, a);
    } return r;
  };
  vi ff(n + 1, 1);
  vi fi(n + 1, 1);
  fore(i, 1, n) ff[i] = mul(ff[i-1], i);
  fi[n] = power(ff[n], mod - 2);
  for (int i = n - 1; i >= 1; --i) fi[i] = mul(fi[i + 1], i + 1);
  auto get3 = [&] (int n, int i, int j, int k) {
    return mul(mul(mul(ff[n], fi[i]), fi[j]), fi[k]);
  };
  auto get2 = [&] (int n, int i, int j) {
    return mul(mul(ff[n], fi[i]), fi[j]);
  };
  vi cnk(n + 1, 1);
  fore(i, 1, n) cnk[i] = sum(cnk[i-1], get2(n, i, n - i));
  int r = 0;
  fore(i, 0, n) {
    i64 sk = k - a * i;
    if (sk >= 0 && sk % b == 0) {
      i64 j = sk / b;
      if (j <= n) {
        r = sum(r, mul(get2(n, i, n - i), get2(n, j, n - j)));
      }
    }
  }
  cout << r << endl;
}

int main() {
#ifdef HOME
  freopen("input.txt", "rt", stdin);
#endif
  solve_b();
  return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int INF = 1e9 + 5;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> H(n);
    for(int i=0; i<n; ++i){
        cin>>H[i];
    }
    vector<int> dp(n, INF);
    dp[0]=0;
    for(int i=0; i<n; ++i){
        for(int j=i+1; j<=i+k; ++j){
            if(j<n){
                dp[j]=min(dp[j], dp[i]+abs(H[i] - H[j]));
            }
        }
    }
    cout<<dp[n-1]<<"\n";
}

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

int main()
{

    data_type n,m,x,y;
    cin>>n>>m;
    vector<vector<data_type>>matrix(n,vector<data_type>(m));
    string str[n];
    for(auto &i:str)
        cin>>i;
    for(int i=0; i<n; i++)
        {
            for(int j=0; j<m; j++)
                {
                    if(str[i][j]=='#')
                        matrix[i][j]=0;
                    else if(i==0 && j==0)
                        matrix[i][j]=(str[0][0]=='.');
                    else if(i==0)
                        matrix[i][j]=matrix[i][j-1];
                    else if(j==0)
                        matrix[i][j]=matrix[i-1][j];
                    else
                        matrix[i][j]=(matrix[i][j-1]+matrix[i-1][j])%1000000007;
                }
        }

    cout<<matrix[n-1][m-1]<<endl;

    return 0;
}



Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
int main()
{
    cin.tie(NULL);
    ios::sync_with_stdio(false);    
    ll s;
    cin>>s;
    vi ax(s);
    for (int i = 0; i < s; ++i)
    {   int d;
        cin>>d;
        ax[i]=d;
    }
    sort(ax.begin(),ax.end());
    for (int i = 0; i < s; ++i)
    {
        if(ax[i]==ax[i+1]){
            cout<<"NO"<<endl;
            return 0;
         }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 1024
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var a, b, c int
	fmt.Fscan(r, &a)
	fmt.Fscan(r, &b)
	fmt.Fscan(r, &c)

	fmt.Printf("%d %d %d\n", c, a, b)
}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// mod combination
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>	
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
typedef unsigned int uii;
typedef pair<int,int> pii;
typedef unsigned long long uLL; 
typedef vector<int> vii; 

const int maxn = 2e5 + 5;
LL d[maxn][2];
std::vector<int> G[maxn];
const int inf = 1e9 + 7; 
LL dp(int u, int c, int p){
	if(d[u][c] != -1) {
		return d[u][c];
	} 
	d[u][c] = 1;
	for(int v : G[u]) if(v != p) {
		LL t = dp(v, 0, u);
		if(!c){
			t += dp(v, 1, u);
		}
		d[u][c] = (d[u][c] * t) % inf;
	}
	return d[u][c];
}

int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	int n;
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	memset(d, -1, sizeof(d));
	for(int i = 0; i < n - 1; ++i){
		int u, v;
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	cout << (dp(1, 0, 0) + dp(1, 1, 0)) % inf << endl;

	return 0;
}

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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define  endl 			"\n"
#define  FOR(i, a, n)   for (ll i = a; i < n; i++)
#define  ROF(i, a, n)   for (ll i = a; i >= n; i--)
#define  all(x)         (x).begin(), (x).end()
#define  mset(x, val)   memset(x,val,sizeof(x))
#define  dline          cout<<"///REACHED///\n";

typedef long long ll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  4e+5+7;
map<ll,ll> factors;
void primeFactors(ll n) 
{ 
	// Print the number of 2s that divide n 
	while (n % 2 == 0) 
	{ 
		factors[2]++;
		n = n/2; 
	} 

	// n must be odd at this point. So we can skip 
	// one element (Note i = i +2) 
	for (ll i = 3; i <= sqrt(n); i = i + 2) 
	{ 
		// While i divides n, print i and divide n 
		while (n % i == 0) 
		{ 
			factors[i]++; 
			n = n/i; 
		} 
	} 

	// This condition is to handle the case when n 
	// is a prime number greater than 2 
	if (n > 2) 
		factors[n]++; 
} 



ll n;
void solve()
{
	cin>>n;
	ll ans=0;
	primeFactors(n);
	ll remaining=0;
	// debug(factors);
	for(auto x: factors){
		double j = -1+sqrt(1+4*2*x.second);
		j/=2;
		j=floor(j);
		// remaining+=(j*(j+1)/2)-x.second;
		ans+=j;
		// debug(j,ans,remaining,x);
	}
	cout<<ans<<endl;

}

int main()
{
   solve();
}



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

int main() {
	ll a, b, k;
	cin >> a >> b >> k;
    if(k>a+b)cout << 0 << " " << 0;
	else if (k >= a) cout << 0 << " " << b - k + a;
	else if (k < a) cout << a - k << " " << b;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int K = in.nextInt();
            int[] x = new int[N];
            for (int i = 0; i < N; i++) {
                x[i] = in.nextInt();
            }

            int sum = 0;
            for (int i = 0; i < N; i++) {
                sum += 2 * Math.min(Math.abs(x[i] - 0), Math.abs(x[i] - K));
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 27084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);


            if (a <= c && b >= c)
            Console.WriteLine("Yes");
            else
            Console.WriteLine("No");

            Console.ReadKey();
        }
    }
}


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

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string s;
    cin >> s;
    if (s.back() == 's')
        s += "es";
    else
        s += "s";
    cout << s << '\n';
    return 0;
}

Measured memory_bytes: 3636
N = input()
sum = 0
mydict = {}
for i in range(int(N)):
    s = list()
    st2 = ""
    st = input()
    for i in range(10):
        s.append(st[i])
    s.sort()
    if st2.join(s) in mydict.keys():
        mydict[st2.join(s)] += 1
        sum += mydict[st2.join(s)]
    else:
        mydict[st2.join(s)] = 0

print(sum)


Measured memory_bytes: 17892
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long lol;
template<typename T>
inline void gg(T &res){
    res=0;T fh=1;char ch=getchar();
    while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
    if(ch=='-')fh=-1,ch=getchar();
    while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
    res*=fh;
}
inline int gi(){int x;gg(x);return x;}
inline lol gl(){lol x;gg(x);return x;}
const int MAXN=100010;
const int INF=1e9;
int a[MAXN];
int main(){
    int n=gi();
    for(int i=1;i<=n;i++)a[i]=gi();
    sort(a+1,a+n+1);
    reverse(a+1,a+n+1);
    for(int i=1;i<=n;i++)
        if(i+1>a[i+1]){
            bool res=1;
            for(int j=i+1;a[j]==i;j++)res^=1;
            res&=(a[i]-i+1)&1;
            printf(res?"Second":"First");
            break;
        }
    return 0; 
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define N 10005
#define INF (long long)12345679*12345679
using namespace std;
long long dp[N];
struct node
{
	int h,p;
	bool operator < (node b)
	{
		return h+p<b.h+b.p;
	}
}a[N];
int n;
int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d%d",&a[i].h,&a[i].p);
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++)
		dp[i]=INF;
	dp[0]=0;
	
	for (int i=1;i<=n;i++)
		for (int j=i;j>=1;j--)
			if (dp[j-1]<=a[i].h)
				dp[j]=min(dp[j],dp[j-1]+a[i].p);
	for (int i=0;i<=n;i++)
		if (dp[i]==INF)
		{
			printf("%d\n",i-1);
			return 0;
		}
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 3848
#include<iostream>
using namespace std;
int main(){
    int H, W;
    while(1){
        cin>>H>>W;
        if(H==0 && W==0)break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout<<"#";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}



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

int main() {
  int A;
  cin >> A;
  int num = 1;
  while(num<A){
    num *=2;
  }
  if(num==A){
    cout << num << endl;
  }
  else if(num != 1){
    cout << num/2 << endl;
  }
  else {
    cout << "1" << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from __future__ import division, print_function, absolute_import, unicode_literals

N, x = map(int, input().split())
a = list(map(int, input().split()))

arg_a = a.index(min(a))
a = a[arg_a:] + a[:arg_a]
ans = sum(a)
for t in range(1, N):
    for i in range(N-1, 0, -1):
        a[i] = min(a[i], a[i-1])
    tmp = (t*x) + sum(a)
    ans = min(ans, tmp)
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

signed main(){
  int x, y, z, k; cin >> x >> y >> z >> k;
  vector<lint> a(x), b(y), c(z);
  for(int i = 0; i < x; i++) cin >> a[i];
  for(int i = 0; i < y; i++) cin >> b[i];
  for(int i = 0; i < z; i++) cin >> c[i];
  vector<lint> data;
  for(int i = 0; i < x; i++){
    for(int j = 0; j< y; j++) data.push_back(a[i] + b[j]);
  }
  sort(data.begin(), data.end(), greater<lint>());
  vector<lint> data2;
  for(int i = 0; i < min(k, int(data.size())) ; i++){
    for(int j = 0; j < z; j++) data2.push_back(data[i] + c[j]);
  }
  sort(data2.begin(), data2.end(), greater<lint>());
  for(int i = 0; i < k; i++) cout << data2[i] << '\n';
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    string a, b, c;cin >> a >> b >> c;
    cout << char(a[0]-'a'+'A') << char(b[0]-'a'+'A') << char(c[0]-'a'+'A') << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
#define int long long
#define mod 1000000007
#define DEBUG cout<<"Hello1\n";
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))
#define deb(...) debug(#__VA_ARGS__, __VA_ARGS__);
const int N = 1e6 + 5;
const double pi =  acosl(-1);
const long long inf = 1e18 + 5;
using namespace std;
template<typename T> void debug(string s, T x) {cout << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cout << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}
template<class T> void print_container(T &container) { for (auto &t : container) { cout << t << " ";} cout << endl;}
template<class T> void printArr(T &a , int n) { for (int i = 0; i < n; i++) {cout << a[i] << " ";} cout << endl;}
typedef long long ll;
typedef pair<int, int> pii;

//Template Ends
int n;
int a[N];

vector<int> v;

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

	v.pb(a[0]);
	for (int i = 1; i < n; i++) {
		if (v.size() % 2)
		{
			if (a[i] < v.back()) {
				v.pop_back();
				v.pb(a[i]);
			}
			else if (a[i] > v.back()) {
				v.push_back(a[i]);
			}
		}
		else
		{
			//(v.size() % 2 == 0)
			if (a[i] > v.back()) {
				v.pop_back();
				v.push_back(a[i]);
			} else if (a[i] < v.back()) {
				v.push_back(a[i]);
			}

		}
	}

	if (v.size() % 2) {
		v.pop_back();
	}

	// print_container(v);

	int ans = 1000;
	int stocks = 0;
	for (int i = 0; i < v.size(); i++) {
		if (i % 2 == 0) {
			stocks = (ans / v[i]) ;
			ans = ans - stocks * v[i] ;
		} else {
			ans += stocks * v[i];
			stocks = 0;
		}
		// deb(ans);
	}


	cout << ans << endl;

}

int32_t main() {
	IOS;

	solve();

	return 0;
}




Measured memory_bytes: 3668
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

// nの約数を昇順に列挙したvectorを返す。計算量はO(√n)
vector<ll> yakusu(ll n) {
    vl res;
    for(ll i = 1; i*i <= n; i++) {
        if(n%i == 0) {
            res.pb(i);
            if(i != n/i) {
                res.pb(n/i);
            }
        }
    }
    sort(all(res));
    return res;  
}

int main() {
    ll x;
    cin >> x;
    
    vl v = yakusu(x);
    for(auto d : v) {
        for(ll b = -200; b <= 200; b++) {
            ll a = b+d;
            ll p = 1;
            ll q = 1;
            rep(i, 5) {
                p *= a;
                q *= b;
            }
            if(p - q == x) {
                cout << a << " " << b << endl;
                re0;
            }
        }
    }

    re0;
}

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


int main() {
    int a,b;
    cin >> a >> b;
    if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0){
        cout << "Possible\n";
    }else cout << "Impossible\n";
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#ユークリッドの互除法( A < B　とし, O(logA))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

N = int(input())

#3個以上の最大公約数を求める必要がある
# res=0 と初期化して、res=gcd(res,x[i])と更新する
# gcd(a,b,c,....) → gcd(gcd(gcd(a,b),c),...) 
res = 0
x = list(map(int,input().split()))

for i in range(N):
    res = gcd(res,x[i])

print(res)


Measured memory_bytes: 14224
#include <iostream>

using namespace std;

bool grid[2000][2000];
int l[2000][2000];
int r[2000][2000];
int u[2000][2000];
int b[2000][2000];

int main() {
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      char tmp; cin >> tmp;
      grid[i][j] = tmp == '.';
      
      if (!grid[i][j]) {
        l[i][j] = 0;
        r[i][j] = 0;
        u[i][j] = 0;
        b[i][j] = 0;
        continue;
      }

      if (j == 0) {
        l[i][j] = 1;
      } else {
        l[i][j] = l[i][j-1]+1;
      }
      
      if (i == 0) {
        u[i][j] = 1;
      } else {
        u[i][j] = u[i-1][j]+1;
      }
    }
    for (int j = W-1; j >= 0; j--) {
      if (!grid[i][j]) continue;
      if (j == W-1) {
        r[i][j] = 1;
      } else {
        r[i][j] = r[i][j+1]+1;
      }
    }
  }
  for (int j = 0; j < W; j++) {
    for (int i = H-1; i >= 0; i--) {
      if (!grid[i][j]) continue;
      if (i == H-1) {
        b[i][j] = 1;
      } else {
        b[i][j] = b[i+1][j]+1;
      }
    }
  }
  int mx = -10000;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int sum = u[i][j] + r[i][j] + l[i][j] + b[i][j] - 3;
      mx = mx > sum ? mx : sum;
    }
  }
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 66688
mi = lambda : map(int, input().split())
li = lambda : list(map(int, input().split()))

import numpy as np

n, x = mi()
l = li()

hane = [0]
for i in range(n):
    d = hane[-1]
    hane.append(int(d+l[i]))

hane = np.array(hane)
ans = np.count_nonzero(hane <= x)

print(ans)

Measured memory_bytes: 14424
#include<bits/stdc++.h>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(){
  	long long A; long long B; long long  K;
  cin>>A>>B>>K;
  if(A>=K)
    cout<<A-K<<" "<<B<<endl;
  else if(A+B>=K)
    cout<<0<<" "<<A+B-K<<endl;
  else cout<<0<<" "<<0<<endl;
}

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

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

ll go(int w, int h, int k){
	ll an = 0;
	f(x, 1, w)f(y2, 0, min(h, (2 * k - 2 + w) / (w - x) + 1)){
		int y1 = min(h - 1ll, (2 * k + (ll)x * y2 + gcd(w, y2)) / w), t = 0;
		if (y1 >= y2){
			t += y1 - y2;
			++y1;
			if (y1 != h && (ll)w * y1 - gcd(x, y1) - gcd(w - x, y1 - y2) <= 2 * k + (ll)x * y2 - 2 + gcd(w, y2))++t;
		}
		an += t;
		if (y2)an += t;
	}
	return an;
}

int main(){
	int w, h, k;
	scanf("%d%d%d", &w, &h, &k);
	printf("%lld\n", go(w, h, k) + go(h, w, k) << 1);
}

Measured memory_bytes: 3804
n,w = map(int,input().split())

dp = [[float("inf")]*(10**5+1) for _ in range(n+1)]
dp[0][0] = 0
for i in range(1,n+1):
    weight,value = map(int,input().split())
    for j in range(10**5+1):
        if j < value:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = min(dp[i-1][j],dp[i-1][j-value]+weight)


ans = 0

for i in range(10**5+1):
    if dp[-1][i] <= w:
        ans = i
print(ans)

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<vector<int>> adj;
vector<int> d;

int N, K;
ll result = 0;

int dfs(int n=0) {
  if (d[n]!=-1) return d[n];
  if (adj[n].size()==0) return d[n]=0;
  int r = -1;
  for (auto x: adj[n]) {
    if (n!=0&&dfs(x)==K-1) { result++; continue; }
    r = max(r, dfs(x));
  }
  r++;
  return d[n] = r;
}

int main() {
  cin >> N >> K;
  adj.resize(N, vector<int>{});
  d.resize(N, -1);

  rep(i,N) {
    int a; cin >> a; a--;
    if (i==0) { if (a!=0) result++; continue; }
    adj[a].push_back(i);
  }
  dfs();
  // rep(i,N) cout << d[i] << " "; cout << endl;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 12416
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	int n;
	double p=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		p += 1. / a;
	}
	cout<<fixed<<setprecision(10)<< 1 / p << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,w;
vector<vector<ll>> dp(100,vector<ll> (100000,-1));
vector<ll> wei(100);
vector<ll> v(100);

ll solve(int i,int weight)
{
    ll ans1,ans2=0;
    if(i==n)    return 0;
    
    if(dp[i][weight]!=-1)   return dp[i][weight];
    
    ans1=solve(i+1,weight);
    if(weight+wei[i]<=w)
    {
        ans2=v[i]+solve(i+1,weight+wei[i]);
    }
    dp[i][weight]=max(ans1,ans2);
    return dp[i][weight];
}
int main()
{
    ll ans;
    cin>>n>>w;
    for(ll i=0;i<n;++i)
        cin>>wei[i]>>v[i];
    ans=solve(0,0);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 79360
import java.util.Scanner;
 
class Main{
    public static void main(String[] args){
        Scanner sc= new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int d=sc.nextInt();
        int p=sc.nextInt();
        a=a*p;
        if(p>c) b=b+d*(p-c);
        System.out.println(Math.min(a, b));  
    }
}


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

int main(){
  //now rating
  double R;
  
  //aiming rating
  double G;
  
  //need rating
  double B;
  
  cin >> R >> G;
  cout << 2*G - R << endl;
  
  return 0;
}
  
  
  
  
  

Measured memory_bytes: 256
const main = function(input){
  var rate = parseInt(input);
  if(rate<1200){
  	console.log("ABC");
  }else if(rate<2800){
  	console.log("ARC");
  }else{
  	console.log("AGC");
  }
}
 
 
 
main(require("fs").readFileSync("/dev/stdin","utf-8"));

Measured memory_bytes: 21192
A, B, C, X, Y = gets.split.map(&:to_i)
ret = 10000000000
([X,Y].max * 2).downto(0) do |c|
    a = [0, X - c.div(2)].max
    b = [0, Y - c.div(2)].max
    ret = [ret, a*A + b*B + c*C].min
end
puts ret

Measured memory_bytes: 1788
using System;

public static class Program
{
    public static void Main(string[] args)
    {
        var length = int.Parse(Console.ReadLine());
        int[] array = new int[length];
        for (int i = 0; i < length; i++)
        {
            array[i] = int.Parse(Console.ReadLine());
        }

        var array_copied = new int[length];
        Array.Copy(array, array_copied, length);
        Array.Sort(array_copied);
        if (array_copied[length - 1] == array_copied[length -2])
        {
            for (int i = 0; i < length; i++)
            {
                Console.WriteLine(array_copied[length - 1]);
            }
            return;
        }
        else
        {
            for (int i = 0; i < length; i++)
            {
                if (array[i] == array_copied[length - 1])
                {
                    Console.WriteLine(array_copied[length - 2]);
                }
                else
                {
                    Console.WriteLine(array_copied[length - 1]);
                }
            }
            return;
        }
    }
}

Measured memory_bytes: 17876
import sys

n = int(input())
l = [int(x) for x in input().split()]

ans = 1

if 0 in l:
    print(0)
    sys.exit()

for i in l:
  ans *= i
  if ans > 1000000000000000000:
    print(-1)
    sys.exit()
print(ans)

Measured memory_bytes: 87776
#line 1 "test/datastructure/potentialunionfind.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_B"
#define CXX "g++"

#include <bits/stdc++.h>
using namespace std;
using lint = long long;

#line 1 "test/datastructure/../../library/datastructure/unionfindpotential.cpp"
template <class Abel>
struct UnionFindPotential {
    vector<int> parent, rank;
    vector<Abel> diff_weight;

    UnionFindPotential(int n = 1, Abel SUM_UNITY = 0)
        : parent(n + 1), rank(n + 1, 0), diff_weight(n + 1, SUM_UNITY) {
        iota(parent.begin(), parent.end(), 0);
    }
    int root(int x) {
        if (parent[x] == x) {
            return x;
        } else {
            int r = root(parent[x]);
            diff_weight[x] += diff_weight[parent[x]];
            return parent[x] = r;
        }
    }
    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }
    bool isSame(int x, int y) { return root(x) == root(y); }
    bool unite(int x, int y, Abel w) {
        w += weight(x);
        w -= weight(y);
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (rank[x] < rank[y])
            swap(x, y), w = -w;
        if (rank[x] == rank[y])
            ++rank[x];
        parent[y] = x;
        diff_weight[y] = w;
        return true;
    }
    Abel diff(int x, int y) { return weight(y) - weight(x); }
};
#line 9 "test/datastructure/potentialunionfind.test.cpp"

int main() {
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    UnionFindPotential<lint> uf(n);
    for (int i = 0; i < q; ++i) {
        int t;
        cin >> t;
        if (t == 0) {
            int x, y, z;
            cin >> x >> y >> z;
            uf.unite(x, y, z);
        } else {
            int x, y;
            cin >> x >> y;
            if (uf.isSame(x, y))
                cout << uf.diff(x, y) << "\n";
            else
                cout << "?"
                     << "\n";
        }
    }
    return 0;
}



Measured memory_bytes: 4432
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int D;
	cin>>D;
	if(D==25){
		cout<<"Christmas";
	}else	if(D==24){
		cout<<"Christmas Eve";
	}else	if(D==23){
		cout<<"Christmas Eve Eve";
	}else	if(D==22){
		cout<<"Christmas Eve Eve Eve";
	}
	return 0;
}


Measured memory_bytes: 256
<?php
function cmp($a,$b){
    if($a[0]===$b[0]){
        return $a[1]>$b[1];
    }
    return strcmp($a[0],$b[0]);
}
$array=array();
while($a=trim(fgets(STDIN))){
        array_push($array,explode(' ',$a));
}
usort($array,"cmp");

$memo="";
foreach($array as $x){
    if($x[0]===$memo){
        echo " ".$x[1];
    }else{
        if($memo!==""){
            echo PHP_EOL;
        }
        $memo=$x[0];
        echo $memo.PHP_EOL;
        echo $x[1];
    }
}
echo PHP_EOL;

Measured memory_bytes: 6684
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int n;
    cin >> n;
    n += 110;
    cout << (n / 111) * 111 << endl;
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <iomanip>
#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
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;

int main()
{
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;

    vector<int> x(N);
    vector<int> y(M);
    rep(i, N) cin >> x.at(i);
    rep(i, M) cin >> y.at(i);

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    rep2(z, X+1, Y-1)
    {
        if(z > x.at(x.size()-1) && z<= y.at(0))
        {
            cout << "No War" << endl;
            return 0;
        }
    }

    cout << "War" << endl;
    return 0;

}


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

int main() {
  int N;
  cin >> N;
  
  string str;
  str = to_string(N);
  
  int count;
  
  for (int i = 0; i < str.size(); i++)
    count += (int)str[i] - 48;
  
  if (N % count == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
    
  

Measured memory_bytes: 3672
#include <stdio.h>
#include <stdlib.h>
#define N 10000
#define M 2000000
int main(){
  int n,i;
  int C[M];
  int *A,*B;

   scanf("%d",&n);
  A=malloc(sizeof(int)*n+1);
  B=malloc(sizeof(int)*n+1);
   
 
 for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
   
  for(i=0;i<M;i++){
    C[i]=0;
  }
   
 
  for(i=0;i<n;i++){
    C[A[i]]++;
  } 

  for(i=1;i<M;i++){
    C[i]=C[i]+C[i-1];
  }
  for(i=0;i<n;i++){
    B[C[A[i]]]=A[i];
    C[A[i]]--;
  }
  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i!=n) printf(" ");
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 24048
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

f cs@[c1,c2,c3] = cond "YES" "NO" $ (>=4) $ length $ filter (<=20) $ map (+my) remain
  where
    remain = [x | x <- [1..10], x `notElem` cs]
    my = c1+c2

main = map (f . map readInt . words) . lines <$> getContents >>= mapM_ putStrLn

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

using namespace std;

int main()
{
  long long a[4];
  for (int i = 0; i < 4; i++) {
    cin >> a[i];
    if (i) a[i] = min(a[i], a[i - 1] * 2);
  }
  long long n;
  cin >> n;
  n *= 4;
  long long ans = 0, now = 8;
  for (int i = 3; i >= 0; i--) {
    ans += n / now * a[i];
    n %= now;
    now /= 2;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

W, H = map(int, raw_input().split())
p = [int(raw_input()) for i in xrange(W)]
q = [int(raw_input()) for i in xrange(H)]
r = zip(p, [0]*W) + zip(q, [1]*H)
r.sort(reverse = True)
w, h = 0, 0
ans = sum(p)*(H + 1) + sum(q)*(W + 1) 
for x, k in r:
    if k == 0:
        ans -= max(0, (H - h)*x)
        w += 1
    else:
        ans -= max(0, (W - w)*x)
        h += 1
print ans


Measured memory_bytes: 29076
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <queue>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    priority_queue<ll> que2;
    priority_queue<ll, vector<ll>, greater<ll> > que;
    ll n, a[312345], fst[312345], ltr[312345], sum1, sum2;
    cin >> n;

    sum1 = 0;
    sum2 = 0;
    REP(i, n * 3)
    {
        cin >> a[i];

        if (i < n)
        {
            que.push(a[i]);

            sum1 += a[i];
        }

        if (2 * n <= i)
        {
            que2.push(a[i]);

            sum2 += a[i];
        }
    }

    for (int i = n - 1; i < 3 * n; i++)
    {
        fst[i] = sum1;

        if (a[i + 1] > que.top())
        {
            sum1 += a[i + 1] - que.top();
            que.pop();
            que.push(a[i + 1]);
        }
    }

    for (int i = 2 * n; i > 0; i--)
    {
        ltr[i] = sum2;

        if (a[i - 1] < que2.top())
        {
            sum2 += a[i - 1] - que2.top();
            que2.pop();
            que2.push(a[i - 1]);
        }
    }

    ll ans = -10000000000000000;
    for (int i = n - 1; i < n * 2; i++)
    {
        ans = max(ans, fst[i] - ltr[i + 1]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9076
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set;
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef vector<string> VS;
typedef pair<int, int> PII;

struct SCORE {
    VI time;
    int total_time;
    int solve;
    SCORE() {
        total_time = 0; 
        solve = 0; 
    }
};

int main(void) {
    int t;
    int p;
    int r;
    while (1) {
        cin >> t >> p >> r;
        if (t == 0 && p == 0 && r == 0) {
            break;
        }
        vector<SCORE> rec(t);
        VI pib(t, false);
        for (int i = 0; i < t; i++) {
            rec[i].time = pib;
        }

        for (int i = 0; i < r; i++) {
            int t2;
            int p2;
            int time;
            string mess;
            cin >> t2 >> p2 >> time >> mess;
            t2--;
            p2--;
            if (mess == "CORRECT") {
              rec[t2].solve++;
              rec[t2].time[p2] += time;  
              rec[t2].total_time += rec[t2].time[p2];
            } else if (mess == "WRONG"){
              rec[t2].time[p2] += 1200;  
            }
        }
        priority_queue<pair<int, pair<int, int> > > pq;
        for (int i = 0; i < t; i++) {
           pq.push(make_pair(rec[i].solve, make_pair(-rec[i].total_time, -(i + 1)))); 
        }
        while (!pq.empty()) {
           cout << -pq.top().second.second << " " << pq.top().first << " " << -pq.top().second.first << endl;
            pq.pop();
        }


    }
    return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, x;
  cin >> a >> b >> x;
  if (a > x || a+b < x)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
/* Coached by rainboy */
#include <stdio.h>
#include <string.h>

#define N 100000
#define MD 1000000007

int main() {
	static char s[N + 1];
	static int dp[N + 1][13];
	int n, i, r, d;	

	scanf("%s", s);
	n = strlen(s);
	dp[0][0] = 1;
	for (i = 0; i < n; i++)
		for (r = 0; r < 13; r++)
			if (s[i] == '?')
				for (d = 0; d <= 9; d++)
					dp[i + 1][(r * 10 + d) % 13] = (dp[i + 1][(r * 10 + d) % 13] + dp[i][r]) % MD;
			else {
				d = s[i] - '0';
				dp[i + 1][(r * 10 + d) % 13] = (dp[i + 1][(r * 10 + d) % 13] + dp[i][r]) % MD;
			}
	printf("%d\n", dp[n][5]);
	return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<int> vv(n), vc(n);
  for (int i = 0; i < n; ++i) {
    cin >> vv[i];
  }

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

  int ans = 0;
  for (int i = 0; i < (1 << n); ++i) {
    int x = 0, y = 0;
    for (int j = 0; j < n; ++j) {
      if (i & (1 << j)) {
        x += vv[j];
        y += vc[j];
      }
    }

    ans = max(ans, x - y);
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3612
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

sys.setrecursionlimit(100001)


class Edge:
    def __init__(self,arg_to,arg_dist):
        self.to = arg_to
        self.dist = arg_dist

V = int(input())
G = [[] for _ in range(V)]

for _ in range(V-1):
    from_,to_,dist_ = map(int,input().split())
    G[from_].append(Edge(to_,dist_))
    G[to_].append(Edge(from_,dist_))

ans = 0

def recursive(node_id,parent):
    max_path1 = 0
    max_path2 = 0

    global ans

    for edge in G[node_id]:
        if edge.to == parent:
            continue
        tmp_dist = edge.dist+recursive(edge.to,node_id)
        if tmp_dist > max_path1:
            max_path2 = max_path1
            max_path1 = tmp_dist
        elif tmp_dist > max_path2:
            max_path2 = tmp_dist

    ans = max(ans,max_path1+max_path2)
    return max_path1

recursive(V//2,-1)
print("%d"%(ans))



Measured memory_bytes: 110508
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;


int main(void){
    long double a,b,h,m;
    cin >> a >> b >> h >> m;
    long double a2=a*a,b2=b*b,rad=abs(6*m-(30*h+0.5*m))*M_PI/180;
    long double cosrad=cos(rad);
    long double c=a2+b2-2*a*b*cosrad;
    c=sqrt(c);
    printf("%.11LF\n",c);

    return 0;
}

Measured memory_bytes: 4100
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int32_t main(){_

   cin >> n;

   cout<<n*n;

   return 0;
}

Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e7
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------
class Edge{
public:
    int t,w;
    Edge(){}
    Edge(int t,int w): t(t), w(w) {}
};
int n,d[100001];
vector<Edge> G[100001];

void bfs(int s){
    for(int i=0;i<n;i++)d[i]=INF;
    queue<int>q;
    q.push(s);
    d[s]=0;
    int u;
    while(!q.empty()){
        u=q.front();q.pop();
        for(int i=0;i<G[u].size();i++){
            Edge e = G[u][i];
            if(d[e.t]==INF){
                d[e.t]=d[u]+e.w;
                q.push(e.t);
            }
        }
    }
}

void solve(){
    bfs(0);
    int maxv=0;
    int tg=0;
    for(int i=0;i<n;i++){
        if(d[i]==INF)continue;
        if(maxv<d[i]){
            maxv=d[i];
            tg=i;
        }
    }
    
    bfs(tg);
    maxv=0;
    for(int i=0;i<n;i++){
        if(d[i]==INF)continue;
        chmax(maxv,d[i]);
    }
    cout<<maxv<<endl;
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int s,t,w;cin>>n;
    for(int i=0;i<n-1;i++){
        cin>>s>>t>>w;
        G[s].pb(Edge(t,w));
        G[t].pb(Edge(s,w));
    }
    solve();
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------







Measured memory_bytes: 9792