akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	ll h1, m1, h2, m2, k;
 	cin >> h1 >> m1 >> h2 >> m2 >> k;   
 	if (h1 == h2) {
 		cout << m2 - m1 - k << endl;
 	}
 	else {
 		ll add1 = 60 - m1 + m2;
 		h1++;
 		ll rest = (h2 - h1) * 60;
 		cout << add1 + rest - k << endl;
 	}
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
const double pi = acos(-1.0);
const int N = 1e5+5;
const int inf = 0x3f3f3f3f;
int dis[N],pre[N];
bool vis[N];
struct node{
	int u,w;
	node(int x,int y):u(x),w(y){}
	bool operator < (const node &a)const
	{
		return w>a.w;
	}
};
vector<node>v[N];
void dijkstra(int st)
{
	fill(dis,dis+N,inf);
	fill(vis,vis+N,false);
	priority_queue<node>q;
	dis[st]=0;
	q.push(node(st,0));
	while(q.size())
	{
		node t=q.top();
		q.pop();
		int from=t.u;
		if(vis[from])continue;
		vis[from]=true;
		for(int i=0;i<v[from].size();i++)
		{
			int to=v[from][i].u;
			int w=v[from][i].w;
			if(!vis[to]&&dis[from]+w<dis[to])
			{
				dis[to]=dis[from]+w;
				q.push(node(to,dis[to]));
				pre[to]=from;
			}
		}
	}
}
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)pre[i]=i;
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		v[x].push_back(node(y,1));
		v[y].push_back(node(x,1));
	}
	dijkstra(1);
	int f=0;
	for(int i=2;i<=n;i++)
	if(dis[i]==inf)
	{
		f=1;
		break;
	}
	if(f)cout<<"No"<<endl;
	else
	{
		cout<<"Yes"<<endl;
		for(int i=2;i<=n;i++)
		cout<<pre[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 13804
#include "vector"
#include "iostream"
#include "string"
#include "algorithm"

using namespace std;

int main()
{
	long long h, w;
	cin >> h >> w;
	long long r = (h * w) % 3;
	if (r == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	long long rt = 1e12;
	for (int i = 1; i <= w; i++)
	{
		long long t1 = h * i;
		long long temp = h * w - t1;
		long long t2;
		long long t3 = (temp / h) * (h / 2);
		if (h % 2 == 0)
		{
			t2 = (temp / h) * (h / 2);
		}
		else {
			t2 = (temp / h) * ((h / 2) + 1);
		}
		long long t = 0;
		if (t1 > t2)
		{
			t = t1 - t3;
		}
		else {
			if (t3 > t1)
			{
				t = t2 - t1;
			}
			else {
				t = t2 - t3;
			}
		}
		if (t > rt)
		{
			break;
		}
		rt = t;
	}

	long long rt2 = 1e12;
	for (int i = 1; i <= h; i++)
	{
		long long t1 = w * i;
		long long temp = h * w - t1;
		long long t2;
		long long t3 = (temp / w) * (w / 2);
		if (w % 2 == 0)
		{
			t2 = (temp / w) * (w / 2);
		}
		else {
			t2 = (temp / w) * ((w / 2) + 1);
		}
		long long t = 0;
		if (t1 > t2)
		{
			t = t1 - t3;
		}
		else {
			if (t3 > t1)
			{
				t = t2 - t1;
			}else {
				t = t2 - t3;
			}

		}
		if (t > rt2)
		{
			break;
		}
		rt2 = t;
	}
	long long rt3 = 1e12;
	for (int i = 1; i <= w - 2; i++)
	{
		long long t1 = h * i;
		long long temp = h * w - t1;
		long long t2, t3;
		int v = w - i;
		t3 = (temp / v) * (v / 2);
		if (v % 2 == 0)
		{
			t2 = (temp / v) * (v / 2);
		}
		else {
			t2 = (temp / v) * ((v / 2) + 1);
		}
		long long t = 0;
		if (t1 > t2)
		{
			t = t1 - t3;
		}
		else {
			if (t3 > t1)
			{
				t = t2 - t1;
			}else {
				t = t2 - t3;
			}

		}
		if (t > rt3)
		{
			break;
		}
		rt3 = t;

	}
	long long rt4 = 1e12;
	for (int i = 1; i <= h - 2; i++)
	{
		long long t1 = w * i;
		long long temp = h * w - t1;
		long long t2, t3;
		int v = h - i;
		t3 = (temp / v) * (v / 2);
		if (v % 2 == 0)
		{
			t2 = (temp / v) * (v / 2);
		}
		else {
			t2 = (temp / v) * ((v / 2) + 1);
		}
		long long t = 0;
		if (t1 > t2)
		{
			t = t1 - t3;
		}
		else {
			if (t3 > t1)
			{
				t = t2 - t1;
			}else {
				t = t2 - t3;
			}

		}
		if (t > rt4)
		{	
			break;
		}
		rt4 = t;
	}
	cout << min({ rt, rt2, rt3, rt4 }) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static String I = "IMPOSSIBLE";
	public static String B = "Bad";
	public static String G = "Good";
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int p = ni();
		int q = ni();
		int r = ni();

		out(Math.min(Math.min(p + q, q + r), p + r));
	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static String n() {
		return sc.next();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

ll mod(ll x) {
    x %= MOD;
    if (x < 0) { x += MOD; }
    return x;
}

// O(log(p))
ll mpow(ll x, ll p) {
    if (p == 0) { return 1; }
    if (p == 1) { return x % MOD; }
    if (p % 2 == 1) { return (x * mpow(x, p - 1)) % MOD; }
    ll sub = mpow(x, p / 2);
    return (sub * sub) % MOD;
}

vi sieve(int n) {
    vi primes(n + 1);
    iota(primes.begin(), primes.end(), 0);

    for (int i = 2; i * i <= n; ++i) {
        if (primes[i] < i) { continue; }
        for (int j = i * i; j <= n; j += i)
            if (primes[j] == j) { primes[j] = i; }
    }
    return primes;
}

void dfs(const map<int, int> fac, vi& div, int i, int x) {
    if (i == (int)fac.size()) {
        div.push_back(x);
        return;
    }

    pair<int, int> p = *next(fac.begin(), i);
    rep(j, 0, p.second + 1) { dfs(fac, div, i + 1, mod(x * mpow(p.first, j))); }
}

vi divisors(const vi& primes, ll n) {
    map<int, int> fac;
    while (n > 1) {
        ++fac[primes[n]];
        n /= primes[n];
    }
    vi div;
    dfs(fac, div, 0, 1);
    return div;
}

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

    int n, k;
    cin >> n >> k;

    // O(k * loglog(k))
    vi primes = sieve(k);

    // 1を含むとき: O(log(n)).
    ll ans = 0;

    for (ll i = 1; i <= k; ++i) {
        // 数列の最小値がiのとき．

        // iの約数．
        vi div = divisors(primes, i);

        // 最大公約数がdiv[i]となる時の順列．
        vll cnt(div.size(), 0);

        rrep(j, 0, div.size()) {
            ll d = div[j];

            // [i, k]のdの倍数の個数．
            ll num_div = k / d - (i - 1) / d;

            // 最大公約数が(i * d)となる時の順列．
            ll diff = 0;
            rrep(k, j + 1, div.size()) {
                if (div[k] > d && div[k] % d == 0) { diff += cnt[k]; }
            }

            // 最大公約数がdとなる時の順列．
            ll only_div = mod(mpow(num_div, n) - mpow(num_div - 1, n) - diff);
            cnt[j] = only_div;

            ans = mod(ans + mod(d * only_div));
        }
    }

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

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define int long long int

int gcd(int a,int b){ //a>b
    int amari;
    while(1){
        amari=a%b;
        if(amari==0){
            break;
        }
        else{
            a=b;
            b=amari;
        }
    }
    return b;    
}


signed main(){
    int A,B,C,D;
    int dvc,dvd,dvcd;
    cin>>A>>B>>C>>D;

    if(A%C==0){
        dvc=(B/C)-(A/C)+1;
    }
    else{
        dvc=(B/C)-(A/C);
    }

    if(A%D==0){
        dvd=(B/D)-(A/D)+1;
    }
    else{
        dvd=(B/D)-(A/D);
    }

    int gmd=(C*D)/gcd(C,D);
    if(A%gmd==0){
        dvcd=(B/gmd)-(A/gmd)+1;
    }
    else{
        dvcd=(B/gmd)-(A/gmd);
    }

    cout<<setprecision(18)<<(B-A+1)-(dvc+dvd-dvcd)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;

int main() {
	for(;;) {
		int n;
		scanf(" %d", &n);
		if(n == 0) break;
		map<char, char> m;
		for(int i = 0; i < n; i++) {
			char from, to;
			scanf(" %c %c", &from, &to);
			m.insert(make_pair(from, to));
		}
		scanf(" %d", &n);
		for(int i = 0; i < n; i++) {
			char c;
			scanf(" %c", &c);
			if(m.find(c) != m.end())
				putchar(m[c]);
			else
				putchar(c);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t[5];
    ll sum = 0;
    REP(i, 0, 5) {
        cin >> t[i];
        sum += (t[i] + 9) / 10 * 10;
    }
    ll minnum = 12;
    REP(i, 0, 5) {
        if (t[i] % 10 != 0) {
            minnum = min(minnum, t[i] % 10);
        }
    }
    if (minnum == 12) {
        minnum = 10;
    }
    ll ans = sum - (10 - minnum);
    cout << ans << endl;
}


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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    rep(i,3){
      int t=n%10;
      if(t==7){
        cout<<"Yes"<<endl;
        return 0;
      }
      n/=10;
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    for(int i=0;i<N;i++){
        cin >> P.at(i);
    }
    sort(P.begin(),P.end());
    int exp = P[N-1]/2;
    for(int i=0;i<N-1;i++){
        exp += P[i];
    }
    cout << exp << endl;
} 



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
//priority_queue<long long, vector<long long>, greater<long long>> pq;

const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long


const double pi = acos(-1.0);

int n, m;


int main() {
  //auto start_clock = clock();
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif

  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int w;
    scanf("%d", &w);
    n -= w;
  }
  if (n >= 0) printf("%d\n", n);
  else printf("%d\n", -1);
  //double r;
  //cin >> r;
  //cout << 2 * pi * r << endl;
  return 0;
}

Measured memory_bytes: 3832
#include <iostream>
#include <string>
typedef unsigned long long int ull;
using namespace std;

ull power(ull x, ull n, ull M)
{
	ull temp = 1;
	if (n > 0)
	{
		temp = power(x, n / 2, M);
		if (n % 2 == 0)
		{
			temp = (temp * temp) % M;
		}
		else
		{
			temp = (((temp * temp) % M) * x) % M;
		}
	}
	return(temp);
}

void solve()
{
	int m, n;
	cin >> m >> n;
	cout << power(m, n, 1000000007) << endl;
	
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long n, m, ans = 0;
    cin >> n >> m;
    if (n >= m / 2)
    {
        ans += m / 2;
        m -= ans * 2;
    }
    else
    {
        ans += n;
        m -= ans * 2;
    }
    ans += m / 4;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <cstdio>
#include <stack>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

bool check(int n, const vector<int> &a, int m) {
  map<int, int> b;

  b[a[0]] = 1;

  for(int i = 1; i < n; i++){
    int next = a[i];
    const int last = (--b.end())->first;

    if(next > last) {
      b[next] = 1;
    } else {
      while(b.count(next) != 0 && b[next] == m) next--;

      if(next == 0) return false;
      if(m == 1) return false;

      b.erase(b.upper_bound(next), b.end());

      if(b[next] == 0) b[next] = 1;
      b[next] += 1;
    }

    // for(auto c : b) printf("%d=%d ", c.first, c.second); puts("");
  }

  return true;
}

int main(){
  const int n = getInt();
  vector<int> a(n);
  REP(i,n) a[i] = getInt();

  int low = 1;
  int high = n;
  while(low <= high) {
    const int med = (low + high) / 2;
    if(check(n, a, med)) {
      high = med - 1;
    } else {
      low = med + 1;
    }
    // puts("");
  }

  printf("%d\n", low);

  return 0;
}

Measured memory_bytes: 10368
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
s = inputs[1].strip()
passwords = set()
for i in range(10):
    if str(i) in s[:-2]:
        pw1 = '{}'.format(i)
        idx1 = s.index(str(i)) + 1
        for j in range(10):
            if str(j) in s[idx1:-1]:
                pw2 = '{}{}'.format(pw1, j) 
                idx2 = idx1 + s[idx1:].index(str(j)) + 1
                for k in range(10):
                    if str(k) in s[idx2:]:
                        passwords.add('{}{}'.format(pw2, k))
print(len(passwords))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < N; i++)
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  int a[N];
  REP(i, N) cin >> a[i];

  sort(a, a + N, greater<int>());
  int ans, alice, bob;
  ans = alice = bob = 0;
  REP(i, N) {
    if (i % 2 == 0)
      alice += a[i];
    else
      bob += a[i];
  }
  ans = alice - bob;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

typedef pair<int, int> ii;

const int MN = 1010;

int cnt[MN][MN];
char board[MN][MN];

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	int h, w; cin >> h >> w;
	queue<ii> q;
	for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> board[i][j];
            if (board[i][j] == '#') q.push(ii(i, j));
        }
	}
	int ans = 0;
	while (!q.empty()) {
        ii curr = q.front(); q.pop();
        int x = curr.first, y = curr.second;
        for (int k = 0; k < 4; k++) {
            int nx = x + dx[k], ny = y + dy[k];
            if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
            if (board[nx][ny] == '.') {
                board[nx][ny] = '#';
                cnt[nx][ny] = cnt[x][y] + 1;
                q.push(ii(nx, ny));
                ans = max(ans, cnt[nx][ny]);
            }
        }
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
操作を逆から見る
*/

bool ok=true;
ll n,b[110],ans[110];

int main(void){
	cin>>n;
	reg(i,1,n)cin>>b[i];
	reg(i,1,n){
		ll c=n-i+1;
		ireg(j,1,n){
			if(b[j]==-1)continue;
			if(b[j]==c){
				ans[i]=c;
				b[j]=-1;
				break;
			}
			c--;
		}
		if(ans[i]==0){
			ok=false;
			break;
		}
	}
	if(ok){
		ireg(i,1,n)cout<<ans[i]<<endl;
	}else{
		cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a[200005],f;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
	for(int i=2;i<=n;i++)
		if(a[i]==a[i-1]) {cout<<"NO";return 0;}
	cout<<"YES";
	return 0;
}

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

int main(int argc, char const *argv[])
{
    int i,j,k,sum;
    int n,x;
    while(1) {
    cin >> n >> x;
    sum = 0;
    if(n==0 && x==0) break;
    for (int i = 1; i < n-1; ++i)
    {
        for (int j = i+1; j < n; ++j)
        {
            for (int k = j+1; k < n+1; ++k)
            {
                if(i+j+k==x) sum+=1;
            }
        }
    }
    cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;

int n;
int node[8][2];
// double dist[8][8] = {0};

double getDistance(int n1, int n2) {
    /*if (dist[n1][n2] != 0) {
        return dist[n1][n2];
    }*/

    return /*dist[n1][n2] = dist[n2][n1] = */ sqrt(
        double((node[n1][0] - node[n2][0]) * (node[n1][0] - node[n2][0]) +
               (node[n1][1] - node[n2][1]) * (node[n1][1] - node[n2][1])));
}

int main() {
    cin >> n;
    vector<int> index(n);
    for (int i = 0; i < n; i++) {
        cin >> node[i][0] >> node[i][1];
        index[i] = i;
    }

    double sum = 0;
    int n_floor = 0;
    do {
        for (int i = 0; i < n - 1; i++) {
            sum += getDistance(index[i], index[i + 1]);
        }
        n_floor++;
    } while (next_permutation(index.begin(), index.end()));

    cout << std::fixed << std::setprecision(15) << sum / n_floor << endl;

    return 0;
}

Measured memory_bytes: 3828
import qualified Data.ByteString.Char8 as B
import Data.Maybe
main=print.solve.map(fst.fromJust.B.readInt).B.words=<<B.getLine
m=10^9+7
solve(a:b:_)
 |d<1=(2*q)`mod`m
 |d<2=(i*q)`mod`m
 |otherwise=0
 where
  (i,j)=if a>b then(a,b)else(b,a)
  d=i-j
  p=f j
  q=(p*p)`mod`m
f 0=1
f n=(n*f(n-1))`mod`m

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<=(n); i++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define int long long
#define abs(a) llabs(a)
#define re(s) reverse((s).begin(),(s).end())
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;

using namespace std;
signed main(){

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

    int n,cnt=0;
    cin>>n;
    int x[1000010];

    rep(i,n) cin>>x[i];

    for(int i=1; i<n-1; i++){
        if((x[i-1] > x[i]) && (x[i] > x[i+1])) cnt++;
        else if((x[i-1] < x[i]) && (x[i] <  x[i+1])) cnt++;
    }
    cout<<cnt<<'\n';
}

Measured memory_bytes: 2304
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define inf 1e18
#define MAX 200005
#define mod 1000000007
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) cout<<"Case #"<<i<<": "
#define pf(a) printf("%lld\n",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define pfff(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pffff(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp,vpp1;
vector<pair<ll,ll> >vp,fin;
vector<ll>v,v1,v2,dummy;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb;
ll n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,maxi;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
vector<pair<ll,ll> >adj[MAX+10];
ll dep[MAX+10];
void reset()
{
    FOR(i,MAX)
    {
        adj[i].clear();
    }
    memset(dep,inf,sizeof dep);
}
void dijkstra(ll s)
{
    priority_queue<pair<ll,ll> >q;
    q.push(m_p(0,s));
    dep[s]=0;
    while(!q.empty())
    {
        ll cost=-q.top().ff;
        ll node=q.top().ss;
        q.pop();
        ll l=adj[node].size();
        FOR(i,l)
        {
            ll present_node=adj[node][i].ss;
            ll fcost=adj[node][i].ff;
            if(dep[present_node]>cost+fcost)
            {
                dep[present_node]=cost+fcost;
                q.push(m_p(-dep[present_node],present_node));
            }
        }
    }
}
int main()
{
    fast;
    reset();
    cin>>n;
    FOR(i,n-1)
    {
        ll x,y;
        cin>>x>>y>>c;
        adj[x].p_b(m_p(c,y));
        adj[y].p_b(m_p(c,x));
    }
    ll Q;
    cin>>Q>>k;
    dijkstra(k);
    FOR(i,Q)
    {
        cin>>a>>b;
        cout<<dep[a]+dep[b]<<endl;
    }
    return 0;
}


Measured memory_bytes: 14320
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
typedef long long LL;
using namespace std;

int main()
{
	//freopen("data_in.txt", "r", stdin);
	int n = 0, k = 0;
	cin >> n >> k;
	cout << (n - 1 +  k - 2) / (k - 1);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 900000000000000004
signed main(void){
    int n,g;cin>>n>>g;
    g/=100;
    int C[n];
    int Pr[n];
    rep(i,n){
        cin>>Pr[i]>>C[i];
        C[i]/=100;
    }
    int ans=INF;
    for(int tmp=0;tmp<(1<<n);tmp++){
        bitset<10>s(tmp);
        int count=0;
        int sum=0;
        rep(i,n){
            if(s.test(i)){
                sum+=(i+1)*Pr[i]+C[i];
                count+=Pr[i];
            }
        }
        if(sum>=g){
            ans=min(ans,count);
            continue;
        }
        for(int i=n-1;i>=0;i--){
            if(s.test(i))continue;
            int dif=g-sum;
            if(dif<=(i+1)*(Pr[i]-1)){
                count+=(dif+i)/(i+1);
                ans=min(ans,count);
                break;;
            }
            count+=Pr[i]-1;
        }
    }
    cout<<ans<<endl;
    
}
        


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
int main(){
  int n,a[N],v,i,j,k,count,minj,flag;
  count = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
      }
  for(i=0;i<=n-1;i++){
    flag = 0;
    minj = i;
    for(j=i;j<=n-1;j++){
      if(a[j]<a[minj]){
	minj = j;
	flag = 1;
      } 
    }
    if(flag){
      v=a[i];
    a[i]=a[minj];
    a[minj]=v;
    count++;
    }
  }
  for(k=0;k<n;k++){
      printf("%d",a[k]);
      if(k != n - 1)printf(" ");
      else printf("\n");
    }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2128
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;

  

int main(){
  string S; cin >> S; int N = S.size();
  bool ans = true;
  rep(i, (N-1)/2){
    if(S[i] != S[(N-3)/2 - i]) ans = false;
  }
  for(int i=(N+1)/2; i<=N-1; i++){
    if(S[i] != S[(3*N-1)/2 - i]) ans = false;
  }
  rep(i, N){
    if(S[i]!=S[N-1-i]) ans = false;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
MOD = 998244353
n,s = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

MAX_S = 3000
dp = [0]*(MAX_S+1)
ans = 0

n.times do |i|
  v = a[i]
  MAX_S.downto(1) do |j|
    if j + v <= MAX_S
      dp[j + v] += dp[j]
      dp[j + v] %= MOD
    end
  end
  dp[v] += i + 1

  if dp[s] > 0
    ans += dp[s] * (n - i)
    ans %= MOD
    dp[s] = 0
  end
end
p ans

Measured memory_bytes: 1916
def f(x, y):
    return x-y, x+y


n = int(input())
p = [list(map(int, input().split())) for i in range(n)]

max_x = -2000000000
min_x = 2000000000
max_y = -2000000000
min_y = 2000000000
for xi, yi in p:
    f1, f2 = f(xi, yi)
    max_x = max(max_x, f1)
    min_x = min(min_x, f1)
    max_y = max(max_y, f2)
    min_y = min(min_y, f2)

print(max(max_x - min_x, max_y - min_y))

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

int main() {

  int K, A, B; cin >> K >> A >> B;

  if (A%K ==0 || B%K == 0) cout << "OK" << endl;
  else if (A/K > 1 && K*(A/K+1) <= B)
    cout << "OK" << endl;
  else cout << "NG" << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
namespace ac {
    using namespace std;
    
}
using namespace std;
using namespace ac;
typedef int64_t ll;
namespace ac {
    
    // 文字列変換
    template < typename T > string to_string(const T& n) {
        ostringstream stm;
        stm << n;
        return stm.str();
    }
    
}
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll n;
        in >> n;
        int cnt = 0;
        string s = to_string(n);
        for (int i = 0; i < s.size() - 1; i++) {
            if (s[i] == s[i + 1]) {
                cnt++;
            }
            else if (cnt > 0){
                break;
            }
        }
        out << (cnt >= 2 ? "Yes" : "No") << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int a[100005],n;
int gcd(int a,int b)
{
	if (b==0) return a;
	else return gcd(b,a%b);
}
void haowuliaokuaixiake(int f)
{
	int x=0,y=0;
	for (int i=1;i<=n;i++)
		if (a[i]&1) x++; else y++;
	if (y&1)
	{
		if (f==1) printf("First\n"); else printf("Second\n");
		return;
	}
	if (x>1)
	{
		if (f==1) printf("Second\n"); else printf("First\n");
		return;
	}
	for (int i=1;i<=n;i++)
		if (a[i]==1)
		{
			if (f==1) printf("Second\n"); else printf("First\n");
			return;
		}
	for (int i=1;i<=n;i++)
		if (a[i]&1) a[i]--;
	int g=a[1];
	for (int i=2;i<=n;i++)
		g=gcd(g,a[i]);
	for (int i=1;i<=n;i++)
		a[i]/=g;
	haowuliaokuaixiake(-f);
	return;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	haowuliaokuaixiake(1);
	return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import math

#############
# Constants #
#############

MOD = 10**9 +7
INF = float('inf')

#############
# Functions #
#############

kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

#############
# Main Code #
#############

N = int(input())
l = map(int, input().split())

min = INF
ans = 0
for i in l:
  if i < min:
    min = i
    ans += 1

print(ans)

Measured memory_bytes: 70668
#include <iostream>
#include <vector>
#include <map>

using namespace std;

template <class T>
bool chmin(T &x, T y)
{
    return x>y ? (x=y, true) : false;
}
template <class T>
bool chmax(T &x, T y)
{
    return x<y ? (x=y, true) : false;
}

main()
{
    int n,k; cin>>k>>n;
    vector<int> a(n);
    for(auto &e:a)
    {
        cin>>e;
    }
    int blank=a.front()+k-a.back();
    for(int i=0;i+1<n;++i)
    {
        chmax(blank, a[i+1]-a[i]);
    }
    cout << k-blank << "\n";
}

Measured memory_bytes: 1024
a, b, c, d, e = map(int, input().split())
ans = 0
if a == 0:
    ans = 1
if b == 0:
    ans = 2
if c == 0:
    ans = 3
if d == 0:
    ans = 4
if e == 0:
    ans = 5
print(ans)

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

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	for (int n = 0;n<N;++n) {
		cin >> A[n];
	}
	int num = 1;
	int ans = 0;
	for (int n = 0; n < N; ++n) {
		if (num == A[n]) {
			num++;
		}
		else {
			ans++;
		}
	}
	if (1 == num) {
		cout << -1<<endl;
	}
	else {
		cout << ans <<endl;
	}
	return 0;
}

Measured memory_bytes: 4044
import sys
import math
import itertools
from collections import deque

s=input()
n=len(s)
if(n%2==1):
    print("No")
    sys.exit()
for i in range(0,n,2):
    if(s[i]!='h' or s[i+1]!='i'):
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 3316
def compute(s, t):
    for si in reversed(range(len(s)-len(t)+1)):
        for ti in range(len(t)):
            if not (s[si+ti]==t[ti] or s[si+ti]=="?"): break
            if ti!=len(t)-1: continue
            head=s[:si]
            tail=s[si+len(t):]
            return head+t+tail
    return None

s=input()
t=input()
template=compute(s, t)
if template:
    result=""
    for c in template:
        result+="a" if c=="?" else c
    print(result)
else:
    print("UNRESTORABLE")


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

int main() {
int x,a,b;
cin >> x >> a >> b;
if(a-b>=0){
  cout << "delicious" << endl;
}
else if((x+a)-b>=0){
  cout << "safe" << endl;
}
else{
  cout << "dangerous" << endl;
}

  return 0;
}


Measured memory_bytes: 256
// Problem : C - Snack
// Contest : AtCoder Beginner Contest 148
// URL : https://atcoder.jp/contests/abc148/tasks/abc148_c
// Memory Limit : 1024.000000MB 
// Time Limit : 2000.000000milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define vl vector<ll>


/*#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}*/


//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

using namespace __gnu_pbds;
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w;
string s,s1,s2;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>x>>y;
	cout<<x*y/__gcd(x,y);
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Summarize count of factor within list
def summarize_list(l):
  sl=sorted(l)

  a=sl[0]
  c=1
  res=[]

  for x in sl[1:]:
    if x==a:
      c+=1
    else:
      res.append([a,c])
      a=x
      c=1
  res.append([a,c])

  return res

def main():
  s=list(S())
  t=summarize_list(s)

  if len(s)==1:
    return 'YES'
  if len(s)==2:
    if len(t)==2:
      return 'YES'
    return 'NO'
  if len(t)<=2:
    return 'NO'

  t=sorted(t,key=lambda x:x[1])
  # print(t)
  if t[2][1]-t[0][1]>=2:
    return 'NO'
  return 'YES'

# main()
print(main())


Measured memory_bytes: 8020
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
B=[]
c=0
for i in range(N):
  a=A[i][0]+A[i][1]
  c-=A[i][1]
  B.append(a)
B=sorted(B)[::-1]
d=(N+1)//2
for i in range(d):
  c+=B[2*i]
print(c)

Measured memory_bytes: 33036
A, V = input().split()
B, W = input().split()
T    = input()

A = int(A)
V = int(V)
B = int(B)
W = int(W)
T = int(T)

result = abs((B - A)) + (W * T) - V * T

if result <= 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9188
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N, T = map(int, readline().split())
    dishes = []
    for _ in range(N):
        A, B = map(int, readline().split())
        dishes.append([A, B])

    dp1 = [[0]*T for _ in range(N)] # i and less than i
    dp2 = [[0]*T for _ in range(N+1)] # more than i

    for i, dish in enumerate(dishes[:-1]):
        a, b = dish
        i = i + 1
        for t in range(T):
            if a > t:
                dp1[i][t] = dp1[i-1][t]
            else:
                if dp1[i-1][t-a] + b > dp1[i-1][t]:
                    dp1[i][t] = dp1[i-1][t-a] + b
                else:
                    dp1[i][t] = dp1[i-1][t]


    for i, dish in enumerate(reversed(dishes[1:])):
        a, b = dish
        i = N - i - 1
        for t in range(T):
            if a > t:
                dp2[i][t] = dp2[i+1][t]
            else:
                if dp2[i+1][t-a] + b > dp2[i+1][t]:
                    dp2[i][t] = dp2[i+1][t-a] + b
                else:
                    dp2[i][t] = dp2[i+1][t]

    ans = 0
    for last in range(1, N+1):
        for j in range(T):
            a = dishes[last-1][1]
            a += dp1[last-1][T-1-j] + dp2[last][j]
            ans = a if ans < a else ans
    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 221268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC099A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;
            string[] s = Console.ReadLine().Split(' ');
            a = int.Parse(s[0]);

            if (a >= 1000)
                Console.WriteLine("ABD");

            else
                Console.WriteLine("ABC");
        }
    }
}


Measured memory_bytes: 11092
# https://abc100.contest.atcoder.jp/tasks/abc100_d
# D - Patisserie ABC

# D_Patisserie_ABC.py

import collections

N, M = map(int, input().strip().split(" "))
A = [[] for i in range(8)]
for n in range(N):
    # 「綺麗さ」「おいしさ」「人気度」
    x, y, z = map(int, input().strip().split(" "))

    A[0].append(x+y+z)
    A[1].append(-x+y+z)
    A[2].append(x-y+z)
    A[3].append(x+y-z)
    A[4].append(x-y-z)
    A[5].append(-x+y-z)
    A[6].append(-x-y+z)
    A[7].append(-x-y-z)


T = []
for i in range(8):
    A[i].sort()
    total = 0
    for _ in range(M):
        total += A[i].pop()
    T.append(total)

T.sort()
print(T[-1])


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1,_2,_3,name,...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (ll i=(a); i<(n); ++i)
#define rep(...) _overload3(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<class T> inline void print(const T& x) {cout << x << "\n";}
template<class T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
struct Init {Init() {cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;

int main() {
    ll n, m;
    cin >> n >> m;
    map<ll, ll, greater<ll>> d;
    rep(i, n) {ll a; cin >> a; ++d[a];}
    rep(i, m) {ll b, c; cin >> b >> c; d[c] += b;}
    ll ans = 0, cnt = 0;
    each(e, d) {
        if (cnt > n) break;
        ll f = min(e.se, n - cnt);
        cnt += f;
        ans += e.fi * f;
    }
    print(ans);
}

Measured memory_bytes: 16124
#!/usr/bin/python3

import sys
# input = sys.stdin.readline
sys.setrecursionlimit(100000)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7

#N = int(input())
#A = [int(x) for x in input().split()]
#V = [[0] * 100 for _ in range(100)]

N, K = [int(x) for x in input().split()]

def f(x):
    ret = x % K
    ret = min(ret, abs(K-ret))
    return ret
    
print(f(N))


Measured memory_bytes: 3060
l = [int(x) for x in input().split()]
A, B, K = l[0], l[1], l[2]
deltaA = A - K
if deltaA < 0:
    A = 0
    deltaB = B + deltaA
    if deltaB < 0:
        B = 0
    else:
        B = deltaB
else:
    A = deltaA
print(A, B)

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) {
        //文字列の入力受付
        Scanner inStr = new Scanner(System.in);
        String S = inStr.nextLine();
        String T = inStr.nextLine();
        inStr.close();

        /*
         * 以下の条件を満たすこと
         *・S,Tは英小文字、文字数は1~10文字
         *・|T| = |S| + 1
         */
        if (Pattern.matches("[a-z]{1,10}", S) && Pattern.matches("[a-z]+", T)
                && T.length() == S.length() + 1) {
            //Tの文字列がSの文字列を全て含んでいること
            String subStr = T.substring(0, S.length());

            //判定結果を出力
            if (S.equals(subStr)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }

        } else {
            System.out.println("No");
        }

    }

}


Measured memory_bytes: 35716
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s<t){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
    int l=0,r=0;
    int n;cin>>n;
    rep(i,n){
        int p;char c;
        cin>>p>>c>>p;
        (c=='('?l:r)+=p;
        cout<<(l==r?"Yes":"No")<<endl;
    }
	
	return 0;
}



Measured memory_bytes: 3124
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;



int main() {
	
	int n;
	cin >> n;
	vector<int> l(n, 0);
	rep(i, n) {
		cin >> l[i];
	}

	sort(l.begin(), l.end());

	int res = 0;

	rep(i, n) {
		for (int j = i + 1; j < n; ++j) {
			int k = lower_bound(l.begin(), l.end(), l[i] + l[j]) - l.begin();

			res += max(k - (j + 1), 0);
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n=0):
        self.d = [-1]*n
    
    def find(self, x):
        if self.d[x] < 0: return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x,y=self.find(x),self.find(y)
        if x==y:return False
        if self.d[x] > self.d[y]: x,y=y,x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True

    def same(self, x,y): return self.find(x)==self.find(y)
    def size(self,x): return -self.d[self.find(x)]
    
N,M=map(int,input().split())
uf = UnionFind(N)
for i in range(M):
  a,b=map(int,input().split())
  uf.unite(a-1,b-1)
  
ans = 0
for v in range(N):
  if uf.d[v]<0: ans += 1
    
print(ans-1)

Measured memory_bytes: 10792
S = input()
T = input()

ans = 10**9

for i in range(len(S)-len(T)+1):
	tmpS = S[i:i+len(T)]
	cnt = 0
	for j in range(len(T)):
		if tmpS[j] != T[j]:
			cnt += 1
	ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 8980
#include<iostream>
#include<cstdio>
using namespace std;
int a;
int m=2000000000,M=-1;
int main()
{
    int n;
    cin>>n;
    for (int i=0; i<n; ++i)
    {
        cin>>a;
        if (a<m) m=a;
        if (a>M) M=a;
    }
    cout<<M-m<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int isprime(int n){
    int i;
    for(i = 2; i  < n; i ++ ){
        if(n % i == 0)return 0;
    }
    return 1;
}
int main(void){
    const int NUM = 10000;
    int i,n,prime[NUM],p1,q1;
    for(i = 2; i < NUM; i ++ ){
        prime[i] = isprime(i);
    }
    
    while(1){
        scanf("%d",&n);
        if(n == 0)break;
        for(i = n; i >= 2; i --){
            if(prime[i] == 1 && prime[i - 2] == 1){
                    q1 = i;
                    p1 = i - 2;
                    printf("%d %d\n",p1,q1);
                    break;
            }
        }
    }
    return 0;
}

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

int main(){
    int N, tmp, two=0, four=0, other=0;
    cin >> N;	
    for(int i=0; i<N; i++){
	cin >> tmp;
	if(tmp%4 == 0)
	    four++;
	else if(tmp%2 == 0)
	    two++;
	else
	    other++;
    }
    if(N%2==1){
	if(four >= other ||(two==0 && four >= other-1))
	    cout << "Yes"<< endl;
	else
	    cout << "No"<< endl;
    }
    else{
	if(four >= other)
	    cout << "Yes"<< endl;
	else
	    cout << "No"<< endl;
    }


}



Measured memory_bytes: 256