akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
int d[10001]={0};
int f[10001]={0};

int main(){
	int n;
	while(cin>>n,n){
		vector<int>V;
		memset(d,0,sizeof(d));
		memset(f,0,sizeof(f));
		
		for(int i=1;i<n;i++){
			int t=i*i%n;
			if(f[t]==0){
				f[t]=1;
				V.push_back(t);
			}
		}
		
		
		for(int i=0;i<V.size();i++){
			for(int j=i+1;j<V.size();j++){
				int t=V[i]-V[j];
				if(t<0)t+=n;
				if(t>(n-1)/2)t=n-t;
				d[t]+=2;
			}
		}
		
		for(int i=1;i<=(n-1)/2;i++){
			cout<<d[i]<<endl;
		}
	}
	
	return 0;
}


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

a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = ii()
print(a[k-1])

Measured memory_bytes: 38384
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {


	while (1) {
		int r;
		int n;
		int xl, xr, h;
		int dp[41] = {};
		double dph[41] = {};
		double mini = 20.0;
		double minihigh = 20.0;

		cin >> r >> n;
		if (n == 0&&r==0) {
			break;
		}

		FOR(i, 1, n) {
			cin >> xl >> xr >> h;

			FOR(j, xl, xr-1) {
				if (dp[j + 20] < h) {
					dp[j + 20] = h;
				}
			}
		}

		/*for (int i = -r; i <= r-1; i++) {
			cout << i << " " << dp[i+20] << endl;
		}*/
		

		for (int i = -r; i <= r; i++) {
			double rr, xx, yy;
			if (i < 0) {
				rr = (double)r;
				xx = (double)(i+1);
				yy = sqrt(rr*rr - xx * xx);
				dph[i + 20] = dp[i + 20] +r-yy;
			}
			if (i == 0) {
				rr = (double)r;
				xx = (double)(i);
				yy = sqrt(rr*rr - xx * xx);
				dph[i + 20] = dp[i + 20] + r - yy;
			}
			if (i > 0) {
				rr = (double)r;
				xx = (double)(i);
				yy = sqrt(rr*rr - xx * xx);
				dph[i + 20] = dp[i + 20] + r - yy;
			}

		}

		//cout << endl;
		for (int i = -r; i <= r-1; i++) {
			//cout << i << " " << dph[i + 20] << endl;
			if (dph[i + 20] < mini) {
				mini = dph[i + 20];
			}
		}
		
		printf("%.5lf\n", max(mini, 0.0));
		cout << endl;
	}
	

	
	return 0;
}


Measured memory_bytes: 3204
#include<iostream>
using namespace std;
int main(){
  int n,mi = 10000000,ma = -10000000;
    long long sum = 0;
  cin >> n;
  int i,b;
  for(i = 0;i < n;i++){
    cin >> b;
    mi = min(mi,b);
    ma = max(ma,b);
    sum += b;
  }
  cout << mi <<  " " << ma << " " << sum << endl;
  return 0;
}



Measured memory_bytes: 3108
N = int(input())
S = [int(input()) for i in range(N)]
ans = sum(S)

S.sort()
if ans % 10 == 0:
    for i in range(N):
        if S[i] % 10 != 0:
            ans -= S[i]
            break
        if i == N-1: ans = 0
print(ans)

Measured memory_bytes: 3060
while 1:
  n = int(input())
  if n== 0: break
  dmax = 0
  for i in range(n):
      p, d1, d2 = map(int,input().split())
      if d1+d2>dmax:
        id,dmax=p,d1+d2
  print(id,dmax)


Measured memory_bytes: 5616
len = gets.to_i
x = gets.to_i
step_min = x
ans = -1000_000_000
(0..(len-2)).each do |i|
  y = gets.to_i
  step_min = (step_min <= x) ? step_min : x
  step_res = y - step_min
  ans = (ans >= step_res) ? ans : step_res
  x = y
end

puts ans


Measured memory_bytes: 8896
#include <stdio.h>
#include <string.h>
int n[14][14];
int m[14][14];
void search(int i,int j,int k)
{
  if(n[i-1][j] == 1 && m[i-1][j] == 0) {
    m[i-1][j] = k;
    search(i-1,j,k);
  }
  if(n[i+1][j] == 1 && m[i+1][j] == 0) {
    m[i+1][j] = k;
    search(i+1,j,k);
  }
  if(n[i][j-1] == 1 && m[i][j-1] == 0) {
    m[i][j-1] = k;
    search(i,j-1,k);
  }
  if(n[i][j+1] == 1 && m[i][j+1] == 0) {
    m[i][j+1] = k;
    search(i,j+1,k);
  }
}
int main()
{
  int i,j,k;
  char c;
  for(;;){
    memset(n,0,sizeof(n));
    memset(m,0,sizeof(m));
    for(i=1;i<=12;i++){
      for(j=1;j<=12;j++){
	if((scanf("%c",&c)) == EOF) return 0;
	n[i][j] = c-'0';
      }
      scanf("\n");
    }
    k = 1;
    for(i=1;i<=12;i++){
      for(j=1;j<=12;j++){
	if(n[i][j] == 1 && m[i][j] == 0) {
	  m[i][j] = k;
	  search(i,j,k++);
	}
      }
    }
    printf("%d\n", k-1);
    if((scanf("\n")) == EOF) return 0;
  }
}

Measured memory_bytes: 0
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <inttypes.h>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// #include <atcoder/all>
// using namespace atcoder;

using namespace std;

using ll = int64_t;
using ull = uint64_t;

[[maybe_unused]] constexpr ll LL_MAX = numeric_limits<ll>::max();
[[maybe_unused]] constexpr ll LL_MIN = numeric_limits<ll>::min();
[[maybe_unused]] constexpr ull ULL_MAX = numeric_limits<ull>::max();

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

template<typename T>
void chmin(T& x, T y) {
	x = min(x, y);
}

template<typename T>
void chmax(T& x, T y) {
	x = max(x, y);
}

ll csum(ll x, ll y) {
	if (x > 0 && y > 0 && x > LL_MAX - y) {
		return LL_MAX;
	}
	if (x < 0 && y < 0 && x < LL_MIN - y) {
		return LL_MIN;
	}
	return x + y;
}

ll readi() {
	ll ret;
	scanf("%" PRId64 "", &ret);
	return ret;
}

vector<ll> readvi(ll n) {
	vector<ll> ret(n);
	rep(i, 0, n) { ret[i] = readi(); }
	return ret;
}

string reads() {
	string s;
	cin >> s;
	return s;
}

void writei(ll x) {
	printf("%" PRId64 "\n", x);
}

void writevi(const vector<ll>& xs) {
    rep(i,0,xs.size()) {
        if (i < xs.size() - 1) {
            printf("%" PRId64 " ", xs[i]);
        } else {
            printf("%" PRId64 "\n", xs[i]);
        }
    }
}

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

int main() {
	ll N = readi();
	auto As = readvi(N);
	ll sum = 0;
	rep(i,0,N) {
		sum += As[i];
	}
	auto calc_cost = [N,&As](ll x){
		ll ans = 0;
		rep(i,0,N) {
			ans += (As[i] - x) * (As[i] - x);
		}
		return ans;
	};
	ll ans = LL_MAX;
	chmin(ans, calc_cost(sum / N));
	chmin(ans, calc_cost(sum / N + 1));
	writei(ans);
}


Measured memory_bytes: 3232
a,b,c,d,e,f = map(int,input().split())
maxa = f//(100*a)

ans = [0,0,0]
for i in range(maxa+1): # iはAの回数
    for j in range((f-100*a*i)//b+1):
        v = 100*a*i + 100*b*j
        if f < v: continue
        for k in range((f-v)//d+1):
            for l in range((f-v-k*d)//c+1,-1,-1):
                s = c*l + d*k
                if v+s > f: continue
                if v/100*e < s: continue
                if v+s == 0: continue
                if ans[0] <= 100*s/(v+s):
                    ans = [100*s/(v+s),v+s,s]
                    break
print(*ans[1:])

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

int main(){
  int N,A,B;
  cin>>N>>A>>B;
  if((B-A)%2==0){
    cout<<"Alice"<<endl;
  }else{
    cout<<"Borys"<<endl;
  }

}


Measured memory_bytes: 256
from scipy.sparse.csgraph import *;from scipy.sparse import *;H,W,*S=open(0).read().split();H,W=int(H),int(W);m=H*W;A=[]
for i in range(m):
 h,w=divmod(i,W);A=[m*2,h,m*2,w+m]+A if S[h][w]=='S' else [h,m*3,w+m,m*3]+A if S[h][w]=='T' else A+[h,w+m,w+m,h] if S[h][w]=='o' else A
f=maximum_flow(csr_matrix(([9**9]*4+[1]*(len(A)//2-4),(A[::2], A[1::2])),shape=(m*4,m*4)),m*2,m*3).flow_value;print(f if f<9**9 else -1)

Measured memory_bytes: 40808
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
map<ll,ll> mx[1000006],my[1000006];
map<ll,ll>::iterator ix,iy;
ll dp[1000006]={0};
int main(void)
{
	ll h,w,k;
	scanf("%lld%lld%lld",&h,&w,&k);
	ll x1,y1,x2,y2;
	scanf("%lld%lld%lld%lld",&x1,&y1,&x2,&y2);
	x1--,y1--,x2--,y2--;
	for(ll i=0;i<h;i++)
	{
		for(ll j=0;j<w;j++)
		{
			char ch;
			scanf(" %c",&ch);
			if(ch=='.') mx[i][j]=0,my[j][i]=0;
			else mx[i][j]=1,my[j][i]=1;
			dp[i*w+j]=1000000000;
		}
	}
	queue<pair<ll,ll> > qq;
	qq.push({x1,y1});
	mx[x1].erase(y1);
	my[y1].erase(x1);
	dp[x1*w+y1]=0;
	
	while(qq.size())
	{
		ll x=qq.front().first,y=qq.front().second;
		ll now=dp[x*w+y];//printf("0--%lld %lld %lld\n",x,y,now);
		if(x==x2&&y==y2)
		{
			printf("%lld",now);
			return 0;
		}
		ll dx,dy;
		qq.pop();
		if(mx[x].size())
		{
			ix=mx[x].lower_bound(y);
		//	printf("  ix--%lld %lld\n",ix->first,ix->second);
			while(ix!=mx[x].end()&&ix->second==0&&ix->first<=y+k)
			{
				dy=ix->first;//rintf("    1--%lld %lld\n",x,dy,ix->second);
				dp[x*w+dy]=now+1;
				ix++;
				mx[x].erase(dy);
				my[dy].erase(x);
				qq.push({x,dy});
			}
			ix=mx[x].lower_bound(y);
			if(mx[x].begin()==ix) goto out1;
			ix--;
			while(ix->second==0&&ix->first>=y-k)
			{
				dy=ix->first;//printf("    2--%lld %lld\n",x,dy);
				dp[x*w+dy]=now+1;
				if(ix==mx[x].begin())
				{			
					mx[x].erase(dy);
					my[dy].erase(x);
					qq.push({x,dy});
					break;
				}
				ix--;
				mx[x].erase(dy);
				my[dy].erase(x);
				qq.push({x,dy});
			}			
		}
		out1:
		if(my[y].size())
		{
			iy=my[y].lower_bound(x);
			//printf("  iy--%lld %lld\n",iy->first,iy->second);
			while(iy!=my[y].end()&&iy->second==0&&iy->first<=x+k)
			{
				dx=iy->first;//printf("    3--%lld %lld\n",dx,y);
				dp[dx*w+y]=now+1;
				iy++;
				my[y].erase(dx);
				mx[dx].erase(y);			
				qq.push({dx,y});
			}
			iy=my[y].lower_bound(x);
			if(my[y].begin()==iy) continue;
			iy--;
			while(iy->second==0&&iy->first>=x-k)
			{
				dx=iy->first;//printf("    4--%lld %lld\n",dx,y);
				dp[dx*w+y]=now+1;
				if(iy==my[y].begin())
				{
					my[y].erase(dx);
					mx[dx].erase(y);
					qq.push({dx,y});					
					break;
				}
				iy--;
				my[y].erase(dx);
				mx[dx].erase(y);
				qq.push({dx,y});				
			}
		}
	}
	printf("-1");
}

Measured memory_bytes: 230316
def solve(n, a):
    mod = 10 ** 9 + 7

    dp = [0] * (1 << n)
    # dp[ペアになった女の集合] = 状態数
    dp[0] = 1

    for mask in range(1, 1 << n):
        man = bin(mask).count('1') - 1
        for woman in range(n):
            if (mask >> woman) & 1 == 1 and a[man][woman] == 1:
                dp[mask] = (dp[mask] + dp[mask & ~(1 << woman)]) % mod

    return dp[(1 << n) - 1]


if __name__ == '__main__':
    n = int(input())
    a = tuple(tuple(map(int, input().split())) for _ in range(n))
    print(solve(n, a))


Measured memory_bytes: 57452
#include<iostream>
#define rep(i,n) for(int i=0;i<(int) (n);i++)
using namespace std;
int main(){
  int n,f=0;
  cin>>n;
  while(n>0){
    if(n%10==7)f=1;
    n/=10;
  }

  if(f==1)cout<<"Yes";
  else cout<<"No";
  return 0;
}


Measured memory_bytes: 3640
str = gets.split
N,M = str[0].to_i, str[1].to_i
str = gets.split
a = Array.new(N)
for i in 0...N do
    a[i] = str[i].to_i
end
a.sort!

l = a[0]
i = 1
while i < N
    if a[i] != a[i-1]
        g = a[i].gcd(l)
        l = a[i]*l/g 
    end
    i += 1
end
l /= 2
answer = M/l
answer += 1
answer /= 2
for i in 0...N do
    if l % (a[i]/2) != 0 || (l / (a[i]/2)) % 2 == 0
        answer = 0
    end
end
puts answer

Measured memory_bytes: 12564
#include "bits/stdc++.h"
#include <unordered_set>

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 1000000000
#define PI 3.14159265358979323846

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;
//==============================================

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

	int n;
	cin >> n;

	vi A(n);
	vi B(n);
	int k = -1;

	REP(i, n) {
		cin >> A[i];
		k = max(k, A[i]);
	}

	vi dp(k + 1);
	REP(i, n) dp[A[i]]++;

	REP3(i, 1, k) dp[i] += dp[i - 1];

	REP(i, n) {
		B[dp[A[i]] - 1] = A[i];
		dp[A[i]]--;
	}

	REP(i, n) {
		if (i) cout << " ";
		cout << B[i];
	}
	cout << "\n";
	return 0;
}

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

int gcd(int a,int b){
  if(b==0)return a;
  return gcd(b,a%b);
}
int main(){
  int W,H,C;
  cin>>W>>H>>C;
  int g=gcd(W,H);
  int cost=0;
  for(int i=0;i<W;i=i+g){
    for(int j=0;j<H;j=j+g){
      cost+=C;
    }
  }
  cout<<cost<<endl;
}



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

int main(void){
//input password
  char O[60],E[60];
  char dummy;
  scanf("%s",O);
  scanf("%c",&dummy);
  scanf("%s",E);

//synthesis password
  char PASS[120];
  int i;
  for(i=0;i<50;i++){
    PASS[2*i] = O[i];
    PASS[2*i + 1] = E[i];
  }
  printf("%s\n",PASS);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {

    jaldi

    string s;
    cin>>s;
    int n= s.length();
    vector<int> a(n);
    for(int i=0;i<n;i++) {
        if(s[i] == 'R') {
            a[i]=0;
        }
        else {
            a[i]=1;
        }
    }

    vector<int> temp;
    temp.clear();
    int count=0;
    for(int j=0;j<n;j++) {
        if(a[j]==0) {
            count++;
        }
        else {
            temp.push_back(count);
            count = 0;
        }
    }
    if(count!=0){
        temp.push_back(count);
    }

    if(temp.size() ==0){
        cout<<0<<'\n';
    }
    else {
        int ans= *max_element(temp.begin(),temp.end());
        cout<<ans<<'\n';
    }
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int Nmax = 1e5 + 5;

vector <int> adj[Nmax];

int sub[Nmax];
int par[Nmax];
int n,mod;

void mul(int &a, int b)
{
    a *= b;
    if (a >= mod) a %= mod;
}

void add(int &a, int b)
{
    a += b;
    if (a >= mod) a %= mod;
}

void solve_sub(int u, int p)
{
    sub[u] = 1;
    for (int v : adj[u])
    {
        if (v == p) continue;
        solve_sub(v, u);
        mul(sub[u], sub[v] + 1);
    }
}

void solve_par(int u, int p)
{
    vector <int> pre(0), suf(0);
    for (int i = 0; i < adj[u].size(); i++)
    {
        int v = adj[u][i];
        pre.push_back(1);
        suf.push_back(1);
        if (v == p) continue;
        pre.back() += sub[v];
        suf.back() += sub[v];
    }
    for (int i = 1; i < adj[u].size(); i++)
    {
        mul(pre[i], pre[i - 1]);
    }
    for (int i = (int) adj[u].size() - 2; i >= 0; i--)
    {
        mul(suf[i], suf[i + 1]);
    }
    for (int i = 0; i < adj[u].size(); i++)
    {
        int v = adj[u][i];
        if (v == p) continue;
        int a = par[u] + 1;
        int b = (i) ? pre[i - 1] : 1;
        int c = (i + 1 < adj[u].size()) ? suf[i + 1] : 1;
        par[v] = a * b % mod * c % mod;
        solve_par(v, u);
    }
}

signed main()
{
    //freopen("file.inp","r",stdin);
    cin >> n >> mod;
    for (int i = 1; i < n; i++)
    {
        int u,v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    solve_sub(1, -1);
    solve_par(1, -1);
    for (int i = 1; i <= n; i++)
    {
        cout << sub[i] * (par[i] + 1) % mod << "\n";
    }
    return 0;
}


Measured memory_bytes: 27896
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define deb(x) cout<<#x<<" = "<<x<<"\n";
#define F first
#define S second
#define mod 1000000007
signed main()
{
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//#endif
	/************************************/
	
	int n, m;
	cin>>n>>m;
	int a[n+1];
	fill(a, a+n+1, 1);
	for(int i=0; i<m; i++)
	{
		int x; cin>>x;
		a[x] = 0;
	}
	
	for(int i=2; i<=n; i++)
	{
		if(a[i]!=0) a[i] = a[i-1] + a[i-2];
		a[i] %= mod;
	}
	cout<<a[n];
	
}

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

int main ()
{
    int h,w;
    cin>> h>>w;

    vector<vector<char>> grid(h,vector<char>(w));
    vector<bool> hisw(h,0);
    vector<bool> wisw(w,0);

    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>grid.at(i).at(j);
        }
    }

    for(int i=0;i<h;i++)
    {
        bool isw=1;
        for(int j=0;j<w;j++)
        {
            if(grid.at(i).at(j)=='#')
            {
                isw=0;
                break;
            }
        }
        if (isw)
        hisw.at(i) = 1;
    }

    for(int j=0;j<w;j++)
    {
        bool isw=1;
        for(int i=0;i<h;i++)
        {
            if(grid.at(i).at(j)=='#')
            {
                isw=0;
                break;
            }
        }
        if(isw)
        wisw.at(j) =1;
    }

    for(int i=0;i<h;i++)
    {
        if(hisw.at(i))
        continue;
        for(int j=0;j<w;j++)
        {
            if(!wisw.at(j))
            cout<<grid.at(i).at(j);
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

bool non[10];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	rep(i,k){
		int d;
		cin >> d;
		non[d] = true;
	}
	for(int i = n; i <= 100000; ++i){
		int num = i;
		bool ok = true;
		while(num > 0){
			if(non[num%10]){
				ok = false;
				break;
			}
			num /= 10;
		}
		if(ok){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}


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

int main(){
  int N;
  bool flag = false;
  cin >> N;
  for(int i=0; i<26; i++){
    for(int j=0; j<100/7+1; j++){
      int sum = 4*i+7*j;
      if(sum==N){flag = true; break;}
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }
  if(!flag){
    cout << "No" << endl;
  }
  return 0;
}

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

const int N = 100005;

struct point {
  int x, y, id;

  point(double _x = 0, double _y = 0) { x = _x; y = _y; }

  void read() {
    int a, b;
    cin >> a >> b;
    x = a; y = b;
  }

  int dist(point b) {
    int dx = abs(x - b.x);
    int dy = abs(y - b.y);
    return min(dx, dy);
  }

  bool operator < (const point &p) const {
    return x < p.x || x == p.x && y < p.y;
  }
};

int i, j, n, p[N];
long long rs;
point a[N], b[N];

int pfind(int x) { return p[x] == x ? x : p[x] = pfind(p[x]); }

void punite(int x, int y) { p[pfind(x)] = pfind(y); }

int main() {
  ios_base::sync_with_stdio(0);

  cin >> n;
  for(i = 1; i <= n; ++i) a[i].read(), a[i].id = p[i] = i, b[i] = a[i];

  sort(a + 1, a + n + 1);
  sort(b + 1, b + n + 1, [](point a, point b) { return a.y < b.y || a.x == b.x && a.y < b.y; });

  set<pair<int, pair<int, int>>> S;

  for(i = 1; i < n; ++i) {
    S.insert(make_pair(a[i].dist(a[i + 1]), make_pair(a[i].id, a[i + 1].id)));
    S.insert(make_pair(b[i].dist(b[i + 1]), make_pair(b[i].id, b[i + 1].id)));
  }

  for(i = 1; i < n; ++i) {
    while(1) {
      if(!S.size()) break;
      auto it = *S.begin();
      if(pfind(it.second.first) != pfind(it.second.second)) break;
      S.erase(S.begin());
    }
    if(!S.size()) break;

    auto it = *S.begin();
    rs += it.first;
    punite(it.second.first, it.second.second);
  }

  cout << rs << '\n';

  return 0;
}

Measured memory_bytes: 17152
#include <iostream>
#include <cassert>
#include <string>
#include <functional>

using namespace std;

typedef function<int(int[3])> node_t;

string S;
size_t cur;

int andtable[3][3] = { {0,0,0},{0,1,1},{0,1,2} };
int ortable[3][3] = { {0,1,2},{1,1,2},{2,2,2} };

node_t parse(){
  char c = S[cur++];
  if(isdigit(c))
    return [=](int[3]){ return c-'0'; };
  if(isalpha(c))
    return [=](int a[3]){ return a[c-'P']; };

  node_t left = parse();
  if(c == '-')
    return [=](int a[3]){ return 2-left(a);};

  assert(c == '(');
  char op = S[cur++];
  node_t right = parse();
  ++cur;

  if(op == '*'){
    return [=](int a[3]){
      return andtable[right(a)][left(a)];
    };
  }else{
    return [=](int a[3]){
      return ortable[right(a)][left(a)];
    };
  }
}

int solve(){
  cur = 0;
  auto tree = parse();
  int count = 0;
  for(int p:{0,1,2}){
    for(int q:{0,1,2}){
      for(int r:{0,1,2}){
        int a[] = {p,q,r};
        if(tree(a)==2) ++ count;
      }
    }
  }
  return count;
}
int main(){

  while(cin>>S&&S[0]!='.')
    cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 3184
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int K = s.nextInt();
		int[] H = new int[N];
		for(int i = 0; i < N; i++) {
			H[i] = s.nextInt();
		}
		
		int[] result = new int[N];
		result[0] = 0;
		for(int i = 1; i < N; i++) {
			result[i] = result[i - 1] + Math.abs(H[i] - H[i - 1]);
		}
		for(int n = 0; n < N; n++) {
			for(int k = 1; k < K + 1; k++) {
				if(n + k >= N)
					continue;
				result[k + n] = Math.min(result[n] + Math.abs(H[n] - H[n + k]), result[k + n]);
			}
		}
		System.out.println(result[N-1]);
    }
}

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

int main() {
  string s;
  cin >> s;
  int Q;
  cin >> Q;

  bool rev = false;
  string left, right;
  for (int i = 0; i < Q; ++i) {
    int T;
    cin >> T;
    if (T == 1) {
      rev = !rev;
    } else {
      int F;
      cin >> F;
      string& dst = (!rev ? (F == 1 ? left : right) : (F == 1 ? right : left));

      string c;
      cin >> c;
      dst += c;
    }
  }

  if (!rev) {
    reverse(left.begin(), left.end());
    cout << left + s + right << endl;
  } else{
    reverse(right.begin(), right.end());
    reverse(s.begin(), s.end());
    cout << right + s + left << endl;
  }
  return 0;
}

Measured memory_bytes: 1348
import java.util.Scanner;

public class Main {
	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong(), k = sc.nextLong();
		if (n % k == 0) {
			System.out.println(0);
		} else {
			System.out.println(Math.min(n % k, Math.abs(k - n % k)));
		}
	}
}


Measured memory_bytes: 23380
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;
using P = pair<int64,int64>;

int main() {
    int h,w,m;
    cin >> h >> w >> m;

    set<P> hw;
    map<int,int> hmp;
    map<int,int> wmp;

    int hmax = -1;
    int wmax = -1;
    for (int i=0; i<m; i++) {
        int hi,wi;
        cin >> hi >> wi;
        if (hi < 0 || 300000 < hi) return 1;
        if (wi < 0 || 300000 < wi) return 1;
        hmp[hi]++;
        wmp[wi]++;
        hmax = max(hmax, hmp[hi]);
        wmax = max(wmax, wmp[wi]);
        hw.insert({hi,wi});
    }
    if (hmax < 0 || wmax < 0) return 1;


    vector<int> a;
    for (auto [hi,c] : hmp) {
        if (c>=hmax) a.emplace_back(hi);
    }

    
    vector<int> b;
    for (auto [wi,c] : wmp) {
        if (c>=wmax) b.emplace_back(wi);
    }

    int ans = hmax + wmax - 1;
    for (auto ai : a) {
        for (auto bi : b) {
            cerr<<ai<<" "<<bi<<endl;
            if (hw.find({ai,bi}) == hw.end()){
                ans = hmax + wmax;
                goto exit;
            }
        }
    }

    exit:
    cout << ans << endl;
}

Measured memory_bytes: 53840
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int main(void){
    int k,mx,mi;
    cin>>k>>mi>>mx;
    while(1){
        if(mi%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
        mi++;
        if(mi>mx){
            break;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}


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

void all_perm(int *elem, int n, function<void(int *)> f)
{
    do{
        f(elem);
    } while(next_permutation(elem, elem + n));
}

void rec_comb(int *elem, int n, int k, function<void(int *)> f)
{
    if(k == 0) f(elem);
    else if(n < 0) return;
    else
    {
        rec_comb(elem, n - 1, k, f);
        elem[k - 1] = n;
        rec_comb(elem, n - 1, k - 1, f);
    }    
}

void comb(int n, int k, function<void(int *)> f)
{
    int t_elem[k];
    rec_comb(t_elem, n - 1, k, f);
}

void perm(int *elem, int n, int k, function<void(int *)> f)
{
    comb(n, k, [&](int *t_elem) {
        all_perm(elem, k, [&](int *p_elem) {
            int elems[k];
            for(int i = 0; i < k; i++) elems[i] = t_elem[p_elem[i]];
            f(elems);
        });
    });
}

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

    int D[C][C];
    int c[N][N];
    for(int i = 0; i < C; i++)
        for(int j = 0; j < C; j++)
            cin >> D[i][j];

    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            cin >> c[i][j];

    int s[C][3];
    int p[C];
    for(int i = 0; i < C; i++)
    {
        s[i][0] = s[i][1] = s[i][2] = 0;
        p[i] = i;
    }

    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            for(int k = 0; k < C; k++)
            {
                int g = ((i + 1) + (j + 1)) % 3;
                s[k][g] += D[c[i][j] - 1][k];
            }
        }
    }

    int ans = INT_MAX;
    perm(p, C, 3, [&](int *elem) {
        int sum = s[elem[0]][0] + s[elem[1]][1] + s[elem[2]][2];
        if(ans > sum) ans = sum;
    });
    cout << ans << endl;
}

Measured memory_bytes: 1280
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def dfs(v, p=-1):
    for u in to[v]:
        if u == p:
            continue
        c[u] += c[v]
        dfs(u, v)


N, Q = map(int, input().split())
to = [[] for i in range(N)]  # 隣接リスト
c = [0] * N

for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)

for i in range(Q):
    p, x = map(int, input().split())
    p -= 1
    c[p] += x
dfs(0)
print(*c)



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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int N = 2000;
const int M = 8192;

int n, a[N], b[N], cost[N];
vector<vi> e;

int parent[11][N];
int depth[N];

int euler[2*N], sz;
int pos[N][2];


int seg_sz = 1;
ll dat[2*M];
inline ll query(int a, int b, int k, int l, int r){
	
	if(b <= l || a >= r) return 0;
	if(a <= l && r <= b) return dat[k];
	
	ll lch = query(a, b, k * 2 + 1, l, (l + r) / 2);
	ll rch = query(a, b, k * 2 + 2, (l + r) / 2, r);
	
	return lch + rch;
}
inline void update(int pos, int d){
	
	pos += seg_sz - 1;
	dat[pos] += d;
	
	while(1){
		if(pos == 0) break;
		pos = (pos - 1) / 2;
		dat[pos] = dat[pos * 2 + 1] + dat[pos * 2 + 2];
	}
}

void dfs(int c, int p, int d = 1){
	
	depth[c] = d;
	parent[0][c] = p;
	dat[seg_sz - 1 + sz] = cost[c];
	euler[sz] = c;
	pos[c][0] = sz++;
	
	rep(i, e[c].size()){
		int id = e[c][i];
		int to = id < 0 ? a[-id - 1] : b[id - 1];
		
		if(to != p) dfs(to, c, d + 1);
	}
	
	dat[seg_sz - 1 + sz] = -cost[c];
	euler[sz] = c;
	pos[c][1] = sz++;
}

inline int lca(int a, int b){
	if(depth[a] < depth[b]) swap(a, b);
	
	for(int i = 10; i >= 0; i--) if(depth[a] - depth[b] >> i & 1) a = parent[i][a];
	
	if(a == b) return a;
	
	for(int i = 10; i >= 0; i--) if(parent[i][a] != parent[i][b]){
		
		a = parent[i][a];
		b = parent[i][b];
	}
	return parent[0][a];
}

int main(){
	
	scanf("%d", &n);
	e.resize(n);
	
	rep(i, n) scanf("%d", cost + i);
	rep(i, n - 1){
		scanf("%d%d", a + i, b + i);
		a[i]--; b[i]--;
		
		e[a[i]].pb(i + 1);
		e[b[i]].pb(-i - 1);
	}
	
	for(; seg_sz < 2 * n; seg_sz *= 2);
	
	dfs(0, 0);
	
	rep(i, 10) rep(j, n) parent[i + 1][j] = parent[i][parent[i][j]];
	
	for(int i = seg_sz - 2; i >= 0; i--){
		
		dat[i] = dat[i * 2 + 1] + dat[i * 2 + 2];
	}
	
	#if 0
	rep(i, seg_sz) cerr<<dat[seg_sz - 1 + i]<<" ";cerr<<endl;
	rep(i, n) cerr<<pos[i][0]<<" "<<pos[i][1]<<endl;
	cerr<<"---"<<endl;
	#endif
	
	int qs; scanf("%d", &qs);
	
	while(qs--){
		int x, y, z;
		scanf("%d%d%d", &x, &y, &z);
		
		if(x == 0){
			y--; z--;
			
			int p = lca(y, z);
			ll ans = 0;
			
			ans += query(0, pos[y][0] + 1, 0, 0, seg_sz);
			ans += query(0, pos[z][0] + 1, 0, 0, seg_sz);
			ans -= query(0, pos[p][0] + 1, 0, 0, seg_sz) * 2;
			ans += dat[seg_sz - 1 + pos[p][0]];
			
			printf("%lld\n", ans);
		}
		else{
			y--;
			update(pos[y][0], z);
			update(pos[y][1], -z);
		}
	}
	
	return 0;
}


Measured memory_bytes: 1660
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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


const int MOD = 1000000007;
const int nMax = 1000000;

long long fact[nMax];  // Array of Factorial
long long invFact[nMax]; // Array of Factorial of Inverse Elements
long long inv[nMax]; // Array of Inverse Elements

void calcFact(){
    fact[0] = 1; fact[1] = 1;
    invFact[0] = 1; invFact[1] = 1;
    inv[1] = 1;     //1に対する逆元は1
    
    for(int i = 2; i < nMax; i++){
        fact[i] = fact[i-1] * i % MOD;
        inv[i] = (- inv[MOD % i] * (MOD/i) ) % MOD + MOD;
        invFact[i] = invFact[i-1] * inv[i] % MOD;
    }   
}
    
long long calcComb(long long _n, long long _k){
    if (_n < 0 || _k < 0) return 0;
    if (_n < _k) return 0;
    return fact[_n] * (invFact[_n-_k] * invFact[_k] % MOD) % MOD;
}



int main(){
  long long N, M;
  cin >> N >> M;
  calcFact();

  long long ans = 1;
  
  for(long long i = 2; i <= M; i++){
      if(M%i == 0){
          long long cnt = 0;
          while(M%i == 0){
              cnt++;
              M/=i;
          }
          ans *= calcComb(N+cnt-1, N-1);
          ans %= MOD;
      }
  }
  
  cout << ans << endl;

  return 0;
}




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

int main() {
  int a, b;
  cin >> a >> b;
  if (a * b % 2 == 0) cout << "Even" << endl;
  else cout << "Odd" << endl;
}

Measured memory_bytes: 256
// 課題2_3
// nk777

#include <stdio.h>

int main(void){
    // N*Nのマス目があり、Aマスを白色に塗る
    int N, A;

    // N, Aの入力を受け取る
    scanf("%d %d", &N, &A);

    // 黒色になるマス目はN*N-Aを出力
    printf("%d\n", N * N - A);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v;
    vector<double> x(n), y(n);
    int tmp = 1;
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
        v.emplace_back(i);
        tmp *= i + 1;
    }
    double ans = 0;
    do {
        for(int i : v){
            if(i == 0) continue;
            ans += sqrt(pow(x[v[i]]-x[v[i-1]], 2) + pow(y[v[i]]-y[v[i-1]], 2));
        }
        // cout << ans << endl;
    } while(next_permutation(v.begin(), v.end()));
    cout << fixed << setprecision(10) << ans / tmp;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e9+10;
const ll N = 1e5+3;
const ll MOD = 1e9+7;
int n, ans, cnt, dist[50][N];
void check() {
    deque<pair<int,int>> q;
    q.push_back({1, 1});
    dist[1][1] = 1;
    while(!q.empty()) {
        int sum = q.front().first, mod = q.front().second;
        if(mod == 0) {
            ans = sum;
            break;
        }
        //printf("%d %d\n", sum, mod);
        q.pop_front();
        if(dist[sum+1][(mod * 10 + 1) % n] == 0)q.push_back({sum + 1, (mod * 10 + 1) % n}), dist[sum+1][(mod * 10 + 1) % n] = dist[sum][mod] + 1;
        if(dist[sum][(mod * 10) % n] == 0)q.push_front({sum, (mod * 10) % n}),dist[sum][(mod * 10) % n] = dist[sum][mod] + 1;
    }
}
int main()
{   
    scanf("%d", &n);
    int temp = n;
    while(temp != 0) {
        cnt++;
        temp /= 10;
    }
    check();
    printf("%d\n",ans );
    return 0;

}
 

Measured memory_bytes: 18308
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll X, K, D;
    cin >> X >> K >> D;
    ll l = abs(X / D);
    ll r = l + 1;
    if (K < l) cout << abs(abs(X) - K*D) << '\n';
    else if (K % 2 == l % 2) cout << abs(abs(X) - l*D) << '\n';
    else cout << abs(abs(X) - r*D) << '\n';
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d %d", &a, &b)
#define sc3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define pri(x) printf("%d\n", x)
#define prie(x) printf("%d ", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define db(x) cerr<< #x <<" == "<< x <<endl;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const ld pi = acos(-1);
const int MOD = 1e9+7;
int n;
ll v[100010];
ll simula(ll x){
	for(int i=0;i<n;i++){
		ll y = x/v[i];
		x = y*v[i];
	}
	return x;
}

ll bb(ll b, ll e){
	if(b==e) return b;
	ll m = (b+e+1)/2;
	if(simula(m) <2 ) return bb(m, e);
	return bb(b, m-1);
}

ll bb2(ll b, ll e){
	if(b==e) return b;
	ll m = (b+e)/2;
	if(simula(m) >2) return bb2(b,m);
	return bb2(m+1, e);
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++) cin>>v[i];
	ll x1 = bb(0,1e18);
	ll x2 = bb2(0,1e18);
	x1++, x2--;
	if(simula(x1) != 2) x1 = -1;
	if(simula(x2) != 2) x2 = -1;
	if(x1==-1 or x2==-1 or x1<0 or x2<0) cout<<x1<<endl;
	else cout<<x1<<" "<<x2<<endl;
	return 0;
}


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

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

const ll INF = 1LL << 60;

int main(){
  int n,x,v;
  bool b=1,c=1;
  cin >> n >> x;
  int a[1000];
  FOR(i,n){
    cin >> a[i];
  }
  sort(a,a+n);
  FOR(i,n){
    x-=a[i];
    if(x<0){
      v=i;
      b=0;
      c=0;
      break;
    }
  }
  if(c)v=n;
  if(x!=0 && b){
    v-=1;
  }
  cout << v << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
string s1,s2;
int main(){
	cin>>s1>>s2;
	int len=s1.length();
	for(int i=0;i<len;i++){
		if(s1[i]!=s2[i]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 3624
def gcd(x,y):
  if y == 0:
    return x
  else:
    return gcd(y,x%y)
a,b,c,d = map(int, input().split())
p = b//c + (-a//c) +1
q = b//d + (-a//d) +1
r = b*gcd(c,d)//(c*d) + (-a*gcd(c,d)//(c*d)) +1
print(b-a+1-p-q+r)

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int K = stdIn.nextInt();
		int []p = new int[N];
		int max = 0;
		for(int a = 0; a < N; a++){
			p[a] = stdIn.nextInt();
		}
		Arrays.sort(p);
		for(int c = 0; c < K; c++){
			max += p[c];
		}
		System.out.println(max);
		stdIn.close();
	}
}


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

int main(){
  ll n, k, i, sum=0;
  cin>>n>>k;
  ll arr[n];
  for(i=0; i<n; i++)
    cin>>arr[i];

  sort(arr, arr+n);
  for(i=0; i<n; i++){
    if(i>=n-k)
      break;
    else
      sum += arr[i];
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

template <class... Args>
struct tuple_input_impl;
template <std::size_t i, std::size_t... tail>
struct tuple_input_impl<std::index_sequence<i, tail...>>
{
    template <class... Args>
    static void f(std::tuple<Args...>& x)
    {
        std::cin >> std::get<i>(x);
        tuple_input_impl<std::index_sequence<tail...>>::f(x);
    }
};
template <>
struct tuple_input_impl<std::index_sequence<>>
{
    static void f(...) {}
};

template <class... Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& x)
{
    tuple_input_impl<std::index_sequence_for<Args...>>::f(x);
    return in;
}
template <class T1, class T2>
std::istream& operator>>(std::istream& in, std::pair<T1, T2>& x) { return in >> x.first >> x.second; }

template <class T>
T read()
{
    T res;
    std::cin >> res;
    return res;
}
template <class T>
std::vector<T> read(std::size_t n)
{
    std::vector<T> res(n);
    for (std::size_t i = 0; i < n; ++i) std::cin >> res[i];
    return res;
}

template <class T>
void out_impl(T&& v) { std::cout << std::forward<T>(v); }
template <class T, class... Args>
void out_impl(T&& v, Args&&... args)
{
    std::cout << std::forward<T>(v) << ' ';
    out_impl(std::forward<Args>(args)...);
}
template <class... Args>
void out(Args&&... args)
{
    out_impl(std::forward<Args>(args)...);
    std::cout << '\n';
}
template <class... Args>
void out_noreturn(Args&&... args) { out_impl(std::forward<Args>(args)...); }

template <class T>
void print(const T& container)
{
    bool first = true;
    for (auto&& x : container) {
        if (!first) std::cout << ' ';
        std::cout << x;
        first = false;
    }
    std::cout << '\n';
}

void prog()
{
    int s = read<int>();

    std::set<int> set;
    for (int i = 0;; ++i) {
        if (set.count(s)) {
            out(i + 1);
            return;
        }
        set.insert(s);
        s = (s % 2) ? 3 * s + 1 : s / 2;
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    prog();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int M, D, ans = 0;
  cin >> M >> D;
  for (int i=1; i<=M; i++) {
    for (int j=1; j<=D; j++) {
      int d1 = j%10;
      int d10 = j/10;
      if (d1>=2&&d10>=2&&d1*d10==i) ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)


#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[NMAX];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;
int dp[NMAX];

void solve()
{
    cin>>n>>k;
    dp[0] = 0;
    arr[0] = 1e18;
    for(int i=1;i<=n;i++){
        dp[i] = INF;
        cin>>arr[i];
        if(i == 1){
            dp[1] = 0;
            continue;
        }
        for(int j=1;j<=k and i - j >= 1;j++){
            dp[i] = min(dp[i],dp[i-j] + abs(arr[i] - arr[i-j]));
        }
        // tr(dp[i]);
    }
    cout<<dp[n];
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 5120
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int a[500010];

int main(){
  string s; cin >> s;
  int n=s.size();
  rep(i,n){
   
    if(s[i]=='<') a[i+1]=a[i]+1;
  }
  for(int i=n;i>=1;i--){
    if(s[i-1]=='>') chmax(a[i-1],a[i]+1);
  }
  ll ans=0;
  rep(i,n+1){
    ans+=a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 2820
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>

using namespace std;

typedef long long ll;

ll N;

class BIT{

private:
	ll b;
	vector<ll>bit;

public:
	BIT(ll n);
	void add(ll i,ll x);
	ll sum(ll i);
};

BIT::BIT(ll n){

	bit.resize(n+1);

	b=1;

	while(b<=n){
		b<<=1;
	}
}
ll BIT::sum(ll i){
	ll s=0ll;

	for(i+=1ll;i>0;i -= i & -i){
		s+=bit[i];
	}
	return s;
}
void BIT::add(ll i,ll x){
	for(i+=1ll;i<bit.size();i += i & -i){
		bit[i]+=x;
	}
}

ll f(vector<ll>a,ll c){

	BIT bt((2ll * N) + 5ll);

	ll i;


	for(i=0ll;i<N;i+=1ll){
		if(a[i]>=c){a[i]=1ll;}
		else{a[i]=-1ll;}
		if(i>0ll){
			a[i]+=a[i-1];
		}
	}

	bt.add(N,1ll);

	ll sum=0ll;

	for(i=0ll;i<N;i+=1ll){
		sum+=bt.sum(a[i]+N);
		bt.add(a[i]+N,1ll);
	}
	return sum;

}

int main() {


	scanf("%lld",&N);

	ll i;

	vector<ll> a(N);

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

	ll l,r,mid;

	l=0ll;
	r=1e10;
	mid=(l+r)/2ll;

	while(r-l>1ll){
		if(f(a,mid)>=ceil(N*(N+1)/2.0/2.0)){l=mid;}
		else{r=mid;}
		mid=(l+r)/2ll;
	}
	printf("%lld\n",mid);

	return 0;
}

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

int main() {
    int i, N, count=0;
    long long D;
    vector<long long> X(200000), Y(200000);
    
    cin >> N;
    cin >> D;
    for (i=0; i<N; i++) {
        cin >> X.at(i);
        cin >> Y.at(i);
    }
    
    for (i=0; i<N; i++) {
        if(X.at(i)*X.at(i)+Y.at(i)*Y.at(i)<=D*D) count +=1;
    }

  cout << count;
}







Measured memory_bytes: 6236
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int[] x = new int[N];
        for(int i=0;i<N;i++) x[i]=sc.nextInt();
        int sum=0;
        for(int w:x) sum+=w;
        long[][][] dp = new long[N+1][N+1][2501];
        dp[0][0][0]=1;
        for(int i=1;i<=N;i++){
            dp[i][0][0]=1;
            for(int j=1;j<=i;j++){
                dp[i][j][0]=0;
                for(int k=1;k<=sum;k++){
                    dp[i][j][k] += dp[i-1][j][k];
                    if(k>=x[i-1]) dp[i][j][k]+=dp[i-1][j-1][k-x[i-1]];
                }
            }
        }
        long ans = 0;
        for(int j=1;j<=N;j++){
            ans += dp[N][j][A*j];
        }
        System.out.println(ans);
    }
}


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

int n;
int h[100010];
long long min_cost[100010];

int main() {
  cin >> n;
  for(int i = 1; i <= n; i++) {
    cin >> h[i];
  }
  min_cost[1] = 0;
  min_cost[2] = abs(h[2] - h[1]);
  for(int i = 3; i <= n; i++) {
    min_cost[i] = min( min_cost[i-1] + abs(h[i] - h[i-1]), 
                       min_cost[i-2] + abs(h[i] - h[i-2]) );
  }
  cout << min_cost[n] << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n,count=0;
  cin >> n;
  for(int i=1; i<=n; i++){
    if(1<=i && i <10 ){
      count++;
    }else if(100 <= i && i < 1000){
      count++;
    }else if(10000 <= i && i < 100000){
      count++;
    }
  }
   
  cout << count << endl;
      
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int K,a,b;
 
  scanf("%d\n", &K);
  scanf("%d %d\n", &a, &b);
  int i = a;
  if(i>b) printf("NG");
  while(i<=b){
    if(i%K==0){
      printf("OK");
      break;
    }else if(i==b){
      printf("NG");
    }
    i++;
  }
  return 0;
}

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

using namespace std;

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

int main(){
  uint64_t k;
  int n;
  cin >> n >> k;
  vector<uint64_t> a(n), f(n);
  REP(i, n){
    cin >> a[i];
  }
  REP(i, n){
    cin >> f[i];
  }
  sort(a.begin(), a.end(), greater<int>());
  sort(f.begin(), f.end());
  uint64_t lo = 0, hi = 1000000000000ull;
  while(lo < hi){
    uint64_t x = (lo + hi) / 2;
    uint64_t kk = 0;
    REP(i, n){
      uint64_t v = x / f[i];
      if(a[i] > v) kk += a[i] - v;
    }
    if(kk > k){
      lo = x + 1;
    }else{
      hi = x;
    }
  }
  cout << lo << endl;
  return 0;
}

Measured memory_bytes: 3328