akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define print(v,r) f(i,0,r) cout<<v[i]<<" "; cout<<endl;
#define Get(x,y) scanf("%I64d%I64d",&x,&y);
#define is_bit(x,y) (x%(1<<(y+1))>=(1<<y))
#define eror(x) cout<<#x<<'='<<(x)<<endl;
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define Gett(x,y) scanf("%d%d",&x,&y);
#define f(i,a,b) for(int i=a;i<b;i++)
#define get(x) scanf("%I64d",&x);
#define All(x) x.begin(),x.end()
#define Add(x,y) x=(x+y)%mod;
#define gett(x) scanf("%d",&x);
#define maxm(a,b) a=max(a,b);
#define minm(a,b) a=min(a,b);
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first

const int N=2002,mod=924844033;

int n,k,res,fac[N],dp[N][N][4],ans[N],pd[N];

void calc(int x){
	f(i,0,N) f(j,0,N) f(mask,0,4) dp[i][j][mask]=pd[i]=0;
	dp[0][0][0]=1;
	f(i,0,x+1)
	    f(j,0,i+1)
	       f(mask,0,4){
	           Add(dp[i+1][j][mask/2],dp[i][j][mask]);
	           if(mask%2==0 && i)
	               Add(dp[i+1][j+1][mask/2],dp[i][j][mask]);
	           Add(dp[i+1][j+1][mask/2+2],dp[i][j][mask]);
            }
    f(i,0,x+1){
    	f(mask,0,2)
    		Add(pd[i],dp[x][i][mask]);
    }
}
void add(int x){
	ans[0]=1;
	f_(i,n,0)
		f(j,1,min(i,x)+1)
			Add(ans[i],1ll*ans[i-j]*pd[j]%mod);
}
void solve(){
	fac[0]=1;
	f(i,1,N) fac[i]=1ll*fac[i-1]*i%mod;
	f(i,0,n+1){
		if(i&1) Add(res,mod-1ll*ans[i]*fac[n-i]%mod)
		else Add(res,1ll*ans[i]*fac[n-i]%mod);
	}
	cout<<res;
}

int main(){
	cin>>n>>k;
	calc((n+k-1)/k);
	f(i,0,n%k) 
	    add((n+k-1)/k);
	calc(n/k);
	f(i,0,k-(n%k))
	    add(n/k);
	solve();
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

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

const int MAX = 1e5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int N;

int main(){
    cin >> N;

    N--;
    ll ans = (ll)(N + 1) * (N / 2);
    if (N % 2) ans += (N + 1) / 2;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n, m;
vector<vector<int> > a;
int MIN = 114514;

void calc(vector<vector<bool> > f){
    vector<int> cnt(m, 0);
    rep(i, 0, n){
        rep(j, 0, m){
            if(f[i][j] == true){
                cnt[a[i][j]]++;
                break;
            }
        }
    }
    if(*max_element(all(cnt)) == 0) return;
    int id = max_element(all(cnt)) - cnt.begin();
    chmin(MIN, *max_element(all(cnt)));
    // cout << id << " " << *max_element(all(cnt)) << endl;
    rep(i, 0, n){
        rep(j, 0, m){
            if(a[i][j] == id) f[i][j] = false;
        }
    }
    
    calc(f);
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    a.resize(n, vector<int>(m));
    rep(i, 0, n){
        rep(j, 0, m){
            cin >> a[i][j]; a[i][j]--;
        }
    }
    vector<vector<bool> > f(n, vector<bool>(m, true));
    calc(f);
    cout << MIN << endl;
}

Measured memory_bytes: 9472
#include<stdio.h>

int main()
{
	int i,j,k,l,n,m,a,b,c,d,min,max;
	while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF)
	{
		if(b<=d)
		min=b;
		else
		min=d;
		if(a<=c)
		max=c;
		else
		max=a;
		if(max>min)
		printf("0\n");
		else
		printf("%d\n",min-max);
	}
	return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (1) {
    c -= b;
    if (c <= 0) break;
    a -= d;
    if (a <= 0) break;
  }
  cout << ((a <= 0) ? "No" : "Yes") << endl;
}


Measured memory_bytes: 3592
#include <stdio.h>
 
int main(){
        int i,start[3],end[3],t[6];
 
        for( i = 0; i < 3; i++){
                scanf("%d %d %d %d %d %d",&t[0],&t[1],&t[2],&t[3],&t[4],&t[5]);
                start[i] = t[0] * 3600 + t[1] * 60 + t[2];
                end[i] = t[3] * 3600 + t[4] * 60 + t[5];
 
                t[0] = end[i] - start[i];
                t[1] = t[0] / 3600;
                t[0] -= t[1] * 3600;
                t[2] = t[0] / 60;
                t[0] -= t[2] * 60;
                printf("%d %d %d\n", t[1], t[2], t[0]);
        }
 
        return 0;
}

Measured memory_bytes: 0
// author <Maksud alam Rony>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define it iterator
#define pb push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define fill(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
#define pi acos(-1)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) (v).erase(unique(all(v)),(v).end())
#define endl "\n"
string digit="0123456789";
string small="abcdefghijklmnopqrstuvwxyz";
string capital="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

int main(){
   ll n;
   cin>>n;
   string s = "";
   while(n>0){
      n--;
      s = char('a'+ n%26)+s;
      n/=26;
   }
   cout<<s<<endl;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)


int main(){
	int N,K,C; string S;
	cin>>N>>K>>C>>S;

	// if(K==1 && C==0) return 0;
	// if(C==0) return 0;

	vi L,R;
	int c;

	c = 0;
	rp(i, 0, N){
		if(c-- > 0) continue;
		c = max(0, c);//[0,C-1]
		if(S[i] == 'o'){
			L.push_back(i);
			c = C;
		}
	}

	c = 0;
	irp(i, N-1, 0-1){
		if(c-- > 0) continue;
		c = max(0, c);//[0,C-1]
		if(S[i] == 'o'){
			R.push_back(i);
			c = C;
		}
	}

	reverse(all(R));

	// cout<<N<<" "<<K<<" "<<C<<" "<<S<<"\n";//
	// cout<<"L ";//
	// rp(i,0,L.size())cout<<L[i]<<" ";puts("");//
	// cout<<"R ";//
	// rp(i,0,R.size())cout<<R[i]<<" ";puts("");//
	// puts("----");//

	if(L.size() > K) return 0;

	vi ans;
	rp(i, 0, L.size()){
		if(L[i] == R[i]){
			ans.push_back(L[i]);
		}
	}

	// if(ans.size() == N) return 0;

	rp(i, 0, ans.size()){
		cout<<ans[i]+1<<endl;
	}
}


Measured memory_bytes: 4216
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n = 0;
    cin >> n;
    vector<int> arr(n, 0);
    for(int& val: arr)
        cin >> val;
    unordered_map<int, int> cnt = {{-1, 3}};
    ll ans = 1, mod = 1e9 + 7;
    for(int cur: arr) {
        ans *= cnt[cur-1];
        ans %= mod;
        cnt[cur] += 1;
        if (--cnt[cur-1] == 0)
            cnt.erase(cur-1);
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 4132
$<.gets.to_i.times do
	point = 0
	out = 0
	runner = 0

	$<.each_line do |line|
		case line.chomp
		when 'HIT'
			runner = (runner << 1) + 1
			if runner[3] == 1
				runner &= 7
				point += 1
			end
		when 'OUT'
			out += 1
			break if out == 3
		when 'HOMERUN'
			point += 3.times.map{|i| runner[i]}.inject(&:+) + 1
			runner = 0
		end
	end

	p point
end

Measured memory_bytes: 6104
// include headers{{{
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*}}}*/
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;



int main() {
    int a, b, k; cin >> a >> b >> k;
    int min_val = min(a, b);
    int ans = 0;

    rep (i, min_val) {
        if (a % (min_val - i) != 0) continue;
        if (b % (min_val - i) != 0) continue;
        k--;
        ans = min_val-i;
        if (k==0) break;
    }

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



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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
	ll a, b, c;
	cin >> a >> b >> c;
	ll cnt = 0;
	while(true) {
		//cout << a << " " << b << " " << c << endl;
		if(a%2 || b%2 || c%2) break;
		ll ta = a/2, tb = b/2, tc = c/2;
		//cout << ta << ":" << tb << ":" << tc << endl;
		a = tb+tc;
		b = tc+ta;
		c = ta+tb;
		cnt++;
		//cout << a << " " << b << " " << c << endl;
		if(cnt>=10000000) break;
	}
	if(cnt >= 10000000) cout << -1 << endl;
	else cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;


int main(){
    int t=1;
    //cin>>t;
    while(t--){
        ll n;
        cin>>n;
        string s;
        map<string,int> a;
        for(ll i=0;i<n;i++){
            cin>>s;
            a[s]++;
        }
        ll count=0;
        for(auto j: a){
            count++;
        }
        cout<<count;
    }
    return 0;
}
    

Measured memory_bytes: 19232
def main():
    N = int(input())
    X, Y = {}, {}
    for _ in range(N):
        x, y = map(int, input().split())
        if x not in X:
            X[x] = set()
        X[x].add(y)
        if y not in Y:
            Y[y] = set()
        Y[y].add(x)
    r = 0
    while X:
        x, ys = X.popitem()
        tx = set([x])
        ty = set(ys)
        mx, my = set(), set(ys)
        while mx or my:
            while my:
                y = my.pop()
                mx |= Y.pop(y, set())
            tx |= mx
            while mx:
                x = mx.pop()
                my |= X.pop(x, set())
            ty |= my
        r += len(tx) * len(ty)
    return r - N

print(main())


Measured memory_bytes: 45800
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;
typedef long long ll;

ll INF = 100000000000;

int main(){
    int N;
    vector<ll> a;
    cin >> N;
    ll total = 0;
    for(int i = 0; i < N; i++){
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
        total += tmp;
    }
    
    ll min_num = INF;
    ll x = 0;
    for(int i = 0; i < N - 1; i++){
        x += a[i];
        ll tmp = abs(2*x - total);
        min_num = min(tmp, min_num);
    }
    cout << min_num << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> a(n); for(int & i : a) cin >> i;
  vector<vector<long long> > f(n, vector<long long>(n, 0));
  for(int i = 0; i < n; i++) 
    if(n&1) f[i][i] = a[i];
  	else f[i][i] = -a[i];
  for(int i = 2; i <= n; i++){
    for(int j = 0; j <= n - i; j++){
      if((n - i)%2 == 0){
        f[j][j+i-1] = max(f[j][j+i-2]+a[j+i-1], a[j]+f[j+1][j+i-1]);
      } else {
        f[j][j+i-1] = min(f[j][j+i-2]-a[j+i-1], -a[j]+f[j+1][j+i-1]);
      }
    }
  }
  cout << f[0][n-1] << endl;
  return 0;
}


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

int main(){
  long int A,B;
  scanf("%ld %ld", &A, &B);
  
  long int K = (A + B)/ 2;
  if(abs(A-K) == abs(B-K)){
    printf("%ld",K);
  }else{
    printf("IMPOSSIBLE");
  }
}

Measured memory_bytes: 128
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

/*考えを書くスペース
  AtCoder Grand Contest 019-A


*/
//main.cpp----------------------------
#define max_n 200000

void solve();

ll x, y;

int main() {
  cin >> x >> y;

  solve();

  return 0;
}

void solve() {

  if(abs(x)==abs(y)) {
    if((x>=0&&y>=0)||(x<0&&y<0)) {
      cout << 0 << endl;
    }else {
      cout << 1 << endl;
    }
  }else if(x > y) {
    if(x==0||y==0) {
      cout << abs(x-y)+1 << endl;
    }else if((x>0&&y>0)||(x<0&&y<0)) {
      cout << abs(x-y)+2 << endl;
    }else {
      cout << abs(abs(x)-abs(y))+1 << endl;
    }
  }else {
    if(x==0||y==0) {
      cout << abs(x-y) << endl;
    }else if((x>0&&y>0)||(x<0&&y<0)) {
      cout << abs(x-y) << endl;
    }else {
      cout << abs(abs(x)-abs(y))+1 << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vint l(n);
    rep(i, n) cin >> l[i];

    int ans = 5000;
    rep(i, 1 << n)
    {
        int li = 0;

        int cnt = __builtin_popcount(i);
        if (!cnt)
            continue;
        rep(x, n)
        {
            if (!(i & (1 << x)))
                continue;
            li += l[x];
        }

        int cstA = (cnt - 1) * 10 + abs(li - a);

        rep(j, 1 << n)
        {
            if (i & j)
                continue;

            cnt = __builtin_popcount(j);
            if (!cnt)
                continue;
            int lj = 0;
            rep(y, n)
            {
                if (!(j & (1 << y)))
                    continue;
                lj += l[y];
            }
            int cstB = (cnt - 1) * 10 + abs(lj - b);

            rep(k, 1 << n)
            {
                if ((i & k) || (j & k))
                    continue;
                cnt = __builtin_popcount(k);
                if (!cnt)
                    continue;
                int lk = 0;
                rep(z, n)
                {
                    if (!(k & (1 << z)))
                        continue;
                    lk += l[z];
                }
                int cstC = (cnt - 1) * 10 + abs(lk - c);

                ans = min(ans, cstA + cstB + cstC);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
  public static void main (String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    int n = Integer.parseInt(br.readLine());
    int[] s = new int[n];
    String[] tmpS = br.readLine().split(" ");
    for(int i = 0; i < n; i++) {
      s[i] = Integer.parseInt(tmpS[i]);
    }
    tmpS = null;

    int q = Integer.parseInt(br.readLine());
    int[] t = new int[q];
    String[] tmpT = br.readLine().split(" ");
    for (int i = 0; i < q; i++) {
      t[i] = Integer.parseInt(tmpT[i]);
    }
    tmpT = null;

    int count = 0;
    for(int i : t) {
      if (binarySearch(s, i)) {
        count++;
      }
    }
    System.out.println(count);
  }

  private static boolean binarySearch(int[] array, int target) {
    int left = 0;
    int right = array.length;
    while (left < right) {
      int mid = (left + right) / 2;
      int temp = array[mid];
      if (target < temp) {
        right = mid;
        continue;
      }
      if (temp < target) {
        left = mid + 1;
        continue;
      }
      return true;
    }
    return false;
  }
}

Measured memory_bytes: 47460
#include <cstdio>
#include <cstring>
using namespace std;

typedef struct
{
	int parts[3];
	int r;
} LIST;

LIST list[2000];

int main()
{
	int a, b, c;
	int result[600];
	int N;
	
	while (scanf("%d %d %d", &a, &b, &c), a + b + c){
		scanf("%d", &N);
		
		for (int i = 0; i < 600; i++){
			result[i] = 2;
		}
		
		for (int i = 0; i < N; i++){
			for (int j = 0; j < 3; j++){
				scanf("%d", &list[i].parts[j]);
			}
			scanf("%d", &list[i].r);
			
			if (list[i].r == 1){
				for (int j = 0; j < 3; j++){
					result[list[i].parts[j]] = 1;
				}
			}
		}
		
//		for (int j = 0; j < N; j++){
			for (int i = 0; i < N; i++){
				if (list[i].r == 0){
					for (int j = 0; j < 3; j++){
						if (result[list[i].parts[(j + 1) % 3]] == 1 &&
						    result[list[i].parts[(j + 2) % 3]] == 1 &&
							result[list[i].parts[j]] == 2){
							result[list[i].parts[j]] = 0;
						}
					}
				}
			}
//		}
		
		for (int i = 1; i <= a + b + c; i++){
			printf("%d\n", result[i]);
		}
	}
	
	return 0;
}

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

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

  int ans=-0;
  rep(i, N){
    int x;
    cin >> x;
    ans += min(x*2,(K-x)*2);
  }

  cout << ans << endl;
}


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

using namespace std;

int main(){
  

    string s;
    cin >> s;

    string anss; 
    int num = atoi(s.c_str());

    int st = num / 100;
    int fin = num - st*100;


    if(1 <= st && st <= 12&& (12 < fin ||fin == 0)){
        anss = "MMYY";
    }else if( (st > 12 || st == 0) && 1 <=fin&& fin <= 12 ){
        anss = "YYMM";
    }else if(1 <=st && st <= 12 && 1 <= fin && fin <= 12){
        anss = "AMBIGUOUS";
    }else{
        anss = "NA";
    }

    cout << anss << endl;
    return 0;
}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void) {

    int N; cin>>N;
    int A,B; cin>>A>>B;
    int ans=0;
    int sum = 0;
    for (int i = 1; i <= N; ++i) {
        int tmp = i;
        int digitwa = 0;

        while (tmp > 0){
            digitwa += tmp % 10;
            tmp /= 10;
        }
        if(A<=digitwa && digitwa<=B) sum += i;
        
    }
    cout<<sum<<endl;
}


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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/a.in", "r", stdin);
//  freopen("../IO/a.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}


void solve(std::istream &in, std::ostream &out) {
  int n,a,b;
  in >> n >> a >> b;
  if (a + b - 1 > n || (int64_t) a * b < n)
    return void(out << "-1\n");
  for (int block = b, sz; block >= 1; --block) {
    sz = min(n - block + 1, a);
    for (int i = 0; i < sz; ++i) {
      out << n - sz + 1 + i << ' ';
    }
    n -= sz;
  }
}

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

int n, m, a, b, c;
std::vector<int> from[64]; 

void Load() {
  std::cin >> n >> m >> a >> b >> c;
  for(int i = 0; i < m; ++i) {
    int s, t;
    scanf("%d %d", &s, &t);
    s -= 1; t -= 1;
    from[s].push_back(t);
  }
}

bool cango_a[64][64];
bool cango_b[64][64];
bool cango_c[64][64];

void calc1(bool xs[64], int r) {
  if( r == 0 ) return;
  bool next[64] = {};
  for(int i = 0; i < n; ++i) {
    if( xs[i] ) {
      for(int j = 0; j < (int)from[i].size(); ++j) {
        next[from[i][j]] = true;
      }
    }
  }
  for(int i = 0; i < n; ++i) {
    xs[i] = next[i];
  }
  calc1(xs, r - 1);
}

void Init() {
  for(int i = 0; i < n; ++i) {
    cango_a[i][i] = true;
    calc1(cango_a[i], a);
  }
  for(int i = 0; i < n; ++i) {
    cango_b[i][i] = true;
    calc1(cango_b[i], b);
  }
  for(int i = 0; i < n; ++i) {
    cango_c[i][i] = true;
    calc1(cango_c[i], c);
  }
}

int main() {
  Load();
  Init();
  // for(int i = 0; i < n; ++i) {
  //   for(int j = 0; j < n; ++j) {
  //     printf("%d ", cango_a[i][j]);
  //   }
  //   puts("");
  // }
  int dist[64];
  for(int i = 0; i < 64; ++i) dist[i] = (1 << 30);
  dist[n-1] = 0;
  
  for(;;) {
    bool end = true;
    int neari = -1;
    int neardist = (1 << 30);
    for(int i = 0; i < n; ++i) {
      if( dist[i] != (1 << 30) ) continue;
      int A, B, C;
      A = B = C = -1;
      int mm = (1 << 30);
      mm = (1 << 30);
      for(int j = 0; j < n; ++j) {
        if( cango_a[i][j] and dist[j] != (1 << 30) ) {
          if( dist[j] < mm ) {
            mm = dist[j];
            A = j;
          }
        }
      }
      mm = (1 << 30);
      for(int j = 0; j < n; ++j) {
        if( cango_b[i][j] and dist[j] != (1 << 30) ) {
          if( dist[j] < mm ) {
            mm = dist[j];
            B = j;
          }
        }
      }
      mm = (1 << 30);
      for(int j = 0; j < n; ++j) {
        if( cango_c[i][j] and dist[j] != (1 << 30) ) {
          if( dist[j] < mm ) {
            mm = dist[j];
            C = j;
          }
        }
      }
      if( not ( A != -1 and B != -1 and C != -1 ) ) continue;
      int d = std::max(dist[A], std::max(dist[B], dist[C])) + 1;
      if( neardist > d ) {
        neardist = d;
        neari = i;
        end = false;
      }
    }
    if( end ) break;
    dist[neari] = neardist;
  }

  if( dist[0] == (1 << 30) ) {
    printf("IMPOSSIBLE\n");
  }
  else {
    printf("%d\n", dist[0]);
  }
    
  return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int X, A, B;
  cin >> X >> A >> B;
  cout << (X-A)%B << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>

using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rep1(i,n) for(int i=1;i<=(int)n;++i)

int N, K;

int Sum[200010];
map<int, int> counter;

signed main()
{
	cin >> N >> K;

	int ans = 0;

	rep1(i, N) {
		cin >> Sum[i];
		Sum[i] += Sum[i-1];
		Sum[i] %= K;
	}

	rep1(i, N) Sum[i] = (Sum[i] - i + K*1000000000) % K;

	counter[0]++;

	rep1(i, N) {
		if (i - K >= 0) counter[Sum[i - K]]--;
		ans += counter[Sum[i]];
		counter[Sum[i]]++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
 
typedef long long   ll;
typedef long double ld;
const int N  = 5e5+10;
const ll mod = 1e9+7;
const ll inf = 1e18;

#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define ub              upper_bound                 // first element >  val(itr)
#define lb              lower_bound                 // first element >= val(itr) 
#define all(x)          (x).begin(),(x).end()
#define reset(a,x)      memset(a,x,sizeof(a))       // x can be 0 or -1
#define leadzero(a)     __builtin_clz(a)            // count leading zeroes
#define trailzero(a)    __builtin_ctz(a)            // count trailing zeroes
#define bitcount(a)     __builtin_popcount(a)       // count set bits
#define iceil(n,x)      ((n)+(x)-1)/(x)
#define test            int t; cin>>t; while(t--)
#define forn(i,a,e)     for(ll i = a; i < e; i++)
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;    }
ll powm(ll base,ll exp){ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
ll modinv(ll n)    { ll ans=powm(n,mod-2); return ans; }
ll add(ll a,ll b)  { return (a%mod+b%mod)%mod;        }
ll sub(ll a, ll b) { return (a%mod+mod-b%mod)%mod;    }
ll mult(ll a,ll b) { return ((a%mod)*(b%mod))%mod;    }
ll choose2(ll n)   { ll ans=(n*(n-1))/2; return ans;  }
ll dist2(ll x1,ll y1,ll x2,ll y2){ ll ans=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1); return ans;}


int main()
{
	fast
	ll n;
	cin>>n;

	string s;
	map<string,ll>cnt;
	forn(i,0,n)
	{
		cin>>s;
		sort(s.begin(),s.end());
		cnt[s]++;
	}
	ll ans=0;
	for(auto x:cnt)
		ans+=(x.second*(x.second-1))/2;

	cout<<ans;

	return 0;
}

Measured memory_bytes: 11264
#!/usr/bin/env python3
import sys
import string
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(H: int, W: int, S: "List[List[str]]"):
    for i in range(H):
        for j in range(W):
            if S[i][j] == 'snuke':
                print(''.join(map(str, [string.ascii_uppercase[j], i+1])))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [[next(tokens) for _ in range(W)] for _ in range(H)]  # type: "List[List[str]]"
    solve(H, W, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4084
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

typedef pair<int, int> P;

int main() {
    int N;
    cin >> N;
    vector<P> red(N);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        red[i] = P(b, a);
    }
    priority_queue<P, vector<P>, greater<P>> blue;
    for (int i = 0; i < N; i++) {
        int c, d;
        cin >> c >> d;
        blue.push(P(c, d));
    }

    sort(red.begin(), red.end(), greater<P>());
    vector<bool> used(N);
    int res = 0;
    while (!blue.empty()) {
        P p = blue.top(); blue.pop();

        for (int i = 0; i < N; i++) {
            P r = red[i];
            if (r.second < p.first && r.first < p.second && !used[i]) {
                res++;
                used[i] = true;
                break;
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main() {

    int N;
    cin >> N;
    int A[N];
    string out = "DENIED";
    bool denied = false;
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i]%2 == 0){
            if(A[i]%6 == 0 || A[i]%10 == 0);
            else{
                denied =true;
                break;
            }
        }
    }
    if(denied == false) out = "APPROVED";
    cout << out << endl;
    return 0;
}


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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;

lli n;
vll a;

unordered_map<lli,lli> m;
lli ans;

int main(){
  cin >> n;
  a = vll(n);
  for(lli i = 0;i < n;i++) cin >> a[i];
  for(lli i = 0;i < n;i++){
    m[a[i]]++;
  }
  for(auto itr = m.begin();itr != m.end();itr++){
    if(itr->first <= itr->second) ans += itr->second-itr->first;
    else ans += itr->second;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5028
import java.util.*;

public class Main {
	public static void main(String[] args) {  
  		Scanner sc = new Scanner(System.in);
      	int Senbei = sc.nextInt();
      	int people = sc.nextInt();
      	if(Senbei % people == 0) {
        	System.out.println(0);  
        } else {
     		System.out.println(1);
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x,a,b;
    cin >> x >> a >> b;

    cout << (x-a)%b << endl;
}



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

int compare(const void *a,const void *b){
  return *(int*)b-*(int*)a;
}

int main(){
  int n,i,ans=0;
  scanf("%d",&n);
  int num[110];
  for(i=0;i<n;i++)scanf("%d",&num[i]);
  qsort(num,n,sizeof(int),compare);
  for(i=0;i<n;i++){
    if(i==0||i%2==0)ans+=num[i];
    else ans -=num[i];
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int N;
    cin >> N;
    if (N <= 999)
        cout << "ABC" << endl;
    else
        cout << "ABD" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long a,b,c,d,ans;

	cin >> a >> b >> c >> d ;

	ans=max(a*c,a*d);
	ans=max(ans,b*c);
	ans=max(ans,b*d);

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

Measured memory_bytes: 3632
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;




int main(){
    int n,m,p;
    while(cin>>n>>m>>p){
        if(n==0 && m==0 && p==0)break;
        
        int sum=0;
        int data[200]={};
        rep(i,n){
            cin>>data[i];
            sum+=data[i];
        }
        
        double allMoney=sum*100;
        allMoney=allMoney*(100-p)/100;
        
        if(data[m-1]==0)cout<<'0'<<endl;
        else cout<<(int)(allMoney/data[m-1])<<endl;
        
        
    }
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
int main()
{
  int n,m,i,j;
  for(;;){
    scanf("%d",&n);
    if(n==0) break;
    j = 0;
    for(m=5;m<=n;m+=5){
      i = m;
      while(i%5 == 0){
	i /= 5;
	j++;
      }
    }
    printf("%d\n",j);
  }
  return 0;
}

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

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

  int x; cin >> x;

  if(x == 1) {
    cout << '1' << '\n';
    return 0;
  }

  int ans = 0;
  for(int b = 2; b <= x; ++b) {
    int tmp = b;
    while(true) {
      tmp *= b;
      if(tmp > x) break;
      ans = max(ans, tmp);
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const ll INF = LLONG_MAX;

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

vector<pair<ll, int>> factorize(ll n) {
  vector<pair<ll, int>> res;
  for( ll i = 2; i * i <= n; ++i){
    if(n % i) continue;
    res.emplace_back(i, 0);
    while(n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if(n != 1) res.emplace_back(n, 1);
  return res;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  auto primes = factorize(g);
  int ans = primes.size();
  cout << ans + 1 << endl;

}

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

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	int ans;
	for (int i = 1; i <= 3; i++) {
		if (i != A && i != B) ans = i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
int main(){
	cin>>n>>m;
	repn(i,n) rep(j,m){
		string s; cin>>s;
		if(s=="snuke"){
			cout<<(char)('A'+j)<<i<<endl;
			return 0;
		}
	}
}

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

using namespace std;

vector < vector < int > > with(100005);

int main() {
	///ios::sync_with_stdio(false);
	int n, u, v;
	cin>>n>>u>>v;
	for (int i = 1; i < n; i++) {
		int l, r;
		cin>>l>>r;
		with[l].push_back(r);
		with[r].push_back(l);
	}
	vector < int > usedv(n + 1, -1);
	usedv[v] = 0;
	vector < int > qv;
	qv.push_back(v);
	int headv = 0, tailv = 0;
	for (; headv <= tailv; headv++) {
		for (int i = 0; i < with[qv[headv]].size(); i++) {
			if (usedv[with[qv[headv]][i]] > -1) continue;
			qv.push_back(with[qv[headv]][i]);
			usedv[with[qv[headv]][i]] = usedv[qv[headv]] + 1;
			tailv++;
		}
	}
	int res = 0;
	vector < int > usedu(n + 1, -1);
	usedu[u] = 0;
	vector < int > qu;
	qu.push_back(u);
	int headu = 0, tailu = 0;
	//cout<<"pass\n";
	for (; headu <= tailu; headu++) {
		//cout<<"ok\n";
		res = max(res, usedv[qu[headu]]);
		if (usedu[qu[headu]] >= usedv[qu[headu]]) continue;
		//cout<<"ok1\n";
		for (int i = 0; i < with[qu[headu]].size(); i++) {
			if (usedu[with[qu[headu]][i]] > - 1) continue;
			qu.push_back(with[qu[headu]][i]);
			usedu[with[qu[headu]][i]] = usedu[qu[headu]] + 1;
			tailu++;
		}
	}
	cout<<(res - 1);
}


Measured memory_bytes: 7800
#include <stdio.h>

#define N 4

int main(void){
  int a[N], b[N], hit, blow;
  int i, j, c[N];

  while(scanf("%d%d%d%d", &a[0], &a[1], &a[2], &a[3]) != EOF){
    scanf("%d%d%d%d", &b[0], &b[1], &b[2], &b[3]);
    hit = 0;
    blow = 0;
    for(i = 0; i < N; i++){
      if(a[i] == b[i]){
	c[i] = 1;
	hit++;
      }else{
	c[i] = 0;
      }
    }
    for(i = 0; i < N; i++){
      for(j = 0; j < N; j++){
	if(c[j] == 0 && a[j] == b[i]){
	  c[j] = 1;
	  blow++;
	}
      }
    }
    printf("%d %d\n", hit, blow);
  }
  return 0;
}

Measured memory_bytes: 596
import std.stdio, std.string, std.conv, std.algorithm, std.array;

void main() {
	string S, T;
	S = readln().chomp();
	T = readln().chomp();
	string res = S.replace("?","z");
	const string ng = "UNRESTORABLE";
	bool flg = false;
	foreach(int i; 0..(to!(int)(S.length)-to!(int)(T.length)+1)) {
		bool f = true;
		foreach(int j; 0..to!(int)(T.length)) {
			if(S[i+j]!=T[j] && S[i+j]!='?') {
				f = false;
				break;
			}
		}
		if(f) {
			flg = true;
			res = min(res, (S[0..i] ~ T ~ S[(i+to!(int)(T.length))..to!int(S.length)]).replace("?","a"));
		}
	}
	if(flg) writeln(res);
	else writeln(ng);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head


#define rep(i,a,n) for (int i=a;i<n;i++)

int n,m,q;
int id[100][100];
vector<array<ll,3>> shop[100];
array<int,3> c[100];
vector<pair<ll,ll>> pp;

namespace mincost {
  const int V=10100,E=400000;
  // inf=0x20202020,_inf=0x20;
  ll dis[V],f[E],c[E],flow,cost,inf=1ll<<60;
  int q[V*30],vis[V],fst[V],pre[V],nxt[E],y[E],S,T,tot,tn;
  void init(int s,int t,int Tn) {
    tot=1; tn=Tn;
    rep(i,0,tn) fst[i]=0;
    S=s;T=t;
  }
  void add(int u,int v,ll ff,ll cc) {
    tot++;y[tot]=v;nxt[tot]=fst[u];f[tot]=ff;c[tot]=cc;fst[u]=tot;
    tot++;y[tot]=u;nxt[tot]=fst[v];f[tot]=0;c[tot]=-cc;fst[v]=tot;
  }
  bool spfa() {
    rep(i,0,tn) dis[i]=inf,vis[i]=0,pre[i]=0;
    dis[S]=0;q[0]=S;vis[S]=1;
    int t=1;
    rep(i,0,t) {
      int u=q[i];
      for (int j=fst[u];j;j=nxt[j]) {
        int v=y[j];
        if (f[j]&&dis[v]>dis[u]+c[j]) {
          dis[v]=dis[u]+c[j];
          pre[v]=j;
          if (!vis[v]) vis[v]=1,q[t++]=v;
        }
      }
      vis[u]=0;
    }
    return dis[T]!=inf;
  }
  void augment() {
    int p=T;
    ll _f=inf;
    while (pre[p]) _f=min(_f,f[pre[p]]),p=y[pre[p]^1];
    pp.pb(mp(_f,dis[T]));
    p=T;
    while (pre[p]) f[pre[p]]-=_f,f[pre[p]^1]+=_f,p=y[pre[p]^1];
  }
  void solve() {
    while (spfa()) augment();
  }
}

const ll inf=1ll<<60;

int main() {
	scanf("%d",&n);
	rep(i,0,n) {
		int k;
		ll s,p,c;
		scanf("%d",&k);
		rep(j,0,k) {
			scanf("%lld%lld%lld",&s,&p,&c);
			shop[i].pb({s,p,c});
		}
		sort(all(shop[i]));
	}
	scanf("%d",&m);
	rep(i,0,m) {
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		--u; --v;
		c[i]={u,v,w};
	}
	int s=0,t=1,mm=2;
	rep(i,0,n) rep(j,1,SZ(shop[i])) id[i][j]=mm++;
  mincost::init(s,t,mm);
	rep(i,0,n) {
		int k=SZ(shop[i]);
		id[i][0]=s; id[i][k]=t;
		rep(j,0,k) {
			mincost::add(id[i][j+1],id[i][j],inf,0);
			mincost::add(id[i][j],id[i][j+1],inf,shop[i][j][2]);
			mincost::add(id[i][j],id[i][j+1],shop[i][j][1],0);
		}
	}
	rep(i,0,m) {
		int u=c[i][0],v=c[i][1],w=c[i][2];
		rep(j,0,SZ(shop[v])) {
			int pos=SZ(shop[u]);
			rep(k,0,SZ(shop[u])) if (shop[u][k][0]+w>=shop[v][j][0]) {
				pos=k;
				break;
			}
			//printf("gg (%d,%d) >= (%d,%d)\n",u,pos,v,j);
			mincost::add(id[v][j],id[u][pos],inf,0);
		}
	}
  mincost::solve();
  scanf("%d",&q);
  rep(i,0,q) {
    ll a;
    scanf("%lld",&a);
    ll ans=0;
    for (auto x:pp) {
      //printf("gg %lld %lld\n",x.fi,x.se);
      if (x.se>=a) break;
      if (x.fi>=1ll<<55) { ans=-1; break; }
      ans+=x.fi*(a-x.se);
    }
    printf("%lld\n",ans);
  }
  mincost::solve();    
}


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

using namespace std;
typedef long long ll;

int main(void)
{
    int h, n;
    cin >> h >> n;
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        sum += a;
    }

    puts(h - sum > 0 ? "No" : "Yes");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << "NO\n"; return;}
#define yes {cout << "YES\n"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int N = 2e5 + 7;

int a[N];

void solve() {
    int n, k; 
    cin >> n >> k;
    loop(i, n)
        cin >> a[i];
    int cur = 0;
    int L = 0;
    loop(i, k)
        cur += a[i] + 1;
    int ans = cur;
    while (L + k < n) {
        cur -= a[L] + 1;
        cur += a[L + k] + 1;
        ++L; ans = max(ans, cur);
    }
    cout << ans / 2 << (ans % 2 ? ".5" : ".0");
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long int 
typedef pair<int,int> pii;
vector<int>v;
map<int,int>op;
#define MAX 200005
bool visited[MAX];
vector<int>adj[MAX];
const int M=1e9+7;
int n,m;
const ll INF = 1LL << 60;

ll solve(int n,int w,int wt[],int val[])
{
	vector<ll>dp(100001,LLONG_MAX);
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		int w=wt[i],v=val[i];
		for(int j=100000;j>=v;j--)
		{
			if(dp[j-v]==LLONG_MAX)
				continue;
			dp[j]=min(dp[j],dp[j-v]+w);
		}
	}
	for(int i=100000;i>=0;i--)
		if(dp[i]<=w)
			return i;
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL); 
	int w;
	cin>>n>>w;
	int wt[n],val[n];
	for(int i=0;i<n;i++)
		cin>>wt[i]>>val[i];
	cout<<solve(n,w,wt,val)<<endl;
	return 0;	
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;



int main(){
    int n;string s;
    cin >> n >> s;
    vector<bool>can(1000,false);
    int fro[12];
    int lat[12];
    rep(i,12){
        fro[i]=INF;
        lat[i]=-1;
    }
    for(int i=0;i<s.size();i++){//最初に登場するのは前から何番目か記録
        int now = s[i]-'0';
        if(fro[now]==INF){
            fro[now]=i;
        }
    }
    for(int i=s.size()-1;i>=0;i--){
        int now = s[i]-'0';
        if(lat[now]==-1){
            lat[now]=i;
        }
    }
    for(int i=1;i<s.size()-1;i++){
        int now = s[i]-'0';
        rep(j,10)rep(k,10){
            if(fro[j]<i&&lat[k]>i){
                can[j*100+10*now+k]=true;
            }
        }
    }
    int ans = 0;
    rep(i,1000){
        if(can[i])ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
h, w, a, b = gets.chomp.split.map(&:to_i)
$M = 10**9+7

r = [1]
for i in 1..200000 do
    r[i] = r[i-1] * i % $M
end

##p r.size
def my_pow(x,n)
    ans = 1
    while n > 0
        if n % 2 == 1
            ans = ans * x % $M
        end
        x = x * x % $M
        n /= 2
    end
    return ans
end


rr = [1]
for i in 1..200000 do
    rr[i] = my_pow(r[i], $M - 2)
#    puts rr[i]
end

def combi(n,k,r, rr)
    k=n-k if 2*k > n
    return 1 if k == 0
    return r[n] * rr[n-k] * rr[k]
end

ans = 0
(1).upto(h-a) do |i|
    aaa = combi(i+b-2, b-1, r, rr)
    bbb = combi(h-i+1+w-b-2, w-b-1, r, rr)
    ans += aaa * bbb % $M
end
puts ans % $M



Measured memory_bytes: 5192