akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include<cstring>
using namespace std;
const long long  maxn=1e7;

int main(){
	int n1,n2;
	cin>>n1>>n2;
	
	long long maxn=n1>n2?n1:n2;
	long long st=maxn;
	while(1){
		if(maxn%n1==0&&maxn%n2==0){
			cout<<maxn<<endl;
			break;
		}
		maxn+=st;
	}
//	cout<<maxn<<endl;
	return 0;
	
}

Measured memory_bytes: 256
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N = NI()
    print((pow(10, N, MOD) - pow(9, N, MOD)*2 + pow(8, N, MOD))%MOD)


if __name__ == "__main__":
    main()

Measured memory_bytes: 65132
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = MOD - 1;
const ll LLINF = 4e18;

const int MAX_N = 200005;
int n, k;
int a[MAX_N];

int b1[MAX_N];
int b2[MAX_N];
int deq1[MAX_N];
int deq2[MAX_N];

void solve() {
    int s = 0, t = 0;
    for (int i = 0; i < n; i++) {
        while (s < t && a[deq1[t - 1]] >= a[i]) t--;
        deq1[t++] = i;
        if (i - k + 1 >= 0) {
            b1[i - k + 1] = a[deq1[s]];
            if (deq1[s] == i - k + 1) {
                s++;
            }
        }
    }
    s = 0, t = 0;
    for (int i = 0; i < n; i++) {
        while (s < t && a[deq2[t - 1]] <= a[i]) t--;
        deq2[t++] = i;
        if (i - k + 1 >= 0) {
            b2[i - k + 1] = a[deq2[s]];
            if (deq2[s] == i - k + 1) {
                s++;
            }
        }
    }
    /*
    for (int i = 0; i <= n - k; i++) {
        printf("%d%c", b1[i], i == n - k ? '\n' : ' ');
    }
    for (int i = 0; i <= n - k; i++) {
        printf("%d%c", b2[i], i == n - k ? '\n' : ' ');
    }
    */
}

int main() {
    cin >> n >> k;
    int d[MAX_N];
    REP(i, n) cin >> a[i];
    d[0] = 1;
    REP(i, n-1) {
        d[i + 1] = 1;
        if (a[i] < a[i + 1]) {
            d[i + 1] += d[i];
        }
    }
    int ans = 1;
    bool f = false;
    REP(i, n) {
        if (d[i] == k) {
            if (f) {
                ans--;
            }
            else {
                f = true;
            }
        }
    }
    solve();
    FOR(i, k, n) {
        if (b1[i - k] != a[i - k] || b2[i - k + 1] != a[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4096
#include<string>
#include<iostream>
#include<cctype>
using namespace std;
int b[26];
int main(){
    string a;
    char c[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    while(getline(cin,a)){
    for(int i=0;i<a.size();i++){
        for(int j=0;j<26;j++){
            if(a[i]==c[j] || a[i]==toupper(c[j])){
                b[j] += 1;
            }
        }
    }
    }
    for(int i=0;i<26;i++){
        cout<<c[i]<<" : "<<b[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
vector<int> ans, a;
vector<vector<int>> edge;
vector<int> dp;
void dfs(int now, int prev) {
    auto ind = lower_bound(all(dp), a[now]);
    int val = *ind;
    *ind = a[now];
    ans[now] = lower_bound(all(dp), __INT_MAX__) - dp.begin();
    for(auto next : edge[now]) {
        if(next != prev) {
            dfs(next, now);
        }
    }
    *ind = val;
}
int main() {
    int n;
    cin >> n;
    ans.resize(n, 0);
    a.resize(n, 0);
    edge.resize(n, vector<int>(0));
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    vector<int> hoge(a.size(), __INT_MAX__);
    dp = hoge;
    dfs(0, -1);
    for(int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 28828
#include <stdio.h>

#define N	300000
#define MD	1000000007

int min(int a, int b) { return a < b ? a : b; }

long long power(int a, int k, int md) {
	long long b = a, p = 1;

	while (k) {
		if (k & 1)
			p = p * b % md;
		b = b * b % md;
		k >>= 1;
	}
	return p;
}

int ff[N * 3 + 1], gg[N * 3 + 1], p3[N * 2 + 1];

void init() {
	int i, f, p;

	f = 1;
	for (i = 0; i <= N * 3; i++) {
		gg[i] = power(ff[i] = f, MD - 2, MD);
		f = (long long) f * (i + 1) % MD;
	}
	p = 1;
	for (i = 0; i <= N * 2; i++) {
		p3[i] = p;
		p = (long long) p * 3 % MD;
	}
}

long long choose(int n, int k) {
	return k < 0 || k > n ? 0 : (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}

int main() {
	int n, m, k, i, ans, sum;

	init();
	scanf("%d%d%d", &n, &m, &k);
	ans = 0, sum = 1;
	for (i = 0; i <= m + k; i++) {
		ans = (ans + sum * choose(n - 1 + i, n - 1) % MD * p3[m + k - i]) % MD;
		sum = (sum * 2 - choose(i, i - k) - choose(i, min(i, m))) % MD;
		if (i + 1 <= m)
			sum = (sum + 1) % MD;
	}
	if (ans < 0)
		ans += MD;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 11076
#include <iostream>
#include <vector>
#include <functional>

template<typename T> struct segment_tree {
private :
	int N;
	std::vector<T> value;
public :
	const std::function<T(T, T)> op;
	const T id;

	segment_tree(const std::vector<T>& a, const std::function<T(T, T)>& f, const T& t) : op(f), id(t) {
		int n = a.size(), m = 1;
		while (m < n) m *= 2;
		value.resize((N = m) * 2, id);
		for (int i = 0; i < n; i++) value[N + i] = a[i];
		for (int i = N - 1; i > 0; i--) value[i] = op(value[i * 2], value[i * 2 + 1]);
	}

	segment_tree(const int& n, const std::function<T(T, T)>& f, const T& t) : op(f), id(t) {
		int m = 1;
		while (m < n) m *= 2;
		value.resize((N = m) * 2, id);
	}

	inline const int& size()const{return N;}

	void point_update(int i, const T& t) {
		i += N;
		value[i] = t;
		while (i /= 2) value[i] = op(value[i * 2], value[i * 2 + 1]);
	}

	T range_fold(const int& L, const int& R, const int& i = 1, const int& l = 0, int r = -1)const{
		if (r == -1) r = N;
		if (L <= l && r <= R) return value[i];
		if (r <= L || R <= l) return id;
		return op(
			range_fold(L, R, i * 2, l, (l + r) / 2),
			range_fold(L, R, i * 2 + 1, (l + r) / 2, r)
		);
	}

	inline const T& operator[](const int& i)const{return value[N + i];}
};

int main() {
	int n, q;
	std::cin >> n >> q;
	std::vector<long long> a(n);
	for (int i = 0; i < n; i++) std::cin >> a[i];

	segment_tree<long long> sg(a, [](long long a, long long b){return a + b;}, 0);
	while (q--) {
		int op;
		std::cin >> op;
		if (op == 0) {
			int p; long long x;
			std::cin >> p >> x;
			sg.point_update(p, sg[p] + x);
		} else {
			int l, r;
			std::cin >> l >> r;
			std::cout << sg.range_fold(l, r) << '\n';
		}
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define INF 1000000000
#define pb push_back
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define tr(c, i) for (typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c), x) != c.end())

long long mod = 1e9 + 7;

long long bigmod(long long a, long long p){
    if(p == 0){
        return 1;
    }
    long long ans = bigmod(a, p/2);
    ans = (ans * ans) % mod;
    if(p % 2 == 1){
        ans = (ans * a) % mod;
    }
    return ans;
}

int main(){
    ll n,k,i,j,ara[200005],x=0;
	cin>>n>>k;

    for(i=1;i<=k;i++){
        ara[i] = bigmod((k/i),n);
    }

   

    for(i=k;i>=1;i--){
        for(j=2;j*i<=k;j++){

            ara[i] = ara[i]-ara[j*i] + mod;
            ara[i] %= mod;

            
        }

    }

    for(i=1;i<=k;i++) x = (x+ara[i]*i)%mod;
    cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 4376
using System;
using System.Collections.Generic;
using System.Linq;
namespace CsProgramSpace
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int[]> list = new List<int[]>();
            while(true)
            {
                int[] i = new int[2];
                i = (Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToArray());
                if (i[0] == 0 && i[1] == 0) break;
                list.Add(i);
            }
            foreach(int[] i in list)
            {
                for(int j = 0; j<i[0];j++)
                {
                    for(int k = 0; k<i[1];k++)
                    {
                        if (j == 0 ||j==i[0]-1|| k == 0 || k == i[1] - 1)
                            Console.Write("#");
                        else
                            Console.Write(".");
                    }
                    Console.WriteLine("");
                }
                Console.WriteLine("");
            }
        }
    }
}


Measured memory_bytes: 16328
//ΔAGC029A
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
string s;
int main()
{
	int n,i,x=0;
	LL r=0;
	cin>>s;
	n=s.length();
	for(i=0;i<n;i=i+1){
		if(s[i]=='B')
			x++;
		else
			r+=x;
	}
	cout<<r;
	return 0;
}

Measured memory_bytes: 640
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ARRAY_MAX		50										// 最大配列数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 配列数取得
	int liACnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d", &liACnt);

	// 配列・最大・最小取得
	int liHNo = 0;
	int liLNo = 0;
	long long ll1Array[D_ARRAY_MAX];
	for (i = 0; i < liACnt; i++) {
#ifdef D_TEST
		fscanf(szpFpT, "%lld", &ll1Array[i]);
#else
		fscanf(stdin, "%lld", &ll1Array[i]);
#endif

		// 最大更新
		if (ll1Array[liHNo] < ll1Array[i]) {
			liHNo = i;
		}

		// 最小更新
		if (ll1Array[liLNo] > ll1Array[i]) {
			liLNo = i;
		}
	}
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif

	// 手順取得
	int li1FNo[D_ARRAY_MAX * 2];
	int li1TNo[D_ARRAY_MAX * 2];
	int liOCnt = 0;
	if (abs(ll1Array[liHNo]) > abs(ll1Array[liLNo])) {

		// 左側より小さい場合、加算
		for (i = 1; i < liACnt; i++) {
			while (ll1Array[i] < ll1Array[i - 1]) {
				ll1Array[i] += ll1Array[liHNo];
				li1FNo[liOCnt] = liHNo;
				li1TNo[liOCnt] = i;
				liOCnt++;

				// 最大更新
				if (ll1Array[liHNo] < ll1Array[i]) {
					liHNo = i;
				}
			}
		}
	}
	else {

		// 右側より大きい場合、減算
		for (i = liACnt - 2; i >= 0; i--) {
			while (ll1Array[i] > ll1Array[i + 1]) {
				ll1Array[i] += ll1Array[liLNo];
				li1FNo[liOCnt] = liLNo;
				li1TNo[liOCnt] = i;
				liOCnt++;

				// 最小更新
				if (ll1Array[liLNo] > ll1Array[i]) {
					liLNo = i;
				}
			}
		}
	}

	// 手順数表示
	sprintf(lc1Out, "%d\n", liOCnt);
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// 手順表示
	for (i = 0; i < liOCnt; i++) {
		sprintf(lc1Out, "%d %d\n", li1FNo[i] + 1, li1TNo[i] + 1);
#ifdef D_TEST
		fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
		if (strcmp(lc1Buf, lc1Out)) {
			siRes = -1;
		}
#else
		printf("%s", lc1Out);
#endif
	}

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
[A,B,C]=sorted(map(int,input().split()))
if (B-A)%2==0:print((B-A)//2+C-B)
elif (C-A)%2==0:print((C-A)//2+(C-B)//2+2*((C-B)%2))
else:print((C-B)//2+(C-A)//2+2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;
template <typename T>
void vecin(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n - 1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}

int main()
{
    ciosup;
    int h, w;
    cin >> h >> w;
    vector<vint> a(h, vint(w));
    vector<pint> lis;
    vector<vint> ans;
    REP(i, h)
    {
        vecin(a[i]);
    }
    REP(i,h){
        if (i % 2 == 0){
        REP(j,w){
            if (a[i][j] % 2 == 1){
                lis.emplace_back(make_pair(i, j));
            }
        }
        }else{
        IREP(j,w){
            if (a[i][j] % 2 == 1){
                lis.emplace_back(make_pair(i, j));
            }
        }
        }
    }
    //lis.emplace_back(make_pair(h, w));
    int sz = lis.size();
    REP(i,sz - (sz % 2)){
        if(i % 2 == 0)
        {
            pint now = lis[i];
            while (now != lis[i + 1])
            {
                vint temp;
                temp.emplace_back(now.FI+1);
                temp.emplace_back(now.SE+1);
                if (now.FI % 2 == 0){
                    if (now.SE == w - 1){
                        now.FI++;
                    }else{
                        now.SE++;
                    }
                }else
                {
                    if (now.SE == 0)
                    {
                        now.FI++;
                    }
                    else
                    {
                        now.SE--;
                    }
                }
                temp.emplace_back(now.FI+1);
                temp.emplace_back(now.SE+1);
                ans.emplace_back(temp);
            }
        }
    }
    cout << ans.size() << endl;
    REP(i,ans.size()){
        vecout(ans[i]);
    }
}

Measured memory_bytes: 11888
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
    int q;
    while (cin >> q) {
        if (q == -1) break;
        double x = q / 2.0;
        while (true) {
            x = x - (x*x*x - q) / (3*x*x);
            if (abs(x*x*x-q) < 1e-5*q) break;
        }
        cout.precision(6);
        cout << fixed << x << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll n;
	cin >> n;

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

	sort(rall(a));

	ll x = a.front();

	ll s = inf;
	ll r = x;
	for (ll i = 1; i < n; i++)
	{
		if (abs(x / 2 - a[i]) < s)
		{
			r = a[i];
			s = abs(x / 2 - a[i]);;;;;
		}
	}

	println(x << " " << r);
}


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

#define llint long long int

using namespace std;

int main(){
    string S, T;

    cin >> S >> T;

    int A, B;

    cin >> A >> B;

    string U;

    cin >> U;

    if(U == S){
        A --;
    }else{
        B --;
    }
    cout << A << " " << B << endl;
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=1e5+5,mod=1e9+7,bit=61;

int solve(int x)
{
    int l=1,r=1e9;
    int ans=1;
    while(l<=r)
    {
        int mid=(l+r)>>1;
        int res=(mid*(mid+1))>>1;
        if(res<=x)
        {
            ans=mid;
            l=mid+1;
        }
        else
        {
            r=mid-1;
        }
    }
    return ans;
}

signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll ans=0;
        map<int,int> mp;
        f(i,2,sqrt(n))
        {
            int pw=0;
            while(n%i==0)
            {
                n/=i;
                pw++;
            }
            if(pw>=1)
            {
                mp[i]=pw;
            }
        }
        if(n>1)
        {
            mp[n]+=1;
        }
        for(auto x:mp)
        {
            ans+=solve(x.ss);
        }
        cout<<ans<<endl;
    }
    return 0;
}



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

#define INF 5000

using namespace std;

int main() {
    int n, ma, mb;
    cin >> n >> ma >> mb;
    int dp[500][500];
    fill(dp[0], dp[500], INF);
    dp[0][0] = 0;
    for (int i=0; i<n; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        for (int j=500; j>=0; j--) {
            if (j + a >= 500) continue;
            for (int k=500; k>=0; k--) {
                if (k + b >= 500) continue;
                dp[j+a][k+b] = min(dp[j+a][k+b], dp[j][k] + c);
            }
        }
    }
    int res = INF;
    //for (auto &dpi:dp) {for (auto &dpij:dpi) cerr << dpij << ' '; cerr <<  endl;}
    for (int i=1; ma * i < 500 && mb * i < 500; i++)
        res = min(res, dp[ma*i][mb*i]);
    cout << (res < INF ? res : -1) << '\n';
    return 0;
}

Measured memory_bytes: 1280
#include <iomanip>
#include <limits>
#include <thread>
#include <utility>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <numeric>
#include <cassert>
#include <random>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <list>
#include <functional>
#include <bitset>
#include <complex>
#include <tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double D;
typedef complex<D> P;
const ll E = 1e18 + 7;
const ll MOD = 1000000007;
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define fill(x, y) memset(x, y, sizeof(x))
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
template <class... A>
void prints() { cout << endl; }
template <class... A>
void prints_rest() { cout << endl; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

template <class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

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

    string s;
    cin >> s;
    vector<char> C;
    rep(i, 4) {
        C.push_back(s[i]);
    }
    sort(all(C));

    if (C[0] == C[1] && C[2] == C[3] && C[1] != C[2]) {
        prints("Yes");
    } else {
        prints("No");
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define L long long
#define pb push_back
using namespace std;
int n,p;
vector<int> a,b;
map<L,int> h;
set<int> f[100010];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	scanf("%d",&n);
	for(i=1;i<=2*n-2;i++)
	  {
	   scanf("%d%d",&j,&k);
	   h[(L)j*n+k]++;
	   h[(L)k*n+j]++;
	   f[j].insert(k);
	   f[k].insert(j);
	   if(h[(L)j*n+k]==2)
	     a.pb(j),b.pb(k);
	  }
	for(i=0;i<a.size();i++)
	  if(h[(L)a[i]*n+b[i]]==2)
	    {
		 p++;
		 if(f[a[i]].size()<f[b[i]].size())
		   swap(a[i],b[i]);
		 while(f[b[i]].size())
		   {
			j=*f[b[i]].begin();
			h[(L)a[i]*n+j]+=h[(L)b[i]*n+j];
			h[(L)j*n+a[i]]+=h[(L)b[i]*n+j];
			h[(L)b[i]*n+j]=h[(L)j*n+b[i]]=0;
			f[a[i]].insert(j);
			f[j].erase(b[i]);
			f[j].insert(a[i]);
			if(h[(L)a[i]*n+j]==2)
			  a.pb(a[i]),b.pb(j);
			f[b[i]].erase(j);
		   }
		}
	if(p==n-1)
	  printf("YES\n");
	else
	  printf("NO\n");
	return 0;
}


Measured memory_bytes: 57584
function main(input) {
  const formatted_input = input.split(' ').map( x => parseInt(x, 10) );
  const A = formatted_input[0];
  const B = formatted_input[1];
  const C = formatted_input[2];

  if(A*C <= B){
    console.log(C);
  }else{
    console.log(parseInt(B/A));
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (size_t i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    if (s <= "2019/04/30") cout << "Heisei";
    else cout << "TBD" << endl;

    return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
S = []
[S.append(input()) for _ in range(N)]

ans = defaultdict(int)

for s in S:
    key = "".join(sorted(s))
    ans[key] += 1

sum = 0

for a in ans:
    sum += (  (ans[a]) *( ans[a] - 1 ) ) // 2

print(sum) 



Measured memory_bytes: 34044
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<map>

#define f first
#define s second

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  int n = 0;
  int sum = 0;
  int num = 0;
  int a,b;
  char c;
  while(cin>>a>>c>>b){
    n++;
    sum += a*b;
    num += b;
  }
  cout << sum << endl;
  cout << floor((double)num/n+0.5) << endl;
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long int lli;
int main()
{
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
  int h1,m1,h2,m2,k,sum;
  cin>>h1>>m1>>h2>>m2>>k;
  sum=(h2-h1)*60 + (m2-m1);
  cout<<max(0,sum-k);
}

Measured memory_bytes: 3612
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int a[50];
int cam(int x,int y)
{
	return x>y;
}
int main()
{
	int x;
	cin>>x;
	int tem=0;
	if(x==1)cout<<1<<endl;
	else if(x==2)cout<<1<<endl;
	else if(x==3)cout<<1<<endl;
	else
	{
		for(int i=2;i<=sqrt(x);i++)
	    {
	    	int y=i;
		    for(int j=1;j<=10;j++)
		    {
		    	if(y<=x&&i*y>x)
				{
					a[tem]=y;
					tem++;
					break;
				}
		    	y*=i;
			}
	    }
		sort(a,a+tem,cam);
        cout<<a[0]<<endl;
	}
	return 0;
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int a=(s[0]-'0')*10+s[1]-'0';
  int b=(s[2]-'0')*10+s[3]-'0';
  if(1<=a&&a<=12&&1<=b&&b<=12){
    cout<<"AMBIGUOUS"<<endl;
  }
  else if(1<=a&&a<=12){
    cout<<"MMYY"<<endl;
  }
  else if(1<=b&&b<=12){
    cout<<"YYMM"<<endl;
  }
  else{
    cout<<"NA"<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
n = int(input())

def p(m, n):
    k = 1
    for i in range(n):
        k = (k * m) % (10**9 + 7)
    return k

x = p(10, n) - 2*p(9, n) + p(8, n)
while x < 0:
    x += 10 ** 9 + 7
if x == 10 ** 9 + 7:
    x = 0
print(x)

Measured memory_bytes: 62688
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&a!=c)
	{
		cout<<"Yes"<<endl;
	}
	else if(a==c&&b!=a)
	{
		cout<<"Yes"<<endl;
	}
	else if(b==c&&a!=b)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    println((1..n)
        .asSequence()
        .filterNot { it % 5 == 0 }
        .filterNot { it % 3 == 0 }
        .map { it.toLong() }
        .sum())
}


Measured memory_bytes: 56152
/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.

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

int mod = 1000000007;
ll dp[100005];;

ll gcd(long long a,long long b){

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


bool sortByVal(const pair<string, int> &a,
               const pair<string, int> &b)
{
    return (a.second < b.second);
}


int main(){

 int n;
 cin>>n;

  map<string,long long>mp;

  for(int i=0;i<n;i++){

     string s;
     cin>>s;
     sort(s.begin(),s.end());
     mp[s]++;
  }

    long long cnt=0;
  for(map<string,long long>::iterator it = mp.begin();it!= mp.end();it++){
    long long y = it->second;
    //cout<<it->second<<endl;
    cnt += (y)*(y-1)/2;
  }

 cout<<cnt<<endl;

return 0;
}



Measured memory_bytes: 11444
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

double A, B, H, M;

// 長針、短針の時計回り方向の角度
double Long, Short;

int main()
{
    cin >> A >> B >> H >> M;

    Long = M / 60.0 * 2.0 * M_PI;

    double time2min;

    time2min = 60.0 * H + M;
    Short = time2min / (12.0 * 60) * 2 * M_PI;

    // for debug
    // cout << Long << "\n"
    //      << Short << "\n";

    double nasuKaku;
    if (Long - Short < 0)
    {
        nasuKaku = Short - Long;
    }
    else
    {
        nasuKaku = Long - Short;
    }

    double res2, res;
    res2 = A * A + B * B - 2 * A * B * cos(nasuKaku);

    res = sqrt(res2);
    printf("%.11f\n", res);
}


Measured memory_bytes: 4224
#include<iostream>
#include<cstdio>
#include<cassert>
#include<cstring>
#define maxn 50
using namespace std;
int n;
int order[3][maxn],post[maxn];
bool vis[maxn];

int find(int num,int c)
{
    for(int i=1; i<=n; ++i)
        if(order[c][i]==num)
        {
            vis[i]=true;
            return i;
        }
    return -1;
}

void postorder(int s,int e)
{
//	cout<<"s="<<s<<" e="<<e<<endl;
    if(s>e) return ;
	if(s==e)
    {
        post[++post[0]]=order[1][e];
//        cout<<post[post[0]]<<" ";
        return;
    }
    int num=order[1][s],pre_num=0,pos_num=0;
    post[++post[0]]=order[1][s];
//    cout<<post[post[0]]<<" ";
    int p=find(num,2);
    for(int i=p+1;i<=n;++i)
      if(vis[i])
        break;
      else
        pos_num++;
    for(int i=p-1;i>=1;--i)
      if(vis[i])
        break;
      else
        pre_num++;
//    cout<<"'"<<pre_num<<"'-'"<<pos_num<<"'"<<endl; 
    postorder(e-pos_num+1,e);
    postorder(s+1,s+pre_num);
    return;
}

int main()
{
    memset(vis,0,sizeof(vis));
    scanf("%d",&n);
    for(int j=1; j<=2; ++j)
        for(int i=1; i<=n; ++i)
            scanf("%d",&order[j][i]);
    post[0]=0;
    postorder(1,n);
    printf("%d",post[post[0]]);
    for(int i=post[0]-1; i>=1; --i)
        printf(" %d",post[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 3212
import bisect

n = int(input())
l = [int(i) for i in input().split()]
l.sort()

cnt = 0
for a in range(n):
    for b in range(a+1, n):
        c = bisect.bisect_left(l, l[a] + l[b])
        if c > b:
            cnt += c - b - 1
print(cnt)


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

int gcd(int a, int b) {
    if(a == 0) return b;
    return gcd(b % a, a);
}
 
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int k;
    cin >> k;
    int sum = 0;
    for(int a=1;a<=k;a++) {
        for(int b=1;b<=k;b++) {
            int cur = gcd(a, b);
            for(int c=1;c<=k;c++) {
                sum += gcd(cur, c);
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int a[5],k;
    cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>k;
    int f=0;
    for(int i=0;i<4;i++){
        for(int j=i+1;j<5;j++){
            if(a[j]-a[i]>k){
                f=1;
                break;
            }
        }
    }
    if(f==0) cout<<"Yay!";
    else cout<<":(";
}


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

int main() {

  int N, K;
  cin >> N >> K;

  int d;
  map<int, int> sunuke;
  int tmp;

  for(int i = 0; i < K; i++){
    cin >> d;
    for(int j = 0; j < d; j++){
      cin >> tmp;
      sunuke[tmp]++;
    }
  }

  cout << N - sunuke.size() << endl;
}


Measured memory_bytes: 3628
n = int(input())
a =[]
#標準入力
for _ in range(n):
    m = int(input())
    a.append([list(map(int, input().split())) for _ in range(m)])

    
c = 0#答え
for i in range(1 << n):#bit全探索
    Flag = True
    for j in range(n):
      if ((i>>j) & 1) == 1:
        for k in a[j]:
          if i >> (k[0]-1) & 1 != k[1]:#証言が正しくないときFalseを付け、breakする。
            Flag = False
      
      if Flag == False:
        break
      if (j == n - 1) & (Flag == True):
        honest = sum([i>>j & 1 for j in range(n)])
        #print(honest)
        c = max(c,honest)
print(c)


Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();

		int g = 1;
		int x = 1800;
		while ( a<x ) {
			g++;
			x -= 200;
		}

		System.out.println(g);
	}
}

Measured memory_bytes: 35652
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  char a; cin >> a;
  if ('A' <= a && a <= 'Z') {
    a = 'A';
  } else {
    a = 'a';
  }
  cout << a << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


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

while len(A) > 1:
    minA = min(A)
    tempA = []
    tempA.append(minA)
    for a in A:
        mod = a % minA
        if mod != 0:
            tempA.append(mod)
    A = tempA

print(A[0])

Measured memory_bytes: 14252
#include <stdio.h>

using namespace std;

int pow(int b, int e){
  int res = 1;
  for(int i=0; i < e; i++){
    res *= b;
  }
  return res;
}

int main(){
  int d, n;
  scanf("%d %d", &d, &n);

  int divides = pow(100, d);
  if(n == 100){
    n = 101;
  }
  int res = divides*n;
  printf("%d\n", res);
  
  return 0;
}


Measured memory_bytes: 256
/* ITP1_2_D:Circle in a Rectangle */
/* 20181118 AOJ */

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main(void){
	int W, H, x, y, r;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if(x - r >=0 &&
	   x + r <= W &&
	   y - r >= 0 &&
	   y + r <= H){
		puts("Yes");
	}else{
		puts("No");
	}

	return 0;
}


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

int main() {
    int N, K, S;
    cin >> N >> K >> S;
    //S<1e9 のとき、S,S,…,S,S+1,…,S+1(SがK個)(l≥Kに対しては区間和がSにならないようにする必要があるので、残りはS+1とかで埋めておく)
    //S=1e9 のとき、S,S,…,S,1,…,1(SがK個)
    int rem = S+1;
    if (rem > 1e9) rem = 1;
    for (int i = 0; i < K; ++i) cout << S << " ";
    for (int i = K; i < N; ++i) cout << rem << " ";
    cout << endl;
}
//lとr同じでいいからね

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b;cin>>a>>b;
  cout<<6-a-b<<endl;
  return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		int maxL = 0;
		int minR = 100001;
		for(int i=0; i<M; i++) {
			maxL = Math.max(maxL, Integer.parseInt(sc.next()));
			minR = Math.min(minR, Integer.parseInt(sc.next()));
		}
		sc.close();

		System.out.println(Math.max(0, minR-maxL+1));
	}

}


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

int main(){
	int n,delta;
	while(cin >> n,n){
		vector<int> table(n,-1);
		int t[5001] = {0};
		for(int i=1;i<n;i++){
			table[i] = (i*i)%n;
		}
		sort(table.begin(),table.end());
		table.erase(unique(table.begin(),table.end()),table.end());
		
		for(int i=1;i<table.size();i++){
			for(int j=1;j<table.size();j++){
				delta = table[i] - table[j];
				if(delta<0)delta+=n;
				if(delta>(n-1)/2)delta=n-delta;
				t[delta]++;
			}
		}
		for(int i=1;i<=(n-1)/2;i++){
			cout << t[i] << endl;
		}
	}
}

Measured memory_bytes: 964
// Author : Mohamed Sameh
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
typedef long long ll ;
using namespace std ;
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n ,k;
    cin >> n >> k ;
    ll ans = n % k ;
    ans = min (ans , abs (ans - k )); 
    cout << ans <<"\n"; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll a,b;
  cin >> a >> b;
  ll c=b-a;
  cout << c*(c-1)/2-a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	vector<bool> mark(300,false);
	int X,N,x;
	cin>>X>>N;
	for(int i=0;i<N;i++)
	{
		cin>>x;mark[100+x] = true;
	}
	int r;
	for(int i=X+100;i<=300;i++)
	{
		if(!mark[i]){r = i;break;}
	}
		
	int l;
	for(int i=X+100;i>=0;i--)
	{
		if(!mark[i]){l = i;break;}
	}	
	if(abs(X-r+100)>=abs(X-l+100))
		cout<<X-abs(X-l+100)<<'\n';
	else 
		cout<<X+abs(X-r+100)<<'\n';
}


Measured memory_bytes: 3660
def main():
    from operator import mul
    from functools import reduce
    def combinations_count(n, r):
        r = min(r, n - r)
        numer = reduce(mul, range(n, n - r, -1), 1)
        denom = reduce(mul, range(1, r + 1), 1)
        return numer // denom
    n, p = list(map(int, input().split()))
    A = list(map(int, input().split()))
    odd = sum([a % 2 == 1 for a in A])
    even = n - odd
    if p == 0:
        odd_sum = 0
        for i in range(0, odd + 1, 2):
            odd_sum += combinations_count(odd, i)
    else:
        if odd == 0:
            print(0)
            exit()
        else:
            odd_sum = 0
            for i in range(1, odd + 1, 2):
                odd_sum += combinations_count(odd, i)
    if even == 0:
        even_sum = 0
        print(odd_sum)
    else:
        even_sum = pow(2, even)
        print(even_sum * odd_sum)


if __name__ == '__main__':
    main()


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


int main(){
	string S;
	cin >> S;
	if(S[0] == S[1])return cout << "Bad", 0;
	if(S[1] == S[2])return cout << "Bad", 0;
	if(S[2] == S[3])return cout << "Bad", 0;
	return cout << "Good", 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;


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

  vector<int> a(3);
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
  }
  ll sol = (ll) 1e18;
  for (int i = 0; i < 3; i++) {
    for (int j = i + 1; j < 3; j++) {
      int k = 3 - i - j;
      if (a[k] % 2 == 0) {
        sol = min(sol, 0LL);
      } else {
        sol = min(sol, a[i] * (ll) a[j]);
      }
    }
  }
  cout << sol << "\n";
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	ll n, k;
	cin >> n >> k;

	ll ans = 0;
	for(ll b = k+1; b <= n; b++){
		ll q = n / b;
		ll r = n % b;

		ans += q * (b - k) + max(r - k + 1, 0LL);
	}

	if(k == 0) ans -= n;

	cout << ans << endl;
}

Measured memory_bytes: 256
def count(n):
    cnt = 0
    m = 2
    if n % 2 == 0:
        cnt = 1
    while True:
        if n % 2 != 0:
            break
        n = n / m
        m += 2
        cnt += 1
    return cnt
def cokkie(a, b, c):
    cnt = 0
    a1 = a
    b1 = b
    c1 = c
    while True:
        if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
            break
        A = (b + c) / 2
        B = (c + a) / 2
        C = (a + b) / 2
        a = A
        b = B
        c = C
        if a1 == a and b1 == b and c1 == c:
            cnt = -1
            break
        cnt += 1
    return cnt
    
        
A, B, C = map(int, input().split())
list = [count(A), count(B), count(C), count(A + B), count(B + C), count(C + A)]
print(cokkie(A, B, C))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pp pair<ll,ll>
#define pq_min priority_queue<ll,vector<ll>,greater<ll>>
#define pq_max priority_queue<ll>
#define forx(i,a,b) for(ll i=0;i<a;i++)
#define ld long double
const ll mod=1e9 + 7;
const ll N=15; 
ll power(ll a,ll b)
{
	a=a%mod;
	ll ans=1;
	while(b>0)
	{
		if(b%2==1)
		{
			ans=(ans*a)%mod;
		}
		b=b/2;
		a=(a*a)%mod;
	}
	return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	srand(time(NULL));
    ll n;
    cin>>n;
    ll a[n+1][n+1];
    memset(a,-1,sizeof(a));
    for(ll i=0;i<n;i++)
    {
    	ll x;
    	cin>>x;
    	for(ll j=0;j<x;j++)
    	{
    		ll p,q;
    		cin>>p>>q;
    		a[i+1][p]=q;
		}
	}
	/*for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=n;j++)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}*/
	ll ans=0;
	ll d=pow(2,n)-1;
	for(ll i=0;i<=d;i++)
	{
		bitset<N> b(i);
		ll f=0;
		for(ll j=0;j<n;j++)
		{
			if(b[j]==1)
			{
				for(ll k=1;k<=n;k++)
				{
					if(a[j+1][k]!=-1 && a[j+1][k]!=b[k-1])
					{
						f=1;
						break;
					}
				}
			}
			if(f==1)
			{
				break;
			}
	    }
	    if(f==0)
	    {
		ll z=b.count();
		ans=max(ans,z);
	    }
	}
	cout<<ans<<endl;
}



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

vector<int> C(26, 0); // C[i]
vector<vector<int> > S(365, vector<int>(26, 0)); // S[d][i]
int D;
int N;

int score(vector<int> V) {
	vector<int> c = C;
	int s = 0;
	for (int d = 0; d < D; d++) {
		c[V[d]] = 0;
		s += S[d][V[d]];
		s -= accumulate(c.begin(), c.end(), 0);
		for (int i = 0; i < N; i++) {
			c[i] += C[i];
		}
	}
	return s;
}

int ls1(int d, int i, int ci, int Ci) {
	return S[d][i] + 5 * ci;
}

int ls(int a, int b, int d, int i, int ci, int Ci) {
	return S[d][i] + a * ci - b * Ci;
}

vector<int> findmin(int a, int b) {
	vector<int> V(D, 0);
	vector<int> c = C;
	int s = 0;
	for (int d = 0; d < D; d++) {
		int mi = 0;
		for (int i = 0; i < N; i++) {
			if (ls(a, b, d,mi,c[mi],C[mi]) < ls(a, b, d, i, c[i], C[i])) mi = i;
		}
		V[d] = mi;
		c[V[d]] = 0;
		s += S[d][V[d]];
		s -= accumulate(c.begin(), c.end(), 0);
		for (int i = 0; i < N; i++) {
			c[i] += C[i];
		}
	}
	return V;
}

int main() {
	cin >> D;
	N = 26;
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}
	for (int d = 0; d < D; d++) {
		for (int i = 0; i < N; i++) {
			cin >> S[d][i];
		}
	}
	vector<int> V(D, 0);
	for (int d = 0; d < D; d++) {
//		cin >> V[d];
//		V[d]--;
		int i = 0;
		for (int j = 1; j < N; j++) {
			if (S[d][i] < S[d][j]) i = j;
		}
		V[d] = i;
	}

	vector<int> sV = findmin(5,30);
	if (score(V) < score(sV)) V = sV;

	for (int a = 1; a < 20; a++) {
		for (int b = 0; b < 100; b++) {
			sV = findmin(a, b);
			if (score(V) < score(sV)) V = sV;
		}
	}


	/*
	random_device seed_gen;
	mt19937 engine(seed_gen());
	uniform_real_distribution<> dist1(0.0, 1.0);
	vector<int> newV = V;
	int ms = score(V);
	for (int j = 0; j < 100000; j++) {
		newV = V;
		for (int k = 0; k < 1; k++) {
			int d1 = int(dist1(engine) * D);
			int d2 = min(D-1, d1 + int(dist1(engine) * 3));
			newV[d1] = V[d2];
			newV[d2] = V[d1];
		}
		int ns = score(newV);
		if (ms < ns) V = newV;
	}
	*/

	for (int d = 0; d < D; d++) {
		cout << V[d] + 1 << endl;
	}
	cerr << score(V) << endl;
  	return(0);
}


Measured memory_bytes: 3692
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int n,m,a[200200],ok[200200];

int main()
{
    n=read();m=read();
    rep(i,1,n) {a[i]=read();ok[i]=1;}
    rep(i,1,m)
    {
        int x=read(),y=read();
        if (a[x]<a[y]) ok[x]=0;
        else if (a[x]>a[y]) ok[y]=0;
        else ok[x]=ok[y]=0;
    }
    int ans=0;
    rep(i,1,n) ans+=ok[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4412
import Control.Monad

main = do
  n<-readLn
  ab<-replicateM n$(\[a,b]->(a,b)).map read.words<$>getLine
  print$solve ab

solve ab
  | null bs = 0
  | otherwise = sum(map fst ab) - minimum bs
  where bs=map snd $ filter (uncurry(>)) ab

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

map<int, ll>::iterator it;

int main() {
  int n;
  cin >> n;
  map<int, ll> m;
  vector<int> a(n);
  rep(i, n) {cin >> a[i]; m[a[i]]++;}
  ll cnt = 0;
  for ( const auto &p : m ) cnt += p.second * (p.second-1) / 2;
  rep(i, n) {
    cout << cnt - m[a[i]] + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 10240
if __name__ == "__main__":
    n, k = map(int, input().split())
    s = set()

    for i in range(k):
        d = int(input())
        a = list(map(int, input().split()))
        for j in a:
            if j not in s:
                s.add(j)
    
    ans = n - len(s)
    print(ans)

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main(){
    int N;
    cin >> N;
    vector<int> t(N), a(N);
    for(int i=0; i<N; i++) {
        cin >> t[i] >> a[i];
    }

    ll T = 1, A = 1;
    for(int i=0; i<N; i++) {
        ll n = max((T+t[i]-1)/t[i], (A+a[i]-1)/a[i]);
        A = n * a[i], T = n * t[i];
    }
    cout << A + T << endl;
}

Measured memory_bytes: 3612