akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
int main(void)
{
    int i, j;
    int H, W;
 
    do{
        scanf("%d %d", &H, &W); 
        if(H == 0 && W == 0) break;
        for(i = 0; i < H; i++){
            for(j = 0; j < W; j++){
                printf("#");
            }
            putchar('\n');
        }
        putchar('\n');
    } while((H != 0) || (W != 0));
 
     
    return 0;
}


Measured memory_bytes: 3104
///
/**
 * @Samaritan
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#define pb emplace_back
#define fi first
#define se second
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define PLI pair<LL, int>

LL quick_pow (LL a, LL b, LL mod) {
    LL ans = 1, base = a;
    while (b) {
        if (b & 1) (ans *= base) %= mod;
        b >>= 1;
        (base *= base) %= mod;
    }
    return ans;
}

inline int log2(const float &x) {
    return ((unsigned &) x >> 23 & 255) - 127;
}

void show(int arr[], int len) {
    for (int i = 0; i <= len; ++i) {
        cout << arr[i] << " ";
    }
    cout << endl;
}
struct node {
    int dif, id;
    node() {
    }
    node(int d, int i) : dif(d), id(i) {}
    bool operator < (const node& k) const {
        return dif < k.dif;
    }
};

const int mod = 998244353;
const int N = 1e5 + 5;
const int logN = 20;
const int INF = 0x3f3f3f3f;

vector<PII> edge[N];
int dist[N];
set<int> type[N];
//bool vis[N];

void work(int n) {
    memset(dist, INF, sizeof dist);
    dist[1] = 0;
    priority_queue<PII> p;
    p.push({0, 1});
    while(!p.empty()) {
        int now = p.top().second;
        int val = -p.top().first;
        p.pop();
        if (dist[now] < val)
            continue;
        for (const auto& pp : edge[now]) {
            int to = pp.first;
            int now_type = pp.second;
            int now_val = val;
            if (!type[now].count(now_type))
                now_val++;
//            int to_ca=ca+(!type[now].count(to_com));
            if (dist[to] > now_val) {
                dist[to] = now_val;
                p.push({-now_val, to});
                type[to].clear();
                type[to].insert(now_type);
            } else if(dist[to] == now_val) {
                type[to].insert(now_type);
            }
        }
    }
    return;
    memset(dist, INF, sizeof(dist[0]) * (n + 3));
    priority_queue<PII, vector< PII >, greater<> > pq;
    dist[1] = 0;
    pq.push({0, 1});
    while (!pq.empty()) {
        int pos = pq.top().second;
        int now_dist = pq.top().first;
        pq.pop();
//        if (vis[pos]) continue;
//        vis[pos] = true;
        if (now_dist > dist[pos]) continue;
        for (const auto& p : edge[pos]) {
            int to = p.first;
            int now_type = p.second;
            int now_val = dist[pos];
            if (!type[pos].count(now_type))
                now_val++;
            if (now_val < dist[to]) {
                dist[to] = now_val;
                type[to].clear();
                type[to].insert(now_type);
                pq.push({dist[to], to});
            } else if (now_val == dist[to]) {
                type[to].insert(now_type);
            }
        }
    }
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i <= n; ++i)
        edge[i].clear();
    int l, r, c;
    for (int i = 0; i < m; ++i) {
        scanf("%d %d %d", &l, &r, &c);
        edge[l].pb(r, c);
        edge[r].pb(l, c);
    }
    work(n);

    if (dist[n] >= INF)
        puts("-1");
    else
        printf("%d\n", dist[n]);
    return 0;
}


Measured memory_bytes: 23412
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double X = sc.nextDouble();
      	double i;
      	double j;
      	int count = 0;
      	for(i = 1; i <= X / 2 + 1; i++){
          for(j = 1; j <= X / 2 + 1; j++){
            if(count <= (int) Math.pow(i, j) && (int) Math.pow(i, j) <= X){
              count = (int) Math.pow(i, j);
            }
          }
        }
        System.out.println(count);  
    }
}

Measured memory_bytes: 37260
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define INF 1e9

static const int seed=6;
static const int D=365;
static const int ntype=26;
static const double swap_rate=0.6;
static const double change_rate=1.0-swap_rate;
static int ans[D+1];
static int max_score=0;
static const int t=1100000;
static const int last_swap=100000;

class Contest{
public:
    Contest(){
        last=0;
    }
    int s[D+1];
    int c;
    int last;
};

static Contest contest[ntype+1];

void Input(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int d;
    cin>>d;
    for(int i=1;i<=ntype;++i){
        int t;
        cin>>t;
        contest[i].c=t;
    }
    for(int day=1;day<=D;++day){
        for(int type=1;type<=ntype;++type){
            int t;
            cin>>t;
            contest[type].s[day]=t;
        }
    }
}

int Score(int type){
    int sum=0;
    contest[type].last=0;
    for(int day=1;day<=D;++day){
        if(ans[day]==type){
            sum+=contest[type].s[day];
            int n=day-contest[type].last;
            sum-=contest[type].c*(n*(n-1)/2);
            contest[type].last=day;
        }
    }
    if(ans[D]!=type){
        int n=D-contest[type].last;
        sum-=contest[type].c*(n*(n+1)/2);
    }
    return sum;   
}

void Output(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    for(int d=1;d<=D;++d) cout<<ans[d]<<'\n';
}

void Init(){
    for(int d=1;d<=D;++d) ans[d]=rand()%ntype+1;
}

void Greedy(){
    vector<int> l(ntype+1,0);
    int score=0;
    for(int d=1;d<=D;++d){
        for(int i=1;i<=ntype;++i) score-=contest[i].c*(d-l[i]);
        int temp=score;
        int t=-1;
        for(int i=1;i<=ntype;++i){
            int k=contest[i].s[d]+contest[i].c*(d-l[i])+score;
            if(k>temp){
                temp=k;
                t=i;
            }
        }
        ans[d]=t;
        l[t]=d;
    }
}

void change(){
    int p=rand()%D+1;
    int before=ans[p];
    int after=rand()%ntype+1;
    int before_score=Score(before)+Score(after);
    ans[p]=after;
    int delta=Score(before)+Score(after)-before_score;
    if(delta>0){ 
        max_score+=delta;
    }
    else ans[p]=before;
}

void swap(){
    int p1=rand()%D+1;
    int p2=rand()%D+1;
    while(p1==p2) p2=rand()%D+1;
    int temp_score=Score(ans[p1])+Score(ans[p2]);
    int temp=ans[p1];
    ans[p1]=ans[p2];
    ans[p2]=temp;
    int delta=Score(ans[p2])+Score(ans[p1])-temp_score;
    if(delta>0){
        max_score+=delta;
    }
    else{
        ans[p2]=ans[p1];
        ans[p1]=temp;
    }
}

void Solve(int times){
    Greedy();
    for(int i=1;i<=ntype;++i) max_score+=Score(i);
    for(int i=0;i<times;++i){
        double p=(double)rand()/RAND_MAX;
        if(p<swap_rate) swap();
        else change();
    }
    for(int i=0;i<last_swap;++i) swap();
}

int main(){
    srand(seed);
    Input();
    Solve(t);
    Output();
}

Measured memory_bytes: 3632
s=input()
flag=0
for i in range(len(s)):
  if s[i]!=s[len(s)-1-i]:
    flag=1
for i in range(int((len(s)-1)/2)):
  if s[i]!=s[int((len(s)-1)/2)-1-i]:
    flag=1
for i in range(int((len(s)+3)/2)-1,len(s)):
  if s[i]!=s[len(s)-1-i]:
    flag=1
if flag==1:
  print("No")
else:
  print("Yes")

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define MOD pow(10,9)+7
#define LLINF pow(2,61)-1
#define INF pow(2,29)-1


int main() {
  ll N, K; cin >> N >> K;
  ll A[N]; rep(i,N) cin >> A[i];
  ll F[N]; rep(i,N) cin >> F[i];
  sort(A,A+N, greater<ll>()); sort(F,F+N);

  ll l=0, r=pow(10,12), m=0;
  while(l!=r) {
    m = ((l+r)/2);
    ll tmp = 0;
    rep(i,N) {
      tmp += max((ll)0, A[i]-m/F[i]);
    }
    // cout << l << " " << r << " " << m << " " << tmp << endl;
    if (tmp<=K) r=m;
    else l=m+1;
  }

  ll result= l;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3328
package main

import (
	"fmt"
)

func main() {
	var (
		k, x int
	)
	fmt.Scan(&k, &x)
	first := true
	for i := x - (k - 1); i < x+k; i++ {
		if !first {
			fmt.Print(" ")
		}
		first = false
		fmt.Print(i)
	}
}


Measured memory_bytes: 512
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = sys.stdin.buffer.readline().decode().rstrip()


# if int(N) < 10:
#     print(int(N))
#     exit()

def count(s):
    return sum(map(int, list(s)))


ans = count(N)
for i in range(len(N)):
    if N[i] != '0':
        a = count(N[:i]) + count(N[i]) - 1 + count('9' * (len(N) - i - 1))
        ans = max(ans, a)
print(ans)


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

int main()
{
    long long a,b,n;
    long long sum,k1,a1,b1;
    scanf("%lld%lld%lld",&a,&b,&n);
    k1=a/b;

    a1=a%b;

    b1=b-1;
    if(b1>n)
        b1=n;
    sum=k1*b1+(a1*b1)/b;
    printf("%lld",sum);

    return 0;
}


Measured memory_bytes: 1736
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
const int N = 5;
typedef pair<int, int> P;
typedef pair<int, P>PP;
int a[200006], b[200006];
int grid[4010][4010];
int pas[4010][4010];
int kj[10000], kji[10000];
int modpow(int a, int x, int mod) {
	int res = 1;
	while (x) {
		if (x & 1)res = res*a%mod;
		x >>= 1;
		a = a*a%mod;
	}
	return res;
}
void kjinit() {
	kj[0] = 1;
	rep(i, 9999) {
		kj[i + 1] = (kj[i] * (i + 1)) % mod;
		kji[i] = modpow(kj[i], mod - 2, mod);
	}
}
int comb(int r, int c) {
	int res = kj[r] * kji[c] % mod;
	res = (res*kji[r - c] % mod);
	return res;
}
signed main() {
	int n; cin >> n;
	rep(i, n) {
		cin >> a[i] >> b[i];
		grid[2005 - a[i]][2005 - b[i]]++;
	}
	kjinit();
	rep(i, 4009)rep(j, 4009)grid[i + 1][j + 1] = (grid[i + 1][j] + grid[i][j + 1]+grid[i+1][j+1]) % mod;
	int ans = 0;
	rep(i, n) {
		ans += grid[2005 + a[i]][2005 + b[i]];
		ans %= mod;
	}
	rep(i, n) {
		ans -= comb(a[i] * 2 + b[i] * 2, a[i] * 2);
		ans += mod;
		ans%=mod;
	}
	ans *= modpow(2, mod - 2, mod);
	cout << ans%mod << endl;
}


Measured memory_bytes: 130048
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long h, w;
  cin >> h >> w;
  long long ans = 1e10;
  for (int i = 1; i < h; i++) {
	long long a = i * w;
	long long b = (h - i) * (w / 2);
	long long c = (h - i)*(w - w / 2);
	long long d = w * ((h - i) / 2);
	long long e = w * ((h - i) - (h - i) / 2);
	long long s = max(abs(a - b), abs(a - c));
	long long t = max(abs(a - d), abs(a - e));
	long long l = min(s, t);
	ans = min(ans, l);
  }
  swap(h, w);
  for (int i = 1; i < h; i++) {
	long long a = i * w;
	long long b = (h - i) * (w / 2);
	long long c = (h - i)*(w - w / 2);
	long long d = w * ((h - i) / 2);
	long long e = w * ((h - i) - (h - i) / 2);
	long long s = max(abs(a - b), abs(a - c));
	long long t = max(abs(a - d), abs(a - e));
	long long l = min(s, t);
	ans = min(ans, l);
  }
  ans = min(ans, (h % 3 + 1) / 2 * w);
  ans = min(ans, (w % 3 + 1) / 2 * h);
  cout << ans << endl;
  return 0;
}



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

using namespace std;
using LL = long long;
const int MOD = 1e9+7;
int main(){
    int n,m;cin >> n >> m;
    vector<int> f(n);
    for(int a = 0;a < m;a++){
        int b;cin >> b;
        f[b] = 1;
    }
    vector<LL> dp(n+1);
    dp[0] = 1;
    for(int i = 1;i <= n;i++){
        if(f[i] == 1)continue;
        if(i == 1){
            dp[i] = dp[0];
            continue;
        }
        dp[i] = dp[i-1] + dp[i-2];
        dp[i]%=MOD;
    }
    /*
    for(int i = 0;i <= n;i++)cout<<dp[i]<<" ";
    cout<<endl;
    */
    cout<<dp.back()<<endl;
}


Measured memory_bytes: 1408
#include<iostream>   //AA06( 19/ 04/ 20) If u see my code, Have a Good Day! (^_^)
#include<bits/stdc++.h>

using namespace std;

int main()
{
    int R;

    cin >> R;

    cout << R * 2 * M_PI << endl;

    return 0;
}


Measured memory_bytes: 3792
#include<iostream>
#include<cstdio>

using namespace std;

const int maxn = 36;

struct task
{
    char name;
    int time;
};
struct task T1[maxn] , T2[maxn];

void BubbleSort (struct task A[] , int n)
{
    for (int i = 1 ; i < n ; i ++){
        for (int j = n ; j >= i + 1 ; j --){
            if (A[j].time < A[j - 1].time){
                task t = A[j];
                A[j] = A[j - 1];
                A[j - 1] = t;
            }
        }
    }
}

void InsertSort(struct task A[] , int n)
{
    for (int i = 1 ; i <= n ; i ++){
        int minA = A[i].time;
        int minj = i;
        for (int j = i + 1 ; j <= n ; j ++){
            if (A[j].time < minA){
                minA = A[j].time;
                minj = j;
            }
        }
        if (minj != i){
            task t = A[i];
            A[i] = A[minj];
            A[minj] = t;
        }
    }
}

bool Stability (struct task T1[] , struct task T2[] , int n)
{
    for (int i = 1 ; i <= n ; i ++){
        if (T1[i].name != T2[i].name)
            return false;
    }
    return true;
}

void print (struct task A[] , int n)
{
    for (int i = 1 ; i <= n ; i ++){
        cout << A[i].name << A[i].time;
        if (i != n)
            cout << " ";
    }
    cout << endl;
}

int main()
{
    int n ;
    while (scanf("%d",&n)!= EOF){
        for (int i = 1 ; i <= n ; i ++){
            cin >> T1[i].name >> T1[i].time;
            T2[i] = T1[i];
        }

        BubbleSort(T1 , n);
        print(T1 , n);
        cout << "Stable" << endl;
        InsertSort(T2 , n);
        print(T2 , n);
        if (Stability(T1 , T2 , n))
            printf("Stable\n");
        else
            printf("Not stable\n");
    }
    return 0;
}



Measured memory_bytes: 3156
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define mod 1000000000+7
#define rep(i,n) for(int i=1;i<=(int) (n);i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
using namespace std;
int main() {
  int n;
  string ans="No";
  cin>>n;
  rep(i,9){
    rep(j,9){
      if(n==i*j)ans="Yes";
    }
  }
  cout<<ans;
}


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

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//REPマクロ
#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 REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
    ll N;
    cin>>N;
    vl A(N);
    REP(i,N) cin>>A[i];
    vl sum(N+1,0);
    REP(i,N){
        sum[i+1]=sum[i]+A[i];
        sum[i+1]%=MOD;
    }
    ll ans=0;
    REP(i,N-1){
        ll tmp=sum[N]-sum[i+1];
        tmp%=MOD;
        while(tmp<0) tmp+=MOD;
        ans+=A[i]*tmp;
        ans%=MOD;
    }
    cout<<ans<<endl;

}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<int> a;
vector<vector<int>> G(500,vector<int>(500,0));
void dfs(int i,int n,vector<bool>& used) {
    for (int j = 0;j < n;++j) {
        if (i != j && G[i][j] == 0 && !used[j]) {
            used[j] = true;
            a.push_back(j);
            dfs(j,n,used);
        }
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0;i < n;++i) {
        vector<bool> used(n,false);
        for (int j = 0;j < n;++j) {
            if (used[j]) continue;
            for (int k = j+1;k < n;++k) if (!used[k] && G[j][k] == 0) {
                a.push_back(j);
                a.push_back(k);
                used[j] = true;
                used[k] = true;
                dfs(k,n,used);
            }
            int m = a.size();
            for (int k = 0;k < m;++k) for (int l = k%2+1;l < m;l += 2) G[a[k]][a[l]] = G[a[l]][a[k]] = i+1;
            a.clear();
        }
        // for (int i = 0;i < n;++i) p_ary(G[i],0,n,j);
        // cout << endl;
    }
    for (int i = 0;i < n-1;++i) {
        for (int j = i+1;j < n;++j) cout << G[i][j] << " \n"[j == n-1];
    }
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
#include<list>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0;i < (n); ++i)



int main(){
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	int count = 0,abr = 0;
	rep(i, s.size()) {
		if (s[i] == 'a') {
			if (count < a + b) {
				cout << "Yes" << endl;
				count++;
			}
			else cout << "No" << endl;
		}
		else if (s[i] == 'b') {
			if (count < a + b && abr < b) {
				cout << "Yes" << endl;
				count++;
				abr++;
			}
			else cout << "No" << endl;
		}
		else cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define input(array) repi(_itr, array) { cin >> *(_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,x,t;
	int ans=0;
	cin >>n>>x>>t;
	cout<<(x+n-1)/x*t<<endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=10000007;
int main(){
string s,t;cin >> s >> t;
cout << t+s << endl;
}

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

using namespace std;
int n,x,y,t,a,b,c;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>c>>a>>b;
        if(abs(x-a)+abs(y-b)>c-t)
        {
            cout<<"No";
            return 0;
        }
        if((abs(x-a)+abs(y-b))%2==0 &&(c-t)%2==1)
        {
            cout<<"No";
            return 0;
        }
        if((abs(x-a)+abs(y-b))%2==1 &&(c-t)%2==0)
        {
            cout<<"No";
            return 0;
        }
        x=a;y=b;t=c;
    }
    cout<<"Yes";
}

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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)
typedef long long ll;

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);
int gcd(int a, int b);

int main() {
    int a ,b, k;
    cin >> a >> b >> k;

    vector<int> x;

    int stop = min(a, b);
    for(int i=1; i<=stop; i++) {
        if(!(a%i) && !(b%i)) {
            x.push_back(i);
        }
    }
    cout << x[x.size() - k] << endl;

    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}
//int sum_digits(int num) {
//    int rtn = 0;
//    string num_str = to_string(num);
//    for(int i=0; i<num_str.size(); i++) {
//        rtn += num_str[i] - '0';
//    }   
//    return rtn;
//}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}

// ユークリウッドの互除法
int gcd(int a, int b) {
    if(b==0) return a;
    else return gcd(b, a % b);
}



Measured memory_bytes: 256
//我是菜鸡
#include<bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
#define debug(x) cout<<x<<endl
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 2e5+5;
int mon[maxn];
void deprint() {
	//ofstream cout("E:\\acm dream\\debug.txt");
	return;
}
ll fpow(ll x, ll n) {
	ll ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
		}
		x *= x;
		n >>= 1;
	}
	return ans;
}
int main() {
	//ifstream cin("E:\\acm dream\\in.txt");
	//ofstream cout("E:\\acm dream\\out.txt");
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	ll H;
	while (cin >> H) {
		ll n = 0;
		ll ans;
		while (H > 0) {
			n++;
			H /= 2;
		}
		ans = fpow(2, n) - 1;
		cout << ans << '\n';
	}
	return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 2010;
const int MOD = 1e9 + 7;

int dp[N][N], fak[N * N], inv[N * N];
int n, k;

inline int add(int A, int B){
	if(A + B >= MOD) return A + B - MOD;
	return A + B;
}

inline int mul(int A, int B){
	return (ll)A * B % MOD;
}

inline int pot(int A, int B){
	int ret = 1, bs = A;
	for(;B;B >>= 1){
		if(B & 1) ret = mul(ret, bs);
		bs = mul(bs, bs);
	}
	return ret;
}

void precompute(){
	fak[0] = 1, inv[0] = 1;
	for(int i = 1;i < N * N;i++){
		fak[i] = mul(fak[i - 1], i);
		inv[i] = pot(fak[i], MOD - 2);
	}
}

inline int ch(int n, int k){
	return mul(fak[n], mul(inv[k], inv[n - k]));
}


int f(int i,int j){
	if(j < i || i < 0) return 0;
	if(j == 0) return 1;
	if(dp[i][j] != -1) return dp[i][j];
	return dp[i][j] = add(f(i - 1, j), mul(f(i, j - 1), ch((j - 1) * (k - 1) + k - 2 + i,k - 2)));
}

int main(){
	memset(dp, -1, sizeof(dp));
	precompute();
	scanf("%d%d", &n, &k);
	if(k == 1)
		printf("1\n");
	else
		printf("%d\n", mul(fak[n], f(n, n)));
}

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

using namespace std;

#define int long long

int x;

struct Test {
    int b;
    int l, r;

    int get_sum(int f) {
        assert(0 <= f && f <= x);
        return max((int)0, f - b) * r + min(f, b) * l;
    }

    Test() {}
};

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

    int n;
    cin >> n >> x;
    vector<Test> a(n);
    int ndl = 0;
    for (auto &t : a) {
        cin >> t.b >> t.l >> t.r;
        ndl += t.b * t.l;
    }
    sort(a.rbegin(), a.rend(), [&](Test a, Test b) {
        return a.get_sum(x) < b.get_sum(x);
    });
    auto can = [&](int hv) {
        int fl = hv / x;
        int lf = hv % x;
        int ans = 0;
        if (lf) {
            int sf = 0;
            int sb = 0;
            for (int i = 0; i < fl; i++) {
                sf += a[i].get_sum(x);
            }
            for (int i = 0; i < fl + 1; i++) {
                sb += a[i].get_sum(x);
            }
            for (int tk = 0; tk < n; tk++) {
                if (tk >= fl) {
                    ans = max(ans, sf + a[tk].get_sum(lf));
                } else {
                    ans = max(ans, sb - a[tk].get_sum(x) + a[tk].get_sum(lf));
                }
            }
        } else {
            for (int i = 0; i < fl; i++) {
                ans += a[i].get_sum(x);
            }
        }
        return ans >= ndl;
    };
    int l = -1;
    int r = n * x;
    while (r - l > 1) {
        int m = (r + l) >> 1;
        if (can(m)) r = m;
        else l = m;
    }
    cout << r << endl;
}   


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

// 子どもを表す構造体
struct infant{
  int position; // 位置
  int64_t lively;   // 活発度
  
  // 活発度が同じ場合、位置で判断する
  bool operator<( const infant &right ) const{
    return lively == right.lively ? position < right.position : lively < right.lively;
  }
  
};

int main(){
  
  int N = 0;
  std::cin >> N;
  
  std::vector< infant > vec_infants( N );
  for( int cnt = 0; cnt < N; cnt++ ){
    vec_infants.at( cnt ).position = cnt + 1;
    std::cin >> vec_infants.at( cnt ).lively;
  }
  
  // 活発度を基準に降順ソート
  sort( vec_infants.begin(), vec_infants.end() );
  reverse( vec_infants.begin(), vec_infants.end() ); 
  
  // dp[x][y]
  // x:左端に寄せた数 y:右端に寄せた数
  // x+y = N
  std::vector< std::vector< int64_t > > dp( N + 1, std::vector< int64_t >( N + 1, 0 ) );
  for( int i = 0; i < N; i++ ){
    for( int j = 0; j < N - i; j++ ){
      // 左端に寄せたとき
      int left_renge = std::abs( ( i + 1 ) - vec_infants.at( i + j ).position );
      if( dp.at( i + 1 ).at( j ) < dp.at( i ).at( j ) + vec_infants.at( i + j ).lively * left_renge ){
        dp.at( i + 1 ).at( j ) = dp.at( i ).at( j ) + vec_infants.at( i + j ).lively * left_renge;
      }
      // 右端に寄せたとき
      int right_renge = std::abs( ( N - j ) - vec_infants.at( i + j ).position );
      if( dp.at( i ).at( j + 1 ) < dp.at( i ).at( j ) + vec_infants.at( i + j ).lively * right_renge ){
        dp.at( i ).at( j + 1 ) = dp.at( i ).at( j ) + vec_infants.at( i + j ).lively * right_renge;
      }
      
    }
  }
  
  int64_t answer = 0;
  for(int i = 0; i <= N ;i++){
    for(int j = 0; j <= N; j++){
      answer = std::max( dp.at( i ).at( j ), answer );
    }
  }
  
  std::cout << answer << std::endl;
  
  return 0;
}

Measured memory_bytes: 34592
N = int(input())
A = [[int(input()),n] for n in range(N)]

B = A + []
B.sort(reverse=True, key=lambda x:x[0])
ans = [B[0][0]]*N
if B[0][0]!=B[1][0]:
    ans[B[0][1]] = B[1][0]

for a in ans:
    print(a)

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

constexpr int mod = 1e9 + 7;

#define dump(x) ([&](){auto y = (x); cout << #x << " = " << (y) << endl; })();
// #define dump(x) ;


template<class T>
ostream&operator<<(ostream &os, vector<T>v) {
  os << "{";
  for(size_t i = 0; i < v.size(); i++) os << v[i] << ", ";
  os << "}";
  return os;
}

template<class T, class U>
ostream&operator<<(ostream &os, pair<T, U>v) {
  os << "(" << v.first << " , " << v.second << ")";
  return os;
}

template<class T, class U>
ostream&operator<<(ostream &os, map<T, U>v) {
  os << "(map: \n";
  for(auto e : v) os << e << ", \n";
  os << ")";
  return os;
}

using Vec = vector<int>;
using Mat = vector<Vec>;

ll modpow(ll x, ll k, ll mod) {
  x %= mod;
  ll r = 1;
  assert(k >= 0);
  while(k) {
    if(k & 1) r = r * x % mod;
    x = x * x % mod;
    k >>= 1;
  }
  return r;
}

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

  while(1) {
    int n, m;
    cin >> n;
    if(n == 0) break;
    cin >> m;
    
    Mat ids(n, Vec(n));
    Mat data(n, Vec(n));
    Vec xs;
    Vec ys;

    int num = 0;
    {
      for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
          if(i < j) {
            ids[i][j] = num;
            ids[j][i] = -num;
            xs.push_back(i);
            ys.push_back(j);
            num++;
          }
        }
      }
    }

    for(int i = 0; i < m; i++) {
      int x, y;
      cin >> x >> y;
      x--, y--;
      data[x][y] = 1;
      data[y][x] = -1;
    }

    using V = vector<int>;
    using MP = map<V, int>;
    MP mp;

    int nn = num / 2;
    // dump(nn);
    for(int i = 0; i < 1 << nn; i++) {
      V v(num);
      bool ok = 1;
      for(int j = 0; j < nn; j++) {
        int k = j;
        int d = data[xs[k]][ys[k]];
        int c = i & (1 << j);
        if(d == 0) {
          if(c) {
            v[xs[k]]++;
            v[ys[k]]--;
          } else {
            v[xs[k]]--;
            v[ys[k]]++;
          }
        } else {
          if(d == 1) {
            if(!c) ok = 0;
            v[xs[k]]++;
            v[ys[k]]--;
          } else {
            if(c) ok = 0;
            v[xs[k]]--;
            v[ys[k]]++;
          }
        }
      }
      if(ok) mp[v]++;
    }

    ll ans = 0;
    // dump(mp);

    int mm = num - nn;
    // dump(mm);
    for(int i = 0; i < 1 << mm; i++) {
      V v(num);
      bool ok = 1;
      for(int j = 0; j < mm; j++) {
        int k = nn + j;
        int d = data.at(xs.at(k)).at(ys.at(k));
        int c = i & (1 << j);
        if(d == 0) {
          if(c) {
            v.at(xs[k])--;
            v.at(ys[k])++;
          } else {
            v.at(xs[k])++;
            v.at(ys[k])--;
          }
        } else {
          if(d == 1) {
            if(!c) ok = 0;
            v.at(xs[k])--;
            v.at(ys[k])++;
          } else {
            if(c) ok = 0;
            v.at(xs[k])++;
            v.at(ys[k])--;
          }
        }
      }
      if(ok) ans += mp[v];
    }

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

  // dump("here");
}




Measured memory_bytes: 12640
#include <functional>
#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include <numeric>
#include<string>
using ll = long long;
using namespace std;
# define maxn 50
# define maxm 50

int main() {
  string Sd,T,ans;
  cin>>Sd>>T;
  int start=Sd.size()-T.size();
  for (int i(start);i>=0;i--){
    bool mat=true;
    ans=Sd;
    for (int j(0);j<T.size();j++){
      if (ans[i+j]!=T[j] && ans[i+j]!='?'){
        mat=false;
      }else{
        ans[i+j]=T[j]; // ここ多分書き方が違う
      }
    }
    if (mat==true){
      replace(ans.begin(),ans.end(),'?','a');
      cout << ans;
      return 0;
    }
  }
  cout << "UNRESTORABLE";
}


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

int main(){
    ll n;
    cin>>n;
    ll ans=0;
    ll a[n], b[n], c[n-1];
    for(ll i=0;i<n;++i){
        cin>>a[i];
        a[i]--;
    }
    for(ll i=0;i<n;++i){
        cin>>b[i];
        ans+=b[i];
    }
    for(ll i=0;i<n-1;++i){
        cin>>c[i];
    }

    for(ll i=0;i<n-1;++i){
        if(a[i]+1 == a[i+1]){
            ans += c[a[i]];
        }
    }
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define PI 		    acos(-1)
#define pb          push_back
#define ins         insert
#define INF        	1000000000000000007 //1e18+7
#define mk          make_pair
#define lb(v,x)     lower_bound(all(v),x)
#define ub(v,x)     upper_bound(all(v),x)
#define ff          first
#define ss          second
#define rev         reverse
#define umap        unordered_map
#define endl        "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a)       (ll)a.size()
#define double      long double
#define minpq       priority_queue <ll,vector<ll>,greater<ll> > 
#define fill(x,y)   memset(x,y,sizeof(x))
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define MOD         1000000007		//1e9+7
#define bp(n)       __builtin_popcountll(n)
#define mxt(a)      *(max_element(a.begin(),a.end()))
#define mnt(a)      *(min_element(a.begin(),a.end())
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i, a, mp) for(ll i = (a); i<= (mp); ++i)
#define trav(a, x) 	 for(auto &a : x)
#define re(i,n)      for(ll i = 0; i < n; ++i) 
const int N = 5e5 + 7;
typedef pair<ll,ll>   pii;
typedef vector<pii>   vpii;
typedef vector<ll>    vll;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int dx[8]={+1, +1, +1, 0, 0, -1, -1, -1};
int dy[8]={+1, 0, -1, +1, -1, +1, 0, -1};
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
template<typename T> T gcd(T a,T mp){ if(a==0) return mp; return gcd(mp%a,a); }
template<typename T> T powm(T a,T mp, ll m){T cnt=1; while(mp>0){ if(mp%2==1) cnt=(cnt*a)%m; mp/=2; a=(a*a)%m; }return cnt%m;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll sqr(ll x) { return x * x;} 
void prec(){

}
void run(){
	int n;cin>>n;
	int h[n+1];
	rep(i,1,n) cin>>h[i];
	int dp[n+1];
	fill(dp,INT_MAX);
	dp[0]=0,dp[1]=0,dp[2]=abs(h[1]-h[2]);
	for(int i=3; i<=n; ++i){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n];
}
int main()
{
    cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
    int tc=1;
    //cin>>tc;
    prec();
    re(i,tc)
    	run();
    return 0; 
}

Measured memory_bytes: 1024
s=input()
l=len(s)
mod=10**9+7
dp=[[0,0,0,0] for _ in range(l+1)]
for i in range(l,-1,-1):
  for j in range(3,-1,-1):
    if i==l:
      if j==3:
        dp[i][j]=1
      else:
        dp[i][j]=0
    else:
      if s[i]=='?':
        dp[i][j]=dp[i+1][j]*3
      else:
        dp[i][j]=dp[i+1][j]
      if j!=3 and (s[i]=='?' or s[i]==('ABC'[j])):
        dp[i][j]+=dp[i+1][j+1]
    dp[i][j]%=mod
print(dp[0][0])

Measured memory_bytes: 27580
N, M = map(int, input().split())
s = [0]*N
t = [1]*N
s[0] = 1
res = 1
for _ in range(M):
    x, y = map(int, input().split())
    x-=1
    y-=1
    t[x] -= 1
    t[y] += 1
    if s[x] == 1:
        if t[x]==0:
            s[x] = 0
            if s[y]==1:
                res -= 1
        else:
            if s[y]!=1:
                res += 1
        s[y] = 1
print(res)

Measured memory_bytes: 71832
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline int ri() {int x; scanf("%d", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/

const int maxn = 100010;

int s, n, m;
LL a[maxn], p[maxn]; 
int main() {
  #ifdef _TEST_
  freopen("input.txt", "r", stdin);
  //freopen("out.txt", "w", stdout);
  #endif
  n = ri(), m = ri(), s = ri();
  rep(i, n) a[i] = ri();
  set<LL> l, r;
  int c = 0;
  rep(i, n) {
    while (c <= i && (a[i] - a[c]) * 2 > s) {
      l.insert(p[c] - 2 * a[c]);
      c ++;
    }
    //cerr << i << ' ' << c << endl;
    p[i + 1] = s + p[c];
    if (!l.empty()) p[i + 1] = min(2 * a[i] + (*l.begin()), p[i + 1]);
  }
  cout << p[n] + m << endl;
  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>

using namespace std;

#define ll long long
#define MAX 100000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int x;
    cin >> x;
    if (x >= 30) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 3100
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<utility>
#include<queue>

const int MAXN = 105;
using namespace std;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

struct edge{
  edge(int from,int to):from(from),to(to){}
  int from,to;
};

bool operator<(edge a,edge b){
  if(a.from != b.from)return a.from < b.from;
  else return a.to < b.to;
}

typedef pair<int,edge> P;

int main(){
  int n,m;
  while(cin >> n >> m && (n | m) != 0){
    vector<P> road;

    for (int i = 0; i < m; ++i){
      int a,b,c;
      cin >> a >> b >> c;
      road.push_back(make_pair(c,edge(a,b)));
    }
    sort(road.begin(),road.end());
    UnionFind u(MAXN);
    int ans = 0;
    int z = road.size();
    for (int i = 0; i < z; ++i){
      edge top = road[i].second;
      int cost = road[i].first;
      if(!u.findSet(top.to,top.from)){
	//cout << "cost:" << cost << " " << top.to << " " << top.from << endl;
	ans += cost;
	u.unionSet(top.to, top.from);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	r := bufio.NewReader(os.Stdin)

	ln, _, _ := r.ReadLine()
	n, _ := strconv.Atoi(string(ln))

	ln, _, _ = r.ReadLine()
	dstr := strings.Split(string(ln), " ")
	var dint []int
	for _, ds := range dstr {
		di, _ := strconv.Atoi(ds)
		dint = append(dint, di)
	}

	s := 0
	for i, d := range dint {
		for j := i + 1; j < n; j++ {
			s += d * dint[j]
		}
	}

	fmt.Println(s)
}


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


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

//C++14 (GCC 5.4.1)
int main() {
    string S;
    cin >>S;
    bool isYYMM=false,isMMYY=false;
    int oo=stoi(S.substr(0,2));
    int tt=stoi(S.substr(2,2));
    if(1<=oo && oo<=12)isMMYY=true;
    if(1<=tt && tt<=12)isYYMM=true;
    
    string ans;
    if(isMMYY&& isYYMM){
        ans="AMBIGUOUS";
    }else if(isMMYY){ans="MMYY";
    }else if(isYYMM){ans="YYMM";
    }else{ans="NA";}



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

Measured memory_bytes: 256
n=gets.to_i;s=[];n.times{s<<gets.chomp.chars};x=s[0];z=[]
n.times{|i|x=x&s[i]}
x.each do|c|
  min=50
  n.times do|i|
    y=s[i].count(c)
    min>y&&min=y
  end
  min.times{z<<c}
end
puts z.sort.join


Measured memory_bytes: 1788
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second


void solve()
{
	ll n, k;
	cin >> n >> k;
	vll arr(n);
	for (ll i = 0; i < n; i++)
		cin >> arr[i];
	sort(arr.begin(), arr.end());
	ll out  = 0;
	for (ll i = 0; i < k; i++)
		out += arr[i];

	cout << out << "\n";

}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin >> t;
	// while (t--)
	// {
	solve();
	// }

	return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Long N, sum = 0L;
        Scanner sc = new Scanner(System.in);
        N = sc.nextLong();
        for(int i = 1 ; i <= N ; i++)
        {
            sum += (((i%3 ==0) || (i%5==0))? 0 : i);
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 51508
#include<bits/stdc++.h>
#define p_ pair<int,int>
#define mp_ make_pair
#define ll long long
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int main()
{
    fastio();
    ll a,b,c;
    cin>>a>>b>>c;
    if(c<b-1) cout<<a*c/b<<endl;
    else cout<<a*(b-1)/b<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
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();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

map<string,bool> m;
bool dfs(string &state,int player){
	if(EXIST(m,state)){
		return 1-(player^m[state]);
	}
	string stones="ox";
	int winner=-1;
	REP(i,2){
		bool flag=true;
		REP(j,state.size()){
			if(state[j]!=stones[i]){
				flag=false;
				break;
			}
		}
		if(flag){
			winner=i;
			break;
		}
	}
	if(winner!=-1){
		return winner==player;
	}
	int ret=false;
	bool canmove=false;
	REP(i,2){
		string s(state);
		int index=i?0:s.size()-1;
		int dir=i?1:-1;
		if(s[index]==stones[1-player]){
			canmove=true;
			while(s[index]==stones[1-player]){
				s[index]=' ';
				index+=dir;
			}
			string ns;
			REP(i,s.size()){
				if(s[i]!=' '){
					ns+=s[i];
				}
			}
			int d=dfs(ns,1-player);
			if(!d){
				ret=true;
			}
		}
	}
	if(!canmove){
		string s(state);
		int d=dfs(s,1-player);
		if(!d){
			ret=true;
		}
	}
	if(player==0){
		m[state]=!ret;
	}else{
		m[state]=ret;
	}
	return ret;
}

int main(){
	string s;
	cin>>s;
	string state;
	char prev=' ';
	REP(i,s.size()){
		if(s[i]!=prev){
			state+=s[i];
			prev=s[i];
		}
	}
	cout<<(dfs(s,0)?'o':'x')<<endl;
}

Measured memory_bytes: 1236
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        int h = inpt[0];
        int w = inpt[1];

        int[][] map = new int[h][];
        int moveCount = 0;
        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < h; i++)
        {
            map[i] = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        }
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if (map[i][j] % 2 == 0)
                {
                    continue;
                }
                if (j < w - 1)
                {
                    ans.AppendLine((i + 1) + " " + (j + 1) + " " + (i +1) + " " + (j + 2));
                    moveCount++;
                    map[i][j]--;
                    map[i][j + 1]++;
                }
                else if (i < h - 1)
                {
                    ans.AppendLine((i + 1) + " " + (j + 1) + " " + (i + 2) + " " + (j + 1));
                    moveCount++;
                    map[i][j]--;
                    map[i + 1][j]++;
                }
            }
        }
        Console.WriteLine(moveCount);
        Console.Write(ans.ToString());
    }


    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"





2 3
1 2 3
0 1 1


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 27804
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


int main() {
	int n, a;
	string s;
	while (cin >> n && n > 0) {
		vector < pair<pii, pair<int, string> > > v(n,pair<pii,pair<int,string> >(pii(0,0),pair<int,string>(0,"")));
		rep(i, n) {
			cin >> s;
			v[i].second.first = i;
			v[i].second.second = s;
			rep(j, n - 1) {
				cin >> a;
				if (a == 0) {
					v[i].first.first -= 1;
				}
				else if (a == 1) {
					v[i].first.second += 1;
				}
			}
		}
		sort(all(v));
		rep(i, n) {
			cout << v[i].second.second << endl;
		}
	}
}

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

int main(){
    int r, d, x;
    cin >> r >> d >> x;
    rep(i, 10){
        x = r*x-d;
        printf("%d\n", x);        
    }
    return 0;
}

Measured memory_bytes: 256