akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int h,n;
    cin>>h>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    ll dp[h+1];
    fill(dp,dp+h+1,LINF);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<h;j++){
            dp[min(j+a[i],h)]=min(dp[min(j+a[i],h)],dp[j]+b[i]);
        }
    }
    cout<<dp[h]<<endl;
}

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

int main(){
    int num[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> num[i][j];
        }
    }
    int n, b;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> b;
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(num[j][k] == b) num[j][k] = 0;
            }
        }
    }
    bool ans = false;
    for(int i = 0; i < 3; i++){
        if(num[i][0] == 0 && num[i][1] == 0 && num[i][2] == 0) ans = true;
        if(num[0][i] == 0 && num[1][i] == 0 && num[2][i] == 0) ans = true;
    }
    if(num[0][0] == 0 && num[1][1] == 0 && num[2][2] == 0) ans = true;
    if(num[0][2] == 0 && num[1][1] == 0 && num[2][0] == 0) ans = true;

    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <unistd.h>
#include <cstdio>
#include <x86intrin.h>

typedef long long ll;
int mat[3000][3000]; 
ll dp0[3000] __attribute((aligned(32)));

char buf[1048576];
int lim = 0;
int cur = 0;

void refill()
{
    lim = read(STDIN_FILENO, buf, sizeof buf);
    cur = 0;
}

int rd()
{
    while (true) {
        if (cur == lim) {
            refill();
            if (lim == 0) return -1;
        } else {
            if (buf[cur] >= '0' && buf[cur] <= '9') break;
            cur++;
        }
    }
    int acc = buf[cur++] - '0';
    while (true) {
        if (cur == lim) {
            refill();
            if (lim == 0) return acc;
        } else {
            if (buf[cur] < '0' || buf[cur] > '9') return acc;
            acc = acc * 10 + buf[cur++] - '0';
        }
    }
}

#pragma clang attribute push(__attribute__((target("avx512vl"))), apply_to=function)
int main(int argc, char **argv)
{
    int rr = rd();
    int cc = rd();
    int k  = rd();

    for (int i = 1; i <= k; i++) {
        int r = rd();
        int c = rd();
        int v = rd();
        mat[r - 1][c - 1] = v;
    }
    for (int y = 0; y < rr; y++) {
        __m256i work = _mm256_setzero_si256();
        for (int x = 0; x < cc; x++) {
            __m256i tmp = _mm256_maskz_set1_epi64(1, dp0[x]);
            work = _mm256_max_epi64(work, tmp);
            __m256i v = _mm256_set1_epi64x(mat[y][x]);
            __m256i s = _mm256_permutex_epi64(work, (2 << 6) + (1 << 4));
            s = _mm256_maskz_add_epi64(14, s, v);
            work  = _mm256_max_epi64(work, s);
            __m256i s2 = _mm256_permutex_epi64(work, (1 << 6) + (0 << 4) + (3 << 2) + (2 << 0));
            __m256i s3 = _mm256_max_epi64(work, s2);
            __m256i s4 = _mm256_permutex_epi64(s3, 5);
            __m256i s5 = _mm256_max_epi64(s3, s4);

            _mm256_mask_store_epi64(&dp0[x], 1, s5);
        }
    }
    std::printf("%lld\n", dp0[cc - 1]);
    return 0;
}
#pragma clang attribute pop

Measured memory_bytes: 39316
#include<iostream>
using namespace std;
int main(){
  bool num[1000001]={false};
  for(int i=2; i<1000; i++) if(!num[i]) for(int j=i*i; j<1000001; j+=i) num[j] = true;
  for(int n; cin >>n;){
    for(int i=n-1;;i--) if(!num[i]){cout <<i<<" ";break;}
    for(int i=n+1;;i++) if(!num[i]){cout <<i<<endl;break;}
  }
  return 0;
}

Measured memory_bytes: 2144
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using P = pair<int, int>;

int main() {
    while (1) {
        int n, w, d;
        cin >> n >> w >> d;
        if (n == 0 && w == 0) break;
        vector<P> v;
        v.push_back(P(w, d));

        for (int i = 0; i < n; ++i) {
            int p, s;
            cin >> p >> s;
            p--;
            int pw = v[p].first;
            int ph = v[p].second;

            s %= pw * 2 + ph * 2;
            if (s > pw + ph) s -= pw + ph;
            bool vert = s <= pw;
            if (s > pw) s -= pw;

            int w1 = pw, h1 = ph, w2 = pw, h2 = ph;
            if (vert) {
                w1 = min(s, pw - s);
                w2 = max(s, pw - s); 
            } else {
                h1 = min(s, ph - s);
                h2 = max(s, ph - s);
            }
            v.erase(v.begin() + p);
            v.push_back(P(w1, h1));
            v.push_back(P(w2, h2));
        }

        vector<int> areas;
        for (P p : v) {
            areas.push_back(p.first * p.second);
        }
        sort(areas.begin(), areas.end());

        cout << areas[0];
        for (int i = 1; i < n + 1; ++i) {
            cout << " " << areas[i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,b[101010],i,j,p[101010],q,l,r;
int main()
{
	n=100000;
	b[1]=1;
	for(i=2;i<=sqrt(n);i++)
		if(b[i]==0)
			for(j=i*i;j<=n;j+=i)
				b[j]=1;
	for(i=1;i<=n;i++)
		p[i]=p[i-1]+(i%2==1&&b[i]==0&&b[(i+1)/2]==0);
	cin>>q;
	while(q--)
	{
		cin>>l>>r;
		cout<<p[r]-p[l-1]<<"\n";
	}
}

Measured memory_bytes: 2176
n = int(input())
#k, x = map(int, input().split())
pl = list(map(str, input().split())); p = int("".join(pl))
ql = list(map(str, input().split())); q = int("".join(ql))
#l=[list(map(int,input().split())) for i in range(n)]
import itertools
l = [str(i) for i in range(1, n+1)]
a, b = 0, 0
for v in list(itertools.permutations(l)):
    num = int("".join(list(v)))
    if p >= num:
        a += 1
    if q >= num:
        b += 1
print(abs(a-b))

Measured memory_bytes: 13980
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sort(v) sort(v.begin(),v.end())
#define pb push_back
int main()
{
 ll aa,b,c,d;
  cin>>aa;
    string s;
    ll a,w,t,r,i;
    a=w=t=r=0;
 for(i=1;i<=aa;i++)
{cin>>s;
if(s=="AC")a++;
else if(s=="WA")w++;
else if(s=="TLE")t++;
else r++;
 }
cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<w<<endl;
cout<<"TLE x "<<t<<endl;
cout<<"RE x "<<r<<endl;
 }

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

using namespace std;
int main(){
  long long int ans = 0;
  long int N;
  cin >> N;
  vector<string> s(N);
  map<string,long int> p;
  for(int i = 0; i < N; i++) cin >> s[i];
  for(int i = 0; i < N; i++) sort(s[i].begin(),s[i].end());
  for(int i = 0; i < N; i++){
      p[s[i]] += 1;
  }
  map<string,int> q;
  for(int i = 0; i < N; i++){
      if(q[s[i]] == 0){  ans = ans + (p[s[i]] - 1) * p[s[i]] / 2; q[s[i]] = 1; }
  }
 cout << ans;
 return 0;
}

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

int main(){
  int N; cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  int min = 100000000;
  for (int i = 0; i < N; i++) {
    int res;
    for (int j = 0; j < 36; j++){
      if (a[i] & (1 << j)) {
        res = j;
        break;
      }
    }
    if (min > res) min = res;
  }
  cout << min << endl;
  return 0;
}

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

struct Point { double x, y; };

void koch( int n, Point a, Point b ) {
  if ( n == 0 ) return;
  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n - 1, t, b);
}

int main() {
  Point a, b;
  int n;

  scanf("%d", &n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}


Measured memory_bytes: 2704
#include<bits/stdc++.h>
using namespace std;
int n,m,x[4][10],y[4][10],nm,nx[2][10],ny[2][10];

bool check(){
  if(m!=nm)return 0;
  int res=0;
  for(int i=0;i<m;i++)nx[1][m-i-1]=nx[0][i],ny[1][m-i-1]=ny[0][i];
  for(int i=m-1;i>=0;i--)
    for(int j=0;j<2;j++)nx[j][i]-=nx[j][0],ny[j][i]-=ny[j][0];
  for(int i=0;i<4;i++)
    for(int j=0;j<2;j++){
      int f=1;
      for(int k=0;k<m;k++)
	if(x[i][k]!=nx[j][k]||y[i][k]!=ny[j][k])f=0;
      if(f)res=1;
  }
  return res;
}

int main(){
  while(cin>>n,n){
    cin>>m;
    for(int i=0;i<m;i++)cin>>x[0][i]>>y[0][i];
    for(int i=m-1;i>=0;i--)
      x[0][i]-=x[0][0],y[0][i]-=y[0][0];
    for(int i=1;i<4;i++){
      for(int j=0;j<m;j++)
	x[i][j]=-y[i-1][j],y[i][j]=x[i-1][j];
    }
    for(int i=1;i<=n;i++){
      cin>>nm;
      for(int j=0;j<nm;j++)cin>>nx[0][j]>>ny[0][j];
      if(check())cout<<i<<endl;
    }
    cout<<"+++++"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ins insert
typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int N=310;

char s[N][N];

int n,m,k,sum[N][N],ans[N][N],colcnt;

vector<int>G[N];

int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++){
		scanf("%s",s[i]+1);
	}
//	for(int i=1;i<=n;i++){
//		printf("%s\n",s[i]+1);
//	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i][j]=='#'){
				G[i].pb(j);
			}
//			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+(s[i][j]=='#'?1:0);
		}
	}
	for(int i=1;i<=n;i++){
//		if(sum[i][m]^sum[i-1][m]){
		if(G[i].empty()){
			for(int j=1;j<=m;j++){
				ans[i][j]=ans[i-1][j];
			}
		}
		else{
			int lst=1;
			for(int j=0,u;j<(int)G[i].size();j++){
				u=G[i][j];++colcnt;
				while(lst<=u){
					ans[i][lst]=colcnt;++lst;
				}
//				ans[i][j]=colcnt;
//				if(j<m&&(sum[i][j]^sum[i][j+1])){
//					++colcnt;
//				}
			}
			while(lst<=m){
				ans[i][lst]=ans[i][lst-1];++lst;
			}
		}
	}
	int qwq=1;
	while(!ans[qwq][1]){
		++qwq;
	}
	while(qwq>1){
		for(int j=1;j<=m;j++){
			ans[qwq-1][j]=ans[qwq][j];
		}
		--qwq;
	}
//	for(int i=1;i<=n;i++){
//		for(int j=1;j<=m;j++){
//			printf("%d%c",sum[i][j]," \n"[j==m]);
//		}
//	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			printf("%d%c",ans[i][j]," \n"[j==m]);
		}
	}
	return 0;
} 

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

int main()
{
    int n,zero=0;
    cin>>n;
    long long int p=1;
    long long int ar[n];
    for(int i=0;i<n;i++){
        cin>>ar[i];
        if(ar[i]==0)zero=1;
    }
    if(zero){cout<<0<<endl; return 0;}
    for(int i=0;i<n;i++){

        if(ar[i]<=1000000000000000000/p){p*=ar[i];}
    else {
        cout<<"-1"<<endl; return 0;
    }
    }
    cout<<p<<endl;

    return 0;

}


Measured memory_bytes: 4380
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<cstdio>
#include<algorithm>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+100;
int arr[N],ans[N];
int main(){
	
	
	int n;
	while(cin>>n){
		
		for(int i=1;i<=n;i++)cin>>arr[i];
		
		if(n&1){
			int cnt=n;
			int tmp=2;
			for(int i=1;i<=n;i++){
				ans[i]=arr[cnt];
				if(cnt==1)tmp=-2,cnt=0;
				cnt-=tmp;
				
				
			}
			
		}else{
			
			int cnt=n;
			int tmp=2;
			for(int i=1;i<=n;i++){
				ans[i]=arr[cnt];
				if(cnt==1)tmp=-2;
				cnt-=tmp;
				if(cnt==0)cnt=1;
			
			}
		}
		for(int i=1;i<=n;i++)cout<<ans[i]<<" ";
		cout<<endl;
	
	}
	return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>

int main(void)
{
	int a, b;

	scanf("%d%d", &a, &b);

	if (a == b)
	{
		printf("a == b\n");
	}
	else
	{
		if (a > b)
		{
			printf("a > b\n");
		}
		else
		{
			printf("a < b\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <stdio.h>
#include <cctype>
#include <bits/stdc++.h>
using namespace std;

int main(){
    string str;
    int counter[26] = {};
    int num = 0;
    while (getline(cin, str)) {
        int l = str.length();
        for (int i = 0; i < l; i++){
            if ('A' <= str[i] && str[i] <= 'Z'){
                str[i] += 'a' - 'A';
            }
            num = str[i] - 'a';
            counter[num] += 1;
        }
    }
    for (char j = 'a'; j <= 'z'; j++){
        cout << j << " : " << counter[j - 'a'] << endl;
    }
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define ms(x, v) memset(x, v, sizeof(x))
using namespace std;
const int N = 105, INF = 0x3f3f3f3f;
char s[N];
int b[N];
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    ios::sync_with_stdio(0), cin.tie(0);
    while(cin >> s)
    {
        ms(b, 0);
        int len = strlen(s);
        int ans = INF;
        for(int x = 'a'; x <= 'z'; x++)
        {
            int lst = 0, mx = 0;
            rep(i, len)
            {
                if(s[i] == x)
                {
                    mx = max(mx, i - lst);
                    lst = i + 1;
                }
            }
            mx = max(mx, len - lst);
            ans = min(ans, mx);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 666666
int arr[N];
vector<int> v1,v0;
int a[N],b[N];
map<int,int> mp;
signed main(){
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+1+n);
	for(int i=1;i<=n;i++) mp[b[i]]=i;
	for(int i=1;i<=n;i++){
		if(i%2!=mp[a[i]]%2) ans++;
	}
	cout<<ans/2;
	return 0;
}
/*
3
1
2
1
*/

Measured memory_bytes: 11392
#include <iostream>
#include <tuple>
#include <cmath>
#include <complex>

using namespace std;
using vec = complex<double>;
using line = pair<vec,vec>;

double inner_product(vec u,vec v){
    return real(u*conj(v));
}
double cross_product(vec u,vec v){
    return imag(conj(u)*v);
}

vec projection(line l,vec p){//p???l???????°???±
    vec s=l.first, t=l.second;
    double k = inner_product(t-s,p-s)/inner_product(t-s,t-s);
    return (1.0-k)*s+k*t;
}

vec reflection(line l,vec p){
    return 2.0*projection(l,p)-p;
}

vec interSection(line l0, line l1){
    vec s0, t0, s1, t1;
    tie(s0,t0)=l0; tie(s1,t1)=l1;
    double k = cross_product(t1-s1,s1-s0)/cross_product(t1-s1,t0-s0);
    return s0+(t0-s0)*k;
}

double segLength(line l){
    return abs(l.first-l.second);
}

int number(string S, int &ite){
    int ret = 0;
    int sign = 1;
    if(S[ite]=='-'){
        sign = -1;
        ite++;
    }
    while('0'<=S[ite]&&S[ite]<='9'){
        ret*=10;
        ret+=S[ite]-'0';
        ite++;
    }
    ret*=sign;
    return ret;
}

line ope(line a, line b){
    if(segLength(a)==0&&segLength(b)==0){
        return line(a.first,b.first);
    }else if(segLength(a)==0){
        return line(reflection(b,a.first),reflection(b,a.first));
    }else if(segLength(b)==0){
        return line(reflection(a,b.first),reflection(a,b.first));
    }else{
        return line(interSection(a,b),interSection(a,b));
    }
}

line parse(string S, int &ite){
    line ret;
    vec v1,v2;
    if('0'<=S[ite]&&S[ite]<='9'||S[ite]=='-'){
        int x=number(S,ite);
        ite++;//','??????????£???°???
        int y=number(S,ite);
        return line(vec(x,y),vec(x,y));
    }
    while(ite<S.size()){
        if(S[ite]==')') break;
        if(S[ite]=='('){
            ite++;//'('
            ret=parse(S,ite);
            ite++;//')'
        }else if(S[ite]=='@'){
            ite++;//'@'
            ite++;//'('
            ret=ope(ret,parse(S,ite));
            ite++;//')'
        }
    }
    return ret;
}

int main(){
    string S;
    while(cin>>S,S[0]!='#'){
        int ite = 0;
        vec ans = parse(S,ite).first;
        cout<<fixed;
        cout.precision(8);
        cout<<real(ans)<<' '<<imag(ans)<<endl;
    }

    return 0;
}

Measured memory_bytes: 3140
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		long[] dp = new long[100001];
		for(int i = 0; i < n; i++) {
			dp[i] = 9223372036854775807l;
		}
		
		dp[0] = 0;
		
		for(int i = 1; i < n; i++) {
			dp[i] = chmin(dp[i], dp[i - 1] + Math.abs(h[i] - h[i - 1]));
			//System.out.println(" " +dp[i]);
			if(i>1)dp[i] = chmin(dp[i], dp[i - 2] + Math.abs(h[i] - h[i - 2]));
			//System.out.println(dp[i]);
		}
		
		/*for(int i = 0; i < n; i++) {
			System.out.println(dp[i]);
		}*/
		System.out.println(dp[n-1]);
	}
	
	
	
	
	
	
	
	
	public static  long chmin(long a,long b) {
		if(a > b) {
			a = b;
		}
		return a;
	}
}

Measured memory_bytes: 49448
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

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

int main() {
  long n;
  cin >> n;

  long ans = n + 2;
  long sqrt_n = sqrt(n) + 1;

  for (long i = 1; i < sqrt_n; i++) {
    if (n % i == 0) {
      long j = n / i;
      long m = i + j;
      if (m < ans) {
        ans = m;
      } else {
        break;
      }
    }
  }

  // 移動回数なので
  ans = ans - 2;
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N;
    vector<vector<P> > info(N,vector<P>(0));
    rep(i,N){
        cin>>A;
        rep(j,A){
            cin>>H>>W;
            --H;
            info[i].emplace_back(H,W);
        }
    }
    ll ans = 0;
    rep(i,(1LL<<N)){
        bool ok = true;
        ll temp = 0;
        rep(j,N){
            bool yesman = (i>>j)&1;
            temp += yesman;
            if(yesman) {
                for (P p : info[j]) {
                    if (((i >> p.fi) & 1) != p.se) ok = false;
                }
            }
        }
        if(ok) ans = max(ans, temp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define INF 1e9
using namespace std;


int main() {
  while(1){
    int T,cir[31],n;
    cin >> T;
    if(!T)break;
    for(int i=0;i<T;i++) cin>>cir[i];
    cin>>n;
    int d,h,job[102]={},dp[102][102]={};
    for(int i=0;i<102;i++)for(int j=0;j<102;j++)dp[i][j]=job[i]=INF;
    for(int i=0;i<n;i++)cin>>d>>h,job[d]=min(job[d],h);

    dp[0][0]=0;
    for(int i=0;i<=100;i++)
      for(int j=0;j<T;j++){
	dp[i+1][1]=min(dp[i+1][1],dp[i][j]+1);
	if(cir[j]<=job[i+1])dp[i+1][(j+1)%T]=min(dp[i+1][(j+1)%T],dp[i][j]);
      }

    int ans=INF;
    for(int i=0;i<T;i++)ans=min(ans,dp[101][i]);
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];

//big priority queue
priority_queue <ll> pql;
priority_queue <P> pqp;

//small priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;

//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}


ll i,j,k,ii,jj,n,m;
ll a,b,c,d,e,g,h,r,l,w,num,ans;
ll x[500005],y[500005],z[500005];
ll dp[300005];
bool flag,dame,ng;

int main(){    
    for(i=0;i<4;i++){
		cin >> a ;
		x[a]++;
	}
	if(x[1] && x[9] && x[7] && x[4]){
		p("YES");
	}else{
		p("NO");
	}

    return 0;
}

Measured memory_bytes: 27520
#include <bits/stdc++.h>
#define ll long long
#define vi vector <int>
#define vl vector <ll>
#define dl pair <ll, ll>
#define ii pair <ll, ll>
#define vii vector <ii>
#define graph vector <vii> graph
#define inf 1000000000

using namespace std;

//ll primos[12] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};

bool comp(ll a, ll b) {
	return a > b;
}

ll suma;

class uf {
public:
    vi p;
    vl s;
    uf (int n) {
        p.resize(n + 5);
        s.assign(n + 5, 1);
        for (int i = 0; i < n + 5; i++) p[i] = i;
    }
    int findset(int u) {return u == p[u] ? u : p[u] = findset(p[u]);}
    void merge(int u, int v) {
        int x = findset(u);
        int y = findset(v);
        if (x == y) {
            return;
        }
        suma -= (s[x] * s[y]);
        if (s[x] > s[y]) {
            p[y] = x;
            s[x] += s[y];
        } else {
            p[x] = y;
            s[y] += s[x];
        }
    }
};

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
 
    ll n, m;
    cin >> n >> m;
    int in1, in2;
    ii arr[m];
    for (int i = 0; i < m; i++) {
        cin >> in1 >> in2;
        arr[i] = {in1, in2};
    }
    vl ans;
    ans.reserve(m);
    suma = (n * (n - 1)) / 2;
    ans.push_back(suma);
    uf kika(n);
    for (int i = m - 1; i > 0; i--) {
        kika.merge(arr[i].first, arr[i].second);
        ans.push_back(suma);
    }
    reverse(ans.begin(), ans.end());
    for (ll x : ans) {
        cout << x << "\n";
    }
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> X(N);
  for (int i = 0; i < N; i++) cin >> X.at(i).second >> X.at(i).first;
  sort(X.begin(), X.end());
  int T = 0;
  string ans = "Yes";
  for (int i = 0; i < N; i++) {
    T += X.at(i).second;
    if (T > X.at(i).first) {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
int main()
{
	int n,t[105],m,p,x;
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> t[i];
	cin >> m;
	for(int i=1;i<=m;i++)
	{	
		int sum=0;
		cin >> p >> x;
		for(int i=1;i<=n;i++)
		{
			if(i!=p)
				sum+=t[i];
			else
				sum+=x;
		}
		cout << sum << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())

    if(N > 1):
        if(N % 2 == 0):
            odd_cnt = N // 2
        if(N % 2 == 1):
            odd_cnt = N // 2 + 1

        print(odd_cnt / N)
    else:
        print(N)


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i,n) for(ll i=0;i<(int)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(int)(n);i++)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<ll,ll> pint;
const long long INF = 1LL<<60;
const ll MOD = 1000000007;
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }
    else{
        return gcd(b,a%b);
    }
}
int main(){
    ll n;cin>>n;
    vector<ll> a(n);rep(i,n)cin>>a[i];
    vector<ll> l(n);
    vector<ll> r(n);
    map<ll,ll> lset;
    map<ll,ll> s;
    ll ans = 0;
    rep(i,n){
        l[i]=a[i]+i;
    }
    rep(i,n){
        ll m=n-1-i;
        r[m]= m-a[m];
        s[r[m]]+=1;
    }
    rep(i,n){
        ans += s[l[i]]-lset[l[i]];
        lset[r[i]]+=1;
    }
    cout<<ans<<endl;
}


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

int main(){
    string str;
    ll N;
    cin >> str >> N;
    for(int i = 0; i < str.size(); i++){
        if(str[i] != 'a' && ('a' + 26) - str[i] <= N){
            N -= ('a' + 26) - str[i];
            str[i] = 'a';
        }
    }
    N = N % 26;
    if(N > 0){
        str.back() = ((str.back() + N) - 'a') % 26 + 'a';
    }
    cout << str << endl;
}

Measured memory_bytes: 3720
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    for i in range(h):
        if i % 2 == 0:
            if w % 2 == 0:
                print('#.'*(w//2))
            else:
                print('#.'*((w-1)//2)+'#')
        else:
            if w % 2 == 0:
                print('.#'*(w//2))
            else:
                print('.#'*((w-1)//2)+'.')
    print()



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

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

    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }
    
    sort(A.begin(), A.end());

    int res = INT_MAX;
    for (int i = 0; i < N-1; i++)
    {
        int tmp = K - (A.at(i+1) - A.at(i));
        if (tmp < res)
        {
            res = tmp;
        }
    }
    int tmp = A.at(N-1) - A.at(0);
    if (tmp < res)
    {
        res = tmp;
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
import sys
N, M = map(int, input().split())

A = []
B = []
for i in range(N):
    A.append(input())
    
for j in range(M):
    B.append(input())
    

for b in range(N-M+1):
    for a in range(N-M+1):
        count = 0
        for i in range(M):
            if B[i] == A[i+b][a:a+M]:
                count += 1
        if count == M:
            print('Yes')
            sys.exit()
    
print('No')


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

int main(){
  int a, b;
  cin >> a >> b;
  int d = a / b;
  int r = a % b;
  double x = (double) a;
  double y = (double) b;
  double f = x / y;
  cout << fixed << setprecision(10);
  cout << d << " " << r << " " << f << endl;
}


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

int main(){
  int N;
  cin >> N;
  int x, y, b, p;
  for(int i=0; i<N; i++){
    cin >> x >> y >> b >> p;
    if(b>=5 && p>=2){
      cout << (b*x + p*y)*4/5 << endl;
    }else if(b>=5){
      cout << min((b*x + 2*y)*4/5, b*x+p*y) << endl;
    }else if(p>=2){
      cout << min((x*5 + p*y)*4/5, b*x+p*y) << endl;
    }else{
      cout << b*x + p*y << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int main(){

	int W,H;
	cin >> W >> H;
	int a[1000],b[1000];
	for(int i=0; i<W; i++) cin >> a[i];
	for(int i=0; i<H; i++) cin >> b[i];
	
	int memo[2][1001] = {};
	for(int i=0; i<W; i++){
		memo[1][a[i]]++;
	}
	sort(b, b+H); reverse(b, b+H);

	for(int i=0; i<H; i++){
		for(int j=0; j<=H; j++){
			 memo[0][j] = memo[1][j];
		}
		for(int j=H; j>=1; j--){
			if(b[i] == 0) break;
			if(memo[0][j] <= b[i]){
				b[i] -= memo[0][j];
				memo[1][j] -= memo[0][j];
				memo[1][j-1] += memo[0][j];
			}
			else{
				memo[1][j] -= b[i];
				memo[1][j-1] += b[i];
				b[i] = 0;
			}
		}
		if(b[i] != 0){
			cout << 0 << endl;
			return 0;
		}
	}
	cout << 1 << endl;

	return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
ll n,a,b,d[100010];

int main(){
	cin >> n >> a >> b;
	REP(i,0,n) cin >> d[i];
	
	ll s=0;
	REP(i,0,n-1) s+=min(b, a*(d[i+1]-d[i]));
	cout << s << endl;
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int main(){
  ll X,Y;cin>>X>>Y;
  if(Y%2==0 && 2*X<=Y && 4*X>=Y)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    string S;
    cin >> S;
    int length = S.length();
    vector<int> a(length+1, -1);
    REP(i, length+1) {
        if(i==0 && S[0] == '<')
            a[0] = 0;
        else if(i==length && S[length-1] == '>')
            a[i] = 0;
        else if(i < length && S[i-1] == '>' && S[i] == '<')
            a[i] = 0;
    }

    FOR(i, 1, length) {
        if(S[i-1] == '<')
            a[i] = a[i-1] + 1;
    }

    FORR(i, length-1, 0) {
        if(S[i] == '>')
            a[i] = max(a[i], a[i+1] + 1);
    }

    // REP(i, length+1) {
    //     cerr << a[i] << " ";
    // }
    // cerr << endl;

    ll ans = 0;
    REP(i, length+1) {
        ans += ll(a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2820
#include <iostream>
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    int a=n, sum=0;
    while(a>0) {
        sum += a%10;
        a/=10;
    }
    if(n%sum==0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Map.Entry;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] count = new int[n + 1];
            int noneZero = 0;
            for (int i = 0; i < n; i++) {
                int a = in.nextInt();
                count[a]++;
                if (count[a] == 1) {
                    noneZero++;
                }
            }
            Arrays.sort(count);
            int i = 0;
            while (count[i] == 0) i++;
            int sum = 0;
            while (noneZero > k) {
                sum += count[i];
                i++;
                noneZero--;
            }
            out.println(sum);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

        public double nextFloat() {
            return Double.parseDouble(next());
        }

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

    }
}


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

using namespace std;

int main() {
    string S; cin >> S;
    if (S == "SUN") cout << 7;
    else if (S == "MON") cout << 6;
    else if (S == "TUE") cout << 5;
    else if (S == "WED") cout << 4;
    else if (S == "THU") cout << 3;
    else if (S == "FRI") cout << 2;
    else if (S == "SAT") cout << 1;
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 1000000007;

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

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}


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

  int n;
  cin >> n;
  vi a(n);
  rep(i,n)cin >> a[i];

  sort(all(a),greater<int>());
  ll ret = a[0];
  int ptr = 1;
  int cnt = 0;
  for(int i = 2;i < n;i++){
    ret += a[ptr];
    cnt++;
    if(cnt == 2){
      cnt = 0;
      ptr++;
    }
  }

  cout << ret << endl;
}

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

int main()
{
    int iNumA = 0;
    int iNumB = 0;
    int iNumC = 0;
    int iResult = 0;
    
    cin >> iNumA >> iNumB >> iNumC;
    
    for (int i = 1; i <= iNumC; i++)
    {
        if (0 == iNumC % i)
        {
            if ((i >= iNumA) && (i <= iNumB))
            {
                iResult++;
            }
        }
    }
    
    cout << iResult << endl;
    
    return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int n=s.size();
	int a=0,b=0;
	rep(i,n){
		if(s[i]=='0') a++;
		else b++;
	}
	cout<<2*min(a,b)<<endl;
}

Measured memory_bytes: 512
c = [list(map(int, input().split())) for _ in range(3)]

if c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1] and c[0][1] - c[0][2] == c[1][1] - c[1][2] == c[2][1] - c[2][2] and c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2] and c[1][0] - c[2][0] == c[1][1] - c[2][1] == c[1][2] - c[2][2]:
    print("Yes")
else:
    print("No")


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

int main() {
  string s; cin >> s;
  
  string t = "";
  
  for(int i = 0; i < s.size(); i++){
    if(i % 2 == 0){
      t += s.at(i);
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void)
{
    int x;
    scanf(" %d",&x);
    if(x>0 && x<10)
    {
        if((x%3==0&& x==3) || x%5==0 || x%7==0)
            printf("YES");
        else
            printf("NO");
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        int n;
        scanf("%d",&n);
        for(int i=0;i<n;i++){
                vector<int>ar(3);
                for(auto&e:ar){
                        scanf("%d",&e);
                }
                sort(ar.begin(),ar.end());
                if(((ar[0]*ar[0])+(ar[1]*ar[1]))==(ar[2]*ar[2])){
                        printf("YES\n");
                }else{
                        printf("NO\n");
                }
        }
        return 0;
}

Measured memory_bytes: 1164
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;


int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int n;
	cin >> n;
	priority_queue<double, vector<double>, greater<double>> q;
	for (int i = 0; i < n; i++)
	{
		double cur;
		cin >> cur;
		q.push(cur);
	}
	while (!q.empty())
	{
		double v1 = q.top(); q.pop();
		if (q.empty()) {
			cout << v1;
			break;
		}
		double v2 = q.top(); q.pop();
		q.push((v1 + v2) / 2);
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define mp make_pair
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front

using namespace __gnu_pbds;
using namespace std;

#define int ll

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

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

    int n;
    cin>>n;
    cout<<n*(n-1)/2;
}


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

int main()
{
    ios::sync_with_stdio(0),cin.tie(0);
    ll n,w,res=0;
    cin>>n>>w;
    vector<ll> dp(100001,1e10);
    dp[0]=0;
    for(ll i=0;i<n;i++)
    {
        ll wei,val;
        cin>>wei>>val;
        for(ll j=100000;j>=val;j--)
            dp[j]=min(dp[j],dp[j-val]+wei);
    }
    for(ll i=1;i<dp.size();i++)
        if(dp[i]<=w) res=i;
    cout<<res<<'\n';
}


Measured memory_bytes: 1024
import sys
def I(): return int(sys.stdin.readline().rstrip())


N = I()
A = [I() for _ in range(N)]

B = [0]*N  # Bi = A1~Aiまでのmax
C = [0]*N  # Ci = Ai~ANまでのmax
for i in range(N):
    if i == 0:
        B[i] = A[i]
    else:
        B[i] = max(B[i-1],A[i])
for i in range(N-1,-1,-1):
    if i == N-1:
        C[i] = A[-1]
    else:
        C[i] = max(C[i+1],A[i])

for i in range(N):
    if i == 0:
        print(C[1])
    elif i == N-1:
        print(B[-2])
    else:
        print(max(B[i-1],C[i+1]))


Measured memory_bytes: 85500
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

// https://pyteyon.hatenablog.com/entry/2019/03/11/200000
class UnionFind {
public:
    vector < ll > par; // 各元の親を表す配列
    vector < ll > siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    explicit UnionFind(ll sz_): par(sz_), siz(sz_, 1) {
        REP(i,sz_) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};


void solve() {
    int N,M;
    cin >> N >> M;
    UnionFind uf(N);
    REP(_,M) {
        int A,B; cin >> A >> B;
        A--; B--;
        uf.merge(A,B);
    }

    int rmax = 0;
    REP(i,N) chmax(rmax,(int)uf.size(i));
    cout << rmax << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 6412
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

bool loved[35];

signed main(void) {
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        loved[i] = true;
    }
    rep(i, N) {
        int K; cin >> K;
        set<int> S;
        rep(j, M) S.insert(j);
        rep(j, K) {
            int tmp;
            cin >> tmp;
            S.erase(tmp-1);
        }
        for (auto food : S) {
            loved[food] = false;
        }
    }

    int ans=0;
    rep(i, M) {
        if (loved[i]) {
            // cout << "loved:" << i << endl;
            ans++;
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, l, q;
vector<i64> x;
vector<array<i64, 18>> tab;
int main() {
  cin >> n;
  read_n(x, n, 1);
  x.push_back(x.back() + 1);
  cin >> l >> q;
  init_n(tab, n + 2);
  for (i64 k = 0; k < 18; ++k) tab[n + 1][k] = n + 1;
  for (i64 i = 1; i <= n + 1; ++i) {
    tab[i][0] = lower_bound(begin(x), end(x), x[i] + l + 1) - begin(x) - 1;
  }
  for (i64 k = 1; k < 18; ++k) {
    for (i64 i = 1; i <= n + 1; ++i) {
      tab[i][k] = tab[tab[i][k - 1]][k - 1];
    }
  }
  /*
  for (i64 k = 0; k < 18; ++k) {
    for (i64 i = 1; i <= n; ++i) {
      cerr << tab[i][k] << ' ';
    }
    cerr << endl;
  }
  */
  while (q--) {
    i64 a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    i64 k = 17, ans = 0;
    while (a < b) {
      while (k > 0 && tab[a][k] > b) --k;
      a = tab[a][k];
      ans += 1 << k;
    }
    cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 17392
N,MA,MB = map(int, input().split())
A = []
for _ in range(N):
  a,b,c = map(int, input().split())
  A.append([a,b,c])
  
# dp[i][ca][cb]
# i番目までのitemでaがca gram, bがcb gram 変えるときの最小コスト
# i:1-indexed. so max(i) = N
# maxca,maxcb = N*10
# max_cost(inf) > N *100
# N <= 40

gram_max = 410
cost_inf = 10000
dp = [[[ cost_inf for _ in range(gram_max)] for _ in range(gram_max)] for _ in range(N+1)]

dp[0][0][0] = 0
for i in range(1,N+1):
  a,b,c = A[i-1]
  for ca in range(0,gram_max):
    for cb in range(0,gram_max):
      dp[i][ca][cb] = min(dp[i][ca][cb], dp[i-1][ca][cb]) # なにもしない
      if ca-a >= 0 and cb-b >= 0:
        dp[i][ca][cb] = min(dp[i][ca][cb], dp[i-1][ca-a][cb-b] + c) 
        
ans = 10000
for ca in range(1,gram_max):
  for cb in range(1,gram_max):
    # ca:cb = MA:MB
    if MA*cb == MB*ca:
      ans = min(ans, dp[N][ca][cb])
      
print(ans if ans < 5000 else -1)

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

bool solve(int i, int m, int n, int a[]) {
    if (m == 0) {
        return true;
    }
    if (i >= n) {
        return false;
    }
    int res = solve(i + 1, m, n, a) || solve(i + 1, m - a[i], n, a);
    return res;
}

int main() {
    int n, q, a[20], m[200];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> m[i];
    }

    for (int i = 0; i < q; i++) {
        if (solve(0, m[i], n, a)) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
}



Measured memory_bytes: 3096