akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define FOR(x,y,z) for(int x=y;x<=z;++x)
#define N 100050
#define LL long long
using namespace std;
inline int in(){
    int w=0,x=0; char ch=0;
    while(!isdigit(ch)){w|=ch=='-';ch=getchar();}
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return w?-x:x;
}
const LL mod = 998244353;
int n, vis[N*3], cnt, A[3*N], ip[4][N];
int T[N][4];
LL ans = 1, x[N], y[N];
struct TMP{int a,b,c;} t[N];
/*void dfs(int now, int F, int num){
    if(num == 4){
        t[cnt].a = T[cnt][1];
        t[cnt].b = T[cnt][2];
        t[cnt].c = T[cnt][3];
        return;
    }
    while( (1<<A[now])&F || vis[now]) ++now,now = find(now);
    vis[now] = 1;
    fa[find(fa[now])] = now+1; 
    T[cnt][num] = now;
    dfs(now+1, F|(1<<A[now]), num+1);
}*/
 
void work(){
    int ind = 1;
    FOR(i,1,n){
        x[i] = x[i-1];
        for(;t[ind].a<t[i].b&& ind<=n;++ind){
            ++x[i];
        }
    }
    ind = n;
    for(int i = n;i>=1;--i){
        y[i] = y[i+1];
        for(;t[ind].c>t[i].b&& ind>=1;--ind){
            ++y[i];
        }
    }
    FOR(i,1,n-1){
        x[i+1] -= 1LL*i;
    }
    FOR(i,1,n-1){
        y[n-i] -= 1LL*i;
    }
    FOR(i,1,n){
        ans *= x[i]*y[i];
        ans %= mod;
    }
    ///FOR(i,1,n) cout<<x[i]<<" ";cout<<endl;
    //FOR(i,1,n) cout<<y[i]<<" ";cout<<endl;
    for(int i=1;i<=n;++i) ans *= 1LL*i, ans%=mod;
}
 
char ch[N*3];
int main(){
    //freopen("ac.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d",&n);
    scanf("%s",ch);
    FOR(i,1,3*n) {
        if(ch[i-1]=='R') {A[i] = 1; ip[1][++ip[1][0]] = i;}
        else if(ch[i-1]=='G') {A[i] = 2; ip[2][++ip[2][0]] = i;}
        else {A[i] = 3; ip[3][++ip[3][0]] = i;}
    }
     
    FOR(i,1,n){
        T[i][1] = ip[1][i];
        T[i][2] = ip[2][i];
        T[i][3] = ip[3][i];
        sort(T[i]+1,T[i]+4);
        t[i].a = T[i][1];
        t[i].b = T[i][2];
        t[i].c = T[i][3];
    }
     
    //FOR(i,1,3*n) {if(!vis[i]) ++cnt,dfs(i,0,1);}
    //FOR(i,1,n) {printf("%d %d %d\n",t[i].a,t[i].b,t[i].c);}
    work();
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8448
INF = 10**8

n, m = map(int, input().split())
c = list(map(int, input().split()))

d = [INF] * (n + 1)
d[0] = 0

for coin in c:
	for price in range(coin, n + 1):
		d[price] = min(d[price], d[price - coin] + 1)

print(d[n])


Measured memory_bytes: 7516
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  int N;in(N);
  vector<int>a(N);ins(a);
  int now=1,cnt=0;
  bool f=true;
  rep(i,N){
    if(a[i]!=now)cnt++;
    else now++;
    if(a[i]==1)f=false;
  }
  out(f?-1:cnt);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
	int i, j;
	int w, h;
	w = 0;
	h = 0;
	while (1)
	{
		scanf("%d%d", &w, &h);
		if (w == 0 && h == 0)
			break;
		for (i = 0;i < w;i++)
		{
			for (j = 0;j < h;j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2104
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD = 1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int par[1400001];
int rnk[1400001];

void init(int n){
	for(int i = 0;i < n;i++){
		par[i] = i;
		rnk[i] = 0;
	}
}

int find(int x){
	if(par[x] == x) return x;
	else return par[x] = find(par[x]);
}

void unite(int x,int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	if(rnk[x] < rnk[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if(rnk[x] == rnk[y]) rnk[x]++;
	}
}

bool same(int x,int y){
	return find(x) == find(y);
}

int n,m,q;
int a[100000];

bool fnd(int x){
	return upper_bound(a,a + q,x) - lower_bound(a,a + q,x);
}

signed main(){
	int n1,n2;
	cin >> n >> m >> q;
	init(m * 7);
	int nn,mm;
	if(m % 7 == 0){
		nn = n / (m / 7);
		mm = m / 7;
	}
	else{
		nn = n;
		mm = m;
	}
	for(int i = 0;i < q;i++) cin >> a[i];
	for(int i = 0;i < mm;i++){
		for(int j = 0;j < 7;j++){
			if(fnd((i * 7 + j) % m)) continue;
			for(int k = 0;k < 4;k++){
				int nx = i + dx[k],ny = j + dy[k];
				if(nx >= 0 && nx < m && ny >= 0 && ny < 7){
					if(!fnd((nx * 7 + ny) % m)) unite(i * 7 + j,nx * 7 + ny);
				}
			}
		}
	}
	set<int> st;
	for(int i = 0;i < mm;i++){
		for(int j = 0;j < 7;j++){
			if(fnd((i * 7 + j) % m)) continue;
			st.insert(find(i * 7 + j));
		}
	}
	n1 = st.size();
	if((m % 7 && n <= m) || (m % 7 == 0 && nn == 1)){
		cout << n1 << endl;
		return 0;
	}
	init(m * 14);
	for(int i = 0;i < 2 * mm;i++){
		for(int j = 0;j < 7;j++){
			if(fnd((i * 7 + j) % m)) continue;
			for(int k = 0;k < 4;k++){
				int nx = i + dx[k],ny = j + dy[k];
				if(nx >= 0 && nx < 2 * m && ny >= 0 && ny < 7){
					if(!fnd((nx * 7 + ny) % m)) unite(i * 7 + j,nx * 7 + ny);
				}
			}
		}
	}
	st.clear();
	for(int i = 0;i < 2 * mm;i++){
		for(int j = 0;j < 7;j++){
			if(fnd((i * 7 + j) % m)) continue;
			st.insert(find(i * 7 + j));
		}
	}
	n2 = st.size();
	if(m % 7) cout << n1 + (n2 - n1) * (n / m - 1) << endl;
	else cout << n1 + (n2 - n1) * (nn - 1) << endl;
	return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF INT_MAX
#define MOD 100000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  ll N,M;
  cin>>N>>M;
  vector<ll>A(N),B(M),C(M);
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<M;i++)cin>>B[i]>>C[i];
  vector<pair<ll,ll>>P(M);
  for(int i=0;i<M;i++)P[i]={C[i],B[i]};
  sort(rng(P));
  reverse(rng(P));
  sort(rng(A));
  vector<ll>sum(N+1);
  sum[0]=0;
  for(int i=1;i<=N;i++)sum[i]=sum[i-1]+A[i-1];
  ll now=0;
  ll ans=sum[N];
  for(int i=0;i<M;i++){
    /*
    if(now+P[i].second<=N&&P[i].first*P[i].second>sum[now+P[i].second]-sum[now]){
      ans-=sum[now+P[i].second]-sum[now];
      ans+=P[i].first*P[i].second;
      now=P[i].second;
    }
    */
    ll l=now-1;
    ll r=min(now+P[i].second,N);
    ll m;
    while(r-l>1){
      m=(r+l)/2;
      if(P[i].first>A[m])l=m;
      else r=m;
    }
    ans-=sum[r]-sum[now];
    ans+=(r-now)*P[i].first;
    now=r;
  }
  cout<<ans<<endl;
  return 0;
}


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



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

  vector<int> lr(2);
  for (int i = 0;i < m;i++){
    int l,r;
    cin >> l >> r;
    if (i == 0){
      lr.at(0) = l;
      lr.at(1) = r;
    }else{
      if (lr.at(0) <= l){
        lr.at(0) = l;
      }
      if (lr.at(1) >= r){
        lr.at(1) = r;
      }
    }

  }

  int ans = 0;
  ans = max(lr.at(1)-lr.at(0)+1,0);
  cout << ans;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    
    long long A, B, K;
    cin >> A >> B >> K;
    
    if(A - K > 0){
        cout << A - K << " " << B << endl;
    }
    else if(B - (K - A) > 0){
        cout << 0 << " " << B - (K - A) << endl;
    }
    else{
        cout << 0 << " " << 0 <<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong p) {
	int i=0;
	for(int j = 0; j < k; j++ ) {
		llong sum = 0;
		while( sum + T[i] <= p) {
			sum += T[i];
			i++;
			if(i == n ) return n;
		}
	}
	return i;
}

int solve() {
	llong left = 0;
	llong right = 100000 * 10000;
	llong mid; 
	while(left <= right) {
		mid = left + (right - left) / 2;
		int v = check(mid);
		if(v >= n) right = mid -1;
		else left = mid + 1;
	}
	return left;
}

main() {
	cin >> n >> k;
	for( int i = 0; i < n; i++) cin >> T[i];
	llong ans = solve();
	cout << ans << endl;
}

 

Measured memory_bytes: 3848
/* ABC168_C
    Stuartyg */

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

int main(void){
        int hour_hand,minute_hand; /*A,Bのこと*/
        int hour,minute; /*h,mのこと*/
        scanf("%d %d %d %d",&hour_hand,&minute_hand,&hour,&minute); /*標準入力から受け取る*/

        double angle,ans;
        /*長針と短針がH:Mの時刻になす角をもとめる*/
        angle = (30*hour - 5.5*minute) / 180 * M_PI;
        /*H:00の時刻には長針と短針は30*hourだけずれている。
        1分間で長針は短針より5.5度分多く進見、追い越そうとする。
        それをラジアンに直す*/

        ans = sqrt(pow(hour_hand,2) + pow(minute_hand,2) -2*hour_hand*minute_hand*cos(angle));
        /*余弦定理*/
        printf("%.10f\n",ans);
        /*小数点以下10桁まで表示*/
        return 0;
}


Measured memory_bytes: 2584
#include <iostream>
#include <cmath>
using namespace std;
using ll = long long;

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

  ll X[N];
  ll zero = -1;
  ll maxIdx = 0;
  for (ll i = 0; i < N; i++)
  {
    cin >> X[i];
    if (zero == -1 && X[i] >= 0)
      zero = i;
    maxIdx = i;
  }

  if (zero == -1)
  {
    cout << abs(X[maxIdx - K + 1]);
    return 0;
  }
  if (zero == 0)
  {
    cout << abs(X[K - 1]);
    return 0;
  }

  ll left = 0, right = 0;
  if (zero <= K)
  {
    left = 0;
  }
  else if (zero > K)
  {
    left = zero - K;
  }
  right = zero + K - 1;

  // cout << "zero: " << zero << " left: " << left << " right: " << right << endl;

  ll ans = 1000000000;
  for (ll i = 0; i < (right - left + 1 - K + 1); i++)
  {
    ll sum1 = 0;
    ll sum2 = 0;
    if (left + i + K - 1 > maxIdx)
      break;
    sum1 += abs(X[left + i]) * 2 + X[left + i + K - 1];
    sum2 += abs(X[left + i]) + X[left + i + K - 1] * 2;
    ll sum = min(sum1, sum2);
    ans = min(ans, sum);
  }

  cout << ans;

  return 0;
}

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

int main() {

    int n, x;
    cin >> n >> x;

    vector<int> donut(n);
    int min = 1000;
    for (int i = 0; i < n; i++) {

        cin >> donut[i];
        x -= donut[i];
        
        if(min > donut[i]) min = donut[i];

    }

    int cnt = 0;

    cnt = n + (x / min);

    cout << cnt << endl; 
    
    return 0;

}

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

int main(void) {
    int N;
    int flg = 0;
    int i;
    int j;
    int f;
    int s;
    
    scanf("%d", &N);
    for (i=0; i<26; i++) {
        f = i * 4;
        if ((N - f) == 0) {
            flg = 1;
            break;
        }
        for (j=1; j<15; j++) {
            s = j * 7;
            if (((N - f) - s) == 0) {
                flg = 1;
                break;
            }
        }
        if (flg == 1) {
            break;
        }
    }
    if (flg == 1) {
        printf("Yes");
    } else {
        printf("No");
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int s;
long long f[2005];
const int mod=1e9+7;
/*
¿¼ÊÔµÄÊ±ºòÊ²Ã´¶¼ÏëÁË 
Ïë¹ý´ò±í£¨Ëã²»³ö±í£©Ïë¹ý×Ü·½°¸¼õ£¨Á¬×Ü·½°¸¶¼Ëã²»³öÀ´£© 
ÍòÍòÃ»Ïëµ½ÕâÊÇ¸ödp 
f[i]±íÊ¾°Ñi°´ÕÕÌâÒâ·Ö½âµÄ·½°¸ 
µ±i>=6Ê±£¬f[i]=sum(f[i-j])£¬3<=j<=i-3 
¾ÍÍêÁË 
*/ 
int main()
{
    cin>>s;
    if(s<3)
    {
    	cout<<0<<endl;
    	return 0;
	}
	for(int i=3;i<=s;i++)
	{
		f[i]=1;//Ö»ÓÐËü×Ô¼º 
		for(int j=3;i-j>=3;j++)
			f[i]=(f[i]+f[i-j])%mod;
	}
    cout<<f[s]<<endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 3668
require 'prime'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end
n = gif
k = gif
x = gif
y = gif

if n > k
	puts y*(n-k)+x*k
else
	puts x*n
end

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

ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
ll mpower(ll a,ll b,ll c){
  int z;
  if(b==0){
    z=1;
    z%=c;
    return z;
  }
  if(b==1){
    z=a;
    z%=c;
    return z;
  }
  else{
    return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
  }
}
 
int main(){
  int n,x,y;
  cin>>n>>x>>y;
  map<int,ll> ans;
  int a;
  for(int i=1;i<=n-1;i++){
    for(int j=i+1;j<=n;j++){
      a=abs(j-i);
      a=min(a,abs(x-i)+1+abs(j-y));
      ans[a]++;
    }
  }
  for(int i=1;i<n;i++){
    cout<<ans[i]<<endl;
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define maxn 100003
using namespace std;
int a[maxn],n,buc[2][maxn];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i),buc[i&1][a[i]]++;
	int mx=0,mxcnt=0,mx2=0,mx2cnt=0;
	for(int i=1;i<=100000;i++){
		if(buc[0][i]>mxcnt)mx2=mx,mx2cnt=mxcnt,mx=i,mxcnt=buc[0][i];
		else if(buc[0][i]>mx2cnt)mx2=i,mx2cnt=buc[0][i];
	}
	int ans=maxn;
	for(int i=1;i<=n;i+=2){
		ans=min(ans,n/2-buc[1][a[i]]+(a[i]==mx?n/2-mx2cnt:n/2-mxcnt));
	}
	printf("%d\n",ans);
	return 0;
}

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


int main(){
    char b;
    cin >> b;
    
    if(b == 'A') cout << 'T' << endl;
    else if(b == 'T') cout << 'A' << endl;
    else if(b == 'C') cout << 'G' << endl;
    else cout << 'C' << endl;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll A, B, C;

int main() {
	scanf("%lld %lld %lld", &A, &B, &C);
	if(A + B + C >= 22) {
		printf("bust\n");
	}
	else {
		printf("win\n");
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

int main()
{
    int l;
    char cf[10000];
    while(~(scanf("%s",cf)))
    {
        l=strlen(cf);
        if(l!=6)
        {
            printf("No\n");
        }
        else
        {
            if(cf[2]==cf[3]&&cf[4]==cf[5])
            {
                printf("Yes\n");
            }
            else
            {
                printf("No\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 128
def dfs(v)
  @used[v] = true
  G[v].each do |u|
    next if @used[u]
    next if @ex == [v, u]
    dfs(u)
  end
end

N, M = gets.split.map(&:to_i)
G = Array.new(N) { [] }
es = []
M.times do
  a, b = gets.split.map(&:to_i)
  G[a - 1] << b - 1
  G[b - 1] << a - 1
  es << [a - 1, b - 1]
end

ans = 0
es.each do |e|
  @ex = e
  @used = Array.new(N, false)
  dfs(e[0])
  ans += 1 unless @used[e[1]]
end

puts ans


Measured memory_bytes: 1916
def calc_score(li):
    prev = li[0]
    ret = 0
    for el in li:
        ret += abs(el - prev)
        prev = el
    return ret


N, *A = map(int, open(0).read().split())
A = sorted(A)
if N % 2:
    ans = 0
    li = [0] * N
    li[0] = A[N // 2]
    for i in range(N // 2):
        li[i * 2 + 1] = A[i + N // 2 + 1]
        li[i * 2 + 2] = A[i]
    ans = calc_score(li)
    li[N - 1] = A[N // 2]
    for i in range(N // 2):
        li[i * 2] = A[i + N // 2 + 1]
        li[i * 2 + 1] = A[i]
    print(max(ans, calc_score(li)))
else:
    li = [0] * N
    for i in range(N // 2):
        li[i * 2] = A[i + N // 2]
        li[i * 2 + 1] = A[i]
    print(calc_score(li))


Measured memory_bytes: 20196
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    
    if(n>=1 && n<=10000){
      int ans = n % 1000;
      if(ans != 0){
        ans = 1000 - ans;
        System.out.println(ans);
      }else{
       System.out.println(0);
      }  
    }else{
      System.out.println("入力条件に違反しています");
    }
  }  
}


Measured memory_bytes: 35628
import functools


N, MOD = int(input()), 10 ** 9 + 7


@functools.lru_cache(maxsize=None)
def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i-1], t[i] = t[i], t[i-1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True


@functools.lru_cache(maxsize=None)
def dfs(cur, last3):
    if cur == N:
        return 1
    ret = 0
    for c in 'ACGT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    return ret


print(dfs(0, 'TTT'))


Measured memory_bytes: 5588
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    char a,b; cin>>a>>b;
    if(a=='H'){
        cout<<b<<endl;
    }
    else{
        if(b=='H')cout<<'D'<<endl;
        else cout<<'H'<<endl;
    }
}



























Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    	Scanner scan=new Scanner(System.in);
    	int a=scan.nextInt();
    	int b[]=new int[a];
    	for(int i=0;i!=a;i++) {
    		b[i]=scan.nextInt();
    	}
    	int ans=0;
    	for(int i=0;i!=a;i++) {
    		if(b[i]%2==0) {
    			b[i]/=2;
    			ans++;
    			i=i-1;
    		}
    	}
    	System.out.println(ans);
    }
}

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

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;

int main() {
    constexpr int C_MAX = 100000;
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    REP(i, R) {
        cin >> r[i];
        --r[i];
    }
    vector<vector<pii>> g(N);
    REP(i, M) {
        int A, B, C;
        cin >> A >> B >> C;
        --A; --B;
        g[A].push_back(pii(B, C));
        g[B].push_back(pii(A, C));
    }

    const ll INF = (N << R) * C_MAX;
    ll result = INF;
    int mask = (1 << R) - 1;
    REP(start, R) {
        vector<int> dp(N << R, INF);
        priority_queue<pli, vector<pli>, greater<pli>> q;
        dp[(r[start] << R) ^ (1 << start)] = 0;
        q.push(pli(0, r[start] << R ^ 1 << start));
        while (!q.empty()) {
            ll d;
            int state;
            tie(d, state) = q.top();
            q.pop();
            if (dp[state] < d) {
                continue;
            }
            int u = state >> R;
            int visited = state & mask;
            if (visited == mask) {
                result = min(result, d);
                break;
            }
            for (const pii &edge: g[u]) {
                int v = edge.first;
                int cost = edge.second;
                int k = distance(r.begin(), find(all(r), v));
                if (visited & 1 << k) {
                    continue;
                }
                int visited_next;
                if (k == R) {
                    visited_next = visited;
                } else {
                    visited_next = visited | 1 << k;
                }
                int state_next = v << R ^ visited_next;
                if (dp[state_next] > d + cost) {
                    dp[state_next] = d + cost;
                    q.push(pli(dp[state_next], state_next));
                }
            }
        }
    }
    cout << result << endl;

    return 0;
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define pb push_back
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;

const ll maxn = 1e5 + 10, MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

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


ll zh[43], fu[43];

ll z[43], f[43];

void init() {
    for (int i = 0; i < 44; i += 2){
        zh[i/2] = (1ll) << i;
    }
    for (int i = 1; i < 44; i += 2) {
        fu[i/2] = (1ll) << i;
    }
    for (int i = 0; i < 44; i++) {
        if (i == 0) {
            z[i] = zh[i];
            f[i] = fu[i];
        } else {
            z[i] += z[i - 1] + zh[i];
            f[i] += f[i - 1] + fu[i];
        }
    }
//    for (int i = 0; i < 10; i++) cout << zh[i] << ' ';cout << endl;
//    for (int i = 0; i < 10; i++) cout << fu[i] << ' '; cout <<endl;
//    for (int i = 0; i < 10; i++) cout << z[i] << ' ';cout << endl;
//    for (int i = 0; i < 10; i++) cout << f[i] << ' '; cout <<endl;
}



int sb[44];

int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
//    ios_base::sync_with_stdio(0);
    init();
    vector<int> res;
    ll n;
    while (cin >>n) {
        res.clear();
        memset(sb, 0, sizeof sb);
        while (n) {
//            cout << n << endl;
            if (n > 0){
                int le = lower_bound(z, z + 44, n) - z;
                res.pb((le) * 2);
                n = n - zh[le];
            } else {
                int le = lower_bound(f, f + 44, -n) - f;
    //            cout << le <<endl;
    //            cout << " Test:   " << (le + 1) * 2 - 1 << endl;
                int tt = (le + 1) * 2 - 1;
    //            cout << tt <<endl;
                res.push_back(tt);
    //            puts("SBSBSB");
                n = n + fu[le];
    //            cout << n <<endl;
    //            break;
            }
        }
        sort(res.rbegin(), res.rend());
        for (auto it : res) {
            sb[it] = 1;
    //        cout <<it <<endl;
        }
        int flg = false;
        for (int i = 44; i >= 0; i--) {
            if (flg) {
                cout << sb[i];continue;
            }
            if (sb[i]) {
    //            cout << i <<endl;
                flg = 1;
                cout << 1;
            }
        }
        if (!flg) cout << 0;
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int max=1000001;

	int[] dp1, dp2;
	int n;

	void run(){
		dp1=new int[max];
		dp2=new int[max];
		fill(dp1, INF);
		fill(dp2, INF);
		dp1[0]=0;
		dp2[0]=0;

		for(int i=0; i<max; i++){
			for(int j=1, sum=1; i+sum<max; j++, sum+=j*(j+1)/2){
				dp1[i+sum]=min(dp1[i+sum], dp1[i]+1);
				if(sum%2==1){
					dp2[i+sum]=min(dp2[i+sum], dp2[i]+1);
				}
			}
		}

		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			solve();
		}
	}

	void solve(){
		println(dp1[n]+" "+dp2[n]);
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 20000
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

# sys.setrecursionlimit(100000)
input = sys.stdin.buffer.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B, N):
    x = min(B - 1, N)
    ans = A*x//B - A*(x//B)
    return ans


def main():
    A, B, N = read_int_n()
    print(slv(A, B, N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 83652
# -*- coding: utf-8 -*-
N, C = map(int, input().split())

D = []
for c in range(C):
    D.append([int(d) for d in input().split()])

Gmod = [[0 for i in range(C)] for i in range(3)]
for n in range(N):
    for m, g in enumerate(input().split()):
        Gmod[(n + m) % 3][int(g) - 1] += 1

K = []
for c0 in range(C):
    d0 = sum([Gmod[0][c] * D[c][c0] for c in range(C)])
    for c1 in [i for i in range(C) if not i == c0]:
        d1 = sum([Gmod[1][c] * D[c][c1] for c in range(C)])
        for c2 in [i for i in range(C) if (not i == c0) and (not i == c1)]:
            d2 = sum([Gmod[2][c] * D[c][c2] for c in range(C)])
            K.append(d0 + d1 + d2)

print(min(K))


Measured memory_bytes: 4076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int N = 1e5, M = 2e5, INF = 1000'000'000;
vector<PII> adj[N];
PII edges[M];
int d[N];
int wt[M];

void NO() {
  cout << -1 << endl;
  exit(0);
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n, m; cin >> n >> m;
  int d_min = INF;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    d_min = min(d_min, d[i]);
  }
  for (int i = 0; i < m; i++) {
    int u, v; cin >> u >> v; u--, v--;
    adj[u].emplace_back(i, v);
    adj[v].emplace_back(i, u);
    edges[i] = make_pair(u, v);
    wt[i] = INF;
  }

  string col(n, '*');
  queue<int> Q;
  for (int u = 0; u < n; u++) {
    for (auto& e: adj[u]) {
      const int v = e.second, i = e.first;
      if (d[u] == d[v]) {
        if (col[u] != '*' || col[v] != '*') continue;
        col[u] = 'W';
        col[v] = 'B';
        Q.push(u);
        Q.push(v);
        wt[i] = d[u];
      }
    }
  }

  while (!Q.empty()) {
    int u = Q.front(); Q.pop();
    for (auto& e: adj[u]) {
      const int v = e.second, i = e.first;
      if (col[v] != '*' || d[v] < d[u]) continue;
      col[v] = col[u] ^ 'W' ^ 'B';
      wt[i] = d[v];
      Q.push(v);
    }
  }

  for (char ch: col) {
    if (ch == '*') NO();
  }

  // answer
  cout << col << '\n';
  for (int i = 0; i < m; i++) {
    cout << wt[i] << '\n';
  }

  return 0;
}


Measured memory_bytes: 13440
#include<stdio.h>
int main(void)
{
int n,m,a[10000],sum,i;
sum = 0;
scanf("%d %d",&n,&m);
for(i=0;i<m;i++){
  scanf("%d",&a[i]);
  sum += a[i];
}
if(n<sum)
	printf("-1");
else
	printf("%d",n - sum);
return 0;
}


Measured memory_bytes: 2128
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>

using namespace std;

typedef long long ll;
const int Max = 1e5 + 5;
ll n, m, t, k, i, j, p, q, flag, ans;

int main(){
	while(scanf("%lld %lld", &n, &m) == 2){
		ans = 0;
		int a[100][100] = {0};
		for(i = 0; i < n; i++){
			cin >> t;
			for(j = 0; j < t; j++) { cin >> k; a[i][k]++; }
		}
		for(j = 0; j <= m; j++){
			flag = 0;
			for(i = 0; i < n; i++){
				if(a[i][j] > 0) flag++;
			}
			if(flag == n) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
int a(int n){
	if(n==0)return 1;
	else return 2*a(n-1)+3;
}
int p(int n){
	if(n==0)return 1;
	else return 2*p(n-1)+1;
}

int f(int n,int x){
	if(n==0&&x==1) return 1;
	else if(x==1)return 0;
	else if(2<=x&&x<=a(n-1)+1) return f(n-1,x-1);
	else if(x==a(n-1)+2) return p(n-1)+1;
	else if(a(n-1)+3<=x&&x<=2*a(n-1)+2)  return p(n-1)+1+f(n-1,x-a(n-1)-2);
	else if(x==2*a(n-1)+3)return 2*p(n-1)+1;
}

signed main(){
	int n,x;
	cin>>n>>x;
	cout<<f(n,x)<<endl;

	// string s="P";
	// rep(i,n){
	// 	s='B'+s+'P'+s+'B';
	// }
	// cout<<s<<endl;
	// int cnt=0;
	// rep(i,x){
	// 	cnt+=s[i]=='P';
	// }		
	// cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 3608
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 300005;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()

int32_t main()
{ 
  IOS

  int n;
  cin>>n;
  int ans = 0;
  for(int i = 2;i*i<=n;i++){
    if(n%i == 0){
      int cnt = 0;
      while(n%i == 0){
        cnt++;
        n/=i;
      }
      int pos = 1;
      for(int  j = 1;j<=cnt;j++){
        if((j*(j+1))<=2*cnt){
          pos = j;
          //trace(pos);
          
        }
        else break;
      }
      ans+=pos;
    }
  }
  if(n>1)
    ans++;
  cout<<ans<<endl;
  
  

}
 

Measured memory_bytes: 3688
N = int(input())
c = input()
red_to_white = c.count("R")
ans = red_to_white
while_to_red = 0

for i in c:
    if i == "W":
        while_to_red += 1 
    else:
        red_to_white -= 1
    ans = min(ans,max(while_to_red,red_to_white))

print(ans)

Measured memory_bytes: 9400
<?php
fscanf(STDIN, '%s %s', $s, $t);
fscanf(STDIN, '%d %d', $a, $b);
fscanf(STDIN, '%s',$u);
if($u == $s) {
    $a--;
} else {
    $b--;
}
echo $a. ' '. $b, PHP_EOL;

Measured memory_bytes: 4728
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */


int main() {
    ll l, r;
    ll ans = 2019;
    cin >> l >> r;
    if (r - l >= 100000) {
        cout << 0 << endl;
    } else {
        for (ll i = l; i < r; ++i) {
            for (ll j = l+1; j <= r; ++j) {
                chmin(ans, i*j% 2019);

            }
        }
        cout <<ans<< endl;
    }
}



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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int n; cin >> n;
  if (n % 2 == 0) cout << n << endl;
  else cout << n * 2 << endl;
}


Measured memory_bytes: 888
function Main(input) {
	input = input.split("\n");
	input[0] = input[0].split(' ');
	input[1] = input[1].split(' ');
	var sum = new Array(input[0][0] - input[0][1] + 1);
	for(var i=0; i<2; i++){
    	input[0][i] = parseInt(input[0][i], 10);
    }
  var sig = 0;
	var max = 0;
	var maxN = 0;
	for(var i=0; i<input[0][0]; i++){
    	input[1][i] = parseInt(input[1][i], 10);
    	input[1][i] = (input[1][i]+1)/2;
    	sig += input[1][i];
        if(i >= input[0][1] - 1){
        	sum[i-input[0][1]+1] = sig;
        	sig -= input[1][i-input[0][1]+1];
        	if(max < sum[i-input[0][1]+1]){
       			max = sum[i-input[0][1]+1];
        		maxN = i-input[0][1]+1;
        	}
        }
    }
	console.log(sum[maxN]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 34424
#include <iostream>
#define P 55556
using namespace std;

int main(){
    int prime[P],i,j,N,count=0;
    cin >> N;
    for(i=2;i<P;i++){
        prime[i] = 1;
    }
    for(i=2;i<P/2;i++){
        if(prime[i]==1){
            for(j=i*2;j<P;j+=i){
                prime[j] = 0;
            }
        }
    }
    for(i=2;i<P;i++){
        if(prime[i]==1&&i%5==1){
            cout << i << " ";
            count++;
        }
        if(count==N){
            break;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
#include<algorithm>
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define fasti ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
ll ans=0;
     
void prime(ll n) 
{ 
    vi a;
    while(n%2==0) 
    { 
        a.pb(2);
        n = n/2; 
    } 
    for (int i = 3; i <= sqrt(n); i = i + 2) 
    { 
        while (n % i == 0) 
        { 
            a.pb(i) ;
            n = n/i; 
        } 
    } 

    if (n > 2) 
        a.pb(n);
    ans=0;
    set<ll>s;
    multiset<ll>ms;
    f(i,(ll)a.size())
    {
        s.insert(a[i]);
        ms.insert(a[i]);
    }
    vi a1;
    for(auto itr=s.begin();itr!=s.end();itr++)
    {
        a1.pb(2*(ms.count(*itr)));
    }
    f(i,(ll)a1.size())
    {
        ll j=1;
        while(1)
        {
            if(j*(j+1)>a1[i])
            {
                j--;
                break;
            }
            j++;
        }
        ans+=j;
    }
} 
int main()
{
fasti;
    ll n;
    cin>>n;
    prime(n);
    cout<<ans;
    return 0;
}

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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int H,W,h,w;

    cin>>H>>W>>h>>w;

    cout<<H*W-(W*h+H*w-h*w)<<endl;

    return 0;
}


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    Int res = 0;
    Int ma = a[0];
    for (Int i = 1; i < n; i++) {
        if (ma > a[i]) {
            res += ma - a[i];
        } else {
            ma = max(ma, a[i]);
        }
    }
    print(res);
    return 0;
}


Measured memory_bytes: 4744
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
//#define MOD 1000000007 //10^9+7
#define MOD 10007

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

int main(void){

  ll a,b,c,d;
  cin>>a>>b>>c>>d;

  ll count = 0;
  ll t;
  while(1){
    if(count%2==0){
      c = c-b;
      if(c<=0){
        cout<<"Yes"<<endl;
        return 0;
      }
    }else{
      a = a - d;
      if(a<=0){
        cout<<"No"<<endl;
        return 0;
      }
    }
    count++;

  }
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  string S;
  cin >> N >> S;
  stack<char> st;
  int ans = 0;
  REP(i, N)
  {
    if (st.size() == 0 || S[i] == '#')
      st.push(S[i]);
    else if (S[i] == '.')
    {
      if (st.top() == '#')
      {
        st.pop();
        ans++;
      }
      else
      {
        st.push(S[i]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  LL ans = 0, sum = 0;
  rep(i, n) {
    if (a[i] == 0) {
      ans += sum / 2;
      sum = 0;
    } else {
      sum += a[i];
    }
  }
  ans += sum / 2;

  cout << ans << endl;
}

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

int main() {
    ll X, money = 100, ans = 0;
    cin >> X;
    REP(i,100000000000000000){
        ans++;
        money = 1.01 * money;
        if(money >= X){
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();
        int[] Xz = new int[N];
        int[] Yz = new int[N];
        for (int i = 0; i < N; i++){
            Xz[i] = sc.nextInt();
            Yz[i] = sc.nextInt();
        }
        double ans = 0;
        int cnt = 0;
        for (int i = 0; i < N; i++){
            ans = Math.sqrt(Math.pow(Xz[i], 2) + Math.pow(Yz[i], 2));
            if (ans <= D){
                cnt++;
            }
        }
        System.out.println(cnt);

    }
}

Measured memory_bytes: 62484
#include <stdio.h>

int main(void){
    int w, h, x, y, r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    
    if(((x+r)<=w)&&((y+r)<=h)&&((x-r)>=0)&&((y-r)>=0))
        printf("Yes\n");
    else
        printf("No\n");
    
    return 0;
}


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

int main() {

    string s;
    cin >> s;
    long w_sum = 0;
    long len = s.length();
    long b_count = 0;
    for (int i = 0 ; i < s.length(); i++) {
        if (s[i] == 'W')  w_sum += b_count;
        else if (s[i] == 'B') b_count += 1;
    }
    cout << w_sum ;
    return 0;
}

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

int main() {
	long long n, a, b;
	cin >> n >> a >> b;

	if((a + b) % 2 == 0) {
		cout << (b - a)/2 << endl;
	} else {
		cout << min(a - 1, n - b) + 1 + (b - a - 1)/2 << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;

ll n, t, a[200005], ans;

int main()
{
	scanf("%lld%lld",&n,&t);
	for(ll i=1;i<=n;i++) scanf("%d",&a[i]);
	a[n+1] = inf;
	for(ll i=1;i<=n;i++) {
		ans += min(a[i+1]-a[i], t);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main
{
  
  public static void main(String[] args)
  {
    Scanner scan = new Scanner(System.in);
    
    int a = scan.nextInt();
    int b = scan.nextInt();
    
    int multiplyNum = a * b;
    
    String result = (multiplyNum % 2 == 0) ? "Even" : "Odd";
    System.out.println(result);
  }
}

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

int main(){
  int k, n; cin>>k>>n;
  vector<int> a(n+1);
  a[0]=0;
  for(int i=1; i<=n; ++i)cin>>a[i];
  int dis=(k-a[n])+a[1];

  for(int i=2; i<=n; ++i)if(dis<a[i]-a[i-1])dis=a[i]-a[i-1];

  cout<<k-dis<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a==b+c||b==a+c||c==a+b)
    {
      printf("Yes\n");
    }
  else
    {
      printf("No\n");
    }
  return 0;
} 

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

int main(){
    int N;
    cin >> N ;
    int a[N];
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < N; i++){
        if(a[i]%2 == 0 && a[i]%3 != 0 && a[i]%5 != 0){
                cout << "DENIED" << endl;
                return 0;
        }
    }
    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int concat(int a,int b,int x)
{
    while(b)
    {
        a= a*10+b/x;
        b =b%x;
        x = x/10;
    }
    return a;
}
int main()
{
    int a ,b,no;
    cin>>a>>b;
    bool flag = true;
    if(b ==10)
    flag = false;
    else if(b<=9)
    {
        no = concat(a,b,1);
    }else if(b<=99)
    {
        no = concat(a,b,10);
    }else 
    {
        no= a*10+1;
    }
    int sq =sqrt(no);
    if( flag && sq*sq ==no)
    cout<<"Yes";
    else
    cout<<"No";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))

s = [0]

def kitai(n):
  return (1 + n) / 2

for i in range(n):
  s.append(kitai(p[i]) + s[-1])

ans = 0
for i in range(n - k + 1):
  ans = max(ans, s[i + k] - s[i])
print(ans)

Measured memory_bytes: 25060
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);

using ll = int64_t;
using ull = uint64_t;

using namespace std;

bool isPrefix(const string& a, const string& b) {
    if (b.size() < a.size()) return false;
    for (int i = 0, j = 0; i < a.size() && j < a.size(); ++i, ++j) {
        if (a[i] != b[j]) return false;
    }
    return true;
}

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

    string a, b;
    cin >> a >> b;
    cout << (isPrefix(a, b) ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 3616