akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define viii vector <pair<ll,pair<ll,ll> > >
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<endl
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define endl "\n"
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
bool compare(pair<ll,string> p1,pair<ll,string> p2){
return p2.fi>p1.fi;
}
void cycle(ll p[],ll fi,ll si,ll ti){
swap(p[fi],p[ti]);
swap(p[si],p[ti]);
}
void solve(){
string s,t;
cin>>s>>t;
ll a=t.length()-1;
t.erase(t.begin()+a);
if(s==t) yes;
else no;
}
int main()
{   fast;
    ll t=1;
    //cin>>t;
    fr(zz,1,t+1){
    solve();
    }
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
template<typename T>
class fixed_point : T {
  public:
    explicit constexpr fixed_point (
        T&& t
      ) noexcept
      : T(forward<T>(t))
      {
      }
    template<typename... Args>
    constexpr decltype(auto)
    operator()(
        Args&&... args
      ) const
      {
        return T::operator()(*this, forward<Args>(args)...);
      }
};
template<typename T>
static inline constexpr decltype(auto) fix (T&& t) noexcept {
  return fixed_point<T>{forward<T>(t)};
}
template <typename T>
class dinic {
  struct edge {
    int to; T cap;
    weak_ptr<edge> rev;
  };
  const int n, source, sink;
  vector<bool> ckd;
  vector<int> dst;
  vector<vector<shared_ptr<edge>>> grh;
  static constexpr T inf = numeric_limits<T>::max();
  void bfs () {
    queue<int> que;
    que.emplace(source); dst[source] = 0;
    while (!que.empty()) {
      int crr = que.front(); que.pop();
      for (auto const& e : grh[crr]) {
        if (e->cap == 0) continue;
        int nxt = e->to;
        if (dst[nxt] != -1) continue;
        que.push(nxt); dst[nxt] = dst[crr] + 1;
      }
    }
  }
  T dfs () {
    return fix ([&](auto dfs, int crr, int f = inf) -> T {
      if (crr == sink) return f;
      ckd[crr] = true;
      for (auto& e : grh[crr]) {
        int nxt = e->to;
        if (ckd[nxt] || e->cap == 0 || dst[crr] >= dst[nxt]) continue;
        T d = dfs(nxt, min(f, e->cap));
        if (d > 0) {
          e->cap -= d;
          e->rev.lock()->cap += d;
          return d;
        }
      }
      dst[crr] = -1;
      return 0;
    })(source);
  }
  public:
    dinic (int n, int source, int sink) :
      n(n), source(source), sink(sink), grh(n)
      {}
    void insert(int u, int v, T c) {
      auto e = make_shared<edge>(edge{v, c});
      auto r = make_shared<edge>(edge{u, 0});
      e->rev = r;
      r->rev = e;
      grh[u].push_back(e);
      grh[v].push_back(r);
    }
    T cal() {
      T ret = 0;
      while (true) {
        dst.assign(n, -1);
        bfs();
        if (dst[sink] == -1) return ret;
        ckd.assign(n, false);
        while (true) {
          T f = dfs();
          if (f == 0) break;
          ret += f;
        }
      }
    }
};
class binary_matching {
  int x, y;
  dinic<int> dnc;
  public:
    binary_matching(int x, int y) :
      x(x), y(y), dnc([x, y]{
        dinic<int> dnc(1 + x + y + 1, 0, 1 + x + y);
        for (int i = 0; i < x; i++) dnc.insert(0, 1 + i, 1);
        for (int j = 0; j < y; j++) dnc.insert(1 + x + j, 1 + x + y, 1);
        return dnc;
      }())
      {}
    void insert (int i, int j) {
      dnc.insert(1 + i, 1 + x + j, 1);
    }
    int cal () {return dnc.cal();}
};
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n;
  cin >> n;
  binary_matching mcg(n, n);
  vector<int> a(n), b(n), c(n), d(n);
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
  for (int i = 0; i < n; i++) cin >> c[i] >> d[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i] < c[j] && b[i] < d[j]) {
        mcg.insert(i, j);
      }
    }
  }
  int ret = mcg.cal();
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 768
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res="";
		int res;
		int[] vals = parseAry(Console.ReadLine().Split(cs));

		res = Math.Max(vals[0] + vals[1], vals[0] - vals[1]);
		res = Math.Max(res, vals[0] * vals[1]);

	

			//deug
			Console.WriteLine(res);

		return;
	}


	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = long.Parse(str[i]); }
		return nums;
	}



	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}

Measured memory_bytes: 13140
use std::io::{self, Read};
use std::str::FromStr;

pub struct Scanner<R: Read> {
    reader: R,
}
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let s = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.expect("failed to read char") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        s.parse::<T>().ok().expect("failed to parse token")
    }
}

enum Tree {
    Nil,
    Node {
        key: i64,
        left: Box<Tree>,
        right: Box<Tree>,
    },
}

#[allow(dead_code)]
impl Tree {
    fn insert(&mut self, val: i64) {
        match *self {
            Tree::Nil => {
                *self = Tree::Node{ 
                    key: val, 
                    left: Box::new(Tree::Nil), 
                    right: Box::new(Tree::Nil),
                }
            },
            Tree::Node{ref key, ref mut left, ref mut right} => {
                if *key < val {
                    right.insert(val);
                } else {
                    left.insert(val);
                }
            },
        }
    }

    fn find(&self, val: i64) -> bool {
        if let Tree::Node{ref key, ref left, ref right} = *self {
            if *key == val {
                return true;
            } else if *key < val {
                return right.find(val);
            } else {
                return left.find(val);
            }
        } else {
            return false;
        }
    }

    fn print_pre(&self) {
        if let Tree::Node{ref key, ref left, ref right} = *self {
            print!(" {}", key);
            left.print_pre();
            right.print_pre();
        }
    }
    
    fn print_in(&self) {
        if let Tree::Node{ref key, ref left, ref right} = *self {
            left.print_in();
            print!(" {}", key);
            right.print_in();
        }
    }

    fn print_post(&self) {
        if let Tree::Node{ref key, ref left, ref right} = *self {
            left.print_post();
            right.print_post();
            print!(" {}", key);
        }
    }
}


fn main() {
    let sin = io::stdin();
    let sin = sin.lock();
    let mut sc = Scanner::new(sin);

    let n: usize = sc.read();
    let mut tree = Tree::Nil;

    for _ in 0..n {
        let cmd: String = sc.read();
        match cmd.as_str() {
            "insert" => {
                let val: i64 = sc.read();
                tree.insert(val);
            },
            "find" => {
                let val: i64 = sc.read();
                if tree.find(val) {
                    println!("yes");
                } else {
                    println!("no");
                }
            },
            "print" => {
                tree.print_in();
                println!("");
                tree.print_pre();
                println!("");
            },
            _ => { panic!("irregular command"); }
        }
    }
}



Measured memory_bytes: 29600
N = int(input())

a_n=[int(input()) for i in range(N)]
import sys

i=1
count=0
for k in range(N):
    if a_n[i-1]==2:
        count+=1
        print(count)
        sys.exit()
    else:
        i=a_n[i-1]
        count+=1

print(-1)

Measured memory_bytes: 7084
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef unsigned long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

map<ll, ll> factorize(ll n) {  // O(ツ」n)
  map<ll, ll> res;
  for (int i=2; i*i<=n; ++i) {
    int cnt = 0;
    while (n%i==0) {
      n /= i;
      cnt++;
    }
    if (cnt) {
      res[i] = cnt;
    }
  }
  if (n!=1) res[n] = 1;
  return res;
}

int main() {
  int N; string M;
  int AAA = 0;
  while(cin >> N >> M, N) {
    ll num = strtoll(M.c_str(), NULL, N);
    map<ll, ll> factor = factorize(N);
    ll ans = 1LL<<62;
    FOR(it, factor) {
      ll now = it->first;
      ll cnt = 0;
      while(1) {
        cnt += num / now;
        if (now>num/it->first+EPS) break;
        now *= it->first;
      }
      //cout << it->first << " " << it->second << " " << cnt << endl;
       ans = min(ans, cnt/it->second);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 948
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<stack>
using namespace std;
typedef long long ll;
ll sum=0,b[100001]={0};
int main(){
	ll n,t,k,j;
	cin>>n;
	while(n--){
		cin>>t;
		b[t]++;
		sum+=t;
	}
	cin>>t;
	while(t--){
		cin>>k>>j;
		ll s=j-k;
		sum+=(b[k]*s);
		b[j]+=b[k];
		b[k]=0;
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 3896
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int n,m,a[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>m;int x=0,y=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    x+=a[i];
    y=max(y,a[i]);
  }
  sort(a+1,a+1+n,[](int x,int y){return x>y;});
  int sta=1;
  for(int i=1;i<=m;i++){
    sta&=(a[i]*4*m>=x);
  }
  if(sta)cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}

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

bool solve(string s)
{
    for (auto c = 'a'; c <= 'z'; c++)
        if (count(begin(s), end(s), c) % 2 == 1)
            return false;
    return true;
}

int main()
{
    string s; cin >> s;
    cout << (solve(s) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int dp[205000];
int N, Q;
vector<int> pathes[205000];

void dfs(int now, int from) {
    for(int i = 0; i < pathes[now].size(); i++) {
        int to = pathes[now][i];
        if(to == from) continue;
        dp[to] += dp[now];
        dfs(to, now);
    }
}

int main() {
    //cout.precision(10);
    cin >> N >> Q;
    for(int i = 1; i < N; i++) {
        int a, b;
        cin >> a >> b;
        pathes[a].push_back(b);
        pathes[b].push_back(a);
    }
    while(Q--) {
        int p, x;
        cin >> p >> x;
        dp[p] += x;
    }
    dfs(1, -1);
    for(int i = 1; i <= N; i++) cout << dp[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 26752
import java.util.*;
import java.math.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
 
            String s = sc.next();
            String t = sc.next();

            if(s.equals(t.substring(0, s.length()))){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
 
        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

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

using namespace std;

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

int main ( void )
{
  int a, b;

  cin >> a >> b;

  cout << gcd(a, b) << endl;

  return 0;
}

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

using namespace std;

using Weight=long long;

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

auto operator < (const Edge &e,const Edge &f){
    if(e.weight!=f.weight)return e.weight>f.weight;
    else if(e.src!=f.src)return e.src<f.src;
    else return e.dst<f.dst;
}

using Edges=vector<Edge>;
using Graph=vector<Edges>;

template<typename T>
struct UnionFind{
    vector<T>data;
    UnionFind(T n):data(n,-1){}
    bool unite(T x,T y){
        x=root(x);y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return x!=y;
    }
    T root(T x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    bool same(T x,T y){
        return root(x)==root(y);
    }
    T size(T x){
        return -data[root(x)];
    }
};

pair<Weight,Edges>kruskal(const Graph &g){
    int n=g.size();
    UnionFind<int> uf(n);
    priority_queue<Edge>q;
    for(int i=0;i<n;++i){
        for(auto e:g[i]){
            if(i<e.dst)q.push(e);
        }
    }
    Weight total=0;
    Edges forest;
    while(forest.size()<n-1 && !q.empty()){
        Edge e=q.top();q.pop();
        if(uf.unite(e.src,e.dst)){
            forest.push_back(e);
            total+=e.weight;
        }
    }
    return {total,forest};
}

int main(){
    int v,e;cin>>v>>e;
    Graph g(v);
    for(int i=0;i<e;++i){
        int s,t,w;cin>>s>>t>>w;
        g[s].emplace_back(s,t,w);
        g[t].emplace_back(t,s,w);
    }
    cout<<kruskal(g).first<<endl;
    return 0;
}
// be checked by AOJ(GRL-2-A).

Measured memory_bytes: 10344
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>


using namespace std;

int main()
{
	int n;

	cin >> n;

	vector<long long> x(n + 1);
	
	for (int i = 1;i <= n;i++) {
		for (int j = i;j <= n;j += i) {
			x[j]++;
		}
	}
	long long ans = 0;
	for (int i = 1;i <= n;i++) {
		ans += x[i] * (long long)i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 81400
s = input()

while s:
    if s[:6] == "eraser":
        s = s[6:]
    elif s[:5] == "erase":
        s = s[5:]
    elif s[:5] == "dream":
        if s[5:8] == "era":
            s = s[5:]
        elif s[5:7] == "er":
            s = s[7:]
        else:
            s = s[5:]
    else:
        print("NO")
        exit()
print("YES")


Measured memory_bytes: 3188
abc = input()
abc_lis_str = abc.split()
abc_lis_int = [int(i) for i in abc_lis_str]
abc_lis = sorted(abc_lis_int, reverse=True)
a = abc_lis[0]
b = abc_lis[1]
c = abc_lis[2]

print( a * 10 + b + c )

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll n,a,x=0LL,y=0LL,c;
	cin >> n;
	map<ll, ll>mp;
	rep(i, n) {
		cin >> a;
		mp[a]++;
	}
	for (auto itr =--mp.end(); itr != --mp.begin(); itr--) {
		c = (*itr).second;
		if (c >= 4) {
			y = (*itr).first;
			if(x == 0)x = y;
			break;
		}
		if (c >= 2) {
			if (x == 0) x = (*itr).first;
			else if (y == 0) {y = (*itr).first; break; }
		}
	}
	cout << x * y << endl;
	return 0;
}

Measured memory_bytes: 9828
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

void solve(){
	int k,s;
	cin>>k>>s;
	int ans = 0;
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			int p = s-i-j;
			if(0<=p && p<=k){
				// cout<<i<<" "<<j<<
				ans += 1;
			}
		}
	}
	cout<<ans<<endl;
}

int main(){
	fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = a + b;
		int d = Integer.parseInt(c);
		double e = Math.sqrt(d);

		int f = (int) e;
		if ((e - f) == 0) {
			System.out.println("Yes");

		} else {
			System.out.println("No");

		}

	}
}


Measured memory_bytes: 23124
date0=input().rstrip().split(" ")
N=int(date0[0])
K=int(date0[1])
list0=[]
for i in range(N):
    list0.append(0)
for j in range(K):
    d=int(input())
    date=input().rstrip().split(" ")
    k=0
    for k in range(d):
        list0[int(date[k])-1]=1
print(list0.count(0))

Measured memory_bytes: 9160
/*
    author: Salam_35
    Created at :

*/

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() int testsalam;cin >> testsalam;while(testsalam--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
#define endl '\n'
//void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}
string inttostr(ll n){std::stringstream ss;ss << n;string out=ss.str();return out;}
ll stringtoint(string s){istringstream iss (s);ll n;iss >> n;return n;}
typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

double calcAngle(double h, double m)  
{  
     double angle = abs(60.00*h-11.00*m)/2.00;
     return angle;
}

int main()
{
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double angle=calcAngle(h,m);
    //cout<<angle<<endl;
    angle=(pi*angle)/180.00;
   	double c=sqrt(a*a+b*b-2*a*b*cos(angle));
   	
   	cout<<setprecision(15)<<fixed<<c<<endl;
}


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

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans = 0;
  ans = max(max(a*c, a*d), max(b*c, b*d));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
n,k=[int(x) for x in input().rstrip().split()]
ans=0
for i in range(1,n+1):
  now=i
  cnt=0
  while(True):
    if k<=now:
      break
    cnt+=1
    now=now*2
  # print(now)
  ans+=(1/n)*(1/2)**cnt
print(ans)



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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

static const ll INF = 1e15;
const ll mod = 1e9 + 7;

ll n;
string s;
unordered_map<char, int> ms;

void solve() {
	ll sum = 0;
	rep(k, n) {
		char ck = s[k];
		rep(j, k) {
			char cj = s[j];
			rep(i, j) {				
				char ci = s[i];
				if (ck != cj && cj != ci && ci != ck) {
					if (k - j != j - i) {
						sum++;
					}
				}
			}
		}
	}
	cout << sum;
}

int main(void)
{
	cin >> n;
	cin >> s;
	int ns[3] = { 0,0,0 };
	ms['R'] = 0;
	ms['G'] = 1;
	ms['B'] = 2;
	vector<ll> sub(n, 0);
	rep(i, n) {
		for (int j = 0; j < i-1; j++) {
			int ij = i + j;
			if (ij % 2 == 0) {
				int k = ij / 2;
				char ck = s[k];
				char cj = s[j];
				char ci = s[i];
				if (ck != cj && cj != ci && ci != ck) {
					sub[k]++;
				}
			}
		}
	}
	vector<vector<ll>> left(n + 2, vector<ll>(3, 0));
	vector<vector<ll>> right(n + 2, vector<ll>(3, 0));
	rep(i, n) {
		char c = s[i];
		rep(j, 3) {
			left[i + 1][j] = left[i][j];
		}
		left[i + 1][ms[c]]++;
	}
	rep(i, n) {
		char c = s[n-1-i];
		rep(j, 3) {
			right[n - i ][j] = right[n-i+1][j];
		}
		right[n-i][ms[c]]++;
	}

	ll sum = 0;
	rep(i, n) {
		char c = s[i];
		if (c == 'R') {
			sum += left[i + 1][1] * right[i + 1][2];
			sum += left[i + 1][2] * right[i + 1][1];
			sum -= sub[i];
		}
		else if (c == 'G') {
			sum += left[i + 1][0] * right[i + 1][2];
			sum += left[i + 1][2] * right[i + 1][0];
			sum -= sub[i];
		}
		else {
			sum += left[i + 1][0] * right[i + 1][1];
			sum += left[i + 1][1] * right[i + 1][0];
			sum -= sub[i];
		}
	}
	cout << sum << endl;
	return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;

bool Isprime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {

    // greenbin 解答中
    
   int n;
   cin>>n;
   vector<string> vec(n);

   for(int i=0;i<n;i++){
       string s;

       cin>>s;

       sort(s.begin(),s.end());
       vec[i]=s;

   }

   sort(vec.begin(),vec.end());
  
  bool x=false;

  Vec conti(0,0);    //　連続した回数の配列

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

   if(vec[i]==vec[i+1]){
     
       if(x){
         conti.back()++;
     }
       else{
         conti.emplace_back(1);

         x=true;
     }
     
   }

   else{
        x=false;
     }
  }

  ll ans=0;

  for(int i=0;i<conti.size();i++){

    if(conti[i]%2==0){

      ll p=conti[i]/2;

         p*=conti[i]+1;

         ans+=p;
    }

    else{

       ll p=(conti[i]+1)/2;

         p*=conti[i];

         ans+=p;
    }

    }

  cout<<ans<<endl;

}
 


Measured memory_bytes: 6612
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1;
    int dy = y1 - y2;
    printf("%d %d %d %d\n", x2 + dy, y2 + dx, x1 + dy, y1 + dx);
}

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

using namespace std;


vector<int> get_distance(vector<vector<int>> to, int u) {
    int N = (int) to.size();
    vector<int> dist_from_u(N, 2 * N);
    queue<pair<int, int>> que;
    que.push(make_pair(u, 0));
    while (!que.empty()) {
        auto node = que.front();
        int d = node.second;
        que.pop();
        // cout << que.size() << " (" << node.first << ", " << node.second << "): " << dist_from_u[node.first] << endl;
        // already visited
        if (dist_from_u[node.first] != (2 * N)) {
            continue;
        }
        d = min(dist_from_u[node.first], d);
        dist_from_u[node.first] = d;

        // next points
        d++;        
        for (int target: to[node.first]) {
            que.push(make_pair(target, d));
        }
    }
    return dist_from_u;

}

int main(int argc, char const *argv[])
{
    int N, u, v;
    cin >> N >> u >> v;
    u--; v--;
    vector<int> A(N - 1), B(N - 1);
    vector<vector<int>> to(N);
    for (int i = 0; i < (N - 1); i++) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        to[A[i]].push_back(B[i]);
        to[B[i]].push_back(A[i]);
    }
    vector<int> dist_from_v = get_distance(to, v);
    vector<int> dist_from_u = get_distance(to, u);

    // furthest point from v (that u can go)
    int point;
    int d = -1;
    for (int i = 0; i < N; i++) {
        if (dist_from_u[i] < dist_from_v[i]) {
            if (d < dist_from_v[i]) {
                point = i;
                d = dist_from_v[i] - 1;
            }
        }
    }
    cout << d << endl;
    return 0;
}


Measured memory_bytes: 13096
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

class UnionFind():
    def __init__(self, N):
        self._parent = [n for n in range(0, N)]
        self._size = [1] * N

    def find_root(self, x):
        if self._parent[x] == x: return x
        self._parent[x] = self.find_root(self._parent[x])
        return self._parent[x]

    def unite(self, x, y):
        gx = self.find_root(x)
        gy = self.find_root(y)
        if gx == gy: return

        if self._size[gx] < self._size[gy]:
            self._parent[gx] = gy
            self._size[gy] += self._size[gx]
        else:
            self._parent[gy] = gx
            self._size[gx] += self._size[gy]

    def get_size(self, x):
        return self._size[self.find_root(x)]

    def is_same_group(self, x, y):
        return self.find_root(x) == self.find_root(y)

    def calc_group_num(self):
        N = len(self._parent)
        ans = 0
        for i in range(N):
            if self.find_root(i) == i:
                ans += 1
        return ans



INF=10**20
def main():
    N,M=mi()
    P = []
    for p in mi():
        P.append(p-1)

    uni = UnionFind(N)
    for i in range(M):
        x,y = mi()
        uni.unite(x-1,y-1)
    
    ans = 0

    for i in range(N):
        if uni.find_root(i) == uni.find_root(P[i]):
            ans += 1

    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 91380
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = sc.ReadInt()
	}

	ReverseInts(a)
	ans := 0
	for i := 0; i < n/2; i++ {
		ans += a[i]
	}
	ans *= 2
	ans -= a[0]
	if n%2 == 1 {
		ans += a[n/2]
	}

	fmt.Println(ans)
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 5932
#include <iostream>
#include <cstring>
#include <climits>
using namespace std;

int main(){
  string kupc = "KUPC";
  string s;

  while(cin >> s){
    int cnt[128];
    memset(cnt, 0, sizeof(cnt));

    for(int i = 0; i < s.size(); i++){
      cnt[s[i]]++;
    }
    int mn = INT_MAX;
    for(int i = 0; i < 4; i++){
      mn = min(mn, cnt[kupc[i]]);
    }
    cout << mn << endl;
  }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
typedef pair<int64_t, int64_t> P;

int main(){
    int N;
    cin >> N;
    vector<int> dp(N + 100, INF);
    dp.at(0) = 0;
    rep(n, 1, N + 1){
        for(int pow6 = 1; pow6 <= n; pow6 *= 6){
            dp.at(n) = min(dp.at(n), dp.at(n - pow6) + 1);
        }
        for(int pow9 = 1; pow9 <= n; pow9 *= 9){
            dp.at(n) = min(dp.at(n), dp.at(n - pow9) + 1);
        }
    }
    cout << dp.at(N) << endl;
}

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

int main(){
  int w, a, b;
  cin >> w >> a >> b;
  int a_max = a + w, b_max = b + w;
  
  if(b_max < a)
    cout << a - b_max << endl;

  else if(a <= b_max && b_max <= a_max)
    cout << 0 << endl;
  
  else if(a <= b && b <= a_max)
    cout << 0 << endl;
  
  else
    cout << b - a_max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  string s ;
  cin >> s ;
  if(s.at(0)=='9' || s.at(1)=='9'){
    cout <<"Yes"<<endl ;
  }
  else {
    cout <<"No"<<endl ;
  }
  
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        int digitSum(long n) {
            int res = 0;
            while (n > 0) {
                res += n % 10;
                n /= 10;
            }
            return res;
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long p10 = 1;
            long res = digitSum(n);
            while (p10 <= n) {
                long m = n / p10 * p10 - 1;
                res = Math.max(res, digitSum(m));
                p10 *= 10;
            }
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



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

using namespace std;

typedef long long int64;

int main()
{
  int64 X;
  cin >> X;
  // 11x = X なので
  //   x = X/11
  int64 get = X / 11;

  X -= get * 11;
  get *= 2;
  if(X > 0) {
    ++get;
    X -= 6;
  }
  if(X > 0) {
    ++get;
    X -= 5;
  }

  cout << get << endl;

}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>

typedef long long ll;

int max(int a,int b){
    if(a>b) return a;
    else return b;
}

int min(int a,int b){
    if(a<b) return a;
    else return b;
}

/*qsort(array,num_of_index,sizeof(int),compare_int); */
 int compare_int(const void *a,const void *b){
     return *(int*) a - *(int *) b; 
 } 
 
int main(){
    int N;
    scanf("%d",&N);
    int Di[102],Dj[102];
    int f[102];
    for(int i=1;i<=N;i++){
        scanf("%d %d",Di+i,Dj+i);
        if(Di[i] == Dj[i])
            f[i] = 1;
        else
            f[i] = 0;
    }
    int len = 0,ans = 0;
    for(int i=1;i<=N;i++){
        if(f[i])
            len++;
        else
            len = 0;
        if(len >= 3)
            ans = 1;
    }
    if(ans)
        printf("Yes");
    else
        printf("No");
}


Measured memory_bytes: 1732
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
 
int main()
{
  int A,B;
  int i;
  int number;
  char s[10];
  int cnt=0;

//    int k=0;
  scanf("%d", &A);
  scanf("%d", &B);
    
    for(i=0;i<=B-A;i++){
     sprintf(s,"%d",A+i);
     //printf("%c%c%c%c\n",s[0],s[1],s[3],s[4]);
//     if(s[0]==s[4] && s[1]==s[3]);
       if((strncmp(&s[0],&s[4],1)==0) &&(strncmp(&s[1],&s[3],1)==0)){
         cnt++;
     // printf("%c%c%c%c%c\n",s[0],s[1],s[2],s[3],s[4]);
       }
    }
   printf("%d\n",cnt);
//     printf("%c%c%c\n",s[0][0],s[1][1],s[2][2]);

return 0;
}


Measured memory_bytes: 128
# this par & rank are initialized lists
def find(x):
    global par
    if par[x]<0:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
        
def unite(x,y):
    x,y=find(x),find(y)
    global par
    if x==y:return False
    else:
        if par[x]>par[y]:x,y=y,x
        par[x]+=par[y]
        par[y]=x
        return True

def size(x):
    return -par[find(x)]
def same(x,y):
    return find(x)==find(y)

n,m=map(int,input().split())
par=[-1]*n
for i in range(m):
  x,y,z=map(int,input().split())
  x-=1
  y-=1
  unite(x,y)

root=[]
for i in range(n):
  root.append(find(i))
r=set(root)
print(len(r))

Measured memory_bytes: 13992
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const long long MOD_NUM = 1000000007LL;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static void D_task();

int main()
{
	D_task();
	fflush(stdout);
	return 0;
}

static void D_task()
{
	int N;
	get1int(N);

	auto num = new char[N + 1];
	num[N] = 0;
	getstring(num);

	int ans = 0;
	for (int i = 0; i < 1000; i++) {
		char tmp[4];
		sprintf(tmp, "%03d", i);

		int ch = 0, now = 0;
		while((ch < 3) && (now < N)){
			if (tmp[ch] == num[now]) {
				ch++;
			}
			now++;
		}
		if (ch == 3) ans++;
	}

	printf("%d\n", ans);
	delete[] num;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

bool judge(std::string const& S,
           std::string const& T) {
  if (S == T) return true;

  std::map<char, char> dict;

  for (size_t i=0; i<S.length(); i++) {
    if (dict.count(S[i]) > 0) {
      if (dict[S[i]] != T[i]) return false;
    } else {
      dict.insert(std::make_pair(S[i], T[i]));
    }
  }

  return true;
}

int main() {
  std::string S, T;

  std::cin >> S >> T;

  std::cout << (judge(S, T) && judge(T, S) ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define  mod 1000000007
using namespace std;
int main(int argc, char const *argv[])
{
	int n; cin>>n;
	string s1,s2;
	cin>>s1>>s2;
	long long answer = 1;
	for (int i = 0; i < n; ++i)
	{
		if(s1[i] == s2[i])
		{
			if(i == 0)
				answer *= 3;
			else if(s1[i - 1] == s2[i-1])
				answer *= 2;
			else
				answer = answer;
		}
		else
		{
			if(i == 0)
				answer *= 6;
			else if(s1[i-1] == s2[i-1])
				answer *= 2;
			else
				answer *= 3;
			i++;
		}
		answer = answer % mod;
	}
	cout<<answer<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define DEBUG_VARIABLE(variable) cout << #variable << ":" << variable << endl

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
#define INF (1 << 9)
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

void printArray(int *array, int);
void printVector(Vector &v);
void printDimention(DVector &dv);

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    int c[n], s[n], f[n];
    rep(i, n - 1){
        cin >> c[i] >> s[i] >> f[i];
    }
    c[n - 1] = 0;
    s[n - 1] = 0;
    f[n - 1] = 1;
    int t[n];
    rep(i, n)   t[i] = 0;
    
    rep(i, n){  //start駅
        FOR(j, i, n){  //今いる駅
            if(t[i] < s[j]) t[i] = s[j];
            while(t[i] % f[j])  t[i]++;
            t[i] += c[j];
        }
        cout << t[i] << endl;
    }
}

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

//Vectorの表示
void printVector(Vector &v){
    rep(i, (int)v.size()){
        if(i)   cout << " ";
        cout << v[i];
    }
    cout << endl;
}

//二次元配列の表示
void printDimention(DVector &dv){
    rep(i, (int)dv.size()){
        rep(j, (int)dv[i].size()){
            if(j)   cout << " ";
            cout << dv[i][j];
        }
        cout << endl;
    }
}

//numの中に何個2がかかってるか
int factor2(int num){
    int cnt = 0;
    while(num % 2 == 0){
        num /= 2;
        cnt++;
    }
    return cnt;
}

Measured memory_bytes: 256
# coding: utf-8
s = input()
forward = int(s[0:2])
back = int(s[2:4])
mmyy = False
yymm = False

if 1 <= forward <= 12:
    mmyy = True
if 1 <= back <= 12:
    yymm = True

if mmyy and yymm:
    print('AMBIGUOUS')
elif mmyy:
    print('MMYY')
elif yymm:
    print('YYMM')
else:
    print('NA')


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n;
    ll ans=1e18;
    cin>>n;
    vector<ll> a(n),imos(n+1),left(n+1),right(n+1);
    imos[0]=0;
    
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
        imos[i+1]=imos[i]+a[i];
    }
    
    for(int i = 0; i < n+1; i++)
    {
        left[i]=1e18;
        right[i]=1e18;
    }
    
    int l=0;
    for(int mid = 2; mid < n-1; mid++)
    {
        left[mid]=l;
        while(l-1<mid)
        {
            if(abs(imos[mid]-imos[l]*2) > abs(imos[mid]-imos[l+1]*2))
            {
                l++;
                left[mid]=l;
            }
            else break;
        }
    }
    
    int r=n;
    for(int mid = n - 2; mid >= 2; mid--)
    {
        right[mid]=r;
        while(r-1>mid)
        {
            //([n]-[r])-([r]-[mid])=[n]+[mid]-2*[r]
            if(abs(imos[n]+imos[mid]-imos[r]*2) > abs(imos[n]+imos[mid]-imos[r-1]*2))
            {
                r--;
                right[mid]=r;
            }
            else break;
        }
    }
    
    for(int mid = 2; mid < n-1; mid++)
    {
        ll w=imos[left[mid]];
        ll x=imos[mid] - imos[left[mid]];
        ll y=imos[right[mid]] - imos[mid];
        ll z=imos[n] - imos[right[mid]];
        ll mi = min(min(w,x),min(y,z));
        ll ma = max(max(w,x),max(y,z));
        ll tmp = ma-mi;
        ans=min(ans,tmp);
    }
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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; }
typedef pair<int,int> P;

int main(){
  int n,m;
  cin >> n >> m;
  priority_queue<P> q;
  rep(i,n){
    int a;
    cin >> a;
    q.push(make_pair(a,1));
  }
  rep(i,m){
    int b,c;
    cin >> b >> c;
    q.push(make_pair(c,b));
  }
  ll ans = 0;
  rep(i,n){
    auto p = q.top();
    q.pop();
    ans += p.first;
    if(p.second != 1){
      p.second--;
      q.push(p);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		if (s.length() >= 4) {
			if (s.substring(0,4).equals("YAKI")) {
				System.out.print("Yes");
			} else {
				System.out.print("No");
			}
		} else {
			System.out.print("No");
		}
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <set>
#include <algorithm>

using namespace std;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)

int n,m;
pii ranges[353531];   // sort by first, [left, right]
pii ranges2[353531];  // sort by second, [right, id]

int ans[125252];

const int B = 400;
const int C = 300;

// pointer struct
struct data{
  // id, position, in-iterator, out-iterator
  int id,pos,in,out;
};
data pts[C];
int cnt[353531];

int main(){
  // input
  scanf("%d%d",&n,&m);
  REP(i,n){
    int l,r;
    scanf("%d%d",&l,&r);
    ranges[i] = pii(l,r);
  }
  
  // d small
  FOR(d,1,min(B,m+1)){
    int tmp = 0;
    REP(i,n){
      int x = (ranges[i].first+d-1)/d;
      if(x*d<=ranges[i].second)tmp++;
    }
    ans[d]=tmp;
  }

  // d large
  // sort
  sort(ranges,ranges+n);
  REP(i,n)ranges2[i]=pii(ranges[i].second, i);
  sort(ranges2,ranges2+n);

  // pointer init
  data yo;
  yo.id=0; yo.pos=0; yo.in=0; yo.out=0;
  set<int> S;
  int tmp = 0;
  FOR(i,1,m+1){
    yo.pos++;
    while(yo.in<n && ranges[yo.in].first==yo.pos){
      S.insert(yo.in);
      yo.in++;
    }
    while(yo.out<n && ranges2[yo.out].first<yo.pos){
      S.erase(S.find(ranges2[yo.out].second));
      yo.out++;
    }
    if(i%B==0){
      // pts
      pts[yo.id] = yo;
      yo.id++;
      for(int x : S){
        if(cnt[x]==0)tmp++;
        cnt[x]++;
      }
    }
  }

  int pts_len = yo.id;
  FOR(d,min(B,m+1),m+1){
    ans[d] = tmp;
    if(d==m)break;
    REP(i,pts_len){
      if(pts[i].pos > m)break;
      // step pts[i]
      pts[i].pos += i+1;
      while(pts[i].in<n && ranges[pts[i].in].first<=pts[i].pos){
        if(cnt[pts[i].in]==0)tmp++;
        cnt[pts[i].in]++;
        pts[i].in++;
      }
      while(pts[i].out<n && ranges2[pts[i].out].first<pts[i].pos){
        int id = ranges2[pts[i].out].second;
        cnt[id]--;
        if(cnt[id]==0)tmp--;
        pts[i].out++;
      }
    }
  }
  FOR(d,1,m+1)printf("%d\n",ans[d]);
  return 0;
}


Measured memory_bytes: 21248
#include<stdio.h>
#include<stdlib.h>
#define MAX 8
int first[MAX];
int rowStat[MAX];//the column value of queen in this row 
int colStat[MAX];//can be put: 0
int dPosStat[2*MAX-1];
int dNegStat[2*MAX-1];
void init(void);
void putQueen(int);
int setQueen(int,int,int);
void removeQueen(void);
void printBoard(void);
int main(void)
{
  int i;//counter
  int firstNum;
  int row,col;
  init();
  scanf("%d",&firstNum);
  for(i=0;i<firstNum;i++)
    {
      scanf("%d%d",&row,&col);
      rowStat[row]=col;
      colStat[col]=dPosStat[row+col]=dNegStat[col-row+MAX-1]=1;
      first[row]=1;
    }
  putQueen(0);
  return 0;
}
void init(void)
{
  int i,j;//counter
  for(i=0;i<MAX;i++)
    {
      first[i]=0;
      rowStat[i]=-1;
      colStat[i]=0;
    }
  for(i=0;i<2*MAX+1;i++) dPosStat[i]=dNegStat[i]=0;
}
void putQueen(int i)
{
  int j;//counter
  //printf("putQueen(%d)\n",i);
  if(i==MAX)
    {
      printBoard();
      return;
    }
  if(first[i]==0)
    {
      for(j=0;j<MAX;j++)
	{
	  if(colStat[j]==0&&dPosStat[i+j]==0&&dNegStat[j-i+MAX-1]==0)
	    {
	      rowStat[i]=j;
	      colStat[j]=dPosStat[i+j]=dNegStat[j-i+MAX-1]=1;
	      //printf("put(%d,%d)\n",i,j);
	      putQueen(i+1);
	      //printf("remove(%d,%d)\n",i,j);
	      colStat[j]=dPosStat[i+j]=dNegStat[j-i+MAX-1]=0;
	    }
	}
    }
  else putQueen(i+1);
}
void printBoard(void)
{
  int i,j;//counter
  for(i=0;i<MAX;i++)
    {
      for(j=0;j<MAX;j++)
	{
	  if(rowStat[i]==j) printf("Q");
	  else printf(".");
	}
      printf("\n");
    }
}



Measured memory_bytes: 2112