akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
long long MOD; int b;
vector <int> s[100005];
vector <pair <int, int> > v;
int lp[100005];
long long biok[100005];
vector <long long> bios[100005], biop[100005];
long long modz(long long x, long long y)
{
	return ((x%MOD) + (y%MOD)) % MOD;
}
long long f(int poz, int p)
{
	v.push_back(make_pair(poz, p));
	long long u = 1;
	for(int i = 0; i < s[poz].size(); i++)
	{
		if(s[poz][i] != p)
		{
			lp[s[poz][i]] = i;
			u *= f(s[poz][i], poz);
			u %= MOD;
		}
	}
	if(p != -1)
	{
		return biok[poz] = modz(u, 1);
	}
	else
	{
		return u;
	}
}
void r(int poz, int p)
{
	for(int j = 1; j <= s[poz].size(); j++)
	{
		if(s[poz][j-1] != p)
		{
		    biop[poz].push_back(biop[poz][j-1] * biok[s[poz][j-1]]);
		}
		else
		{
			biop[poz].push_back(biop[poz][j-1] * modz(biop[p][lp[poz]] * bios[p][lp[poz]+1], 1));
		}
		biop[poz][j] %= MOD;
	}
	for(int j = s[poz].size()-1; j >= 0; j--)
	{
		if(s[poz][j] != p)
		{
		    bios[poz][j] = bios[poz][j+1] * biok[s[poz][j]];
		}
		else
		{
			bios[poz][j] = bios[poz][j+1] * modz(biop[p][lp[poz]] * bios[p][lp[poz]+1], 1);
		}
		bios[poz][j] %= MOD;
	}
}
signed main()
{
    cin >> b >> MOD;
    int p, k;
    for(int i = 0; i < b-1; i++)
    {
    	cin >> p >> k;
    	p--;
    	k--;
    	s[p].push_back(k);
    	s[k].push_back(p);
	}
	for(int i = 0; i <= b; i++)
	{
		for(int j = 0; j <= s[i].size(); j++)
		{
			bios[i].push_back(1);
		}
		biop[i].push_back(1);
	}
	f(0, -1);
	for(int j = 1; j <= s[0].size(); j++)
	{
		biop[0].push_back(biop[0][j-1] * biok[s[0][j-1]]);
		biop[0][j] %= MOD;
	}
	for(int j = s[0].size()-1; j >= 0; j--)
	{
		bios[0][j] = bios[0][j+1] * biok[s[0][j]];
		bios[0][j] %= MOD;
	}
	for(int i = 1; i < v.size(); i++)
	{
		r(v[i].first, v[i].second);
	}
	for(int i = 0; i < b; i++)
	{
		cout << biop[i][s[i].size()] << endl;
	}
}


Measured memory_bytes: 31856
package main

import (
  "fmt"
)

func main() {
  var s string
  fmt.Scan(&s)
  var n,p int
  last := 'R'
  ans := make([]int, len(s))
  for i := range s {
    if last == 'R' && s[i] == 'L' {
      ans[i-1] += (n+1)/2 
      ans[i] += n/2
      p = i
      n=0
    } else if last == 'L' && s[i] == 'R' {
      ans[p-1] += n/2
      ans[p] += (n+1)/2
      n=0
    }
    n++
    last = rune(s[i])
    
    if i == len(s)-1 && last == 'L' {
      ans[p-1] += n/2
      ans[p] += (n+1)/2
    }    
  }
  for i := range ans {
    fmt.Printf("%d ", ans[i])
  }
}
  
  
  
  
  
  
  






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

int main()
{
    char s[4];
    scanf("%s", s);
    if(s[0]=='7' || s[1]=='7' || s[2]=='7')
    {
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

class DK {
public:
	struct edge {
		int to;
		ll cost;
	};

	int prev[100010];
	ll d[100010];
	int N;
	vector<edge> G[100010];//各頂点からの辺

	void dijkstra(int start) {
		fill(d, d + 100010, INF);
		d[start] = 0;
		fill(prev, prev + 100010, -1);

		priority_queue<P, vector<P>, greater<P>> que;
		que.push(P(0, start));

		while (!que.empty()) {
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first)continue;
			for (int i = 0; i < G[v].size(); i++) {
				edge e = G[v][i];
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					prev[e.to] = v;
					que.push(P(d[e.to], e.to));
				}
			}
		}
	}

	vector<int> get_path(int goal) {
		vector<int> path;
		for (int t = goal; t != -1; t = prev[t]) {
			path.push_back(t);
		}//このままでは逆順なのでひっくり返す
		reverse(ALL(path));
		return path;
	}
};

int n, m, s, t;
DK dk;
ll cnt[2][200100] = {};
ll ans;

int main() {
	cin >> n >> m >> s >> t;
	s--;
	t--;
	rep(i, m) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		dk.G[x].push_back({ y,1 });
		dk.G[y].push_back({ x,1 });
	}
	dk.dijkstra(s);
	rep(i, n) {
		if (dk.d[i] != INF)cnt[0][dk.d[i]]++;
	}
	dk.dijkstra(t);
	rep(i, n) {
		if (dk.d[i] != INF)cnt[1][dk.d[i]]++;
	}
	int now = 0;
	rep(i, dk.d[s] - 1) {
		//cout << cnt[0][i] << " " << cnt[1][dk.d[s] - 2 - i] << endl;
		ans += cnt[0][i] * cnt[1][dk.d[s] - 2 - i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 16576
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(x) for(auto it=(x).begin();it!=(x).end();it++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
//#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    string s;
    int ans=0;
    while(cin>>s){
        reverse(all(s));
        string t="";
        rep(i,0,s.size()){
            if('0'<=s[i] && s[i]<='9'){
                int count=0;
                ans+=(s[i]-'0')*pow(10,count);
                while(i+1<s.size() && '0'<=s[i+1] && s[i+1]<='9'){
                   count++;
                   ans+=(s[i+1]-'0')*pow(10,count);
                   i++;
                }
            }
        }
    }
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 3264
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
#define MOD 1000000007LL
#define N 200123

using namespace std;

int n, m;
ll sbw[N], sfw[N], ans;

int main() {
    ios_base::sync_with_stdio(0);

    cin >> n >> m;

    for(int i=1; i <= n; ++i) {
        sbw[i] = sbw[i - 1] + i;
    }

    for(int i=n; i >= 0; --i) {
        sfw[i] = sfw[i + 1] + i;
    }

    for(int i=m; i <= n + 1; ++i) {
        ans = (ans + sfw[n - i + 1] - sbw[i - 1] + 1) % MOD;
    }
    
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 6704
#include<stdio.h>

int main(void){
	int n,ans,s,t,u,i;
	unsigned long l;
	
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		
		l=1;
		ans=0;
		
		
		s=0;
		t=0;
		u=0;
		
		for(i=n;i>0;i--){
			n=i;
			while(n%10==0){
				n/=10;
				u++;
			}
			while(n%2==0){
				n/=2;
				s++;
			}
			while(n%5==0){
				n/=5;
				t++;
			}
			if(s<t)ans=u+s;
			else ans=u+t;
		}
		
		/*
		for(;n>0;n--){
			l=l*n;
		}
		
		while(1){
			if(l%10==0){
				ans++;
				l/=10;
			}
			else break;
		}
		*/
		
		printf("%d\n",ans);
		
	}
		
	
	return 0;
}
	
	

Measured memory_bytes: 600
//why tle lol
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef complex<double> pnt;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> pp;
typedef double ld;
typedef long double lld;
#define INF 0x3f3f3f3f // for int
#define LL_INF 0x3f3f3f3f3f3f3f3f // for ll
#define ms(x, y) memset(x, y, sizeof(x))
//coordinate compression:sort(val.begin(), val.end());
//		val.resize(unique(val.begin(), val.end()) - val.begin());
#define nl '\n'
typedef unsigned long long ull;
const lld pi = 3.14159265358979323846;
const int MOD = 1e9 + 7;

//remember to remove ios stuff if i use scanf

//printf("%05lld\n", x); --> print last 5 digits including 0's
//printf("%02d:%02d", h, m); --> time
ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll pwmd(ll b, ll exp) {
    ll ret = 1;
    while (exp > 0) {
        if (exp % 2 == 1) ret = (ret * b) % MOD;
        exp /= 2;
        b = (b * b) % MOD;
    }
    return ret;
}
//void RotateArr(int X) {
//    for (int n=0; n<X; n++) {
//        for (int i=0; i<N/2; i++) {
//            for (int j=0; j<N; j++) {
//                swap(a[i][j], a[N-i-1][j]);
//            }
//        }
//        for (int i=0; i<N; i++) {
//            for (int j=i+1; j<N; j++) {
//                swap(a[i][j], a[j][i]);
//            }
//        }
//    }
//}

/*
 * string input;
 *
 * stringstream ss(input);
 *- if the input contains '\n', separate lines with: string line; while (getline(ss, line))
 * - clear() to clear the stream
 * - >> : read smth from stringstream object ie. while (s >> word)
 */

struct pair_hash { //--> for unordered_set<pair<ll, ll>>
    //initialize the set with unordered_set<pair<ll, ll>, pair_hash>st
    inline std::size_t operator()(const std::pair<ll,ll> & v) const {
        return v.first*31+v.second;
    }
};
/* for dijkstra:
 * bool operator < (const E &other) const {
        return this->w > other.w;
    }
 */

string s;

void solve(int tc) {

    cin >> s; int n = s.size();
    if (s[n-1] == 's') s = s + "es";
    else s = s + "s";
    cout << s << nl;

}

//you should really read the stuff at the bottom

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

    int tc = 1; //cin >> tc;
    for (int t = 1; t <= tc; t++) solve(t);

    return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
// Did you read the bounds?
// Did you make typos?
// Are there edge cases (N=1?)
// Are array sizes proper (scaled by proper constant, for example 2* for koosaga tree)
// Integer overflow?
// DS reset properly between test cases?
// Is using long longs causing TLE?
// Are you using floating points?
*/

Measured memory_bytes: 3652
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<set>
#include<list>
#include<stack>
#include<vector>
#include<cstdlib>
#include<iterator>
#include<deque>
#include<ctime>
#include<iomanip>
#include<map>
#include<bitset>
#include<utility>
#include<sstream>
using namespace std;
int main()
{
	char c;
	cin>>c;
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')printf("vowel");
	 else printf("consonant");
	return 0;
}



Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
    int A, B, C, K;
    cin >> A >> B >> C;
    cin >> K;

    int max, m;

    max = A;
    m = 0;

    if(B>max){
        max = B;
        m = 1;
    }

    if(C>max){
        m = 2;
    }
    
    //最大数をK回2倍
    if(m==0)
        cout << A*pow(2,K) + B + C << endl;
    else if(m==1)
        cout << A + B*pow(2,K) + C << endl;
    else
        cout << A + B + C*pow(2,K) << endl;
    
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
	int n; cin >> n;
	vector<int> a(n);
	map<int,int> num;
	ll ans=0;
	rep(i,n){
		cin >> a[i];
		ans+=a[i];
		num[a[i]]++;
	}
	int q; cin >> q;
	rep(i,q){
		int b,c; cin >> b >> c;
		ans+=(num[b]*(c-b));
		num[c]+=num[b];
		num[b]=0;
		cout << ans << endl;
	}
return 0;
}


Measured memory_bytes: 8080
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

MaxValue = 0
if N == 1:
  MaxValue = min(B[0], A[0]+A[1])
  print(MaxValue)
else:
  for i in range(N):
    if A[i] < B[i]:
      #MaxValue += A[i]
      if A[i+1] < B[i] - A[i]:
        MaxValue += A[i+1] + A[i]
        A[i+1] = 0
      else:
        temp = B[i] - A[i]
        MaxValue += B[i]
        A[i+1] -= temp
    else:
      MaxValue += B[i]
  print(MaxValue)

Measured memory_bytes: 18624
n, m = map(int, input().split())
num_list = ['X'] * n

def ans():
    if n == 1 and m == 0:
        return 0
    for i in range(m):
        set = list(map(str, input().split()))
        if set[0] == '1' and set[1] == '0' and n != 1:
            return -1
        else:
            if num_list[int(set[0]) - 1] == 'X':
                num_list[int(set[0]) - 1] = set[1]
            elif num_list[int(set[0]) - 1] == set[1]:
                continue
            else:
                return -1


    if num_list[0] == 'X':
        num_list[0] = '1'

    for i in range(1, n):
        if num_list[i] == 'X':
            num_list[i] = '0'

    return ''.join(num_list)

print(ans())


Measured memory_bytes: 3064
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    ans = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            for k in range(j+1, n+1):
                if i+j+k == x:
                    ans += 1
    print(ans)


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

#include <cmath>

int main() {
  long N;
  std::cin >> N;

  std::vector<long long> Avec(N);
  for (auto& A : Avec) {
    std::cin >> A;
  }

  auto it = std::find(Avec.begin(), Avec.end(), 0);
  if (it != Avec.end()) {
    std::cout << "0\n";
    return 0;
  }

  long long result = 1;
  for (auto A : Avec) {
    if ((static_cast<long long>(std::pow(10, 18)) / A) < result) {
      std::cout << "-1\n";
      return 0;
    }

    result *= A;
  }

  std::cout << result << '\n';
}


Measured memory_bytes: 4052
N = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
ans = 0

rui1 = [0] * (N + 1)
rui2 = [0] * (N + 1)
for i in range(1, N + 1):
    rui1[i] = rui1[i - 1] + a1[i - 1]
    rui2[i] = rui2[i - 1] + a2[i - 1]

for i in range(1, N + 1):
    tmp = rui1[i] + (rui2[N] - rui2[i - 1])
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define MAX3(a,b,c) max(a,max(b,c))
#define MIN3(a,b,c) min(a,min(b,c))
using namespace std;
int main()
{
    int a,b,c,ans;
    scanf("%d %d %d",&a,&b,&c);
    ans=(MAX3(a,b,c)*10)+min(a,b)+min(b,c)+min(a,c)-MIN3(a,b,c);
    printf("%d",ans);
}

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

using namespace std;

int N;
vector<int> V;

int main() {
	cin >> N;
	for (int a = 0; a < N; a++) {
		int n;
		cin >> n;
		V.push_back(n);
	}

	sort(V.begin(), V.end(), greater<int>());

	int cont = 1;
	int before = V[0];

	for (const auto& i : V) {
		if (before == i) continue;
		cont++;
		before = i;
	}

	cout << cont << endl;
	
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int sec = 0;
		if(A > C) {
			int x = A;
			A = C;
			C = x;
			x = B;
			B = D;
			D = x;
		}
		if(B < C) System.out.println(sec);
		else if(B < D){
			sec = B - C;
			System.out.println(sec);
		}else{
			sec = D - C;
			System.out.println(sec);
		}
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
int hoge[222222];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  for(auto &a:A)cin>>a;
  vi ans;
  for(int i=n;i>=1;i--){
    if(i>n/2){
      if(A[i-1]==1){ans.pb(i);hoge[i]=1;}
    }else{
      ll cnt=0;
      for(int j=i*2;j<=n;j+=i){
	cnt+=hoge[j];
      }
      // cout<<cnt<<" "<<i<<endl;
      if(A[i-1]==1){
	if(cnt%2==0){
	  ans.pb(i);
	  hoge[i]=1;
	}
      }else{
	if(cnt%2==1){
	  ans.pb(i);
	  hoge[i]=1;
	}
      }
    }
  }
  cout<<ans.size()<<endl;
  for(auto a:ans)cout<<a<<" ";
  cout<<endl;
  return 0;
}


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

typedef long long ll;

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

    int n,m;cin>>n>>m;
    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0;i<n;i++)for(int j=0;j<m;j++){
        cin>>a[i][j];a[i][j]--;
    }
    int res=114514;
    vector<int> used(m,0);
    for(int i=0;i<m;i++){
        int tmp=0,sp;
        vector<int> cnt(m,0);
        for(int j=0;j<n;j++){
            for(int k=0;k<m;k++){
                int idx=a[j][k];
                if(used[idx]) continue;
                cnt[idx]++;break;
            }
        }
        for(int j=0;j<m;j++){
            if(used[j]) continue;
            if(cnt[j]>tmp){
                tmp=cnt[j];sp=j;
            }
        }
        res=min(res,tmp);
        used[sp]=1;
        //cout<<sp<<" "<<tmp<<endl;
        //cout<<res<<endl;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int a,b,c,k,cnt;
int main()
{
	cin>>a>>b>>c>>k;
	if(b==0||c==0) {cout<<"No"<<endl; return 0;}
	while(b<=a) b<<=1,cnt++;
	while(c<=b) c<<=1,cnt++;
	if(cnt<=k) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3628
n = int(input())
P = list(map(int, input().split()))

ans = 0
for i in range(0,len(P)-2):
  if P[i] < P[i+1] < P[i+2] or P[i+2] < P[i+1] < P[i]:
    ans += 1
    
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#define maxn 100005
using namespace std;
int arr[maxn], dp[maxn];
int main() {
	ios::sync_with_stdio(false);
	//   sync_with_YinHsuan(true);
	cin.tie(0);
	int n, k, a, b, c;
	cin >> n >> k >> arr[1];
	for ( int i=2; i<=n; ++i ) {
		cin >> arr[i];
		int mn = -1;
		for ( int j=i-1; j>=i-k&&j>=1; --j )
			if ( mn == -1 || dp[j]+abs(arr[i]-arr[j]) < mn )
				mn = dp[j] + abs(arr[i]-arr[j]);
		dp[i] = mn;
	}
	cout << dp[n] << '\n';
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

int main()
{
    string s;
    cin >> s;
    
    ll ans = 0;
    for (ll i = 0; i < s.size(); i++)
    {
        if (s[i] == '1') {
            ans += 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int n;
		while((n = scn.nextInt())!=0) {
			long min = 0,max = -100000,buf = 0;
			for(int i = 0;i < n;i++) {
				 buf += scn.nextLong();
				 max = Math.max(max, buf-min);
				 min = Math.min(min, buf);
			}
			System.out.println(max);
		}
		scn.close();
	}

}



Measured memory_bytes: 34948
#include<stdio.h>

int main(){
  int a, b, c;
  int temp;
  
  scanf("%d %d %d", &a, &b, &c);

  if(a > b){
    temp = a;
    a = b;
    b = temp;
  }

  if(b > c){
    temp = b;
    b = c;
    c = temp;
  }

  if(a > b){
    temp = a;
    a = b;
    b = temp;
  }

  printf("%d %d %d\n", a, b, c);

  return 0;
}




Measured memory_bytes: 2072
import heapq


def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    ans = 1
    inside_que = [0] * N
    min_que, max_que = [], []
    for i in range(K):
        heapq.heappush(min_que, P[i])
        heapq.heappush(max_que, - P[i])
        inside_que[P[i]] = 1
    for i in range(N - K):
        old_p, new_p = P[i], P[i + K]
        if not(old_p == min_que[0] and new_p >= - max_que[0]):
            ans += 1
        inside_que[old_p] = 0
        inside_que[new_p] = 1
        heapq.heappush(min_que, new_p)
        heapq.heappush(max_que, - new_p)
        while inside_que[min_que[0]] == 0:
            heapq.heappop(min_que)
        while inside_que[-max_que[0]] == 0:
            heapq.heappop(max_que)
    desc_index = 0
    exists_asc_section = False
    for i in range(1, N):
        if P[i - 1] > P[i]:
            if i - desc_index >= K:
                ans -= 1
                exists_asc_section = True
            desc_index = i
    if N - desc_index >= K:
        exists_asc_section = True
        ans -= 1
    if exists_asc_section:
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 32400
#include<cstdio>
#include<algorithm>

int main(){
    int n; scanf("%d", &n);
    int maxv, minv, a;
    maxv= -1000000000;
    scanf("%d", &minv);
    for(int i = 1; i < n; i++){
        scanf("%d", &a);
        maxv = std::max(maxv, a-minv);
        minv = std::min(minv, a);
    }
    printf("%d\n", maxv);
}



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

int ctoi(char c) {
    return c - '0';
}

template<class T>
void printIter(const T &a, string delimiter) {
    if (a.size() == 0) return;
    auto it = a.begin();
    cout << *it;
    it++;
    while (it != a.end()) {
        cout << delimiter << *it;
        it++;
    }
    cout << endl;
}

const int mod = 2019;

template< typename T >
T mod_pow(T x, T n, const T &p) {
    T ret = 1;
    while(n > 0) {
        if(n & 1) (ret *= x) %= p;
        (x *= x) %= p;
        n >>= 1;
    }
    return ret;
}

int main() {
    string S;
    cin >> S;
    vector<int> mods(S.size()+1);
    unordered_map<int, int> m;
    for (int i = 0; i < 2019; ++i) {
        m[i] = 0;
    }

    mods[0] = 0;
    m[0]++;
    for (int i = 0; i < S.size(); i++) {
        int k = ctoi(S[S.size() - 1 - i]);
        mods[i+1] = (mods[i] + k * mod_pow(10, i, mod)) % mod;
        m[mods[i+1]]++;
    }

    long long ans = 0;

    for (int i = 0; i < 2019; i++) {
        if (m[i] < 2) continue;
        ans += m[i] * (m[i] - 1) / 2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4336
#define George_Plover
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <iomanip>
#include <algorithm>
#define MAXN 100001
#define MAXM 200001
#define MOD 100000007
#define EPS (1e-8)
#define LL long long
using namespace std;
bool vis[MAXM];
int n,m;
int h[MAXM];
int main()
{
    memset(vis,1,sizeof(vis));
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%d",&h[i]);
    for(int i=1;i<=m;i++)
    {
        int tx,ty;
        scanf("%d%d",&tx,&ty);
        if(h[tx]>=h[ty])
            vis[ty]=0;
        if(h[ty]>=h[tx])
            vis[tx]=0;
    }
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        if(vis[i])
            sum++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 4276
#include <cassert>
#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <deque>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

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

    if (500 * K >= X) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        // String s = sc.next();
        // long l = sc.nextLong();
            d = d % 1000;
        System.out.println((1000-d)%1000);
    }
}


Measured memory_bytes: 35612
import java.util.*

fun main(args : Array<String>) {
    val scan = Scanner(System.`in`)

    var s = scan.next()
    val q = Integer.parseInt(scan.next())

    var rvFlag = false
    val str = ArrayDeque<Char>(s.toList())

    repeat(q) {
        val q1 = Integer.parseInt(scan.next())

        if (q1 == 1) {
            rvFlag = !rvFlag
        } else {
            val q2 = Integer.parseInt(scan.next())
            val c = scan.next()[0]

            if (rvFlag) {
                if (q2 == 1) {
                    str.addLast(c)
                } else {
                    str.addFirst(c)
                }
            } else {
                if (q2 == 1) {
                    str.addFirst(c)
                } else {
                    str.addLast(c)
                }
            }
        }
    }

    if (rvFlag) {
        println(str.reversed().joinToString(separator = ""))
    } else {
        println(str.joinToString(separator = ""))
    }
}

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

signed main() {
  string S;
  cin >> S;
  
  map<char, int> ans;
  for( int i = 0; i < S.size(); i++ ){
    if( ans.count(S.at(i)) ){
      ans.at(S.at(i))++;
    }else{
      ans[S.at(i)] = 1;
    }
  }
  
  for( int i = 0; i < S.size(); i++ ){
    if( ans.at(S.at(i)) % 2 > 0 ){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

// math functionsz
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main()
{
    ll A, B, C, D;
    input(A, B, C, D);

    ll l = lcm(C, D);
    ll all = B - A + 1;
    ll div = (B / C) - (A % C == 0 ? (A / C - 1) : (A / C)) + (B / D) - (A % D == 0 ? (A / D - 1) : (A / D));
    ll inter = (B / l) - (A % l == 0 ? (A / l - 1) : (A / l));

    cout << all - div + inter << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
tl = list(map(int, input().split()))
m = int(input())
pl = list(list(map(int, input().split())) for _ in range(m))

t_sum = sum(tl)
for p in pl:
    print(t_sum - (tl[p[0] - 1] - p[1]))


Measured memory_bytes: 3060
import java.util.*;
class Main{
    public static void main(String[] args)
    {
        int  n[] = new int[3];   
        try (Scanner scanner = new Scanner(System.in))
        {
        
            for(int i = 0; i < 3; i++)
            {
                n[i] = scanner.nextInt();
            }
        }
        System.out.println(Main.Calculation(n[0], n[1], n[2]));
    }
    public static int Calculation(int a, int b, int c)
    {
        int train, result;
        train = b * a;
        result = c;
        if(train < c)
        {
            result = train;
        }
        return result;
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{

    int f=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='7')
        {
            f=1;
        }
    }

    if(f==1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }









    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------

int ans;
int N;
void _main() {
	cin >> N;
	long int d[100000];
	rep(i, 0, N) {
		cin >> d[i];
	}
	sort(d, d + N);
	if (d[N / 2] == d[N / 2 -1]) ans = 0;
	else ans = d[N / 2] - d[N / 2 -1] ;
	cout << ans << endl;
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		String str = "ai1333";
		for (int i = 0; i < N / 100; ++i) {
			str += "3";
		}
		PrintWriter pw = new PrintWriter(System.out);
		pw.println(str);
		pw.close();
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

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

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}



Measured memory_bytes: 24400
package main

import (
	"fmt"
)

func main() {
	var a1, a2, a3 int
	fmt.Scanf("%d%d%d", &a1, &a2, &a3)

	if a1 > a2 {
		a1, a2 = a2, a1
	}
	if a2 > a3 {
		a2, a3 = a3, a2
	}
	if a1 > a2 {
		a1, a2 = a2, a1
	}

	fmt.Println(a3 - a1)
}


Measured memory_bytes: 512
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

min = 10

dish = [a,b,c,d,e]
total = 0
for i in dish:
    if i % 10 != 0 and i % 10 < min:
        min = i % 10
    total -= (- i // 10) * 10

total += min - 10

print(total)


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const ll mod = 1e9 + 7;
const int inf = 1e9;

int main() {
	cin.sync_with_stdio(false);
	string S;
	cin >> S;
	bool fN = false, fS = false, fW = false, fE = false;
	for (auto i : S) {
		if (i == 'N')fN = true;
		if (i == 'S')fS = true;
		if (i == 'W')fW = true;
		if (i == 'E')fE = true;
	}
	if (fN==fS && fW==fE)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const* argv[])
{
    int r;
    std::cin >> r;

    if (r < 1200) {
        std::cout << "ABC" << std::endl;
    }
    else if (r < 2800) {
        std::cout << "ARC" << std::endl;
    }
    else {
        std::cout << "AGC" << std::endl;
    }
}

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

using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;

int main(){
    int n; cin >> n;
    cout << (n+1) / 2 << endl;


    return 0;
}


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

int main(){
  ll n,m; cin >>n >>m;
  if(2*n>m) cout << m/2 << endl;
  else cout << n+(m-n*2)/4 << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    REPR(i,n){
        if(t.substr(0,i)==s.substr(n-i)){
            cout<<2*n-i<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int nonTaxedPrice = (int)Math.ceil(N/1.08);
		if(Math.floor(nonTaxedPrice * 1.08) == N) {
			System.out.println(nonTaxedPrice);
		} else {
			System.out.println(":(");
		}
	}
}

Measured memory_bytes: 22740
// C - Dice and Coin

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

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

	double ans = 0;

	// i: サイコロの目
	for (int i=1; i<=N; i++) {
		int score = i;
		int j=0;
		while (score <= K-1) {
			j++;
			score *= 2;
		}

		ans += 1.0 / (double)(N * pow(2, j)) ;

	}

	cout << fixed << setprecision(10);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [0] * n
x = [0] * n
y = [0] * n
for i in range(n):
    a[i] = int(input())
    t = [[int(j) for j in input().split()] for k in range(a[i])]
    x[i] = [j[0] for j in t]
    y[i] = [j[1] for j in t]

mx = 0
for bit in range(1<<n):
    flag = True
    tf = [0] * n
    for i in range(n):
        if bit & (1 << i): 
            tf[i] = 1
    for i in range(n):
        if tf[i] == 0:
            continue
        for j in range(a[i]):
            if tf[x[i][j]-1] != y[i][j]:
                flag = False
    if flag: mx = max(mx, bin(bit).count("1"))
print(mx)

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(3*n);
  for(i=0;i<3*n;i++)cin>>a[i];
  sort(ALLR(a));
  for(i=0;i<n;i++){
    res+=a[2*i+1];
  }
  cout<<res<<endl;
  
  return 0;
}

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

typedef long long llint;
typedef long double ld;
typedef pair<int,int> P;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())


priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }



void solve(){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin >> a[i];
    set<int>d;
    for(int b=0;b<(1<<n);b++){
        int sum=0;
        for(int i=0;i<n;i++){
            if(b & (1<<i))sum+=a[i];
        }
        d.insert(sum);
    }
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        int m;
        cin >> m;
        if(d.count(m))cout << "yes" << endl;
        else cout << "no" << endl;
    }
}

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






Measured memory_bytes: 3120
fun main() {
    val s = readLine()!!.trim()

    for (i in 1 until s.length.div(2)) {
        val ss = s.dropLast(i * 2)
        val mid = ss.length.div(2)

        val a = ss.slice(0 until mid)
        val b  = ss.slice(mid .. ss.lastIndex)

        if(a == b){
            print(ss.length)
            return
        }
    }
    print(-1)
}


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

int main(){
	int n ; cin >> n ;
	int sum = 0 ;
	int mx = 0 ;
	for(int i=0;i<n;i++){
		int p ; cin >> p ;
		if(p>mx) mx = p ;
		sum += p ;
	}
	cout << sum-mx/2 << endl ;
}


Measured memory_bytes: 256
fn main() {
    let (n, k, v) = input();
    println!("{}", solve(n, k, v));
}

fn input() -> (usize, usize, Vec<Vec<usize>>) {
    let mut buf1 = String::new();
    std::io::stdin().read_line(&mut buf1).unwrap();
    buf1.pop();
    let mut iter1 = buf1.split_whitespace();
    let n: usize = iter1.next().unwrap().parse().unwrap();
    let k: usize = iter1.next().unwrap().parse().unwrap();
    let mut v = Vec::new();
    for i in 0..k {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.pop();
        let d: usize = buf.parse().unwrap();
        let mut buf2 = String::new();
        std::io::stdin().read_line(&mut buf2).unwrap();
        buf2.pop();
        let mut iter2 = buf2.split_whitespace();
        let vv: Vec<usize> = iter2.map(|s| s.parse().unwrap() ).collect();
        v.push(vv);
    }
    (n, k, v)
}

fn solve(n: usize, k: usize, v: Vec<Vec<usize>>) -> usize {
    let mut have: Vec<bool> = vec![false; n];
    for i in v.iter() {
        for a in i.iter() {
            if !have[a-1] { have[a-1] = true; }
        }
    }
    let mut ans = 0;
    for h in have.iter() {
        if !h { ans += 1; }
    }
    ans
}

Measured memory_bytes: 2168
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Monad
import           Data.IORef
import qualified Data.Text     as T
import qualified Data.Text.IO  as T
import           System.IO

readT :: Read a => T.Text -> a
readT = read . T.unpack

getLineSpc :: Read a => IO [a]
getLineSpc = do
  t <- T.getLine
  let xs = map readT $ T.split (== ' ') t
  return xs

main :: IO ()
main = remainderReminder

remainderReminder :: IO ()
remainderReminder = do
  nkT :: [Int] <- getLineSpc
  let [n, k] = nkT :: [Int]
  if k /= 0
    then do
      m <- newIORef 0
      forM_ [2..n] $ \i -> do
        let (q, r) = n `divMod` i
            add    = q * max 0 (i - k) + max 0 (r - k + 1)
        modifyIORef m (+ add)
      m <- readIORef m
      print m
    else
    print $ n ^ 2

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

int main(){
	ll a,k;	cin >> a >> k;
  	ll arr[a];
  	for(int i = 0; i < a; ++i){
		cin >> arr[i];
    }
  	sort(arr,arr+a);
  	ll ans = 0;
  	for(int i = 0; i < a-k; ++i){
		ans += arr[i];
    }
 	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int v[1005], a, k, n;

void bt(int poz){
    int i3=0, i5=0, i7=0, h=0;
    for(int i=0; i<poz; i++){
        if(v[i]==3)
            i3=1;
        if(v[i]==5)
            i5=1;
        if(v[i]==7)
            i7=1;
        h=h*10+v[i];
    }
    if(i3==1 && i5==1 && i7==1 && h<=n) {
        k++;
    }
    if(poz==a)
        return;
    v[poz]=3;
    bt(poz+1);
    v[poz]=5;
    bt(poz+1);
    v[poz]=7;
    bt(poz+1);

}

int main()
{
    int m;
    cin>>n;
    m=n;
    while(m>0){
        m/=10;
        a++;
    }
    bt(0);
    cout<<k;

    return 0;
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  vi a(n);
  vl cum(n + 1);
  rep(i, n) cin >> a[i];
  rep(i, n) cum[i + 1] = cum[i] + a[i];
  dump(n, a, cum);
  auto calc = [&](int left, int right) {
    ll base = cum[left];
    ll total = cum[right + 1] - base;
    while (right - left > 1) {
      int mid = left + (right - left) / 2;
      if (total / 2 < cum[mid + 1] - base)
        right = mid;
      else
        left = mid;
    }
    return left;
  };
  ll ans = INF;
  for (int m = 2; m <= n - 2; m++) {
    int m1 = calc(0, m - 1);
    int m2 = calc(m, n - 1);
    rep(i, 2) rep(j, 2) {
      if (m1 + i == m - 1) continue;
      if (m2 + j == n - 1) continue;
      ll b = cum[m1 + i + 1];
      ll c = cum[m] - cum[m1 + i + 1];
      ll d = cum[m2 + j + 1] - cum[m];
      ll e = cum[n] - cum[m2 + j + 1];
      if (b + c + d + e != cum[n]) {
        dump(m, m1, m2, b, c, d, e);
        return;
      }
      ll minVal = min(min(b, c), min(d, e));
      ll maxVal = max(max(b, c), max(d, e));
      dump(m, m1, m2, b, c, d, e, minVal, maxVal);
      ans = min(ans, abs(maxVal - minVal));
    }
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N;cin >> N;
    ll A,B,C,D;cin>> A >> B >> C >> D;
    FOR(k,1,N){
        if(B-A>=k*C-(N-1-k)*D&&B-A<=k*D-(N-1-k)*C){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

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

void tolower (std::string &s) {
	for (char &c : s) c = tolower(c);
}

int main() {
	std::string s, t;
	std::cin >> s;
	tolower(s);
	
	int ans = 0;
	
	while (true) {
		std::cin >> t;
		if (t == "END_OF_TEXT") break;
		tolower(t);
		ans += (s == t);
	}
	
	std::cout << ans << '\n';
	
	return 0;
}


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

/*----------------------------------------------*/

signed main(){
  string s;
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());

        System.out.println((N * A) > B ? B : N * A);
    }
}


Measured memory_bytes: 21844
N, A, B, C, D = map(int, input().split())
S = input()

A -= 1
B -= 1
C -= 1
D -= 1

if '##' in S[A:C] or '##' in S[B:D]:
    print("No")
    exit()
if C > D:
    if  '...' not in S[B-1:D+2]:
        print("No")
        exit()
print("Yes")




Measured memory_bytes: 3572