akhauriyash/Code-Regression huggingface dataset:
#ifndef LOCAL
#pragma GCC optimize ("O3")
#endif

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (c it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(x...) " [" #x ": " << (x) << "] "

using ll = long long;

constexpr int mod = 1000 * 1000 * 1000 + 7;

void OdejmijOd(int& a, int b) { a -= b; if (a < 0) a += mod; }
int Odejmij(int a, int b) { OdejmijOd(a, b); return a; }
void DodajDo(int& a, int b) { a += b; if (a >= mod) a -= mod; }
int Dodaj(int a, int b) { DodajDo(a, b); return a; }
int Mnoz(int a, int b) { return (ll) a * b % mod; }
void MnozDo(int& a, int b) { a = Mnoz(a, b); }

constexpr int nax = 200 * 1000 + 105;

void nie() {
  printf("-1\n");
  exit(0);
}

int n;
int tab[nax];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &tab[i]);
    if (tab[i] > i) nie();
  }
  ll wynik = 0;
  for (int i = n - 1; i >= 1; i--) {
    if (tab[i] - 1 == tab[i - 1]) {
      wynik++;
      continue;
    } else if (tab[i] - 1 > tab[i - 1]) {
      nie();
    } else {
      wynik += tab[i];
      continue;
    }
  }
  printf("%lld\n", wynik);
  return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, M: int, C: int, B: "List[int]", A: "List[List[int]]"):
    print(sum(
        1 for Ai in A
        if sum(Aij * Bj for Aij, Bj in zip(Ai, B)) + C > 0
    ))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    B = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    A = [[int(next(tokens)) for _ in range(M)] for _ in range(N)]  # type: "List[List[int]]"
    solve(N, M, C, B, A)


if __name__ == '__main__':
    main()


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

#define int long long
#define double long double

using namespace std;

#define REP(i, a, b) for (int(i) = (a); i < (b); (i)++)
#define rep(i, n) REP(i, 0, n)
#define PER(i, a, b) for (int(i) = (a - 1); i >= (b); (i)--)
#define per(i, n) PER(i, n, 0)
#define each(i, n) for (auto &i : n)
#define clr(a) memset((a), 0, sizeof(a))
#define mclr(a) memset((a), -1, sizeof(a))
#define all(a) (a).begin(), (a).end()
#define dum(val) cerr << #val " = " << val << " ";
#define dump(val) cerr << #val " = " << val << endl;
#define FILL(a, v) fill(a, a + sizeof(a) / sizeof(*a), v)

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const int mod = 1e9 + 7;
const int INF = 1e9;

signed main() {

	int n;
	cin >> n;

	vector<int> a(n);

	P mi = P(INF, -1);
	P ma = P(-INF, -1);
	rep(i, n) {
		cin >> a[i];
		mi = min(mi, P(a[i], i));
		ma = max(ma, P(a[i], i));
	}

	vector<P> ans;
	if(abs(mi.first) > abs(ma.first)){
		rep(i, n){
			if(i != mi.second) {
				ans.push_back(P(mi.second, i));
				a[i] += a[mi.second];
			}
		}
		for(int i = n-1;i >= 1;i--){
			if (a[i - 1] > a[i]) {
				//- -
				ans.push_back(P(i, i - 1));
				a[i - 1] += a[i];
			}
		}
	}else{
		rep(i, n) {
			if (i != ma.second){
				ans.push_back(P(ma.second, i));
				a[i] += a[ma.second];
			} 
		}
		rep(i, n - 1) {
			if (a[i] > a[i + 1]) {
				//- -
				ans.push_back(P(i, i + 1));
				a[i + 1] += a[i];
			}
		}
	}

	cout << ans.size() << endl;
	rep(i, ans.size()) {
		cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
typedef long double ld;
using namespace std;

vvl G = vv(2000, 0, 0, ll);
vector<ll> use(2000, 0);
vvl ans = vv(0, 0, 0, ll);
map<ll, ll> mp;

void df(ll now, ll d){
  use[now] = 1;
  mp.emplace(now, d);
  ll a = 0, b = 0;
  for(int i=0;i<G[now].size();i++) if(mp.count(G[now][i])!=0) a=1, b = max(b, mp.at(G[now][i]));
  if(a==0){
    for(int i=0;i<G[now].size();i++){}
    for(int i=0;i<G[now].size();i++){
      if(use[G[now][i]]==1)continue;
      df(G[now][i], d+1);
    }
  }else{
    //std::cout << now << '\n';
    //for(auto itr = mp.begin(); itr!=mp.end();itr++) std::cout << (*itr).first << " " << (*itr).second << '\n';
    ans.push_back(std::vector<ll> {});
    for(auto itr=mp.begin();itr!=mp.end();itr++) if(b<=(*itr).second) ans[ans.size()-1].push_back((*itr).first);
  }
  mp.erase(now);
}
int main(int argc, char const *argv[]) {
  ll N, M, a, b;
  std::cin >> N >> M;
  for(int i=0;i<M;i++){
    std::cin >> a >> b;
    G[a].push_back(b);
  }
  for(int i=1;i<=N;i++){
    if(use[i]==0){
      mp.clear();
      df(i, 1);
    }
  }
  if(ans.size()==0)std::cout << -1 << '\n';
  else{
    ll m = 1000000, idx = -1;
    for(int i=0;i<ans.size();i++) if(ans[i].size()<m) m = ans[i].size(), idx = i;
    std::cout << m << '\n';
    for(int i=0;i<ans[idx].size();i++) std::cout << ans[idx][i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 512
def mod_inverse(a, p):
    return pow(a, p-2, p)  # フェルマーの小定理より

def mod_binominal(n, r, p):
    numerator= 1
    for i in range(r):
        numerator = (numerator * (n - i)) % p

    denominator = 1
    for i in range(1, r+1):
        denominator = (denominator * i) % p

    return (numerator * mod_inverse(denominator, p)) % p

def resolve():
    n, a, b = map(int, input().split())
    p = 10**9+7

    ans = pow(2, n, p) - mod_binominal(n, a, p) - mod_binominal(n, b, p) - 1
    print((ans + p) % p)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 38896
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,*A = map(int,read().split())

def LIS(seq,wider_sense = False):
    from bisect import bisect_left, bisect_right
    f = bisect_right if wider_sense else bisect_left
    N = len(seq)
    INF = 10**18
    dp = [INF] * (N+1)
    for x in seq:
        i = f(dp,x)
        dp[i] = x
    return f(dp,INF-1)

answer = LIS([-x for x in A],wider_sense=True)
print(answer)

Measured memory_bytes: 12528
n=int(input())
a=list(map(int, input().split()))

print(2*n-1)
if abs(max(a))>=abs(min(a)):
    b=a.index(max(a))
    for i in range(n):
        print(b+1,i+1)
    for i in range(n-1):
        print(i+1,i+2)
  
else:
    b=a.index(min(a))
    for i in range(n):
        print(b+1,i+1)
    for i in range(n-1):
        print(n-i,n-1-i)


Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main()
{
    long long int N, A, B;

    cin >> N >> A >> B;


    if(A == B)

        cout << 1 << endl;

    else if(N == 1)

        cout << 0 << endl;

    else if(B < A)

        cout<< 0 <<endl;

    else

       cout << ((B - A) * (N - 2)) + 1 << endl;

    return 0;
}


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

using namespace std;
const int N = 2e5+100;
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
long long a[N];
long long s[N];
int main(){
  long long n,k;
  cin>>n>>k;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    s[i]=s[i-1]+a[i];
  }
  for(int i=1;i<=n;i++){
    s[i]=((s[i]-i)%k+k)%k;
  }
  map<int,int> counts;
  counts[0]=1;
  long long ans=0;
  for(int i=1;i<=n;i++){
    if(i>=k) counts[s[i-k]]--;//用不到了
    ans+=counts[s[i]];
    // cout<<i<<' '<<ans<<' '<<s[i]<<endl;
    counts[s[i]]++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 12800
N,M = [int(i) for i in input().split()]
La = -1
Ra = 10**9+7
for i in range(M):
    L,R = [int(j) for j in input().split()]
    La= max(L,La)
    Ra = min(R,Ra)
if Ra - La +1 <=0:
    print(0)
if Ra - La + 1>0:
    print(Ra-La+1)

Measured memory_bytes: 3188
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int n,y; cin >> n >> y;
  int n1,n2,n3;
  n1 = 0;
  n2 = 0;
  n3 = 0;
  for (int i = 0; i < n+1; ++i) {
    for (int j = 0; j < n+1 - i; ++j) {
      for (int k = 0; k < n+1 - i - j; ++k) {
        if (i * 10000 + j * 5000 + k * 1000 == y && i+j+k == n) {
          cout << i << " " << j << " " << k << endl;
          return 0;
        }
      }
    }
  }
  cout << "-1 -1 -1" << endl;
	return 0;
}


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

int main(){
  int k, x;
  cin >> k >> x;
  int minv = max(x-k+1, -1000000 );
  int maxv = min(x+k-1, 1000000 );
  for ( int i = minv; i <= maxv; i++){
    if (i != minv)cout << " ";
    cout << i;
  }
  cout << endl;

  return 0;
}

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

int main(){
  long double a, b, c;
  cin >> a >> b >> c;
  if((0 < (c - a - b)) && (4 * a * b < ((c - a - b) * (c - a - b))))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

N, M = LI()
H = LI()
route = []
for i in range(M):
    a, b = LI()
    a -= 1
    b -= 1
    route.append((a,b))

N_path = [[] for i in range(N)]
for a, b in route:
    N_path[a].append(b)
    N_path[b].append(a)

# print(H)
ans = 0
for i in range(N):
    for path in N_path[i]:
        if H[path] >= H[i]:
            break
    else:
        ans += 1
print(ans)



# uf = UnionFind(N)
# for a, b in route:
#     uf.Unite(a, b)

# ans = 0
# good_obs = []
# for i in range(N):
#     print(good_obs)
#     if len(good_obs) == 0:
#         good_obs.append(i)
#     else:
#         for obs in good_obs:
#             print(obs, i)
#             if uf.isSameGroup(obs, i):
#                 if H[obs] == H[i]:
#                     good_obs.append(i)
#                     break
#                 elif H[obs] > H[i]:
#                     pass
#                 elif H[obs] < H[i]:
#                     good_obs.remove(obs)
#                     good_obs.append(i)
# print(good_obs)
# print(len(good_obs))
                
            
    

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

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

    long long PN[1005] = {};
    long long mod = 1000000007;
    // N!を素因数分解したとき、p^xの項が出てきたら、PN[p] = x % mod

    for (int n = 2; n <= N; n++)
    {
        int m = n;
        for (int i = 2; i <= pow(m, 0.5) + 1; i++)
        {
            while (m % i == 0)
            {
                m /= i;
                PN[i]++;
            }
        }
        if (m != 1)
        {
            PN[m]++;
        }
    }

    /*
    cout << N << "! = ";
    for (int i = 2; i <= N; i++)
    {
        cout << " + " << i << "^" << PN[i];
    }
    cout << endl;
    return 0;
    */

    long long ans = 1;
    for (int n = 2; n <= N; n++)
    {
        ans *= PN[n] + 1;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int X = scan.nextInt();
        int A = scan.nextInt();
        int answer = X < A ? 0 : 10;
        System.out.println(answer);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
//const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

//to calculate p1^x  *  p2^x2  *p3^x3 ----------
//i.e. prime factorization and store pi and xi in vector 
vector<pair<ll, ll>> pFactor;

void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        pFactor.pb({2,count}); 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            pFactor.pb({i,count});
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        pFactor.pb({n,1}); 
} 



int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
  ll n, k;
  cin>>n>>k;
  //set<ll> s;
  vector<pll> v;
  lp(0,k){
      ll x,y;
      cin>>x>>y;
      v.pb({x,y});
  }
  
  ll dp[n+1] = {0};
  ll suf[n+1] = {0};
  suf[n] = 1ll;
  ll mod = 998244353;
  dp[n]= 1ll;
  for(ll i=n-1; i>0; i--){
      for(ll j=0; j<v.size(); j++){
          int s= i + v[j].ff;
          int e = i+v[j].ss;
          if(s>n) continue;
          if(e>n) e=n;
          int res;
          if(e == n){
              res = suf[s]%mod;
          }else
          res = (suf[s] - suf[e+1])%mod;
          if(res < 0){
              res += mod;
          }
          dp[i] += res;
          dp[i] %= mod;
      }
      suf[i] = dp[i] + suf[i+1];
      suf[i] %= mod;
  }
  cout<<dp[1]%mod<<endl;
  
}

Measured memory_bytes: 6700
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>

using flt = double;
const flt eps = 1e-12, inf = 1e18, PI = acos(-1.0);
template<typename T>
inline T sqr(T x) {return x * x;}
inline flt cmp(flt a, flt b, flt e = eps) {
  return fabs(a - b) >= e + fabs(a) * e ? a - b : 0;
}
inline int sgn(flt x, flt e = eps) {return x < -e ? -1 : (x > e);}
inline flt fix(flt x, flt e = eps) {return cmp(x, 0, e);}

struct point {
  flt x, y;
  point(flt x = 0, flt y = 0): x(x), y(y) {}
  bool operator < (const point &rhs) const {
    return cmp(x, rhs.x) < 0 || (cmp(x, rhs.x) == 0 && cmp(y, rhs.y) < 0);
  }
  bool operator == (const point &rhs) const {
    return cmp(x, rhs.x) == 0 && cmp(y, rhs.y) == 0;
  }
  point operator + (const point &rhs) const {
    return point(x + rhs.x, y + rhs.y);
  }
  point operator - (const point &rhs) const {
    return point(x - rhs.x, y - rhs.y);
  }
  point operator * (const flt k) const {
    return point(x * k, y * k);
  }
  point operator / (const flt k) const {
    return point(x / k, y / k);
  }
  point operator ~ () const {// counter clockwise rotate 90 degree
    return point(-y, x);
  }
  flt dot(const point &rhs) const {
    return x * rhs.x + y * rhs.y;
  }
  flt det(const point &rhs) const {
    return x * rhs.y - y * rhs.x;
  }
  flt norm2() const {
    return x * x + y * y;
  }
  flt norm() const {
    return hypot(x, y);
  }
  point rot(flt a) const {// counter clockwise rotate A rad
    return point(x * cos(a) - y * sin(a), x * sin(a) + y * cos(a));
  }
  point rot(flt cosa, flt sina) const {// counter clockwise rotate using cos/sin
    return point(x * cosa - y * sina, x * sina + y * cosa);
  }
  point trunc(flt a = 1.0) const {
    return (*this) * (a / this->norm());
  }
};

int main() {
  int n;
  scanf("%d", &n);
  std::vector<point> p(n);
  for (int i = 0; i < n; ++i) {
    scanf("%lf%lf", &p[i].x, &p[i].y);
  }
  for (int i = 0; i < n; ++i) {
    const point &A = p[i], &B = p[(i + 1) % n], &C = p[(i + 2) % n];
    if (sgn((B - A).det(C - A)) < 0) {
      puts("0");
      return 0;
    }
  }
  puts("1");
  return 0;
}

Measured memory_bytes: 2740
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int w=fs.nextInt(), h=fs.nextInt();
		h=w=(int)1e6;
		int n=fs.nextInt();
		int[] xs=new int[n];
		int[] ys=new int[n];
		HashSet<Long> points=new HashSet<>();
		int[] onX=new int[w+1], onY=new int[h+1];
		for (int i=0; i<n; i++) {
			xs[i]=fs.nextInt();
			ys[i]=fs.nextInt();
			points.add(hash(xs[i], ys[i]));
			onX[xs[i]]++;
			onY[ys[i]]++;
		}
		int maxX=0, maxY=0;
		for (int x=0; x<=w; x++) maxX=Math.max(maxX, onX[x]);
		for (int y=0; y<=h; y++) maxY=Math.max(maxY, onY[y]);
		ArrayList<Integer> candidateXs=new ArrayList<>();
		ArrayList<Integer> candidateYs=new ArrayList<>();
		for (int x=0; x<w; x++)
			if (onX[x]==maxX) candidateXs.add(x);
		for (int y=0; y<h; y++)
			if (onY[y]==maxY) candidateYs.add(y);
		int ans=maxX+maxY-1;
		outer: for (int x:candidateXs) {
			for (int y:candidateYs) {
				if (!points.contains(hash(x, y))) {
					ans++;
					break outer;
				}
			}
		}
		
		System.out.println(ans);
	}

	static long hash(int x, int y) {
		return x*1_000_000_000l+y;
	}
	
	static final Random random=new Random();
	
	static void ruffleSort(int[] a) {
		int n=a.length;//shuffle, then sort 
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


Measured memory_bytes: 90320
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n;
    cout<<n*n*3<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   /// https://ideone.com/Fd5s8n
  ll a,b,h,m;
  cin>>a>>b>>h>>m;
  double hdeg = h*30;
  double mdeg = m*6;
  hdeg += mdeg/12;
  double angle = abs(hdeg-mdeg);
  double cosangle = cos(angle * PI/180);
  cout << fixed  << setprecision(20) << sqrt(a*a+b*b -2*a*b*cosangle) << endl;

    return 0;

}


Measured memory_bytes: 4112
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a ^ b ^ c);
    
    cout << endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    println!("{} {}",a*b,a*2+b*2);
}



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

int main(void){
  double w,h,x,y;
  cin >> w >> h >> x >> y;
  cout << fixed << setprecision(20);
  cout << w*h/2 << " ";
  if(h/2 == y && w/2 == x){
    cout << 1 << endl;
  }
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
//typedef complex<long double> com;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	for (int z=0;z<s.size();z++){
		cout << "x";
	}
} 
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#define rep(i,a,b) for(int i=a;i<b;++i)
using namespace std;
typedef long long ll;
void chmin(int &a,int b){if(a>b) a=b;} //Compare two numbers and return smaller one in reference variety a
int N;
 
 
int main()
{
 
    cin>>N;
    double top=(N+0.999)/1.08;
    double bottom=N/1.08;
    
    int int_top=(int)floor(top);
    int int_bottom=(int)ceil(bottom);
    if(int_top-int_bottom>=0)
    {
        cout<<int_bottom<<endl;
    }
    else
    {
        cout<<":("<<endl;
    }
    
    
 
    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;
typedef vector<vector<char> > vvc;
typedef vector<vector<int> > vvi;

int dfs(vvc& G,vvi& G2,int x,int y,int cost)
{
  if(G[y][x] == '*' || x >= G[y].size())
    return cost;
  
  int nx = x + 1;
  int res = dfs(G,G2,nx,y,cost+1);
  G2[y][x] = res-cost;  
  return res;
}

int main()
{
  int H,W;
  while(cin >> H >> W,H|W)
    {
      vector<vector<char> > G;
      G.resize(H);
      vector<vector<int> > G2;
      G2.resize(H);
      for(int i=0;i<H;i++)
	{
	  G[i].resize(W);
	  G2[i].resize(W);
	  string line;
	  cin >> line;
	  for(int j=0;j<W;j++)
	    G[i][j] = line[j],G2[i][j] = -1;     
	}

      for(int i=0;i<H;i++)
	for(int j=0;j<W;j++)
	  if(G2[i][j] == -1 && G[i][j] != '*')
	    G2[i][j] = dfs(G,G2,j,i,1)-1;
  
      int mex = 0;
      for(int i=0;i<H;i++)
	for(int j=0;j<W;j++)
	  if(G[i][j] == '.')
	    {
	      int pre = (1<<29);
	      for(int k=i;k<H&&G[k][j] != '*';k++)
		{
		  pre = min(pre,G2[k][j]);
		  mex = max(mex,pre*(k-i+1)); 
		}
	
	    }     
	  cout << mex << endl;


    }
  return 0;
}

Measured memory_bytes: 2404
const line = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n');

let cnt = 0;

const merge = (arr, left, mid, right) => {
    const n1 = mid - left;
    const n2 = right - mid;
    const L = [];
    const R = [];

    for (let i = 0; i < n1; i++) {
        L[i] = arr[left + i];
    }
    for (let i = 0; i < n2; i++) {
        R[i] = arr[mid + i];
    }

    L[n1] = Number.MAX_VALUE;
    R[n2] = Number.MAX_VALUE;

    let i = 0;
    let j = 0;
    for (let k = left; k < right; k++) {
        cnt++;
        if (L[i] <= R[j]) {
            arr[k] = L[i];
            i++;
        } else {
            arr[k] = R[j];
            j++;
        }
    }
};

const msort = (arr, left, right) => {
    if (left + 1 < right) {
        const mid = Math.floor((left + right) / 2);
        msort(arr, left, mid);
        msort(arr, mid, right);
        merge(arr, left, mid, right);
    }
};

const data = line[1].split(' ').map(Number);
msort(data, 0, data.length);
console.log(data.join(' '));
console.log(cnt);



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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  void solve() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << max(0, (h2 - h1) * 60 + (m2 - m1) - k) << endl;
  }
};
class Solver2 {
 public:
  int n, m;
  Solver2(LL n, LL m) : n(n), m(m){};

  void solve() {
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);

  Problem::Solver sol;
  sol.solve();
  return 0;
}


Measured memory_bytes: 3660
n = int(input())
a = [int(input()) for i in range(n)]
a.sort()
s = a[0:4]
p = []
for i in range(len(s)):
    for j in range(len(s)):
        if i != j:
            p.append(int(str(s[i]) + str(s[j])))
p.sort()
print(p[2])



Measured memory_bytes: 5932
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 123456;
vector<int> G[MAXN];
bool visit[MAXN];

void dfs(int cur) {
     visit[cur] = 1;
     for (int i : G[cur]) {
         if (!visit[i]) dfs(i);
     }
}

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    for (int i = 0; i < M; i++) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (!visit[i]) {
           ans++;
           dfs(i);
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 9472
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
typedef long long LL;

LL fa[100005],siz[100005];
LL c[100005] = {0},d[100005],m,n;
LL l[100005],r[100005];
string s;

void init(){
	for(LL i = 1;i <= (m >> 1);i ++) c[i] = (s[m + 1 - i] - s[i] + 26) % 26;
//	for(LL i = 1;i <= (m >> 1);i ++) cout << c[i] << (i == (m >> 1) ? '\n' : ' ');
	for(LL i = 0;i <= (m >> 1);i ++) d[i + 1] = (c[i + 1] - c[i] + 26) % 26;
	for(LL i = 1;i <= (m >> 1) + 1;i ++){
		fa[i] = i;
		siz[i] = d[i];
	}
	
	for(LL i = 1;i <= n;i ++){
		if(l[i] > (m >> 1) && r[i] > (m >> 1)){
			swap(l[i],r[i]);
			l[i] = m + 1 - l[i];
			r[i] = m + 1 - r[i];
		}
		else if(r[i] > (m >> 1)){
			LL tor = m + 1 - r[i];
			if(tor < l[i]){
				r[i] = l[i] - 1;
				l[i] = tor;
			}
			else{
				r[i] = tor - 1;
			}
		}
	}
}

LL getf(LL x){
	if(fa[x] == x) return x;
	return fa[x] = getf(fa[x]);
}

void unionn(LL x,LL y){
	x = getf(x); y = getf(y);
	if(x == y) return;
	fa[x] = y; siz[y] += siz[x];
}

int main(){
	cin >> s; cin >> n;
	for(LL i = 1;i <= n;i ++) cin >> l[i] >> r[i];
	m = s.length(); s = ' ' + s;
	init();
	
//	for(LL i = 1;i <= (m >> 1) + 1;i ++) cout << d[i] << ' '; cout << endl;
	
	for(LL i = 1;i <= n;i ++){
		r[i] ++;
		unionn(l[i],r[i]);
	}
	for(LL i = 1;i <= (m >> 1) + 1;i ++){
		if(siz[getf(i)] % 26){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

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

int A[101];

int main() {
    
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    
    int N, a, b;
    cin >> N >> a >> b;
    
    int x = 0, y = 0, z = 0;
    
    for(int i=1; i<=N; i++)
    {
        int p;
        cin >> p;
        
        if(p <= a)
            x++;
        else if(p > b)
            z++;
        else
            y++;
    }
    
    cout << min(x, min(y, z)) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int main(){
	int a,b,i,ans;
	char n[105];
	while(~scanf("%s",n))
	{
		a=strlen(n);
		ans=0;
		for(i=0;i<a/2;i++)
		{
			if(n[i]!=n[a-1-i])
			ans+=1;
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <math.h>

using namespace std;

bool isSqrt(const unsigned int num){
  for (int i=0; i<=(num/2); i++){
    if(i*i == num)
      return true;
  }
  return false;
}

int main(int argc, char const *argv[]) {
  string a, b;
  unsigned int num, sq;
  cin >> a >> b;

  num = stoi(a+b);

  if(isSqrt(num))
    cout << "Yes";
  else
    cout << "No";

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#define llong long long
using namespace std;

void read(int &x)
{
    int f=1;x=0;char s=getchar();
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    x*=f;
}

const int N = 3e5;
const int P = 998244353;
char a[N+3];
int num[8];
int n;

int decode(char x) {return x=='B'?0:(x=='R'?1:2);}

int main()
{
	scanf("%d",&n);
	scanf("%s",a+1); llong ans = 1ll;
	for(int i=1; i<=n*3; i++)
	{
		int x = decode(a[i]);
		bool found = false;
		for(int j=6; j>=0; j--)
		{
			if(!(j&(1<<x)))
			{
				if(num[j]>0)
				{
					found = true;
					ans = ans*(llong)num[j]%P;
					num[j]--; num[j|(1<<x)]++;
					break;
				}
			}
		}
		if(!found) {num[1<<x]++;}
	}
	for(int i=1; i<=n; i++) ans = ans*i%P;
	printf("%lld\n",ans);
	return 0;
}

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

using ll = long long;

int N;
string S, T;

void solve(){
    string ST = "";
    for(int i = 1; i <= N; ++i){
        ST.push_back(S[i - 1]);
        ST.push_back(T[i - 1]);
    }
    cout << ST;
}
int main(){
    cin >> N;
    cin >> S >> T;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

  int n ;
  cin>>n;
  int ans = n%10;
  if(ans ==2 || ans ==4 || ans ==5 || ans==7||ans==9)
    cout<<"hon";
  else if(ans==0||ans ==1 || ans==6||ans==8)
    cout<<"pon";
  else
    cout<<"bon";
}

Measured memory_bytes: 3636
/*

*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 3e2 + 2;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int n, m;
int a[5];
double dp[MAXN][MAXN][MAXN];
double dfs(int i, int j, int k)
{
    if (!i && !j && !k)
        return 0;
    if (dp[i][j][k] > 0)
        return dp[i][j][k];
    double temp = (1.0 * n) / (1.0 * (i + j + k));
    if (i)
        temp += ((1.0 * i) / (1.0 * (i + j + k))) * dfs(i - 1, j, k);
    if (j)
        temp += ((1.0 * j) / (1.0 * (i + j + k))) * dfs(i + 1, j - 1, k);
    if (k)
        temp += ((1.0 * k) / (1.0 * (i + j + k))) * dfs(i, j + 1, k - 1);
    return dp[i][j][k] = temp;
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        int x;
        scanf("%d", &x);
        a[x]++;
    }
    printf("%.10f\n", dfs(a[1], a[2], a[3]));
    return 0;
}

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

n = int(input())
d, x = [int(x) for x in input().split()]
count = 0
for i in range(n):
    num = int(input())
    for j in range(d):
        if num == 1:
            count += 1
        elif(j+1) % num == 1:
            count += 1
print(x + count)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0240
{
    enum RateType { Simple = 1, Compound = 2 }
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                int year = RInt();
                Dictionary<int, double> banks = new Dictionary<int, double>();
                for (int i = 0; i < n; i++)
                {
                    int[] vs = RArInt();
                    banks.Add(vs[0], CalcBasicInterest(year, vs[1], vs[2]));
                }
                Console.WriteLine(banks.OrderByDescending(x => x.Value).FirstOrDefault().Key);
            }
        }

        static double CalcBasicInterest(int year, int interestRate, int type)
        {
            switch ((RateType)type)
            {
                case RateType.Simple:
                    return 1 + year * (interestRate / (double)100);
                case RateType.Compound:
                    return Math.Pow(1 + (interestRate / (double)100), year);
                default: return 0;
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 20404
#include <cstdio>

int w, h;
int data[64][64];
int movex[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int movey[] = {-1, 0, 1, -1, 1, -1, 0, 1};

void dfs(int x, int y);

int main(void)
{	
	while (scanf("%d %d", &w, &h)){
		if (w == 0 && h == 0) break;
		
		for (int i = 0; i < 64; i++){
			for (int j = 0; j < 64; j++){
				data[i][j] = 0;
			}
		}
		
		for (int i = 1; i <= h; i++){
			for (int j = 1; j <= w; j++){
				scanf("%d", &data[i][j]);
			}
		}
		
		int res = 0;
		for (int i = 0; i < 64; i++){
			for (int j = 0; j < 64; j++){
				if (data[i][j] == 1){
					dfs(i, j);
					res++;
				}
			}
		}
		
		printf("%d\n", res);
	}
	
	return (0);
}

void dfs(int x, int y)
{
	data[x][y] = 0;
	
	for (int i = 0; i < 8; i++){
		if (data[x + movex[i]][y + movey[i]] == 1){
			dfs(x + movex[i], y + movey[i]);
		}
	}
	
	return;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>

int main(void)
{
	int l[10],v[2];char c;
	while(~std::scanf("%d%c",&l[0],&c))
	{
		int sum=0;
		for(int i=1; i<10; i++)
			std::scanf("%d%c",&l[i],&c);
		for(int i=0; i<2; i++)
			std::scanf("%d%c",&v[i],&c);
		for(int i=0; i<10; i++)
			sum += l[i];

		double meet = (double)v[0]*((double)sum/(v[0]+v[1]));
		int n;
		for(n=0, sum=0; sum < meet; n++)
			sum += l[n];
		std::cout << n << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1212
/*
選択ソート
*/
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
	"strings"
)

type ints []int

func (s ints) String() string {
	var buf bytes.Buffer
	sep := ""
	for _, v := range s {
		buf.WriteString(fmt.Sprintf("%s%d", sep, v))
		sep = " "
	}
	return buf.String()
}

func selectionSort(a ints) int {
	count := 0
	for sorted := 0; sorted < len(a)-1; sorted++ {
		// ソートしていない部分から最小値を探す
		i := sorted + 1
		mini := i
		for ; i < len(a); i++ {
			if a[i] < a[mini] {
				mini = i
			}
		}
		// 入れ替える
		if a[mini] < a[sorted] {
			v := a[sorted]
			a[sorted] = a[mini]
			a[mini] = v
			count++
		}
	}
	return count
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	eGetInt(reader)
	a := eGetInts(reader)
	count := selectionSort(a)
	fmt.Println(ints(a))
	fmt.Println(count)
}
func eGetLine(r *bufio.Reader) string {
	s, err := r.ReadString(byte('\n'))
	if err != nil {
		if err != io.EOF {
			log.Fatal(err.Error())
		}
		return s
	}
	return strings.TrimRight(s, "\r\n")
}
func eGetInt(r *bufio.Reader) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInts(r *bufio.Reader) []int {
	line := eGetLine(r)
	fields := strings.Split(line, " ")
	var ints []int
	for _, f := range fields {
		ints = append(ints, eAtoi(f))
	}
	return ints
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}



Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll M,K;
    cin >> M >> K;
    if(M == 1 && K == 1){
        print("-1");
        return 0;
    }
    ll n = (1LL<<M);
    if(M == 0 && K == 0){
        print("0 0");
        return 0;
    }
    if(M == 0 && K == 1){
        print("-1");
        return 0;
    }
    if(K >= n){
        print("-1");
        return 0;
    }
    if(M == 1 && K == 0){
        print("0 0 1 1");
        return 0;
    }
    vector<ll> ans;
    rep(i,0,n){
        if(i != K){
            // cout << i << " ";
            ans.push_back(i);
        }
    }
    ans.push_back(K);
    rrep(i,n-1,0){
        if(i != K) ans.push_back(i);
    }
    ans.push_back(K);
    rep(i,0,2*n){
        cout << ans[i] << " \n"[i == 2*n-1];
    }

    
}


Measured memory_bytes: 3952
A = int(input())
B = int(input())
C = int(input())
X = int(input())
counter = 0

for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      x = 500*a + 100*b + 50*c
      if X == x:
        counter += 1

        
print(counter)

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

int main (){
  int n,T;
  cin >> n >> T;
  int t[n];
  rep(i,n)cin >> t[i];
  int start = 0;
  int end = T;
  int ans=0;
  for(int i = 1;i<n;i++){
    if(end >= t[i]);
    else{
      ans += end - start;
      start = t[i];
    }
    end = t[i]+T;
  }
  ans += end - start;
  cout << ans << endl;
}


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

int main() {
  int N, max=0;
  cin >> N;
  string s[N];
  int cnt[N];
  
  for(int i=0; i<N; i++){
    cin >> s[i];
    cnt[i] = 0;
  }
  
  int M;
  cin >> M;
  string t[M];
  for(int i=0; i<M; i++){
    cin >> t[i];
  }
  
  for(int i=0; i<N; i++){
    string str=s[i];
    for(int j=0; j<N; j++){
      if(str == s[j]){
        cnt[i]++;
      }
    }
    for(int j=0; j<M; j++){
      if(str == t[j]){
        cnt[i]--;
      }
    }
  }
  
  for(int i=0; i<N; i++){
    if(cnt[i] > max)
      max=cnt[i];
  }
  
  cout << max << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t,a; cin >> n >> t >> a;
  int h;
  double temp;
  double m_temp = 1000000000;
  int ans = 0;
  for(int i = 0; i < n; i++){
    cin >> h;
    temp = t - h * 0.006;
    //cout << temp << endl;
    if(abs(temp - a) < abs(m_temp - a)){
      ans = i + 1;
      m_temp = temp;
    }
  }
  cout << ans;
  
}

Measured memory_bytes: 3552
#include <cstdio>
#include <cstring>
using namespace std;


int main(){

	int n,i,r;
	int pc[200][3];
	int cf[100][3];
	int ptp[200];

	memset(cf,0,sizeof(cf));

	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d%d%d",&pc[i][0],&pc[i][1],&pc[i][2]);
		cf[(pc[i][0])-1][0]++;
		cf[(pc[i][1])-1][1]++;
		cf[(pc[i][2])-1][2]++;
	}

	for(i=0;i<n;i++){
		r=0;
		if(cf[(pc[i][0])-1][0]==1)r+=pc[i][0];
		if(cf[(pc[i][1])-1][1]==1)r+=pc[i][1];
		if(cf[(pc[i][2])-1][2]==1)r+=pc[i][2];
		printf("%d\n",r);
	}



	//printf("%d\n",);
	return 0;

}

Measured memory_bytes: 1028
using System;

class Program
{
    static void Main()
    {
        while (true)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[2]);
            string str = s[1];
            if (str == "?")
                break;
            else if(str == "+")
                Console.WriteLine(a+b);
            else if(str == "-")
                Console.WriteLine(a-b);
            else if(str == "*")
                Console.WriteLine(a*b);
            else if(str == "/")
                Console.WriteLine(a/b);
        }
    }
}

Measured memory_bytes: 9100
const main = stdin => {
  const input = stdin.trim().split('\n')
  const [a, b, c] = input[0].split(' ').map(x => parseInt(x))
  if (b - a === c - b) {
    console.log('YES')
  } else {
    console.log('NO')
  }
}
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 30604
def merge(A, left, mid, right):
    cnt = 0
    n1 = mid - left
    n2 = right - mid
    L = []
    R = []
    for i in range(n1):
        L.append(A[left + i])
    for i in range(n2):
        R.append(A[mid + i])
    L.append(2000000000)
    R.append(2000000000)
    
    i = 0
    j = 0
    
    for k in range(left, right):
        
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            cnt += n1 - i
    return cnt

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = int((left + right) // 2)
        v1 = mergeSort(A, left, mid)
        v2 = mergeSort(A, mid, right)
        v3 = merge(A, left, mid, right)
        return v1 + v2 + v3
    else:
        return 0
        
        

N = int(input())
A = list(map(int, input().split())) 
cnt = mergeSort(A, 0, N)
print(cnt)
    


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n; cin >> n;
    double sum = 0;
    for(int i = 0; i < n; i++){
        double a; cin >> a;
        sum += 1 / a;
    }
    printf("%.10f\n", 1 / sum);

    return 0;
}


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

int main(){
  int s;
  cin >> s;
  int front = s/100;
  int end = s%100;
  if(front <=12 && front > 0){
    if(end <=12 && end >0)cout << "AMBIGUOUS" << endl;
    else{
      cout << "MMYY" << endl;
    }
  }
  else if(end <=12 && end >0)cout << "YYMM" << endl;
  else{
    cout << "NA" << endl;
  }
  return 0;
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);

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

    static int64_t dp[2][200000][16];
    static int64_t pow4[16] = {1};
    for(int i=1;i<=15;++i) pow4[i] = 4 * pow4[i-1];

    for(int j=0;j<=15;++j) dp[0][n-1][j] = j;
    for(int i=n-2;i>=0;--i){
        for(int j=0;j<=15;++j){
            int jj = 0;
            while( (j<=jj && a[i] > a[i+1]*pow4[jj-j]) || (j>jj && a[i]*pow4[j-jj] > a[i+1]) ) ++jj;
            if(jj <= 15) dp[0][i][j] = j + dp[0][i+1][jj];
            else dp[0][i][j] = j + dp[0][i+1][15] + (n-i-1) * (jj-15);
        }
    }
    for(int j=0;j<=15;++j) dp[1][0][j] = j;
    for(int i=1;i<n;++i){
        for(int j=0;j<=15;++j){
            int jj = 0;
            while( (j<=jj && a[i] > a[i-1]*pow4[jj-j]) || (j>jj && a[i]*pow4[j-jj] > a[i-1])) ++jj;
            if(jj <= 15) dp[1][i][j] = j + dp[1][i-1][jj];
            else dp[1][i][j] = j + dp[1][i-1][15] + i * (jj-15);
        }
    }
    int64_t ans = INT64_MAX;
    for(int x=0;x<=n;++x){
        int64_t cand = x;
        if(x > 0) cand += dp[1][x-1][0] * 2;
        if(x < n) cand += dp[0][x][0] * 2;
        ans = min(ans, cand);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 51840
import java.util.Scanner

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]) = {
    val sc = new Scanner(System.in)
    val N = sc.nextInt()
    val HPs = List.fill(N)(sc.nextInt()).sortWith((a, b) => a < b)

    @tailrec
    def updateHPs(small: Int, big: Int): Int = {
      val ret = big - small
      if (ret > 0) {
        if (ret > small) updateHPs(small, ret) else updateHPs(ret, small)
      } else small
    }
    val s = updateHPs(HPs(0), HPs(1))

    HPs.drop(2).flatMap { hp =>
      val a = hp % s
      if (a == 0) None else Some(a)
    }.sortWith((a, b) => a < b).headOption match {
      case Some(min) => println(if(s < min) s else min)
      case None => println(s)
    }
  }
}


Measured memory_bytes: 54764
a, b, c, d, e = (int(x) for x in input().split())

if a == 0 :
    ans = '1'
elif b == 0 :
    ans = '2'
elif c == 0 :
    ans = '3'
elif d == 0 :
    ans = '4'
else :
    ans = '5'

print(ans)

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

A = [0] + A + [0]
total = 0
for i in range(N + 2 -1):
    total += abs(A[i] - A[i+1])

for i in range(1, N + 2 - 1):
    t1 = abs(A[i-1] - A[i]) + abs(A[i] - A[i+1])
    t2 = abs(A[i-1] - A[i+1])
    print(total - t1 + t2)

Measured memory_bytes: 13920