akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
#define MOD 1000000007
using namespace std;

int main() {
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	string s1 = "maerd", s2 = "remaerd", s3 = "esare", s4 = "resare";
	bool flag = true;
	int i = 0;
	while (i<s.size()) {
		string rem, rem2;
		if (s[i] == 'm') {
			rem = s.substr(i, 5);
			if (rem != s1) {
				flag = false;
				break;
			}
			i += 5;
		}
		else if (s[i] == 'e') {
			rem = s.substr(i, 5);
			if (rem != s3) {
				flag = false;
				break;
			}
			i += 5;
		}
		else if (s[i] == 'r') {
			rem = s.substr(i, 7);
			rem2 = s.substr(i, 6);
			if (rem == s2) {
				i += 7;
			}
			else if (rem2 == s4) {
				i += 6;
			}
			else {
				flag = false;
				break;
			}
		}
		else {
			flag = false;
			break;
		}
	}
	if (flag) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i=0; i<n; i++){
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    string ans;
    for(int i=0; i<n; i++){
        ans += s[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math
N = int(input())
list = []
for i in range(int(math.sqrt(N))):
    if(N%(i+1) == 0):
        list.append([i+1, N//(i+1)])
min = 1000000000000
for i in list:
    if(min > i[0]+i[1]):
        min = i[0]+i[1]
print(min-2)

Measured memory_bytes: 3460
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll n,m;cin>>n>>m;
  vl x(n),y(m);
  rep(i,n)cin>>x[i];
  rep(i,m)cin>>y[i];
  n--;m--;
  ll D1=0,D2=0;
  rep(i,n){
    ll part=x[i+1]-x[i];
    part%=MOD;
    part*=i+1;
    part%=MOD;
    part*=n-i;
    part%=MOD;
    D1=(D1+part)%MOD;
  }
  rep(i,m){
    ll part=y[i+1]-y[i];
    part%=MOD;
    part*=i+1;
    part%=MOD;
    part*=m-i;
    part%=MOD;
    D2=(D2+part)%MOD;
  }
  cout<<D1*D2%MOD<<endl;
}


Measured memory_bytes: 4792
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		final int A = scan.nextInt();
		final int B = scan.nextInt();
		final int C = scan.nextInt();
		scan.close();
		int result = C - (A - B);
		if(result <  0) {
			result = 0;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

signed main(void) {
    int N; cin >> N;
    for (int i=0; i*4<=N; i++) {
        if ((N - i*4) % 7 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
     cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#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 endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename 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=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

//n^2かかるのでTLEは注意
template <class T>
vector<vector<T>> comb(T n) {
  vector<vector<T>> v(n+1,vector<T>(n+1,0));
  rep(i,v.size()){
	v[i][0]=1;
	v[i][i]=1;
  }
  FOR(j,1,v.size())FOR(k,1,j){
	v[j][k]=v[j-1][k-1]+v[j-1][k];
  }
  return v;
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n,a,b;
	cin>>n>>a>>b;
	vector<ll> v(n);
	map<ll,ll> mp;
	rep(i,n){
		cin>>v[i];
		mp[v[i]]++;
	}
	sort(begin(v),end(v),greater<ll>());
	double ans=0;
	set<ll> st;
	rep(i,a){
		ans+=v[i];
		st.insert(v[i]);
	}
	cout<<setprecision(15)<<ans/double(a)<<endl;
	vector<vector<ll>> ret=comb(n+1);
	if(st.size()==1){
		ll tar=*st.begin();
		ll num=mp[tar];
		ll cnt=0;
		FOR(i,a,min(num,b)+1){	
			cnt+=ret[num][i];
		}
		cout<<cnt<<endl;
	}else{
		ll tar=v[a-1];
		ll num=0;
		rep(i,a){
			if(v[i]==tar) num++;
		}
		cout<<ret[mp[tar]][num]<<endl;
	}
}

Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main extends App {

  for (_ <- 1 to 300) {
    val input = readLine.split(" ").map(_.toInt)
    val (h, w) = (input(0), input(1))

    if (h == 0 && w == 0) sys.exit() else {
      for (e <- 1 to h) {
        println("#" * w)
      }
      println()
    }
  }

}



Measured memory_bytes: 45448
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int r; cin >> r;
    cout << fixed << setprecision(20) << 2 * r * acos(-1.0) << '\n';

}


Measured memory_bytes: 3780
import numpy as np
n = int(input())
num_list = list(map(int, input().split()))

mod = int(1e+9+7)
cumsum_list = np.cumsum(num_list[::-1])[::-1][1:]
all_sum = sum(num_list)
score = 0
for i in range(n-1):
    #print(num_list[i], cumsum_list[i])
    #score += (num_list[i] * cumsum_list[i]) % mod
    all_sum -= num_list[i]
    score += (num_list[i] * all_sum) % mod
print(score % mod)

Measured memory_bytes: 50192
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        int a, b;
        a = input.nextInt();
        b = input.nextInt();
        System.out.println(a * b + " " + (a + b) * 2);
    }         
}

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

using namespace std;

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

	int len = max(a.size(), b.size());
	a = string(len - a.size(), '0') + a;
	b = string(len - b.size(), '0') + b;

	if (a == b) {
		cout << "EQUAL" << endl;
	} else if (a < b) {
		cout << "LESS" << endl;
	} else {
		cout << "GREATER" << endl;
	}
	return 0;
}


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

#define deb(x)        cerr << #x << " = " << x << "\n";
#define deb2(x, y)    cerr << #x << " = " << x << ", " << #y << " = " << y << "\n";
#define deb3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << "\n";

#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f  first
#define s  second

#define sortall(x) sort(x.begin(), x.end());
#define sz(x) (ll)x.size()

typedef long long         ll  ;

typedef vector < ll >     vl  ;
typedef vector < int >    vi  ;

typedef pair < ll, ll >   pl  ;
typedef pair < int, int > pi  ;

typedef vector < pl >     vpl ;
typedef vector < pi >     vpi ;

void solve()
{
	ll n;
	string temp;
	cin >> n;

	unordered_map < string, ll > cnt;
	for (ll i = 0; i < n; ++i)
	{
		cin >> temp;
		cnt[temp]++;
	}
	cout << "AC x " << cnt["AC"] << '\n';
	cout << "WA x " << cnt["WA"] << '\n';
	cout << "TLE x " << cnt["TLE"] << '\n';
	cout << "RE x " << cnt["RE"] << '\n';
}

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

	//freopen ("in.txt", "r", stdin); freopen("err.txt", "w", stderr); //freopen ("out.txt", "w", stdout);

	ll tc = 1;
	//cin >> tc;

	while (tc--)
	{
		solve();
		//cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3636
Scanf.scanf "%d" (fun n ->
    let ds k =
        let rec loop r acc =
            if r = 0 then acc else loop (r / 10) (acc + r mod 10)
        in
        loop k 0
    in
    let rec loop a acc =
        if a = 0 then acc else
            loop (a - 1) (min acc (ds a + ds (n - a)))
    in
    loop (n / 2) max_int |> Printf.printf "%d\n"
)

Measured memory_bytes: 3844
#include <bits/stdc++.h> 
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define ld double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define sz(x) ((long long)x.size())
#define all(x) (x).begin(), (x).end()
const int MOD =1e9+7;

int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1LL;}return res%p;}
const int N=2*1e5+2,M=20;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	#endif
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	int b[n];
	for(int i=0;i<n;i++) cin>>b[i];
	int ans=0;
	for(int k=30;k>=0;k--)
	{
		int x=(1LL<<(k+1));
		for(int i=0;i<n;i++)
		{
			a[i]%=x;
		}
		for(int i=0;i<n;i++)
		{
			b[i]%=x;
		}
		sort(b,b+n);
		int cnt=0;
		int l=(1LL<<k);
		int r=(1LL<<(k+1));
		r--;
		for(int i=0;i<n;i++)
		{
			int ll=l-a[i];
			int rr=r-a[i];
			int count=(upper_bound(b,b+n,rr)-upper_bound(b,b+n,ll-1));
			cnt+=count;
		}
		l=(1LL<<k)+(1LL<<(k+1));
		r=(1LL<<(k+2));
		r--;
		for(int i=0;i<n;i++)
		{
			int ll=l-a[i];
			int rr=r-a[i];
			int count=(upper_bound(b,b+n,rr)-upper_bound(b,b+n,ll-1));
			cnt+=count;
		}
		if(cnt&1LL)
		{
			ans+=(1LL<<k);
		}
	}
	cout<<ans;
} 
// l<=a+b<=r
// l-a<=b<=r-a  
//          
// 2^k<=a+b<2^(k+1)
// 2^(k+1)+2^(k) <=a+b<2^(k+2)


Measured memory_bytes: 3328
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
long long a,b,c,k;
int main()
{
	cin>>a>>b>>c>>k;
	if(k&1)
	{
		cout<<b-a;
	}
	else 
	
{
	cout<<a-b<<endl;
	return 0;
}
	return 0;
}

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

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

    vector <int> ans(100001);
    rep(i,100001){
        ans[i]=i;
    }

    int x6=1;
    int k;
    rep(i,6){
        x6*=6;
        k=x6;
        rep(j,100001){
            if(j<k){
                continue;
            }
            else{
            ans[j]=min(ans[j],ans[j-x6]+1);
            }
        }
    }

    int x9=1;
    //int k;
    rep(i,5){
        x9*=9;
        k=x9;
        rep(j,100001){
            if(j<k){
                continue;
            }
            else{
            ans[j]=min(ans[j],ans[j-x9]+1);
            }
        }
    }

    /*rep(i,100){
        cout << i << " " << ans[i] << endl;
    }*/

    cout << ans[n] << endl;
    

    return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>

int main(void){
  long int a, b, x;
  scanf("%ld%ld%ld", &a, &b, &x);
  long int ans = b/x - a/x;
  if(a % x == 0) ans++;
  
  printf("%ld\n", ans);
  return 0;
}

Measured memory_bytes: 128
n = int(input())
a, b, c = [], [], []
for _ in range(n):
    ai, bi, ci = map(int, input().strip().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
dp = []
dp.append((a[0], b[0], c[0]))
for i in range(1, n):
    prev = dp[i-1]
    chosen_a = a[i] + max(prev[1], prev[2])
    chosen_b = b[i] + max(prev[0], prev[2])
    chosen_c = c[i] + max(prev[0], prev[1])
    dp.append((chosen_a, chosen_b, chosen_c))
res = dp[n-1]
print(max(res[0], res[1], res[2]))

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;
const int MAX_N = 131072;

int main() {
  int N;
  cin>>N;
  vector<ll> v(N);
  for(int i = 0; i < N; i++) {
    cin>>v[i];
  }
  bool ok = false;
  ll ans = 0LL;
  while(!ok){
    ok=true;
    map<int,ll> m;
    ll cnt = 0LL;
    for(int i = 0; i < N; i++){
      if(v[i]>=N){
        ok=false;
        m[i]=v[i]/N;
        v[i]%=N;
        cnt+=m[i];
      }
    }
    for(int i = 0; i < N; i++){
      v[i]+=cnt-m[i];
    }
    ans += cnt;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
int main(){
    int N,sum=0;
    std::cin >> N;
    std::vector<std::pair<int,int>> A(N);
    for(int i=0;i<N;i++){
        std::cin >> A[i].second >> A[i].first;//yx red
    }
    std::vector<std::pair<int,int>> B(N);
    for(int i=0;i<N;i++){
        std::cin >> B[i].first >> B[i].second; //xy blue
    }
    std::sort(A.begin(),A.end());
    std::sort(B.begin(),B.end());
    std::vector<int> used(N);
    for(int i=0;i<N;i++){
        
        for(int j=N-1;j>=0;j--){
            if(used[j]){
                continue;
            }
            if(B[i].first>A[j].second&&B[i].second>A[j].first){
                used[j]=1;
                sum++;
                break;
            }
                
        }
    }
    std::cout << sum <<std::endl;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto ac = new bool[](N);
    auto wa = new long[](N);
    foreach (_; 0 .. M)
    {
        long p;
        string S;
        scan(p, S);
        p--;
        if (ac[p])
        {
            continue;
        }
        if (S == "AC")
        {
            ac[p] = true;
            continue;
        }
        if (S == "WA")
        {
            wa[p]++;
        }
    }
    foreach (i; 0 .. N)
        if (!ac[i])
            wa[i] = 0;
    long accnt = ac.to!(long[]).sum();
    long wacnt = wa.sum();
    writefln("%d %d", accnt, wacnt);
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, M;
bool G[110][110];

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

    std::cin >> N;

    int M = N * (N - 1) / 2;

    if(N % 2 == 1){
        for(int i=1;i<N;++i){
            int j = N - i;
            if(i > j){
                break;
            }

            G[i][j] = 1;
            M -= 1;
        }
    }else{
        for(int i=1;i<=N;++i){
            int j = N + 1 - i;
            if(i > j){
                break;
            }

            G[i][j] = 1;
            M -= 1;
        }
    }

    std::cout << M << std::endl;

    for(int i=1;i<=N;++i){
        for(int j=i+1;j<=N;++j){
            unless(G[i][j]){
                std::cout << i << " " << j << std::endl;
            }
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)


int main() {
    int H, N;
    cin >> H >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    rep(i, N) cin >> A[i] >> B[i];
    ll dp[10001];
    rep(i, 10001) dp[i] = 1000000000000;
    dp[0] = 0;
    repi(i, 1, H + 1) {
        if (i < A[0]) dp[i] = B[0];
        else dp[i] = dp[i - A[0]] + B[0];
        repi(j, 1, N) {
            if (i < A[j]) dp[i] = min(dp[i], B[j]);
            else dp[i] = min(dp[i], dp[i - A[j]] + B[j]);
        }
    }
    cout << dp[H] << endl;
    return 0;
}



Measured memory_bytes: 384
program tsundoku
  implicit none
  integer :: n, m, i, h = 0, l, r, p
  integer(8) :: k, t
  integer(8), dimension(0:200001) :: a = 0, b = 0, x = 0, y = 0
  read(*,*) n, m, k
  read(*,*) a(1:n)
  read(*,*) b(1:m)
  do i = 1, n
    x(i) = x(i - 1) + a(i)
  end do
  do i = 1, m
    y(i) = y(i - 1) + b(i)
  end do
  do i = 0, n
    t = k - x(i)
    if (t < 0) exit
    l = 0
    r = m + 1
    do while (r - l > 1)
      p = (l + r) / 2
      if (y(p) <= t) then
        l = p
      else
        r = p
      end if
    end do
    h = max(h, i + l)
  end do
  write(*,'(i0)') h
end program tsundoku

Measured memory_bytes: 9372
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n != 0) {
		sum += n % 10; n /= 10;
	}
	return sum;//Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
ld mysqrtl(ld x)
{
	ld a = sqrtl((double)x); // 近似値
	do {
		a = (a + x / a) / 2.0L;
	} while (fabsl(x - a * a) > eps);
	return a;
}
//平方根を求める。sqrtより精度が高い。
//epsを変えて誤差を調整する。
int main(void) {
	Rapid_pleaseAC_fast;
	long long ans, n;
	bool check = false;
	char c[6];
	cin >> c[0]>>c[1]>>c[2]>>c[3]>>c[4]>>c[5];
	if (c[2] == c[3] && c[4] == c[5])cout << "Yes" << endl;
	else cout << "No" << endl;
	please AC;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
typedef long long ll;
int n,s;
ll dp[102][12][1002];

int main(void){
	while(1){
		scanf("%d%d",&n,&s);
		if(n==0)break;
		memset(dp,0,sizeof(dp));
		dp[0][0][0]=1;
		for(int i=0;i<=100;i++){
			for(int j=0;j<=n;j++){
				for(int k=0;k<=s;k++){
					dp[i+1][j][k]+=dp[i][j][k];
					if(i+k<=s)dp[i+1][j+1][i+k]+=dp[i][j][k];
				}
			}
		}
		printf("%lld\n",dp[101][n][s]);
	}
	return 0;
}

Measured memory_bytes: 10616
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

struct Edge {
    int from, to, cost;
};

int main(void) {
    int N, M, P; cin >> N >> M >> P;
    vector<vector<Edge>> G(N+1);
    for (int i = 0; i < M; i++) {
        int a, b, c; cin >> a >> b >> c;
        a--;
        b--;
        c -= P;
        G[a].push_back({a, b, c});
    }

    long long INF = 10000000000000000;
    vector<vector<long long>> v(10001, vector<long long>(N+1, -INF));
    v[0][0] = 0;
    for (int time = 0; time < 10000; time++) {
        for (int i = 0; i < N; i++) {
            if (v[time][i] == -INF) continue;

            for (int j = 0; j < G[i].size(); j++) {
                Edge e = G[i][j];
                v[time+1][e.to] = max(v[time][e.from] + e.cost, v[time+1][e.to]);
            }
            v[time+1][i] = max(v[time][i], v[time+1][i]);
            if (i == N-1) {
                v[time+1][N] = max(v[time][N-1], v[time+1][N]);
            }
            if (time > 5000 && v[time+1][i] > v[time][i]) {
                v[time+1][i] = INF;
            }   
        }
    }
    if (INF <= v[10000][N-1]) cout << -1 << endl;
    else cout << max(v[10000][N-1], 0LL) << endl;
}


Measured memory_bytes: 198144
def result(readlines)
  n_x = readlines[0].chomp.split.map(&:to_i)
  n = n_x[0]
  x = n_x[1]

  a_array = readlines[1].chomp.split.map(&:to_i)
  a_array.sort!

  count = 0
  (1..n).each do |index|
    x -= a_array[index - 1]

    if index == n && x > 0
      break
    end
    
    if x >= 0
      count += 1
    else
      break
    end
  end
  count
end

puts result(readlines)


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

int main() {
	string S;
	cin >> S;
	int count = 0;
	for (int i = 0;i < 6;++i) {
		if (S[i] == '1') {
			count += 1;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//void mysort(vector<int> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<int> &a){reverse(a.begin(),a.end()) ;}

void min_root(vvc &meiro,vvll &cnt,int i,int j,int n){
	if(n>=cnt.at(i).at(j)) return ;
	cnt.at(i).at(j) = n ;
	if(meiro.at(i-1).at(j)=='.') min_root(meiro,cnt,i-1,j,n+1) ;
	if(meiro.at(i+1).at(j)=='.') min_root(meiro,cnt,i+1,j,n+1) ;
	if(meiro.at(i).at(j-1)=='.') min_root(meiro,cnt,i,j-1,n+1) ;
	if(meiro.at(i).at(j+1)=='.') min_root(meiro,cnt,i,j+1,n+1) ;
	return ;
}

int main(){
	int h,w ;
	cin >> h >> w ;
	vvc meiro(h+2,vc(w+2,'#')) ;
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) cin >> meiro.at(i).at(j) ;
	ll mn = 0 ;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(meiro.at(i).at(j)=='#') continue ;
			vvll cnt(h+2,vll(w+2,10000)) ;
			min_root(meiro,cnt,i,j,0) ;
			ll mx = 0 ;
			for(int ii=1;ii<=h;ii++){
				for(int jj=1;jj<=w;jj++){
					if(meiro.at(ii).at(jj)=='.'&&cnt.at(ii).at(jj)>mx) mx = cnt.at(ii).at(jj) ;
				}
			}
			if(mn<mx) mn = mx ;
		}
	}
	cout << mn << endl ;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

const ll NMX=100000;
vl G[NMX];
vl B;
map<P,ll> mp;
vP p;
ll ans;

bool dfs(ll x,ll y,ll c){//from,to,color&&skip
  if(mp[{x,y}]==-1){
    mp[{x,y}]=c;
  }
  else if(mp[{y,x}]==-1){
    mp[{y,x}]=c;
  }
  B[y]=1;
  ans=max(ans,c+1);
  ll k=G[y].size();
  ll j=0;
  rep(i,k){
    if(j==c){
      j++;
    }
    if(B[G[y][i]]==-1){
      dfs(y,G[y][i],j);
      j++;
    }
    else if(B[G[y][i]]!=-1){
      continue;
    }
  }
}
int main() {
  ans=0;
  ll N;
  cin >> N;
  p.resize(N-1);
  rep(i,N-1){
    ll a,b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
    p[i].first=a;
    p[i].second=b;
  }
  rep(i,N-1){
    mp[{p[i].first,p[i].second}]=-1;
  }
  ll k=G[0].size();
  B.assign(N,-1);
  B[0]=1;
  rep(i,k){
    dfs(0,G[0][i],i);
  }
  cout << ans << endl;
  rep(i,N-1){
    cout << mp[{p[i].first,p[i].second}]+1 << endl;
  }
}

Measured memory_bytes: 16768
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int n,r;cin>>n>>r;
  cout << 100*max(0,10-n)+r << endl;
}

Measured memory_bytes: 256
from __future__ import division
import io, sys, atexit, os, itertools
sys.stdout = io.BytesIO()
atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))
sys.stdin = io.BytesIO(sys.stdin.read())
raw_input = lambda: sys.stdin.readline().rstrip()

a, b, c = map(int, raw_input().split())
if b-a == c-b:
	print('YES')
else:
	print('NO')

Measured memory_bytes: 28524
#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;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int32_t main()
{
	AB_BHI_NI_DEGI
	//freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int ac = 0, wa = 0, tle = 0, re = 0;
	while (n--)
	{
		string s;
		cin >> s;
		if (s == "AC")
			ac++;
		if (s == "WA")
			wa++;
		if (s == "TLE")
			tle++;
		if (s == "RE")
			re++;
	}
	cout << "AC x " << ac << "\n";
	cout << "WA x " << wa << "\n";
	cout << "TLE x " << tle << "\n";
	cout << "RE x " << re << "\n";
	return 0;
}

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

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

            var max = 1;
            var min = 1000000000;

            foreach (var item in A)
            {
                var value = int.Parse(item);
                max = Math.Max(value, max);
                min = Math.Min(value, min);
            }

            Console.WriteLine(max - min);
        }
    }
}

Measured memory_bytes: 11092
n = int(input())
cs = {0: n}  # old, current
used = {n: True}
for i in range(1, 10000000):
  cs[i] = cs[i-1] // 2 if cs[i-1] % 2 == 0 else cs[i-1]*3 +1
  if cs[i] in used:
      break
  used[cs[i]] = True
print(i + 1)


Measured memory_bytes: 3060
def check(S) :
    mae = int(S[:2])
    ato = int(S[2:])
    
    if mae == 0 and ato <= 12 and ato > 0 :
        return "YYMM"
    if ato == 0 and mae <= 12 and mae > 0 :
        return "MMYY"
    
    if mae == 0 or ato == 0 :
        return "NA"
    if mae > 12 and ato > 12 :
        return "NA"
    if mae <= 12 and ato <= 12 :
        return "AMBIGUOUS"
    if mae > 12 :
        return "YYMM"

    return "MMYY"
    
    

S = input()
print(check(S))


Measured memory_bytes: 3060
N = int(input())
al = 26
i = 1
while N > al**i:
    N -= al**(i)
    i += 1
ans = ''
a = ord('a')
while i > 0:
    ans += chr(a + (N-1) // al**(i-1))
    N = (N-1) % al**(i-1) + 1
    i -= 1
print(ans)

Measured memory_bytes: 9184
#include<iostream>
    #include<algorithm>
     
    using namespace std;
    typedef long long Int;
     
    Int n, p, cnt[1080000];
    int main(){
      cin >> n >> p;
      if(n == 1){
        cout << p << endl;
        return 0;
      }
      for(Int i = 2;i*i <= p;i++){
        while(p % i == 0){
          p /= i;
          cnt[i]++;
        }
      }
      Int res = 1;
      for(Int i = 2;i < 1080000;i++){
        for(Int j = 0;j < cnt[i] / n;j++){
          res *= i;
        }
      }
      cout << res << endl;
      return 0;
    }

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
typedef long long LL;
#define rep(i,N) for(int i=0;i<(LL)N;i++)
#define array(N,t) (t*)calloc(N,sizeof(t))
const int sz=1<<17;
const LL LINF=2e18;
int N,NG,OK,BASE,minus;
LL K,L=-LINF,M,R=LINF,count;
inline char CH()
{
  static char buf[1<<17],*c1=buf+sz,c2;
  if(c1-buf==sz)fread_unlocked(buf,1,sz,stdin),c1=buf;
  return *c1++;
}
inline LL IN(void)
{
  LL x=0;short f=0,c=CH();
  while(c<48||c>57)f^=c==45,c=CH();
  while(c>47&&c<58)x=x*10+c-48,c=CH();
  return f?-x:x;
}
signed main(void)
{
  N=IN(),K=IN();
  int *A=array(N,int);
  rep(i,N)A[i]=IN();
  std::sort(A,A+N);
  while(R-L>1)
  {
    M=(L+R)/2,count=0;
    rep(i,N)
    {
      NG=i,OK=N,minus=(A[i]<0);
      while(OK-NG>1)
      {
        BASE=(NG+OK)/2;
        if((LL)A[i]*A[BASE]<=M){if(minus)OK=BASE;else NG=BASE;}
        else{if(minus)NG=BASE;else OK=BASE;}
      }
      count+=(minus)?N-OK:NG-i;
    }
    if(count<K)L=M;else R=M;
  }
  free(A);
  return printf("%lld\n",R),0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

static const ll INF = 1e15;

const ll mod = 1000000007;

bool ok(const char* c, int size) {
	for (int i = 0; i < size / 2; i++) {
		if (c[i] != c[size - 1 - i]) {
			return false;
		}
	}
	return true;
}

int main(void)
{
	string s;
	cin >> s;
	const char* c = s.c_str();
	int size = s.size();
	if (!ok(c, size)) {
		cout << "No" << endl;
		return 0;
 	}
	if (!ok(c, (size - 1) / 2)) {
		cout << "No" << endl;
		return 0;
	}
	auto* start = c + (size + 3) / 2 - 1;
	auto* last = c + (size);
	if (!ok(c + (size + 3) / 2 - 1, last - start)) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}


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

long long int INF= 1e17+5;

void cmp(long long int & val1, long long int val2){
	if(val1>=val2 ){
      val1=val2;
	}
}

int main(){

  	int n;
  	cin>>n;
  	vector<long long int> inp(n);
  	vector<long long int> prefix_sums(n+1);
  	for(int i=0;i<n;i++) {
  		cin>>inp[i];
  		prefix_sums[i+1]=prefix_sums[i]+inp[i];
  	}
  	//tc[i][j] denotes the total cost incurred to combine slimes from i...j	
  	vector<vector<long long int>> tc( n+1, vector<long long int>(n+1, INF));
    for(int j=0;j<n;j++){
    	if((j-1)>=0)
           cmp(tc[j-1][j], inp[j-1]+inp[j]);
    	for(int i=(j-2);i>=0;i--){	
           	 cmp(tc[i][j], prefix_sums[j]- prefix_sums[i]+inp[j]+tc[i][j-1]);
           	 cmp(tc[i][j], prefix_sums[j+1]-prefix_sums[i+1]+inp[i]+tc[i+1][j]);
    		for(int k=i+1;k<(j-1);k++)
               cmp(tc[i][j], prefix_sums[j+1]-prefix_sums[i]+tc[i][k]+tc[k+1][j]);
    	// cout<<"the interval is "<<i<<" "<<j<<" "<<tc[i][j]<<endl;
    	}
         
    }
    
    cout<<tc[0][n-1]<<endl;

	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std; 
const int dx[]={1,0,-1,0,1,-1,-1,1}; 
const int dy[]={0,1,0,-1,1,1,-1,-1}; 
const int INF = 1e9; 
const long long LINF = 1e18; 
const double EPS = 1e-8; 
#define pb push_back
#define mk make_pair 
#define fr first 
#define sc second 
#define ll long long 
#define reps(i,j,k) for(int i = (j); i < (k); ++i) 
#define rep(i,j) reps(i,0,j) 
#define all(a) (a).begin(),(a).end() 
#define MOD 1000000007 
typedef pair<int,int> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;

int main(){
	int N;
	cin >> N;
	int sum = 0;
	int a = 0;
	int un = 0;
	bool flg = true;
	rep(i,N){
		string str;
		cin >> str;
		if(str == "A"){
			a++;
			sum++;
		}
		else{
			if(a > 0){
				un++;
				--a;	
			}
			else{
				flg = false;
			}
		}
	}
	if(sum != un){
		flg = false;
	}
	puts(flg?"YES":"NO");
	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
using namespace std;
int main()
{
  int A, B;
	cin >> A >> B;
  for (int i = 1; i <= 1100; i++) {
    if (i*8/100==A && i*10/100==B) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
priority_queue<int, vector<int>, less<int> > que;
int main() {
    int N, M;
    while (cin >> N >> M) {
        long long t;
        for (int i = 1; i <= N; i++) {
            cin >> t;
            que.push(t);
        }
        for (int i = M; i != 0; i--) {
            t = que.top();
            que.pop();
            t /= 2;
            que.push(t);
        }
        long long sum = 0;
        int len = que.size();
        for (int i = 1; i <= len; i++) {
            sum += que.top();
            que.pop();
        }
        cout << sum << endl;
    }
    return 0;
}

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

int main(){
    int h,n,i,tmp;
    cin>>h>>n;

    for(i=0;i<n;i++){
        cin>>tmp;
        h-=tmp;
    }

    h<=0 ? cout<<"Yes" : cout<<"No";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int samecount(string S){
    int A = 0;
    for(int i = 0;i < S.size();i++){
        int QA = 1;
        for(int j = i ;j < S.size() - 1;j++){
           if(S.at(j) == S.at(j + 1)){
               QA++ ;
           }
           if(S.at(j) != S.at(j + 1)){
               break;
           }
           
        }
        A = max(QA,A);
    }
    return A;
}

int64_t minn(int64_t a,int64_t b){
    if(a >= b) return b;
    else return a;
}
int main(){
    int N;
    cin >>N;
    vector<int>  A(N);
    for(int i = 0;i <N;i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    cout << abs(A[0] - A[N-1]) << endl;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>

#define sz(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define all(a) (a).begin(), (a).end()
#define ar vector
#define vse(a) a.begin(), a.end()

#ifdef LOCAL
	#define dbg(x) cout << #x << " = " << x << endl;
#else 
	#define dbg(x)
#endif 

using namespace std;

void solve(); signed main() {
#ifdef LOCAL
    freopen("file1.txt", "r", stdin);                                       
    freopen("file2.txt", "w", stderr);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(15);
    solve();  	
}

const int MAXN = 2e5 + 10;                                      
int n;
int ans[MAXN];
vector<pair<int, int>> g[MAXN]; 

int f(int num) {
 	if (num == 0) {
 	    return 1;
 	}	
 	else {
 	 	return 0;
 	}
}

void dfs(int v, int p = -1) {
	for (auto it : g[v]) {
		int u = it.x, wt = it.y;
		if (u == p) {
		    continue;
		}	
		if (wt % 2 == 0) {
		 	ans[u] = ans[v];
	    }
	    else {
	     	ans[u] = f(ans[v]);
	    }
	    dfs(u, v);
 	}
}    	

void solve() {                                
	cin >> n;	
	for (int i = 0; i < n - 1; ++i) {
	 	int u, v, w;
	 	cin >> u >> v >> w;
	 	u--, v--;
	 	g[u].push_back({v, w});
	 	g[v].push_back({u, w});
	}

	dfs(0);

	for (int v = 0; v < n; ++v) {
	 	cout << ans[v] << endl;
	}
}	 		



Measured memory_bytes: 13312
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

int main(){
  int a,b;
  cin>>a>>b;
  int n;
  n = b + a*pow(10,(int)log10(b)+1);
  bool flag = false;
  for(int i = 0; i<=sqrt(n)+1; i++){
      if(i*i==n){
          flag = true;
      }
  }
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

int main(){
    int n;
    cin>>n;
    int x[n],y[n];
    for(int i=0;i<n;i++) cin>>x[i]>>y[i];
    double ans=0.0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            double dx=x[i]-x[j];
            double dy=y[i]-y[j];
            ans+=sqrt(dx*dx+dy*dy);
        }
    }
    cout<<fixed<<setprecision(10)<<2*ans/n<<endl;
}

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

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

    std::vector<int> res(N, 0);

    for (auto i = 2; i <= N; i++) {
        int Ai;
        std::cin >> Ai;

        res.at(Ai - 1)++;
    }

    for (auto res_elem : res) {
        std::cout << res_elem << std::endl;
    }

    return 0;
}

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



int main() {
	string S[60];
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	
	int dx[8] = { 0, 0, 1, 1, 1, -1, -1, -1 };
	int dy[8] = { 1,-1, 0, 1,-1, 0, 1,-1 };
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			
			if (S[i][j] == '.') {
				int num = 0;
				for (int k = 0; k < 8; k++) {
					int ni = i + dy[k];
					int nj = j + dx[k];
					if (ni >= 0 && ni < H && nj >= 0 && nj < W && S[ni][nj] == '#') {
						num++;
					}	
				}
				S[i][j] = char('0' + num);
			}
		}
	}
	for (int i = 0; i < H; i++) {
		cout << S[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int64_t N, A, B;
  cin >> N >> A >> B;
  
  int64_t c = A + B;
  int64_t rest = N % c;
  int64_t div = N / c;
  
  if(rest >= A){
    rest = A;
  }
  
  cout << div * A + rest << endl;
  
}

Measured memory_bytes: 256
def bubble_sort(c, n)
  (0...n).each{|i|
    (n - 1).downto(i + 1){|j|
      c[j], c[j - 1] = c[j - 1], c[j] if c[j][1] < c[j - 1][1]
    }
  }
  c
end

def selection_sort(c, n)
  (0...n).each{|i|
    minj = i
    (i...n).each{|j|
      minj = j if c[j][1] < c[minj][1]
    }
    c[i], c[minj] = c[minj], c[i] if minj != i
  }
  c
end

n = gets.to_i
arr = gets.chomp.split
b_arr = bubble_sort(arr.dup, n)
s_arr = selection_sort(arr.dup, n)

puts b_arr.join(' ')
puts 'Stable'
puts s_arr.join(' ')
if b_arr == s_arr
  puts 'Stable'
else
  puts 'Not stable'
end


Measured memory_bytes: 6876
#include<iostream>
using namespace std;
int a,b;
int main(){
    cin>>a>>b;
    if(b==1)cout<<0<<endl;
    else if(b-a<=0)cout<<1<<endl;
    else{
        b-=a;
        cout<<(b+a-2)/(a-1)+1<<endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#define scanf __builtin_scanf
#include <vector>
#include <map>
using namespace std;

vector<pair<int, int>> g[100010];
int col[100010];

void dfs(int v, int p, int b)
{
    if (b==0) col[v]=1;

    for(auto& e: g[v]) {
        int u=e.first;
        int w=e.second;
        if (u==p) continue;
        dfs(u, v, (b+w)%2);
    }
}
    
int main()
{
    int n; scanf("%d", &n);
    for(int i=0; i<n-1; ++i) {
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        --u, --v;
        g[u].emplace_back(v, w);
        g[v].emplace_back(u, w);
    }
    dfs(0, -1, 0);
    for(int i=0; i<n; ++i) printf("%d\n", col[i]);
}


Measured memory_bytes: 8320
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int64_t N,M;
    cin >> N >> M;
    vector<pair<int64_t,int64_t>> vec(N);

    rep(i,N) {
        int64_t a,b;
        cin >> a >> b;
        vec.at(i).first = a;
        vec.at(i).second = b;
    }

    int64_t money = 0;
    int64_t sum = 0;

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

    rep(i,N) {
        sum += vec.at(i).second;
        if (sum >= M) {
            int64_t deff = sum - M;
            money += vec.at(i).first * (vec.at(i).second - deff);
            break;
        }
        money += vec.at(i).first * vec.at(i).second;
    }

    cout << money << endl;
}

Measured memory_bytes: 1792
from collections import Counter

def main():
    n = int(input())
    lst = []
    for _ in range(n):
        lst.append(input())
    c = Counter(lst)

    print("AC x {}".format(c["AC"]))
    print("WA x {}".format(c["WA"]))
    print("TLE x {}".format(c["TLE"]))
    print("RE x {}".format(c["RE"]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 16612
n=int(input())
card=list()
for i in range(4):
    mark=[0]*13
    card.append(mark)
for i in range(n):
    pattern,number=map(str,input().split())
    if pattern=='S':
        card[0][int(number)-1]=1
    elif pattern=='H':
        card[1][int(number)-1]=1
    elif pattern=='C':
        card[2][int(number)-1]=1
    else:
        card[3][int(number)-1]=1
for i in range(4):
    for j in range(13):
        if card[i][j]!=1:
            if i==0:
                print("S",j+1)
            elif i==1:
                print("H",j+1)
            elif i==2:
                print("C",j+1)
            else:
                print("D",j+1)


Measured memory_bytes: 5612