akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n;
int main(void) {
	while (1) {
		int ans = 0;
		cin >> n;
		if (n == 0) break;
		for(int i = 1;i <= n;i++){
		    int sum = i,j = i+1;
		    while(1){
		        sum += j;
		        j++;
		        if(sum == n){
		            ans++;
		            break;
		        }else if(sum > n){
		            break;
		        }
		    }
		}
		cout << ans << endl;
	}
	return 0;
}


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

int main(void){
    int m, k;
    cin >> m >> k;
    int n = 1 << m;
    if (k >= n || (m == 1 && k == 1)) {
        cout << -1 << endl;
        return 0;
    }
    vector<int> v;
    if (m <= 1) {
        rep(i,m+1){
            v.push_back(i);
            v.push_back(i);
        }
    } else {
        v.push_back(k);
        rep(i,n){
            if (i == k) continue;
            v.push_back(i);
        }
        v.push_back(k);
        rep(i,n){
            int j = n-1-i;
            if (j == k) continue;
            v.push_back(j);
        }
    }
    rep(i,n*2){
        cout << v[i] << (i < n*2-1 ? " " : "\n");
    }
    return 0;
}


Measured memory_bytes: 2932
from sys import stdin, stdout
import numpy as np
def readLine_int_list():return list(map(int, stdin.readline().split()))



def main():
    n, x = readLine_int_list()

    _a = readLine_int_list()
    a = _a.copy()
    
    for i in range(n-1):
        if a[i] + a[i+1] > x:
            
            if a[i] > x:
                a[i] = x
            
            if x - a[i] >= 0:
                if a[i] == 0:
                    a[i+1] = x
                elif a[i] > 0:
                    a[i+1] = x-a[i]
    print(np.sum(np.array(_a) - np.array(a)))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 23104
%:pragma GCC optimize(3)
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#include <cmath>
#include <ctime>
#include <algorithm>
using namespace std;
typedef long long LL;
const int INF=1e9+7,N=1000010;

void Read(int &x){
	x=0; char ch;
	for (ch=getchar();ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';x=x*10+ch-'0',ch=getchar());
}

int n;
int Die[N],vis[N],A[N];

struct XY{int A,id;}p[N];
bool cmp(XY a,XY b){
	return a.A < b.A;
}
vector<int> G[N];
void Add(int a,int b){
	return G[a].push_back(b);
}


int main(){
	Read(n);
	for (int i=1;i<=n;++i) Read(A[i]),p[i]=(XY){A[i],i};
	for (int i=1,x,y;i<n;++i) Read(x),Read(y),Add(x,y),Add(y,x);
	sort(p+1,p+1+n,cmp);
	
	for (int i=1;i<=n;++i) if (!vis[p[i].id]){
		int x=p[i].id,a=p[i].A;
		int flag=1; vis[x]=1;
		for (int j=0;j<(int)G[x].size();++j){
			int v=G[x][j];
			if (A[v] < a && Die[v]) flag=0;
		}
		if (flag){
			Die[x]=1;
			for (int j=0;j<(int)G[x].size();++j){
				int v=G[x][j];
				if (A[v] > a) vis[v]=1,Die[v]=0;
			}
		}else Die[x]=0;
	}
	for (int i=1;i<=n;++i) if (!Die[i]) printf("%d ",i);
	
	fclose(stdin); fclose(stdout);
	return 0;
}


Measured memory_bytes: 31104
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stack>
using namespace std;
int main()
{
    int r,g,b;
    while(cin>>r>>g>>b)
    {
        int s=r*100+g*10+b;
        if(s%4==0)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


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

const int mx = 2e5+5;

int dist[mx];
int n, m, vis[mx];
vector<int> g[mx], tp;

void dfs(int u){
    vis[u] = 1;
    for(int v : g[u])
        if(!vis[v])
            dfs(v);
    tp.push_back(u);
}

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

    cin >> n >> m;
    while(m--){
        int u, v; cin >> u >> v;
        g[u].push_back(v);
    }

    for(int i=1; i<=n; i++){
        dist[i] = 1;
        if(!vis[i]) dfs(i);
    }

    reverse(tp.begin(), tp.end());
    for(int u : tp)
        for(int v : g[u])
            dist[v] = max(dist[v], 1+dist[u]);
    cout << *max_element(dist, dist+n+1)-1 << "\n";

    return 0;
}



Measured memory_bytes: 14480
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i, n) for(i=0; i<n; i++)
#define pb push_back
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int>bricks;
    int i, count = 0, index = 1;
    rep(i, n){
        int x;
        cin >> x;
        bricks.pb(x);
    }
    rep(i, n){
        if(bricks[i]==index){
            index++;
        }
        else{
            count++;
        }
    }
    if(count==n) cout << "-1\n";
    else cout << count << endl;
    return 0;
}

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

namespace AtCoder_Cs
{
    class Program
    {
        public static void Main()
        {
            int[] N = Console.ReadLine().Trim().Split(' ').Select(s => int.Parse(s)).ToArray();
            Array.Sort(N);
            Console.WriteLine($"{N[0]+N[1]}");


        }
    }
}


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

int main (){
	long long l,r,i,j,ans=2019;
	cin >> l >> r;
	if(r-l>=2018){
		cout << "0" << endl;
	} else {
		l=l%2019;
		r=r%2019;
		if(l>r){
			cout << "0" << endl;
		} else {
			for(i=l;i<r;i++){
				for(j=i+1;j<=r;j++){
					ans=min(ans,i*j%2019);
				}
			}
			cout << ans << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 99999999

int main(){
    string s;
    int n=0;
    vector<string> x;
    while(getline(cin,s)){
        n++;
        x.pb(s);
    }
    int data[110][110]={};
    rep(i,110)rep(j,110)data[i][j]=-INF;
    rep(i,n){
        int c=0;
        string buf="";
        rep(j,x[i].size()){
            if(x[i][j]!=','){
                buf+=x[i][j];
            }
            else{
                data[i][c]=stoi(buf);
                c++;
                buf="";
            }
        }
        data[i][c]=stoi(buf);
    }

    int l=(n+1)/2;
    int dp[110][110];
    rep(i,110)rep(j,110)dp[i][j]=-INF;
    dp[0][0]=data[0][0];
    for(int i=1;i<n;i++){
        for(int j=0;j<l-abs(l-1-i);j++){
            if(i<l)dp[i][j]=max((j-1>=0)*dp[i-1][j-1],dp[i-1][j])+data[i][j];
            if(i>=l)dp[i][j]=max(dp[i-1][j],dp[i-1][j+1])+data[i][j];
        }
    }
    cout<<dp[n-1][0]<<endl;
}

Measured memory_bytes: 1316
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long int x;
    cin >> x;

    long long int ans, d, r;

    d = x / 11;
    r = x % 11;
    if(r == 0) ans = d * 2;
    else if(r <= 6) ans = d * 2 + 1;
    else ans = d * 2 + 2;
    cout << ans << endl;
}

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

int main() {
    int A, B;
    char op;
    cin >> A >> op >> B;

    if (op == '+') {
        cout << A + B << endl;
    } else if (op == '-') {
        cout << A - B << endl;
    }

    return 0;
}

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

using namespace std;

int main()
{
 
    int a,b;
  scanf("%d%d",&a,&b);
  if(a+b==15)
     printf("+");
  
  else if(a*b==15)
      printf("*");
  
  else
     printf("x");
       
  
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a,i;
    long long int sum=0;

    scanf("%d",&a);
    for(i=1;i<=a;i++)
    {
        if((i%3==0)|| (i%5==0))
        {
            sum=sum+0;
        }
        else
        {
            sum=sum+i;
        }
    }

    printf("%lld\n",sum);

    return 0;
}


Measured memory_bytes: 1728
#include <iostream>
using namespace std;
int main(){
	int a,b,c,d=0,cou=1;
	cin>>a>>b;
	for(int i=0;i<a;i++){
		cin>>c;
		d+=c;
		if (b>=d) cou++;
	}
	cout<<cou<<endl;

	return 0;
}

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

namespace ABC140C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            int[] B = ReadInt();

            int[] A = new int[N];
            A[0] = B[0];A[N - 1] = B[N - 2];
            for (int i = 0; i < N - 2; i++)
            {
                A[i + 1] = Math.Min(B[i], B[i + 1]);
            }

            Console.WriteLine(A.Sum());
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 13396
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<math.h>
using namespace std;

int main() {
  
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double hi = 6 * m - (30 * h + 0.5 * m);
  cout << fixed << setprecision(10)<< sqrt(a*a + b*b - 2*a*b*cos(hi*(M_PI / 180)))<< endl;
  }

Measured memory_bytes: 4116
#include<bits/stdc++.h>
using ll = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	int N;
	cin >> N;


	string sna = "";

	if (N == 0)sna = '0';
	if (N == 1)sna = '1';

	while (N != 0 && N != 1) {

		if (N < 0) {
			sna += to_string( (int) (N - ceil((double)N / -2) * (-2) )  ); //N-商*（−２）==余り
			N = ceil((double)N / -2);
		}

		else {
			sna += to_string((int)( N - (N / -2) * (-2) ));
			N = (N / -2);
		}

		if (N == 1)sna += '1';
	}

	reverse(ALL(sna));

	cout << sna << endl;

	return 0;
}


Measured memory_bytes: 3728
S = input()

ans1 = 0
for i in range(len(S)):
	if i%2==0:
		if S[i:i+1]=='1':
			ans1 += 1
	else:
		if S[i:i+1]=='0':
			ans1 += 1
ans2 = 0
for i in range(len(S)):
	if i%2==0:
		if S[i:i+1]=='0':
			ans2 += 1
	else:
		if S[i:i+1]=='1':
			ans2 += 1

print(min([ans1, ans2]))

Measured memory_bytes: 3188
#include<stdio.h>

int main(){

  int i,j,card[50],x[50],n,r,p,c;

  while(scanf("%d%d",&n,&r),n){

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



    for(i=0;i<r;i++){

      scanf("%d%d",&p,&c);

      for(j=0;j<c;j++){
        x[j] = card[p+j];
      }

      for(j=0;j<p-1;j++){
        card[p+(c-1)-j] = card[p-1-j];
      }

      for(j=0;j<c;j++){
        card[j+1] = x[j];
      }

    }

    printf("%d\n",card[1]);
  }

  return 0;

}

Measured memory_bytes: 600
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
 
 
 
int main()
{
	int i, N;
 
	scanf("%d", &N);
 
	int a[11];
	int t[11];
 
	for (i = 0; i < N; i++) scanf("%d", &a[i]);
 
	for (i = 0; i < N; i++) {
		if (a[i] % 2 == 0) {
			t[i] = 2;
		}
		else t[i] = 1;
	}
 
	int seki=1;
 
	for (i = 0; i < N; i++) {
		seki*= t[i];
	}
 
	int p=1;
 
	for (i = 0; i < N; i++) {
		p *= 3;
	}
 
 
	printf("%d", p - seki);
}
 
 
 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e9+7;
const ll N = 100002;
string s;

int main(){
	string s;
	cin>>s;
	bool ok=false;
	FOR(i,0,16){
		ll j=i;
		string a="";
		if(j%2==1)a+="A";
		j/=2;
		a+="KIH";
		if(j%2==1)a+="A";
		j/=2;
		a+="B";
		if(j%2==1)a+="A";
		j/=2;
		a+="R";
		if(j%2==1)a+="A";
		if(s==a){
			ok=true;
		}
	}
	if(ok){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    string s; cin >> s;
    cout << (s == "ABC" ? "ARC" : "ABC") << endl;
    return 0;
}


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

int main()
{
  int ab, bc, ca;
  int res=0;
  cin >> ab >> bc >> ca;;

  cout << ab*bc/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
	int N, X, T;
	cin >> N >> X >> T;
	int total = 0;
	total += N / X * T ;
	if (N % X != 0) {
		total += T;
	}
	cout << total << endl;
}

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

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

int mn = a[0], mx = a[0];
long long sum = 0;
for(int i=0;i<n;i++ ){
  mn = min(mn,a[i]);
  mx = max(mx,a[i]);
  sum += a[i];
}
cout<<mn<<" "<<mx<<" "<<sum<<endl;

return 0;
}


Measured memory_bytes: 3120
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define SZ(x) ((int)(x).size())
#define MSB(x) (31 - __builtin_clz(x))
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
 
const int maxN = 1 << 19, maxS = 513, mod = 998244353;
const long long INF = 1000000000000000000ll;

int npo2(int n)
{
	return n * (n-1) / 2;
}

void solve()
{
	int n, m;
	scanf ("%d%d", &n, &m);
	printf("%d\n", npo2(n) + npo2(m));
}
 
int main()
{
	int t;
	t=1;//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}


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

int lcs();
char X[N],Y[N];

int main(){
    int n,i;
    
    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%s%s",&X[1],&Y[1]);
        X[0]=' ';
        Y[0]=' ';
        printf("%d\n",lcs(X,Y));
    }

    return 0;
}

int lcs(){
    int c[N+1][N+1];
    int m=strlen(X)-1;
    int n=strlen(Y)-1;
    int i,j,max=0;

    for(i=1;i<=m;i++) {
        c[i][0]=0;
    }
    for(i=1;i<=n;i++){
        c[0][i]=0;
    }

    for(i=1;i<=m;i++){
        for(j=1;j<=n;j++){
            if(X[i]==Y[j]) c[i][j]=c[i-1][j-1]+1;
            else{
                if(c[i-1][j]>c[i][j-1]) c[i][j]=c[i-1][j];
                else c[i][j]=c[i][j-1];
            }
            if(max<c[i][j]) max=c[i][j];
        }
    }

    return max;
}


Measured memory_bytes: 5700
//***Faithless is he that says farewell when the road darkens***

#include<bits/stdc++.h>
using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
    ll h,w,a,b;
    cin>>h>>w>>a>>b;

    forn(i,b){
        forn(j,a)
        cout<<"0";
        for(ll j=a+1;j<=(w);j++)
        cout<<"1";
        cout<<"\n";
    }
    forn(i,h-b){
        forn(j,a)
        cout<<"1";
        for(ll j=a+1;j<=(w);j++)
        cout<<"0";
        cout<<"\n";
    }
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(10) << num << endl;
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    ll x; cin >> x;
    ll res=0;
    rep(i,1000000){
        res+=i;
        if(res>=x){
            cout << i << endl;
            return 0;
        }
    }
}



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

using namespace std;

int main() {
	double a, b, c, d, e, f;
	while (cin>>a>>b>>c>>d>>e>>f) {
		double mat = a * e - b * d;
		double dx = (c * e - b * f) / mat;
		double dy = (a * f - d * c) / mat;

		if (dx == -0.) dx = 0.;
		if (dy == -0.) dy = 0.;
		printf("%.3f %.3f\n", dx, dy);
	}
	return 0;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	if(a>=13){
		cout<<b<<endl;
	}else if(a>=6){
		cout<<b/2<<endl;
	}else{
		cout<<0<<endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <utility>
#include <queue>
typedef long long ll;
const int maxn = 100005;
ll d[maxn]; bool inq[maxn];
int k;
typedef std::pair<ll, int> pii;
ll dij() {
  memset(d, 0x3f, sizeof(d));
  std::queue<int> Q;
  for(int i = 1; i <= 9; i ++) {
    int p = i % k;
    d[p] = std::min(d[p], (ll)i);
    if(!inq[p]) {
      Q.push(p); inq[p] = true;
    }
  }
  while(!Q.empty()) {
    int u = Q.front(); Q.pop();
    inq[u] = false;
    for(int i = 0; i < 10; i ++) {
      int v = (u * 10 + i) % k;
      if(d[v] > (d[u] + (ll)i)) {
        d[v] = d[u] + (ll)i;
        if(!inq[v]) {
          Q.push(v); inq[v] = true;
        }
      }
    }
  }
  return d[0];
}

int main() {
  scanf("%d", &k);
  printf("%lld\n", dij());
  return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	int n;
	cin >> n;
	rep(i, 0, n) {
		string str; int a, b;
		cin >> str >> a >> b;
		if (str == "print") {
			cout << s.substr(a, b - a + 1) << endl;
		}
		else if (str == "replace") {
			string rpl;
			cin >> rpl;
			s.replace(a, b - a + 1, rpl);
		}
		else {
			string tmp = s.substr(a, b - a + 1);
			reverse(tmp.begin(), tmp.end());
			for (int k = a, j = 0;k <= b;k++, j++) {
				s[k] = tmp[j];
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3220
#include"stdio.h"

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

const int MAX = 100100;

int linearSearch(int S[], int n, int key){
  rep(i, n)
    if (S[i] == key)
      return 1;
  return 0;
}

int main(){

  int n;
  scanf("%d", &n);
  int S[MAX];
  rep(i, n) scanf("%d", &S[i]);

  int q;
  scanf("%d", &q);
  int T[MAX];
  rep(i, n) scanf("%d", &T[i]);

  int ans = 0;
  rep(i, q){
    ans += linearSearch(S, n, T[i]);
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 2044
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
H = LIST()

count = 0
for hh in H:
    if hh >= K:
        count += 1
print(count)


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

using namespace std;
int c[10][10],dist[10];
queue<int> temp,tem;

void cari(){
	int x,index,i;
	while (!temp.empty()){
		x=tem.front();
		index=temp.front();
		if (x<dist[index]){
			dist[index]=x;
			for (i=0;i<10;i++){
				if (i!=index){
					temp.push(i);
					tem.push(x+c[i][index]);
				}
				
			}
		}
		tem.pop();
		temp.pop();
	}
	 
}

int main(){
	int h,w,i,j,x;
	long long int jumlah;
	cin>>h>>w;
	for (i=0;i<10;i++){
		for (j=0;j<10;j++){
			cin>>c[i][j];
		}
		dist[i]=INT_MAX;
	}
	temp.push(1);
	tem.push(0);
	cari();
	/*
	cout<<endl;
	for (i=0;i<10;i++){
		cout<<dist[i]<<' ';
	}
	cout<<endl;
	*/
	jumlah=0;
	for (i=0;i<h;i++){
		for (j=0;j<w;j++){
			cin>>x;
			if (x!=-1){
				jumlah+=dist[x];
			}
		}
	}
	cout<<jumlah<<endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <set>
#include <list>

using namespace std;

typedef struct {
    int x, y;
} pos_t;

typedef struct {
    pos_t *a, *b;
} path_t;

path_t make_path(pos_t *a, pos_t *b) {
    path_t t;
    t.a = a;
    t.b = b;
    return t;
}


int main() {
    int n = 0;
    scanf("%d", &n);
    pos_t *p = (pos_t *) malloc(sizeof(pos_t) * n);
    pos_t **px = (pos_t **) malloc(sizeof(pos_t *) * n);
    pos_t **py = (pos_t **) malloc(sizeof(pos_t *) * n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &p[i].x, &p[i].y);
        px[i] = py[i] = &p[i];
    }
    auto cpx = [](pos_t *a, pos_t *b) { return a->x == b->x ? a < b : a->x < b->x; };
    auto cpy = [](pos_t *a, pos_t *b) { return a->y == b->y ? a < b : a->y < b->y; };

    sort(px, px + n, cpx);
    sort(py, py + n, cpy);

    auto dist = [](path_t &a) {
        return min(abs(a.a->x - a.b->x), abs(a.a->y - a.b->y));
    };
    auto comp = [&dist](path_t &a, path_t &b) {
        return dist(a) > dist(b);
    };

    priority_queue<path_t, deque<path_t>, typeof(comp)> q(comp);
    set<pos_t *> t;
    int r = 0;

    t.insert(&p[0]);

    auto rx = lower_bound(px, px + n, &p[0], cpx);
    auto ry = lower_bound(py, py + n, &p[0], cpy);
    if (rx == px + n) throw;
    if (ry == py + n) throw;
    if (rx != px) q.push(make_path(*rx, *(rx - 1)));
    if (rx + 1 != px + n) q.push(make_path(*rx, *(rx + 1)));
    if (ry != py) q.push(make_path(*ry, *(ry - 1)));
    if (ry + 1 != py + n) q.push(make_path(*ry, *(ry + 1)));

    while (t.size() != n) {
        auto pp = q.top();
        q.pop();
        if (t.find(pp.b) != t.end()) {
            continue;
        }
        r += dist(pp);
        t.insert(pp.b);
        auto rx = lower_bound(px, px + n, pp.b, cpx);
        auto ry = lower_bound(py, py + n, pp.b, cpy);
        if (rx == px + n) throw;
        if (ry == py + n) throw;
        if (rx != px) q.push(make_path(*rx, *(rx - 1)));
        if (rx + 1 != px + n) q.push(make_path(*rx, *(rx + 1)));
        if (ry != py) q.push(make_path(*ry, *(ry - 1)));
        if (ry + 1 != py + n) q.push(make_path(*ry, *(ry + 1)));
    }
    printf("%d\n", r);
    return 0;
}

Measured memory_bytes: 11264
import java.util.*;
import java.awt.Point;

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

		while(true){
			int N = sc.nextInt();
			if(N == 0) break;

			Point[] p = new Point[N];
			p[0] = new Point(0,0);

			int maxX = 0;
			int maxY = 0;
			int minX = 0;
			int minY = 0;

			for(int i=0;i<N-1;i++){
				int n = sc.nextInt();
				int d = sc.nextInt();
				int x = p[n].x;
				int y = p[n].y;

				switch(d){
				case 0:
					p[i+1] = new Point(x-1,y);
					minX = Math.min(minX,x-1);
					break;
				case 1:
					p[i+1] = new Point(x,y+1);
					maxY = Math.max(maxY,y+1);
					break;
				case 2:
					p[i+1] = new Point(x+1,y);
					maxX = Math.max(maxX,x+1);
					break;
				case 3:
					p[i+1] = new Point(x,y-1);
					minY = Math.min(minY,y-1);
					break;
				}
			}

			System.out.println((maxX - minX + 1) + " " + (maxY - minY + 1));
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <climits>
using namespace std;

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

typedef vector<vector<int> > matrix;
matrix dat;
int R, C;

void update(int r, int c, int a) {
  bool f = 0;
  if (r==0&&c==1) f = 1;
  r += R - 1;
  c += C - 1;
  dat[r][c] = a;
  int cc = c;
  while(cc > 0) {
    cc = (cc-1) / 2;
    dat[r][cc] = min(dat[r][cc*2+1], dat[r][cc*2+2]);
    if (f) {
//      printf("(%d,%d) %d\n", r,cc,dat[r][cc]);
    }
  }
  while(r > 0) {
    r = (r-1) / 2;
    cc = c;
    while(1) {
      dat[r][cc] = min(dat[r*2+1][cc], dat[r*2+2][cc]);
      if (cc == 0) break;
      cc = (cc-1) / 2;
      if (f) {
//        printf("(%d,%d) %d\n", r,cc,dat[r][cc]);
      }

    }
  }
}

int query(int r1, int c1, int r2, int c2, int r, int rl, int rr, int c, int cl, int cr) {
  if (rr<=r1 || r2<=rl || cr<=c1 || c2<=cl) return INF;
//  printf("(%d,%d)(%d,%d)  (%d,%d)\n", rl,cl,rr,cr,r,c);
  if (r1 <= rl && rr <= r2 && c1 <= cl && cr <= c2) {
//    cout << "HOGE" << " " << dat[r][c]<< endl;
    return dat[r][c];
  }
  if (r1 <= rl && rr <= r2) {   // cðª
    int v1 = query(r1,c1,r2,c2,r,rl,rr,c*2+1,cl,(cl+cr)/2);
    int v2 = query(r1,c1,r2,c2,r,rl,rr,c*2+2,(cl+cr)/2, cr);
    return min(v1,v2);
  } else {                      // ¡ðª
    int v1 = query(r1,c1,r2,c2,r*2+1,rl,(rl+rr)/2,c,cl,cr);
    int v2 = query(r1,c1,r2,c2,r*2+2,(rl+rr)/2,rr,c,cl,cr);
    return min(v1,v2);
  }
}
int main() {
  int q;
  while(cin >>R>>C>>q, R||C||q) {
    int RR = R, CC = C;
    R = 1; C = 1;
    while(R < RR) R *= 2;
    while(C < CC) C *= 2;
    dat.assign(2*R-1, vector<int>(2*C-1, INF));
    REP(i,RR) REP(j,CC) {
      int a;
      cin >> a;
      update(i,j,a);
    }
    REP(i,q) {
      int r1,c1,r2,c2;
      cin >> r1 >> c1 >> r2 >> c2;
      cout << query(r1,c1,r2+1,c2+1,0,0,R,0,0,C) << endl;
    }
    
  }
}

Measured memory_bytes: 56000
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n,j,i,a[41],sum,count;
    string w[41] = {}; 
    while(1){
        
        cin >> n;
        if(n == 0) break;
        
        for(i=1;i<n+1;i++){
            cin >> w[i];
            a[i] = w[i].length();
          //  cout << w[i] << ":" << a[i] << endl;
        }
        
        sum = 0;
        count = 5;
        
        for(j = 1;j<=n-4;j++){
            sum = 0;
            count = 5;
            for(i=j;i<n+1;i++){
                
                sum = sum + a[i];
                if(sum == 5) count--;
                else if ( sum == 12) count--;
                else if ( sum == 17) count--;
                else if ( sum == 24) count--;
                else if ( sum == 31) count--;
                
     //       cout << j << ":" << sum << ":" << count  << endl;
                if ( sum >= 31) break;
        
            }
            
            if(count == 0){
                cout << j << endl;
                break;
            }
        }
        
    
    }
    return 0;
    
    
}



Measured memory_bytes: 3220
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

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

const ll mod = 1e9 + 7;

vector<string> g;


int main() {
    
    
    string s;
    cin >> s;
    
    reverse(s.begin(), s.end());
    vector<ll> m(2019);
    
    ll cur = 1;
    ll prev = 0;
    m[0]++;
    for (int i = 0; i < s.size(); ++i)
    {
        ll num = s[i] - '0';
        m[(cur * num + prev) % 2019]++;
        prev = cur * num + prev;
        cur *= 10;
        cur %= 2019;
    }
    
    ll ret = 0;
    for (int i = 0; i < 2019; ++i)
    {
        if (m[i] != 0)
        {
            ret += (m[i] * (m[i] - 1)) / 2;
        }
    }

    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 3760
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define ll          long long
#define pii         pair<int, int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int, int>
#define mii         map<pii, int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define lb          lower_bound
#define ub          upper_bound

#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)
 
#define track(x)                 cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
 
#define ed(i)       i.end()
#define mem(a)	    memset(a, 0, sizeof(a))

#define MOD         1000000007
int mult(int a,int b, int p=MOD){return ((a%p)*(b%p))%p;}
int add(int a, int b, int p=MOD){return (a + b + p)%p;}
int fpow(int n, int k, int p = MOD) {int r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
void self_max(int &a, int b) {a = max(a, b); }
void self_min(int &a, int b) {a = min(a, b); }
void self_add(int &a, int b, int p = MOD) { a += b; if(a >= p) a -= p;}
void self_sub(int &a, int b, int p = MOD) { a -= b; if(a < 0) a += p;}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
const int INF = 1e9 + 5;
#define N	    	400001

int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
void solve(){
    int n, m;
    cin>>n>>m;
    int a[m];
    rep(i, 0, m) {
        cin>>a[i];
    }
    if(n >= m) {
        cout<<0<<endl;
        return;
    }
    sort(a, a + m);
    vi v;
    rep(i, 1, m) {
        v.pb(a[i] - a[i-1]);
    }
    sort(all(v)); reverse(all(v));
    int dis = 0;
    rep(i, 0, n-1)
        dis += v[i];
    cout<<a[m-1] - a[0] - dis<<endl;
}
int main() {
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin>>t;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 4140
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include "bits/stdc++.h"

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define f first
#define s second
#define uint unsigned int

using namespace std;

int main() {
#define FILE_INPUT 0
#define FILE "coins"
#ifndef DEBUG
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#if FILE_INPUT == 1
#warning "FREOPEN is on"
    freopen(FILE".in", "r", stdin);
    freopen(FILE".out", "w", stdout);
#endif
#endif
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    int m = n - 1;
    for (int i = 0; i <= m; ++i) {
        if (c * (m - i) - d * i <= a - b && d * (m - i) - c * i >= a - b) {
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
    return 0;
}


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

int main(void){
    string s, t;
    cin >> s;
    for(int i=0; i<s.length(); i++){
        if(i%2 == 0){
            t += s[i];
        }
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 512
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO;
 use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO;

procedure main is
   S: String(1..3);
begin
   S := get_line;
   if S(1) = S(2) and then S(2) = S(3) then put_line("No");
   else put_line("Yes");
   end if;
end main;

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] c = new int[n];
        int[] s = new int[n];
        int[] f = new int[n];
        for (int i = 0; i < n - 1; i++) {
            c[i] = sc.nextInt();
            s[i] = sc.nextInt();
            f[i] = sc.nextInt();
        }

        int[] ans = new int[n];
        for (int i = 0; i < n - 1; i++) {
            ans[i] = c[i] + s[i];
            for (int j = i + 1; j < n - 1; j++) {
                int startTime = s[j];
                if (ans[i] > startTime) {
                    while (ans[i] > startTime) {
                        startTime += f[j];
                    }
                }
                ans[i] = c[j] + startTime;
            }
        }
        for (int i = 0; i < n; i++) {
            System.out.println(ans[i]);
        }
    }

}


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

int main ()
{
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (a - 2*b > 0)
		cout << a - 2*b << '\n';
	else
		cout << 0 << '\n';
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char b[15];
	while(~scanf("%s",b)){
		int c[10];
		for(int i=0;i<10;i++)c[i]=b[i]-'0';
		for(int i=9;i>0;i--)
			for(int j=0;j<i;j++)
				c[j]=(c[j]+c[j+1])%10;
		printf("%d\n",c[0]);
	}
}

Measured memory_bytes: 0
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
cnt_a = Counter(a)
q = int(input())
s = [sum(a)] + [0] * q
for i in range(q):
    b, c = map(int, input().split())
    try:
        cnt_b = cnt_a.pop(b)
        cnt_a[c] += cnt_b
        s[i + 1] = s[i] + (c - b)*cnt_b
    except KeyError:
        s[i + 1] = s[i]
print(*s[1:], sep='\n')

Measured memory_bytes: 22672
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll inf = 1e16;
const ll mod=1000000007;
typedef pair<ll,ll> pi;

void solve()
{
 ll n,k;
 cin>>n>>k;
 vector<ll>a(n);
 for(ll i=0;i<n;i++)
    cin>>a[i];
 ll low=1;
 ll high=inf;
 ll ans;
 while(low<=high)
 {
     ll mid=(low+high)/2;
     ll c=0;
     for(ll i=0;i<n;i++)
     {
         c+=a[i]/mid;
         if(a[i]%mid==0) c--;
     }
     if(c<=k)
     {
         ans=mid;
         high=mid-1;
     }
     else low=mid+1;
 }
 cout<<ans;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    t=1;
    for(ll i=1;i<=t;i++)
    {
        solve();
        cout<<endl;

    }
    return 0;
}


Measured memory_bytes: 4780
void main() {
	auto s = ri;
	int[] a;
	a ~= s;
	while(true) {
		auto v = a.back;
		auto p = f(v);
		if(a.canFind(p)) {
			writeln(a.length+1);
			return;
		}
		else a ~= p;
	}
}

int f(int n) {
	if(n % 2 == 0) return n / 2;
	else return 3*n + 1;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
// failed to generate code

#include <bits/stdc++.h>
using namespace std;

int main(){	
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	n *= 2;
	vector<int> l(n);
	for(int i = 0 ; i < n ; i++){
		cin >> l[i];
	}
	sort(l.begin(),l.end());
	int ans = 0;
	for(int i = 0 ; i < n ; i+=2)
		ans += min(l[i],l[i+1]);
	cout << ans << endl;
		
}


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

int h[100001];

int main(){
    long long int n, a, b;
    scanf("%lld %lld %lld",&n,&a,&b);
    long long int sum=0;
    for(int i=0;i<n;++i){
        scanf("%d",&h[i]);
        sum += h[i];
    }
    long long int mt = ceil((double)sum / b);
    long long int left = 0, right = mt;
    while(right - left > 1){
        long long int t = left + (right - left) / 2;
        long long int cnt = 0;
        for(int i=0;i<n;++i){
            if(h[i] > b * t)cnt += ceil((double)(h[i]-b*t)/(a-b));
        }
        if(cnt > t)left = t;
        else right = t;
    }

    long long int cnt = 0;
    for(int i=0;i<n;++i){
        if(h[i] > b * left)cnt += ceil((double)(h[i]-b*left)/(a-b));
    }

    if(cnt > left) printf("%lld\n",right);
    else printf("%lld\n",left);

    return 0;
}


Measured memory_bytes: 640
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();

		Set<Integer> sunuke = new HashSet<>();

		for(int i=0; i<k; i++) {
			int d = sc.nextInt();

			for(int j=0; j<d; j++) {
				sunuke.add(sc.nextInt());
			}
		}

		int ans = n - sunuke.size();

		System.out.println(ans);
	}

}


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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N;  cin >> N;
  	ll power[61], bits[61];  power[1] = 1;
  	for(int i = 0 ; i <= 60 ; i++)  bits[i] = 0;
  	for(int i = 2 ; i <= 60 ; i++)  power[i] = (power[i - 1] * 2) % MOD;
  
	for(int i = 0 ; i < N ; i++){
	 ll A;  cin >> A;
	 int bit = 1;
	 while(A){
	  if(A & 1)
	  	bits[bit] += (A & 1);
	  bit += 1;
	  A = A >> 1;
	 }
	}

	ll ans = 0;
	for(int i = 1; i <= 60 ; i++){
	 ans += (power[i] * ((bits[i] * (N - bits[i])) % MOD)) % MOD;
     ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
S = [list(input()) for i in range(n)]
X = "qwertyuiopasdfghjklzxcvbnm"
ans = []
for i in range(26):
	res = []
	for s in S:
		res.append(s.count(X[i]))
	for j in range(min(res)):
		ans.append(X[i])
ans.sort()
print("".join(ans))

Measured memory_bytes: 3064
def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))  # 整数のリスト
    highest = [1 for _ in range(N)]

    for i in range(M):
        A, B = map(int, input().split())
        A_height, B_height = H[A-1], H[B-1]
        if A_height > B_height:
            highest[B-1] = 0
        elif B_height > A_height:
            highest[A-1] = 0
        else:
            highest[A-1], highest[B-1] = 0, 0

    print(highest.count(1))


if __name__ == '__main__':
    main()


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

int n,m;

int main(){
	int i,j;
	
	while(1){
		cin >> n >> m;
		if( !n)break;
		
		int s[100],t[100];
		int ssum = 0,tsum = 0;
		int kokans = -1, kokant = -1;
		int kokanwa = 100000;
		
		for( i = 0; i < n; i++ )
			cin >> s[i];
		for( i = 0; i < m; i++ )
			cin >> t[i];
		
		for( i = 0; i < n; i++ ){
			ssum += s[i];
		}
		for( i = 0; i < m; i++ ){
			tsum += t[i];
		}
		
		for( i = 0; i < n; i++ ){
			for( j = 0; j < m; j++ ){
				if( ssum+t[j]-s[i] == tsum-t[j]+s[i] ){
					if( kokanwa > s[i]+t[j] ){
						kokanwa = s[i]+t[j];
						kokans = s[i];
						kokant = t[j];
					}
				}
			}
		}
		if( kokans == -1 )
			cout << "-1" << endl;
		else{
			cout << kokans << " " << kokant << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
using P = pair <int, int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
ll gcd(ll a,ll b) {return  b ? gcd(b,a%b) : a;}
const long long INF = 1LL << 60;
const int mod = 1000000007;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main() {
     string x;
     cin >> x;
     int n = x.size();
     stack<char> st;
     rep(i,n){
          if (st.empty()) st.push(x[i]);
          else if(st.top()=='S'){
               if(x[i]=='T'){
                    st.pop();
               }
               else st.push(x[i]);
          }
          else st.push(x[i]);
     }
     cout << st.size() <<endl;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo for(int i=0;i<n;i++)
#define clear cin.clear();cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define loopSolve int t; cin>>t; while(t--){solve();}
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//INT_MAX         2,147,483,647                       <10^10
//U_INT_MAX       4,294,967,295                       <10^10
//LONG_LONG_MAX   9,223,372,036,854,775,807           <10^18
//U_LONG_LONG_MAX 18,446,744,073,709,551,615          <10^18
//ll power(int a, int b){
//    return (ll)(pow(a,b)+0.5);
//}

vector<int> gV(int n){
    vector<int> v(n);
    fo { cin>>v[i];  }
    return v;
}

int* gA(int n){
    int* arr = new int[n];
    fo cin>>arr[i];
    return arr;
}


void solve(){
    int c,n;
    cin>>c>>n;
    static ll dp[1001][20001];
    ll wt[1001]; ll val[1001];

    for(int i=0;i<n;i++)
        cin>>wt[i]>>val[i];

//    for(int i=0;i<n;i++)
//        cout<<wt[i]<<" ";
//    cout<<endl;
//    for(int i=0;i<n;i++)
//        cout<<val[i]<<" ";
//    cout<<endl;

    for(int i=0;i<=2*c;i++)
        dp[0][i]=INT_MAX-2000;
    for(int i=0;i<=n;i++)
        dp[i][0]=0;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=2*c;j++){
            if(wt[i-1]<=j){
                dp[i][j]= min(val[i-1]+dp[i][j-wt[i-1]],dp[i-1][j]);
            }else{
                dp[i][j]=min(dp[i-1][j],val[i-1]);
                //dp[i][j]=dp[i-1][j];
            }
        }
    }

//    for(int i=1;i<=n;i++){
//        for(int j=1;j<=c;j++)
//            cout<<dp[i][j]<<" ";
//        cout<<endl;
//    }

    int m=c+1;
    while(m<=2*c && dp[n][c]==INT_MAX-2000){
        dp[n][c]=min(dp[n][c],dp[n][m]);
        m++;
    }
    cout<<dp[n][c]<<endl;


}


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

    solve();
    //loopSolve;

	return 0;
}


Measured memory_bytes: 160004
import java.util.*;


public class Main {

	public static void main(String[] args) {
		
		int t = 0;
		
		String S = new java.util.Scanner(System.in).nextLine();
		String[] ar = S.split("");
		String[] vr = new String[2];
		vr[0] = "+";
		vr[1] = "-";
 		for(int i=0;i<4;i++) {
			if(ar[i].equals(vr[0])) {
				t++;
			}
			else {
				t--;
			}
		}
		System.out.println(t);
	}

}


Measured memory_bytes: 21716
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  cout << (1+n) * n / 2 << endl;
  return 0;
}


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

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

int main() {

  int N;
  cin >> N;

  vector<int> A(N);

  // 左から順番に計算したGCD
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (i == 0) {
      L[i] = A[i];
    } else {
      L[i] = gcd(L[i - 1], A[i]);
    }
  }

  // 右から順番に計算したGCD
  vector<int> R(N);
  for (int i = N - 1; 0 <= i; i--) {
    if (i == N - 1) {
      R[i] = A[i];
    } else {
      R[i] = gcd(R[i + 1], A[i]);
    }
  }

  int answer = 0;
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      answer = max(answer, R[i + 1]);
    } else if(i == N - 1) {
      answer = max(answer, L[i - 1]);
    } else {
      answer = max(answer, gcd(L[i - 1],R[i + 1]));
    }
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 1408