akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <numeric>
using namespace std;

int main(){
    long long N,tmp1,tmp2;
    long long A[200000],B[200000];
    cin>>N;
    vector <pair<long long,long long>> v(N);
    for(int i=0;i<N;i++){
        cin>>tmp1>>tmp2;
        v[i]={tmp2,tmp1};
    }

    sort(v.begin(),v.end());
    
    int t=0;
    for(int i=0;i<N;i++){
        t+=v[i].second;
        if(t>v[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;


}

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

static int cnt=0;

void show(int A[], int N){
  for(int i=0; i<N; i++){
    if(i) cout << " ";
    cout << A[i];
  }
  cout << endl;
}

void bubbleSort(int A[], int N){
  int tmp;
  for(int i=0; i<N; i++){
    for(int j=N-1; j>i; j--){
      if(A[j]<A[j-1]){
        tmp = A[j];
        A[j] = A[j-1];
        A[j-1] = tmp;
        cnt++;
      }
    }
  }
  show(A, N);
}

int main(){
  int N, A[100];
  cin >> N;
  for(int i=0; i<N; i++) cin >> A[i];
  bubbleSort(A, N);
  cout << cnt << endl;
}

Measured memory_bytes: 3072
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	string a;
	cin >> a;
	int cnt=0;
	char c = '0';
	char d = '1';
	for (int i = 0; i < a.length()-1; i++)
	{
		if (a[i] == a[i + 1])
		{
			cnt++;
			if (a[i] == c) a[i + 1] = d;
			else a[i + 1] = c;
		}
	}
	cout << cnt;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <map>
#include <algorithm>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 998244353;

template <class T>
class FenwickTree {
public:
	void init(int _n) {
		this->n = _n;
		bit.assign(n + 1, 0);
	}

	T qry(int x) {
		x = std::min(x, n);
		T ans = 0;
		for(; x > 0; x -= x & -x) {
			ans += bit[x];
		}
		return ans;
	}

	void upd(int x, T v) {
		if(x <= 0) return;
		for(; x <= n; x += x & -x) {
			bit[x] += v;
		}
	}
private:
	int n;
	std::vector<T> bit;
};


int freq[200200][5];

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	std::map<int, int> vx, vy;
	int n;
	std::cin >> n;
	std::vector<std::pair<int, int> > pts(n);
	for(int i = 0; i < n; i++) {
		std::cin >> pts[i].first >> pts[i].second;
		vx[pts[i].first] = 0;
		vy[pts[i].second] = 0;
	}
	{
		int t = 0;
		for(auto &i : vx) {
			i.second = t++;
		}
		t = 0;
		for(auto &i : vy) {
			i.second = t++;
		}
	}
	for(auto &pt : pts) {
		pt.first = vx[pt.first];
		pt.second = vy[pt.second];
	}
	std::sort(pts.begin(), pts.end());
	{
		// go
		FenwickTree<int> tree;
		tree.init(n + 2);
		for(int i = 0; i < n; i++) {
			int x = pts[i].first, y = pts[i].second;
			freq[i][0] = tree.qry(y);
			freq[i][1] = tree.qry(n + 2) - freq[i][0];
			tree.upd(y + 1, 1);
		}
	}
	{
		// back
		FenwickTree<int> tree;
		tree.init(n + 2);
		for(int i = n-1; i >= 0; i--) {
			int x = pts[i].first, y = pts[i].second;
			freq[i][2] = tree.qry(y);
			freq[i][3] = tree.qry(n + 2) - freq[i][2];
			freq[i][4] = 1;
			tree.upd(y + 1, 1);
		}
	}
	int ans = 0;
	std::vector<int> two(n + 1, 1);
	for(int i = 1; i <= n; i++) {
		two[i] = two[i-1] * 2 % MOD;
	}
	for(int i = 0; i < n; i++) {
		// answer with itself
		ans = (ans + two[n-1]) % MOD;
		// answer without itself with 4 corners
		long long cur = 1;
		for(int j = 0; j < 4; j++) cur = cur * (two[freq[i][j]] - 1) % MOD;
		ans = (ans + (int) cur) % MOD;
		// answer with 3 corners
		for(int k = 0; k < 4; k++) {
			cur = 1;
			for(int j = 0; j < 4; j++) {
				if(j != k) {
					cur = cur * (two[freq[i][j]] - 1) % MOD;
				}
			}
			ans = (ans + (int) cur) % MOD;
		}
		// answer with 2 corners
		for(int k = 0; k < 2; k++) {
			int j = k;
			cur = 1;
			cur = cur * (two[freq[i][j]] - 1) % MOD;
			j ^= 3;
			cur = cur * (two[freq[i][j]] - 1) % MOD;
			ans = (ans + (int) cur) % MOD;
		}
	}
	std::cout << ans << '\n';
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100

ll N;
ll dp[MAX_N];

int main()
{
    ZERO(dp);
    cin >> N;

    dp[0] = 2; dp[1] = 1;
    for(int i = 2; i <= 86; ++i) {
        dp[i] = dp[i-1] + dp[i-2];
    }
    printf("%lld\n", dp[N]);
    return 0;
}


Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; }
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; }
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; }
ll modPow(ll x,ll n,ll mod=MOD){
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod);
}
using namespace std;
int main(void){
    ll N;cin>>N;
    vector<ll> T(N);
    REP(i,N)cin>>T[i];
    ll ans=1;
    REP(i,N){
        ans=LCM(ans,T[i]);
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

const string YES = "Yes";
const string NO = "No";

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long k, long long x){

    cout << (k * 500 >= x ? "Yes" : "No") << endl;
}


signed main(){
    long long K;
    scanf("%lld",&K);
    long long X;
    scanf("%lld",&X);
    solve(K, X);
    return 0;
}


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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

struct segtree {
    int n;
    vector<ll> T, U;

    segtree(int n) : n(n) {
        T.resize(4 * n);
        U.resize(4 * n);
    }

    void push(int v) {
        T[2 * v] += U[v];
        U[2 * v] += U[v];
        T[2 * v + 1] += U[v];
        U[2 * v + 1] += U[v];
        U[v] = 0;
    }

    void upd(int lq, int rq, ll x, int v, int l, int r) {
        if (r < lq || l > rq)
            return ;

        if (lq <= l && r <= rq) {
            T[v] += x;
            U[v] += x;
            return ;
        }

        push(v);
        int m = (l + r) / 2;
        upd(lq, rq, x, 2 * v, l, m);
        upd(lq, rq, x, 2 * v + 1, m + 1, r);
        T[v] = min(T[2 * v], T[2 * v + 1]);
    }

    ll get(int lq, int rq, int v, int l, int r) {
        if (r < lq || l > rq)
            return INF * INF;

        if (lq <= l && r <= rq)
            return T[v];

        push(v);
        int m = (l + r) / 2;
        return min(get(lq, rq, 2 * v, l, m), get(lq, rq, 2 * v + 1, m + 1, r));
    }

    void upd(int lq, int rq, ll x) { upd(lq, rq, x, 1, 0, n - 1); }
    ll get(int lq, int rq) { return get(lq, rq, 1, 0, n - 1); }
};

int n, m;
ll S;
vector< pair<int, int> > v[MAXN];

bool read() {
    if (!(cin >> n >> m))
        return false;

    forn (i, m) {
        int l, r, x;
        cin >> l >> r >> x;
        v[r].pb(mp(l, x));
        S += x;
    }

    return true;
}

void solve() {
    segtree T(n + 2);

    for (int i = 1; i <= n + 1; ++i) {
        auto cur = T.get(0, i - 1);
        T.upd(i, i, cur);

        if (i == n + 1)
            cout << S - cur << endl;

        for (auto p : v[i])
            T.upd(0, p.f - 1, p.s);
    }
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 42496
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = 1e-9;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline ll gcd(ll a, ll b) {
	while (b) {
		ll c = a;
		a = b; b = c % b;
	}
	return a;
}
inline ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
bool isprime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
ll mypow(ll a, ll b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	ll memo = mypow(a, b >> 1);
	return memo * memo;
}
int h, w;
char c[110][110];
int dist[2][110][110];
int f[] = { 0,1 };
int g[] = { 1,0 };
signed main() {
	cin >> h >> w;
	rep(i, h) {
		rep(j, w)cin >> c[i][j];
	}
	deque<pair<int, P>> deq;
	rep(i, h) {
		rep(j, w)dist[0][i][j] = dist[1][i][j] = -1;
	}
	if (c[0][0] == '.') {
		dist[0][0][0] = 0;
		deq.push_back(make_pair(0, make_pair(0, 0)));
	}
	else {
		dist[1][0][0] = 1;
		deq.push_back(make_pair(1, make_pair(0, 0)));
	}
	while (!deq.empty()) {
		pair<int, P> p = deq.front();
		deq.pop_front();
		rep(i, 2) {
			int ni = p.second.first + f[i], nj = p.second.second + g[i], nk = p.first;
			if (h <= ni || w <= nj)continue;
			if (c[ni][nj] == '.') {
				if (nk == 0 && dist[0][ni][nj] == -1) {
					dist[0][ni][nj] = dist[nk][p.second.first][p.second.second];
					deq.push_front(make_pair(0, make_pair(ni, nj)));
				}
				if (nk == 1 && dist[0][ni][nj] == -1) {
					dist[0][ni][nj] = dist[nk][p.second.first][p.second.second] + 1;
					deq.push_back(make_pair(0, make_pair(ni, nj)));
				}
			}
			if (c[ni][nj] == '#') {
				if (nk == 1 && dist[1][ni][nj] == -1) {
					dist[1][ni][nj] = dist[nk][p.second.first][p.second.second];
					deq.push_front(make_pair(1, make_pair(ni, nj)));
				}
				if (nk == 0 && dist[1][ni][nj] == -1) {
					dist[1][ni][nj] = dist[nk][p.second.first][p.second.second] + 1;
					deq.push_back(make_pair(1, make_pair(ni, nj)));
				}
			}
		}
	}
	if (c[h - 1][w - 1] == '#')cout << (dist[1][h - 1][w - 1] + 1) / 2 << endl;
	else cout << dist[0][h - 1][w - 1] / 2 << endl;
	return 0;
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

int main() {
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        if (i % 2 == 0)
            continue;
        int cnt = 0;
        for (int j = 1; j <= i; ++j) {
            if (i % j == 0)
                cnt++;
        }
        if (cnt == 8)
            ans++;
    }
    cout << ans << endl;

    return 0;
}

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

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

    int cnt = a;
    while (cnt <= 10000) {
        if (cnt % b == c) {
            cout << "YES" << endl;
            return 0;
        }
        cnt += a;
    }
    cout << "NO" << endl;
    return 0;
}

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

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

    bool ok = true;
    for (int i = n - 2; i >= 0; i--) {
        if (h[i] <= h[i + 1]) continue;
        if (h[i] == h[i + 1] + 1) {
            h[i]--;
            continue;
        }
        ok = false;
        break;
    }

    if (ok)
        puts("Yes");
    else
        puts("No");
}

Measured memory_bytes: 640
import sys

# inputを高速化する。
input = sys.stdin.readline

# 入力
vacation = int(input())
lst_happiness = [list(map(int, input().split())) for i in range(vacation)]

# DPテーブル
# 最大化問題なので0で初期化
dp = [[0 for i in range(3)] for j in range(vacation+1)]

def chmax(a, b):
    if a > b:
        return a
    else:
        return b

# dp[i][0] から dp[i + 1][1] への遷移
# dp[i][0] から dp[i + 1][2] への遷移
# dp[i][1] から dp[i + 1][0] への遷移
# dp[i][1] から dp[i + 1][2] への遷移
# dp[i][2] から dp[i + 1][0] への遷移
# dp[i][2] から dp[i + 1][1] への遷移
# 各 j (= 0, 1, 2) と各 k (= 0, 1, 2) に対して、j ≠ k ならば
# chmin(dp[i + 1][k], dp[i [j] + lst_happiness[i][k])
for i in range(vacation):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = chmax(dp[i+1][k], dp[i][j] + lst_happiness[i][k])


ans = 0
for i in range(3):
    ans = chmax(ans, dp[vacation][i])

print(ans)

Measured memory_bytes: 47344
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var n = ReadInt();
            var a = ReadIntArray().OrderBy(v=>v).ToArray();
            var count = 0;
            for (int i = 0; i < a.Length-1; i++)
            {
                if (a[i] == a[i + 1]) count++;
            }
            Console.WriteLine(n - (count / 2 + count % 2) * 2);
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 22880
I=lambda:list(map(int,input().split()))
n,m=I()
a=I()
a.sort(reverse=True)
qq=[I() for i in range(m)]
qq.sort(key=lambda x:x[1],reverse=True)
ans=0
for x,y in qq:
    for j in range(x):
        if not a:
            break
        aa=a.pop()
        ans+=max(aa,y)
ans+=sum(a)
print(ans)
        

Measured memory_bytes: 82456
a,b,c,d = map(int,input().split())
x = [0]*(202)
x[a] += 1
x[b] -= 1
x[c] += 1
x[d] -= 1
for i in range(201):
    x[i+1] += x[i]
ans = 0
for i in range(202):
    if x[i] == 2:
        ans += 1
print(ans)

Measured memory_bytes: 9140
N,M = list(map(int,input().split()))

P = 10**9+7
def get_soinsu(M):
    for i in range(2,1+int(M**0.5)):
        if M%i == 0:
            return [i] + get_soinsu(M//i)
    else:
        return [M]

soinsu = {}
for n in get_soinsu(M):
    soinsu[n] = 1 + soinsu.get(n,0)

def combi(n,r):
    tmp1,tmp2 = (1,1)
    for i in range(n-r+1,n+1):
        tmp1 *= i
    for i in range(2,r+1):
        tmp2 *= i
    return (tmp1//tmp2)%P

out = 1
soinsu.pop(1,None)
for n in soinsu.values():
    out *= combi(N-1+n,n)
    out %= P
print(out)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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(){
    ll h,w,k; cin>>h>>w>>k;
    vector<string> choco(h);
    rep(i,h) cin>>choco[i];
    ll res=1e10;
    rep(i,(1<<(h-1))){
        bool ifpossible=true;
        ll res_tmp=0;
        ll block_num=1;
        rep(j,h-1){
            if(i>>j & 1) {
                block_num++;
                res_tmp++;
            }
        }
        vector<ll> block(block_num,0);
        rep(j,w){
            rep(x,block_num){
                if(block[x]>k) ifpossible=false;
            }
            vector<ll> block_tmp(block_num,0);
            ll itr=0;
            ll tmp=0;
            if(choco[0][j]=='1') tmp++;
            rep(k,h-1){
                if(i>>k & 1){
                    block_tmp[itr]+=tmp;
                    itr++;
                    tmp=0;
                }
                tmp+=(choco[k+1][j]-'0');
            }
            block_tmp[block_num-1]+=tmp;
            bool ifgo=true;
            rep(x,block_num){
                if(block[x]+block_tmp[x]>k){
                    res_tmp++;
                    rep(y,block_num) block[y]=block_tmp[y];
                    ifgo=false;
                    break;
                }
            }
            if(ifgo){
                rep(x,block_num) block[x]+=block_tmp[x];
            }
        }
        rep(x,block_num){
            if(block[x]>k) ifpossible=false;
        }
        if(ifpossible) chmin(res,res_tmp);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    ll a,b;cin>>a>>b;
    printf("%lld %lld %.6f\n",a/b,a%b,(double)a/b);
}

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



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

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

    if (N[0] == N[1] && N[1] == N[2]
    || N[1] == N[2] && N[2] == N[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

using namespace std;

const int N = 1e5 + 100;
const int mod = 1e9 + 7;

int n, k;
int cnt[N];
long long sum = 1;
vector < int > gr[N];

void dfs( int p, int v )
{
    int jnt = k-1 - (p != -1);
    for( auto to: gr[v] ){
        if( to == p )
            continue;
        cnt[ to ] = jnt;
        jnt--;
        dfs( v, to );
    }
}

int main()
{
    cin >> n >> k;
    for( int i = 1; i <n; i ++ ){
        int a, b;
        cin >> a >> b;
        gr[a].push_back( b );
        gr[b].push_back( a );
    }
    for( int i = 1; i <= n; i ++ ){
        if( gr[i].size() >= k ){
            cout << 0;
            return 0;
        }
    }
    cnt[1] = k;
    dfs( -1, 1 );
    for( int i = 1; i <= n; i ++ ){
        sum *= cnt[i];
        sum %= mod;
    }

    cout << sum;
}


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

using namespace std;

typedef long long ll;

const int N = (int) 2e5 + 7;
const ll INF = (ll) 1e18;
int n;
int a[N];
map<pair<int, int>, ll> sol;

ll solve(int p, int k)
{
    if ((p + 1) / 2 < k)
    {
        return -INF;
    }
    if (sol.count({p, k}))
    {
        return sol[{p, k}];
    }
    if (k == 0)
    {
        sol[{p, k}] = 0;
        return 0;
    }
    ll ans = max(solve(p - 1, k), a[p] + solve(p - 2, k - 1));
    sol[{p, k}] = ans;
    return ans;
}

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

    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    cout << solve(n, n / 2) << "\n";
}

Measured memory_bytes: 30972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s;
    cin >> s;
    int n = s.size();
    ll dp[n + 1][13] = {};
    dp[0][0] = 1;
    rep(i, 0, n) {
        int x = s[i] - '0';
        rep(j, 0, 13) {
            if (s[i] == '?') {
                rep(k, 0, 10) {
                    dp[i + 1][(j * 10 + k) % 13] += dp[i][j];
                    dp[i + 1][(j * 10 + k) % 13] %= MOD;
                }
            } else {
                dp[i + 1][(j * 10 + x) % 13] += dp[i][j];
            }
        }
    }
    cout << dp[n][5] << endl;
    return 0;
}


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

#define ull unsigned long long

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

ull lcm(ull a, ull b)
{
	return a / gcd(max(a, b), min(a, b)) * b;
}

int main()
{
	ull n;
	cin>>n;
	ull a, cur = 1ULL;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		cur = lcm(a, cur);
	}
	cout<<cur<<endl;
	return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
 
sc = [tuple(map(int, input().split())) for _ in range(m)]
 
for i in range(1000):
    k = str(i)
    # all()：全ての要素がTrueであればTrueを返す
    # len(k)==nならば、左から一桁目が0である心配はない
    if len(k) == n and all([k[s-1]==str(c) for s,c in sc]):
        print(k)
        exit()
        
print('-1')

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

using namespace std;
using namespace __gnu_pbds;

using vi = vector<int>;
using pi = pair<int, int>;
using ll = long long;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>Order_Set;

const int mxn = 1e4+10;
const int Mod = 1e9+7;
#define PI acos(-1.0)
void solve()
{
    int n;
    cin>>n;
    cout<<setprecision(20)<<fixed<<(2*1.0*PI*n)<<endl;
}

int main()
{
    ios::sync_with_stdio(false);

    int tc = 1;
    //cin>>tc;
    while(tc--) solve();

    return 0;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL A, B; cin >> A >> B;
		UL K; cin >> K;
		UL n = 0;
		for (UL i = 100; i >= 1; i--) {
			if (A % i != 0) continue;
			if (B % i != 0) continue;
			n++;
			if (n == K) cout << i << endl;
		}
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
#01:00
n,m = map(int,input().split())
check = [-1 for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  check[b] = max(check[b],a)
#print(check)
ans = [0]
for i in range(n):
  if check[i] != -1:
    ans.append(max(ans[-1],ans[check[i]+1]+1))
  else:
    ans.append(ans[-1])
#print(ans)
print(ans[-1])

Measured memory_bytes: 6864
def main():
  n, k = map(int, input().split())
  p = list(map(int, input().split()))
  q = [(x+1)/2 for x in p]
  cur = sum(q[:k])
  ans = cur
  for i in range(k, n):
    cur = cur - q[i-k] + q[i]
    ans = max(cur, ans)
  print(ans)
    

if __name__ == '__main__':
  main()

Measured memory_bytes: 77448
#include <cstdio>

using namespace std;

int main(){
  float p[4][2];
  while(scanf("%f,%f,%f,%f,%f,%f,%f,%f"
	      ,&p[0][0],&p[0][1],&p[1][0],&p[1][1],&p[2][0],&p[2][1],&p[3][0],&p[3][1])>0){
    for(int i=0;i<4;i++){
      int n,m;
      float a1,a2,b1,b2,xp,yp,A,B;
      a1=p[(i+1)%4][0]-p[i%4][0];
      a2=p[(i+1)%4][1]-p[i%4][1];
      b1=p[(i+3)%4][0]-p[i%4][0];
      b2=p[(i+3)%4][1]-p[i%4][1];
      xp=p[(i+2)%4][0]-p[i%4][0];
      yp=p[(i+2)%4][1]-p[i%4][1];
      A=(b1*yp-b2*xp)/(a2*b1-a1*b2);
      B=(a2*xp-a1*yp)/(a2*b1-a1*b2);
      if(A+B<1&&A>0&&B>0){
	printf("NO\n");
	break;
      }
      if(i==3) printf("YES\n");
    }
  }
    return 0;
  }

Measured memory_bytes: 1032
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Objects;

public class Main {
  public static void main(String[] args ){

    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int P = sc.nextInt();

    int applePiece = A * 3 + P;
    int applePie = applePiece / 2;
    System.out.println(applePie);
  }
}


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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int n;
  cin >> n;
  int a[300001] = {};
  rep(i, 0, n) {
    int b, c;
    cin >> b >> c;
    a[b + c]++;
  }
  rep(i, 0, 300001) {
    if(a[i] >= 2) {
      a[i + 1] += a[i] / 2;
      a[i] = a[i] % 2;
    }
  }
  rep(i, 0, 300001) {
    if(a[i]) cout << i << " " << 0 << endl;
  }
}

Measured memory_bytes: 4380
n,a,b,c=map(int,input().split())
l=[]
for i in range(n):
    l.append(int(input()))
ans=100000
for i in range(4**n):
    mp=0
    f=0
    x=[]
    y=[]
    z=[]
    w=[]
    for j in range(n):
        if i%4==0:
            x.append(l[j])
        elif i%4==1:
            y.append(l[j])
        elif i%4==2:
            z.append(l[j])
        else:
            w.append(l[j])
        i=i//4
    if sum(x)==0 or sum(y)==0 or sum(z)==0:
        f=1
    
    X=sum(x)
    Y=sum(y)
    Z=sum(z)
    mp+=(len(x)+len(y)+len(z)-3)*10
    p=[X,Y,Z]
    q=[a,b,c]
    p=sorted(p)
    q=sorted(q)
    mp+=abs(p[0]-q[0])+abs(p[1]-q[1])+abs(p[2]-q[2])
    if f!=1:     
        ans=(min(mp,ans))
print(ans)
    
        

    
        
        
    


Measured memory_bytes: 9204
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    N = len(S)

    A = list(range(N))
    for _ in range(10):
        for i, a in enumerate(A):
            if S[a] == 'L':
                A[i] -= 1
            else:
                A[i] += 1

    B = A
    for _ in range(99):
        A, B = B, list(range(N))
        for _ in range(10):
            for i, b in enumerate(B):
                B[i] = A[b]

    ans = [0] * N
    for b in B:
        ans[b] += 1

    print(*ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 157352
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200010

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int N;
ll a;
int cnt[SIZE]={0};
int main(){
	cin>>N;
	int ans=0;
	for(int i=0;i<N;i++){
		cin>>a;
		if(a>N)ans++;
		else cnt[a]++;
	}
	for(int i=1;i<=N;i++){
		if(cnt[i]>=i)ans+=cnt[i]-i;
		else ans+=cnt[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int i, j, count[26];
    char buf[1201];

    for (i = 0; i < 26; i++)
	count[i] = 0;

    while (1) {
	if (fgets(buf, 1200, stdin) == NULL)
	    break;

	i = 0;
	while (buf[i] != '\n') {
	    j = buf[i++] - 65;
	    if (j >= 0 && j <= 25)
		count[j]++;
	    else {
		j -= 32;
		if (j >= 0 && j <= 25)
		    count[j]++;
	    }
	}
    }

    for (i = 0; i < 26; i++)
	printf("%c : %d\n", 97 + i, count[i]);

    return 0;
}

Measured memory_bytes: 524
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        long MOD = (int) Math.pow(10, 9) + 7;
        long power = 1;
        for (int i = 1; i <= N; i++) {
            power *= i;
            power %= MOD;
        }
        System.out.println(power);
    }
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll a,b,c,i,j,k;
    cin>>a>>b;
    if(a!=1 && b!=1)
    {
        cout<<"1"<<endl;
    }
    else if(a!=2 && b!=2)
    {
        cout<<"2"<<endl;
    }
    else
    {
        cout<<"3"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int N; std::cin >> N;
  std::vector<ll> a(N);
  for(int i=0; i<N; i++) std::cin >> a[i];

  std::unordered_map<ll, int> k;
  for(int i=0; i<N; i++) {
    if ( k.count(a[i]) == 0 ) k[a[i]] = 1;
    else k[a[i]]++;
  }

  if ( k.size() > 3 ) {
    std::cout << "No" << std::endl;
    return 0;
  }

  if ( k.size() == 1 ) {
    if ( a[0] == 0 ) std::cout << "Yes" << std::endl;
    else             std::cout << "No" << std::endl;
    return 0;
  }

  if ( N % 3 != 0 ) {
    std::cout << "No" << std::endl;
    return 0;
  }

  if ( k.size() == 2 ) {
    bool flag = false;
    std::vector<ll> val;
    for(auto itr = k.begin(); itr != k.end(); ++itr ) {
      val.push_back(itr->first);
      if ( itr->second == N/3 ) flag = true;
    }
    if ( flag && ( ((val[0]^val[0]) == val[1] && (val[0]^val[1]) == val[0]) || ((val[1]^val[1]) == val[0] && (val[0]^val[1]) == val[1]) ) ) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }

  if ( k.size() == 3 ) {
    std::vector<ll> val;
    for(auto itr = k.begin(); itr != k.end(); ++itr ) {
      val.push_back(itr->first);
      if ( itr->second != N/3 ) {
        std::cout << "No" << std::endl;
        return 0;
      }
    }

    if ( (val[0]^val[1]) == val[2] && (val[1]^val[2]) == val[0] && (val[2]^val[0]) == val[1] ) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }

  std::cout << "No" << std::endl;
  return 0;
}

Measured memory_bytes: 4260
N,K,Q = [int(X) for X  in input().split()]
scores = [0 for i in range(N)]
for k in range(Q):
  q = int(input()) -1
  scores[q] +=1
  
for score in scores:
  if score >= Q - K + 1:
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 4604
#include "bits/stdc++.h"
#include <iostream>
using namespace std;
#define ll = long long;
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 1e+9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main()
{
	int x;
	cin >> x;
	rep (i,9){
		if (x%(i+1)==0&&(x/(i+1))<10)
		{
			cout << "Yes" << endl;
			return 0;
		}
		
	}
	cout << "No" << endl;
}
/*


  　　　 _」_
　 　×´　　　  _,,..-──-､,_ｧo､__　　  ｀メ.
　　/　    ,  '"´　 　　　   （-､__oヽ　　　_|__
　 　　　／　　　　　　　　 　 ｀ヽ.ヽﾊ）　 　ﾉ
　　　 ／　　　　　　　　　　　  　 Y⌒ヽ.
　　  /　　 /　　　　　　     ヽ.　 |　　',
　　 ,'　　!　　,　 /!　,| ＿   !.　|　　 !　　
　　　|　  |.__/|_ ,'| / ! __｀./! /|　　 |
　　　|　　|´/ |_/  ﾚ' ｧ'´￣` |／､ﾄ、 　|　　奇跡を起こして計算量をO(N)にします!
　　  '､　 |/ｧ'´￣`  　　　,,　|　|ｿ   　ﾊ　　
　　 　 ＼,ハ ,,　　 '　   　（ ＼|　 / .|
　　　 　 | ﾊ、　i7´￣｀i  ,/ ＼_）,'　 |
　　　　 ,'/｀＞ ､,｀   ,.イ/＼＿_! !　  !　　|
　　 　　/　 /｀     T7´／/ヽ､_＿ﾉ_| 　 |__,メ
　　 　　|  .|r/´`ｰ'-､／　,'./  /::/｀ヽ /
　　　　 八　i/      rﾉ,!￣ヽ､| /:/ 　  i_
　　  　,' X`;くﾄ  ､ノ､　/ﾍ｀ヽ．Y    ／::>
　　　　!　// |::|/.|::|＼/ﾉ 八__ノr:':::／/
　　　　|／　 |::|./|::|/　 ）'ﾉ:/--‐'','
　  　  /　　 八:' _ﾉ::ﾉ　 _,.ｲ／　　　　|
　　 　,'　　　 ＼_ ／,|　 　／　　　 　 !
　　　 |　　　　　　  /|　 ／ 　　　/ 　 |
*/


Measured memory_bytes: 256
from collections import deque

N, M = list(map(int, input().split()))

roots = [0] * N
visited = set([])
table = [[] for i in range(N)]

for i in range(M):
    A,B = list(map(int, input().split()))
    table[A-1].append(B-1)
    table[B-1].append(A-1)

visited.add(0)
que = deque([0])

while que:
    cur = que.popleft()
    for target in table[cur]:
        if target in visited:
            continue
        visited.add(target)
        que.append(target)
        roots[target] = cur

print('Yes')
for r in roots[1:]:
    print(r+1)



Measured memory_bytes: 40272
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
n = len(s)
k = I()
for i in range(n):
    if s[i] != '1':
        break
else:
    print(1)
    quit()
if k <= i:
    print(1)
else:
    print(s[i])

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#include <map>
#include <climits>
#include <vector>
#include <set>
#include <string>
#include <numeric>

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define flood(arr, char, size) for (int i=0; i<size; i++) arr[i] = char
//#define int long long
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;
const int N = 1e5 + 2;
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;

int32_t main() {
    FAST_IO;
    int n, m;
    cin >> n >> m;
    for (int i=0; i<m+2; i++) cout << "#";
    cout << "\n";
    while(n--) {
        cout << "#";
        string s;
        cin >> s;
        cout << s;
        cout << "#";
        cout << "\n";
    }
    for (int i=0; i<m+2; i++) cout << "#";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;
const string stable = "Stable";
const string nstable = "Not stable";

void insertionSort(vector<int> &A , int& N ,int& g ,int &cnt){
    for(int i=0;i<N;i++){
        int v = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void shellSort(vector<int> &A, int &N){
    int cnt = 0;
    int m = 20;
    int G[m];
 
    for(int k = 0,t = 1; k < m; k++){
        G[k] = N/t;
        t *= 2;
    }
    for(int i = 0;i < m;i++){
        insertionSort(A,N,G[i] , cnt);
    }
    cout << m << endl;
    for(int i=0; i < m;i++){
        if(i == m - 1){
            cout << G[i] << endl;
        }else{
            cout << G[i] << " ";
        }
    } 
    cout << cnt << endl;
    for(int i=0;i<N;i++){
       cout<< A[i] << endl;
    }
    
}


int main(void){
    // Your code here!
    int N;
    vector<int> A;
    cin >> N;
    for(int i=0;i<N;i++){
        int temp;
        cin >> temp;
        A.push_back(temp);
    }
    shellSort(A,N);
    
    return 0;
}



Measured memory_bytes: 6996
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int N;
  N = S.size();

  int left = 0;
  int right = N - 1;
  int tmp_ans0 = 0;
  int tmp_ans1 = N;
  while (left < right) {
    if (S[left] != S[left + 1]) tmp_ans0 = left + 1;
    if (S[right - 1] != S[right]) tmp_ans1 = right;
    left++, right--;
  }
  int answer = min(N - tmp_ans0, tmp_ans1);
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
char s[10];
int a[10],flag1,flag2;
main() {
	scanf("%s",s);
	for(int i=1; i<=4; i++)
		a[i]=s[i-1]-'0';
	if(a[1]==1&&a[2]<=2)
		flag1=1;
	if(a[3]==1&&a[4]<=2)
		flag2=1;
	if(a[1]==0&&a[2]!=0) flag1=1;
	if(a[3]==0&&a[4]!=0) flag2=1;
	if(flag1&&flag2) puts("AMBIGUOUS"),exit(0);
	if(flag1) puts("MMYY"),exit(0);
	if(flag2) puts("YYMM"),exit(0);
	puts("NA");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// const ll MOD=998244353;

int N,K;
ll V[55];

int main(){
  cin>>N>>K;
  rep(i,N) cin>>V[i+1];
  ll ans=0;
  for(int l=0;l<=N;l++){
    for(int r=l+1;r<=N+1;r++){
      if(N-r+l+1>K) continue;
      ll tmp=0;
      vector<int> A;
      for(int i=1;i<=l;i++) A.push_back(V[i]);
      for(int i=r;i<=N;i++) A.push_back(V[i]);
      if(A.size()==0) continue;
      sort(A.begin(),A.end());
      int cnt=K-(N-r+1+l);
      int ind=0;
      while(cnt--){
        if(A[ind]<0) ind++;
        else break;
      }
      for(int i=ind;i<A.size();i++) tmp+=A[i];
      ans=max(ans,tmp);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
<?php
  list($s) = explode(" ", trim(fgets(STDIN)));
  list($t) = explode(" ", trim(fgets(STDIN)));

  $slen=strlen($s);
  $tlen=strlen($t);
  $ans=0;
  for ($i=0; $i<=$slen-$tlen; $i++) {
    $cnt=0;
    for ($j=0; $j<$tlen; $j++){
      if($s[$i+$j] == $t[$j]){
        $cnt++;
      }
      $ans = max($ans, $cnt);
    }
  }
  echo $tlen-$ans;

Measured memory_bytes: 16060
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e10;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,s,c;
    cin >> n >> m;
    vector<int> a(n,-1);
    string ans = "";
    bool out = 0;
    rep(i,m){
        cin >> s >> c;
        if (a[s-1] == -1) a[s-1] = c;
        else{
            if (a[s-1] != c) out = 1;
        }
    }
    rep(i,n){
        if (i == 0 && a[i] == -1) ans += '1';
        else if (a[i] == -1) ans += '0';
        else ans += to_string(a[i]);
    }
    if (out || (n != 1 && a[0] == 0)) PRINT(-1);
    else if(n == 1 && a[0] == -1) PRINT(0);
    else PRINT(ans);
}


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;
vector<P> d,u;

int main()
{
	int N;
	cin >> N;
	rep(i,N)
	{
		string S;
		cin >> S;
		int t = 0, temp = 0;
		rep(j,S.size())
		{
			if (S[j] == '(') temp--;
			else temp++;
			t = max(t,temp);
			//b = min(b,temp);
		}
		if (temp <= 0)
		{
			d.push_back(P(t,temp));
		}
		else
		{
			u.push_back(P(t-temp,temp));
		}
	}
	sort(d.begin(), d.end());
	sort(u.begin(), u.end());
	reverse(u.begin(), u.end());
	int now = 0;
	rep(i,d.size())
	{
		now += d[i].first;
		if (now > 0)
		{
			cout << "No" << endl;
			return 0;
		}
		now = now - d[i].first + d[i].second;
	}
	rep(i,u.size())
	{
		now += u[i].first + u[i].second;
		if (now > 0)
		{
			cout << "No" << endl;
			return 0;
		}
		now -= u[i].first;
	}
	if (now == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 11240
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;


const int MAX=200;

int main(){
    int m,nmin,nmax,P[MAX];
    int pass;
    while(cin>>m>>nmin>>nmax && m){
        pass=nmin;
        for(int i = 0;i<m;i++){
            cin >>P[i];
        }
        int gap[MAX-1],maxgap=0;
        for(int i=nmin-1;i<nmax;i++){
            gap[i]=P[i]-P[i+1];
            if(gap[i]>=maxgap){pass=i+1;}
            maxgap=max(maxgap,gap[i]);
        }
        cout << pass << endl;
    }
    return 0;
}

Measured memory_bytes: 3108
import sys
def s():
 n=int(input())+1
 e=list(map(lambda x:x.split(),sys.stdin))
 p=[int(e[0][0])]+list(int(x[1])for x in e)
 m=[[0]*n for _ in[0]*n]
 for i in range(n):
  for r in range(n-i-1):
   c=r+i+1
   for j in range(r+1,c):
    x=m[r][j]+m[j][c]+p[r]*p[j]*p[c]
    if 1>m[r][c]or m[r][c]>x:m[r][c]=x
 print(m[r][c])
if'__main__'==__name__:s()


Measured memory_bytes: 5724
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        ArrayList<Edge>[] graph = new ArrayList[n];
        for( int i = 0; i < n; i++ ) graph[i] = new ArrayList<Edge>();
        for( int i = 0; i < n-1; i++ ) {
            int u = in.nextInt()-1;
            int v = in.nextInt()-1;
            long w = in.nextLong();
            // System.out.println(u);
            // System.out.println(v);
            graph[u].add(new Edge(v, w));
            graph[v].add(new Edge(u, w));
        }
        int q = in.nextInt();
        int s = in.nextInt()-1;
        long[] dists = dijkstra(graph, s);
        // System.out.println(Arrays.toString(dists));
        for( int i = 0; i < q; i++ ) {
            int st = in.nextInt()-1;
            int ed = in.nextInt()-1;
            System.out.println(dists[st]+dists[ed]);
        }
    }
    static long[] dijkstra(ArrayList<Edge> graph[], int s) {
        int n = graph.length;
        long dist[] = new long[n];
        Arrays.fill(dist,Long.MAX_VALUE);
        PriorityQueue<Edge> pq = new PriorityQueue<>();
        dist[s] = 0; pq.offer(new Edge(s,0L));
        while(!pq.isEmpty()) {
            Edge cur = pq.poll();
            int u = cur.u;
            long w = cur.w;
            if(dist[u]<w) continue;
            for(Edge e : graph[u]) {
                int v = e.u;
                long nw = w+e.w;
                if(nw < dist[v]) {
                    dist[v] = nw;
                    pq.offer(new Edge(v,nw));
                }
            }
        }
        return dist;
    }
    public static class Edge implements Comparable<Edge> {
        public int u;
        public long w;
        public Edge( int U, long W ) {u = U; w = W;}
        public int compareTo(Edge e) {
            if( w < e.w ) return -1;
            if( w > e.w ) return 1;
            return 0;
        }
    }
}

Measured memory_bytes: 171220
import numpy as np

N = int(input())
A = []
for i in range(N):
  A.append(int(input()))

maxA = max(A)
A_array = np.array(A)
maxi = np.argmax(A_array)


B = A.copy()
B.pop(maxi)

for i in range(N):
  if i != maxi :
    print(maxA)
  else :
    print(max(B))

Measured memory_bytes: 26060
n = int(input())
AB = [list(map(int,input().split())) for _ in range(n)]
# print(AB)
ans = 0
added = 0
for i in reversed(range(n)):

    Ai = AB[i][0] + added
    Bi = AB[i][1]

    if Ai % Bi == 0:
        continue

    tmp = Ai // Bi + 1
    add = Bi * tmp - Ai
    ans += add
    added += add

print(ans)

Measured memory_bytes: 27380
# coding: utf-8
# Your code here!

num = int(input())
s = sorted(list(map(int,input().split())) ,reverse=True)
#print(s)

alice,bob = 0,0
for i,j in enumerate(s):
    if i % 2 == 0:
        alice += j
    else:
        bob += j
        
print(alice - bob)
        
    

Measured memory_bytes: 2940