akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
#include <map>
using ll = long long int;
using namespace std;

int main()
{
    int N, A, B, ans = 0, b = 0;
    string S;
    cin >> N >> A >> B >> S;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'a')
        {
            if (ans < (A + B))
            {
                ans++;
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
        }
        else if (S[i] == 'b')
        {
            b++;
            if ((ans < (A + B)) && (b <= B))
            {
                ans++;
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
        }
        else
        {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

// ll m_lcm(vector<int> &a, int lv, int n){
// 	if(lv == 2){
// 		ll g = __gcd(a.at(lv-2), a.at(lv-1));
// 		ll l = a.at(lv-2) * a.at(lv-1);
// 		l /= g;
// 		return l;
// 	}else{
// 		ll lm = m_lcm(a, lv-1, n);
// 		ll g = __gcd(lm, (ll)a.at(lv-1));
// 		ll l = lm * a.at(lv-1);
// 		l /= g;
// 		return l;
// 	}
// }

int main(){
	int n, m;
	cin >> n >> m;
	vector<ll> a(n);
	rep(snip_i, n) cin >> a.at(snip_i);
	int c;
	rep(i, n){
		if(i == 0){
			c = 0;
			ll temp = a.at(0);
			while(1){
				if(temp % 2 == 0){
					temp /= 2;
					c++;
				}else{
					break;
				}
			}
		}else{
			int ct = 0;
			ll temp = a.at(i);
			while(1){
				if(temp % 2 == 0){
					temp /= 2;
					ct++;
				}else{
					break;
				}
			}
			if(ct != c){
				cout << 0 << endl;
				return 0;
			}
		}
	}
	rep(i, n) a.at(i) /= 2;
	ll l = a.at(0);
	rep2(i, 1, n){
		ll g = __gcd(l, a.at(i));
		l /= g;
		l *= a.at(i);
	}
	// cerr << l << endl;
	int ans = m / l - m / (2*l);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main(){
    string a;
    cin>>a;
    if(a>="A" && a<="Z"){
        cout<<"A"<<endl;
    }
    else if(a>="a" && a<="z"){
        cout<<"a"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
int len = 500000;
vector<int>L(len / 2), R(len / 2);
int merge(vector<int>&a, int l, int r) {
	int mid = (l + r) / 2;
	int n1 = (mid - l), n2 = (r - mid);
	int ret(0);
	rep(i, 0, n1)L[i] = a[l + i];
	L[n1] = INF;
	rep(i, 0, n2)R[i] = a[mid + i];
	R[n2] = INF;
	int i(0), j(0);
	rep(k, l, r) {
		if (L[i] < R[j])a[k] = L[i++];
		else {
			ret += (n1 - i);
			a[k] = R[j++];
		}
	}
	return ret;
}
int mergesort(vector<int>&a, int l, int r) {
	if (r - l > 1) {
		int mid = (l + r) / 2;
		return mergesort(a, l, mid) +
			mergesort(a, mid, r) +
			merge(a, l, r);
	}
	else return 0;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> v(N); rep(i, 0, N) { cin >> v[i]; }
	cout << mergesort(v,0,N) << endl;
	return 0;
}

Measured memory_bytes: 8328
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,K; cin>>N>>K;
  vii A(N);
  rep(i,0,N-1){
    int X,Y; cin>>X>>Y;
    A[X-1].pb(Y-1);
    A[Y-1].pb(X-1);
  }
  vector<bool> F(N,1);
  F[0]=0;
  queue<int> Q;
  Q.push(0);
  int ans=K;
  while(Q.size()>0){
    int X=Q.front();
    Q.pop();
    int count=1;
    rep(i,0,A[X].size()){
      int Y=A[X][i];
      if(F[Y]){
        F[Y]=0;
        Q.push(Y);
      }
      else
        count++;
    }
    int sum=A[X].size()+1;
    rep(i,0,sum-count){
      ans*=max(0ll,K-count-i);
      ans%=MOD;
    }
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 7284
#pragma comment(linker, "/STACK:512000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
#ifdef AIM
#include <sys/resource.h>
#endif
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(__attribute__((unused)) bool);
void precalc();
clock_t start;
#define FILENAME ""

int main() {
#ifdef AIM
  string s = FILENAME;
//    assert(!s.empty());
  freopen("/home/alexandero/ClionProjects/cryptozoology/input.txt", "r", stdin);
  //freopen("/home/alexandero/ClionProjects/cryptozoology/output.txt", "w", stdout);
#else
//    freopen(FILENAME ".in", "r", stdin);
//    freopen(FILENAME ".out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
#ifndef AIM
  cout.sync_with_stdio(0);
  cin.tie(0);
#endif

#ifdef AIM
  const rlim_t kStackSize = 256 * 1024 * 1024;
  struct rlimit rl;
  int result;

  result = getrlimit(RLIMIT_STACK, &rl);
  if (result == 0)
  {
    if (rl.rlim_cur < kStackSize)
    {
      rl.rlim_cur = kStackSize;
      result = setrlimit(RLIMIT_STACK, &rl);
      if (result != 0)
      {
        fprintf(stderr, "setrlimit returned result = %d\n", result);
      }
    }
  }
#endif

  precalc();
  cout.precision(10);
  cout << fixed;
  //cin >> t;
  int testNum = 1;
  while (t--) {
      //cout << "Case #" << testNum++ << ": ";
      solve(true);
  }
  cout.flush();
#ifdef AIM1
    while (true) {
      solve(false);
  }
#endif

#ifdef AIM
  cout.flush();
  auto end = clock();

  usleep(10000);
  print_stats(end - start);
  usleep(10000);
#endif

    return 0;
}

template<typename T>
T binpow(T q, T w, T mod) {
    if (!w)
        return 1 % mod;
    if (w & 1)
        return q * 1LL * binpow(q, w - 1, mod) % mod;
    return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
    while (w) {
        q %= w;
        swap(q, w);
    }
    return q;
}
template<typename T>
T lcm(T q, T w) {
    return q / gcd(q, w) * w;
}

template <typename T>
void make_unique(vector<T>& a) {
    sort(all(a));
    a.erase(unique(all(a)), a.end());
}

template<typename T>
void relax_min(T& cur, T val) {
    cur = min(cur, val);
}

template<typename T>
void relax_max(T& cur, T val) {
    cur = max(cur, val);
}

void precalc() {
}

//#define int li
//const int mod = 1000000007;

void solve(__attribute__((unused)) bool read) {
  int x;
  cin >> x;
  cout << 360 / gcd(360, x) << "\n";
}

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

int main(){
  int N;
  cin >> N;
  int x = sqrt(N);
  cout << x * x << endl;
}


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>;
using Graph = vector<vector<int>>;
 
int main(){
    vector<vector<int>> A(3);
    vector<int> B;
    rep(i, 3){
        rep(j, 3){
            int tmp;
            cin >> tmp;
            A.at(i).push_back(tmp);
        }
    }

    int N; cin >> N;
    rep(i, N){
        int tmp;
        cin >> tmp;
        B.push_back(tmp);
    }

    vector<vector<int>> bingo = {
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0},
    };
    rep(i, 3){
        rep(j, 3){
            rep(k, N){
                if(A[i][j]==B[k]) bingo[i][j] = 1;
            }
        }
    }

    rep(i, 3){
        if(bingo[i][0]==1 && bingo[i][1]==1 && bingo[i][2]==1){
            cout << "Yes" << endl;
            return 0;
        }
        if(bingo[0][i]==1 && bingo[1][i]==1 && bingo[2][i]==1){
            cout << "Yes" << endl;
            return 0;
        }
        if(bingo[0][0]==1 && bingo[1][1]==1 && bingo[2][2]==1){
            cout << "Yes" << endl;
            return 0;
        }
        if(bingo[0][2]==1 && bingo[1][1]==1 && bingo[2][0]==1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	string S;
	cin >> S;

	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] == '9') S[i] = '1';
		else if (S[i] == '1') S[i] = '9';
	}

	cout << S;

	return 0;
}


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

int D[10];

bool ok(int n) {
  while (n) {
    if (D[n%10]==0) {
      n/=10;
    } else {
      return false;
    }
  }
  return true;
}
int main() {
  int N,K;
  cin>>N>>K;
  for (int i=0; i<K; i++) {
    int d;
    cin>>d;
    D[d]=1;
  }
  while (!ok(N)) {
    N++;
  }
  cout<<N<<endl;
  return 0;
}



Measured memory_bytes: 256
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define maxn 100005
#define mod 1000000007
#include <bits/stdc++.h>
using namespace std;

ll dp[100006];

ll mul(ll x, ll y){
    ll res = ( (x%mod) * (y%mod))%mod;
    return res;
}

ll add(ll x, ll y){
    ll res = ( (x%mod) + (y%mod))%mod;
    return res;
}

ll sub(ll x, ll y){
    ll res = (( (x%mod) - (y%mod)) + mod)%mod;
    return res;
}

ll bigmod(ll a, ll b){
    if(b == 0) return 1;
    ll res = bigmod(a, b/2);
    if(b%2) return mul(a, mul(res, res));
    return mul(res, res);
}



int main() {
    ll n, k, res = 0, way;
    cin >> n >> k;
    way = bigmod(k, n);
    for(ll i=k;i>=1;i--){
        dp[i] = bigmod(k/i , n);
        for(ll j=i+i;j<=k;j+=i){
            dp[i] = sub(dp[i], dp[j]);
        }
        //cout << dp[i] << endl;
        /*ll divs = (k/i);
        ll x = bigmod(divs , n);

        cout << i << " " << x << endl;
        way = sub(way, x);
        x = mul(x, i);
        res = add(res, x);
        */
    }
    for(ll i=1;i<=k;i++){
        res = add(res, mul(dp[i], i));
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 4308
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
int main(){
    int n,judge[4]={0};
    string S;
    cin >> n;
    rep(i,n){
        cin >> S;
        if(S == "AC"){
            judge[0]++;
        }else if(S == "WA"){
            judge[1]++;
        }else if(S == "TLE"){
            judge[2]++;
        }else if(S == "RE"){
            judge[3]++;
        }
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d",judge[0],judge[1],judge[2],judge[3]);

    return 0;
}

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

#define INF INT_MAX/2
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

   vector<int>x(3);
   for(int i=0;i<3;i++)cin>>x[i];
   sort(x.begin(),x.end());
   cout<<x[2]*10+x[0]+x[1]<<endl;
   return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
k,n=map(int, input().split())
a=list(map(int, input().split()))
b=0
for i in range(n-1):
  b=max(b, a[i+1]-a[i])
b=max(b,a[0]+k-a[n-1])
print(k-b)

Measured memory_bytes: 25876
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*

fun resolveOp(lhs: Int, op: String, rhs: Int): Int =
        when (op) {
            "+" -> lhs + rhs
            "*" -> lhs * rhs
            "-" -> lhs - rhs
            else -> throw UnsupportedOperationException()
        }

fun main(args: Array<String>) {
    val expr = BufferedReader(InputStreamReader(System.`in`))
            .readText()
            .trim()
            .split(regex = """\s+""".toRegex())

    val nuStack = ArrayDeque<Int>()

    for (item in expr) {
        if (item.matches("""\d+""".toRegex())) {
            nuStack.addLast(item.toInt())
        } else {
            val rhs = nuStack.removeLast()
            val lhs = nuStack.removeLast()
            nuStack.addLast(resolveOp(lhs, item, rhs))
        }
    }



    println(nuStack.first)

}


Measured memory_bytes: 29620
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int s = sc.nextInt();

		int l = s/100;
		int r = s%100;

		String ans = "NA";

		if(0<l&&l<13&&0<r&&r<13)ans="AMBIGUOUS";
		if(0<l&&l<13&&(r<1||12<r))ans="MMYY";
		if((l<1||12<l)&&0<r&&r<13)ans="YYMM";

		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 22228
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll answer = 0;
    REP(i,s.length()-1){
        if(s[i]!=s[i+1])answer++;
    }
    cout << answer+1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<queue>
#include<vector>
using namespace std;
const long long INF=200000000000000000LL;
typedef pair<int,int> P;
int main(){
	long long ans,k=0,al[27]={};
	string str;
	cin>>str;
	long long N=str.size();
	for(int i=0;i<str.size();++i){
		al[str[i]-'a']++;
	}
	for(int i=0;i<26;++i){
		k+=(al[i]*(al[i]-1))/2;
	}
	//if(str[str.size()-1]==str[str.size()-2])que.push(P(str.size()-2,str.size()-1));
	//cout<<que.size()<<endl;
	cout<<(N*(N-1))/2+1-k<<endl;
	return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int n, k;
vector< vector<int> > cnt;

template<typename T>
bool chmax(T &_a, T _b){
    if(_a < _b){
        _a = _b;
        return true;
    }else{
        return false;
    }
}

int calc(int i, int j){
    int res = cnt[i][j] - cnt[i][max(j - k, 0)] - cnt[max(i - k, 0)][j] + cnt[max(i - k, 0)][max(j - k, 0)];
    res += cnt[min(i + k, k * 2)][min(j + k, k * 2)] - cnt[min(i + k, k * 2)][j] - cnt[i][min(j + k, k * 2)] + cnt[i][j];
    res += cnt[min(i + k, k * 2)][max(j - k, 0)] - cnt[min(i + k, k * 2)][max(j - k * 2, 0)] - cnt[i][max(j - k, 0)] + cnt[i][max(j - k * 2, 0)];
    res += cnt[max(i - k, 0)][min(j + k, k * 2)] - cnt[max(i - k, 0)][j] - cnt[max(i - k * 2, 0)][min(j + k, k * 2)] + cnt[max(i - k * 2, 0)][j];
    res += cnt[max(i - k, 0)][max(j - k, 0)] - cnt[max(i - k, 0)][max(j - k * 2, 0)] - cnt[max(i - k * 2, 0)][max(j - k, 0)] + cnt[max(i - k * 2, 0)][max(j - k * 2, 0)];
    return max(res, n - res);
}

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

    cin >> n >> k;

    cnt.resize(k * 2 + 1, vector<int>(k * 2 + 1, 0));
    rep(i, n){
        int x, y;
        char c;
        cin >> x >> y >> c;
        if(c == 'B'){
            x += k;
        }
        x %= (k * 2);
        y %= (k * 2);
        ++x;
        ++y;
        ++cnt[y][x];
    }

    reps(i, k * 2){
        reps(j, k * 2){
            cnt[i][j] += cnt[i][j - 1];
        }
    }

    reps(j, k * 2){
        reps(i, k * 2){
            cnt[i][j] += cnt[i - 1][j];
        }
    }

    int ans = 0;
    REP(i, k, k * 2 + 1){
        REP(j, k, k * 2 + 1){
            chmax(ans, calc(i, j));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 16000
#include <stdio.h>
#define max(p,q)((p)>(q)?(p):(q))

//辺の情報を個別に持つタイプ
int n;
int oya[30];
int ko1[30],ko2[30];

int dep(int k){
	if(oya[k]==-1)return 0;
	return dep(oya[k])+1;
}

int hai(int k){
	int ans=0;
	if(ko1[k]!=-1)ans=max(ans,hai(ko1[k])+1);
	if(ko2[k]!=-1)ans=max(ans,hai(ko2[k])+1);
	return ans;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)oya[i]=-1;
	for(int i=0;i<n;i++){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		ko1[x]=y;
		ko2[x]=z;
		oya[y]=x;
		oya[z]=x;
	}
	for(int i=0;i<n;i++){
		printf("node %d: parent = %d, sibling = %d, degree = %d, ",i,oya[i],oya[i]==-1?-1:ko1[oya[i]]+ko2[oya[i]]-i,(ko1[i]!=-1)+(ko2[i]!=-1));
		int d=dep(i),h=hai(i);
		printf("depth = %d, height = %d, %s",d,h,d==0?"root":h==0?"leaf":"internal node");
		puts("");
	}
}




Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s];i;i=e[i].nxt)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl

using namespace std;
typedef long long ll;

int n,m,t,sum;

int main(){
	si(n),si(m);
	repi(i,1,m){
		si(t);
		sum += t;
	}
	if(sum > n)
		cout<<-1<<endl;
	else
		cout<<n - sum<<endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int max(int a,int b){if(a>b)return a; return b;}
int min(int a,int b){if(a>b)return b; return a;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

vector<vector<long long>> comb(int n, int r) {
  vector<vector<long long>> v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

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

	V prime={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
	map<int,int> cnt;
	for(int i=2;i<=n;++i){
		int x=i;
		for(const auto&a:prime){
			while(x%a==0){
				cnt[a]++;
				x/=a;
			}
			if(x==0)break;
		}
	}
	int A75=0,A25=0,A15=0,A5=0,A3=0;
	for(const auto&a:cnt){
		Pi b=a;
		int aa=b.se;
		if(aa>=74)A75++;
		else if(aa>=24)A25++;
		else if(aa>=14)A15++;
		else if(aa>=4)A5++;
		else if(aa>=2)A3++;		
	}
	//debg(A75);debg(A25);debg(A15);debg(A5);debg(A3);
	int res=A75;
	res+=(A75+A25)*(A75+A25-1+A15+A5+A3);
	res+=(A75+A25+A15)*(A75+A25+A15-1+A5);
	res+=(A75+A25+A15+A5)*(A75+A25+A15+A5-1)/2*(A75+A25+A15+A5+A3-2);

	out(res);

  return 0;
}



Measured memory_bytes: 256
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

L = ir()
edges = []
length = L.bit_length()
for i in range(1, length):
    edges.append((i, i+1, 2**(i-1)))
    edges.append((i, i+1, 0))

# 2**(length-1)-1までの数は完了
# Lに近い切れ端から処理していく
for i in range(length-1):
    if L >> i & 1:
        L -= 2 ** i
        edges.append((i+1, length, L))

print(length, len(edges))
for x in edges:
    print(*x)


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

using p_int = pair<int, int>;
const int INF = -1;

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

    int h, w;
    cin >> h >> w;
    char maze[w][h];
    int d[w][h];
    int dx[4] = { 1, 0, -1, 0 } ;
    int dy[4] = { 0, 1, 0, -1 };

    queue<p_int> que;
    int block = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            d[j][i] = INF;
            cin >> maze[j][i];
            block += maze[j][i] == '#';
        }
    }

    que.push(p_int(0, 0));
    d[0][0] = 1;
    while (!que.empty()) {
        p_int p = que.front();
        que.pop();
        if (p.first == w && p.second == h) break;
        for (int i = 0; i < 4; ++i) {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if (0 <= nx && nx < w && 0 <= ny && ny < h && maze[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(p_int(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }

    
    if (d[w - 1][h - 1] == -1) {
        cout << "-1\n";
    } else {
        cout << w * h - d[w - 1][h - 1] - block << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
import numpy as np

Xin, Yin = input().split()

X = int(Xin)
Y = int(Yin)

a = np.array([[1, 1], [2, 4]])
b = np.array([X, Y])

result = np.linalg.solve(a, b)

if result[0].is_integer() and result[0] >= 0:
    if result[1].is_integer() and result[1] >= 0:
      print('Yes')
    else:
      print('No')
else:
  print('No')

Measured memory_bytes: 27456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
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 (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    ll A, B; cin >> A >> B;
    cout << A*B << "\n";
}


Measured memory_bytes: 3620
#include<iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int* a = new int[n];
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	int count = 0;
	int minj;
	for (int i = 0;i < n - 1;i++) {
		minj = i;
		for (int j = i + 1;j < n;j++) {
			if (a[j] < a[minj])minj = j;
		}
		if (minj != i) {
			count++;
			swap(a[i], a[minj]);
		}
	}
	for (int i = 0;i < n - 1;i++) {
		cout << a[i] << " ";
	}
	cout << a[n - 1] << endl << count << endl;
}


Measured memory_bytes: 3120
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String s=sc.next();
        sc.close();
        int count=0;
        boolean[][] ary=new boolean[3][10];
        for(int i=0;i<10;i++){
            int ind=s.indexOf(i+'0');
            if(ind>=0&&ind<=n-2){
                for(int j=0;j<10;j++){
                    int jnd=s.indexOf(j+'0',ind+1);
                    if(jnd>=0&&jnd<=n-1){
                        for(int k=0;k<10;k++){
                            if(s.indexOf(k+'0',jnd+1)>=0){
                                count++;
                            }
                        }
                    }
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 24020
//
// Created by wulang on 10/10/16.
//
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
    if (argc == 2) {
        freopen(argv[1], "r", stdin);
    }

    int n;
    while(cin>>n) {
        long long ans=0;
        int x=1,y;
        while(n--) {
            cin>>y;
            if(y>x) ans+=(y-1)/x, y=1;
            x=max(x,y+1);
        }
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
using System;

namespace ABC080B
{
    class Program
    {
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());
            int tmp_x = X;
            int fx = 0;
            while(tmp_x > 0){
              fx += tmp_x % 10;
              tmp_x /= 10;  
            }
            if(X % fx == 0){
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
s = input()
if s == 'SUN':
    print(7)
elif s == 'MON':
    print(6)
elif s == 'TUE':
    print(5)
elif s == 'WED':
    print(4)
elif s == 'THU':
    print(3)
elif s == 'FRI':
    print(2)
elif s == 'SAT':
    print(1)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;

int main(){
int n,a,b;
  cin>>n>>a>>b;
  
  if((b-a)%2==1){
    cout<<"Borys"<<endl;}
  if((b-a)%2==0){
    cout<<"Alice"<<endl;}
  
  
  
}

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

int main() {
	int N, X, S;
	cin >> N;
	X = N;
	while (X > 0) {
		S += X % 10;
		X /= 10;
	}
	
	if (N % S == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3600
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		
		if(a.matches("[A-Z]")){
			System.out.println("A");
		}else {
			System.out.println("a");
		}
		
		sc.close();
	}
}


Measured memory_bytes: 35536
import numpy as np


def main(X, N, a):
    a.append(10000000000)
    a.append(-10000000000)
    a.sort()
    maxn = a[0]-1
    for i in range(len(a)-1):

        if a[i] >= X:
            if a[i+1]-a[i] > 1:
                if X-maxn>a[i]+1-X:
                    maxn = a[i]+1
                break
            if X-maxn < a[i]-X:
                break
        else:
            if a[i+1]-a[i] > 1:
                if a[i+1] > X and a[i] < X:
                    maxn = X
                    break
                maxn = a[i+1]-1

    return maxn


X, N = map(int, input().split())
try:
    a = list(map(int, input().split()))
except:
    a = []
print(main(X, N, a))


Measured memory_bytes: 26992
import java.util.*;


public class Main {
    private static int[][] c;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        c = new int[10][10];
        int[][] a = new int[h][w];
        for (int i = 0 ; i < 10 ; i++) {
            for (int j = 0 ; j < 10 ; j++) {
                c[i][j] = sc.nextInt();
            }
        }
        for (int i = 0 ; i < h ; i++) {
            for (int j = 0 ; j < w ; j++) {
                a[i][j] = sc.nextInt();
            }
        }

        for (int i = 0 ; i < 10 ; i++) {
            for (int j = 0 ; j < 10 ; j++) {
                for (int k = 0 ; k < 10 ; k++) {
                    c[j][k] = Math.min(c[j][k],c[j][i]+c[i][k]);
                }
            }
        }

        int cnt = 0;
        for (int i = 0 ; i < h ; i++) {
            for (int j = 0 ; j < w ; j++) {
                if (a[i][j] >= 0) cnt += c[a[i][j]][1];
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 44816
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cassert>

#define X first
#define Y second
#define PB push_back
#define int long long

using namespace std;

const int N = 1e5 + 500;
const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef pair < int , int > pii;

vector < int > v[N];
vector < int > t[N];
int siz[N], n, par[N];
ll dub[N];

void dfs(int x,int lst){
    siz[x] = 1;
    par[x] = lst;
    for(int y : v[x]){
        if(y == lst) continue;
        dfs(y, x);
        siz[x] += siz[y];
    }
}

void dfs2(int x,int lst){
    for(int i = 0;i<v[x].size();i++){
        if(v[x][i] == lst) continue;
        dub[v[x][i]] = dub[x] + t[x][i];
        dfs2(v[x][i], x);
    }
}

pii edg;
int pos = 0, rot = 1;


signed main(){
    scanf("%lld", &n);
    for(int i = 1;i<n;i++){
        int x, y, z;scanf("%lld %lld %lld", &x, &y, &z);
        v[x].PB(y);
        v[y].PB(x);
        t[x].PB(z);
        t[y].PB(z);
    }
    dfs(1, 1);
    for(int i = 1;i<=n;i++){
        if(2 * siz[i] == n){
            pos = 1; edg = {i, par[i]};
            break;
        }
        if(2 * siz[i] >= n && siz[i] < siz[rot]) rot = i;
    }
    ll fin = 0;
    if(!pos){
        dfs2(rot, rot);
        vector < ll > sol;
        for(int i = 1;i<=n;i++) sol.PB(dub[i]);
        sort(sol.begin(), sol.end());
        for(ll x : sol) fin += x;
        fin *= 2LL;
        fin -= sol[0] + sol[1];
    }
    else{
        dfs2(edg.X, edg.Y);
        dfs2(edg.Y, edg.X);
        vector < ll > sol;
        for(int i = 1;i<=n;i++) sol.PB(dub[i]);
        sort(sol.begin(), sol.end());
        for(ll x : sol) fin += x;
        fin *= 2LL;
        fin -= sol[0] + sol[1];
        ll vr = 0;
        for(int i = 0;i<v[edg.X].size();i++)
            if(v[edg.X][i] == edg.Y)
                vr = t[edg.X][i];
        fin += vr * (n - 1);
    }
    printf("%lld\n", fin);
}


Measured memory_bytes: 18808
def main(N, M, L, a, b):
    results = [[0]*L for i in range(N)]
    for n in range(N):
        for l in range(L):
            for m in range(M):
                results[n][l] += a[n][m]*b[m][l]
    results = [" ".join(map(str, i)) for i in results]
    return '\n'.join(map(str, results))


if __name__ == "__main__":
    N, M, L = map(int, input().split())
    a = [list(map(int, input().split())) for i in range(N)]
    b = [list(map(int, input().split())) for j in range(M)]
    print(main(N, M, L, a, b))



Measured memory_bytes: 7004
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back




int main(){
  
  string s;
  cin>>s;
  int q;
  cin>>q;
  int n=int(s.size());
  
  deque<char> dq;
  
  rep(i,n){
    dq.pb(s.at(i));
  }
  
  int cnt=0;
  
  rep(i,q){
    int ope;
    cin>>ope;
    if (ope==1){
      cnt++;
    }
    else {
      int f;
      cin>>f;
      char c;
      cin>>c;
      if ((cnt+f)%2==0){
        dq.pb(c);
        n++;
      }
      else {
        dq.push_front(c);
        n++;
      }
    }
  }
  
  string answer;
  
  rep(i,n){
    if (cnt%2==0){
      char tmp;
      tmp=dq.front();
      answer+=tmp;
      dq.pop_front();
    }
    else {
      char tmp;
      tmp=dq.back();
      answer+=tmp;
      dq.pop_back();
    }
  }
  
  cout<<answer<<endl;

  
}




















Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
int u[1100000];
vector<int> y;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e=0,f=0,g=0;
  cin >>a>>b>>c;
  if(c-a<0) e++;
  c=c-a;
  if(b-c<0) e++;
  if(e>0) cout <<"NO\n";
  else cout <<"YES\n";
  return (0);
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int A=sc.nextInt();
		String ans=null;

		if(N%500<=A) ans="Yes";
		else ans="No";

		System.out.println(ans);
	}
}

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

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h: u64 = read();
    let w: u64 = read();
    if h == 1 {
        println!("{}", 1);
    } else if w == 1 {
        println!("{}", 1);
    } else {
        let odd = ((w + 1) / 2) * ((h + 1) / 2);
        let even = (w / 2) * (h / 2);
        println!("{}", odd + even);
    }
}


Measured memory_bytes: 4352
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)

// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll A, B, K;
	cin >> A >> B >> K;
 
	// 解法
	for (ll i = 0; i < K; ++i){
		if (i%2==0){
			A = A/2;
			B = B + A;
		}
		else{
			B = B/2;
			A = A + B;
		}
	}
	
	//出力
	printf("%lld % lld\n", A, B); // lld としないとオーバーフローする
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by ko-sasaki on 2018/03/25.
 *
 * @author ko-sasaki
 */
public class Main {
    private int row;
    private int[] spots;
    private int allRouteCost;

    public Main(Scanner s) {
        this.row = s.nextInt();
        this.spots = new int[this.row + 2];
        this.spots[0] = 0; //最初
        this.spots[this.row + 1] = 0; //最後
        for(int i = 1 ; i <= this.row; i++){
            this.spots[i] = s.nextInt();
        }
    }

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        Main main = new Main(s);
        main.exec();
    }

    private void exec(){

        for(int i = 0; i <= this.row ; i++){
            this.allRouteCost += Math.abs(this.spots[i] - this.spots[i+1]);
        }

        for(int i = 1; i <= this.row ; i++){
            int result;
            result = this.allRouteCost - Math.abs(this.spots[i-1] - this.spots[i]);
            result -= Math.abs(this.spots[i] - this.spots[i+1]);
            result += Math.abs(this.spots[i-1] - this.spots[i+1]);
            System.out.println(result);
        }
    }
}


Measured memory_bytes: 71096
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false)
#define int long long
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF 0x3f3f3f3f

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

int x;
signed main() {
  IO;
  cin >> x;
  int now = 100;
  int cnt = 0;
  while (now < x){
    int k = now / 100;
    now += k;
    cnt++;
  }
  cout << cnt << '\n';
  return 0;
}

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

int main(){

    int w,x,y;
    while(cin >> w >> x >> y){
        if(w == x && x == y) cout << "1" << endl;
        else if(w!=x && x!=y && y!=w) cout << "3" << endl;
        else cout << "2" << endl;
    }
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
char S[105];
int n;
bool check(int l,int r)
{
    // debug("%d %d\n",l,r);
    while(l<r)
    {
        if(S[l++]!=S[r--]) return 0;
    }
    return 1;
}
int main()
{
    scanf("%s",S+1);
    n=strlen(S+1);
    puts(check(1,n)&&check(1,(n-1)>>1)&&check((n+3)>>1,n)?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"mod=10**9+7\n"
"n,m=map(int,input().split())\n"
"x=list(map(int,input().split()))\n"
"y=list(map(int,input().split()))\n"
"xl=0\n"
"xt=0\n"
"yl=0\n"
"yt=0\n"
"for i in range(n-1):\n"
"  if i==0:\n"
"    for j in range(1,n):\n"
"      xt+=x[j]-x[i]\n"
"    xl=xt\n"
"  else:\n"
"    xt-=(x[i]-x[i-1])*(n-i)\n"
"    xl=(xl+xt)%mod\n"
"for i in range(m-1):\n"
"  if i==0:\n"
"    for j in range(1,m):\n"
"      yt+=y[j]-y[i]\n"
"    yl=yt\n"
"  else:\n"
"    yt-=(y[i]-y[i-1])*(m-i)\n"
"    yl=(yl+yt)%mod\n"
"print(xl*yl%mod)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 18736
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

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

  for (int i = 0; i < n; ++i) {
    char c; cin >> c;
    if (i == k - 1) cout << char(c + 32);
    else cout << c;
  }
  cout << endl;


  return 0;
}


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

constexpr ll MOD = 1e9 + 7;
ll N, X;
vector<ll> S;
vector<vector<ll>> memo;

ll solve(ll i, ll x) {
    if (i == N - 1) {
        return x % S[i];
    }

    if (memo[i][x] != -1) {
        return memo[i][x];
    }

    ll result = 0;

    //i番目のものを先頭で使う
    (result += solve(i + 1, x % S[i])) %= MOD;

    //i番目のものを先頭以外で使う
    //S[i]より小さいものでmodが取られるのでS[i]はxに影響しない
    //残りN - i個で先頭以外の位置はN - i - 1通りありうる
    (result += (N - i - 1) * solve(i + 1, x) % MOD) %= MOD;

    return memo[i][x] = result;
}

int main() {
    cin >> N >> X;
    S.resize(N);
    for (ll i = 0; i < N; i++) {
        cin >> S[i];
    }

    sort(S.begin(), S.end(), greater<>());

    memo.resize(N + 1, vector<ll>(X + 1, -1));
    cout << solve(0, X) << endl;
}

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

using namespace std;

long long lcm(long long a, long long b) {
	return a / __gcd(a, b) * b;
}

int main() {

	int n, m;
	scanf("%d %d", &n, &m);

	vector<int> a(n);
	for(int &x : a) scanf("%d", &x), x /= 2;

	long long l = 1;

	for(int x : a) {
		l = lcm(l, 1LL * x);
		if(l > m) return printf("0\n"), 0;
	}
	int cnt[2] = {0, 0};
	for(int x : a) {
		cnt[l / x % 2]++;
	}
	if(cnt[0] and cnt[1]) return printf("0\n"), 0;

	m /= l;

	printf("%d\n", (m + 1) / 2);
}


Measured memory_bytes: 640
def read():
    N, X = list(map(int, input().strip().split()))
    L = list(map(int, input().strip().split()))
    return N, X, L


def solve(N, X, L):
    d = 0
    for i in range(N):
        if d + L[i] > X:
            return i + 1
        d += L[i]
    return N + 1


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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 namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, k;
    cin >> n >> k;
    vi a(n+1, 0);
    vi loop(0);
    repf(i, n) cin >> a[i];
 
    vector<bool> chk(n+1, true);
    loop.push_back(1);
    chk[1] = false;
    ll next = a[1];
    ll tel_cnt = 0;
 
    while(chk[next]){
        loop.push_back(next);
        chk[next] = false;
        tel_cnt++;
        if(tel_cnt >= k) break;
        next = a[next];
    }

    if(tel_cnt >= k){
        cout << loop.back() << endl;
        return 0;
    }

    // ループを抜けた時のnextがループの始点
    auto p = find(all(loop), next);
    ll nonloop = p - loop.begin();
    ll loopsize = loop.size() - nonloop;
    k = (k - nonloop)%loopsize;
 
    cout << loop[nonloop+k] << endl;
}

Measured memory_bytes: 6920
#include<bits/stdc++.h>
using namespace std;
int main() {
	int H, W;
	cin >> H >> W;
	char A[H][W];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
	char B[2 * H][2 * W];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			B[2 * i][j] = A[i][j];
			B[2 * i + 1][j] = A[i][j];
		}
	}
	for (int i = 0; i < 2 * H; i++) {
		for (int j = 0; j < W; j++) {
			cout << B[i][j];
			if (j == W - 1) {
				cout << endl;
			}

		}
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
ans = 0
for i in range(N):
	tmp = 0
	tmp += sum(A1[0:i+1])
	tmp += sum(A2[i:])
	ans = max(tmp, ans)
	
print(ans)


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> A(H+2, vector<char>(W+2));
  
  
  for (int i = 0; i < H+2; i++) {
    for (int j = 0; j < W+2; j++)
      A.at(i).at(j) = '#';
  }
  
  for (int i = 1; i < H+1; i++) {
    for (int j = 1; j < W+1; j++) 
      cin >> A.at(i).at(j);
  }
  
  for (int i = 0; i < H+2; i++) {
    for (int j = 0; j < W+2; j++)
      cout << A.at(i).at(j);
    cout << endl;
  }
 
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    bool ans = a <= c && c <= b;

    cout << (ans? "Yes" : "No") << endl;
}

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

long long f(long long X,long long Y,long long P){
  vector<long long> digit2(1000),XX(1000);
  long long I,N,mod;
  I=0;
  
  while(Y!=0){
    digit2.at(I)=Y%2;
    Y=Y/2;
    I++;
  }
  N=I;
  
  XX.at(0)=X%P;
  for(I=1;I<N;I++){
    XX.at(I)=(XX.at(I-1)*XX.at(I-1))%P;
  }
  
  mod=1;
  for(I=0;I<N;I++){
    if(digit2.at(I)==1){
      mod=(mod*XX.at(I))%P;
    }
  }
  
  if(mod<0){
    mod=mod+P;
  }
  
  return mod;
}

int main(){
  long long n,m,k,c,p,A,i;
  cin >> n >> m >> k;
  
  p=998244353;
  A=((m%p)*f(m-1,n-1,p))%p;
  c=1;
  for(i=1;i<=k;i++){
    c=((c*(n-i)%p)*f(i,p-2,p))%p;
    A=(A+(((c*m)%p)*f(m-1,n-i-1,p))%p)%p;
  }
  
  if(A<0){
    A=A+p;
  }
  
  cout << A << endl;
}

Measured memory_bytes: 3612
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <locale>
#include <queue>
#include <tuple>
#include <map>
#include <fstream>

using namespace std;


#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))




int main() {
	int n,k;
	cin >> n>>k;
	vector<int> ps(n);
	rep(i, n){
		cin>>ps[i];
	}
	sort(ps.begin(),ps.end());
	ll ans = 0;
	rep(i,k){
		ans += ps[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3624
import sys
from io import StringIO
import unittest
import numpy as np


def resolve():
    N, L = map(int, input().split())
    taste = np.zeros(N)
    for i in range(N):
        taste[i] = L + i
    min_idx = np.argsort(np.abs(taste))[0]
    sum_taste = np.sum(taste) - taste[min_idx]
    print(np.int(sum_taste))

resolve()

Measured memory_bytes: 12516
#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() {
    int A, B;
    cin >> A >> B;
    if (A <= 8 && B <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}


Measured memory_bytes: 3632