akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

struct Edge{
	Edge(int arg_to,int arg_dist){
		to = arg_to;
		dist = arg_dist;
	}
	int to,dist;
};

struct Info{
	Info(int arg_node_id,int arg_sum_dist){
		node_id = arg_node_id;
		sum_dist = arg_sum_dist;
	}
	bool operator<(const struct Info &arg) const{

		return sum_dist > arg.sum_dist; //総距離の昇順(PQ)
	}

	int node_id,sum_dist;
};

int V,E,start;
int min_dist[SIZE];
vector<Edge> G[SIZE];

int main(){

	scanf("%d %d %d",&V,&E,&start);

	int from,to,dist;

	for(int i = 0; i < E; i++){

		scanf("%d %d %d",&from,&to,&dist);
		G[from].push_back(Edge(to,dist));
	}

	for(int i = 0; i < V; i++){

		min_dist[i] = BIG_NUM;
	}

	priority_queue<Info> Q;
	min_dist[start] = 0;

	Q.push(Info(start,0));

	while(!Q.empty()){

		if(Q.top().sum_dist > min_dist[Q.top().node_id]){

			Q.pop();

		}else{

			for(int i = 0; i < G[Q.top().node_id].size(); i++){

				int next_node = G[Q.top().node_id][i].to;
				int next_dist = Q.top().sum_dist+G[Q.top().node_id][i].dist;

				if(min_dist[next_node] > next_dist){
					min_dist[next_node] = next_dist;
					Q.push(Info(next_node,next_dist));
				}
			}
			Q.pop();
		}
	}

	for(int i = 0; i < V; i++){

		if(min_dist[i] == BIG_NUM){

			printf("INF\n");

		}else{

			printf("%d\n",min_dist[i]);
		}
	}

	return 0;
}



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

int main()
{
  int64_t N, P, p, tmp, res = 1;
  cin >> N >> P;
  if (N == 1)
  {
    cout << P << endl;
    return 0;
  }
  vector<pair<int, int>> D(0);
  p = P;
  for (int i = 2; i <= sqrt(P); i++)
  {
    if (p == 1)
      break;
    if (p % i == 0)
    {
      if (D.size() > 0 && D.at(D.size() - 1).first == i)
      {
        D.at(D.size() - 1).second++;
      }
      else
      {
        D.push_back(make_pair(i, 1));
      }
      p /= i;
      i--;
    }
  }
  for (int i = 0; i < D.size(); i++)
  {
    tmp = pow(D.at(i).first, (D.at(i).second / N));
    if (tmp != 0)
      res *= tmp;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;

int main()
{
    int a, b;
    cin>>a>>b;
    cout<<a*b<<endl;

    return 0;
}


Measured memory_bytes: 3568
#include <iostream>

using namespace std;

int main(void) {
  int A, B, C, D;
  int res = 0, tmp = 0;
  cin >> A >> B >> C >> D;

  tmp = (A < B) ? A : B;
  res = (C < D) ? C : D;

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


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
const int N=131072;
int tree[N*2-1];
int func(int a,int b,int k,int l,int r);
int main(void){
	int n,q;
	int n_2;
	int i,k;
	int com,x,y;
	int ans;
	cin>>n>>q;
	n_2=1;
	while(n_2<n)	n_2*=2;
	for(i=0;i<2*n_2-1;i++)	tree[i]=INT_MAX;
	for(i=0;i<q;i++){
		cin>>com>>x>>y;
		if(com==0){
			k=x+n_2-1;
			tree[k]=y;
			while(k>0){
				k=(k-1)/2;
				tree[k]=min(tree[2*k+1],tree[2*k+2]);
			}
		}
		else{
			ans=func(x,y+1,0,0,n_2);
			cout<<ans<<endl;
		}
	}
	return 0;
}
int func(int a,int b,int k,int l,int r){
	int chl,chr;
	if(b<=l||r<=a)	return INT_MAX;
	if(a<=l&&r<=b)	return tree[k];
	else{
		chl=func(a,b,2*k+1,l,(l+r)/2);
		chr=func(a,b,2*k+2,(l+r)/2,r);
		return min(chl,chr);
	}
}
			
			


Measured memory_bytes: 4124
def gcd_all(a):
    from math import gcd
    g = 0
    for x in a: g = gcd(g, x)
    return g

def is_pairwise():
    MAX_A = 10**6 + 1
    C = [0] * MAX_A
    for a in A: C[a] += 1
    if sum(C[2::2]) > 1: return False
    for i in range(3, MAX_A, 2):
        if sum(C[i::i]) > 1: return False
    return True

def solve():
    if is_pairwise(): return 'pairwise'
    if gcd_all(A) == 1: return 'setwise'
    return 'not'

n = int(input())
A = [*map(int, input().split())]
print(solve(), 'coprime')


Measured memory_bytes: 127428
def main():
    mod=1000000007
    n=int(input())
    if n==1:
        return 0
    
    inv=lambda x: pow(x,mod-2,mod)
    Fact=[1] #階乗
    for i in range(1,n+1):
        Fact.append(Fact[i-1]*i%mod)
    Finv=[0]*(n+1) #階乗の逆元
    Finv[-1]=inv(Fact[-1])
    for i in range(n-1,-1,-1):
        Finv[i]=Finv[i+1]*(i+1)%mod
    def comb(n,r):
        if n<r:
            return 0
        return Fact[n]*Finv[r]*Finv[n-r]%mod

    ans=0
    p=2**2
    others=pow(8,n-2,mod)
    for i in range(2,n+1):
        c=comb(n,i)
        ans+=(p-2)*others*c
        ans%=mod
        p*=2
        p%=mod
        others*=inv(8)
        others%=mod
    return ans

if __name__=='__main__':
    print(main())

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

typedef long long ll;
#define pi 3.14159265358979323846

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double angleofminutehand = (m/5)*30;
    double angleofhourhand = h*30 + m/2;

    double totalangle = fabs(angleofhourhand-angleofminutehand);

    totalangle = min(totalangle, 360-totalangle);
    if(totalangle>180) totalangle-=180;
    //cout << totalangle << '\n';
    totalangle = pi*totalangle/180;
    double ans = sqrtl((a*a+b*b)-2*a*b*cos(totalangle));
    cout << setprecision(20) << ans << '\n';

    return 0;
}



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

int main(){
	int x, h, m, s;
	cin >> x;
	h = int( x / 3600 );
	x = x - h * 3600;
	m = int( x / 60 );
	s = x - m * 60;
	cout << h << ":" << m << ":" << s <<endl;
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

const ll inf = 1e18;
ll dp[1000010][2];

int main() {
    string s; cin >> s;
    reverse(s.begin(), s.end());
    s += '0';
    int len = s.size();
    rep(i,len+1) rep(j,2) dp[i][j] = inf;
    dp[0][0] = 0;

    rep(i,len) rep(j,2) {
        int d = s[i] - '0';
        d += j;
        // 繰り上がりなし
        chmin(dp[i+1][0], dp[i][j]+d);
        // 繰り上がりあり
        chmin(dp[i+1][1], dp[i][j]+(10-d));
    }
    cout << dp[len][0] << endl;
    return 0;
}

Measured memory_bytes: 17028
/*
ID: marik_k1
PROG:
LANG: C++
*/
#include <bits/stdc++.h>

using namespace std;

//ifstream fin ("input.txt");
//ofstream fout ("output.txt");

#define forn(i,n) for(int i = 0; i < n; ++i)
#define mp make_pair
#define pb push_back
#define all(t) t.begin(),t.end()
#define gcd(x,y) __gcd(x,y)

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int N = 300000;
const int INF = (int)1e7;
const double eps = 1e-6;
const long long MOD = 1e9 + 7;
const double PI = M_PI;

set<int> s;
int n,k;
int ans;

bool good(int a){
	while(a){
		int r = a % 10;
		if(s.find(r) != s.end()){
			return false;
		}
		a /= 10;
	}
	return true;
}

int main(){
	std::ios::sync_with_stdio(false);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

	cin >> n >> k;
	for(int i = 0; i < k; ++i){
		int d;
		cin >> d;
		s.insert(d);
	}
	
	int ans = n;
	while(!good(ans)){
		ans++;
	}
	cout << ans;
	return 0;
}








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

using namespace std;

struct process {
	string name;
	int time;
};

int main(void) {
	int n,l,tt;
	string nt;
	cin >> n >> l;
	queue<process> q;
	for (int i = 0; i < n; ++i) {
		cin >> nt;
		cin >> tt;
		q.push({nt,tt});
	}
	int clock = 0;
	process now;
	while (!q.empty()) {
		now = q.front();
		q.pop();
		if (now.time <= l) {
			clock += now.time;
			cout << now.name << " ";
			cout << clock << endl;
		}
		else {
			q.push({now.name,now.time-l});
			clock += l;
		}
	}
	return 0;
}



Measured memory_bytes: 6356
#include <iostream>
#include <cstdio>
using namespace std;
int a,n,sum;
int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<3)+(x<<1)+ch-'0';
		ch=getchar();
	}
	return f*x;
}
int main()
{
	a=read();
	n=read();
	for(int i=1;i<=n;++i){
		sum+=read();
	}
	if(sum>=a) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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 long long INF = 1LL << 60;

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

  cout << (a <= c && c <= b ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define MN 201000
#define mod 1000000007

int cnt[MN], a[MN];
int fac[MN], f[MN], inv[MN];

int C(int a, int b) {if(a < b || b < 0) return 0; return 1ll * fac[a] * inv[b] % mod * inv[a - b] % mod;}

int main()
{
	int w, b; scanf("%d%d", &b, &w);
	
	fac[0] = inv[0] = inv[1] = 1;
	for(int i = 1; i <= 200000; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	for(int i = 2; i <= 200000; i++) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
	for(int i = 1; i <= 200000; i++) inv[i] = 1ll * inv[i] * inv[i - 1] % mod;
	
	int S = 0, p = 1;
	int tot = 0;
	for(int i = 1; i <= b + w; i++)
	{
		p = 1ll * p * inv[2] % mod;
		int Min = std::max(0, i - 1 - b + 1), Max = std::min(i - 1, w - 1);
		if(i == 1) tot = 1;
		else
		{
			int lMin = std::max(0, i - 2 - b + 1), lMax = std::min(i - 2, w - 1);
			if(lMin == Min - 1) tot = (tot - C(i - 1, lMin) + mod) % mod;
			if(lMax == Max - 1) tot = (tot + C(i - 1, Max)) % mod; 
		}
		printf("%lld\n", (1ll * tot * p % mod + S) % mod);
		tot = tot * 2 % mod - C(i - 1, Max) + C(i - 1, Min - 1);
		tot = (tot % mod + mod) % mod;
		
		if(i >= w) S = (S + 1ll * C(i - 1, w - 1) * p) % mod;
	}
}

Measured memory_bytes: 3712
#include<stdio.h>

int main()
{
	int a[15]={0},i,j,t;
	for(i=0;i<10;i++)
	{
		scanf("%d",&a[i]);
	}

	for(i=1;i<10;i++)
	{
		for(j=0;j<10-i;j++)
		{
			if(a[j]>a[j+1])
			{
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
			}

		}
	}

	printf("%d\n%d\n%d\n",a[9],a[8],a[7]);
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <algorithm>
#include <queue>
using namespace std;
using ll = long long;

ll n, a[100010], rese, r, b, sum;
priority_queue<ll> pq;
vector<ll> e;
bool containB(ll x, int bits) {
	return (x >> bits) & 1ll;
}
void GaussE(int bits) {
	if (pq.empty() || !containB(pq.top(), bits))
		return;
	ll model = pq.top();
	pq.pop();

	for (ll& val : e)
		if (containB(val, bits))
			val ^= model;
	e.emplace_back(model);
	while (!pq.empty() && containB(pq.top(), bits)) {
		ll cur = pq.top();
		pq.pop();
		pq.emplace(cur ^ model);
	}
}
int main() {
	scanf("%lld", &n);
	for (int i = 0; i < n; i++)
		scanf("%lld", a + i), r ^= a[i];
	sum = r;
	for (int i = 0; i < n; i++)
		a[i] ^= a[i] & r, pq.emplace(a[i]);
	for (int i = 59; 0 <= i; i--)
		GaussE(i);
	ll exor = 0;
	for (ll val : e)
		exor ^= val;
	printf("%lld\n", sum + exor * 2);
}

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

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> h(3, 0);
    cin >> h.at(0) >> h.at(1) >> h.at(2);
    for(int i = 1; i < n; ++i){
        vector<ll> tmp(3, 0);
        cin >> tmp.at(0) >> tmp.at(1) >> tmp.at(2);
        tmp.at(0) += max(h.at(1), h.at(2));
        tmp.at(1) += max(h.at(0), h.at(2));
        tmp.at(2) += max(h.at(0), h.at(1));
        h.swap(tmp);
    }
    cout << *max_element(h.begin(), h.end()) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        String s = ns();

        int cnt = 0;
        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) != s.charAt(i + 1)) cnt++;
        }

        out.println(cnt);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 10964
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var n, k int
	var s string
	fmt.Fscan(read, &n, &k, &s)
	fmt.Fprintln(write, s[:k-1]+strings.ToLower(s[k-1:k])+s[k:])
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()

using namespace std;
signed main(){
  int N,M;
  cin>>N>>M;
  bool M_answer = true;
  if(M==0){
    M_answer = false;
  }
  if(M_answer){
  vector<int> a(M);
  rep(i,M){
    int b , c ;
    cin>>b>>c;
    a[i]=10*b+c;
  }
  bool answer = true;
  sort(all(a));
  rep(j,M){
    rep(i,M){
      if(a[i]/10==a[j]/10){
        if(a[i]%10!=a[j]%10){
          answer = false;
        }
      }
    }
  }
  if(N!=1 && a[0]==10){
    answer = false;
  }
  if(answer){
    int sum =0;
    rep(i,M){
      if(a[i]/10==1){
        sum+=(a[i]%10)*pow(10,N-1);
        break;
      }
    }
    rep(i,M){
      if(a[i]/10==2){
        sum+=(a[i]%10)*pow(10,N-2);
        break;
      }
    }
    rep(i,M){
      if(a[i]/10==3){
        sum+=(a[i]%10)*pow(10,N-3);
        break;
      }
    }
    if(N!=1 && sum<pow(10,N-1)){
      sum+=pow(10,N-1);
    }
    cout<<sum<<endl;
  }
  else{
    cout<<-1<<endl;
  }
  }
  else if (N==1){
    cout<<0<<endl;
  }
  else{
    cout<<pow(10,N-1);
  }
}

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

int main() {
  long long a, b, c;

  a = 2;
  b = 1;

  int n;
  cin >> n;

  int i;
  for(i=2;i<=n;i++) {
  c = a + b;
  a = b;
  b = c;
  }

  if(n=0) cout << a << endl;
  if(n=1) cout << b << endl;
  if(n>=2) cout << c << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

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

    int ans = 0, i, j;
    char S[N];
    scanf("%s", &S);

    int bnum[N], tmp=0, wht=0, max_sequence, cnt=0;
    double max=0.0;
    for (i=N-1; i>=0; i--){
        if (S[i] == '#'){
            tmp++;
        }else{
            wht++;
        }
        bnum[i] = tmp;
        if ( bnum[i] - wht > max){
            max = bnum[i] - wht;
            max_sequence = i;
        }
    }

    if (tmp != 0){
        for (i=0; i<N; i++){
            if (i<max_sequence){
                if (S[i] != '.') ans++;
            }else{
                if (S[i] != '#') ans++;
            }
        }
    }

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

Measured memory_bytes: 1152
def main():
    N = int(input())

    alphabet = list('abcdefghijklmnopqrstuvwxyz')
    name = []

    while True:
        if N % 26:
            res = N % 26
        else:
            res = 26

        name.append(alphabet[res-1])

        if N - res == 0:
            break
        else:
            N = (N - res) // 26
    
    print(''.join(name[::-1]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9184
#include <iostream>

using namespace std;

int n, m;
int H[100000];
int d[100000] = {0};

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        d[i] = 0;
        cin >> H[i];
    }
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;

        d[a] = max(d[a], H[b]);
        d[b] = max(d[b], H[a]);
    }
    int ret = 0;
    for (int i = 1; i <= n; i++)
    {
        if (H[i] > d[i])
            ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n,i;
  cin>>n;
  ll a[n],sum=0;
  for(i=0;i<n;i++)
  {
    cin>>a[i];
    a[i]*=2;
    if(i%2) sum-=a[i];
    else sum+=a[i];
  }
  ll x[n];
  x[0]=sum/2;
  cout<<x[0]<<" ";
  for(i=1;i<n;i++)
  {
    x[i]=a[i-1]-x[i-1];
    cout<<x[i]<<" ";
  }
  return 0;
}

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

#define REP(i,n) for (long long i=0;i<(n);i++)
#define REPT(i,t,n) for (long long i=t;i<(n);i++)

int result_int = 0;
long Result_lng;
string Result_str = "";


int X, Y, realV,N;
//char S,target;
string S;

int main() {
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    REP(i,N) {
        cin >> V[i];
    }
    REP(i,N) {
        cin >> C[i];
    }

    REP(i,N) {
        if(V[i] > C[i]) {
            result_int += V[i] - C[i];
        }
    }
    cout << result_int;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N,C,K,ans;
int main(){
    cin>>N>>C>>K;
    int T[N];
    for(int i=0;i<N;i++)cin>>T[i];
    sort(T,T+N);
    for(int i=0,M=0;i<N;i++)if(T[M]+K<T[i]||i-M+1>C)ans++,M=i;
    cout<<ans+1<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;
typedef unsigned int UINT;
typedef int INT;


int main()
{
	INT N, M;
	cin >> N >> M;

	int even = N * (N - 1) / 2;
	int odd = M * (M - 1) / 2;

	int ret = even + odd;
	cout << ret << endl;

	return 0;
}



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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}

template<typename T>
class Union_Find {
private:
  T n;
  vector<T> parent;

public:
  Union_Find(T v){
    n=v;
    parent.resize(n,-1);
  }

  T root(T v){
    if(parent[v]<0)return v;
    return parent[v]=root(parent[v]);
  }
  T size(T v){
    return -parent[root(v)];
  }
  bool connect(T a,T b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(size(a)<size(b)) swap(a,b);
    parent[a]+=parent[b];
    parent[b]=a;
    return true;
  }
  bool same(T a,T b){
    return root(a)==root(b);
  }

};

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  ll n;
  cin>>n;
  vector<ll> a(n);
  vector<ll> b(n-1);
  cin>>b;
  a[0]=b[0];
  a[n-1]=b[n-2];
  for(ll i=1;i<n-1;++i){
    a[i]=min(b[i],b[i-1]);
  }
  ll sum=0;
  rep(i,n)sum+=a[i];
  cout<<(sum)<<endl;
  
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  string s;
  cin>>s;
  int score = 0;
  int gc = 0;
  int pc = 0;
  rep(i,s.size()) {
    if(gc == pc) {
      gc++;
      if(s[i] == 'p') score--;
    } else {
      pc++;
      if(s[i] == 'g') score++;
    }
  }
  cout << score << endl;

  return 0;
}


Measured memory_bytes: 512
#define _DEBUG 1

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

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

void solve(ll N, std::vector<ll> a) {
  ll max = 0;
  ll min = 1000;
  for (ll x : a) {
    if (x > max)
      max = x;
    if (x < min)
      min = x;
  }

  cout << max - min << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  ll N;
  scanf("%lld", &N);
  std::vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, std::move(a));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    vector<int> A;
    for(int i =0 ; i < N; i++){
        A.push_back(0);
    }
    
    for(int i =0 ; i < N-1; i++){
        int index;
        cin >> index;
        A[index - 1]++;


    }
    for(int i =0 ; i < N; i++){
        cout << A[i] << endl;
    }
    
    
}


Measured memory_bytes: 4232
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	set<int> st;
	int a, b, c;
	cin >> a >> b >> c;
	st.insert(a);
	st.insert(b);
	st.insert(c);
	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::{input, fastout};

macro_rules! echo {
  ($val:expr) => {
    println!("{}", $val);
  }
}

#[fastout]
fn main() {
  input!{
    n: usize,
    m: usize,
    py: [(usize, usize); m]
  };
  let mut mat : Vec<Vec<(usize, usize)>> = vec![Vec::new(); n+1];

  for (i, (p, y)) in py.iter().enumerate() {
    mat[*p].push((i, *y));
  }

  let mut ans = vec![None; m];

  for i in 0..=n {
    mat[i].sort_by_cached_key(|&t| t.1);
    for (k, (j, _)) in mat[i].iter().enumerate() {
      ans[*j] = Some(format!("{:06}{:06}", i, k+1));
    }
  }
  for a in ans {
    echo!(a.unwrap());
  }
}


Measured memory_bytes: 16016
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<vector>
#include<queue>
using namespace std;
namespace MCF {
	// required <string.h> <vector> <queue> <algorithm>
	#define MAXN 31000
	#define MAXM 120000
	#define wint int
	#define cint long long 
	const wint wEPS = 0;
	const wint wINF = 1001001001;
	const cint cEPS = 0;
	const cint cINF = 1001001001001001001LL;
	int n, m, ptr[MAXN], next[MAXM], zu[MAXM];
	wint capa[MAXM], tof;
	cint cost[MAXM], toc, d[MAXN], pot[MAXN];
	int vis[MAXN], pree[MAXN];
	void init(int _n) {
		n = _n; m = 0; memset(ptr, ~0, n * 4);
	}
	void ae(int u, int v, wint w, cint c) {
		next[m] = ptr[u]; ptr[u] = m; zu[m] = v; capa[m] = w; cost[m] = +c; ++m;
		next[m] = ptr[v]; ptr[v] = m; zu[m] = u; capa[m] = 0; cost[m] = -c; ++m;
	}
	bool solve(int src, int ink, wint flo = wINF) {
		int i, u, v;
		wint f;
		cint c, cc;
		memset(pot, 0, n * sizeof(cint));
		//*
		for (bool cont = 1; cont; ) {
			cont = 0;
			for (u = 0; u < n; ++u) for (i = ptr[u]; ~i; i = next[i]) if (capa[i]) {
				if (pot[zu[i]] > pot[u] + cost[i]) {
					pot[zu[i]] = pot[u] + cost[i]; cont = 1;
				}
			}
		}
		//*/
		for (toc = 0, tof = 0; tof < flo; ) {
			typedef pair<cint,int> node;
			priority_queue< node,vector<node>,greater<node> > q;
			for (u = 0; u < n; ++u) { d[u] = cINF; vis[u] = 0; }
			for (q.push(make_pair(d[src] = 0, src)); !q.empty(); ) {
				c = q.top().first; u = q.top().second; q.pop();
				if (vis[u]++) continue;
				for (i = ptr[u]; ~i; i = next[i]) if (capa[i]) {
					cc = c + cost[i] + pot[u] - pot[v = zu[i]];
					if (d[v] > cc) { q.push(make_pair(d[v] = cc, v)); pree[v] = i; }
				}
			}
			if (!vis[ink]) return 0;
			f = flo - tof;
			for (v = ink; v != src; v = zu[i ^ 1]) { i = pree[v]; f=min(f,capa[i]); }
			for (v = ink; v != src; v = zu[i ^ 1]) { i = pree[v]; capa[i] -= f; capa[i ^ 1] += f; }
			tof += f;
			toc += f * (d[ink] - pot[src] + pot[ink]);
			for (u = 0; u < n; ++u) pot[u] += d[u];
		}
		return 1;
	}
}
int p[11000];
int q[11000];
int last[11000];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<b;i++){
		scanf("%d",p+i);
	}
	for(int i=0;i<c;i++){
		scanf("%d",q+i);
		q[i]--;
	}
	for(int i=0;i<b;i++)last[i]=-1;
	MCF::init((c+1)*3+2);
	int s=(c+1)*3;
	int t=(c+1)*3+1;
	MCF::ae(s,0,a,0);
	MCF::ae(c,t,a,0);
	int ret=0;
	for(int i=0;i<c;i++){
		MCF::ae(i,i+1,a,0);
		if(~last[q[i]]){
			if(last[q[i]]+1==i)ret-=p[q[i]];
			else MCF::ae(last[q[i]],i-1,1,-p[q[i]]);
		}
		last[q[i]]=i;
	}
	MCF::solve(s,t,a-1);
	for(int i=0;i<c;i++)ret+=p[q[i]];
	printf("%lld\n",MCF::toc+ret);
}

Measured memory_bytes: 2856
#include <bits/stdc++.h>
 
#define ll long long
#define ii pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 1000000000000000007
 
using namespace std;
#define prime 1000000007
 
#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << endl;

ll pot(ll b, ll e){
	ll res = 1;
	b%=prime;
	while(e != 0){
		if(e%2) {
			res*=b;
			res%=prime;
		}
		b*=b;
		b%=prime;
		e>>=1;
	}
	return res;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	ll fac[1000100];
	fac[0] = 1;
	for (int i = 1; i < 1000001; ++i){
		fac[i] = fac[i-1]*i;
		fac[i]%=prime;
	}
	ll x, y; cin >> x >> y;
	if((x+y)%3){
		cout << "0\n";
		return 0;
	}
	if(x < (x+y)/3 || y < (x+y)/3){
		cout << "0\n";
		return 0;
	}
	ll n = x+y;
	ll m = (x+y)/3, k;
	if(m%2 == 0){
		k = m/2-llabs(n/2 - x);
	}else{
		k = max(llabs(n/2-x), llabs(n/2-y))+m/2;
	}
	cout << ((fac[m]%prime)*pot((fac[m-k]*fac[k]), prime-2))%prime << endl;
	

	return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd; 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define pb(v) push_back(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b)
{
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s)
{
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v)
{
	forl(i,v.size())
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
}
void pa(ll *v,ll size)
{
	forl(i,size)
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
}
// ll nck(ll N,ll K,ll mod)
// {
// 	if(N<K)
// 	{
// 		return 0;
// 	}
// 	return (((facs[N]*facsinv[N-K])%mod)*facsinv[K])%mod;
// }
ll power(ll x,ll y,ll p)
{
	ll res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		{
			res=(res*x)%p;
		}
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x,ll mod)
{
	if(x>=mod)
	{
		x%=mod;
	}
}
ll sumofgp(ll a,ll n,ll m)
{
	// n = number of terms - 1
	if(n<0)
	{
		return 0;
	}
	if(n==0)
	{
		return 1;
	}
	if(n==1)
	{
		return (1+a)%m;
	}
	ll ans;
	if(n%2)
	{
        ans=(1+a)*sumofgp((a*a)%m,(n-1)/2,m);
	}
    else
    {
        ans=1+((a*(1+a))%m)*sumofgp((a*a)%m,n/2-1,m);
    }
    return ans%m;
}
// void checktime()
// {
// 	struct timespec ts;
// 	printf("Running Program\n");
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double st=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	// Call Funcn Here
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double en=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	printf("Program ended\nTime = %Lf\n",en-st);
// }
int main(void)
{
	fastio
	ll h,a;
	cin>>h>>a;
	cout<<(h+a-1)/a<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    int n=0;
    while(cin>>n)
    {
        int cnt=0;
        if(n==0)break;
        for(;;)
        {
            if(n==1)break;
            if(n%2==0)
            {
                //cout<<"ok"<<endl;
                n/=2;
                cnt++;
            }
            else if(n%2!=0)
            {
                //cout<<"3ok"<<endl;
                n*=3;
                n+=1;
                cnt++;
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}

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

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

bool isPrime(int n) {
	int i = 2;
	bool res = true;

	while(i*i<n) {
		if(n%i==0) {
			res = false;
			break;
		} else {
			i++;
		}
		//cout << "i " << i << endl;
	}

	return res;
}

int main() {

	int X;
	cin >> X;

	while(true) {
		// cout << "X " << X << endl;
		if(isPrime(X)) {
			cout << X << endl;
			break;
		} else {
			X++;
		}
	}
			
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	string sa;
	cin>>sa;
	sa[1]=(char)((int)'B'+(int)'R'-(int)sa[1]);
	cout<<sa<<endl;
}


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

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type,Name, n,m,d)vector<vector<Type>> Name(n, vector<Type>(m, d))
#define P pair
using namespace std;
using ll = long long;


int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	ll a, b, n;
	cin >> a >> b >> n;
	ll x = n;

	if (n >= b - 1) x = b - 1;
	ll ans = a * (x % b) / b;
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll k;
    cin>>k;
    ll ma=3,mi=2;
    ll a[k];
    for(int i=0;i<k;i++)cin>>a[i];
    reverse(a,a+k);
    for(int i=1;i<k;i++){
        mi=(mi+a[i]-1)/a[i];
        ma=ma/a[i];
        mi*=a[i];
        ma*=a[i];
        ma+=a[i]-1;
    }
    reverse(a,a+k);
    ll num=mi,m=ma;
    for(int i=0;i<k;i++){
        num/=a[i];
        num*=a[i];
        m/=a[i];
        m*=a[i];
    }
    if(m==2&&num==2)cout << mi<<" "<<ma<<endl;
    else cout<< -1<<endl;
    return 0;
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  if (a < b) {
    cout << "a < b" << endl;
  } else if (a > b) {
    cout << "a > b" << endl;
  } else {
    cout << "a == b" << endl;
  }
  return 0;
}



Measured memory_bytes: 3072
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  int n;
  cin >> n;
  vector<int> v(n),c(n);
  REP(i, n) {
    cin >> v[i];
  }
  REP(i, n) {
    cin >> c[i];
  }

  int ans = 0;
  REP(i, n) {
    if(v[i]-c[i] > 0) {
      ans += v[i]-c[i];
    }
  }

  cout << ans << endl;
}


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

using namespace std;


#define MAXN 10001
typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, a[MAXN], b[MAXN];
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  ll luft=0, treba=0;
  for (int i = 0; i < n; ++i) {
    luft += max(0, (b[i]-a[i])/2);
    treba += max(0, a[i]-b[i]);
  }
  cout << (luft>=treba ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 384
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<sstream>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
#include <cstdio>
using namespace std;

int main() {
	int i, j;
	string S;
	cin >> S;
	int MM = 0;
	int YY = 0;
	int MMYY = 0;
	int YYMM = 0;


	if (S[0] == '0') {
		if ('1' <= S[1] && S[1] <= '9') {
			++MM;
		}
		else if(S[1]=='0') {
			++YY;
		}
	}
	else if (S[0] == '1') {
		if ('0' <= S[1] && S[1] <= '2') {
			++MM;
		}
		else if('3' <= S[1] && S[1] <= '9') {
			++YY;
		}
	}
	else {
		++YY;
	}

	if (S[2] == '0') {
		if ('1' <= S[3] && S[3] <= '9') {
			++MM;
			if (YY == 1) {
				++YYMM;
			}
		}
		else if (S[3] == '0') {
			++YY;
			if (MM == 1) {
				++MMYY;
			}
		}
	}
	else if (S[2] == '1') {
		if ('0' <= S[3] && S[3] <= '2') {
			++MM;
			if (YY == 1) {
				++YYMM;
			}
		}
		else if ('3' <= S[3] && S[3] <= '9') {
			++YY;
			if (MM == 1) {
				++MMYY;
			}
		}
	}
	else {
		if (MM == 1) {
			++MMYY;
		}
		else {
			++YY;
		}
	}


	if (YY == 2) {
		cout << "NA" << endl;
	}
	else if (MM == 2) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (MMYY == 1) {
		cout << "MMYY" << endl;
	}
	else if (YYMM == 1) {
		cout << "YYMM" << endl;
	}

	//cout << YY << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N; cin >> N;
    vector<int> data(10000);
    for(int i = 1; i < 10001; i++){
        for(int j = 1; j < 10001; j++){
            for(int k = 1; k < 10001; k++){
                int tmp = i*i + j*j + k*k + i*j + j*k + k*i;
                if(tmp > 10000) break;
                else{
                    tmp --;
                    data[tmp] += 1;
                }
            }
        }
    }

    for(int i = 0; i < N; i++){
        cout << data[i];
        if(i != N-1){
            cout << endl;
        }
    }
}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 100000000
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	// buf := make([]byte, initialBufSize)
	// sc.Buffer(buf, maxBufSize)

	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}

const divisor = 1000000007

type brokenIndexes map[int]struct{}

func (bi *brokenIndexes) add(key int) {
	(*bi)[key] = struct{}{}
}

func countWays(stairNum int, bi brokenIndexes) int {
	counts := make([]int, stairNum+1)
	counts[0] = 1
	counts[1] = returnStairs(1, 1, bi)
	for i := 2; i < stairNum+1; i++ {
		stairs := counts[i-1] + counts[i-2]
		if stairs == 0 {
			return 0
		}
		counts[i] = returnStairs(i, stairs, bi) % divisor
	}
	return counts[stairNum]
}

func returnStairs(index, value int, bi brokenIndexes) int {
	if _, ok := bi[index]; ok {
		return 0
	}
	return value
}

func main() {
	n, m := nextInt(), nextInt()
	bi := make(brokenIndexes, m)
	for i := 0; i < m; i++ {
		bi.add(nextInt())
	}
	r := countWays(n, bi)
	fmt.Println(r)
}


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

int main(void)
{
  int h, w;
  string s;
  
  cin >> h >> w;
  
  for(int i=0; i<h; i++){
      cin >> s;
      for(int j=0; j<2; j++){
        cout << s << endl;
      }
  }
  return 0;
}


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

#define DIV 1000000007

long long N, K;
long long zero;
vector<long long> posi;
vector<long long> nega;

long long posibig[200005];
long long posismall[200005];
long long negabig[200005];
long long negasmall[200005];


int main(){
	cin >> N >> K;
	for(long long i = 0; i < N; i++) {
		long long tmp;
		cin >> tmp;
		if(tmp > 0) {
			posi.push_back(tmp);
		} else if(tmp == 0) {
			zero++;
		} else {
			nega.push_back(tmp);
		}
	}


	bool canposi = false;
	if(posi.size() >= K) {
		canposi = true;
	} else {
		long long rest = K - posi.size();
		if(rest % 2 == 0 && nega.size() >= rest) {
			canposi = true;
		}
		if(posi.size() > 0) {
			rest++;
			if(rest % 2 == 0 && nega.size() >= rest) {
				canposi = true;
			}
		}
	}


	if(canposi) {
		//cout << "can posi" << endl;
		sort(posi.begin(), posi.end(), greater<long long>());
		sort(nega.begin(), nega.end());
		//for(long long i = 0; i < posi.size(); i++) {
		//	cout << "posi[" << i << "] = " << posi[i] << endl;
		//}
		//for(long long i = 0; i < nega.size(); i++) {
		//	cout << "nega[" << i << "] = " << nega[i] << endl;
		//}

		long long posinum = min((long long) posi.size(), K);
		long long neganum = K - posinum;
		if(neganum % 2 == 1) {
			posinum--;
			neganum++;
		}

		while(posinum >= 2 && neganum <= (long long)nega.size() - 2 && abs(posi[posinum-1] * posi[posinum - 2]) < abs(nega[neganum] * nega[neganum + 1])) {
			posinum-=2;
			neganum+=2;
		}

		//cout << "posinum = " << posinum << endl;
		//cout << "neganum = " << neganum << endl;

		long long ans = 1;
		for(long long i = 0; i < posinum; i++) {
			ans *= posi[i];
			ans %= DIV;
		}

		for(long long i = 0; i < neganum; i++) {
			ans *= nega[i];
			ans %= DIV;
		}
		cout << ans << endl;
		return 0;
	}

	//cout << "can not posi" << endl;



	if(zero>0) {
		cout << 0 << endl;
		return 0;
	}

	sort(posi.begin(), posi.end());
	sort(nega.begin(), nega.end(), greater<long long>());


	long long neganum = min((long long) nega.size(), K);
	long long posinum = K - neganum;
	if(neganum % 2 == 0) {
		neganum--;
		posinum++;
	}

	while(neganum >= 2 && posinum <= (long long)posi.size() - 2 && abs(nega[neganum-1] * nega[neganum - 2]) > abs(posi[posinum] * posi[posinum + 1])) {
		neganum-=2;
		posinum+=2;
	}

	//cout << "posinum = " << posinum << endl;
	//cout << "neganum = " << neganum << endl;

	long long ans = 1;
	for(long long i = 0; i < posinum; i++) {
		ans *= posi[i];
		ans %= DIV;
	}

	for(long long i = 0; i < neganum; i++) {
		ans *= nega[i];
		ans %= DIV;
	}
	cout << (ans + DIV)%DIV << endl;
}


Measured memory_bytes: 5616
// ~/Remember,remember the 6th of March
#include <functional>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<complex>
#include <unordered_map>
#include<unordered_set>
#include <numeric>
#include <string>
#include<iostream>
#include <fstream>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-11;
const ll MOD = 1000000007;
const int N = 100000 + 7;
void fast()
{
	std::ios_base::sync_with_stdio(0);
}
int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt","w",stdout);
#endif*/
	string s;
	cin >> s;
	int cnt = 0;
	if (s[0] == '2')cnt++;
	if (s[1] == '2')cnt++;
	if (s[2] == '2')cnt++;
	if (s[3] == '2')cnt++;
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

vector<int> factor(100 + 1);

void prime_factor(int n) {
    for (int i = 2; i * i <= n; i++)
        while (n % i == 0) {
            factor[i]++;
            n /= i;
        }
    if (n != 1) factor[n] += 1;
}

int num(int n) {
    int ret = 0;
    for (auto x:factor) {
        if (x >= n - 1) ret++;
    }
    return ret;
}

int main() {
    int N;
    cin >> N;

    for (int i = 2; i <= N; i++) {
        prime_factor(i);
    }
    
    cout << num(75) +
            num(25) * (num(3) - 1) +
            num(15) * (num(5) - 1) +
            num(5) * (num(5) - 1) * (num(3) - 2) / 2
         << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import permutations

N = int(input())
P = input()
Q = input()

a = -1
b = -1
base = list(range(1, N + 1))
for i, l in enumerate(permutations(base, N)):
    s = ' '.join([str(x) for x in l])
    if (P == s):
        a = i
    if (Q == s):
        b = i
print(abs(a - b))


Measured memory_bytes: 43100
//Code by Mukul Totla
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{   
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n,i;
  cin>>n;
  int arr[n],temp[n];
  map<int ,int>m;
  int maxm=1;
  for(i=0; i<n; i++)
  {
    cin>>arr[i];
    m[arr[i]]+=1;
    maxm=max(arr[i],maxm);
    temp[i]=arr[i];
  }
  sort(temp,temp+n);
  if(m[maxm]>=2)
  {
    for(i=0; i<n; i++)
      cout<<maxm<<'\n';
  }
  else
  {
     for(i=0; i<n; i++)
     {
      if(arr[i]==maxm)
        cout<<temp[n-2]<<'\n';
      else
        cout<<temp[n-1]<<'\n';
     }
   }
  return 0;
}

Measured memory_bytes: 10596
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 10005
#define LL long long
int n,a,b;
int Abs(int x)
{
	if(x>=0) return x;
	return -x;
}
int main()
{
	scanf("%d %d %d",&n,&a,&b);
	printf("%d\n",min(n*a,b));
	return 0;
}

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

int main(void){
    int N, ans = 0;
    std::cin >> N;
    std::vector<int> A(100002, 0);

    for (int i = 0; i < N; ++i){
        int a;
        std::cin >> a;
        if (a != 0){
            ++A[a - 1];
        }
        ++A[a];
        ++A[a + 1];
    }

    for (int i = 0; i < 100001; ++i){
        ans = std::max(ans, A[i]);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3788
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<string>

using namespace std;

const int INF = 1e9;
int N,C;
int Cost[30][30];
int Wall[3][30];

int solve(int i){
    int color[3];
    color[0]=i%C;
    int tmp=(i-color[0])/C;
    color[1]=tmp%C;
    int tmptmp=(tmp-color[1])/C;
    color[2]=tmptmp%C;
    if(color[0]==color[1] || color[1]==color[2] || color[2]==color[0]) return INF;
    int ret=0;
    for(int t=0;t<3;t++){
        for(int c=0;c<C;c++){
            ret += Wall[t][c]*Cost[c][color[t]];
        }
    }
    return ret;
}

int main(){
    cin>>N>>C;
    for(int i=0;i<C;i++){
        for(int j=0;j<C;j++){
            cin>>Cost[i][j];
        }
    }
    for(int t=0;t<3;t++){
        for(int c=0;c<30;c++){
            Wall[t][c]=0;
        }
    }
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            int color;
            cin>>color;
            color--;
            int t = (i+j)%3;
            Wall[t][color]++;
        }
    }
    int ans=INF;
    for(int i=0;i<C*C*C;i++){
        ans = min(ans,solve(i));
    }
    cout<<ans<<endl;
    return 0;
}


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 300010, M = 1010;

int n, m;
int h[N], e[N], ne[N], idx;
int q[N], dist[N];
int s, t;

void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

int bfs(int st, int ed)
{
	int hh = 0, tt = -1;
	dist[st] = 0;
	q[ ++ tt] = st;
	
	while (hh <= tt)
	{
		int t = q[hh ++ ];
		
		for (int i = h[t]; ~i; i = ne[i])
		{
			int j = e[i];
			if (dist[j]) continue;
			
			q[ ++ tt] = j;
			dist[j] = dist[t] + 1;
			
			if (j == ed) break;
		}
	}

	if (dist[ed] && dist[ed] % 3 == 0) return dist[ed] / 3;
	else return -1;
}

int main()
{
	memset(h, -1, sizeof h);
	
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i ++ )
	{
		int a, b;
		scanf("%d%d", &a, &b);
		add(a * 3, b * 3 + 1);
		add(a * 3 + 1, b * 3 + 2);
		add(a * 3 + 2, b * 3);
	}
	
	scanf("%d%d", &s, &t);
	printf("%d\n", bfs(s * 3, t * 3));
	return 0;
}

Measured memory_bytes: 6144