akhauriyash/Code-Regression huggingface dataset:
n,k=map(int,input().split())
a=list(map(int,input().split()))
if k > sum(a):
    print(0)
    exit()

mod = 1000000007
dp = [[0 for _ in range(k+1)]for __ in range(n+1)]
for i in range(n+1):
    dp[i][0] = 1
for i in range(k+1):
    dp[0][i] = 0

for i in range(1,n+1):
    for j in range(1,k+1):
        if j > a[i-1]:
            if i is 1:
                break
        dp[i][j] = dp[i-1][j] + dp[i][j-1]
        if j > a[i-1]:
            dp[i][j] -= dp[i-1][j-1-a[i-1]]
        dp[i][j] %= mod
print(dp[n][k])

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

int main()
{
	string S;
	cin >> S;
	if (S=="Sunny")
	{
		cout << "Cloudy" << endl;
	}
	else if (S=="Cloudy")
	{
		cout << "Rainy" << endl;
	}
	else
	{
		cout << "Sunny" << endl;
	}
	return 0;
}

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

ll N, A, B;
vector<ll> H;
// c回クエリを実行したときに要件を満たすか
bool f(ll c) {
	vector<ll> rest = H;
	for(int i=0;i<N;i++) {
		rest[i] = max(rest[i] - B * c, 0LL);
	}
	ll cnt = 0;
	for(int i=0;i<N;i++) {
		if(rest[i] == 0) continue;
		cnt += ((rest[i] + (A - B) - 1) / (A - B));
	}
	return ((cnt <= c) ? true : false);
}

signed main() {
	cin >> N >> A >> B;
	H.resize(N);
	for(auto &h : H) cin >> h;
	ll left = 0LL, right = (ll)1e9+7;
	while(right - left > 1) {
		ll mid = (left + right) >> 1LL;
		if(f(mid)) right = mid;
		else left = mid;
	}
	cout << right << endl;
}

Measured memory_bytes: 1792
#include<string>
#include<iostream>

using namespace std;

struct Dice{
	int t,s,e,w,n,b;

	Dice(int T,int S,int E,int W,int N,int B):t(T),s(S),e(E),w(W),n(N),b(B){}

	void rotx(){
		Dice tmp=*this;
		t=tmp.w;
		e=tmp.t;
		w=tmp.b;
		b=tmp.e;
	}

	void roty(){
		Dice tmp=*this;
		t=tmp.s;
		s=tmp.b;
		n=tmp.t;
		b=tmp.n;
	}
};

int main(){
	for(int n;cin>>n,n;){
		Dice dice(1,5,4,3,2,6);
		while(n--){
			string cmd;	cin>>cmd;
			if     (cmd[0]=='n')	dice.roty();
			else if(cmd[0]=='e')	dice.rotx();
			else if(cmd[0]=='s')	dice.roty(),dice.roty(),dice.roty();
			else					dice.rotx(),dice.rotx(),dice.rotx();
		}
		cout<<dice.t<<endl;
	}

	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

typedef double D;
typedef complex<D> P;
typedef pair<int,int> pi;

#define X real()
#define Y imag()

const D eps=1e-8;
const D inf=1e12;
const D PI=acos(-1);

struct L : public vector<P> { // line and segment
  L(const P& a,const P &b){
    push_back(a);
    push_back(b);
  }
};

D cross(P a,P b){ return (conj(a)*b).Y; }
P crosspoint(L l,L m) {
  D A=cross(l[1]-l[0],m[1]-m[0]);
  D B=cross(l[1]-l[0],l[1]-m[0]);
  if (abs(A)<eps&&abs(B)<eps) return m[0]; // same line
  if (abs(A)<eps) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0]+B/A*(m[1]-m[0]);
}
bool intersectLS(L l,L s){
  return cross(l[1]-l[0],s[0]-l[0])*cross(l[1]-l[0],s[1]-l[0])<eps;
}


int main(){
  while(1){
    int N;
    vector<P> ps;
    cin>>N;
    if(N==0)break;
    rep(i,N){
      D x,y;
      cin>>x>>y;
      x+=2000;
      ps.push_back(P(x,y));
    }
    int res=0;
    for(int y=-2000;y<2000;y++){
      L lo=L(P(0,y),P(1,y));
      L hi=L(P(0,y+1),P(1,y+1));
      vector<pi> xs;
      rep(i,N){
        L crt=L(ps[i],ps[(i+1)%N]);
        if(intersectLS(hi,crt)&&intersectLS(lo,crt)){
          P p1=crosspoint(hi,crt);
          P p2=crosspoint(lo,crt);
          D mx=max(p1.X,p2.X);
          D mn=min(p1.X,p2.X);
          xs.push_back(pi((int)floor(mn),(int)ceil(mx)));
        }
      }
      sort(all(xs));
      vector<bool> used(4010,false); 
      if(xs.size()>=2){
        for(int i=0;i+1<xs.size();i+=2){
          int mn=min(xs[i].first,xs[i+1].first);
          int mx=max(xs[i].second,xs[i+1].second);
          repl(j,mn,mx){
            if(used[j])continue;
            res++;
            used[j]=true;
          }
        }
      }
    }
    cout<<res<<endl;
  }
  return 0;
}



Measured memory_bytes: 3148
#include <stdio.h>

typedef long long ll;

ll min(ll a, ll b);

int main() {

	ll A, B, C;

	scanf("%lld %lld %lld",&A,&B,&C);

	if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
		printf("0\n");
	}
	else {
		ll ans1 = A*B;
		ll ans2 = B*C;
		ll ans3 = C*A;
		printf("%lld\n",min(ans1,min(ans2,ans3)));
	}

	return 0;
}
ll min(ll a, ll b) {
	if (a >= b) { return b; }
	else { return a; }
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>

using namespace std;

#define ll long long

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;++i)    cin >> a[i];

    int ans = 0;
    for(int i = 0;i < n;i+=2){
        if(a[i] % 2 == 1){
            ans += 1;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int D;
int C[26];
int S[365][26];

int64_t evaluate(const vector<int> &T) {
  int64_t res = 0;
  vector<int> last(26);
  for (int i = 0; i < T.size(); ++i) {
    res += S[i][T[i] - 1];
    last[T[i] - 1] = i + 1;
    for (int j = 0; j < 26; ++j) {
      res -= C[j] * (i + 1 - last[j]);
    }
  }
  return res;
}

int64_t evaluate_avg(const vector<int> &T) {
  int64_t res = 0;
  vector<int> last(26);
  for (int i = 0; i < T.size(); ++i) {
    res += S[i][T[i] - 1];
    last[T[i] - 1] = i + 1;
    for (int j = 0; j < 26; ++j) {
      res -= C[j] * (i + 1 - last[j]);
    }
  }
  for (int i = T.size(); i < min((int) T.size() + 12, D); ++i) {
    for (int j = 0; j < 26; ++j) {
      res -= C[j] * (i + 1 - last[j]);
    }
  }
  return res;
}

int main() {
  cin >> D;
  for (int i = 0; i < 26; ++i) cin >> C[i];
  for (int i = 0; i < D; ++i) for (int j = 0; j < 26; ++j) cin >> S[i][j];

  vector<int> T;
  for (int _ = 0; _ < D; ++_) {
    pair<int64_t, int> best = make_pair(numeric_limits<int64_t>::min(), 0);
    for (int n = 1; n <= 26; ++n) {
      T.push_back(n);
      best = max(best, make_pair(evaluate_avg(T), n));
      T.pop_back();
    }
    assert(best.second);
    T.push_back(best.second);
  }

  for (int i = 0; i < D; ++i) cout << T[i] << endl;

  return 0;
}



Measured memory_bytes: 3568
#include<iostream>
using namespace std;
int main(){
    
    int n;
    cin >> n;
    
    for(int i=1; i<=n; i+=1){
        if(i%3 == 0) {
            cout << " " << i;
        } else {
            int x =i;
            while(1){
                if(x%10 == 3){
                    cout << " " << i;
                    break;
                } else if((x/10) == 0) break;
                x /= 10;
            }
        }
        
    } 
    
    cout << endl;
    return 0;
}


Measured memory_bytes: 3104
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] X = new int[N];
    ArrayList<Integer> number = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      X[i] = sc.nextInt();
      number.add(X[i]);
    }
    if (N == 2) {
      System.out.println(X[1]);
      System.out.println(X[0]);
      return;
    }
    Collections.sort(number);
    for (int i = 0; i < N; i++) {
      if (X[i] < number.get(N / 2)) {
        System.out.println(number.get(N / 2));
      } else {
        System.out.println(number.get((N / 2) - 1));
      }
    }
  }
}

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

int N;

int dfs(int i, ll num, bool nana, bool go, bool san) {
  if (num > N)
    return 0;
  int res = 0;
  if (nana && go && san)
    res++;
  res += dfs(i + 1, num * 10 + 7, true, go, san);
  res += dfs(i + 1, num * 10 + 5, nana, true, san);
  res += dfs(i + 1, num * 10 + 3, nana, go, true);
  return res;
}

int main() {
  cin >> N;
  cout << dfs(0, 0, 0, 0, 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main (void){
    int a,b,i,ans[8];
    for(i=0;i<7;i++){
        scanf("%d%d",&a,&b);
        ans[i]=a-b;
        if(ans[i]<0)ans[i]=ans[i]*-1;
    }
    for(i=0;i<7;i++){
        printf("%d\n",ans[i]);
    }
return 0;
}

Measured memory_bytes: 600
### constant

MAX_INT = (1 << 30)

### main

while true
  n = gets.strip.to_i
  break if n == 0

  bldgs = 2.times.map{[]}

  bldgs[0] = gets.strip.split(' ').map{|s| s.to_i}
  bldgs[1] = gets.strip.split(' ').map{|s| s.to_i}
  #p bldgs

  min_j = MAX_INT

  for bs in [0, 1]
    dists = 2.times.map{n.times.map{MAX_INT}}
    visit = 2.times.map{n.times.map{false}}

    fs = 0
    while fs < n - 1 && bldgs[bs][fs] == 1 && bldgs[bs][fs + 1] == 1
      fs += 1
    end

    q = [[bs, fs]]
    dists[bs][fs] = 0
    visit[bs][fs] = true

    while ! q.empty?
      b0, f0 = q.shift
      next if f0 >= n - 1

      b1 = 1 - b0
      for f2 in (f0..(f0 + 2)).select{|f| f < n}
        f1 = f2

        case bldgs[b1][f1]
        when 1
          while f1 < n - 1 && bldgs[b1][f1 + 1] == 1
            f1 += 1
          end
        when 2
          while f1 > 0 && bldgs[b1][f1] == 2
            f1 -= 1
          end
        end

        if ! visit[b1][f1]
          dists[b1][f1] = dists[b0][f0] + 1
          visit[b1][f1] = true
          q << [b1, f1]
        end
      end
    end

    min_d = (0..1).map{|i| dists[i][n - 1]}.min
    min_j = min_d if min_j > min_d
  end

  puts (min_j >= MAX_INT ? 'NA' : min_j)
end

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

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

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

  vector<ll> a(n);
  rep(i, n) cin >> a.at(i);

  multiset<ll> com;

  sort(a.rbegin(), a.rend());
  com.insert(a.at(0));
  //eq.erase(eq.find(rate));
  //int ans = *eq.begin();

  ll ans=0;
  for(int i=1; i<n; i++){
    ll top = *com.rbegin();
    ans+=top;
    com.erase(com.find(top));
    com.insert(a.at(i));
    com.insert(a.at(i));
  }

  cout << ans;
}

Measured memory_bytes: 14344
#include<stdio.h>

int main(){
	int num,i;
	int min,max=-2147483648;
	int input;
	
	scanf("%d",&num);
	
	
	scanf("%d",&input);
	min=input;
	
	for(i=1;i<num;i++){
		scanf("%d",&input);
		
		if(max<input-min){
			max = input-min;
		}
		
		if(input<min){
			min=input;
		}
	}
	
	printf("%d\n",max);
	
	return 0;
}

Measured memory_bytes: 596
function main(input) {
    input = input[0].split(" ");
    n = parseInt(input[0],10);
    k = parseInt(input[1],10);
    var i, ans = 0;
    for(i=1; i<n+1; i++){
        ans += Math.pow(0.5, Math.max(Math.ceil(Math.log2(k/i)), 0));
    }
    ans /= n;
    console.log(ans);
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

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

int main() {
	while (1) {
		int m, f, r;
		cin >> m >> f >> r;
		if ( m == -1 && f == -1 && r == -1) break;
		else if (m == -1 || f == -1) cout << "F" << endl;
		else if (m + f >= 80) cout << "A" << endl;
		else if (m + f < 80 && m + f >= 65) cout << "B" << endl;
		else if (m + f < 65 && m + f >= 50) cout << "C" << endl;
		else if ((m + f < 50 && m + f >= 30) && r >= 50) cout << "C" << endl;
		else if (m + f < 50 && m + f >= 30) cout << "D" << endl;
		else cout << "F" << endl;
	}

	return 0;
	
}


Measured memory_bytes: 3108
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <functional>
#include <tuple>
#include <climits>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <numeric>
#include <map>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <array>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for(auto &i : A) cin >> i;
    
    uint64_t count = 0;
    for(int i=0; i<N; i++) {
        if(A[i] == 0) continue;
        if(i!=N-1) {
            const int npairs = min(A[i], A[i+1]);
            A[i+1] -= npairs;
            A[i] -= npairs;
            count += npairs;
            if(A[i] % 2 == 1 && npairs > 0) {
                A[i+1] += 1;
                A[i] += 1;
                count -= 1;
            }
        }
        count += A[i] / 2;
    }
    cout << count << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    int  n,a,b,c,d;cin>>n>>a>>b>>c>>d;
    int t=b-a;
    rep(i,0,n){
        int mini=-1*d*i+c*(n-1-i);
        int maxi=-1*c*i+d*(n-1-i);
        if(mini<=t&&t<=maxi){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}


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

#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

int f(int a, int x) {
	if (a < 0)return -1;
	return a / x;
}

signed main() {
	int a, b, x; cin >> a >> b >> x;
	dump(f(a, x));
	dump(f(b, x));
	cout << f(b, x) - f(a - 1, x) << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (A, B) = Slice2<long>();
            WriteLine(A <= 8 && B <= 8 ? "Yay!" : ":(");
        }
 
        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=305,INF=1<<30;

vector<int> rev(vector<int> &A){
    vector<int> res(si(A));
    
    for(int i=0;i<si(A);i++){
        res[A[i]]=i;
    }
    
    return res;
}

vector<int> mul(vector<int> &A,vector<int> &B){
    vector<int> res=A;
    
    for(int i=0;i<si(A);i++){
        res[i]=B[res[i]];
    }
    
    return res;
}//A→Bの順で写像を適用

vector<int> pow(vector<int> &A,ll n){
    vector<int> res(si(A));
    iota(all(res),0);
    
    while(n>0){
        if(n&1) res=mul(res,A);
        A=mul(A,A);
        n/=2;
    }
    
    return res;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,K;cin>>N>>K;
    K--;
    vector<int> p(N),q(N);
    for(int i=0;i<N;i++){
        cin>>p[i];
        p[i]--;
    }
    for(int i=0;i<N;i++){
        cin>>q[i];
        q[i]--;
    }
    
    vector<int> pp=rev(p),qq=rev(q),r=mul(pp,q);
    
    if(K==0){
        for(int a:p) cout<<a+1<<" ";
        cout<<endl;
        return 0;
    }
    
    if(K==1){
        for(int a:q) cout<<a+1<<" ";
        cout<<endl;
        return 0;
    }
    
    if(K==2){
        for(int a:r) cout<<a+1<<" ";
        cout<<endl;
        return 0;
    }
    
    vector<int> A(N),B(N),res(N);
    iota(all(A),0);
    iota(all(res),0);
    A=mul(A,p);
    A=mul(A,qq);
    A=mul(A,pp);
    A=mul(A,q);
    
    int x=(K-3)%6,y=(K-3)/6;
    
    A=pow(A,y);
    B=rev(A);
    
    p=q;
    q=r;
    
    for(int i=0;i<=x;i++){
        pp=rev(p);
        r=mul(pp,q);
        
        p=q;
        q=r;
    }
    
    res=mul(res,B);
    res=mul(res,q);
    res=mul(res,A);
    
    for(int a:res) cout<<a+1<<" ";
    cout<<endl;
}


Measured memory_bytes: 6920
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;

    double den = -1;
    int m = 0, ms = 0;
    REP(i, f/(100*a)+1) {
        REP(j, f/(100*b)+1) {
            int water = 100*a*i + 100*b*j;

            if (i == 0 && j == 0) continue;
            if (water > f) break;
            int mel = min(f-water, water/100*e);

            int salt = 0;
            REP(k, mel/c+1) {
                REP(l, mel/d+1) {
                    int salt_ = c*k + d*l;

                    if (salt_ > mel) break;
                    salt = max(salt, salt_);
                }
            }

            double den_ = 100.0*salt/(salt+water);
            if (den_ > den) {
                den = den_;
                m = water + salt;
                ms = salt;
            }
        }
    }

    cout << m << " " << ms << endl;
}


Measured memory_bytes: 256
import collections

N=int(input())
A=list(map(int, input().split()))
Q=int(input())
countA=collections.Counter(A)
ans=sum(A)

for i in range(Q):
    B,C=map(int, input().split())
    b=countA[B]
    ans=ans+(C-B)*b
    print(ans)
    countA[B]=0
    countA[C]+=b



Measured memory_bytes: 24144
#include<bits/stdc++.h>
#define pb push_back
#define mod 1000000007
#define mkp make_pair
#define fi first
#define se second
#define ll long long
#define scan(n) ll a[n]; for(ll i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define rep(i,x,y) for(ll i=x;i<y;i++)
//#define int long long
using namespace std;
//typedef vector<int>vi ;
typedef vector<ll>vi ;
typedef vector<vector<ll> >vvl ; 
typedef pair<ll,ll> pll ;
typedef vector<pair<ll,ll> > vpll;
/*vi adj[200005];
ll vis[200005];
ll parent[200005];
ll level[200005];
ll arr[200005];
ll size[200005];*/
//endl mut bhool!!
int main()
{
	fast;
	ll test=1;
	//cin>>test;
	while(test--)
	{
		string s,t;
		cin>>s>>t;
		string s1=t.substr(0,s.size());
		if(s1==s)
		{
			cout<<"Yes";
		}
		else
			cout<<"No";
	}
	return 0;
}
/*
cout<<"YES"<<endl;
cout<<"NO"<<endl;
*/

Measured memory_bytes: 3652
def main():
    N = int( input())
    S = input()
    ans = 0
    for i in range(N-2):
        if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
            ans += 1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}

//vc alp(26) ={'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'};
//cout<<""<<endl;
int main(){
  int N,D,X;cin>>N>>D>>X;vi A(N);rep(i,N)cin>>A[i];
  int tot=0;
  for(int j=0;j<N;j++){
    for(int i=0;i*A[j]+1<=D;i++){
      tot++;
    }
  }
  cout<<tot+X<<endl;
      
}





Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N, K = mi()
S = input()
inds = [[0, 0]]

flag = 0
s = 0
for i in range(N):
    if S[i] == '0':
        if not flag:
            flag = 1
            inds.append([s, i-1])
    else:
        if flag:
            s = i
        flag = 0
if flag:
    inds.append([N-1, N-1])
if not flag:
    inds.append([s, N-1])
#print(inds)
l_inds = len(inds)
wa = 0
if K >= l_inds-1:
    print(N)
    exit()
for i in range(l_inds-K):
    wa = max(inds[i+K][1] - inds[i][0] + 1, wa)

print(wa)

Measured memory_bytes: 11380
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int N ,T ,A , X ;
int main()
{
  scanf ("%d%d%d " ,&N ,&T ,&A );
int res =0;
int cc =1 <<30;
for ( int i =1; i <= N; i++)
{
scanf ("%d" ,&X);
int d =( T *1000 - X *6) - A *1000;
if (d <0) d = -d ;
if ( cc > d ) cc =d , res = i ;
}
printf ("%d\n", res );
  system("pause");
}

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

int sum(int n){
  if (n == 0){
    return 0;
  }
  return sum(n-1) + n;
}

int main(){
  int N, L;
  cin >> N >> L;
  vector <int> aji_abs(N);
  for (int i = 0; i < N; i++){
    aji_abs.at(i) = abs(L+i);
  }
  int min = *std::min_element(aji_abs.begin(), aji_abs.end());
  if (L + N -1 < 0){
    min = min*(-1);
  }
  cout << (L-1)*N+sum(N)-min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >>N;
    int c=0;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(N==i*j){
                c++;
            }
        }
    }
    if(c>0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize, 
        a: usize,
        b: usize
    }

    let ans = (a..n+1).filter(|x| {
        let sum = x.to_string().chars().map(|c| (c as u8 - b'0') as usize).sum::<usize>();
        a <= sum && sum <= b
    }).sum::<usize>();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

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

	string s; cin >> s;

	if (s[0] != 'A') {
		cout << "WA" << endl;
		return  0;
	}

	string t = s.substr(2,s.size() - 3);
	int cnt = 0;
	int idx = 0;
	for (int i = 0; i < t.size(); i++) {
		if (t[i] == 'C') {
			cnt++;
			idx = i+2;
		}
	}
	if (cnt != 1) {
		cout << "WA" << endl;	
		return 0;
	}

	for (int i = 0; i < s.size(); i++) {
		if (isupper(s[i]) and i != 0 and i != idx) {
			cout << "WA" << endl;
			return  0;
		}
	}

	cout << "AC" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin>>s;
	if(s=="AAA" or s=="BBB")puta("No");
	else puta("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
char s[20];
int main(){
    int a,b,i,ok=1;
    scanf("%d%d",&a,&b);
    scanf("%s",s);
    for(i=0;i<a;i++)if(s[i]<'0'||s[i]>'9')ok=0;
    if(s[a]!='-')ok=0;
    for(i=a+1;i<=a+b;i++)if(s[i]<'0'||s[i]>'9')ok=0;
    printf("%s\n",ok?"Yes":"No");
    return 0;
}

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

int main()
{
    int X, x=0,Y, y=0;
    int N;
    cin>>X>>Y>>N;
    for (int i = 0; i < N; i++)
    {
        int tx, ty, a;
        cin >> tx >> ty >> a;
        if(a==1){
            if(x<tx)
                x = tx;
        }else if (a==2)
        {
            if(X>tx)
                X = tx;
        }else if (a==3)
        {
            if(y<ty)
                y = ty;
        }else
        {
            if(Y>ty)
            Y = ty;
        }
    }

    if(X-x<=0||Y-y<=0){
        cout << 0 << endl;
    }else{
        cout << (X - x) * (Y - y) << endl;
    }
}


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

using namespace std;

int main()
{
    int N,M;
    cin >> N >> M;
    vector<int> s(M);
    vector<int> c(M);
    int ans=0;

    if(M == 0 && N==1){
        cout << "0" << endl;
        return 0;
    }

    for(int i=0; i<M; i++){
        cin >> s.at(i) >> c.at(i);
        if(N>1 && s.at(i) == 1 && c.at(i) == 0){
            cout << "-1" << endl;
            return 0;
        }
    }

    vector<int> d(N);

    for(int i=0; i<M; i++){
        if(d.at(s.at(i)-1) == 1 && c.at(i) != ans/(int)(pow(10,N-s.at(i))) ) {
            cout << "-1" << endl;
            return 0;
        }
        if(d.at(s.at(i)-1) == 0){
            ans += c.at(i)*(int)pow(10,N-s.at(i)) ;
            d.at(s.at(i)-1)++;
        }
    }

    if(d.at(0) == 0){
        ans += (int)pow(10,N-1);
    }

    cout << ans << endl;

}

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

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

    int len = S.length();
    int cou = 0;
    string a = S.substr(0, 1);

    for(int i = 1; i < len; i++){
        string b = S.substr(i, 1);
        if(a == b){
            if(b == "1"){
                S.replace(i, 1, "0");
            }else{
                S.replace(i, 1, "1");
            }
            cou++;
        }

        a = S.substr(i, 1);
    }

    cout << cou << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
using ll = long long;
static const int MAX_N = 100;
static const int MAX_V = 100;

int a,b;
int main(){
    cin >> a >> b;
    int c=a+b;
    int d=a-b;
    int e=a*b;
    int f=max(c,d);
    int g=max(e,f);
    cout << g << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 1000010
#define inf 0x3f3f3f3f
#define LL long long
#define pi acos(-1)
#define MOD 1000000007
using namespace std;



int main()
{
	int a,b,ans=0;
	cin >> a>>b;
	cout << max(a+b,max(a+a-1,b+b-1)) << endl;
	return 0;
}

Measured memory_bytes: 256
import math
a,b,x = map(int,input().split())

menseki = a * a
V = menseki * b

if V <= 2 * x:
    ans = (2 * (V - x)) / (a ** 3)
    degree = math.degrees(math.atan(ans))
    print(degree)
else:
    ans = (a * b * b) / (2 * x)
    degree = math.degrees(math.atan(ans))
    print(degree)

Measured memory_bytes: 9260
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { m -> m.toInt() }
    
    val balls = Array(n) { 1 }
    val isRed = Array(n) { false }
    isRed[0] = true
    
    for (i in 0 until m) {
        val (a, b) = readLine()!!.split(" ").map { m -> m.toInt() }
        balls[a - 1]--
        balls[b - 1]++
        if (isRed[a - 1]) {
            isRed[b - 1] = true
        }
        if (balls[a - 1] == 0) {
            isRed[a - 1] = false
        }
    }
    
    println(isRed.filter { m -> m }.size)
}


Measured memory_bytes: 57940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    int n, m, l;
    n = a.size();
    m = b.size();
    l = c.size();

    if(a[n-1] == b[0] && b[m-1] == c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

typedef tree<
			pair <long long, int>,
			null_type,
			less< pair <long long, int> >,
			rb_tree_tag,
			tree_order_statistics_node_update> ordered_set;


long long a[200010];
const int inf = 1e9;

int main(int argc, char const *argv[])
{
	int n, k;
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		a[i] -= k;
	}
	for(int i = 1; i <= n; i++) {
		a[i] += a[i-1]; 
	}
	ordered_set t;
	t.insert(make_pair(0, 0));
	long long ans = 0;
	for(int i = 1; i <= n; i++) {
		ans += t.order_of_key(make_pair(a[i], inf));
		t.insert(make_pair(a[i], i));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 14336
import math

def main():
    n = int(input())
    a = [int(t) for t in input().split()]

    m = 0
    if 0 in a or len([x for x in a if x<0])%2==0:
        m = sum([abs(x) for x in a])
    else:
        a_ = [abs(x) for x in a]
        m = sum(a_)-2*min(a_)

    print(m)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14500
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::string s, t; cin >> s >> t;
	
	for(int i = 0; i < s.size(); i++) {
		std::string A = s.substr(0, i);
		std::string B = s.substr(i, s.size() - i);
		
		if(B + A == t) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
long long mod=1e9+7;

int main(){
  long long n,m;
  cin>>n>>m;
  vector<long long> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  vector<long long> b(n);
  long long tmp=0;
  for(int i=0;i<n;i++){
    tmp+=a[i];
    tmp%=m;
    b[i]=tmp;
  }
  long long ans=0;
  map<long long,long long> mp;
  for(int i=0;i<n;i++){
    mp[b[i]]++;
  }
  ans+=mp[0];
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    ans+=itr->second*(itr->second-1)/2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
typedef long long ll; 

using namespace std;

int main(int argc, const char *argv[]){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b > c + d) cout << "Left" << endl;
    else if (a + b == c + d) cout << "Balanced" << endl;
    else cout << "Right" << endl;

    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;

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;
}
using namespace std;

void solve(){
    ll a,b;
    cin>>a>>b;
    ll x=1,y=1;
    while(x<=a){
        x*=2;
    }
    while(y*2<=b){
        y*=2;
    }
    ll ans=x-a;
    if(ans%4==0)ans=0;
    else if(ans%4==1)ans=a;
    else if(ans%4==2)ans=1;
    else ans=a^1;
    ll cmp=b-y+1;
    if(cmp%4==0)cmp=0;
    else if(cmp%4==1)cmp=b;
    else if(cmp%4==2)cmp=1;
    else cmp=b^1;
    cout<<(ans^cmp)<<"\n";
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Bits

main = do
    [a, b] <- map read <$> words <$> getLine
    putStrLn $ show $ solve (a - 1) `xor` solve b

solve :: Integer -> Integer
solve a | a `mod` 4 == 0 = a
        | a `mod` 4 == 1 = 1
        | a `mod` 4 == 2 = a + 1
        | otherwise      = 0

Measured memory_bytes: 508
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

enum P = 10L^^9+7;

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(long[]);

    long x, r;
    foreach (a; AS) {
        (r += x * a % P) %= P;
        (x += a) %= P;
    }
    writeln(r);
}

Measured memory_bytes: 11688
#include<iostream>
#include <algorithm>
#include<functional>//greater???g—p
using namespace std;
#define MAX_LIST 60000
bool find_list(int *list,int a,int b,int x){
//cout<<list[a]<<" "<<list[b]<<" "<<list[(b+a)/2]<<" "<<x<<endl;
if(b-a<2){
if(list[b]==x){
//cout<<"find"<<endl;
return true;
}
if(find(list+a,list+b,x)!=list+b){
//cout<<"find"<<endl;
return true;
}
//cout<<"false"<<endl;
return false;
}
if(list[(b+a)/2]>x){
return find_list(list,a,(b+a)/2,x);
}else if(list[(a+b)/2]<x){
return find_list(list,(a+b)/2,b,x);
}
//cout<<"find "<<list[(b+a)/2]<<" "<<x<<endl;
return true;
}
int main(){
bool prime[MAX_LIST];
for(int i=0;i<MAX_LIST;i++){
prime[i]=1;
}
prime[0]=prime[1]=0;
for(int i=0;i*i<MAX_LIST;i++){
if(prime[i]==1){
for(int j=i*2;j<MAX_LIST;j=j+i){
prime[j]=0;
}
}
}
int primelist[60000];
int j=0;
for(int i=0;i<MAX_LIST;i++){
if(prime[i]==1){
primelist[j]=i;
j++;
if(j>60000){
break;
}
}
}
int in;
while(cin>>in,in){
int ans=0;
int t=0;
int r;
while(in>primelist[t])t++;
if(in%2==1){
r=2;
}else{
r=t;
}
for(int i=0;i<r;i++){
if(find_list(primelist,i,t,in-primelist[i])){
ans++;
}
}
cout<<ans<<endl;
}
return 0;
}

Measured memory_bytes: 1240
#include<iostream>
#include<algorithm>
using namespace std ;
int main()
{
	int n ;
	int m ;
	int k ;
	int num[ 200 ] ;
	int tmp[ 200 ] ,temp[ 100 ] ;
	cin >> n ;
	for( int i = 1 ; i <= 2 * n ; i++ )
	{
		num[ i - 1 ] = i ;
	}
	cin >> m ;
	for( int i = 0 ; i < m ; i++ )
	{
		int cnt1 = 0 ,cnt2 = 0 ;
		cin >> k ;
		if( k == 0 )
		{
			copy( num ,num + n ,tmp ) ;
			copy( num + n ,num + ( n * 2 ) ,temp ) ;
			for( int j = 0 ; j < n * 2  ; j++ )
			{
				if( j % 2 < 1 )
				{
					num[ j ] = tmp[ cnt1 ] ;
					cnt1++ ;
				}
				else
				{
					num[ j ] = temp[ cnt2 ] ;
					cnt2++ ;
				}
			}
		}
		else
		{
			copy( num ,num + k ,tmp ) ;
			copy( num + k ,num + ( 2 * n ) ,num ) ;
			copy( tmp ,tmp + k ,num + ( ( 2 * n ) - k ) ) ;
		}
	}
	for( int i = 0 ; i < 2 * n ; i++ )
	{
		cout << num[ i ] << endl ;
	}
	return 0 ;
}

Measured memory_bytes: 3108
#include <cstdio>

using namespace std;

#define MAX 10000
#define NIL -1

struct Node { int parent, left, right;};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u,int d) {
	if(u == NIL) return;
	D[u] = d;
	setDepth(T[u].left, d+1);
	setDepth(T[u].right,d+1);
}

int setHeight(int u) {
	int h1 = 0, h2 = 0;
	if(T[u].left != NIL)
		h1 = setHeight(T[u].left)  + 1;
	if(T[u].right != NIL)
		h2 = setHeight(T[u].right) + 1;
	return H[u] = (h1 > h2 ? h1 : h2);
}

// 接点 u の兄弟を返す
int getSibling(int u) {
	if( T[u].parent == NIL ) return NIL;
	if(T[T[u].parent].left != u && T[T[u].parent].left != NIL )
		return T[T[u].parent].left;
	if(T[T[u].parent].right != u && T[T[u].parent].right != NIL )
		return T[T[u].parent].right;
	return NIL;
}

void print(int u) {
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].parent);
	printf("sibling = %d, ",getSibling(u));
	int deg = 0;
	if(T[u].left  != NIL) deg++;
	if(T[u].right != NIL) deg++;
	printf("degree = %d, ",deg);
	printf("depth = %d, ",D[u]);
	printf("height = %d, ",H[u]);
	
	if(T[u].parent == NIL) {
		printf("root\n");
	} else if(T[u].left == NIL && T[u].right == NIL) {
		printf("leaf\n");
	} else {
		printf("internal node\n");
	}
}

int main(void) {
	int v, l, r, root = 0;
	scanf("%d",&n);
	for(int i=0;i<n;i++) T[i].parent = NIL;
	for(int i=0;i<n;i++) {
		scanf("%d %d %d",&v,&l,&r);
		T[v].left  = l;
		T[v].right = r;
		if(l != NIL) T[l].parent = v;
		if(r != NIL) T[r].parent = v;
	}
	
	for(int i=0; i<n; i++)
	if(T[i].parent == NIL) root = i;
	
	setDepth(root,0);
	setHeight(root);
	
	for(int i=0;i<n;i++) print(i);
	
	return 0;
}

/*
9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1
*/


Measured memory_bytes: 2716
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
using namespace std;



int main(){

	int n;
	//even,oddは1オリジン
	vector<int> a,ans,even,odd;
	cin >> n;
	for (int i = 0; i < n; i++){
		int tnp;
		cin >> tnp;
		a.push_back(tnp);
		if (i % 2 == 1) even.push_back(tnp);
		else odd.push_back(tnp);
	}


	if (n % 2 == 0){
		reverse(even.begin(), even.end());
		for (size_t i = 0; i < even.size(); i++){
			ans.push_back(even[i]);
		}
		for (size_t i = 0; i < odd.size(); i++){
			ans.push_back(odd[i]);
		}
	}
	else{
		reverse(odd.begin(), odd.end());
		for (size_t i = 0; i < odd.size(); i++){
			ans.push_back(odd[i]);
		}
		for (size_t i = 0; i < even.size(); i++){
			ans.push_back(even[i]);
		}
	}
	for (int i = 0; i < n; i++){
		cout << ans[i] << " ";
	}
	

	return 0;
}

Measured memory_bytes: 5368
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  int k; cin >> k;
  int n = s.size();
  set<string> st;
  rep(i, n) REP(j, i, i+k) st.insert(s.substr(i, j-i+1));
  auto itr = st.begin();
  rep(i, k-1) itr++;
  cout << *itr << "\n";
  return 0;
}


Measured memory_bytes: 4752
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;

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

    priority_queue<pair <int, int>, vector< pair< int, int > >, greater<pair <int, int > > > q;
    vector<int> v;
    map <int, int> m;
    for(int i = 0; i < n; i++) {
        if(m[a[i]] == 0) v.push_back(a[i]);
        m[a[i]]++;
    }

    for(int i = 0; i < v.size(); i++) {
        q.push(make_pair(m[v[i]],v[i]));
    }
    int sum = 0;
    
    while(q.size() > k) {
        auto p = q.top();
        q.pop();
        sum += p.first;
    }
    cout << sum << endl;





}

Measured memory_bytes: 13300
#include <stdio.h>
#define NUM 2

int main(void)
{
  int n[NUM][4];
  int i,j;
  int t[NUM]={0};
  for(i=0;i<NUM;i++){
    for(j=0;j<4;j++){
      scanf("%d",&n[i][j]);
      t[i] += n[i][j];
      }
  }
  if(t[1]>t[0])
    t[0] = t[1];
  printf("%d\n",t[0]);
  return 0;
}

Measured memory_bytes: 592
import sys
import collections

S=collections.deque(input())
Q=int(input())

rev=0
for _ in range(Q):
    fields=next(sys.stdin).split()
    T,F,C=(fields+['',''])[:3]
    if T=='1':
        rev^=1
    elif (rev and F=='1') or (not rev and F=='2'):
        S.append(C)
    else:
        S.appendleft(C)

if rev:
    print(''.join(reversed(S)))
else:
    print(''.join(S))


Measured memory_bytes: 14148
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

long long n, a, mn=1e9, sum, c;
int main() {
	cin >> n;
	while(n--) {
		scanf("%lld", &a);
		c += (a<0);
		a = abs(a);
		sum += a;
		mn = min(mn, a);
	}
	cout << sum - c%2 * 2 * mn;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

string s, t;
int mp[500], mpb[500];
int cnt;

int main() { 

  getline(cin, s);
  getline(cin, t);

  for (int i = 0; i < sz(s); i++) {
    if ((mp[s[i]] && mp[s[i]] != t[i]) || (mpb[t[i]] && mpb[t[i]] != s[i])) {
      puts("No");
      return 0;
    }
    mp[s[i]] = t[i];
    mpb[t[i]] = s[i];
  }
  
  puts("Yes");

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    double ans = v[0]/1.0;
    for (int i = 1; i < n; i++) {
        ans = (ans + v[i]) / 2.0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256