akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int INT;
int main()
{
    INT n;
    cin>>n;
    INT ans=1e13;
    for (int i=1;i<=sqrt(n);i++){
        double a=(double)n/i;
        if(floor(a)==a)
        {
            if(i+n/i<=ans){
                ans=i+n/i;
            }
        }
        
    }
    cout<<ans-2<<endl;
}

Measured memory_bytes: 3704
sx,sy,tx,ty=map(int,input().split())
tx-=sx
ty-=sy
ans=""
ans+="R"*tx+"U"*ty
ans+="L"*tx+"D"*ty
ans+="D"+"R"*(tx+1)+"U"*(ty+1)+"L"
ans+="U"+"L"*(tx+1)+"D"*(ty+1)+"R"
print(ans)

Measured memory_bytes: 3060
n, m = map(int, input().split())
mod = 1e9 + 7
ok = [True] * (n+1)
for i in range(m):
    a = int(input())
    ok[a] = False
dp = [0] * (n+1)
dp[0] = 1
for i in range(n):
    for j in range(i+1, 1 + min(n, i + 2)):
        if ok[j]:
            dp[j] += dp[i]
            dp[j] %= mod
print(int(dp[-1]))

Measured memory_bytes: 6900
A, B, C, X, Y = map(int, input().split())

ans = float("inf")

# 全部ミックスピザ
ans = min(2 * C * max(X, Y), ans)
# 普通に買う
ans = min(A * X + B * Y, ans)
# 多少はミックスも買う
if X >= Y:
    tmp = 2 * C * Y
    tmp += min((X - Y) * A, 2 * (X - Y) * C)
    ans = min(tmp, ans)
else:  # X < Y
    tmp = 2 * C * X
    tmp += min((Y - X) * B, 2 * (Y - X) * C)
    ans = min(tmp, ans)

print(ans)


Measured memory_bytes: 61948
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main(){    
  int X,A;
  cin >> X >> A;

  if(X < A){
    cout << "0" << endl;
  }
  else cout << "10" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    int h[N];
    for(int i = 0; i < N; i++) cin >> h[i];
    sort(h, h + N);

    int ans = inf;
    for(int i = 0; i < N - K + 1; i++) ans = min(ans, h[K - 1 + i] - h[i]);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 640
def resolve():
    import sys
    sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
    to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
    print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

    # 入力を整数に変換して受け取る
    def input_int(): return int(input())

    def map_int_input(): return map(int, input())

    MII = map_int_input

    def MII_split(): return map(int, input().split())

    def MII_to_index(): return map(to_index, input())

    def MII_split_to_index(): return map(to_index, input().split())

    # 入力全てを整数に変換したものの配列を受け取る
    def list_int_inputs(): return list(map(int, input()))

    LII = list_int_inputs

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

    # 2次元リスト化
    def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

    def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

    d, t, s = MII_split()

    print('Yes' if d / s <= t else 'No')
def resolve():
    import sys
    sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
    to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
    print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

    # 入力を整数に変換して受け取る
    def input_int(): return int(input())

    def map_int_input(): return map(int, input())

    MII = map_int_input

    def MII_split(): return map(int, input().split())

    def MII_to_index(): return map(to_index, input())

    def MII_split_to_index(): return map(to_index, input().split())

    # 入力全てを整数に変換したものの配列を受け取る
    def list_int_inputs(): return list(map(int, input()))

    LII = list_int_inputs

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

    # 2次元リスト化
    def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

    def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

    d, t, s = MII_split()

    print('Yes' if d / s <= t else 'No')

resolve()

Measured memory_bytes: 9308
N,  M = map(int, input().split())
L = []
R = []
for _ in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)
ml = max(L)
mr = min(R)
print(mr - ml + 1 if ml <= mr else 0)


Measured memory_bytes: 55896
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define loop(i,s,e) for(ll i=s; i<e; i++)
#define endl '\n'
#define vll vector<ll>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX
#define minusinf INT_MIN

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

void alpha(){

	char c;
	cin>>c;

	ll x = c+1;
	char ans = x;
	cout<<ans<<endl;

	
	return;

}

int main(){

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

    ll t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        s = reverse(s);
        String[] divide = {"dream","dreamer","erase","eraser"};
        for(int i = 0;i < 4;i++){
            divide[i] = reverse(divide[i]);
        }
        //System.out.println("divide = " + Arrays.toString(divide));
        //System.out.println("s = " + s);
        boolean can = true;
        for(int i = 0;i < s.length();){
            boolean can2 = false;
            for(int j = 0;j < 4;j++){
                String d = divide[j];
                //System.out.printf("divide[%d] = %s\n",j,d);
                if(i + d.length() <= s.length() && s.substring(i,i+d.length()).equals(d)){
                    can2 = true;
                    i += d.length();
                }
                //System.out.println("d = " + d.length());
                //System.out.println("i = " + i);
            }
            if(!can2){
                can = false;
                break;
            }
        }
        if(can){
            System.out.println("YES");
            return;
        }
        System.out.println("NO");
    }
    public static String reverse(String s){
        StringBuffer sb = new StringBuffer(s);
        String sr = new String(sb.reverse());
        return sr;
    }
}


Measured memory_bytes: 28576
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    string S; cin >> S;
    int N = S.size();
    vector<int> A(N+1,0);
    rep(i,N) {
        if (S[i] == '<') chmax(A[i+1], A[i] + 1);
    }
    for (int i = N; i > 0; i--) {
        if (S[i-1] == '>') chmax(A[i-1], A[i] + 1);
    }
    cout << accumulate(A.begin(), A.end(), 0LL) << endl;
}


Measured memory_bytes: 5832
#include <stdio.h>

int main(void)
{
	int n;

	scanf("%d",&n);

	if(n>=1 && n<10) printf("%d\n",n);
	else if(n>=10 && n<100) printf("9\n");
	else if(n>=100 && n<1000) printf("%d\n",n-99+9);
	else if(n>=1000 && n<10000) printf("909\n");
	else if(n>=10000 && n<100000) printf("%d\n",n-9999+909);
	else if(n==100000) printf("90909\n");
	return 0;
}



Measured memory_bytes: 128
N = int(input())

#
ans = 0
flag = True
flag2 = True

while flag:

    if N < 500:
        flag = False
    else:
        ans += 1000
        N-= 500

while flag2:

    if N < 5:
        flag2 = False
    else:
        ans+=5
        N -= 5

print(ans)

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

int main(){
  int N;
  cin >> N;
  vector<int> kazu(N);
  
  for(int i = 0;i < N;i++){
    int x;
    cin >> x;
    kazu.at(i) = x;
  }
  
  sort(kazu.begin(),kazu.end());
  reverse(kazu.begin(),kazu.end());
  
  int alice = 0;
  int bob = 0;
  for(int i = 0;i < N;i++){
    if(i == 0)alice += kazu.at(i);
    else if(i % 2 == 0)alice += kazu.at(i);
    else{bob += kazu.at(i);}
  }
  cout << alice - bob << endl;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	string a,b;
	cin >> a >> b;
	string c = a+b;
	LL d = stoll(c);
	for (int i = 1; i*i <= d; i++) {
		if (i*i == d) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
char a[N],b[N];
int main(){
	int n,k,r,s,p,sum=0;
	cin>>n>>k>>r>>s>>p>>a;
	for(int i=0;i<n;i++){
		if(i-k>=0&&b[i-k]&&a[i-k]==a[i])continue;
		if(a[i]=='r')sum+=p;
		if(a[i]=='s')sum+=r;
		if(a[i]=='p')sum+=s;
		b[i]=1;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n, a, b;
/**********************************************/

int main(){
    cin >> n >> a >> b;

    if((b - a) % 2 == 0){
        cout << "Alice" << endl;
    }else{
        cout << "Borys" << endl;
    }
}


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

int main() {
  char c;
  cin >> c;
  // ここにプログラムを追記
 if (c=='a' || c=='i' || c=='u' || c=='e' || c=='o') cout << "vowel" <<endl;
 else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

signed main(){
    int n;
    cin >> n;
    rep(t, 0, n){
        int x = 0, y = 0, MAX = 0, ax = -1, ay = -1;
        while(1){
            int dx, dy;
            cin >> dx >> dy;
            if(dx == 0 && dy == 0) break;
            x += dx;
            y += dy;
            if(x*x + y*y == MAX && ax < x){
                ax = x; ay = y;
            }            
            if(x*x + y*y > MAX){
                MAX = x*x + y*y;
                ax = x; ay = y;
            }
        }
        cout << ax << ' ' << ay << endl;
    }
}

Measured memory_bytes: 1156
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] x = new int[N];
		int c = 1;
		for(int i = 0; i < N; i++) {
				x[i] = sc.nextInt();
				}

		Arrays.sort(x);
		for(int i = 1; i < N; i++) {
			if(x[i] > x[i - 1])
				c++;
				}
		System.out.println(c);
		}
}



Measured memory_bytes: 23892
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <complex>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

i64 gcd(i64 x, i64 y) {
    while (x % y != 0) {
        swap(x, y);
        y %= x;
    }
    return y;
}

bool solve() {
    i64 a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a < b || d < b) {
        return false;
    }
    if (c >= b) {
        return true;
    }
    i64 g = gcd(b, d);
    return (b - g + a % g) % b <= c;
}
int main() {
    int t;
    cin >> t;
    while (t--) {
        if (solve()) cout << "Yes\n"; else cout << "No\n";
    }
    return 0;
}


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

    int main (){
        int n;
        cin >> n;
        vector<int> x(n);
        rep(i,n)cin >> x[i];
        int l=x[0],r=x[0];
        rep(i,n){
            l=min(l,x[i]);
            r=max(r,x[i]);
        }
        int ans = inf;
        for(int i=l;i<=r;i++){
            int cost =0;
            rep(j,n)cost += (x[j]-i)*(x[j]-i);
            ans = min(ans,cost);
        }

        cout << ans << endl;
return 0;

    }

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 21;

ll a[Maxn];
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, k;
	cin >> n >> k;
	for(int i = 0 ; i < n; i++) cin >> a[i];
	ll ans = 0, cnt = 0;
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if(a[i] < a[j]) cnt ++;
	ll al = k * (k - 1) / 2LL;
	al %= Mod;
	ans += cnt * al;
	ans %= Mod;
	cnt = 0;
	for(int i = 0; i < n; i++) for(int j = i + 1; j < n;j++) if(a[i] > a[j]) cnt ++;
	ans += (cnt*k);
	cout << ans % Mod;
	return 0;
}

/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map( &:to_i )

h = Hash.new( 0 )
n.times do |i|
  h[ a[ i ] - 1 ] += 1 if a[ i ] > 0
  h[ a[ i ] ] += 1
  h[ a[ i ] + 1 ] += 1
end

x = h.max{ |x, y| x[1] <=> y[1] }

p x[1]



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

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


int main(){
    char c;
    cin >> c;

    if(isupper(c)){
        cout << "A" << endl;
    }else{
        cout << "a" << endl;
    }
    
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main()
{
	string s;
	cin>>s;
	vector<char> q;
	int i,n,qu,qu2;
	char c;
	bool b=1;
	for(i=0;i<s.size();++i)
		q.push_back(s[i]);
	cin>>n;
	while(n--)
	{
		cin>>qu;
		if(qu==1)
			b=!b;
		else
		{
			cin>>qu2;
			cin>>c;
			if(b)
				if(qu2==1)
					q.insert(q.begin(),c);
				else
					q.insert(q.end(),c);
			else
				if(qu2==1)
					q.insert(q.end(),c);
				else
					q.insert(q.begin(),c);
		}
	}
	if(b)
	{
		for(i=0;i<q.size();i++)
			cout<<q[i];
		cout<<endl;
	}
	else
	{
		for(i=q.size()-1;i>=0;i--)
			cout<<q[i];
		cout<<endl;
	}
	return 0;
}

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

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  int n;
  cin >> n;
  vector<int> A(n), B(n);
  rep(i, n) {
    int a;
    cin >> a;
    A[i] = B[i] = a;
  }
  sort(B.begin(), B.end());
  rep(i, n) {
    if (A[i] == B[n-1]) cout << B[n-2] << endl;
    else cout << B[n-1] << endl;
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 3200
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

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

ll c[3000][3000];

int main(void) {
  ll n, k;
  ll div = 1000000007;
  cin>>n>>k;
  c[0][0] = 1;
  for(int i=0; i<=2500; i++) {
    for(int j=0; j<=i; j++) {
      c[i+1][j] += c[i][j] % div;
      c[i+1][j+1] += c[i][j] % div;
    }
  }
  for (int i=1; i<=k; i++) {
    if (n-k+1 < 1)
      std::cout << 0 << std::endl;
    std::cout << c[n-k+1][i]*c[k-1][i-1] % div<< std::endl;    
  }

  return 0;
}



Measured memory_bytes: 57984
#![allow(non_snake_case)]

use proconio::input;

fn main() {
    input! {
        A: usize,
        B: usize,
        C: usize,
    }

    solve(A, B, C);
}

fn solve(A: usize, B: usize, C: usize) {
    if A == B && !(A == C) {
        println!("Yes");
        return;
    }

    if B == C && !(B == A) {
        println!("Yes");
        return;
    }

    if C == A && !(C == B) {
        println!("Yes");
        return;
    }

    println!("No");
}


Measured memory_bytes: 2068
#include <queue>
#include <cstdio>
#include <algorithm>

#define MAX_H 1000
#define MAX_DIS 1000000

using namespace std;

typedef pair<int,int> P;

int H,W,N,si,sj;
char bd[MAX_H][MAX_H];
int dis[MAX_H][MAX_H];

int vx[] = {1,-1,0,0},vy[] = {0,0,1,-1};

void solve(){
	queue<P> que;
	int sum=0,n=1,val=0;
	
	while(n<=N){
	
		que.push(P(si,sj));
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				dis[i][j] = MAX_DIS;
			}
		}
		dis[si][sj] = val;

		int qx,qy;
		while(1){
			P v = que.front(); que.pop();
			qx = v.first; qy = v.second;
			
			if(bd[qx][qy] == '0'+(char)n) break;
			for(int i=0;i<4;i++){
				int pi,pj;
				pi = qx+vx[i];
				pj = qy+vy[i];
				if(-1<pi&&pi<H&&-1<pj&&pj<W&&bd[pi][pj]!='X'&&dis[qx][qy]+1<dis[pi][pj]){
					dis[pi][pj] = dis[qx][qy]+1;
					que.push(P(pi,pj));
				}
			}
		}
		si = qx; sj = qy;
		val = dis[qx][qy];
		while(!que.empty()) que.pop();
		n++;
	}
	printf("%d\n",val);
}
	


int main(){
	scanf("%d %d %d",&H,&W,&N);
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			char c;
			scanf(" %c",&c);
			bd[i][j] = c;
			if(c=='S'){
				si = i; sj = j;
			}
		}
	}
	solve();
	return 0;
}

Measured memory_bytes: 5928
n=int(input())
a=list(map(int,input().split()))
a=a[::-1]
b=[0]*n
x=0
y=1
t=True
for aa in a:
    if t:
        b[x]=aa
        x+=1
        t=False
    else:
        b[-y]=aa
        y+=1
        t=True
print(*b)

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

using namespace std;

typedef long long ll;

void pv(vector <int> &v) {
    for(int i = 0; i < v.size(); i++) cout << v[i] << " ";
    cout << endl;
}

void solve() {
	
}

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

    ll n;
    cin >> n;
    vector <int> a(n, 0);
    vector <int> b(n, 0);
    
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    
    reverse(b.begin(),b.end());
    // pv(b);
    int prob = 0;
    for(int i = 0; i < n; i++) {
        if(a[i] == b[i]) prob++;
    }
    int c = -1;
    int l = INT_MAX;
    int r = INT_MIN;
    for(int i = 0; i < n; i++) {
        if(a[i] == b[i]) {
            c = a[i];
            l = i;
            break;
        }
    }
    for(int i = n-1; i >= 0; i--) {
        if(a[i] == b[i]) {
            r = i;
            break;
        }
    }

    int toSwap = (r-l+1);
    if(toSwap == 0 || prob == 0) {
        cout << "Yes" << endl;
        pv(b);
        return 0;
    }
    int l0 = l;
    int r0 = r;
    int avail = 0;
    for(int i = 0; i < l; i++) {
        if(a[i] != c && b[i] != c) avail++;
    }
    for(int i = r+1; i < n; i++) {
        if(a[i] != c && b[i] != c) avail++;
    }
    if(avail < toSwap) {
        cout << "No" << endl;
        return 0;
    }
    else cout << "Yes" << endl;

    int i = 0;
    int j = r0+1;

    while(l <= r) {
        if(i < l0 && a[i] != c && b[i] != c) {
            swap(b[i], b[l]);
            l++;
        }
        i++;
        if(i == n) break;
    }
    if(j < n) {
        while(l <= r) {
            if(j < n && a[j] != c && b[j] != c) {
                swap(b[j], b[l]);
                l++;
            }
            j++;
            if(j == n) break;
        }
    }


    // while(l <= r) {
    //     if(i < l0 && a[i] != c && b[i] != c) {
    //         swap(b[i], b[l]);
    //         l++;
    //         i++;
    //         continue;
    //     }
    //     else if(i == l0 && a[j] != c && b[j] != c && j < n) {
    //         swap(b[j], b[l]);
    //         l++;
    //         j++;
    //         continue;
    //     }
    //     i++;
    //     if(i == l0) j++;
    // }
    pv(b);
    


    
    return 0;
}

Measured memory_bytes: 4772
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let s = input::<i64>();

    let mut ans = 1;
    let mut a = s;
    let mut checked = std::collections::HashSet::new();
    loop {
        checked.insert(a);
        a = if a % 2 == 0 { a / 2 } else { 3 * a + 1 };
        ans += 1;
        if checked.contains(&a) {
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    for (ll i = 0; i < N; i++) {
        if(B >= A + i*(C+D) - (N-1)*D && B <= A + i*(C+D) - (N-1)*C){
            YES();
            return 0;
        }
    }
    NO();
}

Measured memory_bytes: 3616
/*
  Fuad Ashraful Islam
  University of Asia Pacific,Bangladesh
  Date:23th April 2020
  TODO:
  https://vjudge.net/contest/338714
  http://lightoj.com/volume_showproblem.php?problem=1149
 */
#include<bits/stdc++.h>
#define dbg(x) cerr <<__LINE__<<" where "<< #x << " = " << x << endl
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pb push_back

using namespace std;
template <class T>
inline void read(T &res)
{
  res = 0; bool bo = 0; char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-');
  if (c == '-') bo = 1; else res = c - 48;
  while ((c = getchar()) >= '0' && c <= '9')
    res = (res << 3) + (res << 1) + (c - 48);
  if (bo) res = ~res + 1;
}
template<typename T> T Abs(T x){ return x<0?-x:x; }
template<typename T>T Max(T a,T b){return a>b?a:b;}
const int N=1e5+5;
typedef long long ll;
int len,_,n,d,k,m,l,c,cs=1;

int main()
{
  // for(read(_);_;_--)
  int s,w;
  read(s); read(w);
  w>=s?cout<<"unsafe\n":cout<<"safe\n";
  return 0;
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

// これはわからん。解説動画みる。
int main() {
    ll n;
    cin >> n;
    vector<ll> vec(n);
    for (ll &x : vec) {
        cin >> x;
    }

    // 正負
    vector<ll> v = vec;
    ll a = 0;
    // 最初が正
    if (v[0] <= 0) {
        a += abs(v[0]) + 1;
        v[0] += abs(v[0]) + 1;
    }
    for (ll i = 1; i < n; i++) {
        v[i] += v[i-1];
        // 正なら
        if (v[i] >= 0) {
            a += abs(v[i]) + 1;
            v[i] -= abs(v[i]) + 1;
        }
        i++;
        if (i == n) break;

        v[i] += v[i-1];
        // 負なら
        if (v[i] <= 0) {
            a += abs(v[i]) + 1;
            v[i] += abs(v[i]) + 1;
        }
    }

    // for (ll x : v) {
    //     cout << x << " ";
    // } cout << endl;
    
    // 負正
    vector<ll> v2 = vec;
    ll b = 0;
    // 最初が負
    if (v2[0] >= 0) {
        b += abs(v2[0]) + 1;
        v2[0] -= abs(v2[0]) + 1;
    }
    for (ll i = 1; i < n; i++) {
        v2[i] += v2[i-1];
        // 負なら
        if (v2[i] <= 0) {
            b += abs(v2[i]) + 1;
            v2[i] += abs(v2[i]) + 1;
        }
        i++;
        if (i == n) break;

        v2[i] += v2[i-1];
        // 正なら
        if (v2[i] >= 0) {
            b += abs(v2[i]) + 1;
            v2[i] -= abs(v2[i]) + 1;
        }
    }

    // for (ll x : v2) {
    //     cout << x << " ";
    // } cout << endl;

    // DEBUG(a)
    // DEBUG(b)
    cout << min(a, b) << endl;

    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define deb(x) cout << #x << "=" << x << endl;
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   


int main() {
    fastio
    ll sum = 0;
    string s;
    cin>>s;
    for(int i = 0; i<s.length(); ++i) {
        sum += s[i]-'0';
    }

    cout<<(sum%9==0?"Yes":"No")<<endl;
}

Measured memory_bytes: 3672
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

isPrime :: Int -> Bool
isPrime 1 = False
isPrime 2 = True
isPrime n
    | even n = False
    | otherwise = all ((/= 0) . (n `mod`)) [2..(ceiling $ sqrt $ fromIntegral n)]

solve :: Int -> Int
solve n = head $ filter isPrime [n..]

main = do
    num <- readInt
    print $ solve num


Measured memory_bytes: 508
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

x,y = map(int, input().split())

if (x in a) and (y in a):
    print("Yes")

elif (x in b) and (y in b):
    print("Yes")

elif (x in c) and (y in c):
    print("Yes")

else :
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;

vector<LL> fact;
vector<LL> inver(200001);

LL combi(int n,int r){
    if(n<r||n<0||r<0) return 0;
    return fact[n]%mod*inver[n-r]%mod*inver[r]%mod;
}


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

void set_combi(){
    LL s=1;
    fact.push_back(1);
    for(int i=1;i<=200000;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[200000]=fpow(fact[200000],mod-2);
    for(int i=199999;i>=0;i--){
        inver[i]=inver[i+1]*(i+1)%mod;
    }
}

vector<LL> divi(LL K){
    vector<LL> v;
    for(int i=1;i*i<=K;i++){
        if(K%i) continue;
        v.pb(i);
        v.pb(K/i);
    }
    sort(ALL(v));
    v.erase(unique(ALL(v)),v.end());
    return v;
}

vector<LL> t;
LL N,M;

LL dfs(int k,LL sum,LL c){
    if(c>N) return 0;
    if(sum==1){
        return 1;
    }
    if(k==t.size()-1) return 0;
    LL ret=0;
    for(int i=0;;i++){
        if(i&&sum%t[t.size()-k-1]) break;
        if(i==0) ret+=combi(N-c,i)*dfs(k+1,sum,c);
        else{
            sum/=t[t.size()-k-1];
            ret+=combi(N-c,i)*dfs(k+1,sum,c+i);
        }
        ret%=mod;
    }
    return ret%mod;
}



int main(){
    cin >> N >> M;
    t=divi(M);
    set_combi();
    cout << dfs(0,M,0)%mod << endl;
    return 0;
}


Measured memory_bytes: 3968
#include <cstdio>
#include <algorithm>
using std::min;
using std::max;
using std::sort;
#define MAXN 103

int main(void)
{
    int N, K, R;
    int a[MAXN],plate[MAXN];
    scanf("%d%d",&N,&K);
    int i,j,res=0;
    
    for(i=0;i<N;i++)
    {
        scanf("%d",a+i);
    }

    R=min(N,K);
    for(int A=0;A<=R;A++)
    {
        for(int B=0;B<=R-A;B++)
        {
            for(i=0;i<A;i++)
            {
                plate[i]=a[i];
            }
            for(j=0;j<B;j++)
            {
                plate[i+j]=a[N-1-j];
            }
            sort(plate,plate+A+B);
            i=0;
            while(i<K-(A+B) && plate[i]<0)
            {
                i++;
            }
            int s = 0;
            for(;i<A+B;i++)
            {
                s+=plate[i];
            }
            res = max(s,res);
        }
    }
    printf("%d\n",res);
    return 0;
}

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

using namespace std;

int main()
{
  	int n,m,a,tt=0;
  	cin>>n>>m;
  	for(int i=0;i<m;i++)
    {
      cin>>a;
      tt+=a;
    }
  	if(tt>n)
      cout<<"-1"<<'\n';
  	else
      cout<<n-tt<<'\n';
  	return 0;
}

Measured memory_bytes: 3524
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

void solve(long long n, vector<long long> v){
  vector<long long> odd(100001, 0);
  vector<long long> even(100001, 0);
  long long neven, nodd;
  neven = 0;
  nodd = 0;
  for (int i = 0; i < n; i++) {
    if (i%2 == 0) {
      even[v[i]]++;
      neven++;
    } else {
      odd[v[i]]++;
      nodd++;
    }
  }
  long long ret = 0;
  long long maxodd, maxeven;
  long long maxodd2, maxeven2;
  int oddidx, evenidx;
  int oddidx2, evenidx2;
  maxodd = 0;
  maxeven = 0;
  for (int i = 0; i < 100001; i++) {
    if (maxodd < odd[i]) {
      maxodd2 = maxodd;
      maxodd = odd[i];
      oddidx2 = oddidx;
      oddidx = i;
    } else if (maxodd2 < odd[i]) {
      maxodd2 = odd[i];
      oddidx2 = i;
    }
    if (maxeven < even[i]) {
      maxeven2 = maxeven;
      maxeven = even[i];
      evenidx2 = evenidx;
      evenidx = i;
    } else if (maxeven2 < even[i]) {
      maxeven2 = even[i];
      evenidx2 = i;
    }
  }
  ret += nodd - maxodd;
  ret += neven - maxeven;
  if (oddidx == evenidx) {
    ret = min(nodd - maxodd + neven - maxeven2, nodd - maxodd2 + neven - maxeven);
  }
  std::cout << ret << std::endl;
}

int main(){
  long long n;
  scanf("%lld",&n);
  vector<long long> v(n);
  for(int i = 0 ; i < n ; i++){
    scanf("%lld",&v[i]);
  }
  solve(n, v);
  return 0;
}


Measured memory_bytes: 3328
L,R = map(int, input().split())
c = 2018
for i in range(L,R):
  for j in range(i+1,R+1):
    c = min(c,(i*j)%2019)
    if (i*j)%2019 == 0:
      print(c)
      exit()
print(c)      
# 解説をみてから回答

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

#define ll long long
#define endl '\n'
#define M 1000001

int cl[M];
int num[M];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, i;
    int vmax = 0;
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> k;
        if (k > vmax) vmax = k;
        num[i] = k;
    }
    for (i = 0; i < n; i++) {
        int x = num[i];
        while (x <= vmax) {
            cl[x]++;
            x += num[i];
        }
    }
    int ans = 0;
    for (i = 0; i < n; i++) {
        if (cl[num[i]] == 1) ans++;
    }
    // for (i = 0; i < n; i++) {
    //     cout << cl[num[i]] << ' ';
    // }
    // cout << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8336
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, k;
    cin >> n >> k;
    vll h(n);
    REP(i, n) cin >> h[i];
    VSORT(h);
    ll res = 0;
    REP(i, n - k) {
        res += h[i];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include <bits/stdc++.h>
using namespace std;
#define int int32_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l=0,int r=INT_MAX)
{return uniform_int_distribution<int>(l,r)(rng);}

template <typename T,typename G>
ostream& operator << (ostream& out, const pair<T,G> &a) 
{return out<<"( "<<a.x<<", "<<a.y<<")";}

template <typename T>
ostream& operator << (ostream& out, const vector<T> &a) 
{out<<"[ ";for(const auto &i:a)out<<i<<", ";return out<<"]"<<endl;}

template <typename T>
ostream& operator << (ostream& out, const set<T> &a) 
{out<<"{ ";for(const auto &i:a)out<<i<<", ";return out<<"}"<<endl;}

template <typename T,typename G>
ostream& operator << (ostream& out, const map<T,G> &a) 
{out<<"< ";for(const auto &i:a)out<<i<<", ";return out<<">"<<endl;}

template<typename T, size_t N>
typename enable_if<!is_same<typename remove_cv<T>::type, char>::value,
ostream&>::type operator<<(ostream& out, T(&a)[N])
{out<<"[ ";for(size_t i=0;i<N;++i)out<<a[i]<<", ";out <<"]"<<endl;return out;}

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

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n,m,i,id;
	cin>>n>>m;
	vector<int> ct(n+1,0),ac(n+1,0);
	string s;
	for(i=0;i<m;i++){
		cin>>id>>s;
		if(ac[id])
			continue;
		if(s[0]=='W'){
			ct[id]++;
		}else{
			ac[id]=1;
		}
	}
	int sma=0,smb=0;
	for(i=1;i<=n;i++){
		if(ac[i]){
			sma++;
			smb+=ct[i];
		}
	}
	cout<<sma<<" "<<smb;
	return 0;
}


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


int main() {

  string N;
  int Digit_Sum=0;
cin >> N;
  for(int i=0; i<N.size();i++){
    Digit_Sum = Digit_Sum+N.at(i)-48;
  }
  
if(Digit_Sum%9==0){
  cout << "Yes";
}
  else{
  cout << "No";
}

}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
 
int main() {
  int s;
  cin >> s;
  int x = s / 100;
  int y = s % 100;
  
  bool check1 = 0;
  bool check2 = 0;
  
  if (y > 0 && y < 13) check1 = 1;
  
  if (x > 0 && x < 13) check2 = 1;
  
  if (check1 == 1 && check2 == 1) {
    cout << "AMBIGUOUS";
  }
  else if (check1 == 1 && check2 == 0) {
    cout << "YYMM";
  }
  else if (check1 == 0 && check2 == 1) {
    cout << "MMYY";
  }
  else cout << "NA";
  
}

Measured memory_bytes: 256
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {


        var N = Console.ReadLine().ToInt32();
        var an = Console.ReadLine().SplittedStringToInt32List();
        var an2 = Console.ReadLine().SplittedStringToInt32List();
        var ls = new List<int>();
        for (int i = 0; i < N; i++)
        {
            var a1 = an.Take(i + 1).Sum();
            var a2 = an2.Skip(i).Sum();
            ls.Add(a1 + a2);
        }
        Console.WriteLine(ls.Max());

        Console.ReadLine();

    }
    


    
   

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<long> SplittedStringToInt64List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;

    public static int Max(params int[] values)
    {
        var maxes = -1;
        for (int i = 0; i < values.Length; i++)
        {
            maxes = Math.Max(values[i], maxes);
        }
        return maxes;
    }

    #endregion
}



Measured memory_bytes: 13396
n, a, b = map(int, input().split())
a, b, t = min(a, n-a), min(b, n-b), 10**9+7
ans = pow(2, n, t) - 1

X, Y = 1, 1
for i in range(min(a, b)):
    X *= n - i
    X %= t
    Y *= i + 1
    Y %= t
ans -= (X * pow(Y, t-2, t)) % t
if ans < 0:
    ans += t
for i in range(min(a, b), max(a, b)):
    X *= n - i
    X %= t
    Y *= i + 1
    Y %= t
ans -= (X * pow(Y, t-2, t)) % t
if ans < 0:
    ans += t

print(ans)

Measured memory_bytes: 39024
H,W,i,j,t,u;
main(){
    for(;scanf("%d %d",&H,&W),H;puts(""))
        for(i=0,t=H-1;i<H;i++,t--)
            for(j=0,u=W-1;j<W;j++,u--)
                printf("%s%s",i*j*t*u?".":"#",j==W-1?"\n":"");
}

Measured memory_bytes: 1744
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n,0);
    for(int i=0; i<n; i++){
        cin>>a.at(i);
    }
    int s,b;
    long long c;
    s=b=c=a.at(0);
    for(int i=1;i<n;i++){
        s=min(s,a.at(i));
        b=max(b,a.at(i));
        c+=a.at(i);
    }
    cout<<s<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 3120
#include <stdio.h>
#define N 100000

int B[N], C[N];

void countingSort(int A[], int B[], int k, int n) {
	int i, j;

	for (i = 0; i <= k; i++) {
		C[i] = 0;
	}
	for (j = 1; j <= n; j++) {
		C[A[j]]++;
	}
	for (i = 1; i <= k; i++) {
		C[i] = C[i] + C[i - 1];
	}
	for (j = n; j >= 1; j--) {
		B[C[A[j]]] = A[j];
		C[A[j]]--;
	}
}

int main(void) {
	int n, i, j, k = 0;
	int d[N];
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &d[i]);
		if (k < d[i])
			k = d[i];
	}
	
	countingSort(d, B, k, n);

	printf("%d\n", B[n / 2 + 1] - B[n / 2]);
	return 0;
}

Measured memory_bytes: 1280
a,b,c,k=map(int, input().split())
ans = 0
re=k
if a <= re:
	ans += a
	re = k-a
	if  b < re:
		re = re - b
		if c < re:
			ans -= c
		else:
			ans -= re
else:
	ans = k
print(ans)

Measured memory_bytes: 9172
#単なる貪欲アルゴリズム
# A+B < 2Cのとき、ABピザを買う価値はない
# A+B > 2Cのとき、ABピザをできるだけ買う方がよい
# A > 2C のとき、Aピザを買う価値はない
# B > 2C のとき、Bピザを買う価値はない
# A+B = 2Cのとき、どちらでもいい
da = gets.split(" ").map{|nn|nn.to_i}
a = da[0]
b = da[1]
c = da[2]
x = da[3]
y = da[4]
ans = 0
if a + b > 2*c
  if x > y
    ans = 2 * c * y
    if a > 2*c
      ans += 2 * c * (x - y)
    else
      ans += a * (x - y)
    end
  else
    ans = 2 * c * x
    if b > 2*c
      ans += 2 * c * (y - x)
    else
      ans += b * (y - x)
    end
  end
else
  ans = a * x + b * y
end
puts ans.to_s

Measured memory_bytes: 1788
import Foundation

/*
// 1
let N = Int(readLine()!)!

// 1 2
let split = readLine()!.componentsSeparatedByString(" ")
let N = Int(split[0])!
let S = Int(split[1])!

// 1 2 3 4 5
let array = readLine()!.componentsSeparatedByString(" ").map { Int($0)! }
*/

let split = readLine()!.componentsSeparatedByString(" ")
let N = Int(split[0])!
let M = Int(split[1])!

var n = 0
var m = 0
for i in 0..<N {
  n += i
}

for i in 0..<M {
  m += i
}

if N <= 1 { n = 0 }
if M <= 1 { m = 0 }

print(n + m)

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

int main() {
	int n;
	cin >> n;
	int c[550], s[550], f[550];
	for (int i = 0;i < n - 1;i++)cin >> c[i] >> s[i] >> f[i];
	int time = 0;
	int t[550];
	for (int i = 0;i < n - 1;i++) {
		time = s[i];
		for (int j = i;j < n - 1;j++) {
			while (!(s[j] <= time && time%f[j] == 0))time++;
			time += c[j];
		}
		cout << time << endl;
	}
	cout << 0 << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

ll gcd(ll x, ll y) {
  if(x > y)
    return gcd(y, x);
  else if(x == 0)
    return y;
  else
    return gcd(y % x, x);
}
ll lcm(ll x, ll y) {
  ll g = gcd(x, y);
  return g * (x / g) * (y / g);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; ll m; cin >> n >> m;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  auto count = [&](ll n) {
    int ret = 0;
    while(n % 2 == 0) {
      ret++;
      n /= 2;
    }
    return ret;
  };
  int cnt = count(A[0]);
  rep(i, n) {
    if(count(A[i]) != cnt) {
      cout << 0 << endk;
      return 0;
    }
  }
  ll l = A[0];
  rep(i, n) {
    l = lcm(A[i], l);
    if(l/2 > m) {
      cout << 0 << endk;
      return 0;
    }
  }
  cout << (m-l/2) / l + 1 << endk;
  return 0;
}


Measured memory_bytes: 3956