akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>

/* this function(algorthm) is slow for aoj
int isPrime(int x)
{
  if(x <= 1) return 0;
  for(int i = 2; i<=x-1; i++)
    {
      if(x%i==0) return 0;
    }
  return 1;
}
*/

int isPrime(int x)
{
	int i = 3;
	if(x == 2) return 1;
	else if(x < 2 || x%2 == 0) return 0;
	else 
	{
		while(i <= sqrt(x))
		{
			if(x%i == 0) return 0;
			i+= 2;
		}
		return 1;
	}
}

int main()
{
  //input
  int N,j=0, data;
  scanf("%d", &N);
  for(int i=0; i!=N; i++)
    {
      scanf("%d", &data);
      if(isPrime(data)==1) j++;
    }
  printf("%d\n", j);
  
  return 0;
  }



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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int P=1E6+3;

ll fac[P],ifac[P];

ll ksm(ll a,ll b)
{
	ll ret=1;
	for(;b;b>>=1,(a*=a)%=P)
		if(b&1)
			(ret*=a)%=P;
	return ret;
}

void solve()
{
	int x,d,n;
	scanf("%d%d%d",&x,&d,&n);
	if(d==0)
		return printf("%lld\n",ksm(x,n)),void();
	if(n>=P||x==0)
		return puts("0"),void();
	int b=1ll*x*ksm(d,P-2)%P;
	if(b+n-1>=P)
		return puts("0"),void();
	printf("%lld\n",fac[b+n-1]*ifac[b-1]%P*ksm(d,n)%P);
}

int main()
{
	fac[0]=ifac[0]=1;
	for(int i=1;i<P;i++)
		fac[i]=fac[i-1]*i%P;
	ifac[P-1]=ksm(fac[P-1],P-2);
	for(int i=P-2;i;i--)
		ifac[i]=ifac[i+1]*(i+1)%P;
	int T;
	for(scanf("%d",&T);T--;solve());
}


Measured memory_bytes: 16512
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <list>

#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> pii;

const int MAXN = 200;
const int inf = 1e9 + 5;
const long double eps = 1e-8;
const int Q = 1e9 + 7;

int a[MAXN][MAXN];
vector<pii> ans;

bool check(string s) {
    for (int i = 0; i < s.length() - 1; i++)
        if (s[i] != s[i + 1])
            return false;
    return true;
}

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

    string s;
    cin >> s;

    int ans = inf;
    for (char c = 'a'; c <= 'z'; c++) {
        if (s.find(c) == string::npos)
            continue;
        string s1 = s;
        int count = 0;
        while (!check(s1)) {
            string t = "";
            for (int i = 0; i < s1.length() - 1; i++) {
                if (s1[i] == c || s1[i + 1] == c)
                    t += c;
                else
                    t += s1[i];
            }
            s1 = t;
            count++;
        }
        ans = min(ans, count);
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>

using namespace std;
typedef long long ll;

int main(){
    int N,Y; cin >> N >> Y;
    int x,y,z; x=y=z=-1;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N-i;j++){
            int s = i*10000+j*5000+(N-i-j)*1000;
            if(s==Y){
                x=i;y=j;z=N-i-j;
                i+=N;
                break;
            }
        }

    }
    cout << x << " " << y << " " << z << endl;
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[1<<18];

vpint ma[1<<18];

signed main(){
    cin>>N;
    rep(i,1<<N)cin>>A[i];

    rep(i,1<<N)ma[i].pb({A[i],i});
    rep(i,1<<N){
        rep(j,N)if(i>>j&1){
            vpint uku;
            for(auto p:ma[i])uku.pb(p);
            for(auto p:ma[i^(1<<j)])uku.pb(p);
            sort(all(uku));uku.erase(unique(all(uku)),uku.end());
            ma[i].clear();
            ma[i].pb(uku[uku.size()-1]);
            ma[i].pb(uku[uku.size()-2]);
        }
    }

    for(int i=1;i<(1<<N);i++){
        int ans=0;
        rep(j,N)if(i>>j&1){
            int b=i;
            b^=1<<j;
            b|=((1<<j)-1);
            if(ma[b].size()>1)chmax(ans,ma[b][0].fi+ma[b][1].fi);
        }
        chmax(ans,ma[i][0].fi+ma[i][1].fi);
        cout<<ans<<endl;
    }
    return 0;
}


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

int main(void){
    
    int H,W;
    cin >> H >> W;
    char S[H][W];
    
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> S[i][j];
        }
    }
    
    for(int i=0;i<H;i++){
        for(int k=0;k<2;k++){
            for(int j=0;j<W;j++){
                if(j != W-1) cout << S[i][j];
                else cout << S[i][j] << endl;
            }
        }
    }
}

Measured memory_bytes: 3616
#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>;

const ll INF = (ll)5e15;

int main() {
  int n;
  cin >> n;
  P now = P(0,0);
  int time = 0;
  rep(i,n) {
    int t,x,y;
    cin >> t >> x >> y;
    int dist = abs(x-now.first) + abs(y-now.second);
    if(dist > (t-time)) {
      cout << "No" << endl;
      return 0;
    }
    int res = abs((t-time) - dist);
    if(res%2 == 0) {
      time = t;
      now = P(x,y);
    } else {
      cout << "No" << endl;
        return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> cnt(m);
  for (int i=0;i<n;++i){
    int k;
    cin >> k;
    for (int j=0;j<k;++j){
      int a;
      cin >> a;
      a--;
      cnt[a]++;
    }
  }
  int ans = 0;
  for (int i=0;i<m;++i){
    if (cnt[i]==n){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		if (a[i] % 2 != 0) {
			cout << "first" << endl;
			return 0;
		}
	}
	cout << "second" << endl;
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    set<int> s;
    int a,b,c;
    cin>>a>>b>>c;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout<<s.size()<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=100005;
inline int read(){
	int x=0;char ch=getchar();
	while (!isdigit(ch)) ch=getchar();
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x;
}
int n,cnt=0,bel[maxn];
struct data{
	int x,y,id;
}p[maxn];
bool comp1(data d1,data d2){
	if (d1.x==d2.x) return d1.y<d2.y;
	return d1.x<d2.x;
}
bool comp2(data d1,data d2){
	if (d1.y==d2.y) return d1.x<d2.x;
	return d1.y<d2.y;
}
struct edge{
	int from,to,c;
}e[maxn<<1];
inline void add_edge(int from,int to,int c){
	e[cnt].from=from;e[cnt].to=to;e[cnt++].c=c;
}
inline bool cmp(edge e1,edge e2){
	return e1.c<e2.c;
}
int find(int x){
	if (bel[x]==x) return x;
	return bel[x]=find(bel[x]);
}
int main(){
	n=read();for (int i=1;i<=n;++i) bel[i]=i;
	for (int i=1;i<=n;++i) p[i].x=read(),p[i].y=read(),p[i].id=i;
	sort(p+1,p+n+1,comp1);
	for (int i=1;i<n;++i) add_edge(p[i].id,p[i+1].id,min(abs(p[i].x-p[i+1].x),abs(p[i].y-p[i+1].y)));
	sort(p+1,p+n+1,comp2);
	for (int i=1;i<n;++i) add_edge(p[i].id,p[i+1].id,min(abs(p[i].x-p[i+1].x),abs(p[i].y-p[i+1].y)));
	sort(e,e+cnt,cmp);ll ans=0;
	for (int i=0;i<cnt;++i){
		int x=find(e[i].from),y=find(e[i].to);
		if (x==y) continue;
		ans+=e[i].c;
		bel[x]=y;
	}
	printf ("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 4224
N,A,B=map(int,input().split())
S=input()
NumOfPassed_DomesticStudents=0
NumOfPassed_OverseasStudents=0

for i in range(N):
    if S[i]=='a':
        if NumOfPassed_DomesticStudents+NumOfPassed_OverseasStudents< A+B:
            print("Yes")
            NumOfPassed_DomesticStudents+=1
        else:
            print("No")
    elif S[i]=='b':
        if  NumOfPassed_DomesticStudents+NumOfPassed_OverseasStudents<A+B and NumOfPassed_OverseasStudents<B:
            print("Yes")
            NumOfPassed_OverseasStudents+=1
        else:
            print("No")
    elif S[i]=="c":
        print("No")

Measured memory_bytes: 4016
#include<stdio.h>
#include<string.h>
#include<math.h>
#define pi 3.14159265
int main(void){
  double a, b, c, arc, rad;
  double s, l, h;
  scanf("%lf %lf %lf", &a, &b, &arc);
  rad=arc*pi/180;
  s=sin(rad)*a*b/2;
  c=sqrt(a*a+b*b-2*a*b*cos(rad));
  l=a+b+c;
  h=b*sin(rad);
  printf("%.8f\n%.8f\n%.8f\n", s, l, h);
  return 0;
}



Measured memory_bytes: 2080
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 3e5 + 5;

int n, k;
char s[N];
int a[N], sz;
int main(){
    scanf("%d%d%s", &n, &k, &s);
    int lst = '#';
    int cnt = 0;
    for(int i = 0 ; i < n ; ++i){
        if(s[i] != lst){
            if(cnt)
                a[sz++] = cnt;
            cnt = 0;
        }
        lst = s[i];
        ++cnt;
    }
    a[sz++] = cnt;
    if(sz == 1){
        printf("%d\n", n - 1);
        exit(0);
    }
    if(sz == 2){
        if(k)printf("%d\n", n - 1);
        else printf("%d", a[0] + a[1] - 2);
        exit(0);
    }
    int ans = 0;
    for(int i = 0 ; i < sz ; ++i)
        ans += (a[i] - 1);
    if(sz & 1)
        printf("%d\n", ans + min(k, sz / 2) * 2);
    else
        printf("%d\n", ans + min(k * 2, sz - 1));
}

Measured memory_bytes: 768
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long
#define pii pair<int,int>
#define ff first
#define ss second
#define vi vector<int>
#define fo(n) for(int i = 0;i < int(n);i++)
#define foo(a,b) for(int i = int(a);i <= int(b);i++)
#define mk make_pair
#define pb push_back
#define MAXN 100
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define fastio ios_base:: sync_with_stdio(false)
#define inf (int)1e9
vi v(MAXN), w(MAXN);

ll KS(int n,int W){
	ll knapSack[n+1][W+1];

	for(int i = 0;i < n+1;i++){
		knapSack[i][0] = 0;
	}

	for(int i = 0;i <= W;i++){
		knapSack[0][i] = 0;
	}

	for(int i = 0;i < n;i++){
		for(int j = 0;j <= W;j++){
			if(w[i] > j) knapSack[i+1][j] = knapSack[i][j];

			else{
				knapSack[i+1][j] = max(knapSack[i][j], knapSack[i][j-w[i]]+v[i]);
			}
		}
	}

	return knapSack[n][W];
}

int main(){
	
	fastio;
	int n,W;
	cin >> n >> W;

	fo(n){
		cin >> w[i] >> v[i];
	}

	ll ans = KS(n,W);

	cout << ans << endl;

	return 0;
 }	

Measured memory_bytes: 79232
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int arr[10];
	
	for (int a=0;a<3;a++){
		scanf ("%d",&arr[a]);
	}
	
	int total;
	scanf ("%d",&total);
	
	sort(arr,arr+3);
	
	for (int a=1;a<=total;a++){
		arr[2]*=2;
	}
	
	
	printf ("%d\n",arr[0]+arr[1]+arr[2]);
	
	return 0;	
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>


using namespace std;
const int MOD = 1000000009; // check!!!
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)(c).size())
#define ten(x) ((int)1e##x)
#define tenll(x) ((ll)1e##x)

ll dp[10][1001];

int main(){

	dp[0][0] = 1;
	FOR(i,101) for(int j = 1000; j >= 0; j--){
		for(int k = 9; k > 0; k--) if(j - i >= 0){
			dp[k][j] += dp[k-1][j-i];
		}
	}

	int n,s;
	while(cin>>n>>s,n||s){
		cout << dp[n][s] << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int, int> p;
typedef long long ll;
const int inf = 1000000007;
int main() {
  string s;
  cin >> s;
  if (s == "SSS") cout << 0 << endl;
  if (s == "RSS" || s == "SRS" || s == "RSR" || s == "SSR") cout << 1 << endl;
  if (s == "RRS" || s == "SRR") cout << 2 << endl;
  if (s == "RRR") cout << 3 << endl;
  return 0;
}

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

int main() {
    int n;
    cin>>n;
    long long c[5]={0,0,0,0,0};
    for(int i=0; i<n; i++){
        string s_temp;
        cin>>s_temp;
        if(s_temp[0]=='M')      c[0]++;
        else if(s_temp[0]=='A') c[1]++;
        else if(s_temp[0]=='R') c[2]++;
        else if(s_temp[0]=='C') c[3]++;
        else if(s_temp[0]=='H') c[4]++;
        //cout<<s_temp[0]<<c[0]<<c[1]<<c[2]<<c[3]<<c[4]<<endl;
    }
    long long ans;
    ans = c[0]*c[1]*c[2] + c[0]*c[1]*c[3] + c[0]*c[1]*c[4] + c[0]*c[2]*c[3] + c[0]*c[2]*c[4] + c[0]*c[3]*c[4] + c[1]*c[2]*c[3] + c[1]*c[2]*c[4] + c[1]*c[3]*c[4] + c[2]*c[3]*c[4];
    cout<<ans<<endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll a,b,ans=-1;
	cin >> a >> b;
	for(ll i=1009;i>=13;i--){
		if(i*8/100==a && i/10==b) ans=i;
	}
	cout << ans << endl;
	return 0;
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = ReadLine();
            var re = "";

            for (int i = 0; i < s.Length; i++) {
                re += "x";
            }

            Console.WriteLine(re);
            ReadLine();
        }

        //最大公約数
        static int gcd(int a, int b)
        {
            if (a > b) {
                return gcd(b, a);
            }

            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }

        //最小公倍数
        static int lcm(int a, int b) => a * b / gcd(a, b);

        /// <summary>
        /// コンビネーション
        /// </summary>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        public static string ReadLine() => Console.ReadLine();
        public static int ReadLineInt() => int.Parse(Console.ReadLine());
        public static long ReadLineLongInt() => long.Parse(Console.ReadLine());
        public static string[] ReadLineStringSplit(char a = ' ') => ReadLine().Split(a).ToArray();
        public static int[] ReadLineIntSpilit(char a = ' ') => ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        public static long[] ReadLineLongSpilit(char a = ' ') => ReadLine().Split(a).Select(x => long.Parse(x)).ToArray();
        static string[] GetAplhaLowerArray() => new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll k, a, b;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
	
	cin >> k >> a >> b;
	for(ll i = a; i <= b; i++){
		if(i % k == 0){
			cout << "OK" << '\n';
			return 0;
		}
	}
	cout << "NG" << '\n';
}


Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>

using namespace std;

int main()
{
    int ante[5];
    for(int i=0; i<5; i++){
        cin >> ante[i];
    }
    int k;
    cin >> k;
    int ju = 0;

    for(int i=0; i<5; i++){
        for(int j=i; j<5; j++){
        if(ante[j]-ante[i] > k)  ju = 1;
        }
    }

    if(ju == 0) cout << "Yay!\n";
    else cout << ":(\n";

}

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

int main(){
    string s;
    cin>>s;
    int i;
    for(i=0;i<3;i++){
        if(s[i]==s[i+1]){
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    cout<<"Good"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt(), D = scanner.nextInt(),ans=0;
        for (int i = 0; i < N; i++) {
            long a = scanner.nextInt(), b = scanner.nextInt();
            double dist = Math.sqrt(a*a+b*b);
            if (dist<=D)ans++;
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 48792
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;

     cin>>str;

     m=str[0]-'0';

     m*=10;

     m+=str[1]-'0';

     ll y=str[2]-'0';

     y*=10;

     y+=str[3]-'0';

    if( (m==0 && y>12) || (m>12 && y==0))cout<<"NA"<<endl;

    else if(m<=12 && y<=12 && m && y)
        cout<<"AMBIGUOUS"<<endl;

    else if(m<=12 && m)
        cout<<"MMYY"<<endl;

    else if(y<=12 && y)
    {
        cout<<"YYMM"<<endl;
    }
    else cout<<"NA"<<endl;













}



Measured memory_bytes: 3592
#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 n, h, w;
  cin >> n >> h >> w;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  int ans = 0;
  rep(i, n) {
    if (a[i] >= h && b[i] >= w) ++ans;
  }
  cout << ans << endl;
  return 0;
}

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


using namespace std;


const int a = 0, b = 1, c = 2;


int main()
{
    string S[3];
    cin >> S[a] >> S[b] >> S[c];


    int ans = a;
    while( 1 ){
        if( S[ans].length() == 0 ) break;

        int tmp;
        switch( S[ans].c_str()[0] ){
            case 'a': tmp = a; break;
            case 'b': tmp = b; break;
            case 'c': tmp = c; break;
        }

        S[ans].erase(S[ans].begin());

        ans = tmp;
    }


    switch( ans ){
        case a: cout << "A" << endl; break;
        case b: cout << "B" << endl; break;
        case c: cout << "C" << endl; break;
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main() {
  int D;
  cin >> D;
  vector<int> down(27);
  for( int i = 1; i <= 26; i++ ) cin >> down[i];

  //各コンテストの満足度
  vector<vector<int>> contest(D+1, vector<int>(27));
  for( int i = 1; i <= D; i++ ){
    for( int j = 1; j <= 26; j++ ) cin >> contest[i][j];
  }

  vector<int> T(D+1);
  for( int i = 1; i <= D; i++ ) cin >> T[i];

  //各コンテストを最後に実施した日
  vector<int> last(27);

  int now = 0;
  for( int d = 1; d <= D; d++ ){
    last[T[d]] = d;
    now += contest[d][T[d]];
    //満足度を下げる
    for( int i = 1; i <= 26; i++ ){
      now -= down[i]*(d-last[i]);
    }
    cout << now << endl;
  }

}


Measured memory_bytes: 3720
# -*- coding: utf-8 -*-
N = int(input())
tree = [{"parent":-1, "left":-1, "right":-1, "sibling": -1} for _ in range(N)]
parent = set([n for n in range(N)])

for _ in range(N):
    inp = [int(n) for n in input().split()]
    tree[inp[0]]["left"] = inp[1]
    tree[inp[0]]["right"] = inp[2]
    tree[inp[0]]["degree"] = sum([inp[1] != -1, inp[2] != -1])
    
    if inp[1] != -1:
        tree[inp[1]]["parent"] = inp[0]
        tree[inp[1]]["sibling"] = inp[2]
    if inp[2] != -1:
        tree[inp[2]]["parent"] = inp[0]    
        tree[inp[2]]["sibling"] = inp[1]
    
    parent = parent.difference(inp[1:])
    
def set_depth(n, depth):
    tree[n]["depth"] = depth
    
    if tree[n]["left"] != -1:
        set_depth(tree[n]["left"], depth+1)
    if tree[n]["right"] != -1:
        set_depth(tree[n]["right"], depth+1)

root = parent.pop()
set_depth(root, 0)

def set_height(n):
    h1 = 0
    h2 = 0
    if tree[n]["right"] != -1:
        h1 = set_height(tree[n]["right"]) + 1
    if tree[n]["left"] != -1:
        h2 = set_height(tree[n]["left"]) + 1
    
    tree[n]["height"] = max(h1, h2)
    return max(h1, h2)

set_height(root)

for n in range(N):
    if tree[n]["parent"] == -1:
        tree[n]["type"] = "root"
    elif tree[n]["degree"] == 0:
        tree[n]["type"] = "leaf"
    else:
        tree[n]["type"] = "internal node"
    
    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}"\
          .format(n, tree[n]["parent"], tree[n]["sibling"],
                  tree[n]["degree"], tree[n]["depth"], tree[n]["height"], tree[n]["type"]))

Measured memory_bytes: 7900
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20)
#define int long long
#define double long double
const int INF = 1e18, MOD = 2019;

signed main() {
    INCANT;
    double n, m, d;
    cin>>n>>m>>d;
    if (d == 0) {
        cout<<(m - 1) / n<<endl;
    } else {
        cout<<(m - 1) * 2 * (n - d) / n / n<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    return 0;
}

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

int main(){
  string s,t;cin>>s>>t;
  int a,b;cin>>a>>b;
  
  string u;cin>>u;
  
  if(u==s)cout<<a-1<<" ";
  else cout<<a<<" ";
  
  if(u==t)cout<<b-1<<" ";
  else cout<<b<<" ";
}


Measured memory_bytes: 256
import heapq

N = int(input())

def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

fct = factorize(N)
steps = []
for div in divisorize(fct):
    a = num(div)
    b = N//a
    step = a+b-2
    steps.append(step)
    
heapq.heapify(steps)
print(heapq.heappop(steps))

Measured memory_bytes: 4596
R, G, B, N = gets.strip.split(/ /).collect(&:to_i)

count = 0

(N / R + 1).times{|r|
    (N / G + 1).times{|g|
        n = N - R * r - G * g
        if (n >= 0) && (n % B == 0)
            count += 1
        end
    }
}

puts count


Measured memory_bytes: 1788
from collections import deque
import heapq
def f(d,n):
    a = list(d)
    heapq.heapify(a)
    while n > 0 and len(a) > 0:
        tmp = heapq.heappop(a)
        if tmp >= 0:
            heapq.heappush(a,tmp)
            break
        n -= 1
    return sum(a)
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for i in range(1,min(N,K)+1):
    d = deque()
    for k in range(i):
        d.append(V[k])
    ans = max(ans,f(d,K-i))
    for k in range(i):
        d.pop()
        d.appendleft(V[N-1-k])
        ans = max(ans,f(d,K-i))
print(ans)

Measured memory_bytes: 3444
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]


def solve():
    for i in range(n - m + 1):
        for j in range(n - m + 1):
            c = ""
            for k in range(m):
                c += a[i + k][j : j + m]
            if "".join(b) == c:
                print("Yes")
                return
    print("No")


solve()


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef long double f80;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }
int bt(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bt(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }
int nxt_C(int x) { int c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }
ll nxt_C(ll x) { ll c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }

vector<int> get_bits(int mask) {
	vector<int> bb;
	while(mask) { int b = bt(mask); bb.pb(b); mask ^= (1 << b); }
	reverse(all(bb));
	return bb;
}

int get_mask(vector<int> v) {
	int mask = 0;
	for(int x : v) { mask ^= (1 << x); }
	return mask;
}

template<typename T>
void uniq(vector<T> &v) { sort(all(v)); v.resize(unique(all(v)) - v.begin()); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

void sc() {}

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L:" << __LINE__ << "][" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// #ifndef LOCAL
// string to_string(__int128 x) {
// 	string s = "";
// 	bool neg = 0;
// 	if(x < 0) { s += "-"; neg = 1; x = -x; }
// 	if(!x) s += '0';
// 	while(x) {
// 		int rem = x % 10;
// 		s += to_string(rem);
// 		x /= 10;
// 	}
// 	reverse(s.begin() + neg, s.end());
// 	return s;
// }
// #endif

const int mod = 1e9 + 7; // 998244353;

int pwr(int a,ll b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
	Read problem statement carefully!!!
*/

void solve() {
	int l, r, d;
    sc(l, r, d);
    cout << (r / d) - (l - 1) / d;
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3612
using System;

public class Watch
{
    //?§????????¨???¨?¨??????¨???????????????
    static void Main(string[] args)
    {
        /*---??£?¨???¨---*/
        int S;
        int sec;
        int min;
        int hour;
        /*---??£?¨???¨---*/

        /*?§????????????????*/
        S = int.Parse(Console.ReadLine());

        /*?§????99:99:99??¨?¨??????????*/
        hour = S / 3600;
        min = (S % 3600) / 60;
        sec = S % 60;

        /*????¨???¨?¨???§??????*/
        Console.WriteLine("{0}:{1}:{2}", hour, min, sec);
    }
}

Measured memory_bytes: 9128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long

int main(){
  int a, b;
  cin >> a >> b;
  if(a<=2*b){
    cout << 0 << endl;
  }else{
    cout << a-2*b << endl;
  }

  return 0;
}


Measured memory_bytes: 256
s = str(input())
#s = "<>>><<><<<<<>>><"
ans = 0
def leftmore(ln):
    ret = [0]
    cur = 0
    for c in ln:
        if c == "<":
            cur += 1
        else:
            cur = 0
        
        ret.append(cur)
    return ret

def rightless(ln):
    revl = reversed(ln)
    ret = [0]
    cur = 0
    for c in revl:
        if c == ">":
            cur += 1
        else:
            cur = 0
        ret.append(cur)
    return list(reversed(ret))

lm = leftmore(s)
rl = rightless(s)
for i in range(len(s)+1):
    ans += max(lm[i],rl[i])
print(ans)

Measured memory_bytes: 37536
# -*-coding: utf-8 -*-
N = int(input())
H = list(map(int, input().split()))
ans = 0
while sum(H) != 0:
    while True:
        if H[0] == 0:
            H.pop(0)
        else:
            break
    if 0 in H:
        ind = H.index(0)
        for i in range(0, ind):
            H[i] -= 1
    else:
        H = list(map(lambda x: x - 1, H))
    ans += 1
print(ans)

Measured memory_bytes: 3060
N, M = map(int, input().split())
A = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(M)]
A = sorted(A)
bc = sorted(bc, reverse=True, key=lambda x:x[1])
i = 0
for b, c in bc:
    while A[i] <= c and b > 0:
        A[i] = c
        b -= 1
        i += 1
        if i >= N:
            break
    if i >= N:
        break
print(sum(A))

Measured memory_bytes: 33732
N, P = map(int, input().split())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i ==0:
                cnt += 1
                temp //= i
            arr.append((i, cnt))

    if temp != 1:
        arr.append((temp, 1))
    if len(arr) == 0:
        arr.append((n, 1))

    return arr

F = factorization(P)

ans = 1
for a, b in F:
    if b >= N:
        ans *= a ** (b // N)
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N, A[20], T;

int main(void){
	//IO("test.in", "test.out");
	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d", &A[i]);
	for(int i = 0; i < N; i++){
		int v;
		scanf("%d", &v);
		A[i] -= v;
	}
	sort(A, A + N, greater<int>());
	for(int i = 0; i < N && A[i] > 0; i++) T += A[i];
	printf("%d\n", T);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			} else {
				for (int i = 0; i < H; ++i) {
					for (int j = 0; j < W; ++j) {
						if (i == 0 || j == 0 || j == W - 1 || i == H - 1) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.print("\n");
				}
				System.out.print("\n");
			}
		}
		sc.close();
	}
}



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    int x[n], y[n];
    rep(i, n) {
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y, y + n);
    rep(i, n) {
        auto j = lower_bound(y, y + n, x[i]) - y;
        if (j < n / 2) cout << y[n / 2] << endl;
        else cout << y[n / 2 - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

	public void run() {
		new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt() + 2;
		String s = sc.next() + "00";
		int[] a = new int[n];
		int[] sz = new int[n];
		for (int i = 0; i < n; ++i) {
			if (s.charAt(i) == '1') {
				a[i] = 1;
			} else {
				a[i] = 0;
			}
		}
		for (int i = 0; i < n; ++i) {
			if (a[i] == 1) {
				++sz[i];
				if (i > 0)
					sz[i] += sz[i - 1];
			}
		}

		int[] dp = new int[n];
		for (int i = 2; i < n; ++i) {
			dp[i] = dp[i - 1];
			if (a[i] == 0)
				continue;
			if (a[i - 1] == 0 && a[i - 2] == 1) {
				for (int d = 0; d < 3 && sz[i - 2] - d > 0; ++d) {
					dp[i] = Math.max(dp[i],
							(sz[i - 2] - d) + (i - 2 - (sz[i - 2] - d) >= 0 ? dp[i - 2 - (sz[i - 2] - d)] : 0));
				}
			}
			if (i - sz[i] - 1 >= 0 && a[i - sz[i] - 1] == 1) {
				dp[i] = Math.max(dp[i], sz[i] + (i - 2 - sz[i] >= 0 ? dp[i - sz[i] - 2] : 0));
			}
		}
		System.out.println(dp[n - 1]);
	}

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

}


Measured memory_bytes: 42956
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

typedef struct {
    int x;
    int y;
    bool used;
} Point;

int x_less(const void *a, const void *b) {
  return (((const Point*)a)->x - ((const Point*)b)->x);
}
int y_greater(const void *a, const void *b) {
  return (((const Point*)b)->y - ((const Point*)a)->y);
}


int main() {
    string s[3];
    FOR(i,3) cin >> s[i];
    cout << s[0][0] << s[1][1] << s[2][2] << endl;
 return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  
  if(t.size() - 1 == s.size() && s == t.substr(0, s.size())){
    puts("Yes");
  }else{
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 20){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};



//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}


ll sum(ll n, ll m){
  ll res = 1;
  res *= ((m + 2) * comb(n + m + 2, n) % MOD - n - 1) % MOD;
  res += MOD;
  res %= MOD;
  res *= inverse(n+1);
  res %= MOD;
  return res;
}

void solve(){
  COMinit();
  ll r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  ll ans = sum(r2, c2) - sum(r1-1, c2) - sum(r2, c1-1) + sum(r1-1, c1-1);
  ans %= MOD;
  ans += MOD;
  ans %= MOD;
  cout << ans << endl;
}


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


Measured memory_bytes: 47104
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    int N, K, S;
    cin >> N >> K >> S;

    if (S > 1e6) {
        REP(i, K) { cout << S << " "; }
        REP(i, N - K) { cout << 1 << " "; }
        cout << endl;
    } else {
        REP(i, K) { cout << S << " "; }
        REP(i, N - K) { cout << 1000000 << " "; }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define REPe(i, n) for(int i = 0; i <= (int)(n); ++i)
#define REPi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define REPei(i, a, b) for(int i = int(a); i <= int(b); ++i)

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

    int N, A;
    cin >> N >> A;
    int val = N % 500;
    A >= val ? cout << "Yes" << '\n' : cout << "No" << '\n';

}



Measured memory_bytes: 256
def main():
    a = [int(input()) for i in range(5)]
    a.sort(key=lambda x: x%10 if x%10 != 0 else 10, reverse=True)
    ans = 0
    for aa in a[:4]:
        if aa%10 != 0:
            ans += aa+(10-aa%10)
        else:
            ans += aa
    ans += a[4]
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp pop_back
using namespace std;

//  
int main(){
    string n; cin >> n;
    int lgt = n.length();
    if(n[lgt - 1] == '3') cout<< "bon" << "\n";
    else if(n[lgt - 1] == '0' || n[lgt - 1] == '1' || n[lgt - 1] == '6' || n[lgt - 1] == '8') cout<< "pon" <<"\n";
    else cout<< "hon" << "\n";
    return 0;
}


Measured memory_bytes: 3604
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Mod=1e9+7,inv3=(Mod+1)/3;
int qpow(int x,int y){
	int res=1;
	for (;y;y>>=1,x=1LL*x*x%Mod)
		if (y&1) res=1LL*res*x%Mod;
	return res;
}
inline int upd(int x){return x+(x>>31&Mod);}
int fac[1000100],ifac[1000100],inv[1000100];
int dp[3][1000100];
inline void add(int &x,int y){x=upd(x+y-Mod);}
void init(int x){
	fac[0]=1; for (int i=1;i<=x;i++) fac[i]=1LL*fac[i-1]*i%Mod;
	ifac[x]=qpow(fac[x],Mod-2); for (int i=x;i;i--) ifac[i-1]=1LL*ifac[i]*i%Mod;
	inv[1]=1; for (int i=2;i<=x;i++) inv[i]=1LL*(Mod-Mod/i)*inv[Mod%i]%Mod;
	dp[0][0]=1;
	for (int i=0;i<x;i++){
		add(dp[0][i+1],upd(dp[1][i]+dp[2][i]-Mod));
		add(dp[1][i+1],upd(dp[0][i]+dp[2][i]-Mod));
		add(dp[2][i+1],upd(dp[0][i]+dp[1][i]-Mod));
	}
}
inline int C(int n,int m){return 0<=m&&m<=n?1LL*fac[n]*ifac[n-m]%Mod*ifac[m]%Mod:0;}

int n;
int main()
{
	scanf("%d",&n); init(n+10);
	int res=0;
	for (int i=1;i<=n;i++){
		res=(res+1LL*C(n,i)*dp[1][i]%Mod*inv[i])%Mod;
//		printf("%d: %d * %d / %d / %d\n",i,C(n,i),dp[1][i],qpow(3,n-1),3*n*i);
	}
	res=1LL*res*qpow(inv3,n)%Mod*inv[n]%Mod;
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 25160
#include<bits/stdc++.h>
#define rep(i,n) for(i=0;i<(n);i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main(){
  int n,m;
  cin >> n >> m;
  int a,i;
  priority_queue<int> que;
    for(i=0;i<n;i++){
      cin >> a;
      que.push(a);
    }
  for(i=0;i<m;i++){
    int x=que.top();
    que.pop();
    x=x/2;
    que.push(x);
  }
  long long ans=0;
  for(i=0;i<n;i++){
    int x=que.top();
    que.pop();
    ans+=x;
  }
  cout << ans << endl;
  return 0;
}
      

Measured memory_bytes: 3832
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        Integer[] p = new Integer[n];
        Arrays.setAll(p, i -> Integer.parseInt(sc.next()));
        sc.close();

        // 主処理
        double[] exp = new double[n];
        for (int i = 0; i < n; i++) {
            exp[i] = (double) sum(p[i]) / p[i];
        }
        double total = 0;
        for (int i = 0; i < k; i++) {
            total += exp[i];
        }
        double max = total;
        for (int i = 0; i < n - k; i++) {
            total -= exp[i];
            total += exp[i + k];
            max = Math.max(max, total);
        }
        double result = max;

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

    public static int sum(int n) {
        int sum = 0;
        for (int i = n; 0 < i; i--) {
            sum += i;
        }
        return sum;
    }
}


Measured memory_bytes: 64680
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
    int k; cin >> k;
    string s; cin >> s;

    if(s.size() <= k) cout << s << endl;
    else{
        REP(i, k) cout << s[i];
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3632
#include <cstdio>

int main() {
	int k, x;
  	scanf("%d %d", &k, &x);
    int minVal = (x - k + 1 < -1000000) ? -1000000 : x - k + 1;
  	int maxVal = (x + k - 1 > 1000000) ? 1000000 : x + k - 1;
  
  	for (int i = minVal; i <= maxVal; ++i)
      	printf("%d%c", i, i < maxVal ? ' ' : '\n');
	
  	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <stdlib.h>   
using namespace std;
int main(void){
    int n;cin>>n;
    
    int a[n];
    for (int i =0;i<n;i++){
        cin>>a[i];
    }
    int sm=0;
    for (int i =0;i<n;i++){
        sm+=a[i];
    }
    
    for (int i =0;i<n;i++){
        a[i]*=n;
    }
    int mn = 1000000;
    int ans =-1;
    for (int i =0;i<n;i++){
        if (mn>abs(sm-a[i])){
            ans = i;
            mn=abs(sm-a[i]);
        }
    }
    cout<<ans;
    
}


Measured memory_bytes: 3600