akhauriyash/Code-Regression huggingface dataset:
from sys import stdin, setrecursionlimit
from collections import defaultdict


def initialize_cmb(m, mod=10 ** 9 + 7):
    fac = [1]
    finv = [1]
    inv = [0] * (m + 1)
    if m >= 1:
        fac.append(1)
        finv.append(1)
        inv[1] = 1
        pre_fac = 1
        pre_finv = 1
        for i in range(2, m + 1):
            pre_fac = pre_fac * i % mod
            fac.append(pre_fac)
            inv[i] = mod - inv[mod % i] * (mod // i) % mod
            pre_finv = pre_finv * inv[i] % mod
            finv.append(pre_finv)
    return fac, finv


def cmb(n, k, fac, finv, mod=10 ** 9 + 7):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


def main():
    mod = 10 ** 9 + 7
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))

    arr = [-1] * n

    i1 = i2 = 0

    for i in range(n + 1):
        if arr[a[i] - 1] == -1:
            arr[a[i] - 1] = i
        else:
            i1 = arr[a[i] - 1]
            i2 = i
            break

    fac, finv = initialize_cmb(n + 1, mod)

    for k in range(1, n + 2):
        ans = cmb(n + 1, k, fac, finv, mod)
        if k - 1 <= n - i2 + i1:
            ans -= cmb(n - i2 + i1, k - 1, fac, finv, mod)
        print(ans % mod)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 98456
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846

#include "bits/stdc++.h"
using namespace std;

int main() {
	std::cout<<std::fixed<<std::setprecision(10);
	float a, b, x;
	cin >> a >> b >> x;
	float theta1 = atan(2 * (a * a * b - x) / (a * a * a));
	float theta2 = atan((a * b * b) / (2 * x));

	if (b >= 2 * (a * a * b - x) / (a * a)) {
		cout << theta1 * 180 / PI << endl;
	}
	else {
		cout << theta2 * 180 / PI << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
lst=[0]*n
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for j in range(d):
        lst[a[j]-1]+=1

ans=0
for i in range(n):
    if lst[i]==0:
        ans+=1

print(ans)

Measured memory_bytes: 68572
//package atcoder;

import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int count = 0;
			for(int i=0;i<=25;i++) {
				for(int j=0;j<15;j++) {
					int X = 4*i+7*j;
					if(N==X) {
						count ++;
					}
				}
			}
			if(count>0) {
				System.out.println("Yes");
			}else
				System.out.println("No");
			
	}		
}

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

int main()
{
  int N;
  cin >> N;
  
  vector<int> sides(N);
  for(int i = 0; i < N; ++i)
  {
    cin >> sides.at(i);
  }
  
  sort(sides.begin(), sides.end());
  
  int sum = 0;
  for(int i = 0; i < N - 1; ++i)
  {
    sum += sides.at(i);
  }
  
  if(sum > sides.back())
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vll;
int main(){
  ll n, ans = 0;
  cin >> n;
  vll a(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  ans = a[n/2] - a[n/2-1];
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 2050;
 ll mod = 1e9+7;


int main(){
  ll a,b,ans = 0;
  cin >> a >> b;
  if(a%2 != b%2) cout << "IMPOSSIBLE\n";
  else cout << (a+b)/2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

string S[7] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    rep(i, 7) {
        if(S[i] == s) cout << 7 - i << endl;
    }

    return 0;
}


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

const int M = 64;

int main() {
    int N; cin >> N;
    auto f = [&](int64_t n) -> pair<int, int> {
        int two = 0, five = 0;
        while(n % 2 == 0) n /= 2, two++;
        while(n % 5 == 0) n /= 5, five++;
        return make_pair(two, five);
    };

    vector<vector<int64_t>> A(M, vector<int64_t>(M));
    rep(i, N) {
        long double a; cin >> a;
        int64_t l = (int64_t)(a * 1e9 + 0.5);
        auto[two, five] = f(l);
        A[two][five]++;
    }

    int64_t ans = 0;
    rep(t, M) rep(f, M) rep(_t, M) rep(_f, M) {
        if(make_pair(t, f) <= make_pair(_t, _f)) {
            if(t + _t < 18 || f + _f < 18) continue;
            if(t == _t && f == _f) ans += A[t][f] * (A[t][f] - 1) / 2;
            else ans += A[t][f] * A[_t][_f];
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3784
#include <cmath>
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <sstream>

using namespace std;

long long int fact(int n){
    if(n<=1) return 1;
    return n*fact(n-1);
}
int main(){
    int n;
    cin >> n;
    cout << fact(n) << endl;
    return 0;
}

Measured memory_bytes: 1156
N = int(input())
town_list = [list(map(int, input().split())) for i in range(N)]
import itertools
import math

path = []
for p in itertools.permutations(town_list):
    lengh = 0
    for i in range(N - 1):
        lengh += math.sqrt((p[i][0] - p[i + 1][0]) ** 2 + (p[i][1] - p[i + 1][1]) ** 2)
    path.append(lengh)

print(sum(path) / len(path))


Measured memory_bytes: 4400
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int gv[105];
    cin>>n;
    for(int i=0;i<n;i++) cin>>gv[i];
    int cnt=0;
    for(int i=0;i<n;i++){
        int minj=i;
        for(int j=i;j<n;j++){
            if(gv[j]<gv[minj]){
                minj=j;
            }
        }
        swap(gv[i],gv[minj]);
        if(i!=minj) cnt++;
    }
    for(int i=0;i<n;i++){
        cout<<gv[i];
        if(i!=n-1) cout<<" ";
    }
    cout<<endl;
    cout<<cnt<<endl;
    return 0;
}




Measured memory_bytes: 3116
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  rep(i, n) {
    cin >> a;
    if (i % 2 == 1) continue;
    if (a % 2 == 0) continue;
    ans++;
  }
  Cout(ans);
  return 0;
}

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

using namespace std;

long long N, ans;

void rec(long long s, bool has3, bool has5, bool has7) {
  if (s > N) return;
  if (has3 && has5 && has7) ans++;
  rec(10*s+3, true, has5, has7);
  rec(10*s+5, has3, true, has7);
  rec(10*s+7, has3, has5, true);
}

int main()
{
  cin >> N;
  rec(0, false, false, false);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int e;
	while (cin >> e && e) {
		int ans = 1e9;
		for (int i = 0; i * i * i <= e; ++i) {
			for (int j = 0; j * j <= e - i * i * i; ++j) {
				ans = min(ans, i + j + e - (i * i * i + j * j));
			}
		}
		cout << ans << endl;
	}

	return 0;
}


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

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

  int a[n][m];
  int b[m];
  int c[n] = {0};

  rep(i,n){
    rep(j,m){
      cin >> a[i][j] ;
    }
  }

  rep(j,m) cin >> b[j];

  rep(i,n){
    rep(j,m){
      c[i] += a[i][j] * b[j];
    }
  }
  rep(i,n)  cout << c[i] << endl; 


}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n * 3);
    for (int i = 0; i < 3 * n; ++i) {
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    ll ans = 0;
    for (int i = 0; i < 2 * n; ++i) {
        if (i % 2 == 1) {
            ans += a[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4556
program onedimensional_worlds_tale
  implicit none
  integer n, m, x, y
  integer,allocatable :: xs(:), ys(:)

  read *, n, m, x, y
  allocate(xs(n + 1), ys(m + 1))
  read *, xs(1:n), ys(1:m)
  xs(n + 1) = x
  ys(m + 1) = y
  if (maxval(xs) < minval(ys)) then
     print '(a)', "No War"
  else
     print '(a)', "War"
  end if
  deallocate(xs, ys)
end program onedimensional_worlds_tale


Measured memory_bytes: 256
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	String s = sc.next();
	String t = sc.next();
	char[] sArray = s.toCharArray();
	char[] tArray = t.toCharArray();
	Arrays.sort(sArray);
	String sString = new String(sArray);
	Arrays.sort(tArray);
	char[] tReverse = new char[t.length()];
	for(int i = 0; i < t.length(); i++) {
		tReverse[i] = tArray[t.length() - 1 - i];
	}
	String tString = new String(tReverse);
	if(sString.compareTo(tString) < 0) {
		System.out.println("Yes");
	} else {
		System.out.println("No");
	}
}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define se second
#define fi first
#define pb push_back
#define mp make_pair
using namespace std;

const int N = 30010;
const int MX = 1000000;

int n , a[N],b[N];

int main() {
	scanf("%d",&n);
	for (int i = 0; i < n; ++i){
		scanf("%d",&a[i]);
	}
	for (int i = 0; i < n; ++i){
		scanf("%d",&b[i]);
	}
	ll f = 0 , s = 0;	
	for (int i = 0; i < n; ++i){
		ll ab = abs(a[i]-b[i]);
		if(a[i] <= b[i]){
			f += ab/2 + (ab%2 != 0);
			s += (ab%2 != 0);
		}else{
			s += ab;			
		}
	}
	if(f >= s){
		puts("Yes");
	}else{
		puts("No");
	}
	return 0;
}


Measured memory_bytes: 384
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
const double PI = acos(-1);

int main() {
	int a, b;
	while (cin >> a >> b &&a&&b) {
		if (a < b)swap(a, b);
		int count = 0;
		while (b){
			count++;
			int num = a;
			a = b;
			b = num%b;
		}
		cout << a << " " << count << endl;
	}
}

Measured memory_bytes: 3060
#include <cstdio>

using namespace std;

int main()
{
  char c;
  scanf("%c", &c);
  if (c == 'A')
  {
    printf("T");
  }
  else if (c == 'T')
  {
    printf("A");
  }
  else if (c == 'G')
  {
    printf("C");
  }
  else if (c == 'C')
  {
    printf("G");
  }
  return (0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
#define con 1000000007
using namespace std;


int main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     ll i,j,k,n,m;
     ll t;
     string s;
     cin>>s;
     if(s=="ABC")
         cout<<"ARC";
     else
         cout<<"ABC";
}  


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    vector<int> x(5);
    rep(i,5) cin >> x[i];
    rep(i,5) {
        if (x[i] != i+1) {
            cout << i+1 << endl;
        }
    }  
}


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

typedef long long ll;

ll N, K;
set<ll> R;

int main() {
  cin >> N >> K;
  for (ll i = 0; i < N; ++i) R.insert(i);
  for (ll i = 0; i < K; ++i) {
    ll d;
    cin >> d;
    for (ll j = 0; j < d; ++j) {
      ll a;
      cin >> a;
      --a;
      R.erase(a);
    }
  }
  cout << R.size() << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
  ll n, d;
  cin >> n >> d;
  d = d*d;
  int ans = 0;
  rep(i, n){
    ll x, y;
    cin >> x >> y;
    ll D = x*x + y*y;
    if(D <= d) ans++;
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 3640
function Main(input) {
  // inputにはすべての入力の文字列が与えられるので必要に応じて input.split("\n") などで分割する。

  const data = input.split("\n");
  const ha = data[0].split(" ");
  console.log(Math.ceil(ha[0] / ha[1]));
}

// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.container.rbtree;
import std.stdio;
import std.string;

void main()
{
    Input input = void;
    parseInput(input, stdin);
    auto result = main2(&input);
    writeln(result);
}

auto main2(Input* input)
{
    auto array = input.a.sort!("a>b").array;

	uint[32] powBuckets;

	foreach (uint i, a; array)
	{
		auto rank = bsr(a);
		powBuckets[rank] = i + 1;
	}

	auto waribikiken = input.m;
	int lastNum = -1;
	foreach_reverse (num; powBuckets)
	{
		uint waribikikenToUse = num;
		if (num != 0)
			waribikikenToUse = num;
		else if (lastNum != -1)
			waribikikenToUse = lastNum;

		if (waribikikenToUse <= waribikiken)
		{
			for (int i = 0; i < waribikikenToUse; i++)
				array[i] >>= 1;
			waribikiken -= waribikikenToUse;
			lastNum = waribikikenToUse;
		}
		else
			break;
	}

	while (waribikiken >= array.length)
	{
		foreach (ref a; array)
			a >>= 1;
		waribikiken -= array.length;
	}

	array.sort!("a>b");

	for (int j = 0; j < waribikiken; j++)
		array[j] >>= 1;

    BigInt count = 0;
	foreach (a; array)
		count += a;
    return count;
}

unittest { writefln("begin unittest"); }

unittest // example1
{
    string example =
`3 3
2 13 8`;
    Input input = void;
    parseExample(input, example);
    auto result = main2(&input);
    assert(result == 9);
}

unittest // example2
{
    string example =
`4 4
1 9 3 5`;
    Input input = void;
    parseExample(input, example);
    auto result = main2(&input);
    assert(result == 6);
}

unittest // example3
{
    string example =
`1 100000
1000000000`;
    Input input = void;
    parseExample(input, example);
    auto result = main2(&input);
    assert(result == 0);
}

unittest // example4
{
    string example =
`10 1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000`;
    Input input = void;
    parseExample(input, example);
    auto result = main2(&input);
    assert(result == 9500000000);
}

unittest { writefln("end unittest"); }

struct Input
{
	uint n,m;
    uint[] a;
}

void parseInput(T)(out Input input, T file)
{
    with (file) with (input)
    {
		auto nm = readln().strip().split().map!(a=>a.to!uint).array();
		n = nm[0]; m = nm[1];
        input.a = readln().strip().split().map!(a=>a.to!uint).array();
    }
}

void parseExample(out Input input, string example)
{
    struct Adapter
    {
        import std.string;

        string[] _lines;
        this(string input) { _lines = input.splitLines(); }

        string readln()
        {
            auto line = _lines[0];
            _lines = _lines[1..$];
            return line;
        }
    }
    Adapter a = Adapter(example);
    parseInput(input, a);
}


Measured memory_bytes: 5456
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            int n = sc.nextInt();
            if(n==0) break;

            int[] num = new int[n+1];
            for(int i=0; i<n; i++) num[i] = sc.nextInt();
            num[n] = -1; 

            int first = num[0], last = num[0];
            for(int i=1; i<=n; i++){
                if(last+1==num[i]){
                    last = num[i];
                }else{
                    if(first!=last){
                        System.out.print(first+"-"+last);
                    }else{
                        System.out.print(first);
                    }
                    if(i!=n) System.out.print(" ");
                    first = num[i]; last = num[i];
                }
            }
            System.out.println();
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

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


int main(void){
        int N, P;
        cin >> N >> P;
        ll ans = 1;
        int a[2] = {0,0};
        rep(i,N) {
                int A;
                cin >> A;
                a[A%2]++;
                ans *= 2;
        }

        if (a[1] == 0) {
                if ( P == 1) ans = 0;
        }
        else ans /= 2;

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

Measured memory_bytes: 3624
import Data.Array.IO

main = do
    n <- readLn
    a <- map read . words <$> getLine :: IO [Int]
    b <- map read . words <$> getLine :: IO [Int]
    let ans = solve n [a,b] 1 (n - 1)
    print ans

solve :: Int -> [[Int]] -> Int -> Int -> Int
solve n a i j = 
    if i < 0 || j < 0
        then 0
        else (a !! i !! j) + max (solve n a  (i - 1) j) (solve n a  i (j - 1))



Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define mod 1000000007
#define dd double
#define ld long double
#define f(i,a,b) for(ll i = a; i < b; i++)
#define fr(i,a,b) for(ll i = b;i>=a;i--)
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define vpll vector< pii >
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define Sort(v) sort(v.begin(), v.end(), sortbysec)
#define MEM(a, b) memset(a, (b), sizeof(a))

ll power(ll x, ll y, ll p)  
{  
    ll res = 1;      
    x = x % p; 
                
    while (y > 0)  
    {   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}  

 

int main() 
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);

ll n,d;
cin>>n>>d;

vll v[n];
f(i,0,n){
    f(j,0,d)
    {
        ll x;
        cin>>x;
        v[i].pb(x);
    }
}

ll ans = 0;
f(i,0,n){
    f(j,i+1,n)
    {
        ll temp = 0;
        f(k,0,d)
        {
            temp += pow((v[i][k]-v[j][k]),2);
        }
        ll tmp = sqrt(temp);
        if(tmp*tmp == temp)
        ans++;
    }
}

cout<<ans<<endl;




}


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

#include <bits/stdc++.h>
using namespace std;

typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef long long ll;

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vvi c_a(n,vi(m+1));
    for(int i=0;i<n;i++){
        cin >> c_a[i][0];
        for(int j=1;j<=m;j++){
            cin >> c_a[i][j];
        }
    }
    int ans = 1e9;
    for(int i=0;i<(1<<n);i++){
        vi temp(m+1,0);
        for(int j=0;j<n;j++){
            if((i>>j)&1) continue;
            for(int k=0;k<=m;k++){
                temp[k]+=c_a[j][k];
            }
            //cout << j << endl;
        }
        bool flag=true;
        //cout << " now i : " << i << endl;
        for(int j=1;j<m+1;j++){
            //cout << temp[j] << " ";
            if(temp[j]<x) flag = false;
        }
        //cout << endl;
        if(flag) ans=min(ans,temp[0]);
    }

    if(ans==1e9) cout << "-1" << endl;
    else cout << ans << endl;
    return 0 ;
}

Measured memory_bytes: 3640
// -*- coding:utf-8-unix -*-

use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: String,
    }
    let mut count = HashMap::new();
    for c in n.chars() {
        if count.contains_key(&c) {
            *count.get_mut(&c).unwrap() += 1
        }
        else {
            count.insert(c, 1);
        }
    }
    let mut ans = true;
    for (_k, v) in count {
        if v != 2 {
            ans = false;
            break;
        }
    }
    println!("{}", if ans { "Yes" } else { "No" });
}


Measured memory_bytes: 2192
import sys
from decimal import Decimal, ROUND_HALF_UP
import math
input = sys.stdin.readline
#sys.setrecursionlimit(1e9)

def main():
    """code here"""
    x=int(input())
    dp = [0]*(x+1)
    dp[0]=1
    for i in range(x+1):
        if dp[i]:
            for tmp in [100,101,102,103,104,105]:
                if i+tmp<=x:
                    dp[i+tmp]=1
    print(dp[-1])




if __name__ == '__main__':
    main()

Measured memory_bytes: 5844
H, W = map(int, input().split())
A = [input() for _ in range(H)]
B = [A[h] for h in range(H) if '#' in A[h]]

rem = []
for w in range(W):
    col = [B[i][w] for i in range(len(B))]
    if '#' not in col:
        rem.append(w)

for h in range(len(B)):
    for w in range(W):
        if w not in rem:
            print(B[h][w], end="")
    print()

Measured memory_bytes: 4468
n, x, y = map(int, input().split())
k = y - x + 1
s = [0 for i in range(n-1)]
a = x - 1
b = n - y
if k % 2 == 0:
    for i in range(k // 2-1):
        s[i] += k
    s[k//2-1] += k // 2
    for i in range(a):
        for j in range(k // 2):
            if j == 0:
                s[i+j] += 1
                s[i+k//2] += 1
            else:
                s[i+j] += 2
    for i in range(b):
        for j in range(k // 2):
            if j == 0:
                s[i+j] += 1
                s[i+k//2] += 1
            else:
                s[i+j] += 2
    for i in range(a):
      for j in range(b):
        s[2+i+j] += 1
    for i in range(a-1):
        for j in range(i+1, a):
            s[j-i-1] += 1
    for i in range(b-1):
        for j in range(i+1, b):
            s[j-i-1] += 1
else:
    for i in range(k // 2):
        s[i] += k
    for i in range(a):
        for j in range(k // 2 + 1):
            if j == 0:
                s[i+j] += 1
            else:
                s[i+j] += 2
    for i in range(b):
        for j in range(k // 2 + 1):
            if j == 0:
                s[i+j] += 1
            else:
                s[i+j] += 2
    for i in range(a):
        for j in range(b):
            s[2+i+j] += 1
    for i in range(a-1):
        for j in range(i+1, a):
            s[j-i-1] += 1
    for i in range(b-1):
        for j in range(i+1, b):
            s[j-i-1] += 1

print(*s)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
using namespace std;

int main(){
	int n, k;
	vector< int > a;
	vector< int > r;
	
	while(cin >> n >> k, n){
		a.CLR();
		r.CLR();
		
		a.RS(n);
		r.RS(n - k + 1);
		
		REP(i, n) cin >> a[i];
		
		REP(i, k) r[0] +=  a[i];
		
		FOR(i, k, n){
			r[i-k+1] = r[i-k] + a[i] - a[i-k];
		}
		cout << *max_element(ALL(r)) << endl;
	}
	
	return 0;
}

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

int main() {
  int a, b, c, d;
  int ta, ao;
  
  cin >> a >> b >> c >> d;
  
  ta = a / d;
  ao = c / b;
  if(a % d >= 1) ta++;
  if(c % b >= 1) ao++;
  
  if(ta < ao) cout << "No" << endl;
  else if(ta >= ao) cout << "Yes" << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
string LCS(string a,string b)
{
  int i,j,n=a.size(),m=b.size();
   int dp[n+1][m+1];
    for(i=0;i<=n;i++)
    dp[i][0]=0;
    for(i=0;i<=m;i++)
    dp[0][i]=0;
    
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(a[i-1]==b[j-1])
            dp[i][j]=1+dp[i-1][j-1];
            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    
   string ans="";
   i=n,j=m;
   while(i>0 && j>0)
   {
      if(a[i-1]==b[j-1])
      {
          ans.pb(a[i-1]);
          i--;j--;
      }
      else
      {
          if(dp[i-1][j]>dp[i][j-1])
          i--;
          else
          j--;
      }
   }
  
   reverse(ans.begin(),ans.end());
   return ans;
}

int main() {
   string a,b;
   cin>>a>>b;
   
    cout<<LCS(a,b);
	return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
    int A, B, C;
    cin >> A >> B >> C;

    if ((A < C && C < B) || (A > C && B < C)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int r = a%b;
    string ans = "NO";
    rep(i, b){
        if ((r*i)%b == c) ans = "YES";
    }
    cout << ans << endl;

}

Measured memory_bytes: 3588
k, s = map(int, input().split())
if 0 <= s <= k:
    ans = (s+1)*(s+2)/2
    print(int(ans))
elif k < s <= 2*k:
    ans = ((s+1)*(s+2)/2) - ((s-k)*(s-k+1)/2) - ((s-k)*(s-k+1))
    print(int(ans))
elif 2*k < s < 3*k:
    print(3)
else:
    print(1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i)
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
#define dis distance
#define so sort
#define rev reverse
#define pub push_back
#define sec second
#define fir first

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 30);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s ;
	stack<int> S;	//1 => White, 2 => Black
	REP(i,SZ(s)){
		if(s[i] == 'W'){
			S.push(1);
		}else{
			S.push(2);
		}
	}

	int ans = 0;
	int ntop;
	while(!S.empty()){
		ntop = S.top();
		S.pop();
		while((!S.empty())&&(S.top() == ntop)){
			S.pop();
		}
		ans++;
	}
	cout << ans-1 << endl;
	return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[111111];

signed main(){
    scanf("%lld",&N);
    rep(i,N)scanf("%lld",&A[i]);

    int sum=0;
    rep(i,N){
        sum+=A[i]/2;
        A[i]%=2;
        if(A[i]&&A[i+1]){
            sum++;
            A[i]--;
            A[i+1]--;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;
const ll MAX_D = 40;
const ll MOD_P = 1000000000 + 7;

ll binpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a;
    a = a * a;
    n = n >> 1;
  }
  return res;
}

int main() {

  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  ll A, B;
  cin >> A >> B;
  ll d[MAX_D];

  for(ll i = 0; i < MAX_D; i++) {
    ll at = A / binpow(2, i + 1);
    ll ap = A % binpow(2, i + 1);
    ll bt = B / binpow(2, i + 1);
    ll bp = B % binpow(2, i + 1);

    ll n_one = 0;
    ll diff_t = bt - at;
    n_one += (diff_t - 1) * binpow(2, i);

    if (ap >= pow(2, i + 1)/2)  n_one += binpow(2, i + 1) - ap;
    else n_one += binpow(2, i + 1)/2;

    if (bp < pow(2, i + 1)/2)  n_one += 0;
    else n_one += bp - binpow(2, i + 1)/2 + 1;

    if (n_one % 2 == 0) d[i] = 0;
    else d[i] = 1;
  }

  ll ans = 0;
  for(ll i = 0; i < MAX_D; i++) ans += d[i] * binpow(2, i);
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3324
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
    int n, k;

    cin >> n >> k;

    int h[n];

    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    int m[n + 1];

    for (int i = 0; i < n; i++) {
        m[i] = 999999999;
    }

    m[0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= k; j++) {
            if (i + j < n) {
                m[i + j] = min(m[i + j],
                               m[i] + abs(h[i] - h[i + j]));
            }
        }
    }

    cout << m[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define inf 1e9
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (ll i = (ll)(x); i < (ll)(n); i++)
#define repfr(i, n, x) for (ll i = (ll)(n)-1; i >= (ll)(x); i--)
using ll = int64_t;

void Main() {
  int n;
  std::cin >> n;
  int sum = 0;
  int tmp = n;
  while (tmp) {
    sum += tmp % 10;
    tmp /= 10;
  }

  std::cout << (n % sum ? "No" : "Yes") << '\n';
  return;
}

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: 256
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

int main() {

    int N,M,ans,cnt=0;
    cin >> N >>M >>ans;
   /* vector<int>A(N);
    for (int i = 0; i < N; i++) { cin >> A.at(i); }
    */
  while(ans>0){ans-=max(N,M);cnt++;}
    cout<<cnt<<endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int cmb (int a, int b) {
    int res = 1;
    rep (i, 0, b) {
        res *= (a - i);
        res /= (i + 1);
    }
    return res;
}

signed main() {
    int n, a, b;
    cin >> n >> a >> b;
    int v[n];
    rep (i, 0, n) cin >> v[i];
    sort (v, v + n, greater<int>());
    double sum = 0;
    int memo = v[a - 1];
    int cnt2 = 0;
    rep (i, 0, a) {
        sum += v[i];
        if (memo == v[i]) cnt2++;
    }
    int cnt = 0;
    rep (i, 0, n) if (memo == v[i]) cnt++;
    int ans = 0;
    if (v[0] != v[a - 1]) {
        ans = cmb (cnt, cnt2);
    } else {
        rep (i, a, min (b + 1, cnt + 1)) { ans += cmb (cnt, i); }
    }
    cout << fixed << setprecision (15) << sum / a << "\n" << ans << "\n";
}

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

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

  int cnt = 0;
  for (int i = 1; i < m + 1; i++) {
    for (int j = 10; j < d+1; j++) {
      int r = j % 10;
      int l = (j-r)/10;
      if (r >= 2 && l >= 2 && r*l == i) cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
// Author : Rifayat Samee (Sanzee)
// Problem :
// Algorithm:

/*

*/
#include <bits/stdc++.h>
using namespace std;
#define maxval 100005
int main(){

	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
    int n,k;
    scanf("%d %d",&n,&k);
    vector<int>h(n+1);
    vector<int>dp(n+1,1e9+5);
    //printf("%d\n",dp[n-1]);
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    dp[0] = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=i+k && j<n;j++){
            dp[j] = min(dp[j],dp[i] + abs(h[j]-h[i]));
        }
    }
    printf("%d\n",dp[n-1]);
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_DATA_LENGTH 1000

int strIndex(int i) {
    // translate 1-origin to 0-origin since 
    // we use 1 origin for this program but C string is 0-origin
    return i-1;
}

int LCSLength(char X[], char Y[]) {
    int m = strlen(X);
    int n = strlen(Y);
    
    int c[m+1][n+1];
    int i, j;
    
    for (i = 1; i <= m; i++) c[i][0] = 0;
    for (j = 0; j <= n; j++) c[0][j] = 0;
    
    for (i = 1; i <= m; i++) {
        for (j = 1; j <= n; j++) {
            if (X[strIndex(i)] == Y[strIndex(j)])
                c[i][j] = c[i-1][j-1] + 1;
            else if (c[i-1][j] >= c[i][j-1])
                c[i][j] = c[i-1][j];
            else
                c[i][j] = c[i][j-1];
            
//            printf("%d ", c[i][j]);
        }
//            printf("c[%d] ended\n", i);
    }
        
//            printf("RESULT c[%d][%d] = %d\n", m, n, c[m][n]);
    return c[m][n];
}

int main(int argc, char** argv) {
    int nDatasets;
    scanf("%d", &nDatasets);
    
    char X[MAX_DATA_LENGTH], Y[MAX_DATA_LENGTH];
    
    for (int i = 0; i < nDatasets; i++) {
        scanf("%s", X);
        scanf("%s", Y);
        printf("%d\n", LCSLength(X,Y));
    }

    return (EXIT_SUCCESS);
}




Measured memory_bytes: 5676
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    A = LI()
    MAX = max(A)
    MIN = min(A)
    print(2*N-1)
    if abs(MAX)<abs(MIN):
        #全部負にする
        min_idx = A.index(MIN) + 1
        for i in range(1,N+1):
            print(min_idx, i)
        #累積和
        for i in range(2,N+1)[::-1]:
            print(i,i-1)
    else:
        #全部非負にする
        max_idx = A.index(MAX) + 1
        for i in range(1,N+1):
            print(max_idx, i)
        #累積和
        for i in range(1,N):
            print(i,i+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5392
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int s;
    cin >> s;

    int s01 = s / 10 / 10;
    int s23 = s - s01 * 10 * 10;

    bool ym = false, my = false;
    if (s23 > 0 && s23 < 13) ym = true;

    if (s01 > 0 && s01 < 13) my = true;

    if (ym && my) {
        cout << "AMBIGUOUS" << endl;
    } else if (ym) {
        cout << "YYMM" << endl;
    } else if (my) {
        cout << "MMYY" << endl;
    } else {
        cout << "NA" << endl;
    }


    cout << fixed << setprecision(20);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
ll par[100000],sz[100000];
 
int find(int x){
	if(x==par[x])return x;
	return par[x]=find(par[x]);
}
void unite(int x,int y){
	x=find(x);y=find(y);
	if(x==y)return;
	par[x]=y;sz[y]+=sz[x];
}
 
int main(){
	int n,m;scanf("%d%d",&n,&m);
	rep(i,n){
		par[i]=i;
		sz[i]=1;
	}
	rep(i,m){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		unite(a,b);
	}
	ll a=sz[find(0)];
	ll b=sz[find(1)];
	ll c=n-a-b;
	if(a<b)b+=c;
	else a+=c;
	cout<<a*(a-1)/2+b*(b-1)/2-m<<endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0;i<n;i++)
int mx=90001;
int a,h,w,d,q,l,r,y[90001],x[90001],s[90001];
int main() {
	cin>>h>>w>>d;
	REP(i,h)REP(j,w) { cin>>a; y[a]=i,x[a]=j; }
  REP(i,h*w-d+1) s[i+d]=s[i]+abs(x[i+d]-x[i])+abs(y[i+d]-y[i]);
	cin >> q;
  REP(i,q) { cin>>l>>r; cout << s[r]-s[l] << endl; }
}

Measured memory_bytes: 4556
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<int> a(n);

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    using ll = long long;

    const ll mod = 1000000007;

    vector<vector<ll>> dp(n + 1, vector<ll>(k + 1));

    for (int i = 0; i <= n; i++) {
        dp[i][0] = 1;
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
            dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % mod;

            if (j - a[i - 1] - 1 >= 0) {
                dp[i][j] = (dp[i][j] + (mod - dp[i - 1][j - a[i - 1] - 1])) % mod;
            }
        }
    }

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


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

int main()
{
	for(int i = 1; i <= 9; i++)
	{
		for(int j = 1; j <= 9; j++)
		{
			cout << i << 'x' << j << '=' << i*j << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define LL long long
int main()
{
   int a,b;
   cin>>a>>b;
   cout<<a*b-(a+b-1)<<endl;
}

Measured memory_bytes: 256
N,x=map(int,input().split())
a=[int(y) for y in input().split()]
a.sort()
ans=0
if sum(a)<x:
  ans=N-1
else:
  ans=0
  for i in range(N):
    if x>=a[i]:
      x-=a[i]
      ans+=1
    else:
      break
print(ans)

Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
 
public class Main implements Runnable {
	
    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }
    
    public void run() {
        FastScanner sc = new FastScanner();
        
        int p = sc.nextInt();
        int q = sc.nextInt();
        int r = sc.nextInt();
        
        int ans = Math.min(p+q,q+r);
        ans = Math.min(ans,r+p);

        System.out.println(ans);
    }

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextIntArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public Integer[] nextIntegerArray(int n){
		Integer[] a = new Integer[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 22484
#include<iostream>
#include<string>
using namespace std;
int main(){
int N,K;
  string S;
  cin>>N>>K>>S;
  if(S[K-1]=='A'){
  S[K-1]='a';
  }
  else if(S[K-1]=='B'){
  S[K-1]='b';
  }
  else if(S[K-1]=='C'){
  S[K-1]='c';
  }
  cout<<S<<endl;
  return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll ppow(ll a,ll b){
	a%=MOD;
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
class Fact{
	vector<ll>fact;
	vector<ll>inv;
public:
	Fact(){}
	Fact(int n){
		n=n*2+10;
		fact=inv=vector<ll>(n);
		fact[0]=inv[0]=1;
		for(int i=1;i<n;i++){
			fact[i]=(fact[i-1]*i)%MOD;
		}
		inv[n-1]=ppow(fact[n-1],MOD-2);
		for(int i=n-2;i>=0;i--){
			inv[i]=(inv[i+1]*(i+1))%MOD;
		}
	}
	ll get(int n){
		return fact[n];
	}
	ll get_inv(int n){
		return inv[n];
	}
	ll nPr(int n,int r){
		return fact[n]*inv[n-r]%MOD;
	}
	ll nCr(int n,int r){
		return nPr(n,r)*inv[r]%MOD;
	}
	ll nrP(int n,int r){
		return nPr(n+r,n);
	}
	ll nrC(int n,int r){
		return nCr(n+r,n);
	}
};
int main(){
	Fact fac(1e4);
	int s;cin>>s;
	ll ans=0;
	for(int n=1;n*3<=s;n++){
		int d=s-3*n;
		(ans+=fac.nCr(d+n-1,n-1))%=MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3600