akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
bool Poss(vector<ll> &v, ll k, ll mid) {
  ll ct = 0;
  for (const auto &x : v) {
    ct = ct + x / mid - (x % mid == 0);
  }
  return ct <= k;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> v(n);
  for (auto &x : v)
    cin >> x;
  ll st = 1, en = *max_element(v.begin(), v.end());
  while (st < en) {
    ll mid = (st + en) / 2;
    if (Poss(v, k, mid))
      en = mid;
    else
      st = mid + 1;
  }
  cout << st << "\n";
}

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

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

	if (a + b == c || b + c == a || c + a == b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

using lint=long long;

int main()
{
   int N,M; cin>>N>>M;
   vector<int> a(N);
   for(int i=0;i<N;i++) cin>>a[i],a[i]--;

   vector<lint> imos0(M+1);
   vector<lint> imos1(M+1);
   auto add=[&](int l,int r,int a,int b)
   {
      // for x in [l,r] add ax+b
      if(l>r) return;
      imos1[l]+=a; imos1[r+1]-=a;
      imos0[l]+=b; imos0[r+1]-=b;
   };
   for(int i=0;i<N-1;i++){
      int s=a[i],t=a[i+1];
      if(s<t){
         add(0,s,0,t-s);
         add(s+1,t,-1,t+1);
         add(t+1,M-1,0,t-s);
      }else{
         add(0,t,-1,t+1);
         add(t+1,s,0,M+t-s);
         add(s+1,M-1,-1,M+t+1);
      }
   }
   for(int i=1;i<M;i++){
      imos0[i]+=imos0[i-1];
      imos1[i]+=imos1[i-1];
   }
   lint ans=(lint)N*M;
   for(int i=0;i<M;i++){ ans=min(ans,imos1[i]*i+imos0[i]); }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 2176
def divisor(n):
    ret = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ret.append(i)
            if i*i != n:
                ret.append(n//i)
    return ret

n = int(input())
ans = sum(len(divisor(i))==8 for i in range(1,n+1) if i%2)
print(ans)


Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <cmath>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;

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

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n), L(n+1), R(n+1);
  rep(i, n) cin >> a[i];
  L[0] = 0, R[n] = 0;
  rep(i, n){
    L[i+1] = gcd(L[i], a[i]);
    R[n-i-1] = gcd(R[n-i], a[n-i-1]);
  }
  ll ans = 1;
  rep(i, n){
    ans = max(ans, gcd(L[i], R[i+1]));
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 5632
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
template<int MOD>struct modint{
	int value=0;
	modint(int x=0){value=x;}
	inline int mypow(int x,int y){
		int a=x,ret=1;
		do{
			if(y&1)ret=(ll)ret*a%mod;
			a=(ll)a*a%mod;
		}while(y>>=1);
	}
	#define inv(x) mypow(x,MOD-2)
	modint operator+(modint<MOD> x){
		value=value+x.value;
		if(value>=MOD)value-=MOD;
		return *this;
	}
	modint operator+(int x){
		value=value+x;
		if(value>=MOD)value-=MOD;
		return *this;
	}
	modint operator-(modint<MOD> x){
		value-=x.value;
		if(value<0)value+=MOD;
		return *this;
	}
	modint operator-(int x){
		value-=x;
		if(value<0)value+=MOD;
		return value;
	}
	modint operator*(modint<MOD> x){
		value=(ll)value*x.value%mod;
		return *this;
	}
	modint operator*(int x){
		value=(ll)value*x%mod;
		return *this;
	}
	modint operator/(modint<MOD> x){
		value=(ll)value*inv(x.value)%mod;
		return *this;
	}
	modint operator/(int x){
		value=(ll)value*inv(x)%mod;
		return *this;
	}
	bool operator<(modint<MOD> x){
		return value<x.value;
	}
	bool operator==(modint<MOD> x){
		return value==x.value;
	}
	bool operator>(modint<MOD> x){
		return value>x.value;
	}
	bool operator<=(modint<MOD> x){
		return value<=x.value;
	}
	bool operator>=(modint<MOD> x){
		return value>=x.value;
	}
	bool operator<(int x){
		return value<x;
	}
	bool operator==(int x){
		return value==x;
	}
	bool operator>(int x){
		return value>x;
	}
	bool operator<=(int x){
		return value<=x;
	}
	bool operator>=(int x){
		return value>=x;
	}
};
bool operator<(int x,modint<mod>y){
	return x<y.value;
}
bool operator==(int x,modint<mod>y){
	return x==y.value;
}
bool operator>(int x,modint<mod>y){
	return x<y.value;
}
bool operator<=(int x,modint<mod>y){
	return x<=y.value;
}
bool operator>=(int x,modint<mod>y){
	return x>=y.value;
}
#define M modint<mod>
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y<=0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n;
int h[105];
pair<M,M>operator*(pair<M,M>a,pair<M,M>b){
	a.first=a.first*(b.first+b.second);
	a.second=a.second*b.second;
	return a;
}
pair<M,M>solve(int l,int r){
	int low=*min_element(h+l,h+r+1);
	int cnt=0;
	for(int i=l;i<=r;i++)h[i]-=low;
	for(int i=l;i<=r;i++)if(!h[i])cnt++;
	int L=l,R=l;h[r+1]=0;
	pair<M,M>ret(M(modpow(2,cnt)),M(2));
	for(int i=l;i<=r+1;i++){
		R=i-1;
		if(h[i]==0){
			if(L<=R)ret=ret*solve(L,R);
			L=i+1;
		}
	}
	ret.first=ret.first-ret.second;
	ret.second=ret.second*modpow(2,low-1);
	ret.first=ret.first+ret.second;
	return ret;
}
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>h[i];
	cout<<solve(1,n).first.value<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

int main(){
  long long int n, w, dp[102][100010], v[110], x[110], ans=0;
  cin >> n >> w;
  for(int i=0;i<n;i++){
    cin >> x[i] >> v[i];
  }
  for (int i=0;i<=w;i++)dp[0][i]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<=w;j++){
      if(j>=x[i])dp[i+1][j]=max(dp[i][j-x[i]]+v[i], dp[i][j]);
      else dp[i+1][j]=dp[i][j];
    }
  }
  cout << dp[n][w] << endl;
  return 0;
}


Measured memory_bytes: 79872
s=input()
a=list(s)
n=len(a)
m=(n-1)//2
t='Yes'
for c in range(m):
    if a[c]!=a[m-1-c] or a[m+1+c]!=a[n-1-c] or a[c]!=a[m+1+c]:
        t='No'
        break
print(t)

Measured memory_bytes: 2940
def main():
    H,W = list(map(int, input().split()))
    s = []
    for i in range(H):
        s.append(input())

    for i in range(H):
        for j in range(W):
            if s[i][j] == ".":
                continue
            elif i==0:
                if j==0:
                    if s[i+1][j]=="." and s[i][j+1]==".":
                        return "No"
                elif j==W-1:
                    if s[i+1][j]=="." and s[i][j-1]==".":
                        return "No"
                else:
                    if s[i][j+1]=="." and s[i+1][j]=="." and s[i][j-1]==".":
                        return "No"
            elif i==H-1:
                if j==0:
                    if s[i-1][j]=="." and s[i][j+1]==".":
                        return "No"
                elif j==W-1:
                    if s[i-1][j]=="." and s[i][j-1]==".":
                        return "No"
                else:
                    if s[i-1][j]=="." and s[i][j-1]=="." and s[i][j+1]==".":
                        return "No"
            elif j==0:
                if s[i+1][j]=="." and s[i-1][j]=="." and s[i][j+1]==".":
                    return "No"
            elif j==W-1:
                if s[i+1][j]=="." and s[i-1][j]=="." and s[i][j-1]==".":
                    return "No"
            else:
                if s[i+1][j]=="." and s[i-1][j]=="." and s[i][j-1]=="." and s[i][j+1]==".":
                    return "No"
    return "Yes"

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        int red = 0;
        int blue = 0;
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == '0'){
                red++;
            }else{
                blue++;
            }
        }
        
        System.out.println(Math.min(red, blue) *2);
    }
}

Measured memory_bytes: 25928
#include <iostream>
#include <fstream>
#include <bits/stdc++.h> 
#include <string>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define S0RT(a,n) sort(a, a + n)
#define pb push_back
#define mp make_pair
#define f first
#define s second

const int MOD = 1000000007;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);

/* NOTES TO SELF:
    Int overflow? Use all ll if in doubt.
    Edge cases? (n = 1, n = 0)
*/

int a, b;
string s, t, u;

int main(){
    IOS;
    cin >> s >> t >> a >> b >> u;
    if(u == s) a--;
    if(u == t) b--;
    cout << a << " " << b;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
	int main(){
		int W , H , x , y , r;
		cin >> W >> H >> x >> y >> r;
		-100 <= x , y <= 100;
		0 < W , H , r <= 100;
		if ( x + r <= W && x - r >= 0 && y + r <= H && y - r >= 0 )
	     cout << "Yes" << endl;
	     else 
	    	   cout << "No" << endl;
	}

Measured memory_bytes: 1156
#include "bits/stdc++.h"
using namespace std;


int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	map<int, int> c;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		c[a[i]]++;
		c[a[i] - 1]++;
		c[a[i] + 1]++;
	}
	int Ma=0;
	for (auto itr = c.begin(); itr != c.end(); itr++) {
		//cout << itr->first <<" "<< itr->second << endl;
		Ma = max(Ma, itr->second);
	}
	cout << Ma << endl;
}

Measured memory_bytes: 5120
import sys
from math import gcd
def input(): return sys.stdin.readline().rstrip()

def main():
    K = int(input())
    ans = 0
    for i in range(1, K + 1):
        for j in range(1, K + 1):
            ij = gcd(i, j)
            for k in range(1, K + 1):
                ans += gcd(ij, k)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 67792
from collections import Counter
H, W = map(int, input().split())
D = []
for _ in range(H):
    D.extend(list([v for v in input()]))
C = Counter(D)
L = list([v for i, v in C.most_common()])

g1 = sum(v % 2 for v in L)
g4 = sum(v//4 for v in L)

if g4 >= (W-(W % 2))*(H-(H % 2))//4 and g1 == H & 1 & W:
    print("Yes")
else:
    print("No")


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

int main(){
int A;
cin >> A;
  string S;
  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  for(int i = 0;i < A;i++){
    cin >> S;
    if(S == "AC"){
      AC++;
    }
    if(S == "RE"){
      RE++;
    }
    if(S == "WA"){
      WA++;
    }
      if(S == "TLE"){
      TLE++;
    }
}
cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
}

Measured memory_bytes: 3624
#include <cstdio>

int main(){
    int A,B;
    scanf("%d %d",&A,&B);
    int a[3] = {A + B,A - B,A * B};
    int max = a[0];
    for(int i = 1; i < 3; i++){
        if(max < a[i]){
            max = a[i];
        }
    }
    printf("%d\n",max);

    return 0;
}

Measured memory_bytes: 256
' Imports System.Collections.Generic
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim A, B, C, K As Integer
        Dim arr() As String
        arr = Split(Console.ReadLine())
        A = arr(0) : B = arr(1) : C = arr(2) : K = arr(3)
        If K <= A Then
            Console.WriteLine(K)
        ElseIf K <= A + B Then
            Console.WriteLine(A)
        Else
            Console.WriteLine(A - (K - A - B))
        End If
        Return
    End Sub
End Class


Measured memory_bytes: 28352
import itertools
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split())) for _ in range(q)]
sumlist=[]
for A in itertools.combinations_with_replacement(range(1,m+1),n):
  sum=0
  for a,b,c,d in abcd:
    if A[b-1]-A[a-1]==c:
      sum+=d
    sumlist.append(sum)
print(max(sumlist))
      

Measured memory_bytes: 73908
double P[102][101];L[101],B[101],N,T,l,b,t,n,k;main(x){for(;scanf("%d%d%d%d",&N,&T,&l,&b),N;printf("%f\n",P[T][N])){
for(n=0;n<=N;n++)for(L[n]=B[n]=t=0;t<=T;t++)P[t][n]=0;
for(;l--;)scanf("%d",&x),L[x]=1;
for(;b--;)scanf("%d",&x),B[x]=1;
for(P[t=0][0]=1;t<T;P[t+1][N]+=P[t][N],t++)for(n=0;n<N;n++)for(k=1;k<=6;k++)x=n+k,x=B[x=x>N?2*N-x:x]?0:x,P[t+1+L[x]][x]+=P[t][n]/6;
}exit(0);}

Measured memory_bytes: 716
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
#include <cstdlib> 
#include <string>

using namespace std;

int main() {
	int a;
	string s;
	cin >>a>>s;
	if (a>=3200) cout <<s<<endl;
	else cout << "red"<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES_
#include <cmath>
#include <iostream>
#include <cstdio>

int main() {
  double r;

  std::cin >> r;

  double area;
  area = r * r * M_PI;
  double circumference;
  circumference = 2.0 * r * M_PI;

  printf("%.5f %.5f", area, circumference);

  return 0;
}

Measured memory_bytes: 3164
N, M = map(int, input().split())
A_list = list(map(int, input().split()))

toku = 0
for i in range(N):
    if (1 / (4 * M)) * sum(A_list) <= A_list[i]:
        toku += 1

if toku >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import numpy as np
from scipy.sparse.csgraph import dijkstra

N, M, L = map(int, input().split())
abc = []
for _ in range(M):
    abc.append(list(map(int, input().split())))
abc = abc

Q = int(input())
query = []
for _ in range(Q):
    query.append(tuple(map(int, input().split())))
distance = np.zeros((N, N))
for (a, b, c) in abc:
    distance[a - 1, b - 1] = c
    distance[b - 1, a - 1] = c

x = np.where(dijkstra(distance) <= L, 1, 0)
x -= np.eye(N).astype(np.int64)
x = dijkstra(x)
for s, t in query:
    ans = x[s - 1, t - 1]
    if np.isinf(ans):
        print(-1)
    else:
        print(int(ans) - 1)

Measured memory_bytes: 35176
// finish date: 2018/07/07
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>>
        vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
const int bigmod = 1000000007;
const int INF = 1050000000;


int main() {
    string S;
    cin >> S;
    int w;
    cin >> w;
    string ans = "";
    int i = 0;
    while (i < S.size()) {
        ans +=  0 + S[i];
        i += w;
    }
    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 256
h,w=map(int,input().split())
ms=[]
for i in range(h):
    m=input()
    ms.append(list(m))
count=0
for i in range(h):
    for j in range(w):
        if ms[i][j]==".":
            if i>0 and j>0:
                if ms[i-1][j-1]=="#":
                    count+=1
            if i>0 :
               if ms[i-1][j]=="#":
                    count+=1
            if i>0 and w-1>j:
                if ms[i-1][j+1]=="#":
                    count+=1
            if j>0 :
                if ms[i][j-1]=="#":
                    count+=1
            if w-1>j :
                if ms[i][j+1]=="#":
                    count+=1
            if h-1>i and j>0 :
                if ms[i+1][j-1]=="#":
                    count+=1
            if h-1>i:
                if ms[i+1][j]=="#":
                    count+=1
            if h-1>i and w-1>j:
                if ms[i+1][j+1]=="#":
                    count+=1
            ms[i][j]=str(count)
            count=0

for i in range(h):
    temp="".join([ms[i][j] for j in range(w)])
    print(temp)



Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var h = new int[n];

            var val = Console.ReadLine().Split(' ');
            for (int j = 0; j < n; j++)
            {
                h[int.Parse(val[j]) - 1] = j + 1;
            }

            Console.Write(string.Join(" ", h));

        }
    }
}


Measured memory_bytes: 26844
#!/usr/bin/env python3
import sys


def solve(S: str):
    answer = 0
    if len(S)%2 == 0:
        half  = len(S)//2
        for i in range(half,len(S)):
            if S[i] != S[len(S)-i-1]:
                answer += 1
    else:
        half  = len(S)//2
        for i in range(half+1,len(S)):
            if S[i] != S[len(S)-i-1]:
                answer += 1     
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/* 
 * Project: AtCoder Beginners Contest 150 C - Next Prime
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/23
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cmath>
using namespace std;

int x;

void solve() {

    if (x == 2 || x == 3) {
        printf("%d\n", x);
        return;
    }

    int num = x;
    while (true) {
        bool is_prime = true;
        if (num % 2 == 0)
            is_prime = false;
        for (int i=3;i*i<=num;i+=2) {
            if (num%i == 0) {
                is_prime = false;
            }
        }
        if (is_prime) {
            printf("%d\n", num);
            return;
        }
        if (num%2 == 0)
            num++;
        else
            num += 2;
    }
    
}

int main() {

    scanf("%d", &x);

    solve();

}


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

int main(){
  int D,N;
  cin>>D>>N;
  if(N!=100){
    if(D==0){
      cout<<N<<endl;
    } else if(D==1){
      cout<<N*100<<endl;
    } else {
      cout<<N*10000<<endl;
    }
  } else {
    if(D==1){
      cout<<10100<<endl;
    } else if(D==2) {
      cout<<1010000<<endl;
    } else {
      cout<<101<<endl;
    }
  }
}

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;

int32_t main(){
    fast_io;
    char c;
    cin >> c;
    int x = c - 'A';
    if(x >= 0 and x < 26){
    	show('A');
    }
    else{
    	show('a');
    }
    return 0;
}

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

typedef long long ll;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    vector<int>arr(n);
    double sum=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
    }
    sort(arr.begin(),arr.end());
    sum=(sum/(4*m));
    int ans=0;
    for(int i=n-1;i>=0;i--){
        if(arr[i]>=sum){
            ans++;
            if(ans==m)break;
        }
    }
    if(ans==m)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
a,b,c = map(int,input().split())

a_s = a**0.5
b_s = b**0.5
c_s = c**0.5

if c-a-b < 0:
    print("No")
    exit()

if 4*a*b < (c-a-b)**2:
    print("Yes")
else:
    print("No")

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

using namespace std;

int main(){

  int r, g, b;
  scanf("%d %d %d", &r, &g, &b);
  int val = 100 * r + 10 * g + b;
  if( val % 4 == 0 ) printf("YES\n");
  else printf("NO\n");
  return 0;
}

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

int main(void){
    int a,b,c;
    cin >> a >> b;
    if(a == b){
        c = 1;
    } else if(a == 2){
        c = 0;
    } else if(a == 4 || a == 6 || a == 9 || a == 11){
        if(b == 4 || b == 6 || b == 9 || b == 11)c = 1;
        else c = 0;
    } else {
        if(b == 1 || b == 3 || b == 5 || b == 7 || b == 8 || b == 10|| b == 12)c = 1;
        else c = 0;
    }
    
    if(c == 0)cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        x = self.find(x)
        return self.size[x]


def kruskal(n, edges):
    """
    Solve Minimum Spanning Tree by Kruskal's algorithm.
    :param n: Number of nodes
    :param edges: [u, v, cost]
    :return: Total cost
    """
    edges.sort(key=lambda x: x[2])
    uf = UnionFind(n)
    total_cost = 0
    for u, v, c in edges:
        if not uf.is_same(u, v):
            total_cost += c
            uf.union(u, v)
    return total_cost


N = int(input())

X, Y = [], []

for i in range(N):
    x, y = map(int, input().split())
    X.append((x, i))
    Y.append((y, i))

X.sort()
Y.sort()

edges = []

for x1, x2 in zip(X[:-1], X[1:]):
    edges.append([x1[1], x2[1], x2[0] - x1[0]])

for y1, y2 in zip(Y[:-1], Y[1:]):
    edges.append([y1[1], y2[1], y2[0] - y1[0]])

print(kruskal(N, edges))

Measured memory_bytes: 141476
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define SORT(A) sort(A.begin(), A.end())
#define SORTG(A) sort(A.begin(), A.end(), greater<int>())
#define INF 1000000000
using namespace std;
typedef long long ll;

int main()
{
    string S;
    cin >> S;
    ll n = S.size() - 1;
    ll ans = 0;
    ll dig;
    rep(bit, 1<<n)
    {
        dig = 1;
        rep(i, n+1)
        {
            ans += dig * (S.at(n-i) - '0');
            if ((bit>>i) & 1) dig = 1;
            else dig *= 10;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//be naame khodaa

#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cassert>
#include <iomanip>
#include <cstring>
#define fi first
#define se second
#define rep(i, x, n) for (int i = x; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> VI;

bool d[10];

int main()
{
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < k; i++){
		int x;
		cin >> x, d[x] = true;
	}
	for (int i = n; ; i++){
		int x = i;
		bool ok = true;
		while (x){
			ok &= (!d[x%10]);
			x /= 10;
		}
		if (ok){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
#define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<40;
const ll MOD = 1000000007;

// 直線の傾きに単調性があるときのCHT O(n)
// 最大なら <= になる
class ConvexHullTrick {
public:
  deque<PII> que;
  // ax + b を追加
  void add(int a, int b) {
    PII p(a, b);
    while(que.size() >= 2 && check(que[que.size()-2], que.back(), p)) {
      que.pop_back();
    }
    que.push_back(p);
  }
  // 単調性がある xの位置での最小のy
  int incl_query(int x) {
    assert(que.size());
    while(que.size() >= 2 && f(que[0],x) >= f(que[1],x)) {
      que.pop_front();
    }
    return que[0].first * x + que[0].second;
  }
  // 単調性なし
  int query(int x) {
    int lb = -1, ub = que.size()-2;
    while(ub-lb > 1) {
      int mid = (lb+ub)/2;
      if(isright(que[mid], que[mid+1], x)) lb = mid;
      else ub = mid;
    }
    return f(que[ub], x);
  }

  bool isright(const PII &p1, const PII &p2, int x) {
    return (p1.second-p2.second) >= x * (p2.first-p1.first);
  }
  bool check(const PII &a, const PII &b, const PII &c) {
    return (b.first-a.first)*(c.second-b.second)>=(b.second-a.second)*(c.first-b.first);
  }
  int f(const PII &p, int x) {
    return p.first * x + p.second;
  }
};

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

  ll n, c;
  cin >> n >> c;
  vector<ll> h(n);
  REP(i, n) cin >> h[i];

  vector<ll> dp(n);
  ConvexHullTrick cht;
  cht.add(-2*h[0], h[0]*h[0]);
  FOR(i, 1, n) {
    dp[i] = cht.incl_query(h[i]) + h[i]*h[i] + c;
    cht.add(-2*h[i], h[i]*h[i] + dp[i]);
  }
  cout << dp[n-1] << endl;

  return 0;
}


Measured memory_bytes: 5632
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

int main(){

    ll n,m;
    cin >> n >> m;
    vector<ll> a(n);

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

    map<ll,ll> mp;

    ll sum = 0,ans=0;
    mp[0]=1;

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

        sum += a[i];
        sum %= m;
        ans += mp[sum];
        mp[sum]++;

    }
    cout << ans << endl;


   
    return 0;
}

Measured memory_bytes: 4992
n,m=map(int,input().split())
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
    a[i]+=[sum(a[i])]
    print(*a[i])
a=list(zip(*a[::-1]))
for i in range(m):print(sum(a[i]),end=' ')
print(sum(a[m]))    


Measured memory_bytes: 5768
import java.util.*;

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

        for (int i = 1; i <= 9; i++) {
            int mod = N % i;
            if (mod == 0) {
                int div1 = N / i;
                if (div1 >=1 && div1 <= 9) {
                    System.out.println("Yes");
                    return;
                }
            }
        }

        System.out.println("No");
    }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <math.h>

int main(void){
    char moji[200002];
    scanf("%s",moji);
    int sum=0,i=0;
    while(moji[i]){
        sum+=(int)moji[i]-48;
        i++;
    }
    if(sum%9==0){
        printf("Yes");
    }else{
        printf("No");
    }
}


Measured memory_bytes: 1824
N,M=map(int,input().split())

def warshall_floyd(d):
  #d[i][j]: iからjへの最短距離
  for k in range(size_v):
    for i in range(size_v):
      for j in range(size_v):
        d[i][j]=min(d[i][j],d[i][k]+d[k][j])
  return d

abclist=[]
for i in range(M):
  a,b,c=map(int,input().split())
  abclist.append((a,b,c))
#print(graph)

size_v=N+1
dist=[[float("inf")]*size_v for i in range(size_v)] 

for a,b,c in abclist:
  dist[a][b]=c
  dist[b][a]=c
for i in range(size_v):
  dist[i][i]=0

dist=warshall_floyd(dist)
#print(dist)
  
answer_set=set()
for a,b,c in abclist:
  if dist[a][b]==c:
    answer_set.add((a,b,c))
    
print(M-len(answer_set))

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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;
    int br=0;
    cin >> s;
    for (int i=0;i<s.size();i++)
    {
        br+=(s[i]-'0');
        br%=9;
    }
    if(br==0) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3596
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


def main():
    S = input()
    MOD = 10 ** 9 + 7
    dp = [[0] * 13 for _ in range(len(S) + 1)]
    dp[0][0] = 1
    mul = 1
    for i in range(len(S)):
        x = S[-(i + 1)]
        if x == "?":
            for k in range(10):
                for j in range(13):
                    dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                    dp[i + 1][(mul * k + j) % 13] %= MOD
        else:
            k = int(x)
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= MOD
        mul = mul * 10 % 13
    print(dp[len(S)][5])


if __name__ == "__main__":
    main()


Measured memory_bytes: 61788
l, r = map(int, input().split())
if r - l < 2019:
    ans = float("inf")
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            ans = min(ans, (i * j) % 2019)
    print(ans)
else:
    print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	for (int i = 0; i < k; i++) {
		if (b <= a) {
			b *= 2;
			continue;
		}
		if (c <= b) c *= 2;
	}
	if (a < b && b < c && a < c) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

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

long long dp[100100][3];
long long a[100100][3];

int main(void){
    int n;
    std::cin >> n;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            std::cin >> a[i][j];
        }
    }

    for(int i = 0; i < n; i++){
        chmax(dp[i+1][0], dp[i][1]+ a[i][1]);
        chmax(dp[i+1][0], dp[i][2]+ a[i][2]);

        chmax(dp[i+1][1], dp[i][0]+ a[i][0]);
        chmax(dp[i+1][1], dp[i][2]+ a[i][2]);

        chmax(dp[i+1][2], dp[i][0]+ a[i][0]);
        chmax(dp[i+1][2], dp[i][1]+ a[i][1]);
    }

    long long ans = 0;

    for(int i = 0; i < 3; i++){    
        ans = std::max(ans, dp[n][i]);
    }

    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			int l = sc.nextInt();
			if (l == 0) {
				break;
			}
			int month = -1;
			int sum = 0;
			for (int i = 1; i <= 12; i++) {
				int n = sc.nextInt();
				int m = sc.nextInt();
				sum += n - m;
				if (l <= sum && month < 0) {
					month = i;
				}
			}
			if (month < 0) {
				System.out.println("NA");
			} else {
				System.out.println(month);
			}
		}
	}
}

Measured memory_bytes: 34584
N, x = (int(x) for x in input().split())
a = sorted([int(x) for x in input().split()])
for i in range(N):
    if x < a[i]:
        print(i)
        break
    else:
        if i == N-1:
            if x == a[i]:
                print(i+1)
            else:
                print(i)
        x -= a[i]


Measured memory_bytes: 2940
import java.util.Scanner;

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

		if(a>=3 && b>=3) {
			long res=0l;
			res=(a-2)*(b-2)*1l;
			System.out.println(res);
		}
		else if(a==2 || b==2) {
			System.out.println("0");
		}
		else if(a==1 && b==1){
			System.out.println("1");
		}
		else if(a==1 || b==1) {
			System.out.println(Math.max(Math.max(a-2, b-2),0));
		}
	}
}

Measured memory_bytes: 22100
def lower(A, b):
    i = -1
    j = len(A)
    while j - i > 1:
        m = (i + j) // 2
        if A[m] < b:
            i = m
        else:
            j = m
    return i + 1


def upper(C, b):
    i = -1
    j = len(C)
    #print('in upper 1', C, b)
    while j - i > 1:
        m = (i + j) // 2
        #print('in upper 2', i, m, j, C[m] > b)
        if C[m] > b:
            j = m
        else:
            i = m
    return len(C) - j


def answer(N, A, B, C):
    A.sort()
    B.sort()
    C.sort()
    #print(A)
    #print(B)
    #print(A)
    count = 0
    for b in B:
        #print(b, lower(A, b), upper(C, b))
        count += lower(A, b) * upper(C, b)
    return count


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
print(answer(N, A, B, C))


Measured memory_bytes: 23156
#include<stdio.h>
#include<cstring>
#include<algorithm> 
#include<iostream> 
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int vis[maxn];
int h[maxn];
int mx;
vector<int>v[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}
	for(int i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			vis[i]=1;
			mx=0;
			for(int j=0;j<v[i].size();j++){
				mx=max(mx,h[v[i][j]]);
			}
			if(h[i]>mx) cnt++;
		}
	}
	cout<<cnt<<endl;
}

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

vector<int> v;

vector<int> g[100001];
int vis[100001];


void dfs(int u){
	vis[u]=1;
	for(auto i:g[u]){
		if(!vis[i]) dfs(i);
	}
	v.push_back(u);
}

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

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif

	int n,m;
	cin >> n >> m;
	for(int i=0;i<m;i++){
		int a,b;
		cin >> a >> b;
		g[a].push_back(b);
	}

	for(int i=1;i<=n;i++){
		if(!vis[i]) dfs(i);
	}
	reverse(v.begin(),v.end());
	int dp[n+1];
	for(int i=1;i<=n;i++) dp[i]=0;
	int ans=0;
	for(auto i:v){
		for(auto j:g[i]){
			dp[j]=max(dp[j],1+dp[i]);
		}
	}
	for(int i=1;i<=n;i++) ans=max(ans,dp[i]);
	cout << ans;



	
	




	

}


Measured memory_bytes: 8828
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}



int main(){
    cin.tie(0);

    Int X, Y; cin >> X >> Y;
    cout << X + Y/2 << endl;
    
}


Measured memory_bytes: 888
import std.stdio, std.conv, std.string, std.format, std.algorithm;

void main()
{
  int[][] dp = new int[][]( 20001, 256 );
  int[] cs = new int[]( 16 );
  int[] xs = new int[]( 20000 );
  immutable int INF = 1UL << 30;
  while ( true ) {
	string input = readln;
	int N, M;
	formattedRead( input, "%d %d\n", &N, &M );
	if ( N == 0 && M == 0 ) break;

	foreach ( i; 0 .. M ) {
	  cs[ i ] = to!int( strip( readln ) );
	}
	foreach ( i; 0 .. N ) {
	  xs[ i ] = to!int( strip( readln ) );
	}
	
	foreach ( ary; dp[ 0 .. N + 1 ] ) ary[] = INF;
	dp[ 0 ][ 128 ] = 0;
	foreach ( i; 0 .. N ) {
	  foreach ( j; 0 .. 256 ) {
		foreach ( c; cs[ 0 .. M ] ) {
		  immutable int next = min( 255, max( 0, j + c ) );
		  dp[ i + 1 ][ next ] = min( dp[ i + 1 ][ next ], dp[ i ][ j ] + ( xs[ i ] - next ) ^^ 2 );
		}
	  }
	}
	writeln( reduce!min( dp[ N ] ) );
  }  
}

Measured memory_bytes: 45840
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> as(n);
    for(int i = 0; i < n; i++)
    {
        cin >> as[i];
    }
    //4でmodを取る
    for(auto &a : as)
    {
        a = a % 4;
    }
    //0の数，1,3の数をカウント
    int num0, num13;
    num0 = num13 = 0;
    for(auto a : as)
    {
        if(a == 0)
        {
            num0++;
        }else if(a == 1 || a == 3)
        {
            num13++;
        }
    }
    if(num0 < num13 - 1)
    {
        cout << "No" << endl;
    } else{
        int num2 = n - num0 - num13;
        int rest_num0 = num0 - (num13 - 1);
        if(num2 == 0 || rest_num0 > 0)
        {
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}


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

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

    int n, k;
    cin >> n >> k;
    map<int, int> m;
    rep(i,n){
        int a;
        cin >> a;
        
        m[a]++;
    }
    
    int ans = 0;
    
    if(m.size() > k){
        vector<int> v(m.size());
        
        int idx = 0;
        for(auto itr=m.begin(); itr!=m.end(); itr++){
            // cout << itr->first << ":" << itr->second << endl;
            
            v[idx] = itr->second;
            idx++;
        }
        sort(v.begin(), v.end());
        
        rep(i, m.size() - k){
            ans += v[i];
        }
    }
    
    cout << ans << endl;

    return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N;i ++) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());

    int sum = 0;
    for (int i = 0; i < K; i++) {
        sum += A[i];
    }
    cout << sum;
}


Measured memory_bytes: 3608
X, Y ,Z ,K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)


scores = []
for a in range(len(A)):
    for b in range(len(B)):
        if (a + 1) * (b + 1) > K:
            break
        for c in range(len(C)):
            if (a + 1) * (b + 1) * (c + 1) > K:
                break
            score = A[a] + B[b] + C[c]
            scores.append(score)

scores.sort(reverse=True)

for i in range(K):
    print(scores[i])


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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N, A, B;
ll X[100010];
ll dp[100010];

int main(){

    cin >> N >> A >> B;
    for(int i = 0; i < N; i++){
        cin >> X[i];
    }
    for(int i = 1; i < N; i++){
        dp[i] = dp[i - 1] + min((ll)B, (ll)(X[i] - X[i - 1]) * A);
    }
    cout << dp[N - 1] << endl;
    

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>

int consecutive_sum (int n)
{
    int cnt = 0;
    int max = n / 2;

    for (int i = 1; i <= max; i++)
    {
        int total = i;

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

            if (total == n)
            {
                cnt++;
            }
        }
    }

    return cnt;
}

int main ()
{
    int n = 0;
    while (std::cin >> n, n != 0)
    {
        std::cout << consecutive_sum (n) << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#define INF 2e9
using namespace std;
typedef long long ll;
int n,k;
ll data[10000];
ll s[10000];
int main(void){
	ll p=9;
	ll r;
	s[0]=1;
	for(r=1;data[r-1]<=INF;r++){
		data[r]=data[r-1]+p*r;
		s[r]=s[r-1]*10LL;
		p*=10LL;
	}
	while(1){
		scanf("%d %d",&n,&k);
		n--;
		if(n+k==-1)break;
		int g=lower_bound(data,data+r,max(n,1))-data;
		ll all=data[g-1],num=s[g-1];
		if(num<=n-g){
			num+=(n-all)/g;
			all+=((n-all)/g)*g;
		}
		int next=num+1;
		string str="";
		int nall=all;
		while(nall<=n+k){
			string kkk="";
			while(num>0){
				kkk+=num%10+'0';
				num/=10;
			}
			reverse(kkk.begin(),kkk.end());
			str+=kkk;
			num=next;
			next++;
			if(num==s[g])g++;
			nall+=g;
		}
		for(int i=0;i<k;i++){
			printf("%c",str[i+n-all]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1204
from collections import deque
import sys
input = sys.stdin.readline

def solve():
  n,q = (int(i) for i in input().split())
  graph = [[] for _ in range(n)]

  for i in range(n-1):
    a,b = (int(i) for i in input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
  ans = [0]*n
  
  for i in range(q):
    p,x = (int(i) for i in input().split())
    ans[p-1] += x

  query = [(0,-1)]
  while query:
    nowplace,parent = query.pop()
    nowvalue = ans[nowplace]   
    for node in graph[nowplace]:
      if node == parent:
        continue
      else:
        ans[node] += nowvalue
        query.append([node,nowplace])
      
  print(*ans)
  
solve()

Measured memory_bytes: 63276
n = int(input())
S = input()

R = {}
G = {}
B = {}
rc = 0
gc = 0
bc = 0

for i in range(n):
    index = i * 2
    if S[i] == 'R':
        R[index] = i
        rc += 1
    elif S[i] == 'G':
        G[index] = i
        gc += 1
    else:
        B[index] = i
        bc += 1

cnt = rc * gc * bc

for b in B:
    for g in G:
        if (B[b] + G[g]) in R:
            cnt -= 1

for r in R:
    for b in B:
        if (R[r] + B[b]) in G:
            cnt -= 1

for r in R:
    for g in G:
        if (R[r] + G[g]) in B:
            cnt -= 1

print(cnt)


Measured memory_bytes: 9400
#include<stdio.h>

int main(){
    int i,A[44];

    A[0] = A[1] = 1;

    for(i = 2;i <= 44;i++){
        A[i] = A[i-1] + A[i-2];
    }

    scanf("%d",&i);
    printf("%d\n",A[i]);

    return 0;
}



Measured memory_bytes: 2112
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class BCountBalls {
public:
    void solve(std::istream &in, std::ostream &out) {
        ll n, a, b;
        in >> n >> a >> b;
        ll res = n / (a + b) * a, r = n % (a + b);
        res += min(a, r);
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    BCountBalls solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


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

//Euclid's algorithm
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
}

int main(){
    ll r;
    cin>>r;
    double pi = 3.141592653589793238463;
    double ans = 2*pi*r; 
    cout<<ans;
}

    

Measured memory_bytes: 3788
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<sstream>
using namespace std;
int inf = 1000000000;

int main(){

  int d, n;
  cin >> d >> n;
  for(int i=0; i<d; i++){
    n *= 100;
  }
  if( d == 0 && n % 100 == 0 ) n += 1;
  if( d == 1 && n % 10000 == 0 ) n += 100;
  if( d == 2 && n % 1000000 == 0 ) n += 10000;
  cout << n << endl;

  return 0;
}



//


Measured memory_bytes: 256