akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int num(int i, int n, int s);

int main(void){
    int n, s;
    scanf("%d %d", &n, &s);
    
    while(1){
        if(n==0 && s==0) break;
        printf("%d\n", num(10,n,s));
        scanf("%d %d", &n, &s);
    }
    return 0;
}

int num(int i, int n, int s){
    int count=0;
    
    if(n==1){
        if(s<i && s>=0) return 1;
        else 0;
    }
    if(i<n) return 0;
    if(s<0) return 0;
    
    for(int j=i-1; j>=0; j--){
        count+=num(j, n-1, s-j);
    }
    
    return count;
}



Measured memory_bytes: 2036
package main

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


func main()  {
	// Alfabet 大文字のアルファベットの一巡を定数として定義
	Alfabet := strings.Split("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "")
	
	scanner := bufio.NewScanner(os.Stdin)

	// 何文字後を示すかを入力
	scanner.Scan()
	N, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	changeAlfabet := make(map[string]string, 26)

	for index, value := range Alfabet {
		targetIndex := index + N
		if targetIndex >= 26 {
			targetIndex -= 26
		}

		changeAlfabet[value] = Alfabet[targetIndex]
	}

	// アルファベット
	scanner.Scan()
	S := strings.Split(scanner.Text(), "")


	answer := ""
	for i := 0; i < len(S); i++ {
		answer += changeAlfabet[S[i]]
	}

	fmt.Println(answer)
}


Measured memory_bytes: 9208
import numpy as np
n,W,*wv=map(int,open(0).read().split())
w=np.array(wv[::2])
v=np.array(wv[1::2])
dp=np.zeros([n+1,W+1],dtype=int)
for i in range(1,n+1):
  now=np.zeros(W+1,dtype=int)
  now[w[i-1]:]=dp[i-1][:-w[i-1]]+v[i-1]
  dp[i]=np.maximum(dp[i-1],now)
print(dp[-1][-1])

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

int main() {
        int N, K, x,
            result = 0;
        double o;
        cin >> N >> K;

        o = K / 2.0;

        for (int i = 0; i < N; i++) {
                cin >> x;
                if ((o - x) >= 0) {
                        result += 2 * x;
                }
                else {
                        result += 2 * (K - x);
                }
        }
        cout << result << endl;
}


Measured memory_bytes: 256
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

char a[104];

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

    scanf("%s", a);
    ll k = gi(), res = 0;
    int l = strlen(a);
    vector<int> v;
    v.push_back(1);
    for (int i = 1; i < l; i++)
        if (a[i] == a[i-1]) {
            v[v.size()-1]++;
        } else {
            v.push_back(1);
        }

    int vl = v.size();

    if (vl == 1) {
        res = l*k/2;
    } else if (a[0] == a[l-1]) {
        for (int i = 1; i < vl-1; i++)
            res += v[i]/2;
        res *= k;
        res += v[0]/2 + v[vl-1]/2 + (k-1)*((v[0]+v[vl-1])/2);
    } else {
        for (int i = 0; i < vl; i++)
            res += v[i]/2;
        res *= k;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
r, c = map(int, input().split())
x = [];
for i in range(r):
    x.append(list(map(int, input().split())))
rsum = [0 for i in range(r)]
csum = [0 for i in range(c)]
total = 0
for i in range(r):
    for j in range(c):
        rsum[i] += x[i][j]
        csum[j] += x[i][j]
        total += x[i][j]
for i in range(r):
    for j in range(c):
        print(str(x[i][j]) + " ", end="")
    print(rsum[i])
for j in range(c):
    print(str(csum[j]) + " ", end="")
print(total)



Measured memory_bytes: 6232
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
#define ar array
const int mxN=2e5;
const int MOD=1e9+7;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{
    fastio;
    ll n,sum=0,i,j,mina=MOD,maxa=0,in=-1,c=0;
    cin>>n;
    if(n>=400&&n<=599)
    {
        cout<<8<<endl;
    }
    else if(n>=600&&n<=799)
    {
        cout<<7<<endl;
    }
    else if(n>=800&&n<=999)
    {
        cout<<6<<endl;
    }
    else if(n>=1000&&n<=1199)
    {
        cout<<5<<endl;
    }
    else if(n>=1200&&n<=1399)
    {
        cout<<4<<endl;
    }
    else if(n>=1400&&n<=1599)
    {
        cout<<3<<endl;
    }
    else if(n>=1600&&n<=1799)
    {
        cout<<2<<endl;
    }
    else if(n>=1800&&n<=1999)
    {
        cout<<1<<endl;
    }

}





Measured memory_bytes: 3632
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b,c;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	if(a==b&&b==c){
		puts("No");
		return 0;
	}
	if(a==b){
		puts("Yes");
		return 0;
	}
	if(a==c){
		puts("Yes");
		return 0;
	}
	if(b==c){
		puts("Yes");
		return 0;
	}
	puts("No");
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    ll N;
    cin >> N;
    ll tmp = 0;
    while(tmp*tmp <= N) tmp++;
    tmp--;
    cout << (tmp*tmp) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,a,i,j,x[50],xt,min,max;
  long int dp[50][5010]={};
  cin >> n >> a;
  for (i=0;i<n;i++){
    cin >> xt;
    x[i]=xt-a;
  }
  dp[0][2500]++;
  dp[0][x[0]+2500]++;
  if (x[0]>=0){
    min=2500;
    max=x[0]+2500;
  }else{
    min=x[0]+2500;
    max=2500;
  }
  for (i=1;i<n;i++){
    for (j=min;j<=max;j++) if (dp[i-1][j]){
      dp[i][j]+=dp[i-1][j];
      dp[i][j+x[i]]+=dp[i-1][j];
    }
    if (x[i]>0) max+=x[i];
    else min+=x[i];
  }
  cout << dp[n-1][2500]-1 << endl;
  return 0;
}

Measured memory_bytes: 2176
N = int(input())

if N < 2:
    print(1)
elif N >= 2 and N < 2**2:
    print(2)
elif N >= 2**2 and N < 2**3:
    print(2**2)
elif N >= 2**3 and N < 2**4:
    print(2**3)
elif N >= 2**4 and N < 2**5:
    print(2**4)
elif N >= 2**5 and N < 2**6:
    print(2**5)
elif N >= 2**6:
    print(2**6)

Measured memory_bytes: 9064
import sys


def main():
    N = int(input())
    s = list(input())
    s.append(s[0])
    s.insert(0, s[-2])

    init = ((0, 0), (0, 1), (1, 0), (1, 1))
    for i in init:
        p = [0] * (N+2)
        p[0] = i[0]
        p[1] = i[1]
        for j in range(1, N+1):
            if s[j] == "o":
                if p[j] == 0:
                    p[j+1] = p[j-1] ^ 0
                else:
                    p[j+1] = p[j-1] ^ 1
            else:
                if p[j] == 0:
                    p[j+1] = p[j-1] ^ 1
                else:
                    p[j+1] = p[j-1] ^ 0

        if p[0] == p[-2] and p[1] == p[-1]:
            ss = list(map(lambda x: "W" if x == 1 else "S", p[1:N+1]))
            print(''.join(ss))
            sys.exit()
    else:
        print(-1)


main()


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b << endl;
}


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

string s, t;
void input() { cin >> s >> t; }
void solve() {
  int ans = 0;
  rep(i, 0, s.size()) if (s[i] != t[i]) ans++;
  cout << ans << endl;
}

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

Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define db(x) cout<<#x<<"="<<x<<endl
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //y1 j0 j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;

map<int, int> res;
void prime_factors(int n) {
    for(int i = 2; i*i <= n; ++i) {
        while(n % i == 0) {
            res[i]++; // 素数i^{res[i]}
            n /= i;
        }
    }
    if(n!=1) res[n]++;
}


void Main(){

    int N; cin>>N;
    // 75=3*5*5 2,4,4,0.... or 15*5 14,4 or 25*3  24,2 or 75 75

    reps(i,1,N+1){
        prime_factors(i);
    }

    ll overs[101]={};

    reps(i,1,100){
        reps(j,1,101){
            if(res[i]>=j) ++overs[j];
        }
    }
    /*
    ll ans=overs[4]*(overs[4]-1)/2*((overs[2]-overs[4])+(overs[4]-2)/3)
    + overs[14]*((overs[4]-overs[14])+(overs[14]-1)/2)
    + overs[24]*((overs[2]-overs[24])+(overs[24]-1)/2)
    - overs[24]*((overs[4]-overs[24])+(overs[24]-1)/2)
    + overs[74];
    */
    ll ans=overs[4]*(overs[4]-1)/2*(overs[2]-2)
    + overs[14]*(overs[4]-1)
    + overs[24]*(overs[2]-1)
    + overs[74];

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

//-----------------------------------
int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int x = s.size() / 2;
	if (s.size() % 2 == 0)
	{
		string t = s.substr(0, x);
		if ((t + t) == s)
			cout << "Yes";
		else
			cout << "No";
	}
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

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

Measured memory_bytes: 764
//😄😄😄😄😄😄😄😄😄😄😄😄😄
//Apno Swagat che//
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define endl "\n"
#define debug(x) cout<<"AA Baju Smit------> "<<#x<<" -> "<<x<<endl
#define all(x) x.begin(),x.end()
#define mint map<int,int>
#define mod 10000007
#define ciN cin
#define X INT_MAX
#define N INT_MIN
////////////////////////////////////////////////////////////////
//Ha Moj Ha///
////////////////////////////////////////////////////////////////
////TEST CASES ATTACHED CHE BHULTO NAI......///////////////////
int gcd(int a, int b)
{
	if (a == 0)
		return b;
	return gcd(b % a, a);
}
vector<bool>Sieve(int n) {

	vector<bool> is_prime(n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= n; i++) {
		if (is_prime[i] && 1LL * i * i <= n) {
			for (int j = i * i; j <= n; j += i)
				is_prime[j] = false;
		}
	}
	return is_prime;
}

void jabru() {
	vector<bool>p = Sieve(1000000);
	vi xx;
	for (int i = 1; i <= 1000000; i++) {
		if (p[i])xx.pb(i);
	}
	int n; ciN >> n;
	vi v(n);
	For(i, 0, n)cin >> v[i];
	int gcc = v[0];
	mint has;
	bool is_pos = 1;
	For(i, 0, n) {
		gcc = gcd(gcc, v[i]);
		if (is_pos) {
			if (p[v[i]]) {
				if (has[v[i]] == 0)
					has[v[i]] = 1;
				else is_pos = 0;
			}
			else {
				int h = 0;
				if (v[i] > xx[xx.size() - 1])h = xx.size() - 1;
				else {
					h = lower_bound(all(xx), v[i]) - xx.begin();
				}

				for (int j = h; j > -1; j--) {
					if (v[i] % xx[j] == 0) {
						if (has[xx[j]]) {
							is_pos = 0;
							break;
						}
						else {
							has[xx[j]] = 1;
						}
					}
				}
			}

		}
	}
	if (is_pos) {
		cout << "pairwise coprime" << endl;
	}
	else if (gcc == 1) {
		cout << "setwise coprime" << endl;
	}
	else {
		cout << "not coprime" << endl;
	}

}




////////////////////////////////////////////////////////////////
//Bas aabaju nai javanu///
////////////////////////////////////////////////////////////////

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

//	int t; cin >> t;
//	while (t--)
	jabru();

	return 0;
}





///////////////////////////////////////////////////////////////////////////////////////////
//Kai baju bhai???


Measured memory_bytes: 7824
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN 100001

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
  
// Returns nCr % p using Fermat's little 
ll nCrModPFermat(ll n, ll r, ll p) 
{ 
    if(r<0 || n<r){ret0;}

   // Base case 
   if (r==0) 
      return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 

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

    ll n, k;
    cin>>n>>k;
    for(ll i=1; i<=k; i++){
        ll ans = (nCrModPFermat(n-k+1, n-k-i+1, mod) * nCrModPFermat(k-1, i-1, mod))%mod;
        print(ans);
    }
        
   
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
void decimal(int x){cout<<fixed<<setprecision(x);}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  ll n;
  string s;
  cin>>n>>s;
  ll r=0,g=0,b=0;
  rep(i,n){
    if(s[i]=='R') r++;
    else if(s[i]=='G') g++;
    else b++;
  }
  ll p=r*g*b;
  REP(j,1,(n-1)/2+1){
    rep(i,n-j*2){
      bool f=true;
      if(s[i]==s[i+2*j]) f=false;
      if(s[i]==s[i+j]) f=false;
      if(s[i+j]==s[i+j*2]) f=false;
      if(f) p--;
      //cout<<i<<j<<endl;
      //cout<<i<<i+j<<i+2*j<<endl;
    }
  }
  if(p<0) out(0);
  else out(p);
}

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


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define rep(i,n) 				for(int i=0; i<(n); ++i)
#define all(c) 				(c).begin(),(c).end()
#define sortall(x)                 sort(all(x))
#define tr(c,i) 				for( typeof( (c).begin() ) i = (c).begin();  i != (c).end(); ++i)
#define pb 					push_back
#define sz(a) 					int((a).size())
#define mp                         make_pair
#define ll                         long long
#define F                          first
#define S                          second
#define PI                         3.1415926535897932384626
// Input macros
#define s(n)                       scanf("%d",&n)
#define sc(n)                      scanf("%c",&n)
#define sl(n)                      scanf("%lld",&n)
#define sf(n)                      scanf("%lf",&n)
#define ss(n)                      scanf("%s",n)

// Others
#define test(t) 				int t; cin>>t; while(t--)
#define endl 					"\n"

using namespace std;

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

const int mod = 1000000007;
const int INF = 1e9+5;

void self_max(ll& a, ll b){
	a = max(a,b); 
}

int main(){
     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

     ll n, W;
     scanf("%lld %lld",&n,&W);
     
     vector<ll> w(n), v(n);
     
     for(ll i=0; i<n; i++){
			scanf("%lld %lld",&w[i],&v[i]);
	 }
     
     vector<ll> dp(W+1,0);
     dp[0] = 0;
     
     // dp[i] = max value you can get when you have weight limit equal to i
     
     for(int item=0 ; item<n ; item++){
		for( int weight_so_far = W-w[item] ; weight_so_far >= 0 ; --weight_so_far ){
			self_max( dp[weight_so_far + w[item]] , dp[weight_so_far] + v[item] );
		}
	 }
	 
     printf("%lld\n",dp[W]);
     

     return 0;

}
	







Measured memory_bytes: 4064
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def n_based(n:int, base:int) -> str:
    if n == 0:
        return "0"
    
    ans = ""
    res = n
    
    while abs(res) > 0:
        q = res%base
        if q>=0:
            ans = str(q) + ans
            res //= base
        else:
            q += abs(base)
            ans = str(q) + ans
            res //= base
            res += 1
        
    return ans

stf = ["7","5","3"]
n = ni()

ans = 0
for pw in range(3,11):
    for i in range(3**pw):
        s = str(n_based(i,3)).zfill(pw)
        num = ""
        for i in range(pw):
            num += stf[int(s[i])]
            
        if int(num) <= n and ("3" in num and "5" in num and "7" in num):
            ans += 1
            
print(ans)

Measured memory_bytes: 3188
//Code by 27.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath> 
#include<memory.h> 
#include<sstream>
#include<time.h>
using namespace std;
const unsigned long long BIGEST=1000000000000000+1000000000000000;
const long long BIGER=1000000000000000;
const int BIG=1000000000;
const long long MOD=19260817;
int a[100005];
int n;
int main()
{
	scanf("%d",&n);
	int t;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	int mem=-1;
	int g=0;
	for(int i=1;i<=n+1;i++)
	{
		if(mem==-1)
		{
			mem=i;
		}
		else if(a[i]!=a[mem])
		{
			if(a[mem]==i-mem);
			else if(a[mem]<i-mem)
			{
				g+=i-mem-a[mem];
			}
			else
			{
				g+=i-mem;
			}
			mem=i;
		}
	}
	cout<<g;
	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int64 sum(int64 a){
  return (a + 1) * a / 2;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 n;
  cin >> n;
  map<int64_t,int> pf = prime_factor(n);
  int64 ans = 0;
  for(auto [p, e] : pf){
    int32 l = 0;
    int32 r = INF;
    while(r - l > 1){
      int32 mid = (l + r) / 2;
      if(sum(mid) > e){
        r = mid;
      }else{
        l = mid;
      }
    }
    ans += l;
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 3652
def Fib(n):
    a, b = 0, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b
n, m = map(int, input().split())
broken = []
for i in range(m):
  broken.append(int(input()))
L = -1
intv = []
for i in broken:
  intv.append(i - L - 2)
  L = i
intv.append(n - L - 1)
res = 1
#print(intv)
if -1 in intv[1:]:
  print(0)
  exit()
dv = 10 ** 9 + 7
for i in intv:
  res *= Fib(i + 2)
  res %= dv
print(res)

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

int n;
vector<long long> a, b;

int main()
{
    cin >> n;
    a.resize(n);
    b.resize(n);
    for (int i=0; i<n; i++) cin >> a[i];
    for (int i=0; i<n; i++) cin >> b[i];

    long long sum = 0;
    for (int digit=0; digit<28+1; digit++)
    {
        // (digit桁目を求める)
        vector<long long> btrunc = b;
        for (auto &i : btrunc)
        {
            i = i & ((1<<(digit+1))-1);
        }
        sort(btrunc.begin(), btrunc.end());

        long long ans = 0;
        for (auto ai : a)
        {
            long long atmp = ai & ((1<<(digit+1))-1);
            ans += distance(lower_bound(btrunc.begin(), btrunc.end(), (1<<(digit))*1-atmp), lower_bound(btrunc.begin(), btrunc.end(), (1<<(digit))*2-atmp));
            ans += distance(lower_bound(btrunc.begin(), btrunc.end(), (1<<(digit))*3-atmp), lower_bound(btrunc.begin(), btrunc.end(), (1<<(digit))*4-atmp));
            ans = ans % 2;
        }
        sum += ans << digit;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4992
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;int a,b;cin>>n>>m>>a>>b;
	a -= n;b -= m;
	rep(i, b)cout << 'U';
	rep(i, a)cout << 'R';
	rep(i, b)cout << 'D';
	rep(i, a+1)cout << 'L';
	rep(i, b+1)cout << 'U';
	rep(i, a+1)cout << 'R';
	cout << "DR";
	rep(i, b+1)cout << 'D';
	rep(i, a+1)cout << 'L';
	cout << 'U';


	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    string a,b;
    cin>>a>>b;
    string ans="";
    REP(i,a.size()){
        cout<<a[i];
        if(i<b.size())cout<<b[i];
    }
    cout<<endl;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010
#define MAX_V MAX_N

// 1 - modK のグラフを作り最短路を求める
struct edge{ int to, cost; };
typedef pair<int, int> P;   // first は最短距離、 second は頂点の番号

int K, V;
vector<edge> G[MAX_V];      // ノード i からのびている edge の vector 。ダイクストラ前に自分で入力する
int d[MAX_V];

// 始点 s から各頂点への最短距離を求める
void dijkstra(int s) {
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));
    while(!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first){ continue; }
        REP(i, G[v].size()) {
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main()
{
    cin >> K;
    V = K;

    // グラフの構築
    for(int j = 0; j < K; j += 10) {
        for(int i = j; i < j + 10; ++i) {
            if(i >= K) { continue; }
            int to = (i + 1) % K;
            G[i].push_back({to, 1});
            to = (i * 10) % K;
            G[i].push_back({to, 0});
        }
    }

    // 1 から 0 への最短経路
    dijkstra(1);

    printf("%d\n", d[0] + 1);

    return 0;
}


Measured memory_bytes: 6780
n = int(input())
task = []
for i in range(n):
    a,b = map(int,input().split())
    task.append((a,b))
task.sort(key=lambda x:x[1])
time = 0
deadline = 0
for i in range(n):
    time += task[i][0]
    deadline = task[i][1]
    if time > deadline:
        print("No")
        exit()
print("Yes")


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

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

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

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

int main(){
    int n, k;
    cin >> n >> k;
    vi p(n);
    rep(i, n) cin >> p[i];
    double s = 0;
    rep(i, k) s+= (p[i]*(p[i]+1)/2)/(double)p[i];
    double ma = s;
    REP(i, k, n) {
        s -= (p[i-k]*(p[i-k]+1)/2)/(double)p[i-k];
        s += (p[i]*(p[i]+1)/2)/(double)p[i];
        chmax(ma, s);
    }
    cout << fixed << setprecision(15);
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision


#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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

int main() {
	ll n,m;
	cin >> n >> m;

	cout << min(n % m, m - n % m) << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a,int b){return a*b/gcd(a,b);}

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin >> n;
    if(n==1)
    {
        cout << "Hello World" << endl;
        return;
    }
    else
    {
        int a,b;
        cin >> a >> b;
        cout << a + b << endl;
    }
}

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

int main(){
  int dataset;
  int n,k;
  int x[100000+100];
  int d[100000+100];

  cin >> dataset ;
  while( dataset-- ){
    cin >> n >> k;
    cin >> x[0];
    for( int i=1;i<n;i++ ){
      cin >> x[i];
      d[i-1] = x[i]-x[i-1];
    }
    int ans = 0;
    sort( d,d+n-1 );

    int len = n-k;
    for( int i=0;i<len;i++ )
      ans += d[i];

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

Measured memory_bytes: 1644
n,a,b = map(int, input().split())

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def comb(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

def p_f(a,n,p):
    bi=str(format(n,"b"))
    res=1
    for i in range(len(bi)):
        res=(res*res) %p
        if bi[i]=="1":
          res=(res*a) %p
    return res


sm=p_f(2,n,10**9+7)-1
tmp1=comb(n,a)
tmp2=comb(n,b)

print((sm-tmp1-tmp2) % (10**9+7))

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

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

#define INF 100000000

int N;

int main()
{
	cin >> N;
	if (N == 0)
		cout << 0 << endl;
	int mod = -2;
	stack<int> s;
	while (N != 0)
	{
		if (N % mod == -1)
			s.push(1), N = (N - 1) / mod;
		else
			s.push(N % mod), N = (N - N % mod) / mod;
	}
	while (s.size() > 0)
		cout << s.top(), s.pop(); cout << endl;
}




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

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

    if (n >10) {
        cout << r << endl;
        return 0;
    }

    cout << (r + 100*(10-n)) << endl;

}

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

#define sp <<" "
#define el <<"\n"
#define S second
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define obit __builtin_popcount
#define pof pop_front
#define For(i,a,n) for(i=a;i<n;i++)
#define all(ar) ar.begin(),ar.end() 
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned short int us;
typedef short int ss;
typedef long double ld;
const ll mod = 1000000007;



int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    /*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    //*/
    int n,i;
    cin>>n;
    map<int,int> oc;
    For(i,0,n){
        int x;
        cin>>x;
        if(x+1<100000) oc[x+1]++;
        oc[x]++;
        if(x-1>=0) oc[x-1]++;
    }
    int ans = 0;
    for(auto k: oc) ans = max(ans,k.S);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	double h,w,x,y;
	cin>>h>>w>>x>>y;
	cout << h*w/2 <<" ";
	if(2*x==h&&2*y==w){
		cout << 1;
		return 00;
	}
	cout << 0;
}


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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int total, cnt;
  
  
  for (int a = 0; a <= A; a++){
    for(int b = 0; b <= B; b++){
      for(int c = 0; c <= C; c++){
        total = 500*a + 100*b + 50*c;
        if (total == X) cnt++;
      }
    }
  }
  
  cout << cnt <<endl;
}






Measured memory_bytes: 256
Q,H,S,D=map(int,input().split())
Q*=4
H*=2
a=Q*2
b=H*2
c=S*2
d=D
s=min([a,b,c,d])
p=int(input())
if p%2==0:
  print(((p//2)*s))
else:
  print((p//2)*s+min([Q,H,S]))

Measured memory_bytes: 9200
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
 in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(false);cin.tie(nullptr);
cout << fixed << setprecision(10);
    in n,x,m;
    cin>>n>>x>>m;
    if(n==1){
        cout<<x%m<<endl;
        return 0;
    }

    vector<int> mod(m,-1);
 
    MOD=m;

    int st=-1,gl=-1;
    in cnt=x%m;
    mod[cnt]=0;
    vector<in> sum(m,0);
    sum[0]=cnt;

    rep(i,m+1){
        if(mod[cnt*cnt%m]>-1){
            st=mod[cnt*cnt%m];
            gl=i;
            break;
        }
        sum[i+1]=(sum[i]+cnt*cnt%m);
        mod[cnt*cnt%m]=mod[cnt]+1;
        cnt=cnt*cnt%m;
    }


    in roop=0;
    if(st>0)roop=sum[gl]-sum[st-1];
    else roop=sum[gl];
    in roop_cnt=gl-st+1;


    if(n<=st){
        cout<<sum[n]<<endl;
        return 0;
    }
    in ans=0;
    if(st>0)ans=sum[st-1];

    n -=st;

    ans += (n/roop_cnt)*roop;
    n %= roop_cnt;
    if(st!=0)ans += sum[n+st-1]-sum[st-1];
    else if(n>0) ans += sum[n-1];

    
    cout<<ans<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 4516
DBG = !true
n,m = gets.split.map{|x| x.to_i}

seq4city = Array.new(m, 0)
cy4p = []
for i in 0...n
  cy4p << []
end

p = []
y = []
for i in 0...m
  x = gets.split.map{|x| x.to_i}
  p[i] = x[0]-1  # pref: begin-1 to begin-0
  y[i] = x[1]
  cy4p[p[i]] << [i, y[i]]
end

if DBG
  print "n:#{n} m:#{m}\n"
  print p
  print "\n"
  print y
  print "\n"
  print cy4p
  print "\n"
end

for j in 0...n
  cy4p[j].sort_by!{|x| x[1]}
  for k in 0...cy4p[j].size
    seq4city[cy4p[j][k][0]] = k
  end
end

if DBG
  print "cy4p:\n"
  print cy4p
  print "\nseq4city:\n"
  print seq4city
  print "\n"
end

for i in 0...m
  printf("%06d%06d\n", p[i]+1, seq4city[i]+1)
end


Measured memory_bytes: 26488
#include<bits/stdc++.h>
using namespace std;
int n,q,s[100010],cnt;
int srch(int key){
  int left=0,right=n;
  while(left<right){
    int mid=(left+right)/2;
    if(s[mid]==key) return 1;
    if(s[mid]<key) left=mid+1;
    else right=mid;
  }
  return 0;
}
int main(){
  cin>>n;
  for(int i=0;i<n;++i) cin>>s[i];
  cin>>q;
  for(int i=0;i<q;++i){
    int key;
    cin>>key;
    if(srch(key)) ++cnt;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3452
#include<stdio.h>
//#include<math.h>
//#include<string.h>
//#include<stdlib.h>
//#include<ctype.h>
//#include<time.h>
//#include<bits/stdc++.h>
//using namespace std;
int main()
{
	char s[13];
	scanf("%s",s);
	s[3]='8';
	printf("%s\n",s);
	return 0;
}

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

int main(){
	int n,num[200000];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>num[i];
	}
	int maxn = -2000000000,minn = num[0];
	for(int j=1;j<n;j++){
		maxn = max(maxn,num[j]-minn);
		minn = min(minn,num[j]);
	}
		cout<<maxn<<endl;
	return 0;
}


Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    string s,t;
    cin>>s>>t;
    int i,ans=0,n=s.length();
    for(i=0;i<n;i++)
    {
        if(s[i]!=t[i])
        ans++;
    }
    cout<<ans;
}

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

int main(){
	int n;
	cin >> n;
	int k;
	if(n%2==0) {
		k = n/2;
	}else {
		k = n/2+1;
	}
	printf("%.6f\n", (double)k/n);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long h,n;
  cin>>h>>n;
  long long a[n+1];
  long long sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
  //long long x=h/a;
    //if(h%a==0)
      //  cout<<x<<endl;
   // else
    if(sum>=h)
   cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;
}


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

using namespace std;

#define ll long long

int main()
{
	ll n;
	cin>>n;
	vector<pair<int,int>> v;
	for(int i = 0 ;i<n;i++)
	{
		ll a,b;
		cin>>a>>b;
		v.push_back({a,b});
	}
	bool c = true;
	for(int i = 2;i<n;i++)
	{
		if(v[i].first == v[i].second && v[i-1].first == v[i-1].second && v[i-2].first == v[i-2].second)
		{
			cout<<"Yes"<<endl;
			c = false;
			break;
		}
	}
	if(c)
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3620
def calculate(r, D, x_2000):
  result = []
  temp_result = x_2000
  for i in range(0, 10):
    temp_result = r * temp_result - D
    result.append(temp_result)
    
  return result
  
  
import sys

r=0
D=0
x_2000=0
is_arg_ok = False
try:
  num_list = input().split(' ')
  r = int(num_list[0])
  D = int(num_list[1])
  x_2000 = int(num_list[2])
  is_arg_ok = True
  
except:
  print('age,price must be numbers')
  sys.exit(1)

calculated_weights = calculate(r, D, x_2000)
for weignt in calculated_weights:
  print(weignt)
sys.exit(0)



Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#define lli long long int
#define ll long long
#define mod 1000000007
#define pii pair<int,int>
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
	int p, q, r;
	int ans = 0;
	cin >> p >> q >> r;
	if(p <= q && r <= q){
		cout << p + r;
	}
	else if(p <= r && q <= r){
		cout << p + q;
	}
	else{
		cout << q + r;
	}
	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]

AB.sort(key= lambda x:(-x[1],-x[0]))#報酬が高く、かつ、振り込みの日数が長いものからやるためのソート
memo = [0]*(10**5+1)#請け負うと決めた仕事の日のメモ。1がついている日は仕事がすでにある
work = [float('inf')]*(10**5+1)#振り込みまでに必要な日数のうち、前回請け負いを決めた日
noMore = float('inf') #これ以上の日数が振り込みにかかる仕事は受けれない
ans = 0
for a,b in AB:
    if a< noMore:#期日までに報酬が受け取れる仕事であること
        flag = 1
        for idx in range(min(M-a,work[a]),-1,-1):#この検索範囲の絞り込みがTLE解消の決め手。前回検索時に請け負った日またはM-a日以前の日
            if memo[idx] == 0:#仕事が請けられる
                ans += b#報酬を足す
                memo[idx]=1#仕事を受けたことの記録。この日はもう受けられない
                flag = 0#noMoreの更新分岐のため
                work[a] = idx#次回検索時のメモ
                break
        if flag ==1:#請けれる日が見つからなければ、今後この日数以上の日は受けれないので調べない
            noMore = a
    
print(ans)
    


Measured memory_bytes: 41260
#include<iostream>
using namespace std;
int main()
{
  int t,n,s,f;
  int sum;
  while(cin>>t,t){
    cin>>n;
    sum=0;
    for(int i=0;i<n;i++){
      cin>>s>>f;
      sum+=f-s;
    }
    if(sum<t)printf("%d\n",t-sum);
    else puts("OK");
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>

using namespace std;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<int>;


int main()
{
	string S;
	cin >> S;

	int cnt = 0;
	for(auto & c : S)
	{
		if (c == 'o')cnt++;
	}

	if (cnt + (15 - S.length()) >= 8)
	{
		cout << "YES" << endl; return 0;
	}

	cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int i,n,k;
    cin>>n>>k;
    int a[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<=n-k;i++)
    {
        if(a[i]<a[k+i])
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

const int dx[] = {0, -1, 0, 1};
const int dy[] = {-1, 0, 1, 0};

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

    int h, w;
    cin >> h >> w;
    vector<string> grid(h);
    rep(i, h) cin >> grid[i];
    int cnt = 0;
    rep(i, h) rep(j, w) if (grid[i][j] == '#') cnt++;
    if (cnt == w+h-1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}


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

#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define REP(i,a,n) for (int i=a;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define show(x) cout<<(x)<<endl
#define UM unordered_map
#define PB push_back
#define V vector
#define EPS 1e-8
typedef unsigned long ul;
typedef long long ll;
typedef string str;
/*FIN*/
int h,w,k,tb,ans;
str m[6];
V<int> ro(6,0),co(6,0);

int getcnt(int total, int rows, int cols) {
	V<bool> rplaced(6,0), cplaced(6,0);
	REP(i,0,h) {
		if(rows & (1<<i)) {
			total -= ro[i];
			rplaced[i]=1;
		}
	}

	REP(i,0,w) {
		if(cols & (1<<i)) {
			total -= co[i];
			cplaced[i]=1;
		}
	}

	REP(i,0,h) {
		REP(j,0,w) {
			if(rplaced[i] and cplaced[j]) {
				if(m[i][j] == '#') total++;
			}
		}
	}

	return total;
}

int main() {
	FAST;
	cin>>h>>w>>k;
	REP(i,0,h) cin>>m[i];
	tb=0;
	REP(i,0,h) {
		REP(j,0,w) {
			if(m[i][j] == '#') {
				ro[i]++;
				co[j]++;
				tb++;
			}
		}
	}
	
	ans=0;
	REP(i,0,1<<h) {
		REP(j,0,1<<w) {
			ans += (k == getcnt(tb,i,j));
		}
	}
	show(ans);
	return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
const int N=100010;
int n,t;
int a[N];
int main(){
	scanf("%d%d",&n,&t);
	for (int i=1; i<=n; ++i) scanf("%d",&a[i]);
	set<int> s;
	int ans=0;
	for (int i=1; i<=n; ++i){
	if (s.size()){
		ans=max(ans,a[i]-(*s.begin()));
	}
	s.insert(a[i]);
	}
	s.clear();
	int rig=0,lef=0;
	for (int i=1; i<=n; ++i){
	if (s.size()){
		if (a[i]-(*s.begin())==ans) ++rig;
	}
	s.insert(a[i]);
	}
	s.clear();
	for (int i=n; i>=1; --i){
	if (s.size()){
		if ((*s.rbegin()-a[i])==ans) ++lef;
	}
	s.insert(a[i]);
	}
	cout<<min(lef,rig);
}

Measured memory_bytes: 8760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int ,int> pairs;
int main()
{
    ll n,weight,value,a=0,b=0;
  string s;
  char c;
  cin>>s;
  for(int i=0;i<3;i++)
  {
      c=s[i];
      if(c=='A')
      {
          a++;
      }
      else b++;
  }
  if(a<=2&&a!=0)
  {
      cout<<"Yes"<<endl;
  }
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c;
    
    do{
        scanf("%d%d%d", &a, &b, &c);
        
        if(a==-1&&b==-1&&c==-1){
            break;
        }
        
        if(a==-1||b==-1){
            printf("F\n");
            continue;
        }
        
        if(a+b>=80){
            printf("A\n");
        }
        else if(a+b<80&&a+b>=65){
            printf("B\n");
        }
        else if(a+b<65&&a+b>=50){
            printf("C\n");
        }
        else if(a+b<50&&a+b>=30){
            if(c>=50){
                printf("C\n");
            }
            else{
                printf("D\n");
            }
        }
        else{
            printf("F\n");
        }
    }while(1);
    
    return 0;
}

Measured memory_bytes: 584
#include <stdio.h>
int main(void){
    int n,y,i,j,k,count=0;
    scanf("%d%d",&n,&y);
    
    for(i=0;i<n+1;i++){
        for(j=0;j<n-i+1;j++){
                k=n-i-j;
                if(10000*i+5000*j+1000*k == y){
                    count=1;
                    break;}
            if(count==1)break;
        }
        if(count==1)break;
    }
    
    if(count==1)printf("%d %d %d",i,j,k);
    else printf("-1 -1 -1");
    return 0;
}

Measured memory_bytes: 128