akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
#include<utility>
#include<list>
using namespace std;
using ll = long long;

int main(){
  ll x;
  cin >> x;
  ll ans = x/500;
  ans*=1000;
  x = x%500;
  x/=5;
  ans+=5*x;
  cout << ans << endl;
  return 0;
}

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


void solve(long long N, long long K, std::vector<long long> p){
    vector<double> E(N, 0);
    for(int i = 0; i < N; ++i){
        E[i] = (1 + (double)p[i])/2;
    }
    //for(auto i : E) cout << i << " ";
    //cout << endl;
    vector<double> cse(N+1, 0);
    for(int i = 0; i < N; ++i) cse[i+1] = cse[i] + E[i];
    //for(auto i : cse) cout << i << " ";
    //cout << endl;
    double ans = 0;
    for(int i = 0; i <= N-K; ++i){
        //cout << cse[i+K] << " " << cse[i] << endl;
        ans = max(ans, (cse[i+K]-cse[i]));
    }
    printf("%.12f", ans);
    //cout << ans << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, K, std::move(p));
    return 0;
}


Measured memory_bytes: 7968
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define LL long long


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

    int total = 0;
    for (int i=0; i <= 3000; i++) {
        if (i * r > n) {
            break;
        }
        for (int j=0; j <= 3000; j++) {
            if (i * r + j * g > n) {
                break;
            }
            int num = n - (i * r + j * g);
            if (num % b == 0) {
                total++;
            }
        }
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define MOD (int)1e9+(int)7
#define INF 2147483647
typedef long long ll;
typedef unsigned long long ull;

//dark power
//#define int ll
//define Error、大抵は、セミコロン忘れとか、Defineは関係ない
/*
vector<int> d(100000);
vector<int> b(100000);
class UnionFind{
	public:
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	signed find(signed x){
		if(d[x]==x){
			return x;
		}else{
			return d[x]=find(d[x]);
		}
	}
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	void unite(signed x,signed y){
		x=find(x);
		y=find(y);
		if(x==y)return;
		if(b[x]<b[y]){
			d[x]=y;
		}else{
			d[y]=x;
			if(b[x]==b[y])b[x]++;
		}
	}
	bool same(signed x,signed y){return (find(x)==find(y));}
};
*/
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> v(n);
	rep(i,n)cin>>v[i];
	sort(all(v));
	int a=int(v.size());
	int idx=0;
	int flag=0;
	rep(i,n-1){
		if(v[i]==v[i+1]){
			if(flag){flag=flag?0:1;continue;}
			flag=flag?0:1;
			a-=2;
		}
		if(a==1)break;
	}

	cout<<a<<endl;

	return 0;
}

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

int main(){
  int n,l,buf;
  cin>>n>>l;
  buf=1-l;
  if(buf<=1) buf=1;
  else if(buf>=n) buf=n;
  cout<<((1+n)*n)/2+(l-1)*(n-1)-buf<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) {

		try {
	        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	        String str;
			str = reader.readLine();
	        String[] arr = str.split(" ");
	        int a = Integer.parseInt(arr[0]);
	        int b = Integer.parseInt(arr[1]);
	        int c = Integer.parseInt(arr[2]);

			Main ao1_2 = new Main();

			boolean result = ao1_2.judgeThreeNumber(a,b,c);

			if(result){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}

		} catch (IOException e) {
			// TODO ????????????????????? catch ????????????
			e.printStackTrace();
		}

	}

	/**
	 *
	 * @return
	 */
	private boolean judgeThreeNumber(int a, int b, int c){

		if(a < b && b < c){
			return true;

		}
		return false;
	}

}

Measured memory_bytes: 24056
while True:
    try:
        hit = 0
        brow = 0
        Anum = list(map(int,input().split()))
        Bnum = list(map(int,input().split()))
        for i in range(4):
            if Anum[i] == Bnum[i]:
                hit += 1
            elif Bnum[i] in Anum:
                brow +=1
        print(hit,brow)
                
                       
    except EOFError:
        break

Measured memory_bytes: 7648
#include <stdio.h>
#include <stdlib.h>

int main() {
  int A, B, C;
  scanf("%d %d  %d", &A, &B, &C);
  if (A > C) {
    printf("NO\n");
  } else if (A == C){
    printf("YES\n");
  } else if (A + B >= C){
    printf("YES\n");
  } else {
    printf("NO\n");
  }
}


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

int main() {
    int A,B,M;
    cin >> A >> B >> M;
    int a[A],b[B];
    int x[M][3];
    rep(i,A){
        cin >> a[i];
    }
    rep(i,B){
        cin >> b[i];
    }
    rep(i,M){
        rep(j,3){
            cin >> x[i][j];
        }
    }

    int ans=1000000;
    rep(i,M){
        int sum=a[x[i][0]-1]+b[x[i][1]-1]-x[i][2];
        ans=min(ans,sum);
    }
    int a0=1000000;
    int b0=1000000;
    rep(i,A){
        a0=min(a0,a[i]);
    }
    rep(i,B){
        b0=min(b0,b[i]);
    }
        ans=min(ans,a0+b0);
    cout << ans << endl;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

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

struct union_find
{
	vector<int> p;

	union_find(int n) : p(n, -1) {}

	bool join(int u, int v)
	{
		if ((u = root(u)) == (v = root(v)))
			return false;
		if (p[u] > p[v])
			swap(u, v);
		p[u] += p[v];
		p[v] = u;
		return true;
	}

	int root(int u)
	{
		return p[u] < 0 ? u : p[u] = root(p[u]);
	}
};

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n, m, k;
	cin >> n >> m >> k;
	
	union_find ds(n);
	
	vector<vector<int>> g(n), G(n);
	
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		a--, b--;
		ds.join(a, b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	for(int i = 0; i < k; i++){
		int a, b;
		cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	for(int i = 0; i < n; i++){
		int ans = -ds.p[ds.root(i)] - 1;
		
		ans -= (int)g[i].size();
		
		for(auto &j : G[i])
			if(ds.root(i) == ds.root(j))
				ans--;
		
		cout << ans << " \n"[i + 1 == n];
	}

	return 0;
}


Measured memory_bytes: 12280
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
      try (Scanner sc = new Scanner(System.in)) {
        while (sc.hasNextInt()) {
               int a = sc.nextInt();
               int b = sc.nextInt();
               if (a%2==1){
               	if (b%2==1){
               		System.out.println("Odd");
               	} else {
               		System.out.println("Even");
               	}
               } else {
               	System.out.println("Even");
               }
            }
        }
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#define Max 200000
#define Min -2000000000

using namespace std;

int main() {
    int R[Max],n;

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

    int maxv=Min;
    int minv=R[0];

    for (int i = 1; i < n; ++i) {
        maxv=max(maxv,R[i]-minv);
        minv=min(minv,R[i]);
    }

    cout<<maxv<<endl;
    return 0;
}

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

const int N = 2010, INF = 0x3f3f3f3f;
int n, k;
struct edge { int y, nxt; } e[N << 1];
int X[N], Y[N], lin[N], len;
int cnt = 0, ans = INF;

inline int read() {
	int s = 0, f = 1;
	char ch;
	for(; ch < '0' || ch > '9'; ch = getchar())	if(ch == '-')	f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar())	s = (s << 1) + (s << 3) + ch - '0';
	return s * f;
}

inline void Insert(int x, int y) {
	e[++len] = (edge) { y, lin[x] };
	lin[x] = len;
}

inline void dfs(int x, int fa, int dep) {
	if(dep > k)	++cnt;
	for(int i = lin[x]; i; i = e[i].nxt) {
		int y = e[i].y;
		if(y == fa)	continue;
		dfs(y, x, dep + 1);
	}
}

int main() {
	n = read(), k = read();
	for(int i = 2; i <= n; ++i) {
		int x = read(), y = read();
		X[i] = x, Y[i] = y;
		Insert(x, y);
		Insert(y, x);
	}
	if(k & 1) {
		k >>= 1;
		for(int i = 2; i <= n; ++i) {
			cnt = 0;
			dfs(X[i], Y[i], 0);
			dfs(Y[i], X[i], 0);
			ans = min(ans, cnt);
		}
	} else {
		k >>= 1;
		for(int i = 2; i <= n; ++i) {
			cnt = 0;
			dfs(i, 0, 0);
			ans = min(ans, cnt);
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define bs(a,x) binary_search(a.begin(),a.end(),x)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mod 1000000007 
#define N 10000000
#define all(a) a.begin(),a.end()
#define point pair<ll,ll>

const int inf = 1000000007;
const ll linf = 1ll * inf * inf;
const ll MAXIMUM =1000005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

string to_str(char a)
{
    string s(1,a);
    return s;
}

int main()
{
	fio;
	string s,t;cin>>s>>t;
	pair<ll,string> dp[s.length()+1][t.length()+1];
	for(int i=0;i<=s.length();i++)
	{
		for(int j=0;j<=t.length();j++)
		{
			dp[i][j].first=0;
		}
	}
	for(int i=1;i<=s.length();i++)
	{
		for(int j=1;j<=t.length();j++)
		{
			if(s[i-1]==t[j-1])
			{
				if((dp[i-1][j-1].first+1)>=dp[i][j].first)
				{
					dp[i][j].first=dp[i-1][j-1].first+1;
					dp[i][j].second=dp[i-1][j-1].second+to_str(s[i-1]);
				}
			}
			if(dp[i-1][j].first>=dp[i][j].first)
			{
				dp[i][j].first=dp[i-1][j].first;
				dp[i][j].second=dp[i-1][j].second;
			}
			if(dp[i][j-1].first>=dp[i][j].first)
			{
				dp[i][j].first=dp[i][j-1].first;
				dp[i][j].second=dp[i][j-1].second;
			}			
		}
	}
	ll ans=-1;
	string temp;
	for(int i=0;i<=s.length();i++)
	{
		for(int j=0;j<=t.length();j++)
		{
			if(dp[i][j].first>ans)
			{
				ans=dp[i][j].first;
				temp=dp[i][j].second;
				// cout<<dp[i][j].first<<" "<<dp[i][j].second<<"   ";
			}
			// cout<<endl;
		}
	}
	// cout<<ans<<"\n";
	cout<<temp<<"\n";
}

Measured memory_bytes: 909184
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    if n%1000 == 0:
        print(0)
    else:
        print(1000-n%1000)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 68736
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N=0;
  cin >> N;
  vector<int> vec(N);
  vector<int> ans(N);
  
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  for(int k=0; k<N; k++){
     ans.at(vec.at(k)-1)=k+1;
  }
  
  for(int j=0; j<N; j++){
    cout << ans.at(j) << " ";
  }
}

Measured memory_bytes: 1536
from fractions import gcd
for _ in range(int(input())):
 a,b,c,d=list(map(int,input().split()))
 k,p=b*max((a-c-1)//b+1,1),0
 if d<b or a<k:p=1
 elif b<c+2:p=0
 elif b-c>gcd(b,d):p=1
 print("YNeos"[p::2])

Measured memory_bytes: 5344
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
char ch[N];
int num[1000];
int main()
{
    scanf("%s",ch+1);int n=strlen(ch+1);
    for(int i=1;i<=n;i++)num[ch[i]]=1;
    if((num['N']==num['S'])&&(num['W']==num['E']))printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<string, string> P;
const ll MOD = 1000000007LL;

int main() {
	int N;
	cin >> N;
	int S = 0;
	int x = N;
	while (x) {
		S += x % 10;
		x /= 10;
	}
	if (N%S == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    int ans = 0;
    int tmp = 0;
    for(int i = 0; i < N - 1; i++) {
        int sum = 0;
        if(ans >= (N - i)) {
            break;
        }
        for(int j = 1 + i; j < N; j++) {
            // cout << i << " " << j << " " << v.at(j - 1) << " " << v.at(j)
            //      << endl;
            if(v.at(j - 1) >= v.at(j)) {
                sum++;
            } else {
                break;
            }
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//約数の列挙O(√n)
vector<ll>divisor(ll n){
  vector<ll>res;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(n/i);
    }
  }
  return res;
}
int main(){
  ll n,k;cin>>n>>k;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll sum=0;
  rep(i,n)sum+=a[i];
  vector<ll>vec=divisor(sum);
  sort(vec.begin(),vec.end());
  for(ll s=vec.size()-1;s>=0;s--){
    vector<ll>surplus=a;
    rep(i,n)surplus[i]%=vec[s];
    sort(surplus.begin(),surplus.end());
    ll MIN=INF;
    rep(i,n){
      ll count=0;
      ll total=0;
      rep(j,i){
        count+=surplus[j];
        total+=surplus[j];
      }
      for(ll k=i;k<n;k++){
        count+=vec[s]-surplus[k];
        total-=vec[s]-surplus[k];
      }
      count=abs(total)+(count+1)/2;
      if(count<=k){
        cout<<vec[s]<<endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
using namespace std;

#define abs(N) ((N>0)?N:-1*N)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main(int argc, char const *argv[])
{
  long d,n,base=1;
  cin >> d >> n;

  for (int i = 0; i < d; ++i)
  {
    base *= 100;
  }
  if(n==100) n++;
  println(base*n);

  return 0;
}


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

signed main() {
  int H, A, B;
  cin >> H >> A >> B;
  int ans = 0;
  for (int i = A; i <= B; i++) {
    if (H%i == 0) ans++;
  }
  cout << ans << endl;
}



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

void fnInput(int& rnTrgSu, int& rnTrgKin)
{
  cin >> rnTrgSu >> rnTrgKin;
}

int fnRcsSch(int nTrgSu, int nTrgKin)
{
  vector<int> cnvnMoney{10000, 5000, 1000};

  int nCalKin;
  int i, j;
  for (i = 0; i <= nTrgSu; i++)
  {
    for (j = 0; j <= (nTrgSu - i); j++)
    {
      nCalKin = nTrgKin;

      nCalKin -= cnvnMoney[0] * i;
      nCalKin -= cnvnMoney[1] * j;
      nCalKin -= cnvnMoney[2] * (nTrgSu - i - j);
      if (!nCalKin)
        break;
    }
    if (!nCalKin)
      break;
  }
  if (!nCalKin)
    cout << i << " " << j << " " << (nTrgSu - i - j) << endl;
  else
    cout << -1 << " " << -1 << " " << -1 << endl;
}

int main()
{
  int nTrgSu, nTrgKin;
  
  fnInput(nTrgSu, nTrgKin);
  fnRcsSch(nTrgSu, nTrgKin);

  return 0;
}
 

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

int main(void){
    int x;
    int a,b,c;

    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;

    int A ;
    int B ;
    int C ;
    int X ;
    int cnt=0;

for(int k =  0; k <= a; k++){
    for(int j =  0; j <= b; j++){
        for(int i = 0; i <= c; i++){
        X = 500*k + 100*j + 50*i;
        if(x == X){
            cnt = cnt + 1;
        }
    }
  }
}
        
        
        cout << cnt;
    }

   


Measured memory_bytes: 256
#include <bits/stdc++.h>    
#include <unordered_map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cerr<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define endl "\n"
#define fo(i,n) for(int i=0;i<n;i++)
#define foo(i,x,n) for(int i=x;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define w(x) int x;cin>>x;while(x--)
#define display(a,n) {fo(i,n) {cout<<a[i]<<" ";}cout<<endl;}
#define fil(a,n,val) {fo(i,n) a[i]=val; }
const ll MOD   = 1000*1000*1000+7;
const ll MOD2  = 998244353;
const ll N = 1000*1000+5;
const double PI  = 3.14159265;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
ll search(vl arr, ll l, ll r, ll x){if (r >= l) {ll mid = l + (r - l) / 2;if (arr[mid] == x)return mid;if (arr[mid] > x)return search(arr, l, mid - 1, x);return search(arr, mid + 1, r, x);} return -1;}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll lcm(ll a , ll b){return (a*b)/ gcd(a,b);}
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p; } return res; }
ll modInverse(ll n, ll p){return power(n, p-2, p);}
const int maxn=3e5+5;

int main(){
	fastio();
	int N,W;
	cin>>N>>W;
	ll dp[N+1][W+1];
	ll w[N+1], v[N+1];
	foo(i,1,N+1){
		cin>>w[i]>>v[i];
	}

	fo(i,N+1){
		fo(j,W+1){
			if(i==0||j==0){
				dp[i][j]=0;
				continue;
			}

			if(w[i]>j){
				dp[i][j]=dp[i-1][j];
				continue;
			}
			dp[i][j]=max(dp[i-1][j], v[i]+dp[i-1][j-w[i]]);
		}
	}

	cout<<dp[N][W]<<endl;

}

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

typedef long long int ll;

int main()
{
    ll n, d;
    cin >> n >> d;
    vector<pair<ll,ll>> xy(n);
    for(ll i = 0;i < n;i++){
        cin >> xy[i].first >> xy[i].second;
    }

    ll ans = 0;
    for(ll i = 0;i < n;i++){
        if(d * d >= xy[i].first * xy[i].first + xy[i].second * xy[i].second){
            ans++;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 6328
import sys
input = sys.stdin.readline

N = int(input())

div = []
for i in range(1, int(N ** 0.5) + 1):
    if N % i == 0:
        div.append(i)
        
        p = N // i
        if i != p:
            div.append(p)
        
div.sort()
print(len(str(div[int(len(div) / 2)])))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int Plus_or_Minus(int a){
    if(a < 0)return -1;
    if(a == 0)return 0;
    return 1;
}

int main() {
    ll n, k, num = 0, ans = 0;
    cin >> n >> k; k--;
    vector<ll> a(n), sum(n, 0), rsum(n, 0);
    rep(i, n)cin >> a[i]; a.push_back(0);
    rep(i, n){sum[i] = a[i] * (a[i] > 0); if(i)sum[i] += sum[i-1];}
    reverse(all(a));
    rep(i, n){rsum[i] = a[i] * (a[i] > 0); if(i)rsum[i] += rsum[i-1];}
    reverse(all(a));
    reverse(all(rsum));
    ll l = 0, r = a[k];
    rep(i, k)num += a[i];
    for(int i = k-1; i < n; i++){
        ll now = 0;
        if(i-k-1 >= 0)now += sum[i-k-1];
        if(i+1 < n)now += rsum[i+1];
        if(i == k-1){
            if(Plus_or_Minus(r) == 0)now += max(0LL, num);
            else now += max(0LL, r+num);
        }else if(i == n-1){
            num += a[i] - a[i-k];
            l = a[i-k];
            if(Plus_or_Minus(l) == 0)now += max(0LL, num);
            else now += max(0LL, l+num);
        }else{
            num = num + a[i] - a[i-k];
            l = a[i-k];
            r = a[i+1];
            if(Plus_or_Minus(l) == Plus_or_Minus(r) && Plus_or_Minus(l) != 0){
                now += max({0LL, num + max({l, r, l+r}), max(l, r)});
            }
            else{
                now += max(0LL, num) + max(0LL, l) + max(0LL, r);
            }
        }
        chmax(ans, now);
    }
    cout << ans << endl;
}


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

using namespace std;

int main()
{
    long int n,k,q;
    cin>>n>>k>>q;
    int arr[n];
    int ans[q];
    
    for (int i = 0; i < n ; i++){ 
        arr[i] = k; 
    }
    
    for(int i=0;i<q;i++){
        int a;
        cin>>a;
        arr[a-1]+=1;
        
    }
    
     for(int j=0;j<n;j++){
        if((arr[j]-=q)>0)
         cout<<"Yes"<<endl;
         
        else
         cout<<"No"<<endl;
         }

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0;i<(ll)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
const ll mod=1e9+7;
const ll INF = 1e9;

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

bool is_prime(ll x){
    if(x==1) return false;
    for(ll i=2; i*i<=x;i++){
        if(x%i == 0) return false;
    }
    return true;
}

int main(){
    fast_io
    
    int k;
    cin>>k;

    queue<ll> que;
    for(int i=1;i<=9;i++) que.push(i);

    ll ans=0;
    rep(i,k){
        ll x=que.front();
        que.pop();
        if(x%10>0) que.push(x*10+x%10-1);
        que.push(x*10+x%10);
        if(x%10<9) que.push(x*10+x%10+1);
        ans=x;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n; cin>>n;
	int t;
	int i=1,cnt=0;
	For(j,0,n-1){
		cin>>t;
		if(t==i){
			cnt++; i++;
		}
	}
	if(cnt==0) cout<<"-1\n";
	else cout<<n-cnt<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define INF 20000
int g[N][N],n;

int mst(void){
  int i,j,d[n],judge[n],min,u;
  for(i=0;i<n;i++){
    d[i]=INF;
    judge[i]=1;
  }
  d[0]=0;

  while(1){
    min=INF;
    for(i=0;i<n;i++){
      if(judge[i]!=-1&&d[i]<min){
	        min=d[i];
	        u=i;
      }
    }
      if(min==INF)break;
      judge[u]=-1;
    
    for(i=0;i<n;i++){
      if(judge[i]!=-1&&g[u][i]!=-1){
        if(g[u][i]<d[i]){
          d[i]=g[u][i];
          judge[i]=0;
        }
      }
    }
  }
  min=0;
  for(i=0;i<n;i++)min+=d[i];
    return min;
}

int main(){
  int i,j,k;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&g[i][j]);
    }
  }
  k=mst();
  printf("%d\n",k);
  return 0;
}



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

using namespace std;

const int maxn = 1e9 + 6;

bool a[maxn];

int main() {

	int n; cin >> n;
	bool flag = 1;
	for (int i = 0; i < n; ++i)
	{
		int x; cin >> x;
		if (a[x]) {
			flag = 0;
			cout << "NO\n";
			return 0;
		}

		a[x] = 1;
	}

	cout << "YES\n";

	return 0;
}

Measured memory_bytes: 975360
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]
res = [1]*n
for el in ab:
  if h[el[0]-1] >= h[el[1]-1] :
    res[el[1]-1] = 0
  if h[el[0]-1] <= h[el[1]-1] :
    res[el[0]-1] = 0
print(sum(res))


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

using namespace std;
using ll = long long;

#define rep(countName, left, right, up) for (ll countName = left; countName < right; countName += up)
#define rev(countName, right, left, down) for (ll countName = right - 1; countName >= left; countName -= down)

auto solve1(int n, int k, string s)
{
    string str = s;
    str[k - 1] += 'a' - 'A';
    return str;
}

auto solve2(int n, int k, string s)
{
    string str = s;

    if (str[k - 1] == 'A')
    {
        str[k - 1] = 'a';
    }
    else if (str[k - 1] == 'B')
    {
        str[k - 1] = 'b';
    }
    else if (str[k - 1] == 'C')
    {
        str[k - 1] = 'c';
    }

    return str;
}

auto solve3(int n, int k, string s)
{

    for (int i = 0; i < n; i++)
    {
        if (i == (k - 1))
        {
            cout << (char)(s[i] + ('a' - 'A'));
        }
        else
        {
            cout << s[i];
        }
    }
    cout << endl;
}

int main(void)
{

    int n, k;
    string s;

    cin >> n >> k >> s;

    cout << solve1(n, k, s) << endl;
    //cout << solve2(n, k, s) << endl;
    //solve3(n, k, s);

    return 0;
}

Measured memory_bytes: 256
S[51*51*51*51];m[51][51];X,Y;tx,ty,kx,ky;tx2,ty2,kx2,ky2;q,s,g;move(vx,vy){int idx;tx2=tx+vx;ty2=ty+vy;kx2=kx-vx;ky2=ky-vy;if(tx2<1||tx2>X||ty2<1||ty2>Y||m[tx2][ty2])tx2=tx,ty2=ty;if(kx2<1||kx2>X||ky2<1||ky2>Y||m[kx2][ky2])kx2=kx,ky2=ky;idx=((tx2*51+ty2)*51+kx2)*51+ky2;if(!S[idx]){S[idx]=s;S[q]=idx*256+s;q=idx;}g|=tx2==kx2&&ty2==ky2;}main(){int x,y,c,t;for(;scanf("%d%d",&X,&Y),X;){scanf("%d%d%d%d",&tx,&ty,&kx,&ky);for(y=0;++y<=Y;)for(x=0;++x<=X;)scanf("%d",m[x]+y);for(move(q=s=c=g=0,0);c=!g*S[c],c>99;){s=c%256,c/=256;t=c;ky=t%51,t/=51;kx=t%51,t/=51;ty=t%51,t/=51;tx=t;if(++s<100){move(1,0),move(-1,0),move(0,1),move(0,-1);}}printf(g?"%d\n":"NA\n",s);memset(S,0,sizeof(S));}{int n;for(n=1000000;n--;)getchar();}exit(0);}

Measured memory_bytes: 26000
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;

ll dp[1001][10010][2],n;
pair<ii,ll> a[1001];

//dp[i][j][k] = miro el i, con peso maximo j, k=es el primero?

ll solve(int pos, int w, bool f){
    if(pos == n)return 0;
    ll &r = dp[pos][w][f];
    if(r >= 0) return r;
    r = solve(pos+1,w,f);
    if(f) r = max(r, a[pos].snd+solve(pos+1,a[pos].fst.snd,0));
    else if(a[pos].fst.fst <= w) 
        r = max(r, a[pos].snd+solve(pos+1,min(w-a[pos].fst.fst,a[pos].fst.snd), f));
    return r;
}

bool cmp(pair<ii,ll> &x, pair<ii,ll> &y){
    return x.fst.fst+x.fst.snd < y.fst.fst+y.fst.snd;
}

int main(){FIN;
    memset(dp,-1,sizeof(dp));
    cin >> n;
    fore(i,0,n) cin >> a[i].fst.fst >> a[i].fst.snd >> a[i].snd;
    sort(a,a+n,cmp); reverse(a,a+n);
    cout << solve(0,0,1) << endl;
}

Measured memory_bytes: 156928
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception{

        FastReader fs = new FastReader();
        out = new PrintWriter(new BufferedOutputStream(System.out));
int n = fs.nextInt();
long sum = 0 ;
        for(int i=1 ; i<=n ; i++){
            if(i%3==0 || i%5==0){

            }else{
                sum+=i;
            }
        }

        out.println(sum);












        out.close();
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    //--------------------------------------------------------
}


Measured memory_bytes: 32956
#include <bits/stdc++.h>
using namespace std;
int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}
int main(){
	ios::sync_with_stdio(false);
	string str;cin>>str;
	str[3]='8';
	cout<<str<<endl; 
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let t = sc
        .read_chars()
        .into_iter()
        .map(|c| if c == '?' { 'D' } else { c })
        .collect_vec();

    let ans = t.iter().collect::<String>();
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 2600
n = gets.to_i

def fact5(n)
  cnt = 0
  q = 5
  while q <= n
    cnt += n / q
    q *= 5
  end
  cnt
end

def dblfact5(n)
  if n.even?
    fact5(n/2)
  else
    0
  end
end

p dblfact5(n)

Measured memory_bytes: 14260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9 +7;
const ll MAXN = 1e6 + 5;

ll cnt[10][10];
bool vis[10][10];

int head(int x){
	int t=int(log10(x));
	return x/int(pow(10,t));
}

int tail(int x){
	return x%10;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;cin>>n;
	for(int i=1;i<=n;i++){
		cnt[head(i)][tail(i)]++;
	}
	ll res=0;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			if(!vis[j][i] && !vis[i][j]){
		    	vis[i][j]=vis[j][i]=1;
			    if(i==j){
				    res+=cnt[i][j]+cnt[i][j]*(cnt[i][j]-1);
			    }else{
			    	res+=cnt[i][j]*cnt[j][i]*2;
				}
			}
		}
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 640
def gi() gets.to_i end
def gs() gets.chomp end
def gim() gets.split.map(&:to_i) end
def gsm() gets.split.map(&:chomp) end
def YesNo1(bool, yes="Yes", no="No") puts (bool ? yes : no) end
def YESNO2(bool, yes="YES", no="NO") puts (bool ? yes : no) end
def sqrt(i) i ** (1.0/2) end

require "bigdecimal"
#####

x,a = gim
if x < a
  puts "0"
else
  puts "10"
end

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,ai,ans=0;
	cin >>n;
	map<int,int> mp[2];
	pair<int,int> p; 
	for(int i=0;i<n;++i){
		cin >>ai;
		++mp[i&1][ai];
	}
	pair<int,int> p1[2],p2[2];
	for(int i=0;i<2;++i){
		for(map<int,int>::iterator it=mp[i].begin();it!=mp[i].end();++it){
			p={it->second,it->first};
			if(p>p1[i])
				swap(p,p1[i]);
			if(p>p2[i])
				swap(p,p2[i]);
		}
	}
	if(p1[0].second!=p1[1].second)
		ans=p1[0].first+p1[1].first;
	else
		ans=max(p1[0].first+p2[1].first,p2[0].first+p1[1].first);
	cout <<n-ans;
}


Measured memory_bytes: 8272
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cctype>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
const int maxn = 1e6+7;

int main() {
	int n,k;
	cin>>n>>k;
	int *a=new int[n];
	for(int i=0; i<n; i++) {
		cin>>a[i];
	}
	sort(a,a+n);
	int i=n-1;
	int cnt=0;
	int sum=0;
	while(1) {
		sum+=a[i];
		i--;
		cnt++;
		if(cnt>=k) {
			break;
		}
	}
	cout<<sum<<endl;
	return 0;
}


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

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

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


int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a,b,c;
	cin >>a >>b >>c;
	if(a==b && b==c && c==a) puts("Yes");
	else puts("No");
}



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

int main()
{
	map<char,bool> qwer;
	qwer['q'] = false;
	qwer['w'] = false;
	qwer['e'] = false;
	qwer['r'] = false;
	qwer['t'] = false;
	qwer['a'] = false;
	qwer['s'] = false;
	qwer['d'] = false;
	qwer['f'] = false;
	qwer['g'] = false;
	qwer['z'] = false;
	qwer['x'] = false;
	qwer['c'] = false;
	qwer['v'] = false;
	qwer['b'] = false;

	qwer['y'] = true;
	qwer['u'] = true;
	qwer['i'] = true;
	qwer['o'] = true;
	qwer['p'] = true;
	qwer['h'] = true;
	qwer['j'] = true;
	qwer['k'] = true;
	qwer['l'] = true;
	qwer['n'] = true;
	qwer['m'] = true;

	string str;
	while(cin >> str){
		if(str[0] == '#')
			break;
		int count = 0;
		for(unsigned i=1;i<str.size();i++){
			if(qwer[str[i-1]] != qwer[str[i]])
				count++;
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;

void solve(){
	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)solve();
}


Measured memory_bytes: 3620
'use strict';
 
function Main(INPUT) {
    const input = INPUT.split("\n");
    const T = Number(input[0].split(" ")[1]);
    input.shift();
    let min = 9999;
  
    for (let i = 0; i < input.length; i++) {
        let tmp = input[i].split(" ").map(n => Number(n));
        if (tmp[1] <= T && tmp[0] < min) {
            min = tmp[0];
        }
    }
  
    console.log(min == 9999 ? "TLE" : min);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long x = sc.nextLong();

		System.out.println(countP(n, x));

	}

	private static long countP(int n, long x) {
		long pCount = 0;

		if(x <= n) {
			// 下からn枚は全部パン！
			return 0;
		}

		if(n == 0) {
			// レベル0は肉一枚！
			return 1;
		}


		// 真ん中まで入ってるか
		long half = (long)Math.pow(2, n+1) - 2;
		if(x > half) {
			// 入ってる
			// 入ってるレベルの分をカウント
			pCount += (long)Math.pow(2,n) - 1;
			if(x != half) {
				// ピッタリじゃなければ
				// 真ん中のPをカウント
				pCount++;
				long nX = x - half -1;
				// 残りを再起呼び出し
				pCount += countP(n-1, nX);
			}
		} else {
			// 入ってない
			// レベルを下げてもう一回!
			// 一番下のパンの分を1枚引く
			return countP(n-1, x-1);
		}

		return pCount;

	}



}



Measured memory_bytes: 21712
#include <iostream>
#include <climits>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n,a,b,c,ans=INT_MAX;
    cin>>n>>a>>b>>c;
    vector<int>s(n);
    for(int i=0;i<n;i++) cin>>s[i];
	for(int i=1;i<=n-2;i++){
		for(int j=1;j<=n-i-1;j++){
			for(int k=1;k<=n-i-j;k++){
				int l=n-i-j-k;
				vector<int> t;
				for(int m=1;m<=i;m++) t.push_back(1);
				for(int m=1;m<=j;m++) t.push_back(2);
				for(int m=1;m<=k;m++) t.push_back(3);
				for(int m=1;m<=l;m++) t.push_back(4);
				int x=count(t.begin(),t.end(),1);
				int y=count(t.begin(),t.end(),2);
				int z=count(t.begin(),t.end(),3);
				do{
					int one=0,two=0,three=0,mana=0;
					for(int p=0;p<n;p++){
						if(t[p]==1) one+=s[p];
						if(t[p]==2) two+=s[p];
						if(t[p]==3) three+=s[p];
					}
					if(x>1) mana+=10*(x-1);
					if(y>1) mana+=10*(y-1);
					if(z>1) mana+=10*(z-1);
					mana+=abs(one-a);
					mana+=abs(two-b);
					mana+=abs(three-c);
					if(ans>=mana) ans=mana;
				}while(next_permutation(t.begin(),t.end()));
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
int main(){
	fast;
	int n;
	cin >> n;
	ll aux = n / 500;
	ll ans = aux * 1000;
	n %= 500;
	ans += (n / 5) * 5;
	cout << ans << '\n';
	return 0;
}
    

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

using namespace std;

int main()
{

    int n, m;

    cin >> n;

    int p[n+2];
    int q = INT_MAX;

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

    int cnt = 0;

     for(int i = 0; i < n; i++)
    {
        if(p[i] < q)
        {
           cnt++;
           q = p[i];
        }
    }

    cout << cnt << endl;



    return 0;
}



Measured memory_bytes: 1024
# 深さ優先探索
from sys import stdin

N, M = map(int, stdin.readline().split())

links = [[] for _ in range(N + 1)]
for _ in range(M):
    L, R, D = map(int, stdin.readline().split())
    links[L].append((R, D))
    links[R].append((L, -D))

t = [None] * (N + 1)
for i in range(1, N + 1):
    if t[i] is not None:
        continue
    t[i] = 0
    s = [i]
    while s:
        j = s.pop()
        for k, l in links[j]:
            if t[k] is None:
                t[k] = t[j] + l
                s.append(k)
            else:
                if t[k] != t[j] + l:
                    print('No')
                    exit()
print('Yes')


Measured memory_bytes: 65888
#include<iostream>
//#include<string>

using namespace std;

int main(){
  int a[10000];
  int b[10000];
  char op[10000];

  int i;
  for(i=0;i<10000;i++){
    cin >> a[i] >> op[i] >> b[i];
    if(op[i]=='?')
      break;
  }

  for(i=0;i<10000;i++){
    if(op[i]=='+')
      cout << a[i]+b[i] << endl;
    else if(op[i]=='-')
      cout << a[i]-b[i] << endl;
    else if(op[i]=='*')
      cout << a[i]*b[i] << endl;
    else if(op[i]=='/')
      cout << a[i]/b[i] << endl;
    else
      break;
  }
}

Measured memory_bytes: 3076
<?php

fscanf(STDIN, "%d %d", $x, $y);

$flg = false;
for ($i = 0; $i <= 100; $i++) {
    for  ($j = 0; $j <= 100; $j++) {
        if ($i + $j != $x) continue;

        $tmp = 2 * $i + 4 * $j;
        if ($tmp == $y) {
            $flg = true;
            break 2;
        }
    }
}

echo $flg ? 'Yes' : 'No', PHP_EOL;


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

int main() {
    int n, m;
    cin >> n >> m;
    bool impossible = false;
    constexpr int not_set = 1000;
    auto digits = vector<int>(n, not_set);
    for (int i = 0; i < m; i++) {
        int s, c;
        cin >> s >> c;
        if (digits[n - s] != not_set && c != digits[n - s]) {
            impossible = true;
            break;
        }
        digits[n - s] = c;
    }

    // Non-zero
    if (n > 1 && digits[n - 1] == 0) {
        impossible = true;
    }

    if (impossible) {
        cout << -1;
        return 0;
    }

    for (int i = 0; i < n; i++) {
        if (digits[i] == not_set) {
            digits[i] = (n == 1 ? 0 : i == n - 1 ? 1 : 0);
        }
    }

    int answer = 0;
    int mul = 1;
    for (int i = 0; i < n; i++, mul *= 10) {
        answer += digits[i] * mul;
    }

    cout << answer;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
t,a = map(int, input().split())
h = list(map(int, input().split()))
tem = 1000 * (t-a)/6
l = []

for i in h:
    temtem = i - tem
    temAbs = abs(temtem)
    l.append(temAbs)

for j in l:
    if j == min(l):
        print(l.index(j) + 1)
        

Measured memory_bytes: 3060
def main():
    s = input()
    while s:
        if s[:7] == 'dreamer':
            if s[:10] != 'dreamerase':
                s = s[7:]
            else:
                s = s[5:]
        elif s[:5] == 'dream':
            s = s[5:]
        elif s[:6] == 'eraser':
            if s[:10] != 'eraseerase':
                s = s[6:]
            else:
                s = s[5:]
        elif s[:5] == 'erase':
            s = s[5:]
        else:
            return 'NO'
    else:
        return 'YES'





print(main())



Measured memory_bytes: 133876
k = int(input())

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

s = 0

for a in range(1, k + 1):
    #print(f'a={a}')
    s += a # 同じ数
    for b in range(a + 1, k + 1):
        if a == b:
            print(a, b)
            continue
        #print(f' b={b}', 6)
        s += 6 * gcd(a, b)
        for c in range(b + 1, k + 1):
            if a == c or b == c:
                print(a, b, c)
                continue
            #print(f'  c={c}')
            s += 6 *  gcd(a, gcd(b, c)) # 全部違う
        
print(s)


Measured memory_bytes: 9204
#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)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

string s;
int n;
int main(){
    cin>>s;
    n=s.size();
    int c1=0,c2=0;
    rep(i,n){
        if(i&1){
            if(s[i]=='0') ++c1;
            else if(s[i]=='1') ++c2;
        }
        else{
            if(s[i]=='0') ++c2;
            else if(s[i]=='1') ++c1;
        }
    }
    cout<<min(c1,c2)<<endl;
    return 0;
}


Measured memory_bytes: 512
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,K = inpl()
xx = inpl()
ans = INF
for i in range(N-K+1):
	left,right = xx[i], xx[i+K-1]

	if left*right < 0:
		MIN = min(abs(left),abs(right))
		MAX = max(abs(left),abs(right))
		tmp = MIN*2+MAX
	else:
		tmp = max(abs(left),abs(right))

	ans = min(tmp,ans)

print(ans)


Measured memory_bytes: 16032