akhauriyash/Code-Regression huggingface dataset:
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <stdio.h>
#include <bitset>
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int h, w, k;
	cin >> h >> w >> k;
	char* c[h];
	rep(i, h) {
		c[i] = (char*)malloc(w * sizeof(char));
		rep(j, w){
			cin >> c[i][j];
		}
	}
	
	int ans = 0;
	rep(hv, 1 << h){
		rep(wv , 1 << w){
			int count = 0;
			rep(i, h)rep(j,w){
				//0なら見ない
				if(!(hv>>i & 1)) continue;
				if(!(wv>>j & 1)) continue;
				if(c[i][j] =='#') count++;
			}
			if(count == k) ans++;
		}
	}
	
	cout << ans << endl;
	
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>
int main()
{
	int n,i,k,j,a[3000],t=0,sum=0;
	while(scanf("%d",&n)!=EOF)
	{for(i=0;i<n;i++)
	{scanf("%d",&a[i]);
	sum+=a[i];}
	printf("%d\n",sum-n);}
	return 0;
}

Measured memory_bytes: 128
n = int(input())
w = [input() for _ in range(n)]

t = w[0][-1]
for i in range(1,n):
  if w[i][0] != t:
    print("No")
    break
  t = w[i][-1]
else:
  if n == len(set(w)): print("Yes")
  else: print("No")

Measured memory_bytes: 9092
x = input()
t = 0
s = 0
cnt = 0
i=0
while t<len(x)//2:
    if x[i]=='S':
        s+=1
    if x[i]=='T':
        if s>0:
            cnt+=2
            s-=1
        t+=1
    i+=1
print(len(x)-cnt)

Measured memory_bytes: 3500
# From: https://github.com/cheran-senthil/PyRival/blob/master/pyrival/data_structures/SegmentTree.py
class SegmentTree:
    def __init__(self, data, default=0, func=max):
        """initialize the segment tree with data"""
        self._default = default
        self._func = func
        self._len = len(data)
        self._size = _size = 1 << (self._len - 1).bit_length()

        self.data = [default] * (2 * _size)
        self.data[_size : _size + self._len] = data
        for i in reversed(range(_size)):
            self.data[i] = func(self.data[i + i], self.data[i + i + 1])

    def __delitem__(self, idx):
        self[idx] = self._default

    def __getitem__(self, idx):
        return self.data[idx + self._size]

    def __setitem__(self, idx, value):
        idx += self._size
        self.data[idx] = value
        idx >>= 1
        while idx:
            self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
            idx >>= 1

    def __len__(self):
        return self._len

    def query(self, start, stop):
        """func of data[start, stop)"""
        start += self._size
        stop += self._size

        res_left = res_right = self._default
        while start < stop:
            if start & 1:
                res_left = self._func(res_left, self.data[start])
                start += 1
            if stop & 1:
                stop -= 1
                res_right = self._func(self.data[stop], res_right)
            start >>= 1
            stop >>= 1

        return self._func(res_left, res_right)

    def __repr__(self):
        return "SegmentTree({0})".format(self.data)


import io
import os
from collections import defaultdict


def solve(N, Q, C, LR):
    # Bucket sort queries by right endpoint
    LByR = defaultdict(list)
    for i, (l, r) in enumerate(LR):
        LByR[r].append((i, l))

    # Segment tree stores a 1 at position i if the ith element is the rightmost of its dupes
    segTree = SegmentTree([0] * (N + 1), 0, lambda x, y: x + y)
    lastSeen = {}
    ans = [0] * Q
    for r, x in enumerate(C):
        if x in lastSeen:
            # Clear the previous rightmost bit
            segTree[lastSeen[x]] -= 1
        # Add a new rightmost bit
        segTree[r] += 1
        lastSeen[x] = r

        for queryIndex, l in LByR[r]:
            ans[queryIndex] = segTree.query(l, r + 1)

    return "\n".join(map(str, ans))


if __name__ == "__main__":
    input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

    N, Q = [int(x) for x in input().split()]
    C = [int(x) for x in input().split()]
    # 0-indexed, inclusive inclusive
    LR = [[int(x) - 1 for x in input().split()] for i in range(Q)]
    print(solve(N, Q, C, LR))


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

int main(){
    int h, w, l, i, j;
    for(l = 0; ;l++){
        scanf("%d %d", &h, &w);
        if(h == 0 && w == 0) break;
        for(i = 0; i < w; i++) cout << "#";
        cout << endl;
        for(i = 0; i < h - 2; i++){
            cout << "#";
            for(j = 0; j < w - 2; j++) cout << ".";
            cout << "#" << endl;
        }
        for(i = 0; i < w; i++) cout << "#";
        cout << endl;
        cout << endl;
    }
}


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

int main()
{
    // 入力
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i = 0; i < N; i++) cin >> L[i];
    // 棒の高さをソート
    sort(L.begin(), L.end());
    // 組み合わせの個数をカウント
    long long cnt = 0;
    // L[i] : 候補の中で一番長い棒
    for(int i = N-1; i >= 2; i--)
    {
        // L[j] : 候補の中で二番に長い棒
        for(int j = i-1; j >= 1; j--)
        {
            // L[k] : それ以外の棒
            for(int k = j-1; k >= 0; k--)
            {
                // 条件を満たすか判定
                if(L[i] < L[j]+L[k]) cnt++;
                else break; // ダメだったらそれより短いものもダメだからbreak
            }
        }
    }
    // 解を出力
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	vector<int> s;
	int tmp;
	int i = 1;
	cin >> tmp;
	s.push_back(tmp);
	do{
		i++;
		if(s.back()%2){
			s.push_back(3*s.back()+1);
		}else{
			s.push_back(s.back()/2);
		}
		rep(j,0,s.size()-1){
			if(s[j] == s.back()){
				goto end;
			}
		}
	}while(1);
end:
	cout << i << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<string.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------


int main(){
    char b;
    cin >> b;
    char x[4] = {'A', 'C', 'G', 'T'};
    char y[4] = {'T', 'G', 'C', 'A'};
    for(int i = 0; i < 4; i++){
        if(b == x[i]) cout << y[i] << endl;
    }

}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

string delete_pair(string s){
    string ret;
    for(char c : s){
        if(ret.empty()){
            ret.push_back(c);
            continue;
        }
        if(ret.back() == '(' && c == ')'){
            ret.pop_back();
            continue;
        }
        ret.push_back(c);
    }
    return ret;
}

signed main(){
    int n;
    string s;
    cin >> n >> s;
    string t = delete_pair(s);
    
    for(char &c : t){
        c = (c == ')' ? '(' :')');
    }
    
    int b = (int) t.length();
    rep(i, t.length()){
        if(t[i] == ')'){
            b = i; break;
        }
    }
    string ans = t.substr(0,b) + s + t.substr(b);
    cout << ans << endl;
}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


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

  if(s.substr(5,2)=="01"||s.substr(5,2)=="02"
    ||s.substr(5,2)=="03"||s.substr(5,2)=="04"){
      cout<<"Heisei"<<endl;
    }else{
      cout<<"TBD"<<endl;
    }

return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int fa[maxn];
int rk[maxn];
int sz[maxn];
int find(int x){
    return fa[x]==x? x:fa[x]=find(fa[x]);
}
void init(int n){rep(i,1,n)fa[i]=i,rk[i]=0;}
void unite(int x,int y){
    int xx=find(x),yy=find(y);
    if(xx==yy)return;
    fa[xx]=yy;
}
void uniteRk(int x,int y){
    int xx=find(x),yy=find(y);
    if(xx==yy)return;
    if(rk[xx]<rk[yy])fa[xx]=yy;
    else{
        fa[yy]=xx;
        if(rk[xx]==rk[yy])rk[xx]++;
    }
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,q;
    cin>>n>>q;
    init(n);
    rep(i,1,q){
        int x,y,op;
        cin>>op>>x>>y;
        x++,y++;
        if(!op)uniteRk(x,y);
        else cout<<(find(x)==find(y))<<endl;
    }
}
/* 
5 12
0 1 4
0 2 3
1 1 2
1 3 4
1 1 4
1 3 2
0 1 3
1 2 4
1 3 0
0 0 4
1 0 2
1 3 0
 */


Measured memory_bytes: 3304
#include <stdio.h>
#include <string.h>

char str[100005];

int isUnb(char *p);
int f(char *p);

int main()
{
	int length;

	scanf("%s", str);

	length = strlen(str);
	for (int i = 0; i < length - 1; i++) {
		if (f(str + i)) {
			printf("%d %d\n", i + 1, i + 2);
			return 0;
		}
		if (isUnb(str + i)) {
			printf("%d %d\n", i + 1, i + 3);
			return 0;
		}
	}

	printf("-1 -1\n");

	return 0;
}

int isUnb(char *p)
{
	if (p[0] == p[1] || p[0] == p[2] || p[1] == p[2]) {
		return 1;
	} else {
		return 0;
	}
}

int f(char *p)
{
	if (p[0] == p[1]) {
		return 1;
	} else {
		return 0;
	}
}


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

using namespace std;
int main()
{
    int x,n;
    cin>>x>>n;
    vector<int>v;
    for(int i=0;i<n;i++)
    {
        int k;
        cin>>k;
        v.push_back(k);
    }
    int in=0;
    while(1)
    {

        auto it=find(v.begin(),v.end(),x-in);
        if(it==v.end())
        {
            cout<<x-in<<endl;
            break;
        }
        it=find(v.begin(),v.end(),x+in);
        if(it==v.end())
        {
            cout<<x+in<<endl;
            break;
        }
        in++;

    }
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(){
  int N;
  int count;
  int a;
  int i;
  cin >> N;
  for(i=0;i<N;i++){
    cin >> a;
    if(a%2==1){
      count++;
    }
  }
  if(count%2==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	var s, t string

	fmt.Scanf("%d", &n)
	if n < 1 || n > 100 {
		return
	}

	fmt.Scanf("%s %s", &s, &t)
	if len(s) != n || len(t) != n {
		return
	}

	ss := strings.Split(s, "")
	st := strings.Split(t, "")

	var ans string
	for i := 0; i < n; i++ {
		ans += ss[i] + st[i]
	}
	fmt.Printf("%s\n", ans)
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
using namespace std;
int Bsearch(int n,int e){
  if(e==1)return 1;
  int s,t;
  s=0;t=e;
  int x=e/2;
  while(t-s>1){
    if(pow(x,n)<e){
      s=x;
    }else if(pow(x,n)>e){
      t=x;
    }else{
      break;
    }
    x=(s+t)/2;
  }
  return x;
}
 
int main(){
  int e;
  while(cin>>e){
    if(e==0)break;
    int x=Bsearch(3,e);
    int y=Bsearch(2,e);
    int minim=1000;
    for(int i=0;i<=x;i++){
      int z=pow(i,3);
      for(int j=0;j<=y;j++){
	int x=e-z-j*j;
	if(x<0)break;
	minim=min(minim,i+j+x);
      }
    }
    cout << minim << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
N, M =map(int, input().split())
L = [0 for i in range(N+1)]
R = [0 for i in range(N+1)]
for i in range(M):
    l,r = map(int, input().split())
    L[l] += 1
    R[r] += 1
cnt = 0
tmp = 0
for i in range(N+1):
    tmp += L[i]
    if tmp == M:
        cnt += 1
    tmp -= R[i]
print(cnt)


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

using namespace std;

int main(void){
    long long X;
    cin >> X;
    long long sum = 100;
    int ans;
    for(int i = 0; i < 5000; i++)
    {
        sum = sum + sum/100;
        if(sum >= X)
        {
            ans = i+1;
            break;
        }
    }
printf("%d\n",ans);
    
}

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

int main() {

    vector<int> Input(5);
    for (int i = 0; i < 5; ++i) {
        cin >> Input.at(i);
    }
    int finalans = INT_MAX;
    do{
        int ans = 0;
        for (int i = 0; i < 5; ++i) {
            ans += Input.at(i);
            if(i == 4) break;
            for (int j = 0; j < 10; ++j) {
                if(ans %10 == 0){
                    break;
                } else{
                    ans++;
                }
            }
        }
        finalans = min(finalans,ans);
    }while (next_permutation(Input.begin(),Input.end()));
    cout << finalans;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
#define MOD 1000000007
/*
void dijkstra(vector<vector<pair<ll,int>>> &graph, vll &dist, int s){
    priority_queue<pair<ll,int>> que;
    dist[s]=0;
    que.push({0,s});
    while(!que.empty()){
        auto x=que.top(); que.pop();
        if(dist[x.second]<x.first) continue;
        for(auto v:graph[x.second]){
            if(dist[v.second]<dist[x.second]+v.first) continue;
            dist[v.second]=dist[x.second]+v.first;
            que.push({dist[v.second],v.second});
        }
    } 
}
*/

void bfs(vector<vector<pair<ll,int>>> &graph, vll &dist, int s){
    queue<pair<ll,int>> que;
    dist[s]=0;
    que.push({0,s});
    while(!que.empty()){
        auto x=que.front(); que.pop();
        for(auto v:graph[x.second]){
            if(dist[v.second]!=-1) continue;
            dist[v.second]=dist[x.second]+v.first;
            que.push({dist[v.second],v.second});
        }       
    }
}

int main(){
    int n;
    cin >> n;
    vector<vector<pair<ll,int>>> graph(n);
    rep(i,n-1){
        int a,b;
        ll c;
        cin >> a >> b >> c;
        a--; b--;
        graph[a].push_back({c,b});
        graph[b].push_back({c,a});
    }    
    vll dist(n,-1);
    int q,k;
    cin >> q >> k; k--;
    //dijkstra(graph,dist,k);
    bfs(graph,dist,k);
    rep(i,q){
        int x,y;
        cin >> x >> y;
        x--; y--;
        cout << dist[x]+dist[y] << endl;
    }



}

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

using namespace std;

int main() {
  int a, b, count = 0;
  cin >> a >> b;
  for (int i = a; i < b + 1; i++) {
    if (to_string(i)[0] == to_string(i)[4] && to_string(i)[1] == to_string(i)[3]) count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;

int main(){
    int N, M;
    cin >> N >> M;
    int ans = (N+M)*(N+M-1)/2 - (N*M);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
const int maxn = 200005;
const int mod = 1e9 + 7;
const int INF = 0x7f7f7f7f;

inline int read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int n, x, y, ans = 1, sum;
int Size[maxn], fact[maxn], inv[maxn];
int c[maxn], w[maxn];
struct Edge { int to, nxt; } p[maxn << 3];
int minpos[maxn], minval[maxn];
bool used[maxn];

int cnt, head[maxn];
inline void addedge(reg int u, reg int v) {
    p[++cnt].to = v, p[cnt].nxt = head[u], head[u] = cnt;
    p[++cnt].to = u, p[cnt].nxt = head[v], head[v] = cnt;
}

inline void dfs(reg int u) {
    used[u] = true;
    for (reg int i = head[u]; i; i = p[i].nxt)
        if (!used[p[i].to]) dfs(p[i].to);
}

inline void build_same() {
    for (reg int i = 1; i <= n; i++)
        if (i != minpos[c[i]] && w[i] + minval[c[i]] <= x) addedge(i, minpos[c[i]]);
}

inline void build_diff() {
    int First, Second, FirstVal = INF, SecondVal = INF;
    for (reg int i = 1; i <= n; i++)
        if (w[i] < FirstVal) FirstVal = w[i], First = i;
    for (reg int i = 1; i <= n; i++)
        if (w[i] < SecondVal && c[i] != c[First]) SecondVal = w[i], Second = i;
    for (reg int i = 1; i <= n; i++) {
        if (i == First) continue;
        if (c[i] != c[First] && w[i] + w[First] <= y) addedge(i, First);
        if (SecondVal != INF && c[i] != c[Second] && w[i] + w[Second] <= y) addedge(i, Second);
    }
    dfs(First);
}

inline int mod_pow(reg int a, reg int b) {
    reg int ans = 1;
    while (b) {
        if (b & 1) ans = 1LL * ans * a % mod;
        b >>= 1, a = 1LL * a * a % mod;
    }
    return ans;
}

inline int calc(reg int x, reg int y) {
    return 1LL * fact[x] * inv[y] % mod * inv[x - y] % mod;
}

inline void init() {
    memset(minval, 0x7f, sizeof(minval));
    fact[0] = 1; for (reg int i = 1; i < maxn; i++) fact[i] = 1LL * fact[i - 1] * i % mod;
    inv[maxn - 1] = mod_pow(fact[maxn - 1], mod - 2);
    for (reg int i = maxn - 2; i >= 0; i--) inv[i] = 1LL * inv[i + 1] * (1LL * i + 1LL) % mod;
}

int main() {
    ios::sync_with_stdio(false);
    n = read(), x = read(), y = read(), init();
    for (reg int i = 1; i <= n; i++) {
        c[i] = read(), w[i] = read();
        if (minval[c[i]] > w[i]) minval[c[i]] = w[i], minpos[c[i]] = i;
    }
    build_same(), build_diff();
    for (reg int i = 1; i <= n; i++)
        if (used[i]) Size[c[i]]++;
    for (reg int i = 1; i <= n; i++) sum += Size[i];
    for (reg int i = 1; i <= n; i++)
        if (Size[i]) ans = 1LL * ans * calc(sum, Size[i]) % mod, sum -= Size[i];
    printf("%d\n", ans);
    return 0;
}


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

int main(){
    cout.precision(16);
    cout.setf(ios::fixed);
    
    int N; cin >> N;
    vector<double> X(N), Y(N);
    for(int i=0; i<N; i++)
        cin >> X[i] >> Y[i];
    
    bool ok = true;
    for(int i=0; i<N/2; i++){
        int dx = X[i+1] - X[i] + X[(i+1+N/2)%N] - X[i+N/2];
        int dy = Y[i+1] - Y[i] + Y[(i+1+N/2)%N] - Y[i+N/2];
        if(dx != 0 || dy != 0)
            ok = false;
    }
    
    if(ok){
        cout << (X[0]+X[N/2])/2 << " " << (Y[0]+Y[N/2])/2 << endl;;
    }else{
        cout << "NA" << endl;
    }
    
    return 0;
}

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

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  ll input(n);
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  vector<ll> ans(a);
  sort(ans.begin(), ans.end());
  ll cnt = 0;
  REP(i, n) {
    cnt += !(a[i] == ans[i]);
  }

  if (cnt == 0 || cnt == 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3628
N = list(input())
m = list(map(int,N))
a = 10*m[0] + m[1]
b = 10*m[2] + m[3]
 
if 1<=a<=12 and 1<=b<=12:
  print("AMBIGUOUS")
elif 1<=a<=12:
  print("MMYY")
elif 1<=b<=12:
  print("YYMM")
else:
  print("NA")

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

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

    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        sc.close();

        if((A-B) >= C) {
            System.out.println(0);
        }
        else {
            System.out.println(C-(A-B));
        }
    }
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1)/b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

int nmax=200000; // 2*(10^5)
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;

    int answ=0;
    int anss=0;
    double noudo=-1;
    
    for(int i=0;i<=3000;i+=a*100){
        for(int j=0;j<=3000;j+=b*100){
            for(int k=0;k<=1000;k+=c){
                for(int l=0;l<=1000;l+=d){
                    if(i==0&&j==0&&k==0&&l==0) continue;
                    double water=i+j;
                    double suger=k+l;
                    if(suger*100>water*e) continue;
                    if(water+suger>f) continue;
                    double memo=100*suger/(suger+water);
                    if(chmax(noudo,memo)){
                        answ=water+suger;
                        anss=suger;
                    }
                }
            }
        }
    }
    cout<<answ SP anss <<endl;
}

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

typedef long long int ll;

// #define mod (int) 998244353
// #define MOD (int) 1e9+7
// // Big two primes
// #define X 1001100011100001111ll
// #define all(a) a.begin(),a.end()
// #define for0(i, n) for (int i = 0; i < n; i++)
// #define for1(i, n) for (int i = 1; i <= n; i++)
// #define loop(i,a,b) for (int i = a; i < b; i++)
// #define bloop(i,a,b) for (int i = a ; i>=b;i--)
// #define tc(t) int t; cin >> t; while (t--)
// //#define int long long
// #define ll long long
// #define pb emplace_back
// #define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
// #define in(x) scanf("%d", &x)
// #define rr return 0
// #define prec(n) fixed<<setprecision(n)
// #define maxpq priority_queue<int>
// #define minpq priority_queue<int, vector<int>, greater<int> >
// #define inf (int)(1e18)
// #define ini(a, i) memset(a, i, sizeof(a))
// #define vi vector<int>
// #define fi first
// #define se second
// #define endl "\n"
// #define ii pair<int, int>
// #define vii vector<ii>
// #define sz(s) s.size()

ll dp[3001][3001];//dp[i][j]-value taken by first player minus value taken by the second player in range[i,j]. 

int main(){
    int n,i,l,r;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(l=n-1;l>=0;l--){
        for(r=l;r<n;r++){
            if(r==l)
                dp[l][r]=a[l];
            else{
                dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1]);
            }    
        }
    }
    cout<<dp[0][n-1]<<endl;
    return 0;
}

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

minabs = 10e9+1
totalsum = 0
flag = 1 #0あり：2,偶数：1,不可（バツ奇数）：-1
for a in A:
  absa = abs(a)
  #あとでsumを再度計算しなくて済むよう、先に計算
  totalsum += absa
  #絶対値が最小のものの絶対値をminabsに入れる
  if absa < minabs: minabs = absa
  #0ならオール可が決定
  if a == 0:
    flag = 2
  elif a < 0:
    flag *= -1
    

    
print(totalsum if (flag == 1) or (flag == 2) else totalsum - (minabs*2))

Measured memory_bytes: 14252
import string


def main():
    """
    abcdefghijklmnopqrstuvwxyz
    zyxwvutsrqponmlkjihgfedcba
    """
    S = input()

    az = string.ascii_lowercase
    za = az[::-1]
    if len(S) < len(az):
        # 全文字使ってない
        s_s = set(S)
        s_az = set(az)
        a = sorted(list(s_az - s_s))[0]

        # S=abのとき、abc < ac==True なので追加で良い
        ans = S + a
        print(ans)
        return

    editorial(S)

def editorial(S):
    for i in range(1, 26)[::-1]:
        if S[i-1] > S[i]:
            continue

        # 逆sort済みの途中で辞書順になった
        # 逆sortの中で辞書順小さいもので置き換えて、辞書順最小にする
        suffix = S[i:]
        p_1 = S[i-1]
        for q in sorted(suffix):
            if q > p_1:
                ans = S[:i-1] + q
                print(ans)
                return
    print(-1)

if __name__ == '__main__':
    main()


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

#define MOD 1000000007

long long plus_mod(long long x, long long y, long long mod)
{
    return (x + y) % mod;
}

long long inv_mod(long long x, long long mod)
{
    long long y = mod;
    long long u = 1;
    long long v = 0;
    while (y)
    {
        long long t = x / y;
        x -= t * y;
        swap(x, y);
        u -= t * v;
        swap(u, v);
    }
    u %= mod;
    if (u < 0)
        u += mod;
    return u;
}

long long mul_mod(long long x, long long y, long long mod)
{
    return (x * y) % mod;
}

long long calcCombination(long long x, long long y, vector<long long> &func_memo, vector<long long> &func_inv_memo, long long mod)
{
    if (x < y)
    {
        return 0;
    }

    if ((x - y) < y)
    {
        y = x - y;
    }

    long long ans = 1;
    ans *= func_memo[x];
    ans %= mod;
    ans *= func_inv_memo[y];
    ans %= mod;
    ans *= func_inv_memo[x - y];
    ans %= mod;
    return ans;
}

int main()
{
    long long H, W, A, B;
    cin >> H >> W >> A >> B;

    vector<long long> func_memo(200000, 1);
    for (int i = 1; i < 200000; i++)
    {
        func_memo[i] = mul_mod(func_memo[i - 1], i, MOD);
    }

    vector<long long> func_inv_memo(200000, inv_mod(func_memo.back(), MOD));
    for (int i = 200000 - 2; i >= 0; i--)
    {
        func_inv_memo[i] = mul_mod(func_inv_memo[i + 1], i + 1, MOD);
    }

    long long ans = 0;
    for (int i = B; i < W; i++)
    {
        ans = plus_mod(
            ans,
            mul_mod(
                calcCombination((H - A - 1) + i, H - A - 1, func_memo, func_inv_memo, MOD),
                calcCombination((A - 1) + (W - i - 1), A - 1, func_memo, func_inv_memo, MOD), MOD),
            MOD);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
N,K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))

A = sorted(A)[::-1]
F = sorted(F)

sumA = sum(A)

if sumA <= K:
    print(0)
else:
    maxC = 0
    for i in range(N):
        tmp = A[i]*F[i]
        if maxC < tmp:
            maxC = tmp
    L = 0
    R = maxC
    visited = {}
    visited[maxC]=True
        
    while 1:
        nowC = (L+R)//2
        nowA = []
        for i in range(N):
            nowA.append(nowC//F[i])
        shugyou = 0
        for i in range(N):
            shugyou += max(A[i]-nowA[i],0)
        if shugyou <= K:
            visited[nowC] = True
            R = nowC
            if (nowC-1) in visited:
                if visited[nowC-1] == False:
                    ans = nowC
                    break
        else:
            visited[nowC] = False
            L = nowC
            if (nowC+1) in visited:
                if visited[nowC+1] == True:
                    ans = nowC+1
                    break
                
        if nowC == 0:
            if visited[nowC]==True:
                ans = 0
                break
    print(ans)

Measured memory_bytes: 137412
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main() {
	int w, h, x, y, r;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

	int rx = x + r;
	int lx = x - r;
	int uy = y + r;
	int dy = y - r;

	if (lx < 0 || w < rx || dy < 0 || h < uy) {
		printf("No\n");
	} else {
		printf("Yes\n");
	}

	return 0;
}

Measured memory_bytes: 580
//https://atcoder.jp/contests/agc004/tasks/agc004_b
//AtCoder Grand Contest 004 B - Colorful Slimes
#include<bits/stdc++.h>
using namespace std;
long N,x,a[2000][2000],ans;//a[魔法を唱えられる回数i][スライムの色j]は魔法をi回以下唱えたときにスライムjを得るための最小時間
int main(){
  cin>>N>>x;
  for(int i=0;i<N;ans+=a[0][i++])cin>>a[0][i];//このfor文が終了するとansはaの合計値でこれは魔法を0回唱えたときに相当する
  for(int i=1;i<N;i++){//iは魔法を唱えられる回数
    long s=i*x;//魔法を唱えるのに必要な合計時間
    for(int j=0;j<N;s+=a[i][++j%N])a[i][(j+1)%N]=min(a[i-1][(j+1)%N],a[i-1][j]);//二次元の表を書くと意味がわかりやすい
    ans=min(ans,s);
  }
  cout<<ans<<endl;
}
/*
学んだこと
- 変数を固定して考えること。魔法を唱える回数をkとして固定したとき、スライムiを得るには色i,i-1,i-2,...,i-kのスライムのうちa_iが最小の
  スライムを捕まえればいいこと。そうすると、全色のスライムを手に入れるには合計でkx+¥sigma_1^{N}min{a_i,a_{i-1},...,a_{i-k}}
- 色jに対して幅i+1での最小値を計算するには二次元の表を使えること
*/


Measured memory_bytes: 31488
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds; 
using namespace std;



typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
 
 
//defines
typedef long long ll;
typedef long double ld;

ll a,b,c,n,m,k,t=1;

void solve()
{
 cin>>n>>m;
 vector<ll>v(n);
 for(ll i=0;i<n;i++)cin>>v[i];
 ll sum=0;
 sort(v.begin(),v.end());
 for(ll i=0;i<m;i++)sum+=v[i];
 cout<<sum;
 if(t>0)cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

 // cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 3680
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

//
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;
}
//

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

  int n, k;
  string s;
  cin >> n >> k >> s;
  int res = 0;
  rep(i, n - 1) {
    if (s[i] == s[i + 1]) res++;
  }

  cout << min(n - 1, res + k * 2) << endl;

  return 0;
}

Measured memory_bytes: 512
//https://atcoder.jp/contests/abc144/tasks/abc144_d
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
using ld=long double;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-2.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ld a,b,x; cin>>a>>b>>x;
    dump(a*a*b);
    {
		ld t = (2 * a * a * b - 2 * x) / (a * a);
		if(b - t < 0) {
			ld t2 = 2 * x / (b * a);
			ld at = b/ t2;
			ld rad = atan(at);
            //ld rad2=atan2(t2,b);
		    ld deg = rad * 180.0 / M_PI;
			cout << fixed << std::setprecision(10) << deg << endl;
            return 0;
		}
		dump(t);
		ld at = t / a;
		ld rad = atan(at);
		ld deg = rad * 180.0 / M_PI;
        cout<<fixed<<std::setprecision(10)<<deg<<endl;
	}

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <utility>
#include <string>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ul;

const int iinf = 1 << 29;
const long long linf = 1l << 61;

int N;
int p[100800];

int main(int argc, char* argv[])
{
	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d", &p[i]);

	int ans = 0;
	int j = 0;
	for(int i = 0; i < N; i++)
	{
		if(p[i] == i + 1)
		{
			j++;
		}
		else
		{
			ans += j / 2 + j % 2;
			j = 0;
		}
	}
	ans += j / 2 + j % 2;
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int ans=1e9+7;
	for(int i=0;i<=s.size()-t.size();i++){
		int cnt=0;
		for(int j=i;j<i+t.size();j++){
			if(s[j]!=t[j-i]){
				cnt++;
			}
		}
		ans=min(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n;

int main() {
    cin >> n;
    int ans = 1;
    while ((ans + 1) * (ans + 1) <= n) {
        ans += 1;
    }
    cout << ans * ans << endl;
    return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

template <typename T> // T : type of cost
struct BellmanFord {
    T inf = numeric_limits<T>::max(); // initial value, reused when clear() is called
    int n;                            // number of nodes
    vector<T> dist;                   // distance from start node
    vector<bool> negative;
    struct edge {
        int from, to;
        T cost;
        edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
    };
    vector<edge> edges;

    BellmanFord(int n) : n(n), negative(n, false), dist(n, inf){};
    // 0-indexed!
    void addEdge(int from, int to, T cost) { edges.emplace_back(from, to, cost); }
    // calculate dist[i] as a shortest distance from start to each node
    void build(int start) {
        dist[start] = 0;
        for (int i = 0; i < n; ++i) {
            for (auto &e : edges) {
                if (dist[e.from] != inf && dist[e.to] > dist[e.from] + e.cost) {
                    dist[e.to] = dist[e.from] + e.cost;
                }
            }
        }
    }
    // check whether there are negative loops along the path of interest
    bool has_negativeloop(int end = -1) {
        for (int i = 0; i < n; ++i) {
            for (auto &e : edges) {
                if (dist[e.from] != inf && dist[e.to] > dist[e.from] + e.cost) {
                    dist[e.to] = dist[e.from] + e.cost;
                    negative[e.to] = true;
                }
                if (negative[e.from])
                    negative[e.to] = true;
            }
        }
        if (end != -1)
            return negative[end];
        else {
            bool neg = false;
            for (int i = 0; i < n; ++i) {
                neg |= negative[i];
            }
            return neg;
        }
    }
};

int main() {
    ll n, m, p;
    cin >> n >> m >> p;
    BellmanFord<ll> graph(n);
    vl a(m), b(m), c(m);
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        graph.addEdge(a[i], b[i], p - c[i]);
    }
    graph.build(0);
    if (graph.has_negativeloop(n - 1)) {
        cout << -1 << "\n";
    } else {
        cout << max(0LL, -graph.dist[n - 1]) << "\n";
    }
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    int a; cin >> a;
    int b[(a * 6) + 1];
    for (int i = 1; i <= a * 6; i++) cin >> b[i];
    string q = "CCCCNCCCCNCCCCNCCCCNECCCCEECCCCE";
    for (int i = 0; i < a; i++) {
        for (int o = 0; o < a; o++) {
            if (i == o) break;
            for (int u = 0; u < q.length(); u++) {
                int g = 0;
                if (q[u] == 'N') {
                    int o = b[1]; b[1] = b[2]; b[2] = b[6]; b[6] = b[5]; b[5] = o; 
                } else if (q[u] == 'E') {
                    int o = b[1]; b[1] = b[4]; b[4] = b[6]; b[6] = b[3]; b[3] = o; 
                } else if (q[u] == 'C') {
                    int o = b[2]; b[2] = b[3]; b[3] = b[5]; b[5] = b[4]; b[4] = o;
                }
                for (int p = 1; p <= 6; p++) {
                    if (b[i * 6 + p] == b[o * 6 + p]) g++;
                    if (g == 6) {
                       cout << "No" << endl;
                       return 0;
                    }
                }
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

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

    int c[m];
    rep(i, m)cin >> c[i];

    //dp[i][j] : i種類のコインを使って丁度j円になる最小の枚数
    int dp[m+1][n+1];
    rep(i, m+1)rep(j, n+1)dp[i][j] = INF;
    dp[0][0] = 0;

    rep(i, m)rep(j, n+1){
        dp[i+1][j] = dp[i][j];
        if(c[i] <= j) {
            dp[i+1][j] = min(dp[i+1][j], min(dp[i+1][j-c[i]]+1, dp[i][j-c[i]]+1));
        }
    }

    cout << dp[m][n] << endl;
}


Measured memory_bytes: 7188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    int n;
    cin >> n;
    int ans = 800 * n - 200 * (n / 15);
    cout << ans << endl;
}

Measured memory_bytes: 256
import math
import itertools
input_n = int(input())

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
yakusu_list = divisor(input_n)
yakusu_list.sort()

if (len(yakusu_list) % 2) == 1:
  tmp = yakusu_list[len(yakusu_list)//2 + 1 -1] + yakusu_list[-(len(yakusu_list)//2 + 1)]
  print(tmp -2)
else:
  tmp = yakusu_list[len(yakusu_list)//2 - 1] + yakusu_list[-(len(yakusu_list)//2)]
  print(tmp -2)



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

using namespace std;

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

    vector<long int> a(M + 1000);
    for( int i = 0; i < M; i++) cin >> a[i];
    vector<int> dp(N + 1,0);
    /*a[M] = 1000000007;*/
    dp[0] = 1;
    int j = 0;
    if(a[j] == 1){ dp[1] = 0; j++; }
    else{ dp[1] = 1;}
   
   for(int i = 2; i <= N; i++){
       
       
       if(i == a[j]){ dp[i] = 0; j++; }
       else{ dp[i] = dp[i - 1] + dp[i - 2];
           
             } 
            
     dp[i] %= 1000000007;

   }

   cout << dp[N] << endl;
    return 0;
}



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

#define int              long long 
#define FOR( i, m, n )   for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )      FOR( i, 0, n )
#define ALL( a )         (a).begin(), (a).end()
#define fi               first
#define se               second

typedef pair<int, int> P;

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( a > b ) { a = b; return 1; } return 0; }

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

int myPow( int m, int n ){
  if( n == 0 ) return 1;
  if( n % 2 == 0 ){
    int t = myPow( m, n / 2 );
    return  t * t % MOD;
  }
  return m * myPow( m, n - 1 ) % MOD; 
}

signed main(){
  int m, n; cin >> m >> n;
  cout << myPow( m, n ) << endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int h,w,k;
    cin>>h>>w>>k;
    char c;
    std::vector<vector<char>> vec(h,vector<char>(w));
    std::vector<vector<char>> copy(h,vector<char>(w));
    for (int i=0;i<h;i++) {
        for (int j=0;j<w;j++) {
            cin>>c;
            vec[i][j]=c;
            copy[i][j]=c;
        }
    }
    int ans=0;
    for (int bith=0;bith<(1<<h);bith++) {
        std::deque<int> H;
        for (int i=0;i<h;i++) {
            if (bith&(1<<i)) {
                H.emplace_back(i);
            }
        }
        for (int bitw=0;bitw<(1<<w);bitw++) {
            std::deque<int> W;
            for (int j=0;j<w;j++) {
                if (bitw&(1<<j)) {
                    W.emplace_back(j);
                }
            }
            for (int j=0;j<H.size();j++) {
                for (int l=0;l<w;l++) {
                    copy[H[j]][l]='o';
                }
            }
            for (int j=0;j<W.size();j++) {
                for (int l=0;l<h;l++) {
                    copy[l][W[j]]='o';
                }
            }
            int count=0;
            for (int j=0;j<h;j++) {
                for (int l=0;l<w;l++) {
                    if (copy[j][l]=='#') {
                        count++;
                    }
                    copy[j][l]=vec[j][l];
                }
            }
            if (count==k) {
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}

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

int main(){
  	int n;
  	cin >> n;
  	stack<int> v;
  	while(n!=0){
      	v.push(n%10==9?1:
               n%10==1?9:n%10);
      	n/=10;
    }
  	while(!v.empty()){
      	cout << v.top();
    	v.pop();
    }
  	return 0;
}

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

int main() {
  int n,h,w;
  cin >> n >> h >> w;
  int a = 0;
  int b = 0;
  for(int i = 1; i <= n; i++){
    if(i+w-1 <= n) a++;
    if(i+h-1 <= n) b++;
  }
  cout << a*b << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int a=0,po=1; char ch=getchar();
    while (!isdigit(ch)&&ch!='-') ch=getchar();
    if (ch=='-') po=-1,ch=getchar();
    while (isdigit(ch)) a=a*10+ch-'0',ch=getchar();
    return a*po;
}
long long i,j,n,l;
int main(){
	n=read();
	long long a;
	a=read();
	n=n%500;
	if (n<=a) cout<<"Yes";
	if (n>a) cout<<"No";
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}


int main(){

  vector<string> ans,t,cls;
  int n;
  cin >> n;

  if(n==1){
    cout << "a" << endl;
    return 0;
  }

  ans.push_back("a");

  FOR(i,0,n-1){
    for(auto s:ans){
      char m = 'a';
      for(auto c:s) m = max(c,m);
      for(char c='a';c<=(m+1);c++){
        t.push_back(s+c);
      }
    }
    ans = t;
    t = cls;
  }

  SORT(ans);
  for(auto s:ans){
    cout << s << endl;
  }



}


Measured memory_bytes: 11852
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


signed main(signed argc, char** argv){
	int N;
	cin >> N;
	vector<int> X(N), Y(N);
	for(int i = 0; i < N; ++i) {
		cin >> X[i] >> Y[i];
	}
	
	bool g = true;
	int z = (abs(X[0]) + abs(Y[0])) % 2;
	for(int i = 0; i < N; ++i) {
		g = g && (abs(X[i]) + abs(Y[i])) % 2 == z;
	}
	if (!g) {
		cout << -1 << endl;
		return 0;
	}
	bool f = (X[0] + Y[0]) % 2 == 0;
	if(f) {
		for(int i = 0; i < N; ++i) {
			X[i]--;
		}
	}
	const int m = 31;
	cout << (f ? m + 1: m) << endl;
	if(f) cout << 1 << " ";
	for(int i = 0; i < m; ++i) {
		cout << (1LL << i) << (i == m - 1 ? "\n": " ");
	}
	for(int i = 0; i < N; ++i) {
		int U = (X[i] + Y[i] + (1LL << m) - 1) / 2;
		int V = (X[i] - Y[i] + (1LL << m) - 1) / 2;
		int x = 0, y = 0;
		if(f){
			cout << "R";
		}
		for(int i = 0; i < m; ++i) {
			if(((U >> i) & 1) && ((V >> i) & 1)) {
				cout << "R";
				x += 1LL << i;
			} else if(((U >> i) & 1) && !((V >> i) & 1)) {
				cout << "U";
				y += 1LL << i;
			} else if(!((U >> i) & 1) && ((V >> i) & 1)) {
				cout << "D";
				y -= 1LL << i;
			} else if(!((U >> i) & 1) && !((V >> i) & 1)) {
				cout << "L";
				x -= 1LL << i;
			}
		}
		if(x != X[i] || y != Y[i]) {
			cout << x << " " << y << endl;
			cout << "dead" << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256