akhauriyash/Code-Regression huggingface dataset:
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){return "";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var M = one[1];
  var s = next();
  var t = next();
  var thisLcm = lcm(N,M);
  var thisGcd = gcd(N,M);
  //myerr(thisLcm);
  //myerr(thisGcd);
  var slist = {};
  var tlist = {};
  for(var i = 0; i < N; i++){
    slist[i * (thisLcm / N)] = s[i];
  }
  for(var i = 0; i < M; i++){
    tlist[i * (thisLcm / M)] = t[i];
  }
  var count = 0;
  while(count < thisGcd){
    //myerr("check:" + (count * thisLcm / thisGcd));
    //myerr(slist[count * thisLcm / thisGcd]);
    //myerr(tlist[count * thisLcm / thisGcd]);
    if(slist[count * thisLcm / thisGcd] != tlist[count * thisLcm / thisGcd]){
      myout("-1");
      return;
    }
    count++;
  }
  myout(thisLcm);
  //myerr(slist);
  //myerr(tlist);
}
function gcd(m, n) {return n != 0 ? gcd(n, m % n) : m;}
function lcm(m, n) {return Math.max(m, n) / gcd(m, n) * Math.min(m, n);}

Measured memory_bytes: 85064
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		boolean flagA = false, flagC = false, flagL = true;
		int n = 0;
		if(s.charAt(0) == 'A') flagA = true;
		for(int i = 2; i < s.length() - 1; i++) {
			if(flagC && s.charAt(i) == 'C') {
				flagC = false;
				break;
			} else if(s.charAt(i) == 'C') {
				flagC = true;
				n = i;
			}
		}
		for(int i = 1; i < s.length(); i++) {
			if(i != n && Character.isUpperCase(s.charAt(i))) flagL = false;
		}
		if(flagA && flagC && flagL) {
			System.out.println("AC");
		} else {
			System.out.println("WA");
		}
	}
}

Measured memory_bytes: 23508
import sys

input = sys.stdin.readline


# https://atcoder.jp/contests/agc039/submissions/7878237
class AtCoder:
    def main(self):
        N = int(input())
        X = input().rstrip()

        k_cycles = 0
        ans = 0
        L = []
        for k in self.make_divisors(N):
            if (N // k) % 2 != 0:
                first_k_bit = X[:k]
                first_k_bit_ = first_k_bit.replace("0", "2").replace("1", "0").replace("2", "1")
                check_target = first_k_bit + (first_k_bit_ + first_k_bit) * ((N // k - 1) // 2)
                k_cycle = int(first_k_bit, 2) + (int(check_target, 2) <= int(X, 2))

                for l, cnt in L:
                    if k % l == 0:
                        k_cycle -= cnt
                L.append((k, k_cycle))

                k_cycles += k_cycle
                ans += 2 * k * k_cycle

        ans += (int(X, 2) + 1 - k_cycles) * 2 * N

        print(ans % 998244353)

    def make_divisors(self, n: int):
        divisors = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n // i)

        divisors.sort()
        return divisors


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 4592
k =  int(input())

a = [i+1 for i in range(9)]

while(1):
    if k <= len(a):
        print (a[k-1])
        break

    b = []
    k = k - len(a)

    for x in a:
        for i in [-1,0,1]:
            d =  x%10  + i
            if d < 0 or d > 9: continue
            b.append( x*10 + d)
    a = b.copy()

Measured memory_bytes: 12328
import math
import itertools
X=[]
Y=[]
L=0
N=int(input())
Perm=list(itertools.permutations(range(N)))
for i in range(N):
    x,y=map(int,input().split())
    X.append(x)
    Y.append(y)
for p in Perm:
    for j in range(N-1):
        L+=math.sqrt(abs(X[p[j]]-X[p[j+1]])**2 + abs(Y[p[j]]-Y[p[j+1]])**2)
print(L/math.factorial(N))

Measured memory_bytes: 8052
import java.util.Scanner;
public class Main {
	
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int n = sc.nextInt();
				if(n == 0) break;
				
				int count = 0;
				for(int i=1; i<n; i++) {
					int k = i;
					for(int j=i+1; j<n; j++) {
						if(k + j == n) {
							count++;
							break;
						}
						if(k + j < n) {
							k += j;
							continue;
						}
						else break;
					}
				}
				System.out.println(count);
			}
		}
	}
}


Measured memory_bytes: 26848
from sys import stdin
from collections import defaultdict
dic_d = defaultdict(int)
dic_t = defaultdict(int)
N = int(stdin.readline().rstrip())
for D in stdin.readline().rstrip().split():
    if D in dic_d:
        dic_d[D] += 1
    else:
        dic_d[D] = 1

M = int(stdin.readline().rstrip())
for T in stdin.readline().rstrip().split():
    if T in dic_t:
        dic_t[T] += 1
    else:
        dic_t[T] = 1
flag = True
for i in dic_t.keys():
    if dic_t[i] > dic_d[i]:
        flag = False
if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 67680
def main():
    s = input()

    i = 0
    is_ok = True
    while i < len(s):
        if i <= len(s) < i + 7:
            if i <= len(s) < i + 4:
                is_ok = False
                break

        next_word = s[i:i+5]
        if next_word == 'dream':
            if s[i+5:i+7] == 'er':
                if s[i+7:i+8] == 'a':
                    # dream
                    i += 5
                else:
                    # dreamer
                    i += 7
            else:
                # dream
                i += 5
        elif next_word == 'erase':
            if s[i+5:i+6] == 'r':
                # eraser
                i += 6
            else:
                # erase
                i += 5
        else:
            is_ok = False
            break

    if is_ok:
        print('YES')
    else:
        print('NO')

def main2():
    s = input()
    i = len(s)
    while i > 0:
        if s[i-5:i] == 'dream':
            i -= 5
        elif s[i-7:i] == 'dreamer':
            i -= 7
        elif s[i-5:i] == 'erase':
            i -= 5
        elif s[i-6:i] == 'eraser':
            i -= 6
        else:
            break
    if i == 0:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    #main()
    main2()


Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>

using namespace std;

const int MAX=200;
const int MAX_cap=10000;

class edge
{
public:
	int to,cap,rev;
	edge(){}
	edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
};

vector<edge> G[MAX];
bool used[MAX];

void add_edge(int from,int to,int cap)
{
	G[from].push_back(edge(to,cap,G[to].size()));
	G[to].push_back(edge(from,0,G[from].size()-1));
	return;
}

int dfs(int v,int t,int f)
{
	if(v==t)return f;
	used[v]=true;
	for(int i=0;i<G[v].size();i++)
	{
		edge &e=G[v][i];
		if(!used[e.to]&&e.cap>0)
		{
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0)
			{
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int maxflow(int s,int t)
{
	int flow=0;
	while(1)
	{
		for(int i=0;i<MAX;i++)used[i]=false;
		int f=dfs(s,t,MAX_cap);
		if(f==0)return flow;
		flow+=f;
	}
}

int main()
{
	int X,Y,E;cin>>X>>Y>>E;
	int u,v;
	int s=X+Y,t=s+1;
	for(int i=0;i<E;i++)
	{
		cin>>u>>v;
		add_edge(u,X+v,1);
	}
	for(int i=0;i<X;i++)add_edge(s,i,1);
	for(int i=0;i<Y;i++)add_edge(X+i,t,1);
	
	cout<<maxflow(s,t)<<endl;
	return 0;
}

Measured memory_bytes: 3320
<?php
//error_reporting(0);
//list($N,$Q) =  explode(" ",trim(fgets(STDIN)));
$x[] = trim(fgets(STDIN));
$x[] = trim(fgets(STDIN));
$x[] = trim(fgets(STDIN));
$x[] = trim(fgets(STDIN));
$x[] = trim(fgets(STDIN));

$sum = 0;
usort($x,'cmp');
foreach($x as $v) {
  $amari = $sum % 10;
  if ($amari > 0) {
    $sum += 10 - $amari;
  }
  $sum+=$v;
}
printf("%d\n",$sum);
//
//末尾が一番少ないやつを最後にする。(0以外)
function cmp($a,$b)
{
  $aa = $a % 10;
  $bb = $b % 10;
  if ($aa == 0) $aa = 10;
  if ($bb == 0) $bb = 10;
  return $bb-$aa;
}


Measured memory_bytes: 4604
#include<iostream>
#include<string>
using namespace std;
int main(){
  long long n;
  cin>>n;
  char A[n];
  char B[n];
  
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
   for(int i=0;i<n;i++){
    cin>>B[i];
  }
  
  long long N=2*n;
  char C[N];
  long long count=0;
  long long i=0;
  while(count<N){
    C[i]=A[count];
    i++;
    C[i]=B[count];
    i++;
    count++;
  }
  for(long long x=0;x<N;x++){
    cout<<C[x];
  }
 return 0; 
}

Measured memory_bytes: 256
import sys
import numpy as np
from heapq import heappop, heappush

# Dijikstra
def main():
    H, W = map(int, sys.stdin.readline().split())

    grid = np.array([list(sys.stdin.readline().rstrip()) for _ in range(H)])
    grid = np.pad(grid, 1, 'constant')
    # atcoderではnp.pad() のargにconstant_valuesを指定できない
    q = []
    heappush(q, (0, 1, 1))
    visited = set()
    can_go = False
    while q:
        cost, i, j = heappop(q)
        if (i, j) in visited:
            continue
        visited.add((i, j))
        if i == H and j == W:
            can_go = True
            break
        for dy, dx in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
            y = i + dy
            x = j + dx
            if grid[y][x] == '.' and not (y, x) in visited:
                heappush(q, (cost + 1, y, x))
    
    if can_go:
        ans = np.sum(grid == '.') - (cost + 1)
    else:
        ans = -1

    print(ans)  
if __name__ == "__main__":
    main()

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 2e3 + 100;
pii p[N];
int n;

bool cmp(pii a, pii b) {
    return a.first > b.first;
}

ll dp[N][N];

ll clac(int cnt, int l, int r) {
    if (l > r)return 0;
    if (~dp[l][r])return dp[l][r];
    ll ans = 1ll * p[cnt].first * abs(p[cnt].second - l) + clac(cnt + 1, l + 1, r);
    ans = max(ans, 1ll * p[cnt].first * abs(p[cnt].second - r) + clac(cnt + 1, l, r - 1));
    return dp[l][r] = ans;
}

int main() {
    scanf("%d", &n);
    for (int i = 1, x; i <= n; i++) {
        scanf("%d", &x);
        p[i] = {x, i};
    }
    sort(p + 1, p + n + 1, cmp);
    memset(dp, -1, sizeof(dp));
    printf("%lld\n", clac(1, 1, n));
    return 0;
}

Measured memory_bytes: 38412
def main():
    word_A = input()
    word_B = input()
    for i in range(len(word_A)):
        if (word_A != word_B):
            word_A = word_A[1:] + word_A[0]
        else:
            print("Yes")
            return
    print("No")

if __name__ == "__main__":
    main()

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[200005];
LL sum[200005];
map<LL, int> cnt;

int main() {
    scanf("%d", &n);
    forn(i, n) scanf("%d", a + i);
    sum[0] = 0;
    forn(i, n) {
        sum[i + 1] = sum[i] + a[i];
    }
    forn(i, n + 1) {
        ++cnt[sum[i]];
    }
    LL ans = 0;
    for (auto p : cnt) {
        ans += (LL)p.second * (p.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15104
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n, m, k, i, ans;
    cin >> n >> m;
    k = m/n;

    for(i = k; i >= 1; i--) {
        if(m%i == 0) {
            ans = i;
            break;
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
long long n,ans=1;
long long calc1(long long x)
{
	long long now=n;
	while (now%x==0) now/=x;
	if (now%x==1) return 1;
return 0;
}
int main()
{
	scanf("%lld",&n);
	for (long long i=2;i*i<=n;i++)
	if (n%i==0) 
	{
		ans+=calc1(i);
		if (i*i!=n) ans+=calc1(n/i);
	}
	//printf("lalal %lld\n",ans);
	if (n>2) ans++;
	for (long long i=2;i*i<=n-1;i++)
	if ((n-1)%i==0)
	{
		if (n%i!=0) ans++;
		if (n%((n-1)/i)!=0 && (i*i!=(n-1))) ans++;
	}
	printf("%lld\n",ans);
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	int n;
	cin >> n;
	VI cnt(n + 1, 0);
	rep(x, 1, 101) {
		rep(y, 1, 101) {
			rep(z, 1, 101) {
				if (x*x + y*y + z*z + x*y + x*z + y*z <= n) {
					cnt[x*x + y*y + z*z + x*y + x*z + y*z]++;
				}
			}
		}
	}
	rep(i, 1, n + 1)cout << cnt[i] << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







Measured memory_bytes: 3580
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
L = Counter(A)
anss = {}
sum_ans = sum([i*(i-1)//2 for i in L.values() if i >= 2])
for k,v in L.items():
    anss[k] = sum_ans - (v*(v-1)//2) + ((v-1)*(v-2)//2)
for i in A:
    print(anss[i])


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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  set<string> s;
  for (int i = 0; i < n; i++) {
    string t;
    cin >> t;
    s.insert(t);
  }
  cout << s.size() << endl;
}


Measured memory_bytes: 19160
"""
C - Skip
Xを含めた与えられた数列をソートする
最小値を基準０にする
隣同士の差を取る
数列の最大公約数を求める
"""

N, X = map(int, input().split())

numbers = [X]
for part in input().split():
    numbers.append(int(part))

numbers.sort()

# 最小値を基準0とする（ノーマライズ）
min_num = min(numbers)
normal_numbers = []
for num in numbers:
    normal_numbers.append(num - min_num)

# 隣との距離を出す
dist_numbers = []
for i in range(1, len(normal_numbers)):
    # 重複なしで隣との距離を数える
    dist_temp = normal_numbers[i] - normal_numbers[i-1]
    if dist_temp not in dist_numbers:
        dist_numbers.append(dist_temp)

# 最大公約数を求める
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def gcd_list(numbers):
    if len(numbers) == 1:
        return numbers[0]
    elif len(numbers) == 2: 
        return gcd(numbers[0], numbers[1])
    else:
        return gcd(numbers[0], gcd_list(numbers[1:]))

print(gcd_list(dist_numbers))

Measured memory_bytes: 14480
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
//DEBUG 
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define all(v) (v).begin(), (v).end()
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 2e5+5, MOD = 998244353;
int t,n,m,k,x,y;

v32 adj[LIM];
int a[LIM]; 
int ans[LIM];

void dfs(int u,int par,v32 &v){
  int len=v.size();
  int i;
  int prev;
  if(len==0){
    v.pb(a[u]);
    i=0;
  }
  else{
    i=lower_bound(v.begin(),v.end(),a[u])-v.begin();
    if(i==len) v.pb(a[u]);
    else prev=v[i],v[i]=a[u];
  }
  ans[u]=v.size();
  // if(u==10) printint(v);
  for(auto nxt: adj[u]){
    if(nxt!=par) dfs(nxt,u,v);
  }

  //restore the vector
  if(i==len) v.pop_back();
  else v[i]=prev;
}

int32_t main()
{
    IOS;
    cin>>n;
    forn(i,n){
      cin>>a[i+1];
    }
    forn(i,n-1){
      cin>>x>>y;
      adj[x].pb(y);
      adj[y].pb(x);
    }
    v32 v;
    dfs(1,0,v);
    forsn(i,1,n+1) cout<<ans[i]<<ln;
}


Measured memory_bytes: 30404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll n, k;    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n)   cin >> a[i];
    ll res=1;
    rep(i, k) res *= a[i];
    FOR(i, k, n){
        if(a[i-k]<a[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}



Measured memory_bytes: 4840
n=int(input())
a=[]
d={}
e={}
f=1
for i in range(n):
  inp=int(input())
  a.append(inp)
  if not inp in d:
    d[inp]=0
    e[inp]=0
  if f:
    d[inp]+=1
  f=1-f
a.sort()
f=1
for i in a:
  if f:
    e[i]+=1
  f=1-f
c=0
for i in d:
  c+=abs(d[i]-e[i])
print(c//2)

Measured memory_bytes: 103664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    int h,w; cin >> h >> w;
    string a[h];
    rep(i, h) cin >> a[i];
    int l=0;
    rep(i, h+2){
        int k=0;
        rep(j, w+2){
            if(i == 0 || i == h+1){
                cout << '#';
            } else {
                if(j == 0 || j == w+1) cout << '#';
                else{
                    cout << a[l][k];
                    k++;
                }
            }
        }
        if(i != 0 && i != h + 1) l++;
        cout << endl;
    }
}

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

int main(){
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n){
        int a;
        cin >> a;
        mp[a]++;
    }
    
    if(mp.size()%2!=0){
        cout << mp.size() << endl;
    }else{
        cout << mp.size()-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4992
n=parse(Int,readline())
a=div(n,100)
b=n%100
if 0<a<13
	if 0<b<13
		print("AMBIGUOUS")
	else
		print("MMYY")
	end
else
	if 0<b<13
		print("YYMM")
	else
		print("NA")
	end
end


Measured memory_bytes: 107108
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a_b = b_a = 0
for a, b in zip(A, B):
    a_b += max(0, a-b) + max(0, (b-a))%2
    b_a += max(0, (b-a+1)//2)
t = max(a_b, b_a)
#print(t)
if sum(B)-sum(A) >= t:
    print("Yes")
else:
    print("No")


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

using namespace std;
long long n, ans= 0;

int main(){
  cin >> n;
  
  if(n % 2 == 1){
    cout << " 0 " << endl;
    
    return 0;
    
  }
  
  else{
    
    n /= 2;
    
    while(n >= 5){
      
      ans += n / 5;
      n /= 5;
    }
    
    cout << ans << endl;
    
  }
  
}
	

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

class Main {
    static long MOD = (long)Math.pow(10, 9) + 7;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long N = in.nextLong();
        if(N%2 != 0) System.out.println(0);
        else {
            long sum = 0;
            long m = 10;
            while(N/m >= 1) {
                sum += N/m;
                m *= 5;
            }
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(a,n) rep(i,0,n){ cout<<(i ? " ":"")<<a[i]; }cout<<endl;
#define pprint(a,m,n) rep(j,0,m){ print(a[j],n); }
const int mod = 1e9+7;
const int size=1e5;
const int INF=1e9;
int main(){
	string s;cin>>s;
	int ans=s.size();int temp=s.size();
	rep(i,1,s.size()){
		if(s[i]!=s[i-1]) ans=min(ans,max(i,temp-i));
	}cout<<ans<<endl;
}

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

int main(){
  int N;
  cin>>N;
  vector<string>s(N);
  vector<int>t(N);
  for(int i=0;i<N;i++){
    cin>>s[i]>>t[i];
  }
  string x;
  cin>>x;
  int sum=0;
  for(int i=0;i<N;i++){
    if(s[i]==x){
      for(int j=i+1;j<N;j++){
        sum+=t[j];
      }
      cout<<sum<<endl;return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3572
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1L<<60;

void main() {
    long n, s;
    scan(n);
    scan(s);

    if (n == s) {
        writeln(n + 1);
        return;
    }
    if (n < s) {
        writeln(-1);
        return;
    }

    for (long b = 2; b*b <= n; b++) {
        if (digitSum(n, b) == s) {
            writeln(b);
            return;
        }
    }

    long ans = inf;

    for (long p = 1; p*p <= n; p++) {
        long q = s - p;
        if ((n - q) % p == 0) {
            long b = (n - q) / p;
            if (b > 1 && digitSum(n, b) == s) {
                ans = min(ans, b);
            }
        }
    }

    debug {
        if (ans < inf) {
            writefln("%d, %d == %d", ans, digitSum(n, ans), s);
        }
    }

    writeln(ans == inf ? -1 : ans);
}


long digitSum(long n, long b) {
    return n > 0 ? digitSum(n/b, b) + (n % b) : 0;
}











































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <iomanip>
#include <cstring>
#include <cmath>
 
using namespace std;
 
int main() {
    int n, m;
    cin>>n>>m;
    vector<int> v(n, -1);
    for (int i=0;i<m;++i){
        int a, b;
        cin>>a>>b;
        if (v[a-1]!=-1&&v[a-1]!=b){
            cout<<"-1"<<endl;
            return 0;
        }
        v[a-1]=b;
    }
    if (n==1){
        cout<<(v[0]==-1?0:v[0])<<endl;
        return 0;
    }
    if (v[0]==-1){
        v[0]=1;
    } else if (v[0]==0){
        cout<<"-1"<<endl;
            return 0;
    }
    for (int i=0;i<n;++i){
        cout<<(v[i]==-1?0:v[i]);
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
 
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
	ll a,b;	
	cin>>a>>b;
	ll n=gcd(a,b);
	ll ans=0;
	ll cnt=0;
	while(!(n%2))
	{
		n/=2;
		cnt++;
	}	
	if(cnt) ans++;
	for(ll i=3;i*i<=n;i+=2)
	{
		cnt=0;
		while(n%i==0)
		{
			n=n/i;
			cnt++;
		}
		if(cnt) ans++;
	}
	if(n>2) ans++;
	cout<<ans+1<<'\n';
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 3640
#include "bits/stdc++.h"
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	string t = "keyence";
	cin >> s;
	int n = s.size();
	int l=0,r=0;
	while(l<t.size()&&s[l]==t[l]){
		l++;
	}
	while(r<t.size()&&s[n-1-r]==t[6-r]){
		r++;
	}
	if(l+r>=t.size()) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int A,B;
    cin>>A>>B;
    if(A==B)
        cout<<"Draw";
    else if(A==1)
        cout<<"Alice";
    else if(B==1)
        cout<<"Bob";
    else if(A>B)
        cout<<"Alice";
    else if(A<B)
        cout<<"Bob";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define int long long
#define ll long long
#define moder 1000000007
#define INF LLONG_MAX/3
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n;
int a[]={3,5,7};
int func(int a){
	string s;
	while(a){
		s=to_string(a%4)+s;
		a/=4;
	}
	rep(i,s.size()){
		if(s[i]=='0')return INF;
		if(s[i]=='1'){
			s[i]='3';
			continue;
		}
		if(s[i]=='2')s[i]='5';
		if(s[i]=='3')s[i]='7';
	}
	if(s!="")return stoll(s);
	else return 3;
}
bool check(int a){
	string s=to_string(a);
	bool d=false,b=false,c=false;
	rep(i,s.size()){
		if(s[i]=='3')d=true;
		if(s[i]=='5')b=true;
		if(s[i]=='7')c=true;
	}
	return d&b&c;
}
signed main(){
	cin>>n;
	int ans=0;
	for(int i=1;;i++){
		if(func(i)==INF)continue;
		if(n<func(i)){
			cout<<ans<<endl;
			break;
		}
		if(check(func(i)))ans++;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;

int main() {
  ll Q;
  cin >> Q;
  ll ans=0;
  priority_queue<ll> l;
  priority_queue<ll,vector<ll>,greater<ll>> r;
  while(Q--) {
    ll q;
    cin >> q;
    if(q==1) {
      ll a,b;
      cin >> a >> b;
      ans+=b;
      l.push(a);
      r.push(a);
      ll x=l.top();l.pop();
      ll y=r.top();r.pop();
      if(x>y) {
        ans+=x-y;
        ll tmp=x;
        x=y;
        y=tmp;
      }
      l.push(x);
      r.push(y);
    }
    else {
      cout << l.top() << " " << ans << endl;
    }
  }
}

Measured memory_bytes: 4588
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<long long> num(n);
    vector<long long> cnt(n+1,0);
    for(int i =0; i < n; i++){
        cin>>num[i];
        cnt[num[i]]++;
    }
    long long total = 0;
    for(int i = 1; i <= n; i++){
        total = total + cnt[i]*(cnt[i]-1)/2; 
    }
    for(int i = 0; i < n; i++){
        long long temp = total;
        long long z = num[i];
        temp = temp - cnt[z]*(cnt[z]-1)/2+(cnt[z]-1)*(cnt[z]-2)/2;
        cout<<temp<<'\n';
    } 
}

Measured memory_bytes: 5760
#include "stdio.h"
#define N 50

int solve(int m,int digit){
    int i,sum;
    sum=0;
    if (digit==1){
        for (i = 0; i < 10; i++) {
            if(i==m)return 1;
        }
        return 0;
    }
    for (i = 0; i < 10; i++) {
    sum=sum+solve(m-i,digit-1);
    }
    return sum;
}

int main(int argc, char const *argv[]) {
    int n[N],i,j;
    i=0;
    while(scanf("%d",&n[i])!=EOF)i++;
    for (j = 0; j < i; j++) {
        printf("%d\n",solve(n[j],4));
    }
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    int a[N];
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    sort(a,a+N,greater<>());
    int Alice=0;
    int Bob=0;
    for(int i=0; i<N; i++){
        if(i%2==0){
            Alice+=a[i];
        }
        else{
            Bob+=a[i];
        }
    }
    cout << Alice-Bob << endl;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n;
    cin >> n;
    v_int d(n);
    cin >> d;
    sort(d.begin(), d.end());

    int r = n/2;
    int l = (n-1)/2;
    
    int ans;
    if(d[r] == d[l]) {
        ans = 0;
    } else {
        ans = d[r] - d[l];
    }
    cout << ans << endl;
    return 0;
} /*atcoder*/



Measured memory_bytes: 3768
N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))


MAX_V = [0]
for t, v in zip(T, V):
    MAX_V[-1] = min(MAX_V[-1], v)
    for ti in range(t * 2):
        MAX_V.append(v)


N = len(MAX_V)
Feasible_V = [0] * N
for i in range(N - 1):
    Feasible_V[i + 1] = min(Feasible_V[i] + 0.5, MAX_V[i + 1])

Feasible_V[-1] = 0
for i in reversed(range(1, N)):
    Feasible_V[i - 1] = min(Feasible_V[i - 1], Feasible_V[i] + 0.5)


ans = 0
for i in range(N - 1):
    x1, x2 = Feasible_V[i], Feasible_V[i + 1]
    ans += (x1 + x2) * 0.5 / 2

print(ans)


Measured memory_bytes: 3756
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    // 数値の配列を作る
    const numList0 = input[0].split(' ').map(x => parseInt(x, 10));
    const W = numList0[0];
    const H = numList0[1];
    const x = numList0[2];
    const y = numList0[3];

    const menseki = W * H * 0.5;
    var flag = false;
    if (W * 0.5 === x && H * 0.5 === y) {
        flag = true;
    }
    const resultFlagText = flag ? '1' : '0';
    console.log(menseki + ' ' + resultFlagText);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
MAX_V = 100100
MAX_N = 101
INF = pow(2, 70)

N, W = map(int, input().split())
w = [0 for _ in range(N)]
v = [0 for _ in range(N)]
for i in range(N):
    w[i], v[i] = map(int, input().split())

dp = [[INF for _ in range(MAX_V)] for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    for sum_v in range(MAX_V):
        # print(i, sum_v, sum_v - v[i] >= 0)
        if sum_v - v[i] >= 0:
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - v[i]] + w[i])
        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])
        # print(dp[i + 1][sum_v])

ans = max([i for i in range(len(dp[N])) if dp[N][i] <= W])
# for l in dp:
#     print([n for n in l if not n == INF])

print(ans)


Measured memory_bytes: 173640
#[allow(unused)]
use std::cmp::{max, min};

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        n: usize,
        l: i64,
    }

    let mut sum = 0;
    let mut taste = 0;
    let mut vec: Vec<i64> = Vec::with_capacity(n);

    for i in 1..n + 1 {
        taste = l - 1 + (i as i64);
        sum += taste;
        vec.push(taste);
    }

    if l - 1 + (n as i64) >= 0 && l <= 0 {
        println!("{}", sum);
    } else if l > 0 {
        println!("{}", sum - vec[0]);
    } else {
        println!("{}", sum - vec[n - 1]);
    }
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
// BEGIN NO SAD

typedef long long ll;
#define rep(i, a, b) for(ll i = a; i < (b); ++i)

void solve(){
  ll N;cin>>N;
  ll A[N];rep(i, 0, N) cin>>A[i];
  ll dp[N];
  dp[0] = 0;dp[1] = abs(A[1]-A[0]);
  rep(i, 2, N){
    dp[i] = min(dp[i-2]+abs(A[i]-A[i-2]), dp[i-1]+abs(A[i]-A[i-1]));
  }
  cout<<dp[N-1];

}

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

  solve();

  return 0;
}


Measured memory_bytes: 1792
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	sum := 0
	for i := 1; i <= n; i++ {
		if i%3 == 0 && i%5 == 0 {
			// fizzbuzz
			continue
		}

		if i%3 == 0 {
			// fizz
			continue
		}

		if i%5 == 0 {
			// buzz
			continue
		}

		sum += i
	}
	fmt.Print(sum)
}


Measured memory_bytes: 1752
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){

int X, N;
cin >> X >> N;
vector<int> table(N);
for (int i = 0; i < N; i++){
    cin >> table.at(i);
}

int sa = 100;
int ans = 0;
bool check = false;

for (int i = -100; i <= 101; i++){
    for (int j = 0; j < N; j++){
        if(i == table.at(j)){
            check = true;
            break;
        }
    }
    if(check == true){  //同じ数字がtable内にあったら
        check = false;
        continue;
    }
    if(abs(i - X) < sa){
        sa = abs(i - X);
        ans = i;
    }

}

cout << ans << endl;

return 0;
}

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

int main() {
    int n, k, q;
    cin >> n >> k >>q;
    vector<pair<int, int>> data(n);
    for (int i = 0; i < n; i++){
        data.at(i) = make_pair(i,k);
    }
    for (int i = 0; i < q; i++){
        int a;
        cin >> a;
        data.at(a-1).second ++;
    }
    for (int i = 0; i < n; i++){
        if(data.at(i).second > q){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1408
#include<iostream>

using namespace std;

int main(){

    int ant[5],k;

    for(int i=0;i<5;i++){
        cin>>ant[i];
    }
    cin>>k;

    for(int i=0;i<5;i++){
        for(int j=1;j<5;j++){
            if(ant[j]-ant[i]>k){
                cout<<":(\n";
                return 0;
            }
        }
    }

    cout<<"Yay!\n";


    return 0;
}

Measured memory_bytes: 256
n = int(input())
S = []
T = []
for _ in range(n):
    s,t = map(str, input().split())
    S.append(s)
    T.append(int(t))

x = input()

for i, s in enumerate(S):
    if s == x:
        ans = sum(T[i+1:])
        break

print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int a,b;cin  >> a >> b;
  rep(i,max(a,b)) cout << min(a,b);
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

const int INF = 1 << 30;
int main(){
    while(true){
        int N;
        cin >> N;

        if(N == 0) break;
        vector<vector<int> > T(N,vector<int>(N+1));
        for(int i=0;i<N;i++){
            for(int j=0;j<N+1;j++){
                cin >> T[i][j];
            }
        }
        int BIT_N = 1 << N;

        vector<int> DP(BIT_N,INF);
        DP[0] = 0;

        for(int S=0;S<BIT_N;S++){
            if(DP[S] == INF) continue;
            for(int next=0;next<N;next++){
                if(!(S & (1 << next))){
                    int mi = DP[S] + T[next][0];
                    for(int j=0;j<N;j++){
                        if(S & (1 << (j))){
                            mi = min(mi,DP[S] + T[next][j+1]);
                        }
                    }
                    DP[S | (1 << next)] = min(DP[S | (1 << next)],mi);
                }
            }
        }
        cout << DP[(1 << N) -1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1476
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod = 1e9+7;
int a[200001],b[200001];
ll f[200001],g[200001];
int n;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int m=0; 
    for(int i=1;i<=n;i++) 
        if(i==0 || a[i]!=a[i-1]){
            m++; 
            b[m]=a[i];
        }
    n=m; 
    for(int i=1;i<=n;i++)
        a[i]=b[i];
    f[0]=1ll;
    g[a[1]]=1ll;
    for(int i=1;i<=n;i++){
        f[i]=g[a[i]];
        g[a[i+1]]=(g[a[i+1]]+f[i])%mod;
    }
    printf("%lld\n",f[n]);
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

static const int MAX = 100;

int N, A[MAX];

void output(void)
{
	for(int i=0;i<N;i++){
		cout << A[i];
		if (i < N-1) cout << " ";
	}
	cout << endl;
	return;
}

int main(void)
{
	int temp, j;
	cin >> N;
	for (int i=0;i<N;i++) cin >> A[i];
	output();
	for(int i=1;i<N;i++){
		temp = A[i];
		j = i - 1;
		while(j >= 0 && A[j] > temp){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = temp;
		output();
	}
	return 0;
}

Measured memory_bytes: 1164
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

void bomb(int, int, int a[8][8]);

int main()
{
	int i, j, k, n, x, y, a[8][8], buf;

	scanf("%d", &n);

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

		for(j=0; j<8; j++){
			scanf("%d", &buf);
			for(k=0; k<8; k++){
				if(buf % 10 == 0)
					a[j][7-k] = 0;
				else
					a[j][7-k] = 1;
				buf = buf / 10;
			}
		}

		scanf("%d%d", &x, &y);

		bomb(x-1, y-1, a);

		printf("Data %d:\n", i);

		for(j=0; j<8; j++){
			for(k=0; k<8; k++){
				printf("%d", a[j][k]);
			}
			printf("\n");
		}

	}

	return 0;

}

void bomb(int x, int y, int a[8][8])
{
	int i;

	if((x<0 || x>7) || (y<0 || y>7) || a[y][x] == 0)
		return;
	else {
		a[y][x] = 0;
		for(i=x-3; i<=x+3; i++)
			bomb(i, y, a);
		for(i=y-3; i<=y+3; i++)
			bomb(x, i, a);
	}
	return;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=520;

int K,n;

int col[maxn][maxn];

inline void doing()
{
	K=read();
	if(K<=500)
	{
		n=K;
		printf("%d\n",n);
		REP(i,1,n)
		{
			REP(j,1,n)printf("%d ",i);
			puts("");
		}
	}
	else
	{
		n=500;
		printf("%d\n",n);
		REP(i,1,n)
		{
			REP(j,1,n)
			{
				int col=(j-i+n-1)%n+1;
				if(col+n<=K)
				{
					printf("%d ",i&1?col:col+n);
				}else printf("%d ",col);
			}
			puts("");
		}
	}
}

int main()
{
	doing();
	return 0;
}


Measured memory_bytes: 1152
import math        # factorical（階乗) # hypot(距離)
# import heapq
# from fractions import gcd # Python3.5以前 # lcm（最小公倍数） = (a*b)//gcd(a,b)
# from fractions import Fraction
# from math import gcd # Python3.6以降
# --------------------------------------------------------------

a,b,x = map(int,input().split())

if x*2 <= a*a*b:
    print(math.degrees(math.atan(a*b*b/(2*x))))
else:
    print(math.degrees(math.atan((a*a*b-x)*2/(a**3))))


Measured memory_bytes: 9216
def my_eval(ar,str):
    res = True
    n = len(str)
    # print(n)
    # print("start")
    for i in range(n):
        # print(i)

        if(ar[str[i][0]] == 1):
            # print(str[i][0])
            # print(str[i][1])
            # print(str[i][2])
            # print(ar[str[i][1]-1])
            # print(ar[str[i][1]-1] == str[i][2])
            # print(ar)
            # print()
            if(ar[str[i][1]] != str[i][2]):
                res = False
    # print("end")
    # print()
    return res

if __name__ == "__main__":

    # 全探索
    n = int(input())
    str = []
    for i in range(n):
        a = int(input())

        for j in range(a):
            x = list(map(int,input().split()))
            x.insert(0,i+1)
            str.append(x)
    ar = [0] * (n+1)
    res = 0
    # print(str)
    count = 0
    for i in range(2**n):
        count = 0
        for j  in range(n):
            if(i >> j & 1 == 1):
                ar[j+1] = 1
                count += 1
            else:
                ar[j+1] = 0
        # print(ar)
        if(my_eval(ar,str)):
            res = max(res,count)
    print(res)



Measured memory_bytes: 9200
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
//        int a = int.Parse(input[2]);
//        int b = int.Parse(input[3]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
//        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
        string ko = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        for(int i=0;i<n;i++){
            string[] temp = ReadLine().Split(' ');
            for(int j=0;j<m;j++){
                if(temp[j] == "snuke"){
                    WriteLine("{0}{1}",ko[j],i+1);
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 13140
#include<stdio.h>

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

	if (a==b && a!=c) printf("Yes\n");
	else if (a==c && a!=b) printf("Yes\n");
	else if (b==c && a!=b) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128