akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

size_t i, j;
ll N, K, S = 0;
ll A[500];

bool solve(ll m) {
    vector<ll> B(N, 0);
    for(i = 0; i < N; i++) B[i] = A[i] % m;
    sort(ALL(B));
    j = N - 1;
    ll cnt = 0, buff = 0;
    for(i = 0; i <= j; i++) {
        if(B[i] % m == 0) continue;
        buff += B[i];
        cnt += B[i];
        B[i] = 0;
        while(buff && j >= 0) {
            if(B[j] % m == 0) {
                j--;
                continue;
            }
            if(m - B[j] > buff) {
                B[j] += buff;
                buff = 0;
            } else {
                buff -= (m - B[j]);
                B[j] = m;
                j--;
            }
        }
    } 
    return cnt <= K;
}

int main() {
    fastio();
    cin >> N >> K;
    REP(i, N) {
        cin >> A[i];
        S += A[i];
    }
    ll x = 1;
    vector<ll> cand;
    while(x * x <= S) {
        if(S % x == 0) {
            cand.push_back(x); 
            cand.push_back(S / x);
        }
        x++;
    }
    sort(ALL(cand)); reverse(ALL(cand));
    for(auto& c : cand) if(solve(c)) {
        cout << c << endl;
        break;
    }
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	string s;
	cin >> s;

	ll sum = 0;
	for (int tmp = 0; tmp < (1 << (sz(s) - 1)); tmp++) {
		ll t = s[0] - '0';

		for (int i = 0; i < sz(s) - 1; i++) {
			if (tmp & (1 << i)) {
				sum += t;
				t = s[i + 1] - '0';
			}
			else {
				t *= 10;
				t += s[i + 1] - '0';
			}
		}
		sum += t;
	}

	out(sum);

	return 0;
}

Measured memory_bytes: 256
import bisect

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
        
ans = 0
for t in T:
    if bisect.bisect_left(S, t) != bisect.bisect_right(S, t):
        ans += 1
    
print(ans)  


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

int main(){
                                                                     

    int n, i, j, f;

    int t = 0;

    int m = 0;

    string s, l, r;

    
    cin >> n >> s;


    for( i = 1 ; i < n ; i = i + 1 ){

         l = s.substr( 0, i );

         r = s.substr( i, n - i );

         sort( l.begin(), l.end() );

         sort( r.begin(), r.end() );

         l.erase( unique( l.begin(), l.end() ), l.end() );

         r.erase( unique( r.begin(), r.end() ), r.end() );

         t = 0;


         for( j = 0 ; j < l.size() ; j = j + 1 ){

              f = count(r.begin(), r.end(), l.at(j) );

              if( f > 1 ) f = 1;

              t += f;

              }

         if( m < t ) m = t;

         }



    cout << m << endl;

    return 0;

    }

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

int need[30];
int tani[30];

int main() {
  int n, u;
  for (;;) {
    cin >> n >> u;
    if (n == 0 && u == 0) break;
    rep (i, n) {
      int k;
      cin >> tani[i] >> k;
      int bit = 0;
      rep (j, k) {
	int r;
	cin >> r;
	bit |= 1 << r;
      }
      need[i] = bit;
    }
    int res = n;
    rep (bit, 1 << n) {
      int koma = __builtin_popcount(bit);
      if (res <= koma) continue;
      int sum = 0, b = bit;
      while (b) {
	int clz = 31 - __builtin_clz(b);
	if ((bit & need[clz]) != need[clz]) goto aaa;
	b ^= 1 << clz;
	sum += tani[clz];
      }
      if (sum < u) continue;
      res = koma;
    aaa:;
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 868
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const ll N =2e5+5;
ll ans[N];
ll sum[N];
int main(){
       cin.tie(0), ios::sync_with_stdio(0);
  ll n;
  cin>>n;
  map<string,ll>m;
  while(n--){
      string s;
    cin>>s;
    m[s]++;
  }
  cout<<m.size()<<endl;
}
    

Measured memory_bytes: 19204
str = STDIN.gets.chomp
if str.index(/(.)\1/)
	s = str.index(/(.)\1/) + 1
	e = s + 1
elsif str.index(/(.).\1/)
	s = str.index(/(.).\1/) + 1
	e = s + 2
else
	s = -1
	e = -1
end

STDOUT.print "#{s} #{e}\n"

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

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    for(int i=0; i<n; i++){
        ll a; cin >> a;
        ans += a-1;
    }
    cout << ans << endl;
    return 0;
}

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

vector<int> to[200005];
vector<int> ans;

/**
 * 深さ優先探索
 */
void dfs(int v, int p=-1) {
  for (int u : to[v]) {
    if (u == p) continue; // 親には行かない
    ans[u] += ans[v]; // 累積和を取る
    dfs(u,v);
  }
}

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

  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  ans.resize(n);
  rep(i, q) {
    int p, x;
    cin >> p >> x;
    --p;
    ans[p] += x; // ポイントの起点となる枝にポイントを加算する
  }
  // dfsで木の要素を回りながら累積和を取る
  dfs(0);

  rep(i, n) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 23424
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <iostream>
using namespace std;

const int NMAX = 3010;
int dp[3010][3010];


int main()
{
    string a, b, ans;
    cin >> a >> b;

    int n = a.size(), m = b.size();

    a = "%" + a, b = "$" + b;

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

    for (int i = n, j = m; min(i, j) >= 1; ) {
        if (a[i] == b[j] && dp[i][j] == 1 + dp[i - 1][j - 1]) {
            ans += a[i];
            i--, j--;
        }
        else if (dp[i - 1][j] >= dp[i][j - 1])
            i--;
        else
            j--;
    }

    reverse(ans.begin(), ans.end());

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 35584
#include <stdio.h>
int main(){
  int x,y,a,d;
  scanf("%d%d",&x,&y);
  if(x<y){
    a=x;
    x=y;
    y=a;
  }
  while((d=x%y)!=0){
    x=y;
    y=d;
  }
printf("%d\n",y);
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>

using namespace std;

using ull = unsigned long long;

int main()
{
    ull H, W;
    cin >> H >> W;

    ull ans = ULONG_LONG_MAX;
    vector<ull> areas(3);
    // full width
    for (ull h = 1; h <= H - 1; h++) {
        ull max_a, min_a;
        areas[0] = h * W;

        areas[1] = ((H - h) / 2) * W;
        areas[2] = ((H - h) - ((H - h) / 2)) * W;

        max_a = *max_element(areas.begin(), areas.end());
        min_a = *min_element(areas.begin(), areas.end());
        ans = min(ans, max_a - min_a);

        areas[1] = (H - h) * (W / 2);
        areas[2] = (H - h) * (W - (W / 2));

        max_a = *max_element(areas.begin(), areas.end());
        min_a = *min_element(areas.begin(), areas.end());
        ans = min(ans, max_a - min_a);
    }

    // full height
    for (ull w = 1; w <= W - 1; w++) {
        ull max_a, min_a;
        areas[0] = w * H;

        areas[1] = H * ((W - w) / 2);
        areas[2] = H * (W - w - ((W - w) / 2));

        max_a = *max_element(areas.begin(), areas.end());
        min_a = *min_element(areas.begin(), areas.end());
        ans = min(ans, max_a - min_a);

        areas[1] = (H / 2) * (W - w);
        areas[2] = (H - (H / 2)) * (W - w);

        max_a = *max_element(areas.begin(), areas.end());
        min_a = *min_element(areas.begin(), areas.end());
        ans = min(ans, max_a - min_a);
    }

    cout << ans << endl;
}


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();
        String s = sc.next();

        int count = 0;

        for (int i = 0; i < n; i++) {
            int index = s.indexOf("ABC");
            if (index > -1) {
                count++;
                s = s.substring(index + 3);
            } else {
                break;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 22740
//By Vlgd
#include<bits/stdc++.h>
#define M 1046527
#define ll long long
const int L=14,NUL=-1;
using namespace std;
char H[M][L];
int toint(char ch){
	if (ch=='A') return 1;
	else if (ch=='C') return 2;
	else if (ch=='G') return 3;
	else if (ch=='T') return 4;
	else return 0;
}
ll tokey(char str[]){
	ll sum=0,o=1;
	for(int i=0;i<strlen(str);i++){
		sum+=o*toint(str[i]);
		o*=6;
	}
	return sum;
}
int h1(int k){return k%M;}
int h2(int k){return 1+k%(M-1);}
int insert(char str[]){
	ll h,i,key=tokey(str);
	for(i=0;;i++){
		h=(h1(key)+i*h2(key))%M;
		if (strcmp(H[h],str)==0) return 1;
		else if (strlen(H[h])==0){
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
}
int find(char str[]){
	ll h,i,key=tokey(str);
	for(i=0;;i++){
		h=(h1(key)+i*h2(key))%M;
		if (strcmp(H[h],str)==0) return 1;
		else if (strlen(H[h])==0) return 0;
	}
	return 0;
}
int main(){
	int n;
	scanf("%d",&n);
	char ins[8],str[L];
	for (int i=0;i<n;i++){
		scanf("%s %s",ins,str);
		if (ins[0]=='f'){
			if (find(str)) printf("yes\n");
			else printf("no\n");
		}
		else insert(str);
	}
}



Measured memory_bytes: 17440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, M;
    cin >> N >> M;
    priority_queue<ll> pq;
    rep(i, N)
    {
        int a;
        cin >> a;
        pq.push(a);
    }
    rep(i, M)
    {
        pq.push(pq.top() / 2);
        pq.pop();
    }
    ll ans = 0;
    rep(i, N)
    {
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
#include<stdio.h>
int main(){
    int n, m;
  	int mn, mx;
    int le, ri;
    int c;
    scanf("%d %d",&n, &m);
    scanf("%d %d",&mn, &mx);
    for(int i=1;i<m;i++){
      scanf("%d %d",&le, &ri);
      if(le>=mn) mn=le;
      if(ri<=mx) mx=ri;
    }
    c=mx-mn+1;
    if(c<0) c=0;
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 128
n = int(input())
ab_ls = [[0,0] for _ in range(n)]
for i in range(n):
    a,b = map(int,input().split())
    ab_ls[i] = [a,b]
ab_ls.sort(reverse=True,key = lambda x:x[0]+x[1])
ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += ab_ls[i][0]
    else:
        ans -= ab_ls[i][1]
print(ans)


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            List<int> p = new List<int>();
            string[] input_str = Console.ReadLine().Split(' ');
            List<bool> isNotLine = new List<bool>();
            for (int i = 0; i < N; i++)
            {
                p.Add(int.Parse(input_str[i]));
                if (p[i] != (i + 1)) isNotLine.Add(true);
                else isNotLine.Add(false);
            }
            if (isNotLine.Count(val => val == true) > 2)
            {
                Console.WriteLine("NO");
            }
            else
            {
                Console.WriteLine("YES");
            }
//            Console.Read();
        }
    }
}

Measured memory_bytes: 13268
using System;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            var p = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
            Console.WriteLine(Math.Sqrt(Math.Pow(p[0] - p[2], 2) + Math.Pow(p[1] - p[3], 2)));
        }
    }
}

Measured memory_bytes: 5776
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int a[501][501];
vector<string> ans;
int main(){
    int h,w;
    cin>>h>>w;
    rep(i,h)rep(j,w) cin>>a[i][j];
    string t;
    rep(i,h){
        rep(j,w-1){
            if(a[i][j]&1){
                --a[i][j];
                ++a[i][j+1];
                t.clear();
                t+=to_string(i+1)+" "+to_string(j+1)+" "+to_string(i+1)+" "+to_string(j+2);
                ans.pb(t);
            }
        }
    }
    rep(i,h-1){
        if(a[i][w-1]&1){
            --a[i][w-1];
            ++a[i+1][w-1];
            t.clear();
            t+=to_string(i+1)+" "+to_string(w)+" "+to_string(i+2)+" "+to_string(w);
            ans.pb(t);
        }
    }
    cout<<ans.size()<<endl;
    for(auto it:ans) cout<<it<<endl;
    return 0;
}

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

#define INF INT_MAX
#define ll long long

using namespace std;

int main(){
	string s;
	cin >> s;
	vector<char> v;
	v.push_back(s[0]);
	int ans = 0;
	for(int i=1;i < s.size();i++){
		v.push_back(s[i]);
		// cout << v[v.size()-1] << " "  << v[v.size()-2]  << endl;
		if((v[v.size()-1] == '1' && v[v.size()-2] == '0')
			|| (v[v.size()-1] == '0' && v[v.size()-2] == '1')){
			v.pop_back();
			v.pop_back();
			ans++;
			ans++;
		}
	}
	cout << ans << endl;
}


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

int w[100];
int main()

{	
	int n,b=0,ss,t,s1,s,min=9999;
	cin >> n;
	for (int i=0;i<n;i++)
		cin >>w[i];
		
	for (int t=0;t<n;t++)
	{
		s=s1=0;
		
		for(int j=0;j<=t;j++)
			s=s+w[j];
		for(int k=t+1;k<n;k++)
			s1=s1+w[k];
		
		ss=abs(s-s1);
		
		if (ss<min)
		min=ss;
	}
	
	cout << min;
}


Measured memory_bytes: 256
#import<cstdio>
#define r(a) for(int i=0;i<a;i++)
#define s (scanf("%d",&w),w);
#define c(a,b) a=a<b?a:b
int w,n,m,d[999],p[999];main(){n=s m=s r(n)d[i]=s r(n)p[i]=1e9;r(m){s r(n)c(p[i],p[i+1]+w*d[n-i-1]);}printf("%d\n",*p);}

Measured memory_bytes: 1032
/*
	In the name of Allah.
*/
 
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define gap ' '
#define INF 999999
 
const int MAXN = 2 * 1e5 + 5;
 
 
int main(){
	int x, y; cin >> x >> y;
	if(y >= 2 * x and y <= 4 *x and y % 2 == 0){
		cout << "Yes" << endl; 
	}
	else{
		cout << "No" << endl; 
	}


 
    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(long i=1; i<=(long)(n); i++)
int main(){
long N, ans=0; cin >> N; 
REP(i, N){ ans+=(i*(N/i)*(1+N/i))/2; }
cout << ans << "\n";
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

long long d[100][100];

int main()
{
	fill(d[0], d[101], LLONG_MAX / 4);

	int N, M;
	cin >> N >> M;
	vector<pair<int, long long>> g[100];
	for (auto i = 0; i < M; ++i)
	{
		int a, b;
		long long c;
		cin >> a >> b >> c;
		g[a - 1].push_back(make_pair(b - 1, c));
		g[b - 1].push_back(make_pair(a - 1, c));
		d[a - 1][b - 1] = c;
		d[b - 1][a - 1] = c;
	}

	for (auto i = 0; i < N; ++i)
	{
		d[i][i] = 0;
	}

	for (auto k = 0; k < N; ++k)
	{
		for (auto i = 0; i < N; ++i)
		{
			for (auto j = 0; j < N; ++j)
			{
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}

	auto count = 0;
	for (auto i = 0; i < N; ++i)
	{
		for (auto p : g[i])
		{
			if (p.first < i)
			{
				continue;
			}
			if (d[i][p.first] < p.second)
			{
				++count;
			}
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 384
N = int(input())
s = []
ans = 0
numa = 0
numb = 0
numab = 0
for _ in range(N):
    s = input()
    num = 0
    for x,y in zip(s, s[1:]):
        if x == 'A' and y == 'B' :
            num += 1
    ans += num
    if s[0] == 'B' and s[-1] == 'A':
        numab += 1
    elif s[0] == 'B':
        numb += 1
    elif s[-1] == 'A':
        numa += 1
if numab == 0:
    print(ans + min(numa, numb))
else:
    if numa == 0 and numb == 0:
        print(ans + (numab-1))
    elif numa == 0:
        if numb == 0:
            print(ans + (numab-1))
        else:
            print(ans + (numab-1) + 1)
    elif numb == 0:
        if numa != 0:
            print(ans + (numab-1) + 1)
    else:
        print(ans + (numab-1) + 2 + min(numa-1,numb-1))

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
int a,b,c,i,j,k,n,m=0;
int coin;
scanf("%d%d%d%d",&a,&b,&c,&n);
for(i=0;i<a+1;i++){
for(j=0;j<b+1;j++){
for(k=0;k<c+1;k++){
coin = 500*i+100*j+50*k;
if(n==coin)m++;
//printf("%d",coin);
}}}
printf("%d",m);
return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <array>
#include <set>
#include <climits>
#include <cassert>
#include <bitset>
using namespace std;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    long long n, k;cin>>n>>k;
    vector<long long>v(n);
    for(auto &itr:v){
        cin>>itr;
    }
    sort(v.begin(),v.end(),greater<int>());
    long long  sum = 0;
    for(int i=k;i<n;++i){
        sum+=v[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s; cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  if(s.at(0)==s.at(1) && s.at(0)==s.at(2) && s.at(1)==s.at(2)){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}


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

using namespace std;

#define INF 2100000000
#define int long long

signed main(){
    int n;
    cin >> n;
    float sum = 0;
    for(int i=0;i<n;i++){
        float tmp;
        cin >> tmp;
        sum = sum + (float)(1 / tmp);
    }
    cout << (float)1 / sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

#define INF (1 << 28)

using namespace std;

int cost[200][200], dist[200][200];

int main(){
	
	int n, m;
	
	while(true){
		
		cin >> n >> m;
		
		if(n == 0 && m == 0){
			break;
		}
		
		for(int i = 0; i <= m; i++){
			for(int j = 0; j <= m; j++){
				cost[i][j] = INF;
				cost[j][i] = INF;
				dist[i][j] = INF;
				dist[j][i] = INF;
			}
		}
		for(int i = 0; i <= m; i++){
			cost[i][i] = 0;
			dist[i][i] = 0;
		}
		
		for(int i = 0; i < n; i++){
			int a, b, c, t;
			cin >> a >> b >> c >> t;
			cost[a][b] = c;
			cost[b][a] = c;
			dist[a][b] = t;
			dist[b][a] = t;
		}
		
		for(int i = 0; i <= m; i++){
			for(int j = 0; j <= m; j++){
				for(int k = 0; k <= m; k++){
					cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
					dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
				}
			}
		}
		
		int k;
		
		cin >> k;
		
		for(int loop = 0; loop < k; loop++){
			int p, q, r;
			cin >> p >> q >> r;
			if(r == 0){
				cout << cost[p][q] << endl;
			}else{
				cout << dist[p][q] << endl;
			}
		}
		
	}
	
	return 0;
}

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

signed main() {
#ifdef LOCAL
  assert(freopen("a.in", "r", stdin));
#endif
  ll k, a, b;
  cin >> k >> a >> b;
  if (a >= k) {
    cout << 1 << '\n';
    return 0;
  }
  if (b >= a) {
    cout << -1 << '\n';
    return 0;
  }
  k -= a;
  ll d = a - b;
  cout << 1 + 2 * ((k + d - 1) / d) << '\n';
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func rcvStr() string {
	sc.Scan()
	return sc.Text()
}

func rcvInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	h, w := rcvInt(), rcvInt()
	row := make([]bool, h)
	cal := make([]bool, w)

	a := make([]string, h)
	for i := 0; i < h; i++ {
		a[i] = rcvStr()
		for j, v := range a[i] {
			if v == '#' {
				row[i] = true
				cal[j] = true
			}
		}
	}

	for i, v := range row {
		if !v {
			continue
		}
		for j, w := range cal {
			if w {
				fmt.Print(string(a[i][j]))
			}
		}
		fmt.Print("\n")
	}
}

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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

string arr[513];

void bin(void){
    arr[0]="000000000";
    for(int i=1;i<512;i++){
        int j=i;
        string b="";
        while(j>0){
            if((j&1)==0){
                b+="0";
            }
            else{
                b+="1";
            }
            j>>=1;
        }
        while(b.length()<9){
            b+="0";
        }
        arr[i]=b;
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    bin();
    int n=s.length()-1;
    ll ans=0;
    for(int i=0;i<(1<<n);i++){
        string k=arr[i];
        string x="";
        x+=s[0];
        for(int j=0;j<n;j++){
            if(k[j]=='1'){
                x+="+";
            }
            x+=s[j+1];
        }
        x+="+";
        ll a=0;
        for(int i=0;i<x.length();i++){
            if(x[i]!='+'){
                a*=10;
                int k=x[i]-'0';
                a+=k;
            }
            else{
                ans+=a;
                a=0;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main()
{
    int x,n,e,lf,rt,cnd=0,i,anl,anr;
    scanf("%d%d",&x,&n);
    set<int> st;
    for(i=0;i<n;i++){
        scanf("%d",&e);
        st.insert(e);
    }
    i=x;
    while(1){
        if(st.count(i)==0){
            cnd=1;rt=abs(x-i);anr=i;
            break;
        }
        else i++;
    }
    i=x-1;
    while(1){
        if(st.count(i)==0){
            cnd=2;lf=abs(x-i);anl=i;
            break;
        }
        else i--;
    }
    if(lf<=rt) printf("%d\n",anl);
    else printf("%d\n",anr);

}


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


int main(){

    string S;
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        if((i % 2 == 0 && S.at(i) == 'L') || (i % 2 == 1 && S.at(i) == 'R')){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 384
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

x, y = map(int,input().split())

a =    2 * x -  y 
b =   - x + 2 * y 

ans = 0
if a % 3 == 0 and b % 3 == 0:
    a = a//3
    b = b//3
    ans = cmb(a+b, a, mod)
print(ans)

Measured memory_bytes: 128864
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_168_Therefore
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());
            long a = n % 10;
            string result;
            if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9)
            {
                result = "hon";
            }
            else if (a == 0 || a == 1 || a == 6 || a == 8)
            {
                result = "pon";
            }
            else
            {
                result = "bon";
            }
            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27488
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using ll = long long;


int main() {
	ll n;
	cin >> n;
	ll C[10][10];
	rep(i, 10) {
		rep(j, 10) C[i][j] = 0;
	}

	for (int i=1; i<=n; i++) {
		string s = to_string(i);
		int c2 = s.back() - '0';
		int c1 = s[0] - '0';
		C[c1][c2]++;
	}
	ll res = 0;
	rep(i, 10) {
		rep(j, 10) {
			res += C[i][j]*C[j][i];
		}
	}
	cout << res << endl;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;

const int maxn = 105;
const double pi = acos(-1);

int n;

struct P{
    ll x, y;
    P(){}
    P(ll _x, ll _y):x(_x), y(_y){}
    P operator + (P p){return P(x + p.x, y + p.y);}
    P operator - (P p){return P(x - p.x, y - p.y);}
    ll det(P p){return x * p.y - y * p.x;}
    ll dot(P p){return x * p.x + y * p.y;}
    ll abs2(){return x * x + y * y;}
    double abs(){return sqrt(abs2());}
    void read(){cin >> x >> y;}
}p[maxn];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 1;i <= n;i++){
        p[i].read();
    }
    cout << fixed << setprecision(10) << endl;
    for(int i = 1;i <= n;i++){
        bool ok = false;
        for(int j = 1;j <= n;j++){
            if(j == i)
                continue;
            bool flag = true;
            double mi = 1.0;
            for(int k = 1;k <= n;k++){
                if(k == i or k == j)
                    continue;
                P v1 = p[j] - p[i];
                P v2 = p[k] - p[i];
                if(v1.det(v2) < 0)
                    flag = false;
                mi = min(mi, v1.dot(v2) / v1.abs() / v2.abs());
            }
            if(flag){
                mi = max(-1.0, mi);
                double angle = (pi - acos(mi)) / (2 * pi);
                ok = true;
                cout << angle << endl;
                break;
            }
        }
        if(!ok){
            cout << 0 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 384
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)


n, m, q = map(int, input().split())
a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q
for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1

ans = 0
p = [0] * n
def dfs(id):
    global ans
    if id < n:
        for i in range(p[id-1], m + 1):
            p[id] = i
            dfs(id + 1)
    else:
        tmp = 0
        for i in range(q):
            if p[b[i]] - p[a[i]] == c[i]:
                tmp += d[i]
        ans = max(ans, tmp)

for i in range(1, m + 1):
    p[0] = i
    dfs(1)
print(ans)

Measured memory_bytes: 9260
#include<stdio.h>
int main(){
  int n,m,i,j;
  scanf("%d%d",&n,&m);
  int a[m+3];
  long long num[n+3];
  for(i=0;i<m;i++)
    scanf("%d",&a[i]);
  num[0]=1;
  a[m]=n+1;
  j=0;
  for(i=1;i<=n;i++){
    if(a[j]==i){
      num[i]=0;
      j++;
    }
    else if(i==1)
      num[i]=1;
    else{
      num[i]=num[i-1]+num[i-2];
      num[i]%=1000000007;
    }
  }
  printf("%lld\n",num[n]);
  return 0;
}


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

using namespace std;

int main(){
    int n;
    string s;
    int ans=0;
    cin >> n >> s;
    
    for(int i=0;i<n;i++){
        int cnt=0;
        for(char c='a';c<='z';c++){
            bool left=false,right=false;
            
            for(int j=0;j<i;j++){
                if(s[j]==c) left=true;
            }
            for(int j=i;j<n;j++){
                if(s[j]==c) right=true;
            }

            if(left&&right){
                cnt++;
            }
        }

        if(ans<cnt){
            ans=cnt;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{
    int n, x;
    scn(n); scn(x);

    vi a(n);

    rep(i, 0, n)
    scn(a[i]);

    ll moves = 0;

    rep(i, 0, n) {
        int k = max(0, a[i] + a[i-1] - x);
        moves += k;
        a[i] -= k;
    }

    lprin(moves);
}

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll a, b, c, k; cin >> a >> b >> c >> k;
	
	ll ans = 0;
	ans += min(a, k);
	k -= min(a, k);
	k -= min(b, k);
	ans += -min(c, k);
	print(ans)
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/01/06  Problem: EDU_DP X / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	LL N; cin >> N;
	using tp = tuple<LL, LL, LL, LL>;
	vector<tp>a(N);
	FOR(i, 0, N) {
		LL w, s, v; cin >> w >> s >> v;
		a[i] = tp(w + s, w, s, v);
	}
	SORT(a);
	VVL dp(N + 1, VL(20004, 0));
	FOR(i, 0, N) {
		LL w, s, v;
		tie(ignore, w, s, v) = a[i];
		FOR(ww, 0, 20004) {
			if (ww <= s && ww + w < 20004)
				dp[i + 1][ww + w] = max(dp[i + 1][ww + w], dp[i][ww] + v);
			dp[i + 1][ww] = max(dp[i + 1][ww], dp[i][ww]);
		}
	}
	FOR(i, 0, 20004) {
		ans = max(ans, dp[N][i]);
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 162528
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <cstdio>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
string ans = "URDL";
bool f[5][5][5];

int main() {

    memset(f,0,sizeof(f));

    rep(i,9) {
        int y = i/2;
    
        if(i%2 == 0) {
            string t;
            cin >> t;
    
            rep(j,4) {
                if(t[j] == '1') {
                    f[y][j][1] = true;
                    f[y][j+1][3] = true;
                }
            }
        } else {
            string t;
            cin >> t;
    
            rep(j,5) {
                if(t[j] == '1') {
                    f[y+1][j][0] = true;
                    f[y][j][2] = true;
                }
            }
        }
    }

    int dy[4] = {-1,0,1,0};
    int dx[4] = {0,1,0,-1};
    string ans = "URDL";
    int y = 0, x = 0, dir = 1;

    do {
        if(f[y][x][(dir+3)%4]) {
            dir = (dir+3)%4;
        } else if(f[y][x][dir]) {

        } else if(f[y][x][(dir+1)%4]) {
            dir = (dir+1)%4;
        } else if(f[y][x][(dir+2)%4]) {
            dir = (dir+2)%4;
        }


        y += dy[dir];
        x += dx[dir];
        cout << ans[dir];
    } while(y != 0 || x != 0);
    cout << endl;

    return 0;
}

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

#define PI 3.14159265358979323

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

	printf("%.5f %.5f", r * r * PI, 2 * r * PI);
	return 0;
}

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

vector<vector<int>> T;
vector<long> v;

void in(long k) {
	if (k == -1)
		return;
	else {
		in(T[k][0]);
		cout << " " << v[k];
		in(T[k][1]);
		return;
	}
}

void pre(long k) {
	if (k == -1)
		return;
	else {
		cout << " " << v[k];
		pre(T[k][0]);
		pre(T[k][1]);
		return;
	}
}

int main()
{
	string s;
	long n = 0, t = 0;

	cin >> n;

	T.assign(n, { -1, -1});
	v.assign(n, -2000000001);

	for (long i = 0; i < n; i++) {
		cin >> s;

		if (s == "insert") {
			cin >> v[t];

			long y = -1, x = 0;

			while (x != -1) {
				int m = 1;
				y = x;
				if (v[t] < v[x])
					m = 0;
				x = T[x][m];
			}

			int s = 1;

			if (i > 0 && y != -1){
				if (v[t] < v[y])
					s = 0;
				T[y][s] = t;
			}
			t++;
		}
		else if (s == "print") {
			in(0);
			cout << endl;
			pre(0);
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 33832
d={t:0for t in'MARCH'};a=0
for t in open(0).read().split():
 if t[0]in d:d[t[0]]+=1
for i in range(32):
 c=t=1
 for j,l in enumerate(d.values()):
  if i>>j&1:t*=l;c+=1
 a+=t*(c==4)
print(a)

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

using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)

vector<int>a[50505];
int N[50505];
double ave[50505];
int main() {
	int cnt = 0;
	REP(i, 100010) {
		cin >> N[i];
		if (N[i] == 0)break;
		cnt++;
		ave[i] = 0;
		REP(j, N[i]) {
			int x; cin >> x;
			a[i].push_back(x);
			ave[i] += x;
		}
	}
	//cout << cnt << endl;
	REP(i, cnt) {
		ave[i] /= N[i];
		int ans = 0;
		REP(j, N[i]) {
			if (a[i][j] <= ave[i]) {
				ans++;
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 4460
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  }
}

struct Scanner<R: BufRead> {
  reader: R,
  iter: std::vec::IntoIter<String>
}

#[allow(dead_code)]
impl<R: BufRead> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader, iter: vec![String::new()].into_iter() }
  }
  fn new_line(&mut self) {
    let mut line = String::new();
    self.reader.read_line(&mut line).ok();
    self.iter = line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>().into_iter();
  }
  fn get<T: FromStr>(&mut self) -> T {
    self.iter.next().unwrap().parse().ok().unwrap()
  }
  fn get_line(&mut self) -> String {
    let mut line = String::new();
    self.reader.read_line(&mut line).ok();
    line.trim().to_string()
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  let mut s = sc.get_line();
  sc.new_line();
  let q = scan!(sc; i32);
  for _ in 0..q {
    sc.new_line();
    match &sc.get::<String>()[..] {
      "print" => {
        let (a, b) = scan!(sc; usize, usize);
        println!("{}", &s[a..b + 1]);
      },
      "reverse" => {
        let (a, b) = scan!(sc; usize, usize);
        let s_ = s.clone();
        let s0 = &s_[0..a];
        let s1 = &s_[b + 1..];
        let s_: String = (&s_[a..b + 1]).chars().rev().collect();
        s = format!("{}{}{}", s0, s_, s1);
      },
      "replace" => {
        let (a, b, p) = scan!(sc; usize, usize, String);
        let s_ = s.clone();
        let s0 = &s_[0..a];
        let s1 = &s_[b + 1..];
        s = format!("{}{}{}", s0, p, s1);
      },
      _ => {}
    };
  }
}



Measured memory_bytes: 5032
icase=0
if icase==0:
    n,x=map(int,input().split())
    m=[0]*n
    for i in range(n):
        m[i]=int(input())
    m.sort()
    m0=m[0]
    msum=sum(m)
    print((x-msum)//m0+n)  

Measured memory_bytes: 3060
n,y = map(int,input().split())
 
price = 0
ok = 0
 
for i in range(n+1):
    for j in range(n+1-i):
            k = n - i - j
            if k < 0:
                k = 0
 
            price = 10000 * i + 5000 * j + 1000 * k   
            
            if price == y and i+j+k == n and ok == 0:
                print(i, j, k)
                ok = 1
                break
 
    else:
        continue
    break
 
if ok == 0:
    print(-1, -1, -1 )

Measured memory_bytes: 3064
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for ai in range(a + 1):
    for bi in range(b + 1):
        for ci in range(c + 1):
            if x == 500 * ai + 100 * bi + 50 *ci:
                count += 1
print(count)

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

typedef long long ll;
#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

#define P pair<int, int >


const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;



//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

bool firstCompare(const P& firstElof, const P& secondElof){
    return firstElof.first < secondElof.first;
}
bool secondCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}
//---------------//

struct Node{
    ll parent;
    vector<ll> children;
    ll count;
};
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll N, Q;
    cin >> N >> Q;
    vector<ll> a(N - 1), b(N - 1), p(Q), x(Q);
    LREP(i, 0, N - 1) cin >> a[i] >> b[i];
    LREP(i, 0, Q) cin >> p[i] >> x[i];

    Node T[N + 1];
    LREP(i, 1, N + 1){
        T[i].count = 0;
        T[i].parent = -1;
    } 
    LREP(i, 0, N - 1){
        T[a[i]].children.push_back(b[i]);
        T[b[i]].parent = a[i];
    }
    LREP(i, 0, Q){
        T[p[i]].count += x[i];
    }
    /*
    LREP(i, 0, Q){
        queue<ll> q;
        ll root;
        q.push(p[i]);
        while(!q.empty()){
            root = q.front();
            q.pop();
            T[root].count += x[i];
            LREP(j, 0, T[root].children.size()){
                q.push(T[root].children[j]);
            }
        }
    }
    */
    queue<ll> q;
    q.push(1);
    while(!q.empty()){
        ll root = q.front();
        if (T[root].parent > 0){
            T[root].count += T[T[root].parent].count;
        }
        q.pop();
        LREP(i, 0, T[root].children.size()){
            q.push(T[root].children[i]);
        }
    }
    LREP(i, 1, N + 1){
        cout << T[i].count << ' ';
    }
    cout << '\n';
}


Measured memory_bytes: 22784
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,M;
LL ans=0;
LL MOD=1e9+7;
LL C[500010];
void init(){
	C[0]=1;
	C[1]=1;
	REP(i,500010){
		if(i==0)continue;
		C[i]=C[i-1]*i;
		C[i]%=MOD;
	}
}

LL reverse(LL x){
	LL now=MOD-2;
	LL ans=1;
	LL temp=x;
	while(now!=0){
		if(now%2==1){
			ans*=temp;
			ans%=MOD;
		}
		temp*=temp;
		temp%=MOD;
		now/=2;
	}
	return ans;
}

LL W[500010];

int main(){
	init();
	cin>>N>>M;
	W[0]=1;
	W[1]=M-N;
	for(int i=2;i<N+1;i++){
		LL a=W[i-1]*(i-1);
		LL b=W[i-1]*(M-N);
		LL c=0;
		c=W[i-2]*(i-1);
		a%=MOD;
		b%=MOD;
		c%=MOD;
		W[i]=a+b+c;
		W[i]%=MOD;
	}
	/*REP(i,N+1){
		cout<<W[i]<<endl;
	}*/
	LL ans=W[N];
	ans*=C[M];
	ans%=MOD;
	//ans*=reverse(C[N]);
	ans%=MOD;
	ans*=reverse(C[M-N]);
	ans%=MOD;
	
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int long long n,k;
  cin>>n>>k;
   int long long a;
  a = n%k ;
   int long long b;
  b = k-a ;
  if(a<=b){
    cout <<a<<endl;
  }
  else{cout <<b<<endl;}
}
  


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

int main()
{

    string s;
    cin >> s;
    string s1="";
    for(int i =0;i<s.length();++i)
    {
        if(s[i] == 'B' &&  s1.length()>=1 ){
           s1.erase(s1.length()-1);
       }
        else if(s[i] != 'B'){
                s1 = s1 + s[i];

        }

    }
    cout << s1;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        List<Character> ss = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            ss.add(s.charAt(i));
        }

        if (ss.contains('a') && ss.contains('b') && ss.contains('c')) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}




Measured memory_bytes: 23764
//
//  main.cpp
//  A - Two Coins
//
//  Created by 谢威宇 on 2018/3/17.
//  Copyright © 2018年 Ervin's Studio. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
using namespace std;
int main(){
	map<string, long long int> M; 
	map<string, bool> checked;  
	int N; cin >> N; 
	string S[100010] = {}; 
	for(int i = 0; i < N; i++){
		string s; cin >> s; 
		sort(s.begin(), s.end()); 
		M[s] ++; 
		S[i] = s; 
	}
	long long int ans = 0; 
	for(int i = 0; i < N; i++){
		if(!checked[S[i]]){
			ans += M[S[i]] * (M[S[i]] - 1) / 2;
			checked[S[i]] = true;  
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 22940
<?php
fscanf(STDIN, "%d%d", $n, $m);

$mount = explode(" ", trim(fgets(STDIN)));
$not_list = array_fill(0,$n,0);

while($m--){
    $tmp = fscanf(STDIN, "%d%d", $a, $b);
    if($mount[$a-1] > $mount[$b-1]){
        if(isset($not_list[$b-1])){
            unset($not_list[$b-1]);
        }
    }elseif($mount[$b-1] > $mount[$a-1]){
        if(isset($not_list[$a-1])){
            unset($not_list[$a-1]);
        }
    }else{
        if(isset($not_list[$a-1])){
            unset($not_list[$a-1]);
        }
        if(isset($not_list[$b-1])){
            unset($not_list[$b-1]);
        }
    }

}
echo count($not_list);

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

void solve(std::string S)
{
    int y = stoi(S.substr(0, 4));
    int m = stoi(S.substr(5, 2));
    int d = stoi(S.substr(8, 2));

    if (y < 2019)
    {
        cout << "Heisei" << endl;
    }
    else if (y == 2019 && m < 4)
    {
        cout << "Heisei" << endl;
    }
    else if (y == 2019 && m == 4 && d <= 30)
    {
        cout << "Heisei" << endl;
    }
    else
    {
        cout << "TBD" << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int main(){
    int N; cin >> N;
    int s[N];
    int sum=0;
    for(int i=0;i<N;i++){
        cin >> s[i];
        sum+=s[i];
    }
    sort(s,s+N);
    if(sum%10!=0){
        cout << sum << endl;
        return 0;
    }
    for(int i=0;i<N;i++){
        if((sum-s[i])%10!=0){
            cout << sum-s[i] << endl;
            return 0;
        }
    }
    cout << 0 << endl;

}

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

void a_round_up_the_mean(void){
	int a, b;
	cin >> a >> b;
	int x = (a + b + 1) >> 1;
	cout << x << endl;
}

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

Measured memory_bytes: 3608