akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <limits>

using namespace std;

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

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#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)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


LL power(LL x, LL n, LL mod) {
	LL ret = 1;
	while (n > 0) {
		if (n & 1) (ret *= x) %= mod;
		(x *= x) %= mod;
		n >>= 1;
	}
	return ret;
}

int main() {
	int n, m; cin >> n >> m;

	cout << power(n, m, 1e9 + 7) << endl;
	return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define ll long long
using namespace std; 
#define mod 924844033
#define maxn 4010
int n,m,tot;
bool lk[maxn];
long long f[maxn][maxn][2],jiecheng[maxn],ans;
void init(){
	jiecheng[0]=1;
	for(int i=1;i<=4000;i++)
		jiecheng[i]=(jiecheng[i-1]*i)%mod;
}
int main(){
	scanf("%d%d",&n,&m);
	init();
	for(int i=1;i<=m;i++)
		for(int t=2;t--;)
			for(int j=i;j<=n;j+=m){
				tot++;
				if(j!=i) lk[tot]=1;
			}
	f[0][0][0]=1;
	for(int i=0;i<2*n;i++)
		for(int j=0;j<=n;j++){
			f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%mod;
			if(lk[i+1]) f[i+1][j+1][1]=f[i][j][0];
		}
	for(int i=0,t=1;i<=n;i++,t=-t){
		f[2*n][i][0]=(ll)(f[2*n][i][0]+f[2*n][i][1])*jiecheng[n-i]%mod;
		ans=(ans+f[2*n][i][0]*t+mod)%mod;
	}
	cout<<ans;
}
//

Measured memory_bytes: 249728
from collections import Counter

n = int(input())
nums = [int(s) for s in input().split()]
counter = Counter(nums)
res = 0

for cnt in counter.values():
    res += (cnt - 1)*cnt // 2

for outlier in nums:
    cnt = counter[outlier]
    if cnt <= 1:
        print(res)
    else:
        print(res - cnt + 1)





Measured memory_bytes: 26908
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int N, T; cin >> N >> T;
	int minC = INT_MAX; 
	REP(i, N){
		int c, t; cin >> c >> t;
		if(t <= T){
			minC = min(minC, c);
		} 
	}
	if(minC != INT_MAX) cout << minC << endl;
	else cout << "TLE" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#include<utility>
#define ll long long
#define mod 1000000000+7
#define rep(i,n) for(int i=0;i<(int) (n);i++)
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
int main(){
  int n;
  cin>>n;
  vector <tuple<int,int>> a;

  for(int i=1;i<=n;i++){
	int m;
	cin>>m;
	a.push_back(tie(m,i));
}

sort(a.begin(),a.end());

for(int i=0;i<n;i++){
	cout<< get<1>(a[i])<<" ";
}

}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  ll a[5];
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  ll m = min(a[0], a[1]);
  for (int i = 1; i <= 3; i++) {
    m = min(m, a[i+1]);
  }
  
  cout << 4 + (N+m-1)/m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define str string
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define ff fflush(stdout)
using namespace std;
ll num[100005];
ll dif[100005];
int main () { 
	ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
	scanf("%lld", &a);
	for (i = 1; i <= a; i++) {
		scanf("%lld", &num[i]);
	}
	stable_sort(num + 1, num + a + 1);
	b = 1;
	for (i = 2; i <= a; i++) {
		num[i] += num[i - 1]; b++;
		if (num[i - 1] * 2 < num[i] - num[i - 1]) b = 1;
	}
	printf("%lld\n", b);
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;
int main(){
  int n,k;
  cin>>n>>k;
  vector<ll> xary,yary;
  for(int i=0;i<n;++i){
    ll x,y;
    cin>>x>>y;
    xary.push_back(x);
    yary.push_back(y);
  }

  unsigned long long ret = 0;
  for(int xi=0;xi<n;++xi){
    for(int xj=xi+1;xj<n;++xj){
      for(int yi=0;yi<n;++yi){
        for(int yj=yi+1;yj<n;++yj){
          int cnt = 0;
          ll maxx = max(xary[xi],xary[xj]);
          ll minx = min(xary[xi],xary[xj]);
          ll maxy = max(yary[yi],yary[yj]);
          ll miny = min(yary[yi],yary[yj]);
          for(int p=0;p<n;++p){
            if(maxx>=xary[p] && xary[p]>=minx && maxy>=yary[p] && yary[p]>=miny){
              cnt += 1;
            }
            if(cnt>=k){
              break;
            }
          }

          if(cnt>=k){
            unsigned long long s = (maxx-minx) * (maxy-miny);
            if(ret==0 || s<ret){
              ret = s;
            }
          }
        }
      }
    }
  }
  cout<<ret<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N, M = map(int, raw_input().split())
ab = [map(int, raw_input().split()) for i in xrange(N)]
cd = [map(int, raw_input().split()) for i in xrange(M)]

for i, (a, b) in enumerate(ab):
    mn = 1e10
    p = -1
    for j, (c, d) in enumerate(cd, 1):
        tmp = abs(a - c) + abs(b - d)
        if tmp < mn:
            mn = tmp
            p = j
    print p


Measured memory_bytes: 4008
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n;
  cin>>n;

  vector<queue<int>> p(n);
  rep(i,n){
    rep(j,n-1){
      int x;
      cin>>x;
      x--;
      p[i].push(x);
    }
  }

  int ans=-1;
  while(1){
    bool dame=true;
    bool kara=true;

    ans++;

    vector<bool> che(n,false);
    rep(i,n){
      if(!p[i].empty()){
        if(che[i]) continue;
        kara=false;
        int x=p[i].front();
        if(x<=i || che[x]) continue;
        int y=p[x].front();
        if(i==y){
          dame=false;
          che[x]=true;
          p[i].pop();
          p[x].pop();
        }
      }
    }
    if(kara) {
      cout << ans << endl;
      return 0;
    }
    if(dame) {
      cout << -1 << endl;
      return 0;
    }
  }

}

Measured memory_bytes: 8032
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    char C;
    cin>>C;
    if(C=='A')print('T')
    if(C=='T')print('A')
    if(C=='G')print('C')
    if(C=='C')print('G')


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

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

int main() {
    int A, B, C, X, Y;
    scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);

    int xy = (X < Y) ? X : Y;

    int c = ((2 * C) < (A + B)) ? 2 * C : (A + B);

    if (X < Y) {
        if (c > B) printf("%d\n", xy * c + (Y - xy) * B);
        else printf("%d\n", xy * c + (Y - xy) * c);
    } else {
        if (c > A) printf("%d\n", xy * c + (X - xy) * A);
        else printf("%d\n", xy * c + (X - xy) * c);
    }

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N-1);
  int sum;
  for(int i = 0; i < N-1; i++) {
    cin >> B.at(i);
  }
  A.at(0) = B.at(0);
  A.at(N-1) = B.at(N-2);
  for(int i = 1; i < N-1; i++) {
    A.at(i) = min(B.at(i-1),B.at(i));
  }
  for(int i = 0; i < N; i++) {
    sum = sum + A.at(i);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
# import bisect
# # import heapq
# # from copy import deepcopy
# # from collections import deque
# # from collections import Counter
# # from itertools import accumulate
# # from itertools import permutations
# import numpy as np
# # import math
# a,b,c = map(int, input().split())
n = int(input())
# p = list(map(int, input().split()))


def dfs(s, var):
    if len(s) == n:
        print(s)
    else:
        for i in range(var):
            dfs(s+chr(ord('a')+i), var)

        dfs(s+chr(ord('a')+var), var+1)

dfs('a',1)


Measured memory_bytes: 4380
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <string>
using namespace std;

int main(void)
{
    //float f;
    string s;
    int m,n,o;
    //vector <float> f(10);
    //char a,b,c;
    int i=0,j,sum=0;
    //long long int m,n,o,total=0;
    cin>>m>>n;
    for(i=0;i<m;i++)
    {
        cin>>s;
        cout<<s<<endl<<s<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		Arrays.setAll(h, i -> sc.nextInt());
		
		int[] cost = new int[n];
		Arrays.fill(cost, Integer.MAX_VALUE);
		cost[0] = 0;
		
		for (int i = 0; i < n - 1; i++) {
			int c1 = Math.abs(h[i + 1] - h[i]);
			cost[i + 1] = Math.min(cost[i + 1], c1 + cost[i]);
			
			if (i < n - 2) {
				int c2 = Math.abs(h[i + 2] - h[i]);
				cost[i + 2] = Math.min(cost[i + 2], c2 + cost[i]);
			}
		}
		
//		System.out.println(Arrays.toString(h));
//		System.out.println(Arrays.toString(cost));
		
		System.out.println(cost[n - 1]);
		
		sc.close();
	}

}




Measured memory_bytes: 51180
n = gets.to_i
a = n.times.map{gets.to_i}
f = false
s = 0
ans = 0
(n-1).downto(1) do |i|
  if s-1 == a[i]
    s -= 1
  elsif s <= a[i]
    s = a[i]
    ans += a[i]
  else
    puts "-1"
    exit
  end
end
if a[0] == 0
  puts ans
else
  puts "-1"
end

Measured memory_bytes: 5500
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h,w;
  cin >> h >> w;
  string board[50];
  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
  
  for (int i = 0; i < h; i++) {
    cin >> board[i];
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (board[i][j] == '#') continue; 
        int num =0; 
        for (int d = 0; d < 8; ++ d) {
          const int ni = i + dy[d];
          const int nj = j + dx[d];

         if (ni < 0 or h <= ni) continue;
         if (nj < 0 or w <= nj) continue;
         if (board[ni][nj] == '#') num++;
       }

     board[i][j] = char(num + '0');

 }
}
for (int i = 0; i < h; ++i) cout << board[i] << endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>

char str[200];
int dp[150][6][3];

int dfs(const int& now, const int& cnt, const int& equal, const int& n,
const int& k) {
	if (now == n + 1) {
		return cnt == k;
	}
	if (cnt > k) {
		return 0;
	}
	if (dp[now][cnt][equal] >= 0 && !equal) {
		return dp[now][cnt][equal];
	}
	int max = equal ? str[now] - '0' : 9;
	int sum = 0;
	for (int i = 0; i <= max; ++i) {
		sum += dfs(now + 1, cnt + !!i, equal && (i == max), n, k);
	}
	return dp[now][cnt][equal] = sum;
}

int main(int argc, char** argv) {
	std::memset(dp, -1, sizeof(dp));
	int k;
	std::scanf("%s%d", str + 1, &k);
	std::printf("%d\n", dfs(1, 0, 1, std::strlen(str + 1), k));
	return 0;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
L = [list(map(int, input().split())) for i in range(N)]
L.sort(key=lambda x: x[0])
c = 0
for i in range(N):
    if M <= L[i][1]:
        print(c + L[i][0] * M)
        exit()
    else:
        M -= L[i][1]
        c += L[i][0] * L[i][1]


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

int x[3] = {5, 7, 5};

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 0; i < 3; i++) {
    if (a == x[i%3] && b == x[(i+1)%3] && c == x[(i+2)%3]){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
N, Q = map(int, input().split())
#link = [[0]*(N+1) for _ in range(N+1)]
link = [[] for _ in range(N+1)]
for n in range(N-1):
    a, b = map(int, input().split())
    # link[a][b] = 1
    # link[b][a] = 1
    link[a].append(b)
    link[b].append(a)
V = [0] * (N+1)
ans = [0] * (N+1)
for q in range(Q):
    p, x = map(int, input().split())
    V[p] += x

def dfs(i, parent, acc):
    V[i] += acc
    # for j in range(1,N+1):
    #     if link[i][j] == 1 and parent!=j:
    #         dfs(j,i,V[i])
    for j in link[i]:
        if j==parent:
            continue
        dfs(j,i,V[i])
cur = 1
parent = 0
acc = 0

dfs(cur, parent , acc)
V = [str(v) for v in V]
print (" ".join(V[1:]))

Measured memory_bytes: 228912
N = int(input())
A = list(map(int, input().split()))

X = [0]*N

# X[0]を求めたい
hoge = 0
for i in range(1, N, 2):
    hoge += A[i]

X[0] = sum(A)-2*hoge

for i in range(1, N):
    X[i] = 2*A[i-1] - X[i-1]

X_str_list = map(str, X)

ans = " ".join(X_str_list)
print(ans)


Measured memory_bytes: 19220
#include<stdio.h>
#include<math.h>

int main(void){
  double xa,ya,ra;
  double xb,yb,rb;
  double d,d1,d2;
  int count;
  int i;

  scanf("%d",&count);

  for(i=0;i<count;i++){
    scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
    d = (xa-xb)*(xa-xb)+(ya-yb)*(ya-yb);
    d1 = sqrt(d);
    if(ra>=rb){
      d2 = ra - rb;
    }else{
      d2 = rb - ra;
    }


    if(d1>ra+rb){
      printf("0\n");
    }
    if((d1<=ra+rb)&&(d1>=d2)){
      printf("1\n");
    }
    if((d1<d2)&&(ra>rb)){
      printf("2\n");
    }
    if((d1<d2)&&(rb>ra)){
      printf("-2\n");
    }

  }
  return 0;
}

Measured memory_bytes: 616
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;



int main(){
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	set<int> sugar, water;
	for (int i = 0; i <= f; i++) {
		for (int j = 0; j <= f; j++) {
			int y = i*c + j*d;
			if (y <= f)
				sugar.insert(y);
		}

	}
	for (int i = 0; i*100 <= f; i++) {
		for (int j = 0; j*100 <= f; j++) {
			int y = i*a*100 + j*b*100;
			if (y <= f)
				water.insert(y);
		}

	}
	double rate = -1.0;
	int answ=0, anss=0;
	for (set<int>::iterator p = water.begin(); p != water.end(); p++) {
		for (set<int>::iterator q = sugar.begin(); q != sugar.end(); q++) {
			if (*q * 100.0 <= e * *p && *p+*q <= f) {
				double y = *q * 100.0 / (*p + *q);
				if (y > rate) {
					answ = *p; anss = *q;
					rate = y;
				}

			}	
			
		}
	}
	cout << answ+anss << " " << anss << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rapido ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"

void solve()
{
    int n;cin>>n;
    int ans=(n*(n-1))/2;
    cout<<ans<<endl;
}
int32_t main()
{
    rapido;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    solve();
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    string s;
    int w;
    cin >> s >> w;
    for(int i = 0;i < s.size();i++)
    {
        if(i % w == 0)
        {
            cout << s[i];
        }
    }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 using namespace std; 
  int main() { 
    int n;
    cin>>n;
    vector<int>k;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        k.push_back(x);
    }
   sort(k.begin(),k.end());
   if(n%2 != 0){
       cout<<0;
   }else if(n%2 ==0){
       cout<<k[(n/2)]-k[(n/2)-1];
   }
     }


   


Measured memory_bytes: 892
#include<vector>
#include <iostream>
#include<string>
#include <complex>
#include <algorithm>
#include<string>

using namespace std;

int main(){
    int s = 0;
    int s2 = 0;
    int a;
    cin >> a;

    s = a / 100;
    s2 = a % 100;

    if(s <= 12 && s >= 1){
        if(s2 <= 12 && s2 >= 1){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if(s2 <= 12 && s2 >= 1){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }

}

Measured memory_bytes: 3584
import static java.util.Arrays.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.StringTokenizer;

public class Main {

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int n = sc.nextInt();
		BigDecimal x = BigDecimal.valueOf(a).divide(BigDecimal.valueOf(b), n + 20, RoundingMode.DOWN);
		if (a >= b) {
			x = x.subtract(BigDecimal.valueOf(a/b));
		}

		String s = x.toPlainString();
		int ans = 0;
		for (int i = 0; i < n; i++) {
			char c = 0;
			try {
				c = s.charAt(i + 2);
			} catch (Exception e) {c = 0;}
			ans += (int)(c - '0');
		}
		out.println(ans);
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

Measured memory_bytes: 17080
n = int(input())
a = sorted(list(map(int, input().split())))

eat = 0
l = 0
r = n-1
while l < r:
    while l < n - 1 and a[l+1] != a[l]:
        l += 1
    while r > 0 and a[r-1] != a[r]:
        r -= 1
    if r <= l:
        break
    eat += 1
    l += 1
    r -= 1
print(n-eat*2)

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<double> A(N);
    for(int i=0; i<N; i++)
    {
        cin >> A.at(i);
    }
    double sum=0;
    for(int i=0; i<N; i++)
    {
        sum+=1/A.at(i);
    }
    cout << setprecision(10) << fixed << 1/sum <<endl;
    
}

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

using namespace std;

int main() {
	int n, T;
	cin >> n >> T;
	int m = 11111;
	for (int i = 0; i < n; i++) {
		int c, t;
		cin >> c >> t;
		if (t > T) c = 11111;
		m = min(m, c);
	}
	if (m > 10000) cout << "TLE" << endl;
	else cout << m << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    vector<int> t(n+1), x(n+1), y(n+1);
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;

    for(int i=1; i<=n; i++) cin >> t[i] >> x[i] >> y[i];

    for(int i=1; i<=n; i++) {
        int l = abs(x[i] - x[i-1])+ abs(y[i] - y[i-1]);
        int div_t = t[i] - t[i-1];

        if(div_t < l) {
            cout << "No" << endl;
            return 0;
        }

        if((div_t - l) % 2 == 1 && div_t >= l) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 4524
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n,m = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

size = a.size
left = Array.new(size+1)
left[0] = 0
h = Hash.new(0)
0.upto(size-1) do |i|
  left[i+1] = left[i] + a[i]
  h[left[i+1] % m] += 1
end
# p left
# p h
ans = 0
h.each do |k,v|
  ans += v * (v-1) / 2
end
puts ans + h[0]

Measured memory_bytes: 13680
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define p pair<int,int>
#define pb push_back
#define endl '\n'
void fast()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);

}

int main()
{
    fast();
    int a[5];
    for(int i=0;i<5;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<5;i++)
    {
        if(a[i]==0)
        {
            cout<<i+1<<endl;
            return 0;
        }
    }
}



Measured memory_bytes: 3612
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());
// greatest common divisor
long long gcd(long long a, long long b) {
  if (a==0 || b==0) return a+b;
  long long r = 1;
  while (r != 0) {
    r = a%b; a = b; b = r;
  }
  return a;
}

long long lcm(long long a, long long b) {
  return a/gcd(a,b)*b;
}


class FSumDifference {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n, x, d; cin >> n >> x >> d;
      if (x==0 && d==0) {
        cout << 1 << endl;
        return;
      }
      if (x==0) {
        cout << n*(n-1)/2+1 << endl;
        return;
      }
      if (d==0) {
        cout << n+1 << endl;
        return;
      }
      if (d < 0) {
        x = -x;
        d = -d;
      }
      vector<ll> a(n);
      rep(i, n) {
        a[i] = x + d*i;
      }
      vector<ll> sum(n+1);
      rep(i, n) {
        sum[i+1] = sum[i] + a[i];
      }

      /*
      set<P> st;
      rep(i, n) {
        ll r = (x*i)%d;
        st.emplace(r, i);
      }

      int now = -1;
      ll blank = 0;
      ll ans = 0;
      for(auto& e: st) {
        ll r = e.first;
        ll idx = e.second;
        if (now < r) {
          ans += ()


        }


      }*/


      // x > 0 && d > 0
      ll r = gcd(abs(x), abs(d));
      ll k = abs(d)/r;
      ll ans = 0;
      rep(i, k) {
        ll mi = 0;
        ll ma = 0;
        ll blank = 0;
        bool flag = false;
        for(int j=0; j*k+i<=n; j++) {
          flag = true;
          ll p = j*k+i;
          ll nmi = sum[p];
          ll nma = sum[n]-sum[n-p];
          if (j==0) {
            mi = nmi;
            ma = nma;
          } else {
            if (ma < nmi) {
              ll diff = nmi-ma;
              blank += diff/abs(d) - 1;
            } else if (nma < mi) {
              ll diff = mi-nma;
              blank += diff/abs(d) - 1;
            }
            chmin(mi, nmi);
            chmax(ma, nma);
          }
        }
        if (flag) {
          ans += (ma-mi)/abs(d) + 1 - blank;
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  FSumDifference solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

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

int main() {

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

	int N;
	cin >> N;

	vector<lint> T(N), A(N);
	for (int i = 0; i < N; i++) cin >> T[i] >> A[i];

	lint T_vote = 1, A_vote = 1, max_vote;
	for (int i = 0; i < N; i++) {

		max_vote = max((T_vote - 1) / T[i] , (A_vote - 1) / A[i]) + 1;
		T_vote = max_vote * T[i];
		A_vote = max_vote * A[i];
	}

	cout << T_vote + A_vote;

	return 0;
}

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


int n;

void dfs(string s,char mx){
  if (s.size()==n){
    cout << s << endl;
    return;
  }
  for(char c='a';c<=mx+1;c++){
    string t=s;
    t+=c;
    dfs(t,max(mx,c));
  }
}
int main(){
  cin >> n;
  dfs("",'a'-1);
  return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(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 << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000000
#define N 200005  //check the limits, man
int main()
{
    int i,n,k,a;
    in2(n,k);
    vi v(n);
    read(v,i,n);
    vi sum(n+1);
    sum[0]=0;
    lp(i,1,n+1)
    {
        sum[i]=sum[i-1]+v[i-1];
        sum[i]%=k;
    }
    rep(i,n+1)
    {
        sum[i]-=(i%k);
        if(sum[i]<0)
            sum[i]+=k;
    }
    map<int,int> cnt;
    rep(i,min(n+1,k))
        a=sum[i],cnt[a]++;
    ll ans=0;
    rep(i,n)
    {
        a=sum[i];
        cnt[a]--;
        ans+=(cnt[a]);
        if(i+k<=n)
            a=sum[i+k],cnt[a]++;
    }
    llout(ans);
}




Measured memory_bytes: 11136
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];
int H[MAX];


void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].l!=NIL) calcDepth(T[u].l,p+1);
  if(T[u].r!=NIL) calcDepth(T[u].r,p+1);
}


int calcHeight(int u){
  int a=0,b=0;
  if(T[u].l!=NIL){
    a=calcHeight(T[u].l)+1;
  }
  if(T[u].r!=NIL){
    b=calcHeight(T[u].r)+1;
  }

  if(a>b){
    H[u]=a;
    return H[u];
  }else{
    H[u]=b;
    return H[u];
  }
}


int getSib(int u){
  int n;
  n=T[u].p;
  if(n==NIL){
    return NIL;
  }else if(T[n].l!=NIL&&T[n].l!=u){
    return T[n].l;
  }else if(T[n].r!=NIL&&T[n].r!=u){
    return T[n].r;
  }else{
    return NIL;
  }
}

void print(int u){
  int degree=0;
  if(T[u].l!=NIL)degree++;
  if(T[u].r!=NIL)degree++;
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", u, T[u].p,getSib(u),degree, D[u],H[u]);

  if(T[u].p==NIL) printf("root\n");
  else if(T[u].l==NIL&&T[u].r==NIL) printf("leaf\n");
  else printf("internal node\n");
}
 

int main(){
  int i;
  int n;
  int id, l, r;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;
  
  for(i=0; i<n; i++){
    scanf("%d %d %d", &id, &l,&r);
    T[id].l=l;
    T[id].r=r;
    if(l!=NIL){
      T[l].p=id;
    }
    if(r!=NIL){
      T[r].p=id;
    }
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }
  
  //それぞれのノードの深さ,高さを求める
  calcDepth(root, 0);
  calcHeight(root);
  //出力 (output)
  for(i=0; i<n; i++) print(i);
  
  return 0;
}



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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	if (m<=2*n) {
		cout << m / 2 << endl;
	}
	else {
		cout << (n + (m - 2 * n) / 4) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) _OUTPUT_IMPL_(__VA_ARGS__)
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	in(int, n);
	out(n*(n + 1) / 2);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> V;
	vector<int> C;
	int i;
	for (i = 0; i < N; i++) {
		int v;
		cin >> v;
		V.push_back(v);
	}
	for (i = 0; i < N; i++) {
		int c;
		cin >> c;
		C.push_back(c);
	}
	int ans = 0;
	for (i = 0; i < N; i++) {
		ans += max(0, V.at(i) - C.at(i));
	}
	cout << ans;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N , K , X , Y;
  cin >> N >> K >> X >> Y;
  int result;
  if(N <= K){
    result = N * X;
  } else {
    result = (K * X) + ((N - K) * Y);
  }
  cout << result;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ad = {}
for i in range(n):
    if a[i] in ad:
        ad[a[i]] +=1
    else:
        ad[a[i]] = 1
ans = 0
for j in ad.values():
    ans += j*(j-1)//2

for i in range(n):
    j = ad[a[i]]
    print(ans-j*(j-1)//2+(j-1)*(j-2)//2)

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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   int N;
   cin >> N;
   vector<int> H(N);
   rep(i, N) cin >> H.at(i);

   string ans = "Yes";

   if (N != 1) {
     H.at(0)--;
     for (int i = 1; i < N ; i++) {
       if (H.at(i - 1) == H.at(i)) continue;
       else if (H.at(i - 1) < H.at(i)) H.at(i)--;
       else if (H.at(i - 1) > H.at(i)) {
         ans = "No";
         break;
       }
     }
   }
   cout << ans << endl;
 }


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

using namespace std;

using ll = long long;

const ll INF = 1LL << 50;

// ソート用比較関数
bool sumcmp(const pair<int, int>& a, const pair<int, int>& b) {
    return a.first + a.second < b.first + b.second;
}

ll dp[5010][5010];

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

    pair<ll, ll> hp[N];
    for (int i = 0; i < N; ++i) {
        cin >> hp[i].first >> hp[i].second;
    }

    // ペアの和について昇順にソート
    sort(hp, hp + N, sumcmp);

    fill(dp[0], dp[0] + N + 1, INF);
    dp[0][0] = 0, dp[0][1] = hp[0].second;
    // dp[i][j] = i人目まででj人を選んだときの,Pの総和の最小値
    // 0人目は絶対置けるので初期化

    for (int i = 1; i < N; ++i) {
        // i人目を選ばない場合
        for (int j = 0; j <= N; ++j) {
            dp[i][j] = dp[i - 1][j];
        }

        // i人目を選ぶ場合
        for (int j = 0; j < N; ++j) {
            if (dp[i - 1][j] <= hp[i].first) {
                dp[i][j + 1] = min(dp[i][j + 1], dp[i - 1][j] + hp[i].second);
            }
        }
    }

    int ans = 0;
    for (int j = 0; j <= N; ++j) {
        if (dp[N - 1][j] < INF) ans = j;
    }

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


Measured memory_bytes: 195968
import java.util.*;
 
class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int H, W;
     
    while (in.hasNext()) {
      StringBuilder odd  = new StringBuilder();
      StringBuilder even = new StringBuilder();
      StringBuilder total = new StringBuilder();
      String crlf = System.getProperty("line.separator");
      H = in.nextInt();
      W = in.nextInt();
      if(H == 0 && W == 0) break;
       
      for (int w = 0; w < W; w++) {
        if (w % 2 == 1) { 
          odd.append("#");
          even.append(".");
        } else {
          odd.append(".");
          even.append("#");
        }
      }
      odd.append(crlf);
      even.append(crlf);
       
      for (int h = 0; h < H; h++) {
        if (h % 2 == 1) total.append(odd);
        else            total.append(even);
      }
      System.out.println(total.toString());
    }
  }
}

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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long

int main() {
	string s;
	cin >> s;
	for(int i=0;i<s.size();i++) {
		if(s[i] == '?')
			s[i] = 'D';
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3756
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var nm=(Arr.shift()).split(" ").map(Number);
   if(nm[0]==0 && nm[1]==0)break;
   var arr=[];
   for(var i=0;i<nm[1];i++)arr[i]=[i+1,0];
   for(var i=0;i<nm[0];i++){
      var v=(Arr.shift()).split(" ").map(Number);
      v.forEach(function(val,i){arr[i][1]+=val;});
   }
   arr.sort(function(a,b){
      if(a[1]==b[1])return a[0]-b[0];
      else return b[1]-a[1];
   });
   var ans=[];
   arr.forEach(function(val,i){ans.push(arr[i][0]);});
   console.log(ans.join(" "));
}

Measured memory_bytes: 12204
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int H, W, K;
string S[10];
//---------------------------------------------------------------------------------------------------
int dp[1010], cnt[11];
int solve(vector<int> grp) {
	int res = 0;
	int x = 0;

	while (x < W) {
		rep(c, 0, 11) cnt[c] = 0;

		int nxt = x;
		rep(xx, x, W) {
			bool ng = false;
			rep(y, 0, H) if (S[y][xx] == '1') {
				cnt[grp[y]]++;
				if (K < cnt[grp[y]]) ng = true;
			}
			if (ng) break;
			chmax(nxt, xx + 1);
		}

		if (nxt == x) return inf;
		x = nxt;

		res++;
	}

	return res - 1;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> H >> W >> K;
	rep(y, 0, H) cin >> S[y];

	int ans = inf;
	rep(div, 0, 1 << (H - 1)) {
		vector<int> grp;
		int g = 1, cnt = 0;
		rep(i, 0, H - 1) {
			grp.push_back(g);
			if (div & (1 << i)) g++, cnt++;
		}
		grp.push_back(g);

		chmin(ans, solve(grp) + cnt);
	}
	cout << ans << endl;
}







Measured memory_bytes: 256
h,w=gets.split.map &:to_i
a=[]
h.times do
  x=gets.chomp.chars
  x.count('#')!=0&&a<<x
end
a=a.transpose; i=0; n=a.size
while i<n do
  if a[i].count('#')==0
    a.delete_at(i)
    n-=1
  else
    i+=1
  end
end
a.transpose.each{|c|puts c.join}


Measured memory_bytes: 2300
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N;
	int a[200010];
	cin >> N;
	ll sum = 0;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	ll ans = 1e10;
	ll sum2 = 0;
	for (int i = 0; i < N-1; ++i) {
			sum2 += a[i];
			ll A = (sum - sum2) - sum2;
			if (A < 0)A -= 2 * A;
			ans = min(ans, A);
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int N; cin >> N;
    string S; cin >> S;
    string T(S);
    int temp;
    int A, Z;
    A = int('A');
    Z = int('Z');
    for (int i = 0; i < S.size(); i++) {
        //temp = (int(S[i]) + N) % int('Z') + int('A') - 1;
        temp = (int(S[i]) + N);
        if (temp > Z) {
            temp = temp % Z + A - 1;
         }
        T[i] = char(temp);
    }
    cout  << T << endl;
    return 0;
}


Measured memory_bytes: 256
from sys import maxint

N = input()
stones = map(int,raw_input().split())

costs = [maxint] * N 
costs[0] = 0
for n in range(N) :
  if n+1 < N : costs[n+1] = min(costs[n+1], costs[n] + abs(stones[n]-stones[n+1]))
  if n+2 < N : costs[n+2] = min(costs[n+2], costs[n] + abs(stones[n]-stones[n+2]))

print costs[-1]

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

int main() {
				    // *constraint*
  int N,A;    	    // 1<=N<=200
  					// 1<=Ai<=10＾9
  				    // Enter an natural number
  cin  >> N;
  int count = 0;
  vector<int> vec(N);
  int i = 0;
  while(i < N){
  	cin >> vec.at(i);
    i++;
  }
  
  
  bool isEven = true;
  while (1) {
    i = 0;
    while(i < N){
      if((vec.at(i) % 2) != 0){
        isEven = false;
        break;
      }
      vec.at(i) /= 2;
      i++;
    }
    if(isEven == false){
      break;
    }
    count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 3640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int k=sc.nextInt();
    int x=sc.nextInt();
    sc.close();
    for(int i=x-k+1;i<x+k;i++){
      System.out.print(i+" ");
    }
    System.out.println();
  }
}

Measured memory_bytes: 21844
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

def main():
    D = int(input())
    if D == 25:
        print('Christmas')
    elif D == 24:
        print('Christmas Eve')
    elif D == 23:
        print('Christmas Eve Eve')
    else:
        print('Christmas Eve Eve Eve')

main()


Measured memory_bytes: 63980
#include <stdio.h>

 int main(void){
// Initialize number
 int a, b, c;

 scanf("%d%d%d", &a, &b, &c);

 int ispoor = 0;
 if (a == b && b != c) ispoor = 1;
 if (b == c && c != a) ispoor = 1;
 if (c == a && a != b) ispoor = 1;

 if (ispoor) {
 puts("Yes");
 } else {
 puts("No");
 }

 return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pi pair<int,int>
#define mk make_pair
#define f(i,n) for(int i=1;i<=n;i++)
#define fo(i,a,n) for(int i=a;i<n;i++)
#define fr(i,a,n) for(int i=a;i>=n;i--)
#define ll long long
#define N 1000000
using namespace std;
vector<int> adj(305);
vector<vector<int>> dp(100005,vector<int> (3,-1));
int n;
int winner(int sum,int ind)
{
    if(sum==0)
        return 1;
    if(sum<0)
        return 0;
    if(dp[sum][ind]==-1)
    {
        int ans=0;
        int cnd;
        if(ind==1)
            cnd=2;
        else
            cnd=1;
        f(i,n)
        {
            ans=ans|winner(sum-adj[i],cnd);
            if(ans==1)
                break;
        }
        //cout<<ans<<"  ";
        dp[sum][ind]=ans;
    }
    //cout<<ind<<" "<<dp[sum][ind]<<endl;
    if(dp[sum][ind]==0)
        return 1;
    else
        return 0;

}



int main()
{
//int n,k;
int k;
    cin>>n>>k;
    f(i,n)
        cin>>adj[i];
    int ans=winner(k,1);
    //cout<<ans;
    if(ans==0)
        cout<<"First";
    else
        cout<<"Second";


}


Measured memory_bytes: 16384
#include<stdio.h>
#include<string.h>
#include <math.h>
#include <stdlib.h>
#define MAX 10000
 
#define N 100000
#define INF 100000000
 
typedef struct{
  int a,b,c;
}data;
 
int n,A[N];
data D[500000];
 
void cal(int sum)
{
  int i,ran=1;
 
  for(i=0; i<n; i++)A[i]=INF;
  A[0]=0;
 
  while(ran!=0){
    ran=0;
    for(i=0; i<sum; i++){
      if(D[i].c+A[D[i].b]<A[D[i].a]){
    A[D[i].a]=D[i].c+A[D[i].b];
    ran=1;
      }
    }
  }
}
 
int main()
{
  int i,j,k,l,data=0;
 
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d%d",&l,&k);
    for(j=0; j<k; j++){
      D[data].b=l;
      scanf("%d%d",&D[data].a,&D[data].c);
      data++;
    }
  }
  cal(data);
  for(i=0; i<n; i++)printf("%d %d\n",i,A[i]);
  return 0;
}



Measured memory_bytes: 7588