akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> P;

int H, W, D, A[300][300], Q, L[100000], R[100000];

int main(){
    cin >> H >> W >> D;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++)    cin >> A[i][j];
    }
    cin >> Q;
    for(int i=0;i<Q;i++)    cin >> L[i] >> R[i];

    map<int, P> m;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            m[ A[i][j] ] = P(i, j);
        }
    }

    vector< vector<P> > vec(D);
    for(int i=1;i<=H*W;i++){
        vec[ i % D ].push_back(m[i]);
    }

    vector< vector<int> > sum(D);
    for(int i=0;i<D;i++)    sum[i].push_back(0);
    for(int i=0;i<D;i++){
        for(int j=0;j<vec[i].size()-1;j++){
            int add = abs( vec[i][j+1].first - vec[i][j].first ) + abs( vec[i][j+1].second - vec[i][j].second );
            sum[i].push_back( sum[i][j] + add );
        }
    }

    for(int i=0;i<Q;i++){
        int64_t ans = sum[ R[i] % D ][ (R[i] - 1) / D ] - sum[ L[i] % D ][ (L[i] - 1) / D ];
        cout << ans << endl;
    }
}


Measured memory_bytes: 17024
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    K =int(input())

    if K%5==0 or K%2==0:
        print(-1)

    x = 0
    for i in range(10**7+6):
        x = x*10+7
        x %= K
        if x%K ==0:
            print(i+1)
            exit()



if __name__ == "__main__":
    main()


Measured memory_bytes: 63012
#include <bits/stdc++.h>
using namespace std;
class Point{
	public:
	double x,y;
	void input(){
		cin>>x>>y;
	}
};
double dist(Point a,Point b){
	return sqrt(pow(a.x-b.x,2.0)+pow(a.y-b.y,2.0));
}
class Line{
	public:
	double a,b,c;//ax+by=c
	Line(Point s,Point t){
		//x=(x1+x2)/2 , y=(y1+y2)/2????????????
		//??????a=-(x1-x2)/(y1-y2)?????´???
		//(y1-y2)(y-(y1+y2)/2) = -(x1-x2)(x-(x1+x2)/2)
		//(x1-x2)x + (y1-y2)y = (x1^2-x2^2)/2 + (y1^2-y2^2)/2
		a=s.x-t.x;	b=s.y-t.y;
		c=((s.x+t.x)*(s.x-t.x)+(s.y+t.y)*(s.y-t.y))/2.0;
	}
	void multi(double x){
		a*=x;	b*=x;	c*=x;
	}
};
double searchx(Line s,Line t){
	double tmp=s.b;
	s.multi(t.b);	t.multi(tmp);
	return (s.c-t.c)/(s.a-t.a);
}
double searchy(Line s,Line t){
	double tmp=s.a;
	s.multi(t.a);	t.multi(tmp);
	return (s.c-t.c)/(s.b-t.b);
}
int main(){
	int n;	cin>>n;
	while(n--){
		Point a,b,c;
		a.input();	b.input();	c.input();
		Line l(a,b),m(b,c);
		Point center;
		center.x=searchx(l,m);	center.y=searchy(l,m);
		double dis=dist(center,a);
		printf("%.3lf %.3lf %.3lf\n",center.x,center.y,dis);
	}
	return 0;
}

Measured memory_bytes: 1244
#include<iostream>
using namespace std;
int a[]={0,3,5,7};
int ans,n;
main()
{
	cin>>n;
	for(int i0=0;i0<4;i0++)
	for(int i1=!!i0;i1<4;i1++)
	for(int i2=!!i1;i2<4;i2++)
	for(int i3=!!i2;i3<4;i3++)
	for(int i4=!!i3;i4<4;i4++)
	for(int i5=!!i4;i5<4;i5++)
	for(int i6=!!i5;i6<4;i6++)
	for(int i7=!!i6;i7<4;i7++)
	for(int i8=!!i7;i8<4;i8++)
	{
		int now=a[i0]*100000000+a[i1]*10000000+a[i2]*1000000+a[i3]*100000+a[i4]*10000+a[i5]*1000+a[i6]*100+a[i7]*10+a[i8];
		int cnt[4]={};
		cnt[i0]++;
		cnt[i1]++;
		cnt[i2]++;
		cnt[i3]++;
		cnt[i4]++;
		cnt[i5]++;
		cnt[i6]++;
		cnt[i7]++;
		cnt[i8]++;
		if(cnt[1]&&cnt[2]&&cnt[3]&&now<=n)ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int m,n;
double p[20][20];
bool used[20][1<<16];
double memo[20][1<<16];
double dfs(int b,int k){
  if(k==n) return 1.0;
  if(used[k][b]) return memo[k][b];
  used[k][b]=1;
  double res=0;
  for(int i=0;i<m;i++){
    if((b>>i)&1) continue;
    double tmp=0,pro=1.0;
    for(int j=k;j<n;j++){
      tmp+=pro*(1.0-p[i][j])*dfs(b+(1<<i),j);
      pro*=p[i][j];
    }
    tmp+=pro;
    res=max(res,tmp);
  }
  return memo[k][b]=res;
}
signed main(){
  cin>>m>>n;
  for(int i=0;i<m;i++)
    for(int j=0;j<n;j++) cin>>p[i][j];
  printf("%.12f\n",dfs(0,0));
  return 0;
}

Measured memory_bytes: 12436
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	int N, Q;
	string S;
	cin >> N >> Q;
	cin >> S;
	int l[Q], r[Q];
	int ans[Q] = {0};
	rep(i, Q) cin >> l[i] >> r[i];

	// 累積和
	int sum[N]; // sum[i] : 0 ~ i の部分列に含まれるACの和
	sum[0] = 0;
	for(int i=1; i<N; i++) {
		if(S[i-1]=='A' && S[i]=='C') {
			sum[i] = sum[i-1] + 1;
		} else {
			sum[i] = sum[i-1];
		}
	}

	rep(j, Q) {
		ans[j] = sum[r[j]-1] - sum[l[j]-1];
	}

	rep(j, Q) {
		cout << ans[j] << endl;
	}	
	
	return 0;
}

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

bool check(int a,int X,int Y,int xmax, int ymin) {
	if (!(X < a && a <= Y))return false;
	if (!(xmax<a && a<=ymin))return false;
	return true;
}

int find_xmax(vector<int>a) {
	int xmax(a[0]);
	for (int i(1); i < a.size(); i++) {
		if (xmax < a[i])xmax = a[i];
	}
	return xmax;
}

int find_ymin(vector<int>a) {
	int ymin(a[0]);
	for (int i(1); i < a.size(); i++) {
		if (ymin > a[i])ymin = a[i];
	}
	return ymin;
}

int main(void) {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vector<int>x;
	vector<int>y;
	for (int i(0); i < N; i++) {
		int tmp;
		cin >> tmp;
		x.push_back(tmp);
	}
	for (int i(0); i < M; i++) {
		int tmp;
		cin >> tmp;
		y.push_back(tmp);
	}
	bool flag(false);
	for (int i(X + 1); i < Y; i++) {
		if (check(i, X, Y, find_xmax(x), find_ymin(y))) {
			flag = true;
			break;
		}
	}
	if (flag == true)cout << "No War" << endl;
	else cout << "War" << 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)
typedef long long ll;

int g[15][15];
//////i番目のヒトがｊ番目のヒトへの証言
////////0不親切1正直－1証言無し
int main(){
    int n;cin>>n;
    rep(i,n)rep(j,n) g[i][j]=-1;
    rep(i,n){
        int a;
        cin>>a;
        rep(j,a){
            int x,y;
            cin>>x>>y;
            --x;
            g[i][x]=y;
        }
    }

    int ans = 0;
    /////bit全探索
    rep(i,1<<n){
        vector<int> d(n);
        rep(j,n) if(i>>j&1){
            d[j]=1;
        }
        bool ok = true;
        rep(j,n){
            if(d[j]){
                rep(k,n){
                    if(g[j][k]==-1)continue;
                    if(g[j][k]!=d[k]) ok=false;
                }
            }
        }
     if(ok) ans=max(ans,__builtin_popcount(i));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N = int(input())
Info = [None] * 99999


# 0番の情報を持っておく
print(0)
s = input()
Info[0] = s
if s == 'Vacant':
    exit()

# N - 1番の情報を持っておく
print(N - 1)
s = input()
Info[N - 1] = s
if s == 'Vacant':
    exit()


# にぶたん
l, r = 0, N - 1
while True:
    m = (l + r) // 2

    print(m)
    s = input()
    Info[m] = s
    if s == 'Vacant':
        exit()

    if (m - l) % 2 == 0:
        if Info[m] == Info[l]:
            l = m
        else:
            r = m

    else:
        if Info[m] == Info[l]:
            r = m
        else:
            l = m


Measured memory_bytes: 4424
A = str(input())
B= str(input())

if A == "1":
    if B == "2":
        print("3")
    else:
        print("2")
elif A == "2":
    if B == "1":
        print("3")
    else:
        print("1")
elif A == "3":
    if B == "1":
        print("2")
    else:
        print("1")    


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int a, N;cin>>N;
    vector<int> v(N);
    for(int i=0; i<N;i++){
       cin>>a; v[i]=a;
    }
    sort(v.begin(),v.end());
    int ans = v[N-1]-v[0];
    cout<<ans<<endl;
    return 0;
}


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

const int maxN = 4e4 + 10, mod = 998244353, g = 3, gi = 332748118;

int n, m;
int lim, cnt, r[maxN + 1];
int f[205][8005];
int A[maxN + 1], B[maxN + 1];
int fac[maxN + 1], inv[maxN + 1];

inline int ADD(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }

inline int SUB(int x, int y) { return x - y < 0 ? x - y + mod : x - y; }

inline int mpow(int a, int x)
{
	int ans = 1;
	while(x)
	{
		if(x & 1) ans = 1ll * ans * a % mod;
		a = 1ll * a * a % mod;
		x >>= 1;
	}
	return ans;
}

inline void NTT(int *a, int type)
{
	for(int i = 0; i < lim; i++)
		if(i < r[i]) swap(a[i], a[ r[i] ]);
	for(int mid = 1; mid < lim; mid <<= 1)
	{
		int wn = mpow(type == 1 ? g : gi, (mod - 1) / (mid << 1));
		for(int i = 0; i < lim; i += (mid << 1))
		{
			int w = 1;
			for(int j = 0; j < mid; j++, w = 1ll * w * wn % mod)
			{
				int x = a[i + j], y = 1ll * a[i + mid + j] * w % mod;
				a[i + j] = ADD(x, y); a[i + mid + j] = SUB(x, y);
			}
		}
	}
	if(type == -1)
	{
		int inv = mpow(lim, mod - 2);
		for(int i = 0; i < lim; i++) a[i] = 1ll * a[i] * inv % mod;
	}
}

inline int C(int n, int m)
{
	if(n < m) return 0;
	return 1ll * fac[n] * inv[m] % mod * inv[n - m] % mod;
}

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

	fac[0] = 1;
	for(int i = 1; i <= n + 5; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[n + 5] = mpow(fac[n + 5], mod - 2);
	for(int i = n + 4; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;

	lim = 1, cnt = 0;
	while(lim <= n * 2) lim <<= 1, cnt ++;
	for(int i = 0; i < lim; i++) r[i] = (r[i >> 1] >> 1) | ((i & 1) << cnt - 1);

	for(int i = 0; i <= n; i++) B[i] = inv[i + 3];
	NTT(B, 1);

	f[0][0] = 1;
	for(int i = 1; i <= m; i++)
	{
		for(int j = 0; j <= n; j++) A[j] = 1ll * f[i - 1][j] * inv[j] % mod;
		
		NTT(A, 1);
		for(int j = 0; j < lim; j++) A[j] = 1ll * A[j] * B[j] % mod;
		NTT(A, -1);

		f[i][0] = f[i - 1][0];
		for(int j = 1; j <= n; j++) 
			f[i][j] = ADD(1ll * fac[j + 2] * A[j - 1] % mod, 1ll * ADD(C(j + 1, 2), 1) * f[i - 1][j] % mod);

		for(int j = 0; j < lim; j++) A[j] = 0;
	}

	int ans = 0;
	for(int i = 0; i <= n; i++) ans = ADD(ans, 1ll * f[m][i] * C(n, i) % mod);

	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 6784
N=int(input())
announced = []
announced.append(input())
judge = True
for i in range(N-1):
    word = input()
    if (announced[i])[len(announced[i])-1] == word[0] and word not in announced:announced.append(word)
    else:
        judge = False
        print("No")
        break
if (judge): print("Yes")

Measured memory_bytes: 3060
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <random>
#include <cassert>
#include <limits>

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long long i = p; i < q; i++)
#define repd(i, p, q) for (long long i = p; i >= q; i--)
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> M;
typedef map<long, long> ML;
typedef map<long long, long long> MLL;
typedef pair<int, int> P;
typedef pair<long, long> PL;
typedef pair<long long, long long> PLL;
typedef int I;
typedef double D;
typedef long double LD;
typedef long L;
typedef long long LL;

LL b[100003] = {0};

int main()
{
    LL n, q;
    cin >> n >> q;
    string a;
    cin >> a;
    repi(i, 1, n)
    {
        if (a[i] == 'C' && a[i - 1] == 'A')
        {
            b[i] = b[i - 1] + 1;
        }
        else
        {
            b[i] = b[i - 1];
        }
    }
    LL l, r;
    while (q--)
    {
        cin >> l >> r;
        cout << b[r - 1] - b[l - 1] << "\n";
    }
    return 0;
}

Measured memory_bytes: 1792
import bisect
import sys

input=sys.stdin.readline

N,Q=map(int,input().split())
A=list(map(int,input().split()))
if N%2==1:
    data1=[A[i] for i in range(0,N)]
    for i in range(1,N):
        data1[-i-1]+=data1[-i]

    data2=[A[2*i] for i in range(0,N//2+1)]
    for i in range(1,len(data2)):
        data2[i]+=data2[i-1]
else:
    data1=[A[i] for i in range(0,N)]
    for i in range(1,N):
        data1[-i-1]+=data1[-i]

    data2=[A[2*i+1] for i in range(0,N//2)]
    for i in range(1,len(data2)):
        data2[i]+=data2[i-1]

for _ in range(Q):
    x=int(input())
    index=bisect.bisect_right(A,x)
    start=1
    end=N-index
    while end-start>1:
        test=(end+start)//2
        r=N-test-1
        l=bisect.bisect_left(A,2*x-A[-test])
        if r-l+1>=test-1:
            start=test
        else:
            end=test
    r=N-end-1
    l=bisect.bisect_left(A,2*x-A[-end])
    if r-l+1>=end-1:
        m=end
    else:
        m=start
    if m==0:
        m=1
    ans=data1[-m]
    num=(N-2*m+1)//2
    if num>0:
        ans+=data2[num-1]
    print(ans)


Measured memory_bytes: 80236
#include<bits/stdc++.h>
#define nl                 "\n"
#define f                  front
#define s                  second
#define ll                 long long
#define pb                 push_back
#define pf                 push_front
#define np                 next_permutation
#define pp                 prev_permutation
#define sz(x)              x.size()
#define sqr(x)             ((x)*(x))
#define pi                 acos(-1)
#define setprecision(x)    fixed<<setprecision((int)(x))
#define mem1(x)            memset(x,0,sizeof(x))
#define mem2(x)            memset(x,-1,sizeof(x))
#define all(x)             (x).begin(),(x).end()
#define rev(x)             reverse(all(x))
#define iota(x,a)          iota(all(x),a)
#define sorta(x)           sort(all(x))
#define sortd(x)           sort(all(x),greater<int>())
#define csort(x,c)         sort(all(x),c)
#define rsort(x)           sort(x.rbegin(),x.rend())
#define faster_io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define count_time         cerr<<nl<<"Time elapsed : "<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<nl;
#define all_ele(x)         for(auto i:(x)){cout<<i<<' ';}cout<<nl;
#define multiple_test      int t; cin>>t; while(t--){solve();}
#define multiple_test2     int t;cin>>t;for(int i=1; i<=t; i++){cout<<"Case #"<<i<<": "<<test()<<nl;}
#define single_test        solve();
using namespace std;
//vector<vector<int>>p(sz,vector<int>(sz,val));
/*
ll test()
{
    return value;
}
*/
void solve()
{
    int n;cin>>n;
    if(n>=30)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}
int main()
{
    faster_io //multiple_test2
    //multiple_test
    single_test
    //count_time
    return 0;
}




Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  cout << (N-2)*180 << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
g = 0
pre = -100
for i in range(n):
    if pre+1 == a[i]-1:
        g += c[pre]
    g += b[a[i]-1]
    pre = a[i]-1
print(g)

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const llint INF = 100000000;

int main(){
	int a;
	cin >> a;
	int ans = 0;
	if (a >= 1800)ans = 1;
	else {
		if (a >= 1600)ans = 2;
		else{
			if (a >= 1400)ans = 3;
			else {
				if (a >= 1200)ans = 4;
				else {
					if (a >= 1000)ans = 5;
					else{
						if (a >= 800)ans = 6;
						else {
							if (a >= 600)ans = 7;
							else ans = 8;
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3592
void main()
{
    long n = rdElem;
    long[] a = rdRow;

    long mod = 10 ^^ 9 + 7;
    long[] hat = new long[n];
    long result = 1;
    foreach (x; a)
    {
        if (x == 0)
        {
            result = result * (3 - hat[0]) % mod;
            ++hat[0];
        }
        else
        {
            result = result * (hat[x-1] - hat[x]) % mod;
            ++hat[x];
        }
    }

    result.writeln;
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 4348
N = int(input())
A = 0
B = 0
num = 0
ans = 10**10

for i in range(1, int((N)**(1/2)+1)):
  if N%i == 0:
    A = len(str(i))
    B = len(str(N//i))
    num = max(A, B)
    ans = min(ans, num)
print(ans)

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

int main(){
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  ll cnt = x / d;
  if(cnt > k){
    cout << x -k*d << endl;
    return 0;
  }
  if(cnt %2 != k %2) ++cnt;
  cout << abs(x -cnt *d) << endl;
}

Measured memory_bytes: 3668
import math

A, B, C = 7, 2, 5
K = 3

A, B, C = 7, 4, 2
K = 3

# A, B, C = 7, 7, 7
# K = 3
#
A, B, C = map(int, input().split())
K = int(input())


def calculate(a, b, c, k):
    res1 = 0
    while b <= a:
        b = b * 2
        res1 += 1

    res2 = 0
    while c <= b:
        c = c * 2
        res2 += 1

    result = res1 + res2
    if result <= k:
        print("Yes")
    else:
        print("No")


calculate(A, B, C, K)


Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
#define test int t;cin>>t;while(t--)
void fastcode()
{
    /*
    cout<<fixed<<setprecision(2);
    π = 3.141592653;
    itoa to convert any system itoa(n,bin,2)
    */
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int arr[101];
int main()
{
    /*freopen(" ","r",stdin);
    freopen(" ","w",stdout);*/
    fastcode();
    string s;
    cin>>s;
    if(s=="RRS"||s=="SRR")
    {
        cout<<2;
    }
    else if(s=="RSR"||s=="SRS"||s=="RSS"||s=="SSR")
    {
        cout<<1;
    }
    else if(s=="RRR")
    {
        cout<<3;
    }
    else
    {
        cout<<0;
    }
    return 0;
}


Measured memory_bytes: 3624
from sys import stdin
import numpy as np
from numba import njit
def main():
    #入力
    readline=stdin.readline
    n,k=map(int,readline().split())
    a=np.array(list(map(int,readline().split())),dtype=np.int64)

    cnt=0
    while cnt<k:
        s=f(n,a)
        a=np.cumsum(s)
        cnt+=1
        if a[a==n].size==n:
            break

    print(*a)

@njit(cache=True)
def f(n,a):
    s=np.zeros(n,dtype=np.int64)
    for i in range(n):
        x_min=i-a[i]
        x_max=i+a[i]+1
        s[max(0,x_min)]+=1
        if n-1<x_max:
            pass
        else:
            s[x_max]-=1
    return s

if __name__=="__main__":
    main()

Measured memory_bytes: 123072
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define deb(a) cout << a << ": "
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e6 + 7;
const int md = 1e9 + 7;
int a[N], p[N];
int mul(int a, int b) {
  return ((a % md) * (b % md)) % md;
}
int add(int a, int b) {
  return ((a % md) + (b % md)) % md;
}
void sliczny() {
  int n;
  int ans = 0;
  cin >> n;
  for(int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  p[n] = a[n];
  for(int i = n; i > 0; i--) {
    p[i - 1] = a[i - 1] + p[i];
  }
  for(int i = 1; i < n; i++) {
    int cur = mul(a[i], p[i + 1]);
    ans = add(ans, cur);
  }
  cout << ans;
}

int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; 
  for(int t = 1; t <= T; t++) {
    //cout << "Case #" << t << ": ";
    sliczny();
  }
  return 0;
}


Measured memory_bytes: 6760
"""
author : halo2halo
date : 23, Jan, 2020
"""

import sys

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
print(0 if N//K*K==N else 1)


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

int main()
{
    int n, m;
    cin >> n >> m;
    int h[100005];
    for(int i = 0; i < n; i++) cin >> h[i];
    bool f[100005];
    fill(f, f + n, true);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(h[a] <= h[b]) f[a] = false;
        if(h[b] <= h[a]) f[b] = false;
    }
    int ans = 0;
    for(int i = 0; i < n; i++) if(f[i]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 4060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
int a=0;
int b=0;
char s;
int main()
{
	while(cin >> s)
	{
		if((a==0)&&(s=='C'))
		{
			a=1;
		}
		else if((a==1)&&(s=='F'))
		{
			b=1;
		}
	}
	if((a==1)&&(b==1))
	{
		cout << "Yes" <<endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int x,rem,ans;
int a[15];
int mul[15];
vector<int>q;
int main() {
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&x);
		a[x]++;
	}
	a[0]++;
	ans=0;
	mul[1]=1;
	for(int i=2;i<15;i++)
	{
		mul[i]=mul[i-1]*2;
	}
	if(a[0]>1||a[12]>1)
	{
		printf("0\n");
		return 0;
	}
	for(int i=1;i<12;i++)
	{
		if(a[i]>2)
		{
			printf("0\n");
			return 0;
		}
	}
	for(int i=0;i<mul[13];i++)
	{
		q.clear();
		q.push_back(0);
		rem=24;
		for(int j=1;j<=12;j++)
		{
			if(a[j]==0)
			{
				continue;
			}
			else if(a[j]==1)
			{
				if((i&mul[j])==mul[j])
				{
					q.push_back(j);
				}
				else
				{
					q.push_back(24-j);
				}
			}
			else
			{
				q.push_back(j);
				q.push_back(24-j);
			}
		}
		sort(q.begin(),q.end());
		for(int j=1;j<q.size();j++)
		{
			for(int k=0;k<j;k++)
			{
				rem=min(rem,q[j]-q[k]);
				rem=min(rem,24-q[j]+q[k]);
			}
		}
		ans=max(ans,rem);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
//
// Created by kuroneko on 2019-08-10.
//
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>

using namespace std;

typedef long long ll;

#define INF 1000000000000009LL
#define MOD 1000000007LL

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight):src(src), dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

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

    for (int i = 0; i < N; i++) {
        int a, b; cin >> a >> b;
        v[i].first = a;
        v[i].second = b;
    }
    sort(v.begin(), v.end());

    priority_queue<int> q;

    int idx = 0;
    int ans = 0;
    for (int t = 0; t <= M; t++) {
        while (idx != N && v[idx].first <= t) {
            q.push(v[idx].second);
            idx++;
        }

        if (!q.empty()) {
            ans += q.top();
            q.pop();
        }
    }

    cout << ans << endl;
    return 0;
}


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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define PRINT(s) cout<<s
#define PRINTS(s) cout<<s<<' '
#define PRINTL(s) cout<<s<<endl
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    string s;
    cin>>s;

    for(int i=0;i<s.size();i+=2)cout<<s[i];
    cout<<endl;

    return 0;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    int N;
    cin >> N;
    vchar S(N), T(N);
    rep(i,N)
    {
        cin >> S[i];
    }
    rep(i,N)
    {
        cin >> T[i];
    }
    vchar ans(2*N);
    int j = 0, k = 0;
    rep(i, 2 * N)
    {
        if (i % 2 == 0)
            ans[i]= S[j++];
        else
            ans[i]= T[k++];
    }
    rep(i,2*N)
    {
        cout << ans[i];
    }
}

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

using namespace std;

#define int long long

typedef pair<int,int> ii;

int n,d,A;
ii a[200001];

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

	cin >> n >> d >> A;
	for (int i=1;i<=n;i++)
		cin >> a[i].first >> a[i].second;
	sort(a+1,a+1+n);
	int pos = 1;
	queue<ii> tmp;
	int cur = 0;
	int ans = 0;
	while(pos <= n)
	{
		while(!tmp.empty())
		{
			int z = tmp.front().first;
			int val = tmp.front().second;
			if (a[pos].first > z)
			{
				cur -= val;		
				tmp.pop();
			}
			else
				break;	
		}
		a[pos].second -= cur*A;
		if (a[pos].second <= 0) 
		{
			pos++;
			continue;
		}
		int cost = a[pos].second / A;
		if (a[pos].second % A) cost++;
		ans += cost;
		cur += cost;
		tmp.push(ii(a[pos].first + 2*d,cost));
		pos++;
	}
	cout << ans;
}

Measured memory_bytes: 4992
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
const long double eps = 1e-12;
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*2
#define REP(a,b) for(long long a = 0;a < b;++a)
long long start[200000] = {};
int main() {
	int n, k, query;
	cin >> n >> k >> query;
	REP(i, query) {
		long long a;
		cin >> a;
		start[a] += 1;
	}
	for (int i = 1; i <= n; ++i) {
		long long final_s = k + start[i] - query;
		if (final_s <= 0) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define int int64_t
#define watch(x) cout << (#x) << " is " << (x) << endl

const int32_t MAX=1e9+7;
typedef vector<int> vi;
typedef vector<int64_t> vll;


int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
	
	int x,y;
	cin >> x >> y;
	bool ans{false};
	// 4t+2c=y and t+c=x ... 2c+4x-4c=y ... 4x-2c=y ... 4x-y=2c;
	for(int c=0;c<=x;c++)
		if(4*x-2*c == y)
			ans=true;

	if(ans)
		cout << "Yes";
	else
		cout << "No";
    return 0;
}



Measured memory_bytes: 3588
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

X = INT()
i = int (X**0.5)

while i*(i+1)//2 < X:
	i += 1
print(i)

Measured memory_bytes: 13592
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MOD = 1e9 + 7;

void add_self(int &a, int b)
{
	a += b;
	if (a > MOD)
	{
		a -= MOD;
	}
}

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

	vector<vector<char>> matrix(n, vector<char>(m));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0;j < m; j++)
		{
			cin >> matrix[i][j];
		}
	}

	vector<vector<int>> dp(n, vector<int>(m));
	dp[0][0] = 1;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			for (int r2 : {i, i+ 1})
			{
				int c2 = j;
				if (r2 == i)
				{
					c2 = j + 1;
				}

				if (r2 < n && c2 < m && matrix[i][j] != '#')
				{
					add_self(dp[r2][c2], dp[i][j]);
				}
			}
		}
	}

	cout << dp[n -1][m -1 ]<<endl;
	
}



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

void testCase(){
    long long n;
    cin>>n;
    vector<long long> v(n);
    map<long long, long long> m;
    long long count = 0;
    for(long long i = 0; i < n; i++){
        cin>>v[i];
        // cout<<v[i]<<" ";
        count += m[i+1-v[i]];
        m[i+1+v[i]]++;
    }
    cout<<count<<endl;
}

int main(){
    int t;
    t = 1;
    // cin>>t;
    while(t--){
        testCase();
    }
}



Measured memory_bytes: 27540
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <string>
#include <functional>
#include <cassert>
#include <cmath>
#define SIZE 100005

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

int main()
{
	int m,d;
	scanf("%d %d",&m,&d);
	int ret=0;
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=d;j++)
		{
			int a=j%10,b=j/10;
			if(a>=2&&b>=2&&a*b==i) ret++;
		}
	}
	printf("%d\n",ret);
	return 0;
}


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

int main(void) {
  int N, T;
  cin >> N >> T;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  int minA = A[0];
  int maxBenefit = 0;
  int maxBenNum = 0;
  for (int i = 1; i < N; ++i) {
    int benefit = A[i] - minA;
    if (maxBenefit == benefit) {
      ++maxBenNum;
    } else if (maxBenefit < benefit) {
      maxBenefit = benefit;
      maxBenNum = 1;
    }
    minA = min(minA, A[i]);
  }

  cout << maxBenNum << endl;
  return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
const ll MOD = 1e9+7;

ll gcd (ll a, ll b) {
return b ? gcd (b, a % b) : a;
}

///modulo version
ll binpow(ll a,ll b) {
if (b == 0)return 1;ll res = binpow(a, b / 2)%MOD;
if (b % 2)return ((res%MOD * res%MOD)%MOD * a%MOD)%MOD;else return (res%MOD * res%MOD)%MOD;}

ll inv(ll A)
{
    return binpow(A,MOD-2);
}

//modulo arithmetic
inline ll add(ll a, ll b)
{
	ll res = a + b;
	if(res >= MOD)
		return res - MOD;
	return res;
}

inline ll mult(ll a, ll b)
{
	ll  res = a;
	res *= b;
	if(res >= MOD)
		return res % MOD;
	return res;
}

inline ll sub(ll a, ll b)
{
	return (a%MOD-b%MOD+MOD)%MOD;
}

int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n,k;
 	cin>>n>>k;
 	ll ans=0;
 	ll ways[k+1]={0};
 	ll sum=0;
 	for(ll i=k;i>=2;i--)
 	{
 		ll val=k/i;
 		ways[i]=binpow(val,n);
 		for(ll j=2*i;j<=k;j+=i)
 		{
 			// cout<<i<<"_"<<j<<endl;
 			ways[i]=sub(ways[i],ways[j]);
 		}
 		ans=add(ans,mult(i,ways[i]));
 		sum=add(sum,ways[i]);
 		//cout<<i<<" "<<ways[i]<<endl;
 	}
 	ans=add(ans,sub(binpow(k,n),sum));
 	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4372
# https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_c

N, K = map(int, input().split())
A = list(map(int, input().split()))

while K > 0:
    K -= 1
    # imos法 (B)
    B = [0] * (N + 1)
    for i in range(N):
        l = max(0, i - A[i])
        r = min(N - 1, i + A[i])
        B[l] += 1
        if r + 1 < N:
            B[r + 1] -= 1

    C = 0
    for j in range(N):
        C += B[j]
        A[j] = C

    if set(A) == set([N]):
        break

print(*A)

Measured memory_bytes: 146212
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=5e7+9;

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin); 
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll k,mod=0;
    cin>>k;
    for(int i=1;i<N;i++){
    	mod=((mod*10)+7)%k;
    	if(mod==0){
    		cout<<i;
    		return 0;
    	}
    }
    cout<<-1;
}
        




Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 100010;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int main(){
    string s; cin >> s;
    int n = s.size();
    string t = s.substr(0, (n - 1) / 2);
    string u = s.substr((n + 1) / 2, (n - 1) / 2);
    //cout << t << " "  << u << endl;

    string s2 = s;
    string t2 = t;
    string u2 = u;
    reverse(t2.begin(), t2.end());
    reverse(u2.begin(), u2.end());
    reverse(s2.begin(), s2.end());
    if(t2 == t and u2 == u and s2 == s) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}


bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

bool palin(string S){//回文判定
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
/*vector<int> d(N+1,-1);

//頂点xとの各点との最短距離を求める
void bfs(int x,Graph &G){
  d[x] = 0;
  queue<<int> que;
  que.push(x);

  // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
}*/

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  vector<int> P(N);
  rep(i,N){
    cin >> P[i];
  }
  int c1 = 0;//A以下の数
  int c2 = 0;//A+1以上B以下
  int c3 = 0;//B＋１以上
  rep(i,N){
    if(P[i] <= A) c1++;
    if(P[i] >= A +1 && P[i] <= B) c2++;
    if(P[i] >= B+1) c3++;
  }
  cout << min(c1,min(c2,c3)) << endl;

  
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s;
  cin>>s;
  if(s=='q'||s=='w'||s=='e'||s=='r'||s=='t'||s=='y'||s=='u'||s=='i'||s=='o'||s=='p'||s=='a'||s=='s'||s=='d'||s=='f'||s=='g'||s=='h'||s=='j'||s=='k'||s=='l'||s=='z'||s=='x'||s=='c'||s=='v'||s=='b'||s=='n'||s=='m')
    cout<<"a"<<endl;
  else cout<<"A"<<endl;
}

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

int main() {
    int N; string S;
    cin >> N >> S;
    long long r = 0, g = 0, b = 0;
    for (auto c : S) {
        if (c == 'R') ++r;
        else if (c == 'G') ++g;
        else ++b;
    }
    long long all = r * g * b;
    long long sub = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            if (S[i] == S[j]) continue;
            int k = j*2-i;
            if (k >= N || S[k] == S[i] || S[k] == S[j]) continue;
            ++sub;
        }
    }
    cout << all - sub << endl;
}

Measured memory_bytes: 3612
def sub():
    S = input()
    head = int(S[:2])
    tail = int(S[2:])

    isHeadMM = False
    if head <=12 and head >0:
        isHeadMM = True

    isTailMM = False
    if tail <=12 and tail >0:
        isTailMM = True

    if isHeadMM is True and isTailMM is False:
        print("MMYY")
    elif isHeadMM is False and isTailMM is True:
        print("YYMM")
    elif isHeadMM is True and isTailMM is True:
        print("AMBIGUOUS")
    else:
        print("NA")

sub()




Measured memory_bytes: 3060
import math
N,D = map(int,input().split())

X = [0]*N
for i in range(N):
    X[i] = list(map(int,input().split()))
ans=0

for i in range(N-1):
    for j in range(i+1,N):
        distance=0
        for k in range(D):
            distance += (X[i][k]-X[j][k])*(X[i][k]-X[j][k])
        distance=math.sqrt(distance)
        if int(distance)==distance:
            ans += 1

print(ans)


Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    string s; cin >> s;
    if(s[s.size()-1] == 's') cout << s << "es" << endl;
    else cout << s << "s" << endl;
}


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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	char 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: 3592
#include <bits/stdc++.h>
using namespace std;

int main(){
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    long long n, x;
    cin >> n >> x;
    cout << ceil(n * 1.0 / x) << '\n';
    
    return 0;
}


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

int main() {
    int D, G;
    cin >> D >> G;
    vector<int> p(D), c(D);
    for (int i = 0; i < D; i++) {
        cin >> p[i] >> c[i];
    }
    vector<int> v;
    for (int i = 0; i < (1 << D); i++) {
        int num = 0;
        int sum = 0;
        for (int j = 0; j < D; j++) {
            if (i & (1 << j)) {
                sum += p[j] * (100 * (j + 1)) + c[j];
                num += p[j];
            }
        }
        if (G <= sum) {
            v.push_back(num);
            continue;
        }
        for (int j = D - 1; j >= 0; j--) {
            if (!(i & (1 << j))) {
                    int rest = G - sum;
                    int tmp_num = (rest + (100 * (j + 1)) - 1) / (100 * (j + 1));
                    if (tmp_num < p[j]) {
                        num += tmp_num;
                        v.push_back(num);
                    }
                    break;
                }
        }
    }
    cout << *min_element(v.begin(), v.end()) << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split(' '))
l_val, r_val = map(int, input().split(' '))
for i in range(M-1):
    l, r = map(int, input().split(' '))
    l_val = max(l_val, l)
    r_val = min(r_val, r)
if r_val == l_val:
    print(1)
elif r_val < l_val:
    print(0)
else:
    print(r_val - l_val + 1)

Measured memory_bytes: 3064
n,t=map(int,input().split(' '));T=list(map(int,input().split(' ')))
total = 0
tstart, tend = T[0],T[0]+t
i = 1
while i < n:
    if T[i] > tend:
        total += (tend-tstart)
        tstart,tend = T[i],T[i]+t
    else:
        tend = T[i]+t
    i += 1
total += (tend-tstart)
print(total)

Measured memory_bytes: 26708
// C++(Clang 10.0.0)

//GCC用 ナゾです
//#pragma GCC target("avx")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <stdio.h>
#include <stdlib.h> //rand() 0~RAND_MAX2147483647
#include <math.h>
#include <time.h>   //srand((unsigned int)time(NULL));
#include <unistd.h> //sleep
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <unordered_map>
#include <set>
#include <cassert> //assart(x>=0) -> x<0の時異常終了
#include <numeric>
#include <iterator>
#include <list>
#include <tuple>
#include <queue>

using namespace std;
#define ll long long int
#define FOR(i,min,max) for(ll i=(min);i<(max);i++)
#define FOReq(i,min,max) for(ll i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(ll i=(max)-1;i>=(min);i--)
#define FORREVeq(i,max,min) for(ll i=(max);i>=(min);i--)

#define all(vec) (vec).begin(),(vec).end()

const int MOD=1e9+7;
const int MOD2=998244353;
const int not0=1;
const int INF=2000000001;
const ll INFll=2e18;
//const int MAX_V=10000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INFll || MOD2 || not0){;}
    return 0;
}

#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
//#define br printf("\n");
#define br cout<<"\n";
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}
#define elif else if

#define issame(a,b,c,d) ((a)==(b) and (b)==(c) and (c)==(d))
#define isdiff3(a,b,c) ((a)!=(b) and (b)!=(c) and (c)!=(a))
#define isdiff4(a,b,c,d) ((a)!=(b) and (b)!=(c) and (c)!=(a) and (d)!=(a) and (d)!=(b) and (d)!=(c))
#define isdiff5(a,b,c,d,e) ((a)!=(b) and (b)!=(c) and (c)!=(a) and (d)!=(a) and (d)!=(b) and (d)!=(c) and (e)!=(a) and (e)!=(b) and (e)!=(c) and (e)!=(d))
#define Func3(f,a,b,c) (f)((f)((a),(b)),(c))
#define Func4(f,a,b,c,d) (f)((f)((f)((a),(b)),(c)),(d))

inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
inline ll samepair(ll x){return x*(x-1)/2;}
inline ll  gcd(ll a,ll b){ if(b==0)return a;else return gcd(b,a%b);}//最大公約数 なお一方が0なら答えは他方になるので番兵は０で良い また、負の数もOK -4%3=-1となるため
inline ll  lcm(ll a,ll b){return a*b/gcd(a,b);}//MODやオーバーフローには注意！
//inline ll  ceil(double a){return (ll)a+1;}
//ans = accumulate(A, A+N, 0, [](int a, int b) {return gcd(a,b);});
//auto count = std::count_if(v.begin(), v.end(), [](int x) { return x == 1 || x == 3; } );

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

//累積和　しゃくとり法　木構造　DP キュー　乱択アルゴリズム　嘘解法　ハッシュ　next_permulation

//課題：DP 木構造　Xor

ll probNow(){
    ll ans;ans=0;
    ll N;
    cin>>N;
    
    ll P[N];
    inarray(P, 0, N);
    
    ll mini=INF;
    FOR(i, 0, N){
        if(mini>P[i])ans++;
        mini=min(mini,P[i]);
    }
   
    
    OutputAndReturn0(ans);
    return 0;
}

signed main(){
    cin.tie(0);    //cinとcoutの結び付き解除（cout時にcinの内容を吐き出さなくなる）
    ios::sync_with_stdio(false);  //coutとprintfの結び付き解除（coutとprintfを同時に使うな！）
    probNow();
    return 0;
}


Measured memory_bytes: 1792
H,W = map(int,input().split())
L = []
for i in range(H):
  L.append(list(input()))
cnt = 0
for j in range(H):
  for k in range(W):
    if L[j][k] == '#':
      cnt += 1
if cnt == H+W-1:
  print('Possible')
else:
  print('Impossible')

Measured memory_bytes: 3060