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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int c[3][3];
    rep(i,0,3) rep(j,0,3) cin >> c[i][j];

    rep(a1,-100,101) rep(a2,-100,101) rep(a3,-100,101){
        int b1=c[0][0]-a1,b2=c[0][1]-a1,b3=c[0][2]-a1;
        if(a2+b1!=c[1][0]) continue;
        if(a2+b2!=c[1][1]) continue;
        if(a2+b3!=c[1][2]) continue;
        if(a3+b1!=c[2][0]) continue;
        if(a3+b2!=c[2][1]) continue;
        if(a3+b3!=c[2][2]) continue;
        cout << "Yes" << endl;
        return;
    } 

    cout << "No" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

pair<int,int> find(int n, vvi const& v){
	rep(i,v.size())rep(j,v[i].size()){
		if(v[i][j]==n)return make_pair(i,j);
	}
	return make_pair(-1,-1);
}

void view(vvi const& v){
	puts("v---");
	rep(i,v.size()){
		rep(j,v[i].size()){
			cout<<v[i][j]<<" ";
		}
		cout<<endl;
	}
	puts("^---");
}

int main(){
	int m;
	while(cin>>m && m){
		int a,b;
		vvi ps(m);
		rep(i,m)ps[i]={i+1};
		while(cin>>a>>b && a|b){
			auto ia=find(a,ps), ib=find(b,ps);
			vi &A=ps[ia.first], &B=ps[ib.first];
			if(b==0){
				if(ia.second==0) continue;
				while(1){
					int top=A.back();
					ps.push_back({top});
					A.pop_back();
					if(top==a)break;
				}
			}else if(ia.first==ib.first){
				if(ia.second < ib.second){
					ps.push_back({b,a});
					while(1){
						int top=A.back();
						if(top!=a && top!=b){
							ps.push_back({top});
						}
						A.pop_back();
						if(top==a) break;
					}
				}
			}else{
				while(1){
					int top=A.back();
					A.pop_back();
					if(top==a){
						B.push_back(a);
						break;
					}else{
						ps.push_back({top});
					}
				} 
			}
			ps.erase(remove_if(ps.begin(),ps.end(),[](const vi& v){return v.size()==0; }),ps.end());
		}
		vi ans;
		rep(i,ps.size())if(ps[i].size())ans.push_back(ps[i].size());
		sort(ans.begin(),ans.end());
		for(int i=0;i<ans.size();i++){
			cout<<ans[i]<<endl;
		}
		cout<<"end"<<endl;
	}
}

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

using namespace std;

#define int long long

int hell = 1e9 + 7;

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n,i,j;
	cin>>n;
	vector< double > P(n);
	for(i = 0; i < n; i++)
		cin>>P[i];
	vector< vector< double > > dp(n, vector<double>(n+1,0));
	// dp[i][j] = probability that among first i+1 coins, j coins are heads
	dp[0][0] = 1-P[0];
	dp[0][1] = P[0];
	for(i = 1; i < n; i++)
	{
		dp[i][0]  = dp[i-1][0] * (1-P[i]);
		for(j = 1; j <= n; j++)
			dp[i][j] = (dp[i-1][j-1]*P[i]) + (dp[i-1][j]*(1-P[i]));
	}
	double ans = 0;
	for(i = (n/2) + 1; i <= n; i++)
		ans += dp[n-1][i];
	cout<<setprecision(10)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 70784
#define f first
#define s second
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
 
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    //freopen("Inp.txt","r", stdin);
    //freopen("Out.txt","w", stdout);
 
    int n; cin >> n;
    vector <pair <int,int> > a;
    a.push_back(make_pair(1,2));
    a.push_back(make_pair(2,5));
    a.push_back(make_pair(3,5));
    a.push_back(make_pair(4,4));
    a.push_back(make_pair(5,5));
    a.push_back(make_pair(6,6));
    a.push_back(make_pair(7,3));
    a.push_back(make_pair(8,7));
    a.push_back(make_pair(9,6));
    
    int k; cin >> k;
    vector<pair<int,int> > b(k);
    for (int i = 0;i < k;i++)
    {
    	int t; cin >> t;
    	b[i] = a[t-1];
    }
    sort(b.begin(),b.end());
 
    vector <int> dp(n+1,0);
    vector <vector<int> > res(n+1,vector<int>(k,0));
    for (int i = 0 ; i <= n; i++)
    {
    	for (int j = 0; j < k; j++)
    	{
    		if (b[j].s <= i)
    		{
    			int pre = dp[i];
				dp[i] = max (dp[i], dp[i-b[j].s]+1);
				if (dp[i] == 1 && !(i-b[j].s == 0))
					dp[i] = 0;
				if (dp[i] == dp[i-b[j].s]+1)
				{
					for (int t = 0; t < k; t++)
						res[i][t] = res[i-b[j].s][t] + (j == t);
				}
    		}
    	}
    }
    for (int i = k-1; i >=0; i--)
    {
    	while (res[n][i]>0)
    	{
    		cout << b[i].f;
    		res[n][i]--;
    	}
    }
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

#define MAXR 100
#define MAXC 100

int main(){
    int r,c;
    int sumr[MAXR] = {0}, sumc[MAXC] = {0}, sumall = 0;
    int i,j,x;
    scanf("%d %d", &r, &c);
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            scanf("%d", &x);
            sumr[i] += x;
            sumc[j] += x;
            printf("%d ", x);
        }
        sumall += sumr[i];
        printf("%d\n", sumr[i]);
    }
    for(j=0;j<c;j++){
        printf("%d ",sumc[j]);
    }
    printf("%d\n", sumall);
    return 0;
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    double a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2.0 << endl;
}

Measured memory_bytes: 256
t,s=open(0)
n,k=map(int,t.split())
l=2*k+1
x=[0]+[i for i in range(n)if s[i]!=s[i-1]]+[n]*l
print(max(x[i+l]-x[i]for i in range(s>'1',len(x)-l,2)))

Measured memory_bytes: 8672
#include<stdio.h>
#include<stdlib.h>

int main(){
  int *A;
  int i,n,key;

  scanf("%d",&n);
  A = malloc(sizeof(int)*n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  printf("node 1: key = %d, left key = %d, right key = %d, \n",A[0],A[1],A[2]);
  for(i=1;i<n;i++){
    printf("node %d: key = %d, parent key = %d,",i+1,A[i],A[(i-1)/2]);
    if(i*2+1<n)printf(" left key = %d,",A[i*2+1]);
    if((i+1)*2<n)printf(" right key = %d,",A[(i+1)*2]);
    printf(" \n");
  }
  free(A);
  return 0;
}



Measured memory_bytes: 2112
#include <iostream>

using namespace std;

int main()
{
    int N;
    cin>>N;
    int i=0,j=0;
    int judge=0;
    if(N%4==0||N%7==0)
    {
        cout<<"Yes";
        judge=1;
    }

    else
    {
    for( i=0;i<=275;i++)
    {
        if(judge==1)
            break;
        for( j=0;j<=158;j++)
       {
        if(4*i+7*j==N)
        {
              cout<<"Yes";
              judge=1;
              break;
        }

        if(4*j+7*i==N)
        {
             cout<<"Yes";
             judge=1;
             break;
        }

        }
    }

    }

    if(judge==0)
        cout<<"No";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
class Point{
  public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}
  Point operator + (Point p){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(a*x,a*y);}
  Point operator / (double a){return Point(x/a,y/a);}
  bool operator < (const Point &p) const{
    return x!=p.x?x<p.x:y<p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
  }
};
struct seg{Point p1,p2;};
//??????
double dot(Point a,Point b){
  return a.x*b.x+a.y*b.y;
}
//??????
double cross(Point a,Point b){
  return a.x*b.y-a.y*b.x;
}
//??´?????????
bool C90(seg s1,seg s2){
  return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}
bool C0(seg s1,seg s2){
  return equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}


main(){
  int n;
  cin>>n;
  while(n--){
    seg a,b;
    cin>>a.p1.x>>a.p1.y>>a.p2.x>>a.p2.y;
    cin>>b.p1.x>>b.p1.y>>b.p2.x>>b.p2.y;
    if(C0(a,b))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

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

int main()
{
	int n, x, m, w = 1001;

	cin >> n >> x;

	for (int i = 0; i < n; i++) {
		cin >> m;
		x -= m;
		if (w > m)
			w = m;
	}

	cout << n + x / w << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std;

const int N=400010;
int n,A,B,C,D;
char s[N];

int main(){
	scanf("%d%d%d%d%d%s",&n,&A,&B,&C,&D,s+1); bool flag=0;
	rep(i,A+1,C) if (s[i]=='#' && s[i-1]=='#'){ puts("No"); return 0; }
	rep(i,B+1,D) if (s[i]=='#' && s[i-1]=='#'){ puts("No"); return 0; }
	if (C<D){ puts("Yes"); return 0; }
	rep(i,B,D) if (s[i-1]=='.' && s[i]=='.' && s[i+1]=='.'){ flag=1; break; }
	if (!flag) puts("No"); else puts("Yes");
	return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
N = int(input())
an = list(map(int, input().split()))

col = {x:0 for x in range((4800//400) + 1)}
for ai in an:
    col[ai//400] +=1

cnt1 = 0
cnt2 = 0
for k,v in col.items():
    if v > 0:
        if k < 8:
            cnt1 += 1
        else:
            cnt2 += v

print(max([cnt1,1]),cnt1+cnt2)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int a, b, tmp;
    cin>>tmp;
    a=tmp;
    cin>>tmp;
    if(a>tmp) a=tmp;
    
    cin>>tmp;
    b=tmp;
    cin>>tmp;
    if(b>tmp) b=tmp;
    
    cout<<a+b;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <sstream>
#include <cassert>
#include <functional>
#include <cfloat>
#include <climits>
#include <cstring>
#include <stack>
#include <time.h>
#include <complex>
using namespace std;
int main()
{
    long long N;
    long long M;
    long long ans;
    cin>>N>>M;
    if(N*2>=M)
        ans=M/2;
    else ans=(2*N+M)/4;
    cout<<ans<<endl;
    return 0;
}

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

#define fff(i,a,b) for(int (i)=(a);(i)<=(b);i++)
#define pb push_back
#define len(a) (a).length()
#define all(a) (a).begin(),(a).end()
#define sz(a) (a).size()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long ,long long > pll;
typedef unsigned long long ull;
typedef long double ld;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin>>n;
	int a,b,c;
	int dpa[n];
	int dpb[n];
	int dpc[n];
	fff(i,0,n-1)
	{
		cin>>a>>b>>c;
		if(i==0)
		{
			dpa[0]=a;
			dpb[0]=b;
			dpc[0]=c;
		}
		else
		{
			dpa[i]=max(dpb[i-1],dpc[i-1])+a;
			dpb[i]=max(dpa[i-1],dpc[i-1])+b;
			dpc[i]=max(dpa[i-1],dpb[i-1])+c;
		}
	}
	cout<<max(max(dpc[n-1],dpb[n-1]),dpa[n-1])<<endl;
	
 	return 0;
}

Measured memory_bytes: 1408
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)


def main():
    n = I()
    a = [S() for _ in range(n)]
    ss = '-'
    r = 0
    ba = []
    ta = []
    tb = []
    for s in a:
        if s[0] == 'B':
            if s[-1] == 'A':
                ba.append(s)
            else:
                tb.append(s)
        elif s[-1] == 'A':
            ta.append(s)
        else:
            r += len(s.split('AB')) - 1

    while ba or ta or tb:
        if ss[-1] == 'A':
            if ba:
                ss += ba[-1]
                ba = ba[:-1]
            elif tb:
                ss += tb[-1]
                tb = tb[:-1]
            else:
                ss += ta[-1]
                ta = ta[:-1]
        else:
            if ta:
                ss += ta[-1]
                ta = ta[:-1]
            elif ba:
                ss += ba[-1]
                ba = ba[:-1]
            else:
                ss += tb[-1]
                tb = tb[:-1]
    # print(r,ss)

    return r + len(ss.split('AB')) - 1


print(main())




Measured memory_bytes: 7124
#include <bits/stdc++.h>
 
using namespace std;
 
#define ld long double
#define ll long long
#define ull unsigned long long
#define dd double
#define lbits 64
#define ibits 32

const double pi = acos(-1);
const ll mod = (ll)(1e9 + 9);

bool isPrime(ll x){for(int i=2;i*i<=x;i++)if(x%i==0)return false;return true;}
double dist(dd a,dd b,dd c,dd d){return sqrt((c-a)*(c-a)+(d-b)*(d-b));}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
    srand(time(0));

    int n,m,k;cin>>n>>m>>k;
    vector<vector<char>> g(n,vector<char>(m));
    vector<vector<int>> ans(n,vector<int>(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>g[i][j];
        }
    }
    int c = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(g[i][j] == '#'){
                int s = j,e = j;
                for(int k=j - 1;k>=0;k--){
                    if(ans[i][k] == 0 && g[i][k] == '.'){
                        s = k;
                    }
                    else {
                        break;
                    }
                }
                for(int k=j + 1;k<m;k++){
                    if(ans[i][k] == 0 && g[i][k] == '.'){
                        e = k;
                    }
                    else {
                        break;
                    }
                }
                c++;
                for(int k=s;k<=e;k++){
                    ans[i][k] = c;
                }
                int x = i - 1;
                while(x >= 0){
                    bool done = 1;
                    for(int k=s;k<=e;k++){
                        if(g[x][k] == '#' || ans[x][k] != 0){
                            done = 0;
                            break;
                        }
                    }
                    if(done){
                        for(int k=s;k<=e;k++){
                            ans[x][k] = c;
                        }   
                        x--;
                    }
                    else {
                        break;
                    }
                }
                x = i + 1;
                while(x < n){
                    bool done = 1;
                    for(int k=s;k<=e;k++){
                        if(g[x][k] == '#' || ans[x][k] != 0){
                            done = 0;
                            break;
                        }
                    }
                    if(done){
                        for(int k=s;k<=e;k++){
                            ans[x][k] = c;
                        }
                        x++;
                    }
                    else {
                        break;
                    }
                }
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cout<<ans[i][j]<<" ";
        }
        cout<<"\n";
    }

    // CHECK THE OVERFLOW
    // CHECK THE BOUNDS

    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL>V;
typedef set<LL>S;
int func(LL n){
	if(n<2)		return 0;
	if(n==2)	return 1;
	else{
		if(n%2==0)	return 0;
	}
	double nn=sqrt(n);
	for(int i=3;i<=nn;i+=2){
		if(n%i==0){
			return 0;
		}
	}
	return 1;
}
int main(void){
	LL a,b;
	LL n,cnt;
	V v,v1,v2;
	LL i;
	S s;
	cin>>a>>b;
	for(i=1;i<=sqrt(a);i++){
		if(a%i==0){
			v1.push_back(i);
			v1.push_back(a/i);
		}
	}
	for(i=1;i<=sqrt(b);i++){
		if(b%i==0){
			v2.push_back(i);
			v2.push_back(b/i);
		}
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	// for(auto &it:v1)	cout<<it<<" ";
	// cout<<endl;
	// for(auto &it:v2)	cout<<it<<" ";
	// cout<<endl;
	for(auto &it:v1)	s.insert(it);
	for(auto &it:v2){
		auto it2=s.find(it);
		if(it2!=s.end())	v.push_back(*it2);
	}
	// for(auto &it:v)	cout<<it<<" ";
	// cout<<endl;
	cnt=1;
	for(i=1;i<(int)v.size();i++){
		n=v[i];
		int x=func(n);
		if(x==1)	cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	while(d <= x && k){
		ll mul = x / d;
		mul = min(mul, k);
		k -= mul;
		if(x > 0){
			x -= d*mul;
		}
		x = abs(x);
	}
	if(k%2){
		cout << abs(x - d) << endl;
	}
	else{
		cout << abs(x) << endl;
	}
	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>

int main(void) {
	int N, i, j, l, M;
	int* A;
	scanf("%d", &N);
	A = (int*)malloc(sizeof(int) * N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	int S = 0, T = 0;
	for (j = 0; j < N; j++) {
		S = S + A[j];
	}
	for (l = 0; l < N; l = l + 2) {
		T = T + A[l];
	}
	printf("%d ", 2 * T - S);
	M = 2 * T - S;
	for (i = 0; i < N - 1; i++) {
		M = (A[i] - M / 2) * 2;
		printf("%d ", M);
	}
	free(A);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main() {
    int c[3][3];
    rep(i, 3) rep(j, 3) cin >> c[i][j];

    int a[3], b[3];
    a[0] = 0;
    rep(i, 3) b[i] = c[0][i] - a[0];
    rep(i, 3) a[i] = c[i][0] - b[0];

    bool ok = true;
    rep(i, 3) {
        rep(j, 3) {
            int tmp = a[i] + b[j];
            if(tmp != c[i][j]) ok = false;
        }
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    S = input_raw[0]
    X = int(S[:2])
    Y = int(S[2:])
    if((1 <= X and  X <= 12) and (1 <= Y and  Y <= 12)):
        print "AMBIGUOUS"
    elif(1 <= X and  X <= 12) :
        print "MMYY"

    elif(1 <= Y and  Y <= 12):
        print "YYMM"
    else:
        print "NA"

if __name__ == '__main__':
    main()


Measured memory_bytes: 2932
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(D, T, S):
    return 'Yes' if D <= T*S else 'No'


def main():
    D, T, S = read_int_n()
    print(slv(D, T, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 77040
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a,b;
    cin >> a >> b;
    if(a <= 5){
        cout << 0 << endl;
    }
    else if(a <= 12){
        cout << b/2 << endl;
    }
    else{
        cout << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int n;
	cin >> n;
	vector<int> dp(n , INF);
	vector<int> h(n);
	for (int i = 0; i < n; i++){
		cin >> h[i];
	}
	dp[0] = 0;
	for (int i = 0; i < n; i++){
		for (int j = 1; j <= 2; ++j){
			if (i + j < n)
				dp[i + j] = min(dp[i + j] , dp[i] + abs(h[i] - h[i + j]));
		}
	}
	cout << dp[n - 1];
	return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

struct food {
	string name;
	int w;
	int s;
};
int N;
vector<food>fs;
pair<int,vector<string>> memo[1024];

pair<int,vector<string>> getans(bitset<10>&used,int num,int sum) {
	if (memo[used.to_ulong()].first != -1) {
		return memo[used.to_ulong()];
	}
	else {
		if (used.count() == N)return make_pair(0, vector<string>());
		else {
			pair<int, vector<string>>ans(int(1e8), vector<string>());
			for (int i = 0; i < N; ++i) {
				if (!used[i]&&fs[i].s>=sum) {
					used[i] = true;
					const int nextsum = sum + fs[i].w;
					vector<string>nans;
					auto p = getans(used, num + 1, nextsum);
					p.first += (N-num)*fs[i].w;
					p.second.push_back(fs[i].name);
					if (p.first < ans.first) {
						ans = p;
					}
					used[i] = false;
				}
			}
			return memo[used.to_ulong()] = ans;
		}
	}
}

int main() {
	while (1) {
		for (int i = 0; i < 1024; ++i) {
			memo[i] = make_pair(-1,vector<string>(1," "));
		}
		cin >> N;
		if (!N)break;
		fs.clear();
		for (int i = 0; i < N; ++i) {
			string name; int w, s; cin >> name >> w >> s;
			fs.push_back(food{ name,w,s });
		}
		bitset<10>used;
		auto ans = getans(used, 0, 0);
		for (auto n : ans.second) {
			cout << n << endl;
		}

	}
	return 0;
}

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

int main(){
  int H,N;
  cin>>H>>N;
  vector<int> A(N);
  int sum=0;
  for(int i=0;i<N;i++){
cin>>A.at(i);
    sum+=A.at(i);
  }
  if(sum-H>=0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mk make_pair
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define vl vector<long long int>
#define vvl vector<vector<ll> > 
#define fo(i,a,b) for(int i=a;i<b;i++)
#define rof(i,a,b)  for(int i=b;i>=a;i--)
using namespace std;
ll mod=1000000007;
int main()
{
    ll h,w;cin>>h>>w;
    char a[h+1][w+1];ll dp[h+1][w+1];
    memset(dp,0,sizeof(dp));
    fo(i,0,h)
        fo(j,0,w)
            cin>>a[i][j];
    dp[0][0]=1;
    fo(i,1,h)
    {
        if(a[i][0]=='.')
            dp[i][0] = a[i-1][0]=='.'?dp[i-1][0]:0;
        if(a[0][i]=='.')
            dp[0][i] = a[0][i-1]=='.'?dp[0][i-1]:0;
    }
    fo(i,1,h)
        fo(j,1,w)
        {
            dp[i][j] += a[i-1][j]=='.'?dp[i-1][j]:0;
            dp[i][j] += a[i][j-1]=='.'?dp[i][j-1]:0;
            dp[i][j]=dp[i][j]%(1000000007);
            if(a[i][j]=='#')
                dp[i][j]=0;
        }
    cout << dp[h-1][w-1];
}



Measured memory_bytes: 12340
n, w = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(n)]

dp = [[0]*(w+8) for _ in range(n+10)]
weight = [0] * (n)
value = [0] * (n)

for i in range(n):
    weight[i] = li[i][0]
    value[i] = li[i][1]

for i in range(n):
    for j in range(w+1):
        if j - weight[i] >= 0:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j - weight[i]] + value[i])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[n][w])

Measured memory_bytes: 156620
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#define lowbit(a) ((a)&(-(a)))
using namespace std;

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
}

int main()
{
	int a, b;
	cin >> a >> b;
	if (a <= 5)
		puts("0");
	else if (a <= 12)
		printf("%d\n", b / 2);
	else
		printf("%d\n", b);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll n;
	cin >> n;
	vector<ll> vet(n);
	vector<ll> val;
	for(ll i = 0;i<n;i++){
		cin >> vet[i];
		val.push_back((vet[i]-(i+1)));
	}
	ll b = 0;
	sort(val.begin(),val.end());
	if(val.size()&1)
		b = val[val.size()/2];
	else
		b = (val[val.size()/2-1]+val[val.size()/2])/2;
	
	ll soma = 0;
	
	for(ll i = 0;i<n;i++){
		soma += abs(vet[i]-(i+1)-b);
	}
	cout<<soma;

}

Measured memory_bytes: 3956
n = int(input())
ans = 0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** .5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors
divs = make_divisors(n)
ans = 0
for d in divs:
    m = d - 1
    if m == 0:
        continue
    if n // m == n % m:
        ans += m
print(ans)

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

int Max(int &a,int b){return a = max(a,b);}

int dp[2][1001][1001];
int check(const string &a,const string &b){
  int n = a.size();
  int m = b.size();
  assert(n==m);
  int res = 0;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      Max(res,dp[0][i][j]);
      Max(res,dp[1][i][j]);
      if(j<n) Max(dp[1][i][j+1],dp[1][i][j]);
      if(i<n) Max(dp[0][i+1][j],dp[1][i][j]+1);
      if(i<n&&j<n&&a[i]==b[j])Max(dp[1][i+1][j+1],dp[0][i][j]+1);
    }
  }
  return res>=n;
}

int main(){
  string a,b;
  cin>>a>>b;
  bool ans = check(a,b);
  cout<<(ans? "Yes":"No")<<endl;
  return 0;
}

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

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

    int X;
    cin >> X;

    int sum = 0;
    int i = 1;
    int t = 0;
    while(sum < X){
        sum += i;
        ++i;
        ++t;
    }
    cout << t << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){ 
	vector<ll>a;
	map<ll,ll>l;
	int n;
	cin >> n;
	ll len;
	for (int i =0;i<n;i++)
	{
		cin >> len;
		l[len]++;
		if(l[len]==2)
			{
				a.push_back(len);
			}
		else if (l[len]==4)
		{
			a.push_back(len);
		}
	}
	sort(a.begin(),a.end());
	if (a.size()<=1){
		cout<<"0";
	}
	else {
		cout<< a[a.size()-1]*a[a.size()-2];
	}
	return 0;
}

Measured memory_bytes: 6528
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define ll long long
#define debug(x) cout << "debug: " << x << endl
#define MOD 1e9 + 7
#define INF 1e9

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;
}

int main() {
  int N;
  int A[210];
  cin >> N;
  rep(i, N) cin >> A[i];
  int res = 0;

  while (true) {
    bool exist_odd = false;
    rep(i, N) {
      if (A[i] % 2 != 0)
        exist_odd = true;
    }
    if (exist_odd)
      break;

    rep(i, N) { A[i] /= 2; }
    ++res;
  }

  cout << res << endl;

  return 0;
}


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

int sumall(int n){
  int sum = 0;
  while(n>0){
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  int total = 0;
  for(int i=1;i<=N;i++){
    int sum = sumall(i);
    if(sum>=A && sum <=B){
    total += i;
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 256
def resolve():
    s = input()
    out = 0
    l = []
    for i in range(3):
        if s[i] == 'R':
            out += 1
        elif s[i] == 'S':
            l.append(out)
            out = 0
    l.append(out)
    print(max(l))
resolve()    

Measured memory_bytes: 9048
#include <stdio.h>
         
    int main(void)
    {
    int H,W,A,B;
    (void)scanf("%d %d %d %d",&H,&W,&A,&B);
    	for (int i=0; i<H; i++) {
    		for (int j=0; j<W; j++) {
    			putchar('0'+((i<B)^(j<A)));
    		}
    		putchar('\n');
    	}
    return 0;
    }

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

int main(){
    string S,T;
    cin >> S >> T;
    int flag =0;
    for(int i=0;i<S.size();i++){
        if(S[i] != T[i]){
            cout << "No";
            flag = 1;
            break;
        }  
    }
    if(flag == 0) cout << "Yes";
}


Measured memory_bytes: 3596
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e2 + 10;
bool check(int n)
{
	string str = to_string(n);
	int l = 0, r = str.length() - 1;
	while (l < r)
	{
		if (str[l++] != str[r--]) return false;
	}
	return true;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b;
	cin >> a >> b;
	int cnt = 0;
	for (int i = a; i <= b; i++)
	{
		if (check(i))
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  vector<ll> c(n);
  vector<ll> na(n, 0);
  vector<ll> nb(n, 0);
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < n; ++i) cin >> b[i];
  for(int i = 0; i < n; ++i) cin >> c[i];

  sort(ALL(b));
  sort(ALL(c));

  for(int i = 0; i < n; ++i)
  {
    auto itc = upper_bound(ALL(c), b[i]);
    nb[i] = distance(itc, c.end());
  }
  for(int i = n - 2; i >= 0; --i)
  {
    nb[i] += nb[i + 1];
  }
  for(int i = 0; i < n; ++i)
  {
    auto itb = upper_bound(ALL(b), a[i]);
    na[i] = nb[distance(b.begin(), itb)];
  }
  cout << accumulate(ALL(na), 0LL);
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 7140
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <unordered_map>
#include <assert.h>
using namespace std;

#define ran(i, a, b) for ((i) = (a); (i) < (b); (i)++)
#define rep(i, a) ran ((i), 0, (a))
#define rep1(i, a) ran ((i), 1, (a)+1)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
#define _0 first
#define _1 second
#define _pb(x) push_back(x)
#define _mp(x, y) make_pair(x, y)
#if defined(SHIROKO1_LOCAL) && !defined(NDEBUG)
#define DEBUG(...) fprintf(stderr, "[DEBUG] " __VA_ARGS__)
#else
#define DEBUG(...) ((void)0)
#endif



int main()
{
	int N;
	int ans = 0;
	cin >> N;
	while (N--) {
		int l, r;
		cin >> l >> r;
		ans += r-l+1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll k,a,b;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> k>>a>>b;
    ll k1=k;
    if(a+1>=b){
        cout << 1+k << "\n";
        return 0;
    }
    ll now=1;
    now+=min(a-1,k);
    k-=min(a-1,k);
    if(k==0){
        return cout<<now<<"\n",0;
    }
    now=(b-a)*(k/2)+now;
    if(k%2){
        now++;
    }
    cout<<max(now,1+k1)<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100001];
int ar[100001];

int calc(int i,int n,int k){
  if(i==n-1)return 0;
  if(i>n)return INT_MAX-1;
  if(dp[i]!=-1)return dp[i];
  int mini,ans;
  mini=INT_MAX;
  for(int l=1;l<=k;l++){
      
      if(i+l<n){
          //cout<<ar[i]<<" ";
          ans=calc(i+l,n,k)+abs(ar[i+l]-ar[i]);
          mini=min(mini,ans);
      }
  }
  return dp[i]=mini;
}
int main(){
    int n,k;
    cin>>n>>k;
   // int ar[n];
   memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++){
        cin>>ar[i];
       // cout<<ar[i];
    }
    int ans=calc(0,n,k);
    cout<<ans<<endl;
}

Measured memory_bytes: 7296
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int n;
    cin >> n;
    set<int> t;
    REP(i, n){
        int a;
        cin >> a;
        if(t.count(a)){
            cout << "NO" << endl;
            return 0;
        }
        t.insert(a);
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = a; i < (b + a); i++)
#define W1 while (1)
#define COUT(x) cout << x << endl
using namespace std;
using ll = long long;
using ld = long double;
#define ALL(x) x.begin(),x.end()
#define P pair<int,int>
#define mod 1000000007
#define PB push_back
#define F first
#define S second

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int ans = r / d - (l - 1) / d;
  COUT(ans);

  return 0;
}


Measured memory_bytes: 3628
n,m = map(int,input().split())
p = [list(input().split())for _ in range(m)]

q = [0]*n
count = 0
wacount = 0

for i in range(m):
  if p[i][1] == "WA":
    q[int(p[i][0])-1] += 1
  elif p[i][1] =="AC":
    if q[int(p[i][0])-1] < 0:
      continue
    else:
      count += 1
      wacount += q[int(p[i][0])-1]
      q[int(p[i][0])-1] -= 10**6

print("{} {}".format(count,wacount))

Measured memory_bytes: 29860
#include <iostream>

using namespace std;

const int NMAX = 100000 + 5;

int N;
int a[NMAX];

int main()
{
    cin >> N;

    int minimum = N, maximum = 0;
    for (int i = 1; i <= N; ++ i) {
        cin >> a[i];
        minimum = min(minimum, a[i]);
        maximum = max(maximum, a[i]);
    }

    if (maximum - minimum > 1) {
        cout << "No\n";
        return 0;
    }
    else if (maximum == minimum) {
        // Everyone is unique
        if (maximum == N - 1)
            cout << "Yes\n";
        else if (2 * maximum <= N)
            cout << "Yes\n";
        else
            cout << "No\n";
        return 0;
    }

    int colors = maximum;
    int singles = 0;
    int doubles = 0;

    for (int i = 1; i <= N; ++ i)
        if (a[i] == minimum)
            ++ singles;
        else
            ++ doubles;

    colors -= singles;
    maximum -= singles;
    N -= singles;

    if (1 <= colors && colors <= N && N > 0) {
        if (2 * maximum <= N)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 640
_,q=gets.split.map &:to_i
r=[*$<].map &:split
s=0
while r!=[]
t=r[0][1].to_i
s+=q
if 0<t-=q
r[0][1]=t
r.rotate!
else
puts"#{r.shift[0]} #{s+=t}"
end
end

Measured memory_bytes: 20084
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int a, p;

int solve() {
    return (a * 3 + p) / 2;
}

void input() {
    cin >> a >> p;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
import numpy as np

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

if moji[K-1]=="A":
    moji[K-1]="a"
if moji[K-1]=="B":
    moji[K-1]="b"
if moji[K-1]=="C":
    moji[K-1]="c"
    
exportmoji=""
for x in moji:
    exportmoji+=x
print(exportmoji)

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int N = 5;
	vector <int> t(N);
	for (int ii = 0; ii < N; ++ii){
		cin >> t[ii];
	}

	vector <int> v;
	for (int ii = 0; ii < N; ++ii){
		v.push_back(ii);
	}

	int ans = 1001001001;
	do {
		int time = 0;
		for (int ii = 0; ii < N; ++ii){
			if (time % 10 != 0){
				int val = time / 10;
				time = 10 * (val + 1);
			}
			time += t[v[ii]];
		}
		ans = min(ans, time);
	} while(next_permutation(v.begin(), v.end()));

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  int h, w;

  while(1) {
    cin >> h >> w;
    if(h+w == 0)break;

    int area = h*h + w*w;
    int ah = 1000000, aw = 0;
    int ans = 10000000;

    for(int i = 1; i < 150; i++) {
      for(int j = i+1; j < 150; j++) {
	int tmp = i*i + j*j;
	if(i == h && j == w) continue;
	if(area <= tmp && tmp <= ans) {
	  if((tmp == area && i < h) || (tmp == ans && i > ah )) break;
	  ah = i;
	  aw = j;
	  ans = tmp;
	}
      }
    }
    cout << ah << ' ' << aw << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define int  long long 
#define loop(i,a,b) for(i=a;i<b;i++)
#define mod 1000000007
#define INF 1000000000000
#define pb push_back
#define lim 1000001
using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,ans=0,rem=0;
    
    unordered_map<int,int> mp;
    cin>>n;

    while(1)
    {
    	rem=(rem*10%n)%n;
    	rem=(rem+7)%n;
    	if(mp[rem])
    		break;
    	ans++;
    	mp[rem]++;
    	if(rem==0) break;
    }

    if(rem) ans=-1;

    cout<<ans<<endl;

    return 0;}

Measured memory_bytes: 42592
import java.io.*;
import java.util.*;
class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] case_numbers;
    int small_number = 0;
    int large_number = 0;
    List<String> group_number = new ArrayList<String>();
    while(true){
      case_numbers = br.readLine().split(" ");
      small_number = Integer.parseInt(case_numbers[0]);
      large_number = Integer.parseInt(case_numbers[1]);
      if(small_number == 0 && large_number == 0){
        break;
      }
      if(small_number > large_number){
        int tmp = small_number;
        small_number = large_number;
        large_number = tmp;
      }
      group_number.add(small_number + " " + large_number);
    }

    for(String number: group_number){
      System.out.println(number);
    }
  }
}



Measured memory_bytes: 26812
n,a,b=map(int,input().split())
mod=1000000007
c=[1]*(b+1)
def com(n,b):
    for i in range(1,b+1):
        c[i]=c[i-1]*((n-i+1)*pow(i,mod-2,mod))%mod
com(n,b)
ans=(pow(2,n,mod)-c[a]-c[b]-1)%mod

print(ans)


Measured memory_bytes: 16620
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <math.h>
#include <sstream>
#include <map>
#include <vector>
#include <queue>
#include <iomanip>
#include <unordered_map>
using namespace std;
typedef long long ll;
ll ans, mx, sum,temp, mn = 1e14, flag,cnt;

int main(){
	ll n;
	cin>>n;
	for(ll i=0; i<=100; i++){
		for(ll j=0; j<=100; j++){
			ll ans=(i*4)+(j*7);
			if(ans==n){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int H, W;
    cin >> H >> W;

    vector<vector<ll>> dist(10, vector<ll>(10));
    rep(i, 10) {
        rep(j, 10) {
            cin >> dist[i][j];
        }
    }

    rep(k, 10) {
        rep(i, 10) {
            rep(j, 10) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    ll res = 0;

    rep(i, H) {
        rep(j, W) {
            int num;
            cin >> num;
            if (num == -1 || num == 1) {
                continue;
            }
            res += dist[num][1];
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
// Problem : A - Payment
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	int x = n/1000;
	n = n - (x * 1000);
	if(n == 0)
	{
		cout<<0;
	}
	else
	{
		cout<<1000 - n;
	}
	return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main() {
	int n,t=0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		if (i % 2 != 0) {
			t++;
		} 
	}
	double T = t,N = n;
	printf("%f",T/N);
	return 0;
}

Measured memory_bytes: 128