akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100009
#define MAXM 320
#define EPS 1e-9
#define MOD 1000000007
#define INF 1000000009
#define FOR(x,n) for(int x=0; x<n; x++)
#define FOR1e(x,n) for(int x=1; x<=n; x++)
#define pb push_back
#define all(x) x.begin(), x.end()
typedef long long ll;

int arr[20];
ll pd[20][1 << 16];

ll fexp(ll a, ll b, ll mod) {
	ll ans = 1;
	while (b > 0) {
		if (b&1) { ans = (ans*a) % mod; }
		a = (a*a)%mod;
		b >>= 1;
	}
	return ans;
}

ll fac[1 << 20], finv[1 << 20];

ll choose(ll a, ll b) {
	return (fac[a] * finv[a-b]) % MOD * finv[b] % MOD;
}

int main() {
	int n, m;
	fac[0] = 1; finv[0] = 1;
	for (int i = 1; i < (1 << 20); i++) {
		fac[i] = fac[i-1]*i % MOD;
		finv[i] = fexp(fac[i], MOD-2, MOD);
	}

	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d", &arr[i]);
	}

	pd[m][0] = 1;
	for (int i = m-1; i >= 0; i--) {
		for (int mask = 0; mask < (1 << n); mask++) {
			pd[i][mask] = pd[i+1][mask];
			for (int j = 0; j < n; j++) {
				if ((1 << j)&mask) {
					int rem = (1 << n) - arr[i] - (mask^(1 << j));
					if (rem >= (1 << j)-1) {
						pd[i][mask] += (pd[i+1][mask^(1 << j)]*choose(rem, (1 << j)-1)) % MOD * fac[1 << j] % MOD;
						pd[i][mask] %= MOD;
					}
				}
			}
		}
	}

	ll ans = 0;
	for (int mask = 0; mask < (1 << n); mask++) {
		if (__builtin_popcount(mask)%2) {
			ans -= (pd[0][mask]*fac[(1 << n) - mask - 1])%MOD;
			ans = (ans + MOD)%MOD;
		} else {
			ans += (pd[0][mask]*fac[(1 << n) - mask - 1])%MOD;
			ans %= MOD;
		}
	}

	ans = ans*(1 << n);
	ans %= MOD;
	printf("%lld\n", ans);
}

Measured memory_bytes: 26880
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
#define ll long long
#define maxn 100010
#define inf 0x3f3f3f3f
inline ll read()
{
    ll x=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    return x*f;
}
inline void write(ll x)
{
    static int buf[20],len; len=0;
    if(x<0)x=-x,putchar('-');
    for(;x;x/=10)buf[len++]=x%10;
    if(!len)putchar('0');
    else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
struct edge{
	int to,nxt;
}e[2*maxn];
int fir[maxn],a[maxn],b[maxn],c[maxn],id[maxn],fa[maxn],mark[maxn];
ll f[maxn],size[maxn];
std::vector<int>son[maxn];
int n,m,tot=0;
bool cmp(int x,int y){return c[x]<c[y];}
inline void add_edge(int x,int y){e[tot].to=y; e[tot].nxt=fir[x]; fir[x]=tot++;}
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
void dp(int now)
{
	size[now]=b[now];
	for(int i:son[now]){
		dp(i);
		size[now]+=size[i];
	}
	f[now]=(son[now].size()?1ll<<60:c[now]+b[now]);
	for(int i:son[now]){
		f[now]=std::min(f[now],std::max((ll)c[now],f[i])+size[now]-size[i]);
		// printf("%d -> %d : %lld %lld\n",now,i,std::max((ll)c[now],f[i]),size[now]-size[i]);
	}
}
int main()
{
	n=read(); m=read();
	for(int i=1;i<=n;i++)
		a[i]=read(),b[i]=read(),c[i]=std::max(a[i]-b[i],0);
	memset(fir,255,sizeof(fir)); tot=0;
	for(int i=1;i<=m;i++){
		int x=read(),y=read();
		add_edge(x,y); add_edge(y,x);
	}
	for(int i=1;i<=n;i++)
		fa[i]=i,id[i]=i;
	std::sort(id+1,id+n+1,cmp);
	for(int i=1;i<=n;i++){
		mark[id[i]]=1;
		for(int j=fir[id[i]];~j;j=e[j].nxt)
			if(mark[e[j].to]){
				int fx=find(id[i]),fy=find(e[j].to);
				if(fx!=fy){
					fa[fy]=fx;
					son[id[i]].push_back(fy);
				}
			}
	}
	dp(id[n]);
	writeln(f[id[n]]);
	// for(int i=1;i<=n;i++)
	// 	writesp(id[i]);
	// putchar('\n');
	// for(int i=1;i<=n;i++){
	// 	printf("%d : ",i);
	// 	for(int j:son[i])
	// 		writesp(j);
	// 	putchar('\n');
	// }
	// for(int i=1;i<=n;i++)
	// 	printf("%d %d %d %d %lld %lld\n",i,a[i],b[i],c[i],size[i],f[i]);
	return 0;
}

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

bool prime[1000005];


int dp[100][100];


int f(int a, int b) {
	if (a == 0) {
		return 0;
	}
	if (b > a) 
		return 0;
	if (dp[a][b] != -1) return dp[a][b];
	return dp[a][b] = max(f(a,b+1), f(a-b, b+1)+1);
}

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

	int64_t N;
	cin >> N;

	fill(prime, prime+1000005, 1);
	prime[0] = prime[1] = 0;

	for (int64_t p = 2; p <= 1000000; ++p) if (prime[p]) {
		for (int64_t m = p*p; m <= 1000000; m += p) {
			prime[m] = 0;
		}
	}

	memset(dp, -1, sizeof dp);

	map<int, int> facts;

	int64_t num = N;

	for (int64_t p = 2; p*p <= N; ++p) if (prime[p]) {
		// cout << num << " " << p << endl;
		while (num%p == 0) {
			num /= p;
			facts[p]++;
		}
		// if (num <= 1000000 && prime[num]) {
		// 	facts[num]++;
		// 	break;
		// }
	}

	if (num > 1) {
		facts[num]++;
	}

	// cout << "here" << endl;

	int64_t ans = 0;

	for (auto kv : facts) {
		// cout << kv.first << " " << kv.second << " " << f(kv.second, 1) << endl;
		ans += f(kv.second, 1);
	}

	cout << ans << endl;

}

Measured memory_bytes: 4668
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap

def c(A, S):
    a = 0
    for i, j in combinations_with_replacement(range(len(A)), r=2):
        if S == sum(A[i:j+1]):
            a += 1
    return a

@mt
def slv(N, K, S):
    m = S+1 if S < 10**9 else S-1
    A = [S] * K + [m] * (N-K)
    # assert c(A, S) == K
    return ' '.join(map(str, A))


def main():
    N, K, S = read_int_n()
    print(slv(N, K, S))

    # while True:
    #     N = random.randint(1, 10)
    #     K = random.randint(0, N)
    #     S = random.randint(1, 100)
    #     print(N, K, S)
    #     print(slv(N, K, S))




if __name__ == '__main__':
    main()


Measured memory_bytes: 14388
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
using namespace std;

vector<vector<int>>M;

int solve(int k) {
	vector<int>num;
	num.push_back(0);
	for (int i = 0; i < M[k].size(); i++) {
		num.push_back(solve(M[k][i]));
	}
	sort(num.begin(), num.end(),greater<int>());
	int Mx = 0;
	for (int i = 0; i < M[k].size(); i++) {
		num[i] += i + 1;
		Mx = max(Mx, num[i]);
	}
	return Mx;
}

int main()
{
	int n; cin >> n;
	M.resize(n + 1);
	for (int i = 1; i < n; i++) {
		int a; cin >> a;
		M[a].push_back(i+1);
	}

	cout << solve(1) << endl;

    return 0;
}


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

int main() {
int n;
string s;
cin >> n >>s;
int ans =0;
int che =0;
for(int i=0;i<n;i++){
    if(s.at(i)=='I')ans++;
    else ans--;
    che = max(ans,che);
}
cout << che << endl;
}





Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    bool flag=false;
    if(a%3==0) flag = true;
    if(b%3==0) flag = true;
    if((a+b)%3==0) flag = true;
    if(flag) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
def sign(s):
    if len(s)==1:
        return s
    elif s=="AA":
        return "B"
    elif s in ["AB", "BA"]:
        return ""
    elif s=="BB":
        return "A"

def diff(a, b):
    if b=="":
        return a
    elif b==a:
        return ""
    elif a=="":
        if b=="A":
            return "B"
        elif b=="B":
            return "A"
    else:
        return b

a = ""
Sn = [""]
for s in S:
    a = sign(a+s)
    Sn.append(a)
a = ""
Tn = [""]
for t in T:
    a = sign(a+t)
    Tn.append(a)

q = int(input())
for i in range(q):
    a, b, c, d = map(int, input().split())
    if diff(Sn[b], Sn[a-1]) == diff(Tn[d], Tn[c-1]):
        print("YES")
    else:
        print("NO")



Measured memory_bytes: 5228
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n, m;
	cin >> n;
	string *s = new string[n];
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
	}
	cin >> m;
	string *t = new string[m];
	for (int j = 0; j < m; ++j) {
		cin >> t[j];
	}
	int zero = 0;
	int max = 0;
	for (int i = 0; i < n; ++i) {
		int value = 0;
		for (int j = i; j < n; ++j) {
			if (s[j] == s[i]) {
				value++;
			}
		}
		for (int k = 0; k < m; ++k) {
			if (t[k] == s[i]) {
				value--;
			}
		}
		if (value > max) {
			max = value;
		}
	}
	if (max > zero) {
		cout << max;
	}
	else {
		cout << zero;
	}
	delete[] s;
	delete[] t;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		String S = sc.next();
		List<String> list = new ArrayList<String>();
		for (int i = 0; i < S.length(); i++) {
			String s = String.valueOf(S.charAt(i));
			list.add(s);
		}
		boolean flg = false;
		for (int i = 0; i < list.size(); i++) {
			String str = list.get(i);
			int cnt = 0;
			for (int j = 0; j < list.size(); j++) {
				if (str.equals(list.get(j))) {
					cnt++;
				}
			}
			if (cnt == 2) {
				flg = true;
			} else {
				flg = false;
				break;
			}
		}

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

	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 21204
import math
n, m =map(int, input().split())
num = 0
if abs(n-m) >= 2:
	print (0)
	exit()
if n == m:
	num = math.factorial(n) * math.factorial(n) * 2
else:
	num = math.factorial(n) * math.factorial(m)
print (num % 1000000007)	

Measured memory_bytes: 5180
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder out=new StringBuilder();
		String str;
		int q=0;
		while((str=br.readLine()).equals("-")==false){
			StringBuilder sb=new StringBuilder();
			sb.append(str);
			q=str.length();
			int n=Integer.parseInt(br.readLine());
			int p;
			for(int i=0;i<n;i++){
				p=Integer.parseInt(br.readLine());
				sb.append(sb.substring(0,p));
				sb.delete(0,p);
			}
			out.append(sb+"\n");
		}
		 // 最後にマッチしたインデックス(最後の改行)を取得
        int index = out.lastIndexOf("\n");
         
        // インデクスを指定して削除して表示
        out.deleteCharAt(index);
        System.out.println(out);
	}
}

Measured memory_bytes: 16884
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N, K, A[101010];

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> A[i];
    if (N == K) {
        cout << 1 << endl;
        return 0;
    }

    int idx = 0;
    for (int i = 0; i < N; ++i)
        if (A[idx] > A[i]) idx = i;

    int li = (idx + K-2) / (K-1);
    int ri = ((N-1) - li * (K-1) + (K-2)) / (K-1);
    int ans = li + ri;

    idx = N-1 - idx;
    li = (idx + K-2) / (K-1);
    ri = ((N-1) - li * (K-1) + (K-2)) / (K-1);
    ans = min(ans, li + ri);

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


Measured memory_bytes: 640
import java.io.*;
import java.util.Scanner;
    
class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws IOException {
        int a = ReadInt();
        int b = ReadInt();
        System.out.print(a * b + " " + (a + b) * 2 + "\n");
    }
    static int ReadInt() throws IOException {
        return Integer.parseInt(sc.next());
    }
}

Measured memory_bytes: 25996
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    public static void Main()
    {
        var line = Console.ReadLine();

        int a = int.Parse(line.Substring(0, 2));
        int b = int.Parse(line.Substring(2));


        if ((0 == a || (12 < a && a <= 99)) && (1 <= b && b <= 12))
        {
            Console.WriteLine("YYMM");
        }
        else if ((0 == b || (12 < b && b <= 99)) && (1 <= a && a <= 12))
        {
            Console.WriteLine("MMYY");
        }
        else if ((1 <= a && a <= 12) && (1 <= b && b <= 12))
        {
            Console.WriteLine("AMBIGUOUS");
        }
        else if(99 < a || 99 < b || (0 == a || ((12 < a && a <= 99)) && (0 == b || (12 < b && b <= 99))))
        {
            Console.WriteLine("NA");
        }
    }
}




Measured memory_bytes: 11092
#include<iostream>
using namespace std;
int main(){
  int x,y;
  
  while(1){
    cin >> x >> y;
    if(x == 0 && y == 0) break;

    else if (x > y) cout << y << " " << x << endl;
    else  {
      cout << x << " " <<y << endl;
    }

  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(){
  int s;
  cin>>s;
  int w[1000001];
  for(int j=1;j<=1000000;j++){
  for(int i=1;i<=1000000;i++){
    if(i==1){
      w[i]=s;
    }
    else{
      if(w[i-1]%2==0){
        w[i]=w[i-1]/2;
      }
      else{
        w[i]=w[i-1]*3+1;
      }
    }
    if(w[i]==w[j]&&i!=j){
      cout<<max(i,j)<<endl;
      return 0;
    }
  }
  }
}

Measured memory_bytes: 4096
import Data.Char

main = do
  n <- getLine

  print $ maximum $ map (sum . map (\c -> ord c - ord '0')) (solve [] n)

  where
    solve pre [] = [pre]
    solve pre (x:xs) = (pre ++ (chr (ord x - 1) : map (const '9') xs)) : solve (pre++[x])xs


Measured memory_bytes: 508
def main():
    N = int(input())
    a = list(map(int, input().split()))
    
    ans = {i:0 for i in range(1,N+1)}
    for i in a:
        ans[i] += 1
    for i in ans.values():
        print(i)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 38804
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
long long ans,a,b,c=100;
string s;int n;
int main()
{
	cin>>a>>s;
	n=s.length();
	for(int i=0;i<n;++i)
	  if(s[i]>=48&&s[i]<=57)b=b*10+s[i]-48;
	cout<<a*b/c;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  if (n % 2) {
    cout << "No" << endl;
    return 0;
  }
  bool can = true;
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[i + n / 2]) can = false;
  }
  if (can) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

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

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

vector<int> x, y;
vector<char> d;
int n;

ld calc(ld time)
{
	ld xmin = 1e18, ymin = 1e18;
	ld xmax = -1e18, ymax = -1e18;
	for (int i = 0; i < n; ++i)
	{
		ld cx = x[i];
		ld cy = y[i];
		switch (d[i])
		{
		case 'R':
			cx += time;
			break;
		case 'L':
			cx -= time;
			break;
		case 'U':
			cy += time;
			break;
		case 'D':
			cy -= time;
			break;
		}
		xmin = min(xmin, cx);
		xmax = max(xmax, cx);
		ymin = min(ymin, cy);
		ymax = max(ymax, cy);
	}
	return (xmax - xmin) * (ymax - ymin);
}

ld ternary_search(ld low, ld high)
{
	for (int i = 0; i <= 500; ++i)
	{
		ld m1 = (low * 2 + high) / 3;
		ld m2 = (low + 2 * high) / 3;
		if (calc(m1) < calc(m2))
			high = m2;
		else
			low = m1;
	}
	return calc(low);
}

void solve()
{
	cin >> n;
	x.resize(n);
	y.resize(n);
	d.resize(n);
	for (int i = 0; i < n; ++i)
		cin >> x[i] >> y[i] >> d[i];
	cout << fixed << setprecision(12) << ternary_search(0, 2e8) << '\n';
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, l;
    cin >> n >> l;
    vector<string> s(n);
    vector<vector<int>> trie(1, vector<int>(2));
    vector<int> depth(1);
    vector<ll> t;
    rep(i, 0, n) {
        cin >> s[i];
        int pos = 0;
        rep(j, 0, s[i].size()) {
            if (trie[pos][s[i][j] - '0'] == 0) {
                trie.emplace_back(vector<int>(2));
                depth.emplace_back(depth[pos] + 1);
                pos = trie[pos][s[i][j] - '0'] = trie.size() - 1;
            } else {
                pos = trie[pos][s[i][j] - '0'];
            }
        }
    }
    debug(trie, depth);
    rep(i, 0, trie.size()) {
        if (trie[i][0] != 0 && trie[i][1] != 0) continue;
        if (trie[i][0] == 0 && trie[i][1] == 0) continue;
        t.emplace_back(l - depth[i]);
    }
    debug(t);
    ll g = 0;
    rep(i, 0, t.size()) {
        ll x = 1;
        while (t[i] % (x * 2) == 0) x *= 2;
        g ^= x;
    }
    if (!g)
        cout << "Bob" << endl;
    else
        cout << "Alice" << endl;
    return 0;
}


Measured memory_bytes: 8112
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>
#include <stack>
#include <iomanip>

using namespace std;
#define REP(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

#define MOD (1'000'000'000+7)

bool _less(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
}

double dp[3000][3000];

int main() {
    int N;
    cin >> N;
    vector<double> p(N+1);
    REP(i, 1, N+1) {
        cin >> p[i];
    }
    
    dp[0][0] = 1.0;
    REP(i, 1, N+1) {
        dp[i][0] = dp[i-1][0]*(1-p[i]);
        REP(j, 1, i+1) {
            dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]);
        }
    }
    
    double sum = 0.0;
    REP(i, N/2+1, N+1) {
        sum += dp[N][i];
    }
    cout << setprecision(10) << sum << endl;

}


Measured memory_bytes: 68992
#include <stdio.h>

int main()
{
	int n, m, s=0;
	
	scanf("%d", &n);
	
	m = n;
	while(m){
		s += m%10;
		m /= 10;
	}
	
	if(n%s == 0) printf("Yes");
	else printf("No");
	
	return 0;
}

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

#define make_it_fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}

template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}

void _print() {cerr << "]\n";}

template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...) 20
#endif

ll power(ll a,ll b,ll m=1e9+7)
{
    a%=m;
    if(b==1)
    return a;
    if(b==0)
    return 1;
    ll ret=power(a,b/2);
    ret=(ret%m*ret%m)%m;
    if(b&1)
    ret=(ret%m*a%m)%m;
    return ret;
}

ll lcm(ll a,ll b)
{
    return (a*b)/(__gcd(a,b));
}

const ll N=1e3+5,M=1e9+7;
ll dp[N][N];
char a[N][N];

void update(ll n,ll m)
{
    if(n==0 || m==0)
    return;
    int i;
    for(i=n;i>=1;i--)
    {
        if(a[i][m]=='#')
        continue;

        if(a[i+1][m]!='#')
        dp[i][m]+=dp[i+1][m];

        if(a[i][m+1]!='#')
        dp[i][m]+=dp[i][m+1];

        dp[i][m]%=M;
    }
    for(i=m-1;i>=1;i--)
    {
        if(a[n][i]=='#')
        continue;

        if(a[n][i+1]!='#')
        dp[n][i]+=dp[n][i+1];

        if(a[n+1][i]!='#')
        dp[n][i]+=dp[n+1][i];

        dp[n][i]%=M;
    }
    update(n-1,m-1);
}

void solve()
{
    ll n,m,i,j;
    cin>>n>>m;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cin>>a[i][j];
        }
    }
    memset(dp,0,sizeof(dp));
    dp[n][m]=1;
    for(i=n-1;i>=1;i--)
    {
        if(a[i][m]!='#')
        dp[i][m]=dp[i+1][m];
    }
    for(i=m-1;i>=1;i--)
    {
        if(a[n][i]!='#')
        dp[n][i]=dp[n][i+1];
    }
    update(n-1,m-1);
    // for(i=1;i<=n;i++)
    // {
    //     for(j=1;j<=m;j++)
    //     cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    cout<<dp[1][1]<<endl;
}

int main()
{
    make_it_fast;
    int TEST_CASES=1;
    // cin>>TEST_CASES;
    while(TEST_CASES--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 12448
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
P dp[111][111111];
int n,x;

void MAX(P &a,P b){
    if(b.second>=1e9)return ;
    if(a.first<b.first)a=b;
    else if(a.first==b.first&&a.second>b.second)a=b;
}


signed main(){
    while(cin>>n,n){
        P ans=P(0,1e9);
        r(i,111)r(j,111111)dp[i][j]=P(0,1e9);
        dp[0][0]=P(0,0);
        r(i,n){
            cin>>x;
            int a=((x%1000)?(x%1000):1000);
            r(j,100000){
                int A=dp[i][j].first;
                int B=dp[i][j].second;
                MAX(dp[i+1][j],dp[i][j]);
                if(a<=500)MAX(dp[i+1][j+500-a],P(A+1,B+x));
                else{
                    int b=((a%500)?(a%500):500);
                    MAX(dp[i+1][j+1000-a],P(A,B+x));
                    if(b<=j)MAX(dp[i+1][j-b],P(A+1,B+x));
                }
            }
        }
        r(i,111111)MAX(ans,dp[n][i]);
        cout<<ans.first<<' '<<ans.second<<endl;
    }
}


Measured memory_bytes: 99464
n=int(input())
a=list(map(int,input().split()))
snuke,arai=a[0],sum(a)-a[0]
ans=abs(snuke-arai)
for i in range(1,n-1):
    snuke+=a[i]
    arai-=a[i]
    ans=min(ans,abs(snuke-arai))
print(ans)

Measured memory_bytes: 30592
# ABC091b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
s = dict()
for _ in range(n):
    i = input()[:-1]
    if (s.get(i) == None):
        s[i] = 1
    else:
        s[i] += 1
m = int(input())
for _ in range(m):
    i = input()[:-1]
    if (s.get(i) == None):
        s[i] = -1
    else:
        s[i] -= 1
print(max(max(s.values()), 0))

Measured memory_bytes: 3064
N, K = map(int, input().split())
p = list(map(int, input().split()))
for i in range(N):
    p[i] = p[i] / 2 + 0.5

s = 0
for i in range(K):
    s += p[i]
maxSum = s
j = 0

for i in range(K, N):
    s = s + p[i] - p[i-K]
    maxSum = max(maxSum, s)
print(maxSum)

Measured memory_bytes: 32048
# -*- coding: utf-8 -*-
"""
D - Cake 123
https://atcoder.jp/contests/abc123/tasks/abc123_d
AC
"""
import sys

def solve(X, Y, Z, K, A, B, C):
    # 解説の解法#2
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)
    res = []
    for i, a in enumerate(A, start=1):
        for j, b in enumerate(B, start=1):
            for k, c in enumerate(C, start=1):
                if i*j*k > K:
                    break
                res.append(a+b+c)
    return sorted(res, reverse=True)[:K]


def main(args):
    X, Y, Z, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    C = [int(c) for c in input().split()]
    ans = solve(X, Y, Z, K, A, B, C)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])


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

int main() 
{
    int m = 0, f = 0, r = 0;                                    //中間:m 期末:f 再試:r

    while( cin >> m >> f >> r )
    {
        if( m == -1 && f == -1 && r == -1 )                     //全て-1なら終了
            break;
        
        int sum = m + f;                                        //sum = 中間+期末

        if( m == -1 || f == -1 )
            cout << 'F' << endl;
        
        else if( sum >= 80 )
            cout << 'A' << endl;

        else if( sum >= 65 )
            cout << 'B' << endl;   

        else if( sum >= 50 )
            cout << 'C' << endl;        

        else if( sum >= 30 )
        {
            if( r >= 50)
                cout << 'C' << endl;
            else
                cout << 'D' << endl;
        }

        else
            cout << 'F' << endl;
    }

    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
ll mod= 1e9 + 7;

int main() {
  string s;
  cin >> s;
  rep(i,3){
    if(s[i]==s[i+1]){cout << "Bad" << endl; return 0;}
  }
  cout << "Good" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int p(int i){return i/2;}
int l(int i){return i*2;}
int r(int i){return i*2+1;}
int main(){
  int h,a[300];
  cin >> h;
  for(int i=1;i<=h;i++)cin >> a[i];
  for(int i=1;i<=h;i++){
    cout << "node " << i << ": key = " << a[i] << ", ";
    if(p(i)>=1)cout << "parent key = " << a[p(i)]<<", ";
    if(l(i)<=h)cout << "left key = " << a[l(i)] << ", ";
    if(r(i)<=h)cout << "right key = " << a[r(i)] << ", ";
    cout << endl;
  }
}

  

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

using i64 = int64_t;

constexpr i64 INF = (1ll<<31) - 1;

template <typename T, typename E>
class SegmentTree {
  private:
    int n;
    vector<T> node;
    const function<T (T, T)> query_func;
    const function<T (T, E)> update_func;
    const T identity;

  public:

    SegmentTree() = default;

    SegmentTree(int size, function<T(T, T)> query_func,
                function<T(T, E)> update_func, T identity,
                vector<T> v = vector<T>())
            : query_func(query_func), update_func(update_func), identity(identity) {
        n = 1;
        while(n < size) n *= 2;
        node.resize(2*n-1, identity);
        if(size == v.size()) build(size, v);
    }

    void build(int size, vector<T> v) {
        for(int i=0;i<size;++i) node[i+n-1] = v[i];
        for(int i=n-2;i>=0;--i) node[i] = query_func(node[2*i+1], node[2*i+2]);
    }

    void update(int x, E val) {
        x += n - 1;

        node[x] = update_func(node[x], val);
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = query_func(node[2*x+1], node[2*x+2]);
        }
    }

    T query(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;

        if(r <= a || b <= l) return identity;

        if(a <= l && r <= b) return node[k];

        int vl = query(a, b, 2*k+1, l, (l+r)/2);
        int vr = query(a, b, 2*k+2, (l+r)/2, r);
        return query_func(vl, vr);
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    SegmentTree<i64, i64> st(n,
        [](i64 a, i64 b){return min(a, b);},
        [](i64 a, i64 b){return b;},
        INF
    );
    for(int i=0;i<q;++i){
        int com, x, y;
        cin >> com >> x >> y;
        if(com == 0){
            st.update(x, y);
        }else{
            cout << st.query(x, y+1) << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 4852
#include <iostream>
#include <assert.h>
#include <vector>
#include <map>


bool dfs(int32_t node, std::vector<std::vector<int32_t>>& graph,
        std::vector<bool>& visiting, int32_t& numVisit, std::pair<int32_t, int32_t>& rem_edge) {
  if (visiting[node]) {
    return false;
  }
  visiting[node] = true;
  numVisit++;
  if (numVisit == (int32_t)graph.size()) {
    return true;
  } else {
    for (auto next : graph[node]) {
      if ((rem_edge.first == node && rem_edge.second == next) ||
          (rem_edge.first == next && rem_edge.second == node)) {
        continue;
      }
      if (dfs(next, graph, visiting, numVisit, rem_edge)) return true;
    }
  }
  return false;
}

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

  int32_t N, M;
  std::cin >> N >> M;
  std::vector<std::vector<int32_t>> graph(N);
  std::vector<std::pair<int32_t, int32_t>> edges(M);
  for (int32_t i = 0; i < M; i++) {
    int32_t a,b;
    std::cin >> a >> b;
    graph[a-1].emplace_back(b-1);
    graph[b-1].emplace_back(a-1);
    edges[i] = std::make_pair(a-1,b-1);
  }

  int32_t res = 0;
  for(int32_t i = 0; i < M; i++) {
    std::vector<bool> visiting(N,false);
    int32_t numVisit = 0;
    std::pair<int32_t, int32_t> rem_edge = edges[i];
    if (!dfs(0, graph, visiting, numVisit, rem_edge)) {
      res++;
    }
  }
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 256
import math
import sys
sys.setrecursionlimit(10000)
H, W = map(int, input().split())
S = []
for i in range(H):
  S.append(str(input()))
  
def main(l, d, cnt):
  tmp = []
  for n in l:
    i, j = n[0], n[1]
    if (0<i) and (S[i-1][j] == '.'):
      if d[i-1][j] > d[i][j]+1:
        d[i-1][j] = d[i][j]+1
        tmp.append([i-1, j])
    if (i<H-1) and (S[i+1][j] == '.'):
      if d[i+1][j] > d[i][j]+1:
        d[i+1][j] = d[i][j]+1
        tmp.append([i+1, j])
    if (0<j) and (S[i][j-1] == '.'):
      if d[i][j-1] > d[i][j]+1:
        d[i][j-1] = d[i][j]+1
        tmp.append([i, j-1])
    if (j<W-1) and (S[i][j+1] == '.'):
      if d[i][j+1] > d[i][j]+1:
        d[i][j+1] = d[i][j]+1
        tmp.append([i, j+1])
  if tmp == []:
    return cnt
  else:
    cnt += 1
    return main(tmp, d, cnt)
  
ans = 0
for i in range(H):
  for j in range(W):
    if S[i][j] == '.':
      d = [[float('inf') for i in range(W)] for j in range(H)]
      d[i][j] = 0
      cnt = main([[i, j]], d, 0)
      ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 9228
//
// Created by rajshah9914 on 29/03/20.
//


#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
double p[100000];
for(int i=0;i<n;i++)
{
    cin>>p[i];
}
double ans=0;
double dp[n+2][n+2];
memset(dp,0,sizeof(dp));
dp[0][0]=1;
dp[0][1]=0;
//// dp[i][j]= i coins tossed....j heads....i-j tails;
for(int i=1;i<=n;i++)
{
    for(int j=0;j<=i;j++)
    {
        if(j>0)
            dp[i][j]+=dp[i-1][j-1]*p[i-1];
        dp[i][j]+=dp[i-1][j]*(1-p[i-1]);
         ////    i coins tossed....j heads....i-j tails;
    }
}
//for(int i=1;i<=n;i++)
//{
//    for(int j=0;j<=i;j++)
//        cout<<dp[i][j]<<" ";
//    cout<<endl;
//}
for(int i=0;i<=n;i++)
{
    if(i>n-i)
    ans+=dp[n][i];
}
cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 70656
#include<stdio.h>
 
  int a,i;
  float j=0;
  float n;
int main(void)
{scanf("%d",&a);
 
for(i=0;i<=a;i++){
  	if(i%2==1){
    	j++;
    	}
}
 n=j/a;
printf("%f",n);
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[5100];
int L[5100][5100];
int R[5100][5100];
int sum[5100];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
	}
	L[0][0]=R[a][0]=1;
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			if(L[i][j]){
				L[i+1][j]=1;
				if(j+p[i]<b)L[i+1][j+p[i]]=1;
			}
		}
	}
	for(int i=a;i>=0;i--){
		for(int j=0;j<b;j++){
			if(R[i][j]){
				R[i-1][j]=1;
				if(j+p[i-1]<b)R[i-1][j+p[i-1]]=1;
			}
		}
	}
	int ret=0;
	for(int i=0;i<a;i++){
		if(p[i]>=b)continue;
		for(int j=0;j<=b;j++)sum[j]=0;
		for(int j=0;j<b;j++){
			sum[j+1]=sum[j]+R[i+1][j];
		}
		bool ok=true;
		for(int j=0;j<b;j++){
			if(!L[i][j])continue;
			int left=max(0,b-p[i]-j);
			int right=b-j;
			if(sum[right]!=sum[left]){
				ok=false;break;
			}
		}
		if(ok)ret++;
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 202880
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebug(multimap<T1, T2> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mdebugr(map<T1, T2, greater<T1>> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebugr(multimap<T1, T2, greater<T1>> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


struct Pair {
    ll x, y, z;
    Pair(ll x, ll y, ll z):x(x),y(y),z(z){};
};

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

    int n, m;
    vector<Pair> xyz;
    ll x, y, z;
    cin >> n >> m;
    rep(i, n){
        cin >> x >> y >> z;
        xyz.push_back(Pair(x, y, z));
    }

    ll max = -inf;
    for(int bit=0; bit < (1<<3); bit++){
        vector<ll> sums;
        for(auto const& e : xyz){
            ll sum = 0;
            if(bit & (1<<0)) sum += -e.x;
            else sum += e.x;
            if(bit & (1<<1)) sum += -e.y;
            else sum += e.y;
            if(bit & (1<<2)) sum += -e.z;
            else sum += e.z;
            sums.push_back(sum);
        }

        //vdebug(sums);

        sort(all(sums), greater<ll>());

        ll sum = 0;
        rep(i, m){
            sum += sums[i];
        }
        chmax(max, sum);
    }

    cout << max << endl;

    return 0;
}


Measured memory_bytes: 256
// WARNING: Add compile option "-std=c++11" for C++11 compile.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

// Macro
#define REP(i, N) for(int i=0; i<(int)N; i++)
#define REPR(i, N) for(int i=(int)N-1; i>=0; i--)
#define mp make_pair
#define pb push_back

// Type
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;

// Constants
const ll MOD = 1000000007;

/**
  型に合わせたINFを返す
  int: 214,748,364 (2.14 * 1e8)
  ll : 922,337,203,685,477,580 (9.22 * 1e17)
*/
template <typename T>
T getINF() {
  // NOTE: INF同士を足してもオーバーフロー起こさないように、10で割っている
  return numeric_limits<T>::max() / 10;
}

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

bool isMM(char m1, char m2) {
  return (m1 == '0' && m2 != '0') || ((m1 == '1') && (m2 == '0' || m2 == '1' || m2 == '2'));
}

int main() {
  string s;
  cin >> s;

  bool yymm = isMM(s[2], s[3]);
  bool mmyy = isMM(s[0], s[1]);

  if(yymm && mmyy) cout << "AMBIGUOUS" << endl;
  else if(!yymm && !mmyy) cout << "NA" << endl;
  else if(yymm && !mmyy) cout << "YYMM" << endl;
  else cout << "MMYY" << endl;

  return 0;
}

Measured memory_bytes: 256
Imports System.Console
Module Module1
    Sub Main()
        Dim n As Integer = ReadLine()
        Dim ans As Int64
        Dim y As Int64
        For i = 1 To n
            y = n \ i
            ans += i * (y + 1) * y / 2
        Next
        WriteLine(ans)
    End Sub
End Module


Measured memory_bytes: 28304
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
#define fi first
#define se second
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    int n;cin>>n;
    vec h(n);
    rep(i,n) cin>>h[i];

    int res=0;

    while(true){
        if(*max_element(all(h)) == 0) break;
        int i=0;
        while(i<n){
            if(h[i] == 0) i++;
            else{
                res++;
                while(h[i]>0 && i<n){
                    h[i]--;
                    i++;
                }
            }
        }
    }

    cout<<res<<endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
  
 
int main(){
     int N;
     cin >> N;
     int X;
     cin >> X;
     int d = 0;
     int ans = 1;
     for(int i=0;i<N;i+=1){
          int x;
          cin >> x;
          // cout << x << endl;
          
          d += x;
          if(d<=X){
               ans+=1;
          }
          
     }
     cout << ans << endl;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>
using namespace std;
#define rep(i, m, n) for (int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for (int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
using Edge = pair<int, long long>;
using Graph = vector<vector<Edge>>;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef vector<vector<vector<ll>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
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;
}
// ~~~~~~~~~~~~~~memo~~~~~~~~~~~~~~
// for (int i = 0; i < n; ++i)
// vector<long long> v(n), c(n);
// cout << res << endl;
// cout << res << '\n';
// int型の2次元配列(h×w要素の)の宣言
// vector<vector<int>> data(h, vector<int>(w));
// rotate(s.begin(), s.begin() + 1, s.end());
// sort(all(a),greater<int>());
// s.substr(0,2) 先頭から2文字切り出す
// for (auto it = mp.rbegin();it != mp.rend(); ++it)
long long gcd(long long x, long long y) {
    return y ? gcd(y, x%y) : x;
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    ll a,b;
    cin >> a >> b;
    ll g = gcd(a,b);
    auto pf = prime_factorize(g);
    cout << pf.size()+1 << '\n';
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<stdio.h>

using namespace std;

int main(void)

{
    int a, b, c;
    scanf("%d%d", &a, &b);
    c = 6-a-b;
    if(c<0){
        c *= (-1);
    }
    printf("%d\n", c);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N, X;
  cin >> N >> X;
  vector<int> L;
  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    L.push_back(a);
  }
  int D = 0;
  int ans = 1;
  for (int i = 0; i < N; i++)
  {
    D = D + L.at(i);
    if (X >= D)
    {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n, k;
    cin >> n >> k;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;

        if (h >= k) ans++;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 888
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <iostream>
using namespace std;
char s[10];
int a[10];
char vis[10];

int f(int i, int j, int k){
	int ans = 0;
	int t = 0;
	if (i == 1){
		vis[++t] = '+';
		ans = a[1] + a[2];
	}
	else {
		vis[++t] = '-';
		ans = a[1] - a[2];
	}
	if (j == 1){
		vis[++t] = '+';
		ans = ans + a[3]; 
	}
	else{
		vis[++t] = '-';
		ans = ans - a[3];
	}
	if (k == 1){
		vis[++t] = '+';
		ans = ans + a[4];
	}
	else {
		vis[++t] = '-';
		ans = ans - a[4];
	}
	return ans;
}



int main()
{
	scanf("%s", s + 1);
	for (int i = 1; i <= 4; i++){
		a[i] = s[i] - '0';
	}
/*	for (int i = 1; i <= 4; i++)
		cout <<a[i];
	cout <<endl;*/
	int flag = 0;
	for (int i = 1; i <= 2; i++)
		for (int j = 1; j <= 2; j++)
			for (int k = 1; k <= 2; k++){
				if (!flag)
					if (7 == f(i, j, k)){
						flag = 1;
						break;
					}
			}
	printf("%d%c%d%c%d%c%d=7\n", a[1], vis[1], a[2], vis[2], a[3], vis[3], a[4]);  
}

Measured memory_bytes: 256