akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define mx 10e6
int pn[10000000];
void prime()
{
    pn[2]=1;
    for(int i=3;i<=mx;i+=2)
        pn[i]=1;
        for(int i=1;i*i<=mx;i++)
        {
            if(pn[i]!=0)
            {
                for(int j=i*i;j<=mx;j+=i)
                    pn[j]=0;
            }
        }

}

int main()
{
    prime();
    int n;
    cin>>n;
    for(int i=n;;i++)
    {
        if(pn[i])
        {
            cout<<i<<endl;
            break;
        }
    }
}


Measured memory_bytes: 42660
/**
 *   @FileName	d.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.21 21:16:07
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

 
int main() {
    int n;cin >> n;
    vector<ll> cnt(100001,0);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        cnt[a]++;
        sum += a;
    }
    int q;cin >> q;
    for (int i = 0; i < q; i++) {
        int b,c;cin >> b >> c;
        sum -= cnt[b] * b;
        sum += cnt[b] * c;
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0 ; i<n ; i++)
    cin >> a.at(i);
  
  int ans = 1;
  for (int i=0 ; i<n ; i++){
    if (a.at(i)%2 == 0){
      if (a.at(i)%3 != 0 && a.at(i)%5 != 0){
        ans = 0;
        break;
      }
    }
  }
  
  if (ans == 1)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int ara[1000001];
int main()
{
  long long  int n;
    cin>>n;
   long long int sum=0;
    for(long long int i=5;i<=n;i+=5)
    ara[i]=1;
    for(long long int i=3;i<=n;i+=3)
    ara[i]=1;
    for(long long int i=1;i<=n;i++)
    {
        if(i%5!=0 && i%3!=0) sum+=i;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
bool cmp(int a,int b)
{
	return a<b;
}
int main()
{
	int n,sum;
	cin>>n>>sum;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n,cmp);
	int ans=0;
	int i=0;
	while(sum>=a[i] && i<n-1)
	{
		sum-=a[i];
		i++;
		ans++;
	}
	if(a[i]==sum) ans++;
	cout<<(ans?ans--:ans)<<'\n';
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define fi first
#define se second
#define lowbit(x) ((x)&-(x))
#define debug(x) cout << #x " = " << x << endl;
namespace IO{
	const int L = 1 << 15;
	char ibuf[L|1],*iS=ibuf,*iT=ibuf;
	char obuf[L|1],*oS=obuf,*oT=obuf+L;
	char c,st[66];int tp=0,f;
	inline char gc(){
		if(iS==iT) iT=(iS=ibuf)+fread(ibuf,sizeof(char),L,stdin);
		return (*iS++);
	}
	inline void flush() {
		fwrite(obuf,sizeof(char),oS-obuf,stdout);
		oS = obuf;
	}
	inline void pc(char c){*oS++=c;if(oS==oT) flush();}
	#define gc getchar
	#define pc putchar
	inline ll read(){
		ll x=0;f=1,c=gc();
		for(;!isdigit(c);c=gc())if(c=='-')f=-1;
		for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c&15);
		return x*f;
	}
	void write(ll x){
		if(!x) pc('0');if(x<0) pc('-'),x=-x;
		while(x) st[++tp]=x%10+'0',x/=10;
		while(tp) pc(st[tp--]);
	}
	void wri(ll x){write(x);pc(' ');}
	void writeln(ll x){write(x);pc('\n');}
	struct IOflusher{~IOflusher(){flush();}}_ioflusher_;
}
using IO::read;
using IO::writeln;
using IO::wri;
inline void gg(string s){cout << s << endl;exit(0);}
inline void gg(ll x){writeln(x);exit(0);}
const int maxn = 2e5+233;
const int mod = 1e9+7;
int n,m,k,f[maxn],ans;char s[maxn];
int main(){
#ifdef LOCAL
	freopen("1.in","r",stdin);
#endif
	
	n = read(),m = read();
	scanf("%s",s + 1);
	k = n;while(m && s[m]==s[1])--m;
	if(!m) ans = 1;
	for(int i=1,j=1;i<=m;i=j+1){
		j = i;
		if(s[i]==s[1]){
			while(j<m&&s[j+1]==s[1]) ++j;
			if(i==1){
				if((j-i+1)&1) k=min(k,j-i+1); else k=min(k,j-i+2);
			}else{
			 	if((j-i+1)&1) k=min(k,j-i+1);
			}
		}
	}
	if(k==n){
		for(int i=f[0]=1,j=0;i<=n;++i){
			f[i] = j;
			j = (j + f[i-1]) % mod;
		}
		Rep(i,2,n){
			ans = (ans + 1ll * i * f[n-i]) % mod;
		}
	} else{
		++k;
		for(int i=2,j=f[0]=1;i<=n;i+=2){
			f[i] = j;
			j = (j + f[i]) % mod;
			if(i>=k) j = (j - f[i-k] + mod) % mod;
		}
		for(int i=2;i<=k;i+=2) ans = (ans + 1ll * i * f[n-i]) % mod;
	}writeln(ans);
	return 0;
}

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

typedef struct
{
    string s;
    int k;
} xx;
bool f(xx a,xx b)
{
    if(a.s==b.s)
        return a.k>b.k;
    else return a.s<b.s;
}
int main ()
{
    int n;
    while(cin>>n)
    {
        xx xx[100],xx1[100];
        for(int i=0; i<n; i++)
        {
            cin>>xx[i].s>>xx[i].k;
            xx1[i].s=xx[i].s;
            xx1[i].k=xx[i].k;
        }
        sort(xx,xx+n,f);
        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
                if(xx[i].k==xx1[j].k&&xx[i].s==xx1[j].s)
                    cout<<j+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int r, g, b;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> r >> g >> b;

  int sum = 100 * r + 10 * g + b;
  if (sum % 4 == 0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 5e16
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    ll N;
    cin >> N;
    vector<ll> a;
    REP(i,3*N){
        ll b;
        cin >> b;
        a.push_back(b);
    }
    priority_queue<ll> right;
    priority_queue<ll,vector<ll>,greater<ll> > left;
    ll dpleft[N+1], dpright[N+1];
    dpleft[0] = 0;
    dpright[0] = 0;
    REP(i,N){
        left.push(a[i]);
        right.push(a[3 * N - 1 - i]);
        dpleft[0] += a[i];
        dpright[0] += a[3*N-1-i];
    }
    
    REP(i,N){
        if(a[N+i] > left.top()){
            dpleft[i+1] = dpleft[i] - left.top() + a[N+i];  //left.topは一番小さいやつ
            left.pop();
            left.push(a[N+i]);
        }
        else{
            dpleft[i+1] = dpleft[i];
        }   
    }
    REP(i,N){
        if(a[2*N-1-i] < right.top()){
            dpright[i+1] = dpright[i] - right.top() + a[2*N-1-i];
            right.pop();
            right.push(a[2*N-1-i]);
        }
        else{
            dpright[i+1] = dpright[i];
        }
    }
    ll ans = -INF;
    REP(i,N+1){
        ans = max(ans,dpleft[i] - dpright[N-i]);
    }
    cout << ans << endl;

}


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

//const Long MX = ;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.precision(10);
	cout << fixed;

	Long n, m;
	cin >> n >> m;
	vector<Long> v(n,0);
	for(Long i = 0; i < n; i++){
		cin >> v[i];
	}
	
	sort(v.begin(),v.end());
	
	Long ans = 0;
	for(Long i = 0; i < m; i++) ans += v[i];
	
	cout << ans << "\n";
	return 0;
}


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

int main() {
    char c; cin >> c;
    string z = "abcdefghijklmnopqrstuvwxyz";

    for(int i=0; i<z.size(); i++){
        if(z.at(i)==c){
            cout << z.at(i+1) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,m;cin>>n>>m;
    vin c(m);
    rep(i,m)cin>>c[i];
    sort(all(c));
    vvin dp(m,vin(n+1));
    rep(i,n+1)dp[0][i]=i;
    rep(i,m-1)rep(j,n+1){
        if(c[i+1]>j)dp[i+1][j]=dp[i][j];
        else dp[i+1][j]=min(dp[i][j],dp[i+1][j-c[i+1]]+1);
    }
    cout<<dp[m-1][n]<<endl;
}


Measured memory_bytes: 7152
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;

const int maxN=3004;

int n,m;
char a[maxN],b[maxN];

int dp[maxN][maxN];

int main(){
    cin>>(a+1)>>(b+1);

    n=strlen(a+1);
    m=strlen(b+1);

    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int val=0;
            if(a[i]==b[j]){
                dp[i][j]=1+dp[i-1][j-1];
            } else {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }

    string sol="";
    int i=n,j=m;
    while(i>0){
        if(a[i]==b[j]){
            sol+=a[i];
            i--;
            j--;
        } else if(dp[i-1][j]<dp[i][j-1]){
            j--;
        } else {
            i--;
        }
    }

    int st=0;
    int dr=sol.size()-1;
    while(st<dr){
        swap(sol[st],sol[dr]);
        st++;
        dr--;
    }

    cout<<sol;

    return 0;
}

Measured memory_bytes: 35456
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph._shortest_path import floyd_warshall


def solve():
    H, W = map(int, input().split())
    c = [[] for _ in range(10)]
    for i in range(10):
        c[i] = list(map(int, input().split()))
    A = [[] for _ in range(H)]
    for i in range(H):
        A[i] = list(map(int, input().split()))
    
    fw = floyd_warshall(csr_matrix(c))
    power = [0 for _ in range(10)]
    for i in range(10):
        if i == 1:
            continue
        power[i] = fw[i][1]
    
    ans = 0
    for i in range(H):
        for j in range(W):
            if A[i][j] == -1 or A[i][j] == 1:
                continue
            ans += power[A[i][j]]
    print(int(ans))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 15748
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a*b > c*d)
		cout << a*b<<endl;
	else
		cout << c*d<<endl;
	return 0;
}

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

int main()
{
   int x,y;
   cin >> x >> y;
   vector<int> inte;
   inte = {0,1,3,1,2,1,2,1,1,2,1,2,1};
   if(inte[x] == inte[y]){
       cout << "Yes" << endl;
   }else {
       cout << "No" << endl;
   }
}
    

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

int main() {
 int N;
 cin >>N;
  if(N%10==2||N%10==5||N%10==4||N%10==7||N%10==9){
    cout <<"hon";
  }
  else if(N%10==3){
    cout <<"bon";
  }
  else {
    cout <<"pon";
  }
}

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

int N, M, Q;
int a[51], b[51], c[51], d[51], A[10];
long res;

void func(int k, int x)
{
    if (k==N) {
        long s=0;
        for(int i=0; i<Q; ++i)
            if (A[b[i]-1]-A[a[i]-1]==c[i]) s+=d[i];
        res=max(res, s);
        return;
    }
    for(int y=x; y<=M; ++y) {
        A[k]=x;
        func(k+1, y);
    }
}

int main()
{
    cin>>N>>M>>Q;
    for(int i=0; i<Q; ++i) cin>>a[i]>>b[i]>>c[i]>>d[i];

    res=0;
    for(int i=1; i<=M; ++i) func(0, i);
    cout<<res<<endl;
}


Measured memory_bytes: 3628
// {{{ Template for Competitive Programming
// -std=c++14 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define FOR(i, a, b)  for (int(i) = (a); (i) < (b); ++(i))
#define CFOR(i, a, b) for (int(i) = (a); (i) <= (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) >= (b); --(i))
#define rep(i, n) FOR((i), 0, (n))
#define crep(i, n) CFOR((i), 0, (n))
#define rrep(i, n) RFOR((i), (n), 0)
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(ALL(x), 0)

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

const int INF = 1'010'000'000'000'000'017LL;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

using vint = vector<int>;
using pint = pair<int, int>;
// }}}

signed main() {
	int n;
	cin >> n;
	vint h(n);
	vector<bool> check(n, true);
	for (auto &e : h) cin >> e;
	reverse(ALL(h));

	rep(i, n-1) {
		if (h[i+1] - h[i] > 1) {
			cout << "No" << endl;
			return 0;
		}
		else if (h[i+1] - h[i] > 0) {
			if (check[i+1]) {
				h[i+1]--;
				check[i+1] = false;
			}
		}
	}
	cout << "Yes" << endl;
}



Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(b!=100){
    if(a==0) printf("%d\n",b);
    else if(a==1) printf("%d\n",b*100);
    else printf("%d\n",b*10000);
    }
    else {
        if(a==0) printf("101\n");
    else if(a==1) printf("10100\n");
    else printf("1010000\n");
    }
    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left
N, M = map(int, input().split())
s = input()
safe = []
out = []
cnt = 0
for i, m in enumerate(s):
  if m=='1':
    out += [i]
    cnt += 1
    if cnt==M:
      print(-1)
      break
  else:
    safe += [i]
    cnt = 0
else:
  ps = N
  ans = []
  while ps!=0:
    ind = bisect_left(safe,ps-M)
    ans += [ps-safe[ind]]
    ps = safe[ind]
  print(*ans[::-1])
    

Measured memory_bytes: 10340
h,w,k=gets.split.map(&:to_i)

cakearray=[]
answerarray=Array.new(h).map{Array.new(w,0)}
h.times{
    cakearray.push(gets.chomp.split(''))
}

number=1
i=0
h.times{
    if cakearray[i].include?('#')
        j=0
        rowcount=0
        w.times{
            if cakearray[i][j]=="#" && rowcount==0
                rowcount+=1
                answerarray[i][j]=number
            elsif cakearray[i][j]=="#"
                number+=1
                answerarray[i][j]=number
            else
                answerarray[i][j]=number
            end
            j+=1
        }
        number+=1
    end
    i+=1
}


k=0
h.times{
    if answerarray[k][0]==0
        k+=1
    else
        break
    end
}

answerarray[0]=answerarray[k]

m=1
(h-1).times{
   if answerarray[m][0]==0
        answerarray[m]=answerarray[m-1]  
   end
   m+=1 
}


answerarray.map{|value|
    puts value.join(" ")
}

Measured memory_bytes: 11644
#include <iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>

#define pb push_back
#define mp make_pair

using namespace std;



int main()
{
      int n,k;
      int a[100010];
      cin>>n>>k;
      for( int i = 0;i<n;i++ )
      {
          cin>>a[i];
      }
     int curr=0,cnt=0;
     while( curr<n-1 )
     {
         curr+=k-1;
         cnt++;
     }

    cout<<cnt<<endl;
	return 0;
}





































Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test
{
    class Program
    {
        struct Vector
        {
            public decimal x;
            public decimal y;
        }

        static void Main(string[] args)
        {
            List<string> resultList = new List<string>();

            string input;
            while ((input = Console.ReadLine()) != null)
            {
                string[] inputArray = input.Split(' ');
                Vector A, B, C, P;
                A.x = decimal.Parse(inputArray[0]);
                A.y = decimal.Parse(inputArray[1]);
                B.x = decimal.Parse(inputArray[2]);
                B.y = decimal.Parse(inputArray[3]);
                C.x = decimal.Parse(inputArray[4]);
                C.y = decimal.Parse(inputArray[5]);
                P.x = decimal.Parse(inputArray[6]);
                P.y = decimal.Parse(inputArray[7]);

                Vector AP = GetVector(A, P);
                Vector AB = GetVector(A, B);
                Vector AC = GetVector(A, C);

                decimal s, t;

                if (AC.y != 0)
                {
                    s = (AP.x - AC.x * AP.y / AC.y) / (AB.x - AC.x * AB.y / AC.y);
                    t = (AP.y - AB.y * s) / AC.y;
                }
                else
                {
                    s = AP.y / AB.y;
                    t = (AP.x - AB.x * s) / AC.x; 
                }

                if (s > 0 && t > 0 && s + t < 1)
                {
                    resultList.Add("YES");
                }
                else
                {
                    resultList.Add("NO");
                }
            }

            foreach (string s in resultList)
            {
                Console.WriteLine(s);
            }


        }

        static Vector GetVector(Vector A, Vector B)
        {
            Vector AB;
            AB.x = B.x - A.x;
            AB.y = B.y - A.y;

            return AB;

        }

    }
}

Measured memory_bytes: 5796
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
#define ll long long
const int maxn = 1000 + 5;
map<ll,ll>dp;
ll w[maxn],v[maxn];
ll n,W;
int main()
{
    cin>>n>>W;
    for(int i=1; i<=n; i++)
    {
        scanf("%lld%lld",&w[i],&v[i]);
    }
    if(w[1]<=1e3)
    {
        ll ans=min(W,(w[1]+3)*n);
        for(ll i=1; i<=n; i++)
        {
            for(ll j=ans; j>=1; j--)
            {
                if(j>=w[i])
                    dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
            }
        }
        cout<<dp[ans]<<endl;
    }
    else
    {
        ll ans=min(W,(w[1]+3)*n);
        for(ll i=1; i<=n; i++)
        {
            for(ll j=ans; j>=w[1]; j-=w[1])
            {
                if(j>=w[i])
                    dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
            }
        }
        cout<<dp[ans]<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX_SIZE 400001
#define MAX_N 100001
using namespace std;
typedef long long ll;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

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

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}

ll sum(ll bit[], ll i){
    // sum of [1...i] 
    ll ans=0;
    while(i>0){
        ans+=bit[i];
        i-=i&(-i); // lowest set bit
    }
    return ans;
}

void update(ll bit[], ll n, ll i, ll delta){
    // update ith element with value of delta
    while(i<=n){
        bit[i]+=delta;
        i+=i&(-i);
    }
}

int main(){





    // #ifndef ONLINE_JUDGE 

    // // For getting input from input.txt file 
    // freopen("input.txt", "r", stdin); 

    // // Printing the Output to output.txt file 
    // freopen("output.txt", "w", stdout); 
    // #endif 




    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n=32;
    ll arr[n]={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};
    // for(ll i=0;i<n;i++){
    //     cin>>arr[i];
    // }
    ll k;
    cin>>k;

    cout<<arr[k-1]<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, m;
  cin >> n >> m;
  vector<vi> s(m);
  rep(i, m) {
    int k;
    cin >> k;
    rep(j, k) {
      int sw;
      cin >> sw;
      sw--;
      s[i].push_back(sw);
    }
  }
  vi p(m);
  rep(i, m) cin >> p[i];
  int ans = 0;
  rep(i, 1 << n) {
    vi on(n, false);
    rep(j, n) if(i >> j & 1) on[j] = true;
    bool ok = true;
    rep(k, m) {
      int cnt = 0;
      for(int v : s[k])
        if(on[v]) cnt++;
      if(cnt % 2 != p[k]) ok = false;
    }
    if(ok) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
const int MAXC = 205;
char S[MAXC], T[MAXC];

bool rotate_equals()
{
	int L = strlen(S);
	for(int i = 0; i < L; ++i)
	{
		S[i+L] = '\0';
		if(strcmp(S+i, T) == 0)
			return true;
		S[i+L] = S[i];
	}
	return false;
}

int main()
{
	scanf(" %s%s", S, T);
	puts(rotate_equals() ? "Yes" : "No");
    return 0;
}


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

using namespace std;

int count(vector<string> &g) {
  int res = 0;
  for (auto row : g) {
    for (auto c : row) {
      res += (c == '#');
    }
  }
  return res;
}

vector<string> paint(int h, int w, int rmask, int cmask, vector<string> &g) {
  auto res = g;
  for (int i = 0; i < h; i++) {
    if (rmask & (1 << i)) {
      for (int j = 0; j < w; j++) {
        res[i][j] = '.';
      }
    }
  }
  for (int j = 0; j < w; j++) {
    if (cmask & (1 << j)) {
      for (int i = 0; i < h; i++) {
        res[i][j] = '.';
      }
    }
  }
  return res;
}

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> g(h);
  for (int i = 0; i < h; i++) {
    cin >> g[i];
  }

  int num = 0;
  for (int i = 0; i < (1 << h); i++) {
    for (int j = 0; j < (1 << w); j++) {
      auto new_g = paint(h, w, i, j, g);
      num += (count(new_g) == k);
    }
  }

  cout << num << '\n';
  return 0;
}


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

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

int main(){
    int n,m;
    cin>>n>>m;
    int a[3];
    a[0]=a[1]=a[2]=-1;
    int s,c;
    int life=1;
    while(cin>>s>>c){
        if(s==1){
            if(n!=1&&c==0){
                life=0;
            }
        }
        if(a[s-1]==-1){
            a[s-1]=c;
        }else{
            if(a[s-1]==c){
                
            }else{
                life=0;
            }
        }
    }
    if(!life){
        cout<<"-1";
        return 0;
    }
    int sum=0;
    for(int i=0;i<n;i++){
        int tmp=0;
        if(a[i]==-1){
            if(n!=1&&i==0){
                tmp=1;
            }
        }else{
            tmp=a[i];
        }
        sum=sum*10+tmp;
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
ll Abs(ll x,ll y){
    if(x>=y)return x-y;
    else return y-x;
}

int 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};

int main(void){
    int k;
    cin>>k;
    k--;
    cout<<a[k]<<endl;
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Volume1_0100
{
    class Program
    {
        static void Main(string[] args)
        {
            int dataNum;
            var dataQueue = new Queue<List<Worker>>();

            while ((dataNum = int.Parse(Console.ReadLine())) != 0)
            {
                var workers = new List<Worker>();

                for (int i = 0; i < dataNum; i++)
                {
                    long[] data = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

                    var worker = new Worker()
                    {
                        Number = (int)data[0],
                        Money = data[1] * data[2]
                    };

                    if (workers.Any(w => w.Number == worker.Number))
                    {
                        workers.Where(w => w.Number == worker.Number).Single().Money += worker.Money;
                    }
                    else
                    {
                        workers.Add(worker);
                    }
                }

                dataQueue.Enqueue(workers);
            }

            foreach (var workers in dataQueue)
            {
                var goodWorkers = workers.Where(w => w.Money >= 1000000);

                foreach (var goodWorker in goodWorkers)
                {
                    Console.WriteLine(goodWorker.Number);
                }

                if (goodWorkers.Count() < 1)
                {
                    Console.WriteLine("NA");
                }
            }
        }
    }

    class Worker
    {
        public int Number { get; set; }
        public long Money { get; set; }
    }
}

Measured memory_bytes: 6460
#include <bits/stdc++.h> 
using namespace std;
int ans[1000002];
int ask(int x){
	if(x==2||x==3)return 2;
	int y=0;
	int k=(int)sqrt(x);
	for(int i=1;i<=k;i++){
		if(x%i==0)y++;
	}
	y*=2;
	if(k*k==x)y--;
	return y;
}
int tmp;
void process(){
	for(int i=2;i<=1e6;i++){
		ans[i]=tmp+ask(i-1);
		tmp=ans[i];
	}
}
int main(){
	int p,q;
	scanf("%d",&p);
	for(int i=1;i<=1e6;i++) ans[i]=0;
	ans[1]=0;
	tmp=0;
	process();
//	q=ask(p);
//	printf("%d",q);
	printf("%d",ans[p]);
} 

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

using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define MOD 1000000007
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 100005

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int len,arr[MAXN],K;
ll dp[MAXN];

ll solve(int idx){
    if(idx == 1) return 0;
    if(dp[idx] != -1) return dp[idx];
    ll ans = LONG_MAX;
    for(int i=idx-1; i>=max(1,idx-K); i--){
        ll nxt = abs(arr[idx]-arr[i])+solve(i);
        ans = min(ans,nxt);
    }
    return dp[idx] = ans;
}

int main(){
    scanf("%d %d",&len,&K);
    for(int i=1; i<=len; i++) scanf(" %d",&arr[i]);
    memset(dp,-1,sizeof dp);
    printf("%lld\n",solve(len));
}


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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim().ToCharArray();
        var t = Console.ReadLine().Trim().ToCharArray();

        var min = int.MaxValue;
        for (int i = 0; i + t.Length - 1 < s.Length; ++i)
        {
            var k = 0;
            for (int j = 0; j < t.Length; ++j)
            {
                if (s[i + j] != t[j])
                {
                    ++k;
                }
            }
            min = Math.Min(min, k);
        }

        Console.WriteLine(min);
    }
}


Measured memory_bytes: 25852
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

int main() {
  int H, W;
  cin >> H >> W;
  string S[H];
  REP(i, H) cin >> S[i];
  int l[H+2][W+2] = {};
  int r[H+2][W+2] = {};
  int t[H+2][W+2] = {};
  int b[H+2][W+2] = {};
  REP(i, H) {
    int count = 0;
    REP(j, W) {
      if (S[i][j] == '.') {
        count++;
        l[i+1][j+1] = count;
      } else {
        count = 0;
      }
    }
  }
  REP(i, H) {
    int count = 0;
    for (int j = W - 1; j >= 0; j--) {
      if (S[i][j] == '.') {
        count++;
        r[i+1][j+1] = count;
      } else {
        count = 0;
      }
    }
  }
  REP(i, W) {
    int count = 0;
    for (int j = 0; j < H; j++) {
      if (S[j][i] == '.') {
        count++;
        t[j+1][i+1] = count;
      } else {
        count = 0;
      }
    }
  }
  REP(i, W) {
    int count = 0;
    for (int j = H - 1; j >= 0; j--) {
      if (S[j][i] == '.') {
        count++;
        b[j+1][i+1] = count;
      } else {
        count = 0;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++) {
    if (S[i-1][j-1] == '.')
      ans = max(ans, l[i][j-1] + r[i][j+1] + t[i-1][j] + b[i+1][j] + 1);
  }
  cout << ans << '\n';
}


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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define B 1000000007

//ベクトル型、マトリックス型を導入
typedef long* vector;
typedef vector* matrix;

//v[0]~v[c-1]の添字のものを作る(初期値0)
vector create_vector(int c){
    vector v;
    NEW(v,c);
    for(int i=0;i<c;i++){
        v[i]=0;
    }
    return v;
}

//M[0][0]-M[0][c-1]-M[b-1][0]-M[b-1][c-1]の添字のものを作る
matrix create_matrix(int b, int c){
    matrix M;
    NEW(M,b);
    for(int i=0;i<b;i++){
        M[i]=create_vector(c);
    }
    return M;
}

//0C0〜N_C_Nまでのパスカルの三角形を作る(CはC[0][0]~C[N][N]のmatrix型のメモリ確保済み)
void build_pascals_triangle(matrix C, int N){
    //初期値にC[i][0]とC[i][i]を入れる
    for(int i=0;i<=N;i++){
        C[i][0]=1;
        C[i][i]=1;
    }

    //iCjをDPで入れる
    for(int i=1;i<=N;i++){
        for(int j=1;j<i;j++){
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%B;
        }
    }
    return;
}

int main(void){
    int N, K;
    scanf("%d %d",&N, &K);

    matrix C = create_matrix(N+1,N+1);
    build_pascals_triangle(C,N);

    for(int i=1;i<=K;i++){
        int ans=(C[N-K+1][i]*C[K-1][i-1])%B;
        printf("%d\n",ans);
    }

    return 0;
}

//400点
//パスカルの三角形をDPで求める手もある！！(Nがそこそこ小さかったら)

Measured memory_bytes: 31488
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;
vector<int> ps;
int smallest[10001];
long long modpow(long long x, long long n) { 
  if (n == 0) return 1%mod; 
  long long u = modpow(x,n/2); 
  u = (u*u)%mod; 
  if (n%2 == 1) u = (u*x)%mod; 
  return u;
}
void EE(int a, int b, int& x, int& y)
{
    if(a%b == 0)
    {
        x=0;
        y=1;
        return;
    }
    EE(b,a%b,x,y);
    int temp = x;
    x = y;
    y = temp - y*(a/b);
}
int inverse(int a)
{
    int x,y;
    EE(a,mod,x,y);
    if(x<0) x += mod;
    return x;

}
int main ()
{
  prep();
  for (int i=2; i<=10000; i++){
    if (smallest[i] == 0){
     ps.push_back(i);
     smallest[i] = i;
    }
    for (int j=0; j<ps.size(); j++){
     if (ps[j]*i > 10000 || ps[j] > smallest[i]){
       break;
     }
     smallest[ps[j]*i] = ps[j];
    }
  }

  int n;
  cin >> n;
  int arr[n];
  
  for (int i=0; i<n; i++){
      cin >> arr[i];
  }
  int freqs[10001] = {0};
  set<int> other;

  for (int i=0; i<n; i++){
      int cur = 0;
      int temp = arr[i];
      for (int j=0; j<ps.size(); j++){
          int cnt = 0;
          while (temp%ps[j] == 0){
              temp /= ps[j];
              cnt++;
          }
          if (cnt > freqs[j]){
              freqs[j] = cnt;
          }
      }
      if (temp > 1){
          other.insert(temp);
      }
      
  }
  long long lcm = 1;
  for (int i=0; i<=10000; i++){
      lcm *= modpow(ps[i], freqs[i]);
      lcm %= mod;
  }
  for (int i : other){
      lcm *= i;
      lcm %= mod;
  }
  //cout << lcm << endl;
  long long sum = 0;
  for (int i=0; i<n; i++){
      long long inv = inverse(arr[i]);
      sum += (lcm*inv)%mod;
      sum %= mod;
  }
  cout << sum;
  return 0; 
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
typedef vector<int,vector<int>> vvec;
typedef long double ld;

//----***Like a Pythonista***----
#define REP(i,j,n) for (ll i=j;i<(n);i++)
#define RREP(i,n,j) for (ll i = n; j<i;i--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(all(__VA_ARGS__),0LL)
#define dsum(...) accumulate(all(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(all(a)); }
template<class T> inline auto min(const T& a){ return *min_element(all(a)); }
inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

//----***定数***----
const int MOD=1000000007;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***----
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define HERE  cout<<"Here"<<endl;

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

int N,M;
string S;
signed main(){
  cin>>N;
  int ans=0;
  ans+=1000*(N/500);
  ans+=5*((N%500)/5);
  print(ans)
  
}


Measured memory_bytes: 256
#include<stdio.h>
 int main(void)
 {
     char S[5];
     int i,j=0;

     scanf("%s",S);

     for(i=0;i<4;i++){
       if(S[i]=='+') j++;
       else j--;
     }

     printf("%d\n",j);
     return 0;
 }



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p = 0;
    cin >> n >> m;
    ll arr[n];
    for(i = 0; i < n; i++){
        cin >> arr[i];
        sum += arr[i];
    }
    sort(arr,arr+n,greater<ll>());
    x = ceil((double)sum/(double)(4*m));
    for(i = 0; i < m; i++){
        if(arr[i] < x){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int h, w;
    std::cin>>h>>w;
    std::vector<std::string> c(h);
    for(int i = 0;i < h;i++){
        std::cin>>c[i];
    }
    for(int i = 0;i < h;i++){
        std::cout<<c[i]<<std::endl;
        std::cout<<c[i]<<std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
use std::collections::VecDeque;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let m: usize = sc.read();

    let mut graph = vec![vec![]; n];
    for _ in 0..m {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        graph[a].push(b);
        graph[b].push(a);
    }

    let mut vis = vec![false; n];
    let mut path = VecDeque::new();
    path.push_back(0);
    path.push_back(graph[0][0]);
    vis[0] = true;
    vis[graph[0][0]] = true;
    loop {
        let start = path.len();
        let head = path.pop_front().unwrap();
        path.push_front(head);
        let tail = path.pop_back().unwrap();
        path.push_back(tail);

        for &v in &graph[head] {
            if !vis[v] {
                vis[v] = true;
                path.push_front(v);
                break;
            }
        }

        for &v in &graph[tail] {
            if !vis[v] {
                vis[v] = true;
                path.push_back(v);
                break;
            }
        }

        if path.len() == start {
            break;
        }
    }

    println!("{}", path.len());
    while !path.is_empty() {
        print!("{} ", path.pop_front().unwrap() + 1);
    }
    println!();
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MAXN 10005
#define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;

int N;
int A[55];

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

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

	sort(A, A+N);

	double ans = A[0];
	for(int i = 1; i < N; i++){
		ans = (ans+A[i])/2;
	}

	cout << ans << "\n";

	return 0;		
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
long gcd(long x,long y){
	if(y == 0){
		return x;
	}
	return gcd(y,x%y);
}
void Calc(){
	long A = rel();
	long B = rel();
	long C = rei();
	long D = rei();
	long ans = B-A+1;
	ans -= B/C;
	ans += (A-1)/C;
	ans -= B/D;
	ans += (A-1)/D;
	long LCM = C*D/gcd(C,D);
	ans += B/LCM;
	ans -= (A-1)/LCM;
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

struct List {
    int prev, next;
};

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

    int m, n;
    while(cin >> m >> n && (m | n)){

        List l[1010];
        l[0].prev = m - 1;
        l[0].next = 1;
        for(int i = 1; i < m - 1; ++i){
            l[i].prev = i - 1;
            l[i].next = i + 1;
        }
        l[m - 1].prev = m - 2;
        l[m - 1].next = 0;

        int now = 0;
        bool check[1010];
        for(int i = 0; i < m; ++i){
            check[i] = true;
        }

        int cnt = 0;
        for(int i = 1; i <= n; ++i){
            string str;
            cin >> str;
            bool b1 = (i % 3 == 0 && i % 5 == 0 && str == "FizzBuzz");
            bool b2 = (i % 3 == 0 && i % 5 != 0 && str == "Fizz");
            bool b3 = (i % 3 != 0 && i % 5 == 0 && str == "Buzz");
            bool b4 = (i % 3 != 0 && i % 5 != 0 && str == to_string(i));
            if(cnt < m - 1){
                if(b1 || b2 || b3 || b4){
                    now = l[now].next;
                }
                else {
                    cnt++;
                    check[now] = false;
                    l[l[now].prev].next = l[now].next;
                    l[l[now].next].prev = l[now].prev;
                    now = l[now].next;
                }
            }
        }

        //cout << cnt << endl;

        bool check2 = false;
        for(int i = 0; i < m; ++i){
            if(check[i]){
                if(check2){
                    cout << ' ';
                }
                cout << i + 1;
                check2 = true;
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1260
N, T = map(int, input().split())
c = []
t = []
for _ in range(N):
    cc, tt = map(int, input().split())
    c.append(cc)
    t.append(tt)

INF = 1 << 30
ans = INF

for i in range(N):
    if t[i] <= T:
        ans = min(ans, c[i])

if ans < INF:
    print(ans)
else:
    print('TLE')

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

typedef long long int ll;

int main()
{
    ll n, m;
    cin >> n >> m;
    priority_queue<ll> a;
    for(ll i = 0;i < n;i++){
        ll t;
        cin >> t;
        a.push(t);
    }

    while(m != 0){
        ll t = a.top();
        a.pop();
        a.push(t / 2);
        m--;
    }

    ll ans = 0;
    while(!a.empty()){
        ans += a.top();
        a.pop();
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 1400
permutation_number = int(input())
permutation = list(map(int, input().split()))
conditional_permutation = 0
for i in range(permutation_number - 2):
    if permutation[i] < permutation[i + 1] < permutation[i + 2] or permutation[i] > permutation[i + 1] > permutation[i + 2]:
        conditional_permutation += 1
print(conditional_permutation)

Measured memory_bytes: 9044
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(ll i=a;i<(b);i++)
#define fj(a,b) for(ll j=a;j<(b);j++)
#define fk(a,b) for(ll k=a;k<(b);k++)
//hash base 177013


int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//while(testcase--)
	{
		int x;
		cin>>x;
		if(x==0)
		{
			
		}
		cout<<!x<<'\n';
		
		
		
	}
}



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

int main(){
  int N,M,i,p,ACcnt=0,WAcnt=0;
  string S;
  cin >> N >> M;
  map<int,pair<string,int>> AtCoder;

  for(i=0;i<M;i++){
    cin >> p >> S;
    if(AtCoder.count(p)){
      if(AtCoder.at(p).first=="WA"){
        if(S=="AC"){
          ACcnt++;
          AtCoder[p].first = "AC";
          WAcnt += AtCoder[p].second;
        }else
        AtCoder[p].second++;
      }
    }else{
      if(S=="WA"){
        AtCoder[p].first = "WA";
        AtCoder[p].second = 1;
      }else {
        ACcnt++;
        AtCoder[p].first = "AC";
      }
    }
  }
  cout << ACcnt << " " << WAcnt << endl;
}


Measured memory_bytes: 11136
object Main extends App {

  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()

  var a = new Array[Int](n)
  var b = new Array[Int](n)

  for (i <- 0 until n) a(i) = sc.nextInt()

  val halfSize: Int = (n.toDouble / 2).ceil.toInt

  val prefix = n % 2

  for (i <- 0 until n) {
    if ((n - 1) - 2 * i >= 0) {
      b(i) = a((n - 1) - 2 * i)
    } else {
      b(i) = a(prefix + 2 * (i - halfSize))
    }
  }
  
  println(b.mkString(" "))
}

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


int main(void) {

	// 1_4-B Circle

	double r,s,l;
	//double pi=3.1415926;
	scanf("%lf",&r);
	
	s = r*r*M_PI;
	l = 2*r*M_PI;
	
	printf(" %.5lf %.5lf",s,l);
        return 0;
}

Measured memory_bytes: 652