akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,x;cin>>n>>x;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    ll res=0;
    rep(i,n){
        if(x<a[i]){
            x=0;
            break;
        }
        x-=a[i];
        res++;
    }
    if(x>0)res--;
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
  int k,a,i;
  char s[100];
  scanf("%d",&k);
  scanf("%s",s);

  a=strlen(s);
  if(a<k||a==k){
    printf("%s",s);
  }else{
    for(i=0;i<k;i++){
      printf("%c",s[i]);
    }
    printf("...");
  }
  return 0;
  }

Measured memory_bytes: 1732
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<iomanip>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;

int main(){
    int n,m; cin>>n>>m;
    vector<bool> a(n,false);
    vector<int> p(m);
    int ansA=0,ansW=0;
    for(int i=0;i<m;i++){
        cin>>p[i];
        p[i]--;
        string s; cin>>s;
        if(!a[p[i]]&&s=="AC"){
            ansA++;
            a[p[i]]=true;
        }else if(!a[p[i]]&&s=="WA"){
            ansW++;
        }
    }
    for(int i=0;i<m;i++){
        if(!a[p[i]]) ansW--;
    }
    cout<<ansA<<endl;
    cout<<ansW<<endl;
}

Measured memory_bytes: 640
n = int(input())

w = [int(x) for x in input().split()]
ans = []

for i in range(n):
    s1 = 0
    s2 = 0
    for j in range(i):
        s1 += w[j]
    for j in range(i,n):
        s2 += w[j]
    ans.append(abs(s1-s2))

print(min(ans))

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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T vec_max(auto & , string);
template <class T>
T vec_min(auto & , string);

ll n,x;
vector<long long> a(100);
vector<long long> p(100);

ll dfs(int level, ll patty){
  if (level == 0) {
		if (patty <= 0) return 0;
		return 1;
	}
	else if (patty <= 1 + a[level-1]) return dfs(level-1, patty-1);
	return p[level-1] + 1 + dfs(level-1, patty-2-a[level-1]);
}


int main(){
  faster();
  cin >> n >> x;
  for(int i=0;i<n+1;i++){
    if(i==0){
      a[i]=1;
      p[i]=1;
    }
    else{
      a[i] = a[i-1]*2+3;
      p[i] = p[i-1]*2+1;
    }
  }
  cout << dfs(n,x) << endl;
}



























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//配列内の最大要素の添え字取得or要素取得
template <class T>
T vec_max(auto &v, string s){
  auto itr = max_element(v.begin(),v.end());
  ll element = *itr;
  ll place = itr - v.begin();
  if(s == "element") return element;
  else if(s == "place") return place;
  else return -1;
}

//配列内の最小要素の添え字取得or要素取得
template <class T>
T vec_min(auto &v, string s){
  auto itr = min_element(v.begin(),v.end());
  ll element = *itr;
  ll place = itr - v.begin();
  if(s == "element") return element;
  else if(s == "place") return place;
  else return -1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;

int main() {
  ll h,w;
  cin >> h >> w;
  if(h==1||w==1){
    cout << 1 << endl;
  }
  else cout << (h*w+1)/2 << endl;
  return 0;
}

Measured memory_bytes: 3636
import math
a,b,=map(int, input().split())
aTax = math.ceil(a / 0.08)
bTax = math.ceil(b / 0.10)
if 0 <= aTax - bTax < 10:
    print(aTax)
elif aTax < bTax and math.floor(bTax * 0.08) == a:
    print(bTax)
else:
    print(-1)


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

using ll = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string S; cin >> S;
	int N = int(S.size());
	ll K; cin >> K;
	if (S == string(N, S[0])) {
		cout << (N * K) / 2 << '\n';
	}
	else {
		int prefLen = 0;
		for (int i = 0; S[i] == S[0]; i++) {
			prefLen++;
		}
		int suffLen = 0;
		for (int i = N - 1; S[i] == S[N - 1]; i--) {
			suffLen++;
		}
		int midVal = 0;
		for (int i = prefLen + 1; i < N - suffLen; i++) {
			if (S[i] == S[i - 1]) {
				midVal++;
				i++; // extra ++ to skip the next
			}
		}

		ll ans = midVal * K + (prefLen / 2) + (suffLen / 2) + (S[0] == S[N - 1] ? (prefLen + suffLen) / 2 : prefLen / 2 + suffLen / 2) * (K - 1);
		cout << ans << '\n';
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;

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

    int n; cin >> n;
    int minus = 0;
    ll ideal = 0;
    bool zero = false;
    ll minv = 1LL<<60;

    vector<ll> a(n);
    for(int i=0; i<n; ++i){
        cin >> a[i];
        ideal += abs(a[i]);
        chmin(minv, abs(a[i]));

        if(a[i] == 0) zero = true;
        if(a[i] < 0) ++minus;
    }

    if(zero || minus%2 == 0) cout << ideal << endl;
    else cout << ideal-2*minv << endl;
 
	return 0;
}

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


int main(){
    int a[3][3],c[3][3];
    int n;

    for(int i=0;i<3;i++) {
        for(int j=0;j<3;j++){
             cin>>a[i][j];
            } 
    }

    
    cin>>n;
    
    int b;
    for(int k=0;k<n;k++){
        cin>>b;
        for(int i=0;i<3;i++){
             for(int j=0;j<3;j++){
                 if(a[i][j]==b)
                 c[i][j]=1;
            } 
         }
    }

    for(int i=0;i<3;i++){
        if((c[i][0]==1) && (c[i][1]==1) && (c[i][2]==1)){
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    for(int i=0;i<3;i++){
        if((c[0][i]==1) && (c[1][i]==1) && (c[2][i]==1)){
            cout<<"Yes"<<endl;
            return 0;
        }
    }

        if((c[0][0]==1) && (c[1][1]==1) && (c[2][2]==1)){
            cout<<"Yes"<<endl;
            return 0;
        }

        if((c[2][0]==1) && (c[1][1]==1) && (c[0][2]==1)){
            cout<<"Yes"<<endl;
            return 0;
        }
    
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int N = 100001;
vector<vector<int> > fat(N,vector<int> (20,-1));

int par(int now,int n){
	for(int i=18;i>=0;i--){
		if(now == -1) continue;
		if(n>>i&1) now = fat[now][i];
	}
	return now;
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n;
    int x[n];
    for(int i=0;i<n;i++) cin >> x[i];

    int L;
    cin >> L;
    for(int i=0;i<n;i++) fat[i][0] = upper_bound(x,x+n,x[i]+L) - x - 1;
    for(int i=0;i<18;i++)for(int j=0;j<n;j++) fat[j][i+1] = fat[fat[j][i]][i];

    cin >> q;
    vector<int> ans;
    while(q--){
    	int a, b;
    	cin >> a >> b;
    	a--;b--;
    	if(a > b)swap(a,b);
    	int le = 0, ri = n, mid;
    	while(ri - le > 1){
    		mid = (ri + le) / 2;
    		int p = par(a, mid);
    		if(p >= b) ri = mid;
    		else le = mid;
    	}
    	ans.pb(ri);
    }
    for(auto& i:ans){
    	cout << i << endl;
    }
    return 0;
}


Measured memory_bytes: 14716
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#define rep(i,N) for(int i=0; i<N;i++)
using namespace std;

int main(){
    int X,N;
    cin>>X>>N;
    vector<int> p(N);
    rep(i,N){
        cin>>p.at(i);
    }
    int ans=0;
    int d=abs(X-ans);
    rep(i,102){
        int c=0;
        rep(j,N){
            if(i==p.at(j)){
                c=1;
            }
        }
        if(c!=1){
            if(abs(X-i)<d){
                d=abs(X-i);
                ans=i;
            }
        }
    }

    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 3620
import string

S = input()
N = len(S)

if S == string.ascii_lowercase[::-1]:
    print(-1)
elif N <= 25:
    for l in string.ascii_lowercase:
        if l not in S:
            print(S + l)
            break
else:
    ret = string.ascii_lowercase[::-1]
    for i in range(N):
        for c in string.ascii_lowercase:
            if c in S[:i]:
                continue
            s = S[:i] + c
            if S >= s:
                continue
            ret = min(ret, s)
    print(ret)


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

vector<int> graph[3005];
int dat[3005];
bool yes[3005];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &dat[i]);
	for (int i = 1; i < n; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		a--; b--; graph[a].push_back(b); graph[b].push_back(a);
	}

	vector<pair<int, int>> vt;
	for (int i = 0; i < n; i++) vt.emplace_back(dat[i], i);
	sort(vt.begin(), vt.end());
	for (auto &&e : vt)
	{
		for (int nxt : graph[e.second])
		{
			if (dat[nxt] >= dat[e.second]) continue;
			if (yes[nxt] == false)
			{
				yes[e.second] = true;
				break;
			}
		}
	}
	for (int i = 0; i < n; i++) if (yes[i]) printf("%d ", i + 1);
	printf("\n");
}

Measured memory_bytes: 512
def valid?(a, b, c)
  a <= b + c && b <= c + a + 1 && c <= a + b + 1
end
 
def calc(rear, front, west, east, north, south, limit, best)
  path = []
  while path.size < limit
    a = rear + front
    b = west + east
    c = north + south
 
    if east > 0 && valid?(b - 1, c, a)
      rear, front, west, east = east - 1, west, rear, front
      y = 69
    elsif north > 0 && valid?(c - 1, a, b)
      rear, front, north, south = north - 1, south, front, rear
      y = 78
    elsif south > 0 && valid?(c - 1, a, b)
      rear, front, north, south = south - 1, north, rear, front
      y = 83
    #elsif west > 0 && valid?(b - 1, c, a)
    else
      rear, front, west, east = west - 1, east, front, rear
      y = 87
    end
     
    if best
      x = best[path.size]
      return best if x < y
      best = nil if x > y
    end
    path << y  
  end
  path
end
 
def find(target, limit)
  best = nil
  target.permutation(6).to_a.uniq.each do |rear, front, west, east, north, south|
    a = rear + front
    b = west + east
    c = north + south
    if valid?(a, b, c)
      best = calc(rear, front, west, east, north, south, limit, best)
    end
  end
  best
end
 
loop do
  target = gets.split.map!(&:to_i)
  break if target.all?(&:zero?)
  p, q = gets.split.map!(&:to_i)
  result = find(target, q)
  puts result ? result[p-1...q].pack('C*') : 'impossible'
end

Measured memory_bytes: 73680
#include <bits/stdc++.h>
using namespace std;
const int maxn=100000+10;
int n,k,a[maxn],f[maxn],head[maxn],to[maxn],nxt[maxn],tot,ans;

void add(int x,int y){
	to[++tot]=y;
	nxt[tot]=head[x];
	head[x]=tot;
}

void dfs(int x){
	for(int i=head[x],y;i;i=nxt[i]){
		y=to[i];
		dfs(y);
		f[x]=max(f[x],f[y]+1);
	}
	if(f[x]==k-1&&a[x]!=1){
		f[x]=-1;
		ans++;
	}
}

int main()
{
	scanf("%d%d",&n,&k);
	scanf("%d",&a[1]);
	for(int i=2;i<=n;i++){
		scanf("%d",&a[i]);
		add(a[i],i);
	}
	if(a[1]!=1){
		ans++;
		a[1]=1;
	}
	dfs(1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main(void) {
  int i,j,n;
  cin>>n;
 
  vi a(n),order(n);
  rep(i,n)cin>>a[i];
  rep(i,n)order[a[i]-1]=i;
 
  set<int> st;
  st.insert(-1);
  st.insert(n);
 
  ll ans=0;
  rep(i,n){
    set<int>::iterator itr=st.lower_bound(order[i]);
    ll right=(*itr)-order[i];
    itr--;
    ll left=order[i]-(*itr);
    ll tmp=a[order[i]]*left*right;
    ans+=tmp;
    st.insert(order[i]);
  }
  cout<<ans<<endl;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int x = in.nextInt();
		int sum = 0;
		int i = 1;
		while(sum < x){
			sum += i++;
		}
		System.out.println(i-1);
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
P x[100000],y[100000];
int zz[100000];
int mypow(int a,int b,int c){
	if(b==0)return 1;
	else if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
signed main(){
	int n;
	cin>>n;
	f(i,n){
		cin>>x[i].F;
		x[i].S=i;
	}
	f(i,n){
		cin>>y[i].F;
		y[i].S=i;
	}
	sort(x,x+n);
	f(i,n){
		zz[x[i].S]=i;
	}
	sort(y,y+n);
	f(i,n){
		if(x[i].F>y[i].F){
			puts("No");
			return 0;
		}
	}
	f(i,n-1){
		if(x[i+1].F<=y[i].F){
			puts("Yes");
			return 0;
		}
	}
	int z=y[0].S,cnt=1;
	while(zz[z]){
		z=y[zz[z]].S;
		cnt++;
	}
	if(cnt<n){
		puts("Yes");
	}
	else puts("No");
}


Measured memory_bytes: 4096
W, H, N = map(int, input().split())
xl, xr = 0, W
yl, yr = 0, H
for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        xl = max(xl, x)
    elif a == 2:
        xr = min(xr, x)
    elif a == 3:
        yl = max(yl, y)
    else:
        yr = min(yr, y)
print(max(0, xr-xl)*max(0, yr-yl))

Measured memory_bytes: 38256
list = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
C = input()
def solve():
    for i in range(len(list)):
        if list[i] == C:
            return list[i + 1]
print(solve())

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n,m;
    cin>>n>>m;
    int b[m-1],o=0;
    int a[m];
    int ans=0;
    rep(i,m){
        cin>>a[i];
    }
    sort(a,a+m);
    for(int i=1;i<m;i++){
        b[o]=a[i]-a[i-1];
        o++;
    }
    sort(b,b+m-1);
    reverse(b,b+m-1);
    for(int i=n-1;i<m-1;i++){
        ans+=b[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

signed main(){
  int x,y,z,k;cin>>x>>y>>z>>k;
  int a[1100], b[1100], c[1100];rep(i,x)cin>>a[i];rep(i,y)cin>>b[i];rep(i,z)cin>>c[i];
  sort(a,a+x,greater<int>());sort(b,b+y,greater<int>());sort(c,c+z,greater<int>());
  vector<int> v;
  rep(i,x){
    rep(j,y){
      rep(l,z){
        if((i+1)*(j+1)*(l+1) > k)break;
        v.push_back(a[i]+b[j]+c[l]);
      }
    }
  }
  sort(v.begin(), v.end(), greater<int>());
  rep(i,k)cout << v[i] << endl;
}


Measured memory_bytes: 1400
#include<stdio.h>
#include<math.h>
    
#define MAX 10000
#define MIN 0
#define IS_ERR(n) (n < MIN || n > MAX)
    
int main(void)
{
    double r, circumference, area;
    
    scanf("%lf", &r);
   
    if(IS_ERR(r)) return -1;
    
    circumference = 2 * r * M_PI;
    area = r * r * M_PI;
    
    printf("%lf %lf\n", area, circumference);
    
    return 0;
}


Measured memory_bytes: 2064
#include<bits/stdc++.h>
using namespace std;
int
main (void)
{
    int n,k;
    cin>>n>>k;
    int i,a[n],b[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=0;
    }
    while(k--)
    {
        int count=0;
        for(i=0;i<n;i++)
        {
            if(1)
            {
                if(i-a[i]<0)
                b[0]++;
                else
                b[i-a[i]]++;
                if(i+a[i]+1<n)
                b[i+a[i]+1]--;
            }
        }
        for(i=1;i<n;i++)
        b[i]+=b[i-1];
        for(i=0;i<n;i++)
        {
            a[i]=b[i];
            b[i]=0;
            if(a[i]==n)
            count++;
        }
        if(count==n)
        break;
    }
    for(i=0;i<n;i++)
    cout<<a[i]<<" ";
}


Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl


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

    if (K == 1) print(0);
    else print(N-K);
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
int X;
	cin >> X;

	if (X>=1800) {
		ce(1)
	}
	else if (X>=1600) {
		ce(2)
	}
	else if (X >= 1400) {
		ce(3)
	}
	else if (X >= 1200) {
		ce(4)
	}
	else if (X >= 1000) {
		ce(5)
	}
	else if (X >= 800) {
		ce(6)
	}
	else if (X >= 600) {
		ce(7)
	}
	else if (X >= 400) {
		ce(8)
	}
    return 0;
}



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

using namespace std;
struct UnionFind {
    // par[i]データiの属する木の親の番号。i==par[i]のときデータiは木の根ノードである
    vector<int> par;
    // sizes[i]:根ノードiの木に含まれるデータ数、iが根ノードでないときは無意味な値になる
    vector<int> sizes;

    UnionFind(int n) : par(n), sizes(n, 1) {
        //最初は全てのデータiがグループiに存在するものとして初期化
        for (int i = 0; i < n; i++) {
            par[i] = i;
        }
    }
    //データxが属する木の根を得る
    int find(int x) {
        if (x == par[x]) {
            return x;
        }
        return par[x] = find(par[x]);
    }
    // 2つのデータx,yが属する木をマージする
    void unite(int x, int y) {
        //データの根ノードを得る
        x = find(x);
        y = find(y);
        //もしすでに同じ木に属しているならマージの必要はない
        if (x == y) {
            return;
        }
        // xの木がyの木よりも大きくなるようにする
        if (sizes[x] < sizes[y]) {
            swap(x, y);
        }
        // xがyの親になるように連結する
        par[y] = x;
        sizes[x] += sizes[y];
    }
    // 2つのデータx,yが属する木が同じならtrueを返す
    bool same(int x, int y) { return find(x) == find(y); }
    //データxが含まれる木の大きさを返す
    int size(int x) { return sizes[find(x)]; }
};
const long long MOD = 1000000007;
int main() {
    int N,M;
    cin>>N>>M;
    int X[M],Y[M],Z[M];
    for(int i=0;i<M;i++){
        cin>>X[i]>>Y[i]>>Z[i];
        X[i]--;
        Y[i]--;
    }
    UnionFind uf(N);
    for(int i=0;i<M;i++){
        uf.unite(X[i],Y[i]);
    }
    int ans[N];
    for(int i=0;i<N;i++){
        ans[i]=uf.find(i);
    }
    sort(ans,ans+N);
    int anss=1;
    for(int i=0;i<N-1;i++){
        if(ans[i]!=ans[i+1]){
            anss++;
        }
    }
    cout<<anss<<endl;





}













Measured memory_bytes: 2560
public class Main {
  private static void solve() {
    long n = ni();
    
    long l0 = 2;
    long l1 = 1;
    if (n == 1) {
      System.out.println(l1);
    } else {
      long l = 0;
      for (int i = 1; i < n; i ++) {
        l = l0 + l1;
        l0 = l1;
        l1 = l;
      }
      System.out.println(l);
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()


ll func1(ll x, ll val, vector <ll> &vec){
   while(x < 1e6+1){
         vec[x] = max(vec[x], val);
         x += (x&-x);
   }
}

ll func2(ll x, vector <ll> vec){
   ll ans = 0;
   while(x > 0){
         ans = max(ans, vec[x]);
         x -= (x&-x);
   }
   return ans;
}

ll arr[123];

int main()
{
   arr[0] = 2;
   arr[1] = 1;
   for(int i = 2; i <= 86; i++){
       arr[i] = arr[i-1]+arr[i-2];
   }
   int n;
   cin >> n;
   cout << arr[n];
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[100100],b[100100];

int main(void){
	int n,m,k,i,j,x,y;
	ll ans = INFLL, tmp = INFLL;
	cin >> n >> m >> k;
	for(i=0; i<n; ++i){
		cin >> a[i];
		ans = min(ans,a[i]);
	}
	for(i=0; i<m; ++i){
		cin >> b[i];
		tmp = min(tmp,b[i]);
	}
	ans += tmp;
	for(i=0; i<k; ++i){
		cin >> x >> y >> tmp;
		--x; --y;
		ans = min(ans,a[x]+b[y]-tmp);
	}
	cout << ans << endl;
	return 0;
}


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

namespace StringsLength
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputAmount = int.Parse(Console.ReadLine());
            var inputStrings = Console.ReadLine().Split();

            var charArrayA = inputStrings[0].ToCharArray();
            var charArrayB = inputStrings[1].ToCharArray();
                        
            string newWord = "";
            for(int i = 0; i<inputAmount; i++)
            {
                string[] firstLetter = charArrayA[i].ToString().Split();
                string[] secondLetter = charArrayB[i].ToString().Split();

                newWord += firstLetter[0] += secondLetter[0];
            }
            Console.WriteLine(newWord);                                
        }        
    }
}

Measured memory_bytes: 11092
#include <iostream>

using namespace std;

bool contains(string findable, char toFind) {
    for (int i = 0; i<3; i++) {
        if (findable[i] == toFind)
            return true;
    }
    return false;
}

int main()
{
    string input;
    cin >> input;

    if (!contains(input, 'a'))
        cout << "No";
    else if (!contains(input, 'b'))
        cout << "No";
    else if (!contains(input, 'c'))
        cout << "No";
    else
        cout << "Yes";
    return 0;
}


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

int main() {
    int x, y;
    for (;;) {
        cin >> x >> y;
        if (x == y && x == 0) break;
        if (x < y) {
            cout << x << ' ' << y << endl;
        } else {
            cout << y << ' ' << x << endl;
        }
    }
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll power(ll n)
{
    ll prod=1;
    for(ll i=1;i<=n;i++)
        prod*=10;
    return prod;
}
int main()
{
  ll n,sum=0,cnt=0;
  cin>>n;
  ll temp = n,msb = 0;
  while(temp)
  {
  		if(temp/10==0)
          msb=temp;
    	temp/=10;
    	cnt++;
  }
  
  if(cnt%2==0)
  {
    sum = (power(cnt)-1)/11;
  }
  else
  {
    sum = (power(cnt-1)-1)/11;
   
    sum += (msb-1)*power(cnt-1) + (n%power(cnt-1) + 1);
  }
  cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,cnt=0;
  cin >> n;
  long long ans=1;
  vector<long long int>a(n);
  for(int i=0; i<n; i++){
    cin >> a.at(i);
    if(a.at(i)==0){
      ans=0;
    }
  }
  if(ans!=0){
    int i=0;
    for(int i=0; i<n; i++){
      if(ans<=1000000000000000000/a.at(i)){
        ans*=a.at(i);
      }
      else{
        ans=-1;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4040
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL mod = 1000000007;

LL f(LL n){
  LL sum = 0;
  for (LL i = n / 4 * 4; i <= n; ++i)
  {
    sum ^= i;
  }
  return sum;
}

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

  LL A, B;
  cin >> A >> B;
  A--;
  cout << (f(B)^f(A)) << endl;
}


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

using namespace std;

long long n, m;
vector<int>factors;

int main()
{
    while(cin >> n >> m)
    {
        factors.clear();
        for(int i = 1; i * i <= m; i++)
        {
            if(m % i == 0)
                factors.push_back(i), factors.push_back(m / i);
        }

        int res = 0;
        for(int i = 0; i < factors.size(); i++)
        {
            if(factors[i] * n <= m)
                res = max(res, factors[i]);
        }

        cout << res << endl;


    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll ans,mx,sum,mn=1e8;

 
int main(){
	ll n;
	cin>>n;
	ll a[n];

	for(ll i=0; i<n; i++){
		cin>>a[i];
	}
	for(ll i=-100; i<=100; i++){
		for(ll j=0; j<n; j++){
			ans += (a[j]-i)*(a[j]-i);
		}
		mn=min(mn,ans);
		ans=0;
	}
	cout<<mn<<endl;
}


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

int main(void){
	double x,sum;
	int i;
	while(scanf("%lf",&x)!=EOF){
		for(sum=x,i=0;i<9;i++){
			if(i%2==0)x*=2;
			else x/=3;
			sum+=x;
		}
		printf("%.10lf\n",sum);
	}
	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
const string c3[3] = {
"aa.",
"..b",
"..b"
};
const string c4[4] = {
"abcc",
"abdd",
"eefg",
"hhfg"
};
const string c5[5] = {
"aabbc",
".de.c",
"fde..",
"f.ghh",
"iigjj"
};
const string c6[6] = {
"aabbcc",
"ddeeff",
"...ghi",
"...ghi",
"jkl...",
"jkl..."
};
const string c7[7] = {
"aabbcc.",
"ddee..f",
"gghh..f",
"....ijk",
"....ijk",
"....lmn",
"....lmn"
};
int n;
string ans[1005];
int main() {
	scanf("%d", &n);
	if (n == 2) {
		puts("-1");
		return 0;
	}
	if (n == 7) {
		for (int i = 0; i < 7; i++)
			puts(c7[i].c_str());
		return 0;
	}
	if (n == 11) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				ans[i] += '.';
			}
		}
		for (int i = 0; i < 5; i++)
			for (int j = 0; j < 5; j++)
				ans[i][j] = c5[i][j];
		for (int i = 0; i < 6; i++)
			for (int j = 0; j < 6; j++)
				ans[5 + i][5 + j] = c6[i][j];
		for (int i = 0; i < n; i++)
			puts(ans[i].c_str());
		return 0;
	}
	if (n == 3 || n == 6) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				ans[i] += '.';
			}
		}
		for (int k = 0; k < n / 3; k++) {
			for (int i = 0; i < 3; i++) {
				for (int j = 0; j < 3; j++) {
					ans[k * 3 + i][k * 3 + j] = c3[i][j];
				}
			}
		}
		for (int i = 0; i < n; i++)
			puts(ans[i].c_str());
		return 0;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			ans[i] += '.';
		}
	}
	int c = 0;
	while ((n - c * 5) % 4 != 0) c++;
	int d = (n - c * 5) / 4;
	for (int k = 0; k < d; k++) {
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				ans[k * 4 + i][k * 4 + j] = c4[i][j];
			}
		}
	}
	for (int k = 0; k < c; k++) {
		for (int i = 0; i < 5; i++) {
			for (int j = 0; j < 5; j++) {
				ans[d * 4 + k * 5 + i][d * 4 + k * 5 + j] = c5[i][j];
			}
		}
	}
	for (int i = 0; i < n; i++)
		puts(ans[i].c_str());
	return 0;
}

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

typedef long long ll;

int n;
double x[11];
vector<string> s(11);

int main(){
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> x[i] >> s[i];
    }
    double sum = 0.0;
    for (int i = 0; i < n; i++){
        if (s[i] == "JPY"){
            sum += x[i];
        } else {
            sum += 380000.0 * x[i];
        }
    }

    cout << fixed << setprecision(6) << sum << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
four, two, odd = 0, 0, 0
for a in A:
    if a%4 == 0:
        four += 1
    elif a%2 == 0:
        two += 1
    else:
        odd += 1
result = 'Yes' if four + 1 >= odd + bool(two) else 'No'
print(result)

Measured memory_bytes: 15020
#include <stdio.h>

int main(void)
{
    int W, H, x, y, r;

    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

    if (W < x + r || H < y + r || 0 > x - r || 0 > y - r) {

        printf("No\n");
    }
    else {

        printf("Yes\n");
    }

    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,ans=1,ans2=1,obo;

  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++){
    cin >> vec.at(i);
    ans=max(ans,vec.at(i));
    if(ans==vec.at(i)) obo=i;
  }
  /*
  for (int i=0;i<N;i++){
    ans=1;
    for (int j=0;j<N;j++){
      if(i==j) continue;
      else ans=max(ans,vec.at(j));
    }
    cout << ans <<endl;
  }
  */
  
  
  for (int k=0;k<N;k++){
    if(k==obo){
      for (int i=0;i<N;i++){
        if(i==obo) continue;
        else ans2=max(ans2,vec.at(i));
      }
      cout << ans2<<endl;
      continue;
    }
    cout << ans <<endl;
  } 
}

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

int main(){
	int r, c, h[120][120] = {}, i, j;
	
	cin>>r>>c;
	
	for(i = 0; i < r; i++)
		for(j = 0; j < c; j++)
			cin>>h[i][j];
	
	
	for(i = 0; i < r; i++)
		for(j = 0; j < c; j++) {
			h[i][c] += h[i][j];
			h[r][c] += h[i][j];
		}
	
	for(i = 0; i < c; i++)
		for(j = 0; j < r; j++)
			h[r][i] += h[j][i];
	
	for(i = 0; i <= r; i++)
		for(j =0; j <= c; j++){
			cout<<h[i][j];	
			if(j != c)
				cout<<" ";
			else 
				cout<<endl;
		}
	
	
	return 0;
}


Measured memory_bytes: 3176
#include<stdio.h>
#define N 100

void print(int *,int);
int main(){
    int i,j,v[N],n,m;
    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d",&v[i]);
    }
    print(v,n);
    for(i=1;i<n;i++){
        m = v[i];
        j=i-1;
        while(j>=0&&v[j]>m){
            v[j+1] = v[j];
            j--;
            
        }
        v[j+1]=m;
        print(v,n);
        
    }
 return 0;   
}


void print(int v[],int n){
    
int i;
for(i=0;i<n;i++){
    if(i<n-1) printf("%d ",v[i]);
    else printf("%d",v[i]);
}
printf("\n");
}



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

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

  int counter = 0;
  int border = vote / (4 * M);
  if (vote % (4 * M) > 0) border++;
  for (int i=0; i<N; i++) {
    if (A[i] >= border) counter++;
  }

  string ans = "No";
  if (counter >=  M) ans = "Yes";

  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }
    int cnt = 0;
    rep(i, n) {
        if (a[a[i]] == i)
            cnt++;
    }
    cout << cnt / 2 << endl;
}

Measured memory_bytes: 640
n = int(input())
a_list = list(map(int, input().split()))
if 1 not in a_list:
    print(-1)
else:
    count = 0
    number = 1
    for i in range(n):
        if a_list[i] == number:
            number += 1
        else:
            count += 1
    print(count)

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

int main() {
	string s = "";
	string ans = "";
	int ind = 0;
	cin >> s;
	for(int i = 0; i < s.length(); i++){
		if(s[i] != 'B'){
			ans += s[i];
			ind++;
		}else if(ind > 0){
			ind--;
			if(ind < 0){
				ind = 0;
			}
			ans.erase(ans.begin()+ind);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define drng(i,a,b) for(int i=int(a);i>int(b);i--)
typedef long long LL;
 

int main() {
    fastio
    int n,k;
    cin>>n>>k;
    int a[n];
    rng(i,0,n){
        cin>>a[i];
    }
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    rng(i,2,n){
        dp[i] = dp[i-1] + abs(a[i]-a[i-1]);
        int te = 2;
        while(te <= k && (i-te)>= 0){
            dp[i] = min(dp[i], dp[i-te] + abs(a[i] - a[i-te]));
            te++;
        }

    }
    cout<<(int)dp[n-1]<<endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define debug(x) cout << #x " = " << (x) << '\n';
#define P(x) cout << #x << '\n';    
#define int long long
typedef pair<int, int> pii;
const int mod = 1000000007;

const int inf = 1e10;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(9);
    
	int x;
	cin >> x;
	int n = 6;
	
	vector<int> a = {100, 101, 102, 103, 104, 105};
	vector<char> dp(x + 10, false);
	dp[0] = true;
	for(int i = 100; i <= x; ++ i)
	{
		for(int j = 0; j < n; ++ j)
		{
			if(i - a[j] < 0) continue;
			dp[i] |= dp[i - a[j]];
			
		}
	}
	if(dp[x] == true)
		cout << "1" << '\n';
	else
		cout << "0" << '\n';
	
    return 0;
}






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

const long long MOD = 1000000007;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

void solve(long long X, long long Y){
    vector<long long> v(1, 1);
    for(int i = 1;i <= 1e6+7;i++){
        v.push_back(v.back() * i);
        v.back() %= MOD;
    }
    long long ans = 0;
    for(int i = 0;i <= Y;i++){
        int remain = Y - i;
        if((Y - i) % 2 != 0){
            continue;
        }
        if(X - 2 * i < 0){
            continue;
        }
        if((Y - i)/2 != X - 2 * i){
            continue;
        }
        ans += v[i + (remain / 2)] * modinv(v[i], MOD) % MOD * modinv(v[remain / 2], MOD) % MOD;
        ans %= MOD;
    }
    cout<<ans<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 10476
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


int lb(vi &min, int g, int a, int b) {
    if(b-a == 1) {
        return b;
    }
    int c = (a+b)/2;
    if(min[c] >= g) {
        a = c;
    } else {
        b = c;
    }
    return lb(min, g, a, b);
}

 
int main() {
    int n;
    cin >> n;
    vector<int> min(1);
    min[0] = 1000000001;
    int ans = 0;
    rep(i, n) {
        int g;
        cin >> g;
        if(min[min.size()-1] >= g) {
            ++ans;
            min.push_back(g);

        } else {
            int num = lb(min, g, 0, min.size());
            min[num] = g;
        }
        
    }

    cout << ans << endl;
}


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

int main() 
{
    char str[1200];
    
   fgets(str, 1200, stdin); 

   int l=strlen(str);
    
    for(int i=0;i<l;i++){
        if(str[i]>='A' && str[i]<='Z'){
            str[i]=str[i]+32;
        }
        
        else if(str[i]>='a' && str[i]<='z'){
            str[i]=str[i]-32;
        }
        else str[i]=str[i];
    }

    printf("%s", str);
return 0;
} 




Measured memory_bytes: 2704
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    boolean[] prime = new boolean[200001];
    for(int i = 2; i < 200001; i++) {
      prime[i] = true;
    }
    prime[1] = false;
    for(int i = 2; i < 200001; i++) {
      if(prime[i]) {
        for(int j = (2 * i); j < 200001; j += i) {
          prime[j] = false;
        }
      } 
    }
    int ans = 0;
    for(int i = 2; i < 200001; i++) {
      if((prime[i]) && (i >= x)) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define mod 1000000007

void solve() {
    int n;
    ll s = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) if (i %3  && i % 5) s+= i;
    cout << s << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve(); 
    return 0;
}



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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

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

    if (a * b > c * d) {
        cout << a * b << endl;
    } else {
        cout << c * d << endl;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

from collections import deque
n,c,k = list(map(int, input().split()))
t = deque(sorted([int(input()) for _ in range(n)]))

cnt=0
bus=[]
while t:
    flg=False
    t1=t.popleft()
    if not bus:
        bus.append(t1)
        flg=True
    elif t1-bus[0]<=k and len(bus)<c:
        bus.append(t1)
        flg=True

    if len(bus)>=c or t1-bus[0]>=k:
#        print('bus=',bus)
#        print('t1=',t1)
        cnt+=1
        bus.clear()

    if not flg:
        bus.append(t1)

if bus:
    cnt+=1
    
print(cnt)

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

int main(){
  int n;
  double ans = 0.0, nowv = 0.0, lim = 0.0;
  cin >> n ;
  int t[n+1], v[n+2], cnt = 1;
  t[0] = 0;
  v[n+1] = 0;
  v[0] = 0;
  for(int i=1;i<=n;i++){
    cin >> t[i];
    t[i] += t[i-1];
  }
  for(int i=1;i<=n;i++){
    cin >> v[i];
  }
  for(double i = 0.5; i<=t[n];i+=0.5){
    if(i > t[cnt]) cnt++;
    double lim = v[cnt];
    for(int j=0;j<=n;j++){
      lim = min(lim, (j < cnt?(v[j] + i - t[j]):(v[j+1] + t[j] - i)));
    }
    ans += (nowv/2);
    if(nowv<lim){
      ans += 0.25;
      nowv += 0.5;
    }else if(nowv>lim){
      ans -= 0.25;
      nowv -= 0.5;
    }
  }
  cout << fixed << setprecision(8) <<  ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    int sum = 0;
    int[] s = new int[N];
    for (int i = 0; i < N; i++) {
      s[i] = sc.nextInt();
      sum += s[i];
    }
    Arrays.sort(s);
    
    int sub = 0;
    for (int i = 0; i < N; i++) {
      if (s[i]%10 != 0) {
        sub = s[i];
        break;
      }
    }
    if (sub == 0) {
      System.out.println(0);
      return;
    }
    
    System.out.println(sum%10 != 0 ? sum : sum - sub);
  }
}

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

int main(void){
    int n, sz, ans = 0; string sb; cin >> n;
    vector<string> ss(n); vi loc(26); map<string, int> cnt;
    rep(i, n) {cin >> ss[i]; reverse(all(ss[i]));}
    auto cmp = [&](string s1, string s2)->bool{return s1.length() < s2.length();};
    sort(all(ss), cmp);

    for (string& s: ss){
        fill(all(loc), -1); sz = s.length(); sb = "";
        rep(i, sz) loc[s[i] - 'a'] = i;
        rep(i, sz){
            if (!cnt.count(sb)) {sb += s[i]; continue;}
            int bit = cnt[sb];
            for (char c = 'a'; c <= 'z'; ++c) if (loc[c - 'a'] >= i && (bit >> (c - 'a') & 1)) ans++;
            sb += s[i];
        }
        cnt[s.substr(0, sz - 1)] |= (1LL << (s[sz - 1] - 'a'));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 20340
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  sort(ALL(d));
  int maxv = 0;
  int ans = 0;
  rep(i, n){
    if (d[i] > maxv){
      ans++;
      maxv = d[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; i++) cin >> H.at(i);

    int ans = 0;
    for(int i = 0; i < N - 1; i++){
        int count = 0;
        while((i < (N - 1)) && (H.at(i) >= H.at(i + 1))){
            count++;
            i++;
        }
        ans = max(ans, count);
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 640