akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
  int H, A;
  int times;
  
  cin >> H >> A;
  
  times = (H % A == 0) ? H / A : H / A + 1;
  
  printf("%d\n", times);
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A , B , C , D;
  cin >> A >> B >> C >> D;

  if(A+B == C+D){
    cout << "Balanced" << endl;
  }

  else if (A+B > C+D){
    cout << "Left" << endl;
  }

  else if (A+B < C+D){
    cout << "Right" << endl;
  }
}


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

typedef long long LL;
typedef pair<int, int> PII;

#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
#define F first
#define S second

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

int a[550][550] = {{}};
int n, m;
char s[550];

int v[550][550] = {{}};

int no = 0;
void dfs(int i, int j) {
  if (i < 0 || j < 0 || i == n || j == m || v[i][j] || a[i][j] != 3) return ;
  v[i][j] = no;
  dfs(i + 1, j);
  dfs(i - 1, j);
  dfs(i, j + 1);
  dfs(i, j - 1);
}

int main() {
  scanf("%d%d", &n, &m);
  REP(i, n) {
    scanf("%s", s);
    REP(j, m) a[i][j] = s[j] == '#' ? 3 : 0;
  }
  no++;
  REPE(i, 1, n - 2) {
    a[i][0] = 1;
    v[i][0] = no;
  }
  REP(i, n) REP(j, m) {
    if (a[i][j] == 3 && !v[i][j]) {
      no++;
      dfs(i, j);
      int k = j;
      while (k > 0) {
        if (v[i][k] && v[i][k] != no) {
          break;
        }
        v[i][k] = no;
        a[i][k] |= 1;
        REP(d, 4) {
          int tx = i + dx[d];
          int ty = k + dy[d];
          if (v[tx][ty] && v[tx][ty] != no) {
            k = 0;
            break;
          }
        }
        k--;
      }
    }
  }
  REP(i, n) {
    REP(j, m) {
      putchar((a[i][j] & 1) ? '#' : '.');
    }
    puts("");
  }
  puts("");
  REP(i, n) {
    REP(j, m) {
      putchar((a[i][j] == 1) ? '.' : '#');
    }
    puts("");
  }
  return 0;
}



Measured memory_bytes: 14464
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,K,cnt = 0;
  cin >> A >> B >>K;
  for(int i = min(A,B); i >= 1; i--){
    if((A % i == 0) && (B % i ==0)){
      cnt++;
      if(cnt == K){
        cout << i << endl;
        return 0;
      }
    }
  }
}



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

typedef long long LL;
typedef pair<LL,LL> PLL;
const int M=2e5+5;
const int MO=1e9+7;
const int INV2=5e8+4;

inline int add(int x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
	return x;
}
inline int sub(int x,int y)
{
	x-=y;
	if(x<0) x+=MO;
	return x;
}
inline int mul(int x,int y)
{
	return 1LL*x*y%MO;
}
inline void addv(int &x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
}
inline void subv(int &x,int y)
{
	x-=y;
	if(x<0) x+=MO;
}
inline void mulv(int &x,int y)
{
	x=1LL*x*y%MO;
}

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

struct Point
{
	LL x,y;
	void read()
	{
		scanf("%lld%lld",&x,&y);
		if(x==0&&y==0) return;
		LL g=gcd(abs(x),abs(y));
		x/=g; y/=g;
		if(y<0) x=-x,y=-y;
		else if(y==0&&x<0) x=-x;
	}
}p[M];
map<PLL,int> cnt;
set<PLL> vis;
int er[M];

int main()
{
	int n;
	scanf("%d",&n);
	int m=0;
	int cnt0=0;
	for(int i=0;i<n;i++,m++)
	{
		p[m].read();
		if(p[m].x==0&&p[m].y==0) 
			cnt0++,m--;
		else
			cnt[make_pair(p[m].x,p[m].y)]++;
	}
	er[0]=1;
	for(int i=1;i<=m;i++)
		er[i]=mul(er[i-1],2);
	int ans=1;
	for(auto p:cnt)
	{
		PLL A=p.first;
		if(vis.count(A)) continue;
		PLL B;
		if(A.first<=0) B=make_pair(A.second,-A.first);
		else B=make_pair(-A.second,A.first);
		vis.insert(A);
		vis.insert(B);
		int c1=p.second;
		int c2=0;
		if(cnt.count(B)) c2+=cnt[B];
		int nans=add(er[c1],er[c2]);
		subv(nans,1);
		//cout<<A.first<<" "<<A.second<<" : "<<c1<<" "<<c2<<" "<<nans<<endl;
		mulv(ans,nans);
	}
	addv(ans,cnt0);
	subv(ans,1);
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    int N, M, X;
    string result;
    cin >> N >> M >>X;
    int A, B;
    A = 0;
    B = 0;

    for(int i=0; i<M; i++){
        int a;
        cin >> a;
        if(a < X){
            A += 1;
        }else if(a > X){
            B += 1;
        }else{
            continue;
        }
    }

    cout << min(A,B) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        String r = scan.next();
        String g = scan.next();
        String b = scan.next();
        String cnt;
        
        String rgb;
        int rgb_num;
        
        rgb = r + g + b;
        rgb_num = Integer.parseInt(rgb);
        
        if(rgb_num % 4 == 0)cnt = "YES";
        else cnt = "NO";
            
        System.out.println(cnt);
	  }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H1,M1,H2,M2,K;
  cin>>H1>>M1>>H2>>M2>>K;
  int Ans;
  Ans=(H2-H1)*60+M2-M1-K;
  cout<<Ans<<endl;
  return 0;
}

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

int main() {
	int a[100000] = { 0 };
	int N = 0;
	int ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < N - 2; i++) {
		if (a[i] < a[i + 1] && a[i + 2] < a[i + 1]) {

		}
		else if (a[i] > a[i + 1] && a[i + 2] > a[i + 1]) {

		}
		else {
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 640
# 予めsx, syを全て計算しておく
# このとき漸化式を使えば毎回全ての話を求める必要がない

mod = int(1e9+7)
n, m = [int(num) for num in input().split()]

x = [int(x) for x in input().split()]
y = [int(y) for y in input().split()]


sx = [0] * n
sx[0] = x[0]
for i in range(n-1):
    sx[i+1] = sx[i] + x[i+1]
sxd = 0  
for i in range(n-1):
    sxd += ((sx[n-1] - sx[i]) - x[i] * ((n-1) - (i+1) + 1)) % mod

sy = [0] * m
sy[0] = y[0]
for k in range(m-1):
    sy[k+1] = sy[k] + y[k+1]
syd = 0
for k in range(m-1):
    syd += ((sy[m-1] - sy[k]) - y[k] * ((m-1) - (k+1) + 1)) % mod

ans = ((sxd % mod) * (syd % mod)) % mod

print(ans)

Measured memory_bytes: 20672
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int L = 0; // (の数
  string tasu = "";
  for( int i = 0; i < N; i++ ){
    if ( S.at(i) == '(' ){
      L++;
    }else if( S.at(i) == ')' ){
      if( L > 0 ){
        L--;
      }else{
        tasu += "(";
      }
    }
  }
  
  S = tasu + S;
  for( int i = 0; i < L; i++ ){
    S += ")";
  }
  cout << S << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define fi first
#define se second
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
 
#define inf 1e18
#define sqr(x) ((x)*(x))
using namespace std;
int n,a[300005];
set<pii> S;
bool check(int lim){
	S.clear();
	S.insert(pii(0,1));
	S.insert(pii(a[1],0));
	for (int i=2;i<=n;i++){
		if ((--S.end())->fi<a[i]){
			S.erase(--S.end());
			S.insert(pii(a[i],0));
			continue;
		} 
		for (;!S.empty()&&(--S.end())->first>=a[i];) S.erase(--S.end());
		if (S.empty()) return 0;
		int id=a[i]-1;
		for (;!S.empty()&&(--S.end())->first==id&&(--S.end())->second==lim;S.erase(--S.end()),id--);
		if (S.empty()) return 0;
		if ((--S.end())->first==id){
			int val=(--S.end())->second+1;
			S.erase(--S.end());
			S.insert(pii(id,val));
		}
		else
			S.insert(pii(id,2));
		S.insert(pii(a[i],0));
	}
	return 1;
}
int main(){
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]);
	int l=1,r=200005,ans;
	For(i,1,n-1) if (a[i]>=a[i+1]) l=2;
	if (l==1)
		return printf("1"),0;
	while (l<=r){		
		int mid=(l+r)/2;
		if (check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1024
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
for(var i=0;i<Arr.length;i++){
   var d=Arr[i];
   var sum=0;
   for(var j=1;j<600/d;j++){
      sum+=Math.pow(d*j,2)*d;
   }
   console.log(sum);
}

Measured memory_bytes: 8644
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    public void run() {
        while (true) {
            int H = sc.nextInt(), W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int h = 0; h < H; h++) {
                for (int w = 0; w < W; w++) {
                    pr((h+w)%2==0 ? "#"
                            : ".");
                }
                ln();
            }
            ln();
        }
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
}


Measured memory_bytes: 34760
//2018-1-20
//miaomiao
//
#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)

#define N (200+5)
const int A = 100;

int m, ans[N], l, r;

void Solve(LL n){
	if(n <= 1) return;

	if(n & 1){
		Solve(n-1);
		ans[--l] = ++m;
	}else{
		Solve(n>>1);
		ans[++r] = ++m;
	}
}

int main(){
	LL n;

	scanf("%lld", &n); ++n;

	l = A+1; r = A;
	Solve(n);
	
	printf("%d\n", m<<1);
	For(i, l, r) printf("%d ", ans[i]);
	For(i, 1, m) printf("%d%c", i, i==m? '\n': ' ');

	return 0;
}

Measured memory_bytes: 256
n = int(input())
product = {}
for i in range(n) :
    p, m = input().split()
    if p not in product :
        product[p] = int(m)
    else :
        product[p] += int(m)
sorted_product = dict(sorted(product.items(), key = lambda x: x[0]))
sorted_product = sorted(sorted_product.items(), key = lambda x: len(x[0]))
for i in range(len(sorted_product)) :
    print(*sorted_product[i])


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

using namespace std;

class Restaurant {
public:
    Restaurant(int serialNumber, string cityName, int score) : m_serialNumber(serialNumber), m_cityName(cityName), m_score(score) {}
    int getSerialNumber() const {
        return m_serialNumber;
    }
    string getCityName() const {
        return m_cityName;
    }
    int getScore() const {
        return m_score;
    }
private:
    const int m_serialNumber;
    const string m_cityName;
    const int m_score;
};

bool lexicalOrder(const Restaurant* front, const Restaurant* back);

int main() {
    int numOfRestaurant;
    cin >> numOfRestaurant;
    
    vector<Restaurant*> guideBook;
    string cityName;
    int score;
    for (int i = 1; i <= numOfRestaurant; ++i) {
        cin >> cityName >> score;
        guideBook.push_back(new Restaurant(i, cityName, score));
    }
    
    sort(guideBook.begin(), guideBook.end(), lexicalOrder);
    
    for (Restaurant* restaurant : guideBook) {
        cout << restaurant->getSerialNumber() << endl;
    }

    for (Restaurant* restaurant : guideBook) {
        delete restaurant;
    }  
    
}

bool lexicalOrder(const Restaurant* front, const Restaurant* back) {
    if (front->getCityName() == back->getCityName()) {
        return front->getScore() > back->getScore();
    } else {
        return front->getCityName() < back->getCityName();
    }
}

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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	map<int, int> mp;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i]--;
		mp[A[i]]++;
	}
	if (N == 2) {
		cout << -1 << endl;
		return 0;
	}
	set<int> st;
	for (int i = 0; i < N; i++) {
		st.insert(i);
	}
	vector<int> res(N);
	int dame = -1;
	for (int i = 0; i < N - 3; i++) {
		auto a = st.begin();
		while ((*a) == dame){
				a++;
			}
		res[i] = (*a);
		dame = A[*a];
		mp[A[*a]]--;
		if (mp[A[*a]] == 0) {
			mp.erase(A[*a]);
		}
		st.erase(a);
	}
	vector<int> X;
	for (int i : st) {
		X.push_back(i);
	}
	bool ok = false;
	do {
		if (X[0] != dame && X[1] != A[X[0]] && X[2] != A[X[1]]) {
			ok = true;
			break;
		}
	} while (next_permutation(X.begin(), X.end()));
	for (int i = 0; i < 3; i++) {
		res[N - 3 + i] = X[i];
	}
	if (!ok) {
		int x = dame;
		vector<int> t;
		for (int i = N - 1; i >= -1; i--) {
			if (i == -1 || res[i] != dame) {
				if (i == -1 || A[res[i]] != dame) {
					sort(t.begin(), t.end());
					res[i + 1] = dame;
					if(A[dame] == t[0]){
						swap(t[0], t[1]);
					}
					for (int j = 0; j < t.size(); j++) {
						res[i + 2 + j] = t[j];
					}
					
					break;
				}
				t.push_back(res[i]);
			}
		}
	}
	for (int i = 0; i < N; i++) {
		if (i > 0) cout << " ";
		cout << res[i] + 1;
	}
	cout << endl;
}

Measured memory_bytes: 13312
n, m = [int(i) for i in input().split()]
ab = [[int(i) for i in input().split()] for _ in range(n)]
cd = [[int(i) for i in input().split()] for _ in range(m)]
for a, b in ab:
  dmin = float("inf")
  cp = -1
  for i in range(len(cd)):
    c, d = cd[i]
    d = abs(a - c) + abs(b - d)
    if d < dmin:
      cp = i + 1
      dmin = d
  print(cp)

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

#define ALL(v) v.begin(),v.end()

using ll=long long;
using P=pair<ll,ll>;
ll dist(P p0,P p1){
    return max(abs(p0.first-p1.first),abs(p0.second-p1.second));
}
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    a--,b--;
    queue<P> que;
    P ap;
    ll d;
    set<P> holexy;
    set<P> holeyx;
    vector<P> holexyv(n);
    vector<P> holeyxv(n);;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        ll rx=x+y,ry=x-y;
        P p=make_pair(rx,ry);
        P q=make_pair(ry,rx);
        holexyv[i]=p;
        holeyxv[i]=q;
        if(i==a){
            ap=p;
            que.push(p);
        }
        else{
            if(i==b){
                d=dist(ap,p);
            }
            holexy.insert(p);
            holeyx.insert(q);
        }

    }
    sort(holexyv.begin(),holexyv.end());
    sort(holeyxv.begin(),holeyxv.end());
    ll res=0;
    while(!que.empty()){
        auto ret=que.front();
        que.pop();
        ll x=ret.first,y=ret.second;
        
        P p1=P(x+d,y+d);
        P q1=P(y+d,x+d);
        P p2=P(x-d,y+d);
        P q2=P(y+d,x-d);
        P p3=P(x-d,y-d);
        P q3=P(y-d,x-d);
        P p4=P(x+d,y-d);
        P q4=P(y-d,x+d);
        
        auto b=holeyx.upper_bound(q2);
        auto e=holeyx.upper_bound(q1);
        res+=lower_bound(ALL(holeyxv),q1)-lower_bound(ALL(holeyxv),q2);
        vector<P> inserter;
        for(auto it=b;it!=e;it++){
            ll tox=it->second,toy=it->first;
            inserter.push_back(make_pair(tox,toy));
        }
        
        b=holeyx.lower_bound(q3);
        e=holeyx.lower_bound(q4);
        res+=lower_bound(ALL(holeyxv),q4)-lower_bound(ALL(holeyxv),q3);
        for(auto it=b;it!=e;it++){
            ll tox=it->second,toy=it->first;
            inserter.push_back(make_pair(tox,toy));
        }
        
        b=holexy.lower_bound(p4);
        e=holexy.lower_bound(p1);
        res+=lower_bound(ALL(holexyv),p1)-lower_bound(ALL(holexyv),p4);
        for(auto it=b;it!=e;it++){
            ll tox=it->first,toy=it->second;
            inserter.push_back(make_pair(tox,toy));
        }
        
        b=holexy.upper_bound(p3);
        e=holexy.upper_bound(p2);
        res+=lower_bound(ALL(holexyv),p2)-lower_bound(ALL(holexyv),p3);
        for(auto it=b;it!=e;it++){
            ll tox=it->first,toy=it->second;
            inserter.push_back(make_pair(tox,toy));
        }
        
        for(auto &e:inserter){
            ll tox=e.first,toy=e.second;
            holexy.erase(holexy.find(P(tox,toy)));
            holeyx.erase(holeyx.find(P(toy,tox)));
            que.push(P(tox,toy));
        }
        
    }
    cout<<res/2<<endl;
    return 0;
}

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


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

    yn(n[0] == '7' || n[1] == '7' || n[2] == '7');

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

int main() {
	ll A, B, X;
	cin >> X;
	for (ll i = -1000;i < 1000;i++) {
		for (ll j = -1000;j < 1000;j++) {
			if (i * i * i * i * i - j * j * j * j * j == X) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long, long long> pll;
#define rep(i, a, b) for(int i = a; i < b; i++)

int main(){
    int a, b, c, n, ans = 0;
    string S;
    vector<int> vec(10);

    cin >> a >> b;
    if(a >= 10 || b >= 10) cout << -1 << endl;
    else cout << a * b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
using namespace std;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;

int fact(int c) {
    int res=1;
    for (int i=2;i<=c;i++) res *= c;
    return res;
}

int main () {
    string s;
    cin >> s;
    if(s=="RRR") cout<<3;
    else if(s=="SRR" || s=="RRS") cout<<2;
    else if(s=="SSS") cout<<0;
    else cout<<1;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい



void Main(){
	string S;
	cin >> S;
	int A=0, B=0;
	A += (S[0] - '0')*10 + (S[1] - '0');
	B += (S[2] - '0')*10 + (S[3] - '0');

	if(A > 12 || A == 0){
		if(B > 12 || B == 0){
			cout << "NA" << endl;
		}else{
			cout << "YYMM" << endl;
		}
	}else{
		if(B > 12 || B == 0){
			cout << "MMYY" << endl;
		}else{
			cout << "AMBIGUOUS" << endl;
		}
	}


}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


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

int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int cnt = 0;
    for (int i = 0; i <= N - 1; i++) {
        for (int j = N - 1; j >= i + 1; j--) {
            if (A[j] < A[j - 1]) {
                swap(A[j], A[j - 1]);
                cnt++;
            }
        }
    }
    for (int i = 0; i < N; i++) {
        if (i != 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main() {
  int N;
  cin>>N;
  string s;
  cin>>s;
  map<char,int>k;
  for(int i=0;i<N;i++){
    k[s[i]]++;
  }
  int64_t ans=1;
  for(auto c:k){
    ans*=(c.second+1);
    ans%=mod;
  }
  cout<<ans-1<<endl;
  return 0;
}

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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "

int D;
int c[26];
int s[365][26];

int main(){
    cin >> D; //D = 365
    int max_[365];
    int lastd[26];
    //vector<int> high_c;
    //vector<int> midl_c;
    //vector<int> low_c;
    vector<pair<int,int>> high_pr(26);
    Rep(i,26){
        cin >> c[i];
        lastd[i] = 0;
        //if(c[i] > 70)high_c.push_back(i);
        //else if(c[i] > 40)midl_c.push_back(i);
        //else low_c.push_back(i);
    }
    Rep(i,365){
        Rep(j,26){
            cin >> s[i][j];
        }
    }
    Rep(i,365){
        max_[i] = 0;
        int max = 0;
        Rep(j,26){
            Rep(k,15){
                if(max < s[i][high_pr[25-k].second] + high_pr[25-k].first){
                    max = s[i][high_pr[25-k].second] + high_pr[25-k].first;
                    max_[i] = high_pr[25-k].second;
                }
            }
        }
        Rep(j,26){
            if(j == max_[i])lastd[j] = 0;
            else lastd[j]++;
        }
        Rep(j,26){
            high_pr[j] = make_pair(c[j]*lastd[j],j);
        }
        sort(high_pr.begin(),high_pr.end());
    }
    Rep(i,365){
        cout << max_[i]+1 << endl;
    }
    //int x;
    //cin >> x;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		bool data[100][100],f[100];
		memset(data,false,sizeof(data));
		memset(f,true,sizeof(f));
		for(int i=0;i<n;i++){
			int m,a;
			cin>>m;
			for(int j=0;j<m;j++){
				cin>>a;a--;
				data[i][a]=true;
			}
		}
		int k,b;
		cin>>k;
		for(int i=0;i<k;i++){
			cin>>b;b--;
			for(int j=0;j<n;j++){
				if(!data[j][b])f[j]=false;
			}
		}
		bool g=false;
		int ans=-1;
		for(int i=0;i<n;i++){
			if(f[i]&&ans!=-1){
				g=true;
			}else if(f[i]){
				ans=i+1;
			}
		}
		if(!g&&ans!=-1)cout<<ans<<endl;
		else cout<<-1<<endl;
	}
}

Measured memory_bytes: 1176
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rint register int
#define rep(i, l, r) for (rint i = l; i <= r; i++)
#define per(i, l, r) for (rint i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)

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

ll n,blue,red;

int main(){
    //freopen("in.txt","r",stdin);
    int a,b;
    int flag=-1;
    cin>>a>>b;
    for(int i=1;i<=1250;i++){
        if(i*8/100==a&&i/10==b){
            flag=i;
            break;
        }

    }
    printf("%d\n",flag);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
long long X,K,D;
  cin >> X >> K >> D;
  if(X < 0){
   X *= -1; 
  }
  long long k = X / D;
  if(k >= K){
   cout << X - K * D; 
  }else{
    if(K % 2 == k % 2){
   if(abs(X - k * D) < abs(X - (k+2) * D)){
     cout << abs(X - k * D);
   }else{
     cout << abs(X - (k+2) * D);
   }
  }else{
   if(abs(X - (k-1) * D) < abs(X - (k+1) * D)){
     cout << abs(X - (k-1) * D);
   }else{
     cout << abs(X - (k+1) * D);
   }
  }
  }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int64_t len(int64_t a,int64_t b,int64_t c,int64_t d,int64_t p){
  if(a/p!=c/p&&b/p!=d/p)
    return abs(c-a)+abs(d-b);
  if(a/p==c/p&&b/p==d/p)
    return len(a%p,b%p,c%p,d%p,p/3);
  if(a/p==c/p)
    return len(b,a,d,c,p);
  int64_t xa=a;
  int64_t xc=c;
  int k=0;
  while(abs(xc-xa)>1){
    k++;
    xc/=3;
    xa/=3;
  }
  int64_t x=(b+d)/2;
  vector<int> t;
  while(x>0){
    t.push_back(x%3);
    x/=3;
  }
  int64_t l=0;
  int64_t g=0;
  bool f=0;
  for(int i=(int)t.size()-1;i>=0;i--){
    l*=3;
    g*=3;
    if(f){
      l+=2;
      continue;
    }
    if(i<k&&t.at(i)==1){
      g+=2;
      f=1;
      continue;
    }
    l+=t.at(i);
    g+=t.at(i);
  }
  return min(abs(c-a)+abs(l-b)+abs(l-d),abs(c-a)+abs(g-b)+abs(g-d));
}
int main(){
  int q;
  cin>>q;
  for(int _=0;_<q;_++){
    int64_t a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;
    b--;
    c--;
    d--;
    int64_t p=1;
    while(p<=max({a,b,c,d}))
      p*=3;
    cout<<len(a,b,c,d,p/3)<<endl;
  }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,a,b,c,y,x,z;
    cin >> a>>b>>c;
   x=a+b;
   y=c+b;
   z=a+c;
   x=min({x,y,z});


        cout<<x<<endl;
    return 0;

}







Measured memory_bytes: 3588
def main():
    from decimal import Decimal
    A, B = map(Decimal, input().split())
    print(int(A * B))


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 10068
from sys import stdin
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def lsi():
    x=list(stdin.readline())
    x.pop()
    return x
def si(): return stdin.readline()
############# CODE STARTS HERE #############
n, k=mi()
s=[0]*n
a=li()
#s[n-2]=abs(a[n-2]-a[n-1])
for i in range(n-2, -1, -1):
    x=100000000000
    for j in range(i+1, min(i+k+1, n)):
        x=min(x, abs(a[i]-a[j])+s[j])
    s[i]=x
print(s[0])

Measured memory_bytes: 53212
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;


struct node {
	int v, d;
	node(int v, int d) :v(v), d(d){}
	bool operator<(const node &n) const { return d > n.d; }
};
struct edge{ int to, weight; };

void dijkstra(vector<vector<edge>>& g, vector<int>& dist, int S){
	int N = g.size();
	dist.assign(N, -1);
	priority_queue<node> que;
	que.push(node(S, 0));
	while (!que.empty()){
		int v = que.top().v, d = que.top().d;
		que.pop();
		if (dist[v] >= 0 and dist[v] <= d) continue;
		dist[v] = d;
		for (int i = 0; i < g[v].size(); i++)
			que.push(node(g[v][i].to, d + g[v][i].weight));
	}
}

signed main(){

	int N, M, S, T;
	cin >> N >> M >> S >> T;
	S--; T--;

	vector<vector<edge>> g1, g2;
	g1.assign(N, vector<edge>());
	g2.assign(N, vector<edge>());

	rep(i, M){
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		u--; v--;
		g1[u].push_back(edge{ v, a });
		g1[v].push_back(edge{ u, a });
		g2[u].push_back(edge{ v, b });
		g2[v].push_back(edge{ u, b });
	}
	vector<int> dist1, dist2;

	dijkstra(g1, dist1, S);
	dijkstra(g2, dist2, T);

	vector<int> ans;
	int mi = INF;
	for (int i = N - 1; i >= 0; i--){
		mi = min(mi, dist1[i] + dist2[i]);
		ans.push_back(mi);
	}

	for (auto i = ans.rbegin(); i != ans.rend(); i++){
		cout << 1000000000000000LL - *i << endl;
	}


	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORB(i,a,b) for(int i=a;i>=b;i--)
#define INT_MAXI 2147483647
#define INT_MINI -2147483648
#define REV(a) reverse(a.begin(),a.end())
#define NP(a) next_permutation(a.begin(),a.end())

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

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  //cout<<"input"<<endl;freopen("input.txt","r",stdin);
  //cout<<"output"<<endl;freopen("output.txt","w",stdout);
  
  string s;
  cin>>s;
  if(s[s.size()-1]!='s')
    cout<<s<<'s'<<endl;
  else
    cout<<s<<"es"<<endl;
  
  
  
  
  
  return 0;
}

Measured memory_bytes: 3656
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1) { res = res * a%MOD; }
		a = a * a%MOD;
		b >>= 1;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑


int main() {
	int n, k[105], mon = 999, sum = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> k[i];
		sum += k[i];
		if (k[i] % 2 == 1) { mon = min(mon, k[i]); }
	}
	if (sum % 2 == 0) { cout << sum / 2 << endl; }
	else { cout << (sum - mon) / 2 << endl; }
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

bool comp(const string& i, const string& j){
	return (i > j);
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli k, sum=0, ans = 1;
	string s;
	cin >> s >> k;
	rep(i,k){
		if(s[i] > '1'){
			ans = s[i] - '0';
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
ll mod = 1000000000 + 7;

int main(void)
{
    ll N;

    cin >> N;

    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }
    ll t = 1;
    for (int i = 1; i <= N; i++) {
        t *= 10;
        t %= mod;
    }
    ll n = 1;
    for (int i = 1; i <= N; i++) {
        n *= 9;
        n %= mod;
    }
    ll e = 1;
    for (int i = 1; i <= N; i++) {
        e *= 8;
        e %= mod;
    }
    ll ans = (t - n - n + e) % mod;
    if (ans < 0) {
        ans += mod;
    }
    cout << ans % mod<< endl;

    return 0;
}

Measured memory_bytes: 3632
from collections import defaultdict
from queue import Queue
g = defaultdict(list)
visted = defaultdict(bool)
N, M = map(int, input().split())
for i in range(M):
    A, B = map(int, input().split())
    g[A].append(B)
    g[B].append(A)

h = [-1] * (N+1)

h2 = defaultdict(list)
def solve(v):
    visited = set()
    q = Queue()
    visited.add(v)
    h[v] = 0
    h2[0].append(v)
    q.put(v)
    while not q.empty():
        v = q.get()
        for c in g[v]:
            if not c in visited:
                visited.add(c)
                h[c] = h[v] + 1
                h2[h[v]+1].append(c)
                q.put(c)

solve(1)
ans = []

for v in range(2, N+1):
    i = h[v]

    for c in g[v]:
        if h[c] == i-1:
            ans.append(c)
            break


print('Yes')
for v in ans:
    print(v)

Measured memory_bytes: 61488
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int A[50];
int main()
{
    vector<int> vec;
    int n;
    cin>>n;
    int x;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        vec.push_back(x);
        A[i]=x;
    }
    int Count=0;
    sort(vec.begin(),vec.end());
    for(int i=0;i<n;i++){
        if(vec[i]!=A[i]){
            ++Count;
        }
    }
    if(Count==2) cout<<"YES"<<endl;
    else if (Count==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}


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

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

    if(a=='H' && b=='H')
        cout<<"H";
    else if(a=='H' && b=='D')
        cout<<"D";
    else if(a=='D' && b=='H')
        cout<<"D";
    else if(a=='D' && b=='D')
        cout<<"H";
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var n = Integer.parseInt(br.readLine());
      final var a = Arrays
        .stream(br.readLine().split(" "))
        .mapToInt(Integer::parseInt)
        .toArray();
      Arrays.sort(a);

      long sum = a[a.length - 1];
      var rest = n - 2;
      var idx = a.length - 2;
      while (rest >= 2) {
        sum += a[idx] * 2;
        rest -= 2;
        idx--;
      }

      if (rest >= 1) {
        sum += a[idx];  
      }      
      System.out.println(sum);
    }
  }
}


Measured memory_bytes: 64748
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
	public static void Main()
	{
		var n = ReadLine();
		long sum = 0;
		for(int i = 0; i < n.Length; i++)
		{
			sum += long.Parse(n[i].ToString());
		}
		if(sum % 9 == 0)
			WriteLine("Yes");
		else
			WriteLine("No");
	}
}


Measured memory_bytes: 21612
import numpy as np
S = input()
S1 = np.array(S.split("W"))
S2 = np.array(S.split("B"))
if len(S1) == 1 or len(S2) == 1:
    print(0)
else:
    num1 = len(S1[S1 != '']) * 2 - 1
    if S1[0] == '' and S1[-1] == '':
        num1 += 1
    if num1 < 0:
        num1 = 0
    num2 = len(S2[S2 != '']) * 2 - 1
    if S2[0] == '' and S2[-1] == '':
        num2 += 1
    if num2 < 0:
        num2 = 0
    if num2 < num1:
        print(num2)
    else:
        print(num1)

Measured memory_bytes: 23120
#include<iostream>
using namespace std;
 
int main(){
    int card[4][13];
    int i,j;
    for (i=0; i<4; i++){
        for (j=0; j<13; j++){
           card[i][j] =j+1;
        }
    }
     
    int n;
    cin >>n;
     
    char x;
    int y;
    for (int k=0; k<n; k++){
        cin >>x >>y;
        for (j=0; j<13; j++){
            if (x=='S' && y==j+1) card[0][j] =0;
            if (x=='H' && y==j+1) card[1][j] =0;
            if (x=='C' && y==j+1) card[2][j] =0;
            if (x=='D' && y==j+1) card[3][j] =0;
        }
    }
     
    for (i=0; i<4; i++){
        for (j=0; j<13; j++){
            if (card[i][j]==0) continue;
            if (i==0) cout << "S" <<" "<< j+1 <<"\n";
            if (i==1) cout << "H" <<" "<< j+1 <<"\n";
            if (i==2) cout << "C" <<" "<< j+1 <<"\n";
            if (i==3) cout << "D" <<" "<< j+1 <<"\n";
        }
    }   
     
    return 0;
}
	

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,a[51][6],ans,h,m;
vector<int>v;
int main(){
  cin>>n;
  rep(i,n){
    rep(j,6){
      cin >> h >> m;
      a[i][j] = h*60+m;
      if(j%2==0) v.push_back(a[i][j]);
    }
  }
  sort(v.begin(),v.end());
  for(int i=0;i<v.size();i++)
    for(int j=i+1;j<v.size();j++)
      for(int k=j+1;k<v.size();k++){
        int cnt = 0;
        rep(l,n) if(a[l][0]<=v[i]&&v[i]<=a[l][1]&&a[l][2]<=v[j]&&v[j]<=a[l][3]&&a[l][4]<=v[k]&&v[k]<=a[l][5]) cnt++;
        ans = max(ans,cnt);
      }
  cout<<ans<<endl;
}

Measured memory_bytes: 3152
/**
 *    SATAR ALLAH
 *
**/
#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
 const int oo=1e9;
 int n;
 const int N=1e6+1;
 long long dp[N];

int main()
{

       cin>>n;

       dp[0]=0;

       for(int i=1;i<=n;i++){

          dp[i]=dp[i-1]+1;

          for(int j=6;j<=i;j*=6)
            dp[i]=min(dp[i],dp[i-j]+1);

          for(int j=9;j<=i;j*=9)
            dp[i]=min(dp[i],dp[i-j]+1);
       }
       cout<<dp[n];

    return 0;
}


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

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int Cin()
{
    int n;
    cin >> n;
    return n;
}

int main()
{
    // 監視範囲が重複しないようになるべく距離を置いて監視員を配置
    int N = Cin(), D = Cin();
    int range = D * 2 + 1;
    cout << (N + range - 1) / range << endl;
}


Measured memory_bytes: 256
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/
typedef long long LL;
const int SZ=1e6+5,N=505;

int n;

bool bp[SZ];
LL pn[SZ],lp;
void sieve(){
    bp[0]=bp[1]=1;
    FOR(i,2,SZ-1){
        if(!bp[i])pn[++lp]=i;
        if(lp>=1000)break;
        FOR(j,1,lp){
            int pj=pn[j];
            if(i*pj>=SZ)break;
            bp[i*pj]=1;
            if(i%pj==0)break;
        }
    }
}
LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){
    if(a==0)a=1;
    if(b==0)b=1;
    return a/gcd(a,b)*b;}
LL lcm(LL a,LL b,LL c,LL d){
    return lcm(lcm(a,b),lcm(c,d));
}
LL a[N][N],b[N][N];

int main(){
    scanf("%d",&n);
    if(n==2)return puts("4 7\n23 10"),0;
    sieve();
    int pos=0;
    for(int i=1;i<=n;i+=2)a[i][1]=pn[++pos];
    for(int i=n&1?1:2;i<=n;i+=2)a[n][i]=pn[++pos];
    for(int i=1;i<=n;i+=2)b[1][i]=pn[++pos];
    for(int i=1;i<=n;i+=2)b[i][1]=pn[++pos];
    ROF(i,n-1,1)FOR(j,2,n)a[i][j]=a[i+1][j-1];
    FOR(i,2,n)FOR(j,2,n)b[i][j]=b[i-1][j-1];
    //FOR(i,1,n)FOR(j,1,n)printf("%lld%c",a[i][j]," \n"[j==n]);
    //FOR(i,1,n)FOR(j,1,n)printf("%lld%c",b[i][j]," \n"[j==n]);
    FOR(i,1,n)FOR(j,1,n)a[i][j]*=b[i][j];
    FOR(i,1,n)FOR(j,1,n)if(!a[i][j]){
        a[i][j]=lcm(a[i-1][j],a[i+1][j],a[i][j-1],a[i][j+1])+1;
    }
    FOR(i,1,n)FOR(j,1,n)printf("%lld%c",a[i][j]," \n"[j==n]);
    return 0;
}


Measured memory_bytes: 9728
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

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 nCr(ll n, ll r){
	if (r == 0 || r == n){
		return 1;
	}
	else if (r == 1){
		return n;
	}
	return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
	r = n - r;
	ll ret = 1;
	for (ll i = n; i >= r + 1; i--) ret *= i;
	return ret;
}

//-----------------------ここから-----------

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

	vector<ll> a(n);

	for (int i = 0; i < n; i++) cin >> a[i];

	vector<ll> sum(n + 1);

	sum[0] = 0;

	for (int i = 1; i < n + 1; i++){
		sum[i] = sum[i - 1] + a[i - 1];
	}

	map<ll, ll> mp;
	for (int i = 0; i < n + 1; i++){
		mp[sum[i]]++;
	}

	ll ans = 0;

	for (auto i : mp){
		if (i.second > 1) ans += nCr(i.second, 2);
	}

	cout << ans << endl;
}


Measured memory_bytes: 15872
#include<iostream>

using namespace std;

int main() {
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if (x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H) {
		cout << "Yes"<<endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair
#define debug_vec(x, n) cout << (#x) << ": "; for(int i = 0; i < n; i++) cout << x[i] << (i == n - 1 ? "\n" : " ");

typedef long long ll;
typedef long double ld;

void solve(){
    int n;
    cin >> n;
    set<string> s;
    for(int i = 0; i < n; i++){
        string x;
        cin >> x;
        s.insert(x);
    }
    cout << s.size() << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 19220
import sys
import re
import queue
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []



def main():
	S = i_input()
	ans = []
	ans.append(0)
	ans.append(0)
	ans.append(1)
	for i in range(3,S):
		ans.append((ans[i-1]+ans[i-3])%MOD)
	print(ans[S-1])
	
	return


if __name__ == '__main__':
	main()

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

int main() {
  // 入力
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];

  sort(a, a + N);
  int ans = 0;
  int cnt = 1;
  for (int i = 0; i < N - 1; i++) {
    if (a[i] == a[i+1]) {
      cnt++;
    } else {
      if (cnt & 1) ans++;
      cnt = 1;
    }
  }
  if (cnt & 1) ans++;

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N; cin>>N;
    vector<int> a(N+1),b(N+1),c(N+1);
    for(int i=1;i<=N;i++) cin>>a[i]>>b[i]>>c[i];

    vector<vector<int>> dp(N+1,vector<int>(3));
    for(int i=1;i<=N;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    cout<<*max_element(dp[N].begin(),dp[N].end())<<endl;
    return 0;
}

Measured memory_bytes: 8064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b, k; cin >> a >> b >> k;
  set<int> st;
  FOR(i, a, a+k) {
    if (i > b) break;
    st.insert(i);
  }
  FOR(i, max(b-k+1, a), b+1) st.insert(i);
  for (auto a : st) cout << a << '\n';
  return 0;
  return 0;
}


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

int n;
int m[55];
xy_t P[55][15];
xy_t Q[55][15];
xy_t A[55][15];
xy_t B[55][15];
int c = 0;
int d = 0;
int main()
{
    while(cin >> n && n != 0)
    {
        for(int i = 0; i < n+1; i++)
        {
            cin >> m[i];
            for(int j = 0; j < m[i]; j++)
            {
                int x, y;
                cin >> x >> y;
                P[i][j] = xy_t(x, y);
                Q[i][m[i]-1-j] = P[i][j];
            }
        }
        
        for(int i = 1; i < n+1; i++)
        {
            A[i][0] = P[i][0];
            A[i][1] = P[i][1];
            B[i][0] = P[i][0];
            B[i][1] = P[i][1];
            for(int j = 2; j < m[i]; j++)
            {
                A[i][j] = (P[0][j] - P[0][0]) * (P[i][1] - P[i][0]) / (P[0][1] - P[0][0]) + P[i][0];
                B[i][j] = (Q[0][j] - Q[0][0]) * (P[i][1] - P[i][0]) / (Q[0][1] - Q[0][0]) + P[i][0];
            }
        }
        
        for(int i = 1; i < n+1; i++)
        {
            c = 0;
            d = 0;
            if(m[i] != m[0])
            {
                c = 1;
                d = 1;
            }
            if(abs(P[0][1] - P[0][0]) != abs(P[i][1] - P[i][0]))
            {
                c = 1;
            }
            for(int j = 0; j < m[i]; j++)
            {
                if(P[i][j] != A[i][j])
                {
                    c = 1;
                }
            }
            if(c == 0)
            {
                cout << i << endl;
            }
            else
            {
                if(abs(Q[0][1] - Q[0][0]) != abs(P[i][1] - P[i][0]))
                {
                    d = 1;
                }
                for(int j = 0; j < m[i]; j++)
                {
                    if(P[i][j] != B[i][j])
                    {
                        d = 1;
                    }
                }
                if(d == 0)
                {
                    cout << i << endl;
                }
            }
        }
        
        cout << "+++++" << endl;
    }
}

Measured memory_bytes: 3156
#include <stdio.h>

int main(void)
{
	char 	s[1024];
	int		cs[27] = {0};
	int		i;

	scanf("%s", s);
	i = 0;
	while (s[i])
		cs[s[i++] - 'a'] += 1;
	i = 0;
	while (i < 27)
	{
		if (1 < cs[i++])
		{
			printf("no\n");
			return (0);
		}
	}
	printf("yes\n");
	return 0;
}

Measured memory_bytes: 1640