akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#define int long long
#define REP(i, a, b) for (long long i = (long long)(a); i < (long long)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define mp(x,y) make_pair((x),(y))
using namespace std;


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

	int N;
	cin >> N;
	vector<int>A(N), ref(N);
	rep(i, N)cin >> A[i];
	rep(i, N)ref[i] = A[i];
	sort(ALL(ref));
	int answer = 0;
	for (int i = 0; i < N; i += 2){
		//A[i]がref配列の奇数番目の要素なら、それを交換する必要がある
		int lower_bound = 0, upper_bound = N;
		while (lower_bound + 1 < upper_bound){//[lb,ub)
			const int med = (lower_bound + upper_bound) / 2;
			if (A[i] < ref[med])upper_bound = med;
			else lower_bound = med;
		}
		if (lower_bound % 2)answer++;
	}
	cout << answer << endl;

}

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

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define iter(it,c) for(auto it=c.begin(); it!=c.end(); it++)
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

bool match(string const& a, string const& b){
    if(a.size()!=b.size()) return false;
    int n=a.size();
    rep(i,n){
        if(a[i]=='*') continue;
        if(a[i]!=b[i]) return false;
    }
    return true;
}

int main(){
    int n,m;
    while(cin>>n>>m &&  n|m){
        vs s(n);
        vi a(n);
        rep(i,n) cin >> s[i] >> a[i];
        long long int ans = 0;
        rep(i,m){
            string t; cin>>t;
            rep(i,n){
                if(match(s[i],t)){
                    ans+=a[i];
                    break;
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1204
while 1:
    n=int(raw_input())
    if n==0:
        break
    m=int(raw_input())
    x=int(raw_input())
    d=int(raw_input())
    D=range(d)
    amida=['' for i in D]
    for i in D:
        amida[i]='0'+raw_input()+'0'
    rroot=[]
    for i in range(d-1,-1,-1):
        if amida[i][x-1]=='1':
            x-=1
        elif amida[i][x]=='1':
            x+=1
        rroot.append(x)
    if m==x:
        print 0
    else:
        root=[]
        for i in D:
            if amida[i][m-1]=='1':
                m-=1
            elif amida[i][m]=='1':
                m+=1
            root.append(m)
        rroot.reverse()
        for i in D:
            if abs(root[i]-rroot[i])==1:
                p=min(root[i],rroot[i])
                if int(amida[i][p-1])+int(amida[i][p+1])==0:
                    print i+1,p
                    break
            if i==d-1:
                print 1

Measured memory_bytes: 6328
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++){
    cin >> H[i];
  }
  int C = H[0];
  bool flg = true;
  for (int i = 1; i < N; i++){
    if (H[i] < C - 1){
      flg = false;
      break;
    } else {
      C = max(H[i], C);
    }
  }
  if (flg){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

const int AMAX = 100000;
ll cnt[AMAX + 1];

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

  for (int i = 0; i < n; ++i) {
    int A, B;
    cin >> A >> B;
    cnt[A] += B;
  }

  for (int ans = 1; ans <= AMAX; ++ans){
    if (k <= cnt[ans]) {
      cout << ans << endl;
      break;
    }
    k -= cnt[ans];
  }

  return (0);
}

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

int n, m; // 変数
ll a;
double b;

int main() {
// input
    // cin >> a >> b;
    cin >> a;
    string s;
    cin >> s;
    ll b = 0;
    b += (s[0] - '0') * 100;
    b += (s[2] - '0') * 10;
    b += (s[3] - '0');
// solve
// output
    // cout << (a * (ll)(b * 100 + 0.001) / 100) << "\n";
    cout << (a * b / 100) << "\n";
}

Measured memory_bytes: 3596
import java.util.*;
class Main{
	public static void main(String arts[]){
      	Scanner sc =  new Scanner(System.in);
      	int A;
      	int B;
      	double T;
      	int c = 0;
      	A = sc.nextInt();
      	B = sc.nextInt();
      	T = sc.nextInt();
      	T = T + 0.5;
      	c = (B * (int)(T / A));
       System.out.println(c);
    }
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    ll l, r;
    cin >> l >> r;
    ll modl = l % 2019;
    ll modr = r % 2019;
    ll ldiv = l / 2019;
    ll rdiv = r / 2019;
    if (ldiv < rdiv) {
        cout << 0 << "\n";
    } else { // ldiv == rdiv
        ll mini = INF;
        for (ll i = l; i < r; ++i) {
            for (ll j = i + 1; j <= r; ++j) {
                ll mult = (i * j) % 2019;
                chmin(mini, mult);
            }
        }
        cout << mini << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
int main()
{
    long long a,b;
    while(scanf("%lld%lld",&a,&b)!=-1)
    {
        if(a+a<=b)
        printf("%lld\n",(a+a+b)/4);
        else
            printf("%lld\n",b/2);
    }
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let mut ans = 0;
    for i in 0..2 {
        if v[i] == 1 {
            ans += 300000;
        }
        if v[i] == 2 {
            ans += 200000;
        }
        if v[i] == 3 {
            ans += 100000;
        }
    }
    if v[0] == 1 && v[1] == 1 {
        ans += 400000;
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}


ll getSumDigit(ll N){
    string s=to_string(N);
    ll ret=0;
    for(int i=0;i<s.size();i++)ret+=(s[i]-'0');
    return ret;
}

int main(){
  init();
  ll N,A,B;cin>>N>>A>>B;
  ll ans=0;
  for(int i=1;i<=N;i++){
    if(A<=getSumDigit(i)&&getSumDigit(i)<=B)ans+=i;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;

ll N;
ll a[1010];
ll ans=1;
int main(){
  cin >> N;
  for(int i=2;i<=N;i++){
    ll t = i;
    for(int j=2;j<=N;j++){
      if(i<j) break;
      while(t%j == 0){
        a[j]++;
        t/=j;
      }
    }
  }
  for(int i=2;i<=N;i++){
    ans = (ans*(a[i]+1)) % MOD;
  }
  cout << ans << endl;
}



Measured memory_bytes: 896
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define int long long
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

main(void){
	scanf("%lld",&n);
	if(n%2==1){printf("0\n");return 0;}
	n=n/2;
	while(n){
		n/=5;
		cev+=n;
	}
	printf("%lld\n",cev);
	return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var in = bufio.NewScanner(os.Stdin)

func max(num []int) int {
	max := 0
	for i := 0; i < len(num); i++ {
		if max < num[i] {
			max = num[i]
		}
	}
	return max
}
func main() {
	var n int
	fmt.Scanf("%d\n", &n)

	var l []int
	in.Scan()
	temp := strings.Split(in.Text(), " ")
	for i := 0; i < n; i++ {
		li, _ := strconv.Atoi(temp[i])
		l = append(l, li)
	}

	max := max(l)

	sum := 0
	for i := 0; i < n; i++ {
		sum += l[i]
	}
	sum -= max
	if max < sum {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

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

using namespace std;
int main(){
    int n,d,a[11][11],i,j,k,count = 0,ans = 0;
    double s[50]={0},b[11][11];
    cin >> n >> d;
    for(i=0; i<n; i++){
       for(j=0; j<d; j++){
          cin >> a[i][j];
          b[i][j]=a[i][j];
        }
    }
    for(i=0; i<n-1; i++){
       for(j=i+1; j<n; j++){
          for(k=0; k<d; k++){
             s[ans]=s[ans]+(pow((b[i][k]-b[j][k]),2));
          }
          s[ans]=sqrt(s[ans]);
          if((round(s[ans])-(s[ans]))==0){
             count++;}
             ans++;
      }
    }
    cout << count << endl;
    return 0;
}


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

using namespace std;

int main(void){

  int t;
  cin >> t;
  while(t--){
    int c,a,n;
    cin >> c >> a >> n;

    int ans=0;
    int tmp=min(min(c,a),n);
    ans+=tmp;
    c-=tmp,a-=tmp;

    ans+=min(c/2,a);
    c-=min(c/2,a)*2;
    ans+=c/3;
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int r; cin >> r;

    cout << (double)2*M_PI*r << ln;
    return 0;
}

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

using namespace std;
typedef long long ll;

void call(int n){
  int i = 1;
  while(i<=n){
    int x = i;
    if ( x % 3 == 0 ){
        cout << " " << i;
    }
    else{
        while(x){
            if ( x % 10 == 3 ){
                cout << " " << i;
                break;    
            }
            x /= 10;
        }
    }
    ++i;
    }
  cout<<endl;
}

int main(){
    
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    call(n);
    return 0;
}




Measured memory_bytes: 3168
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll r,d,x;
  cin >> r >> d >> x;
  ll y[11];
  y[0]=x;
  for(int i=0;i<10;i++){
    y[i+1]=r*y[i]-d;
    cout << y[i+1] << endl;
  }

}

Measured memory_bytes: 256
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
using namespace std;

#ifndef ConanYu
// #define CPPIO
#endif
#ifdef CPPIO
#define endl '\n'
#endif

#define push_back emplace_back
template<typename T>
class List : public vector<T>
{
public:
//  new
    template<typename... U>
    List(const U &... tail) : vector<T>(0)
    {
        pb(tail...);
    }

//  push_back
    void pb() {}
    template<typename... U>
    void pb(const T & head, const U &... tail)
    {
        this->push_back(head);
        pb(tail...);
    }

//print
    void print()
    {
        const int LEN = this->size();
        for (int i = 0; i < LEN; i++)
        {
            cout << (*this)[i] << (i == LEN - 1 ? '\n' : ' ');
        }
    }
};

template<typename T>
ostream & operator << (ostream & out, const vector<T> & vec)
{
    const int n = vec.size();
    out << '[';
    for (int i = 0; i < n; i++)
    {
        out << vec[i] << (i == n - 1 ? "]" : ", ");
    }
    return out;
}

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

pll exgcd(const long long x, const long long y)
{
    if (!y)
    {
        return make_pair(1, 0);
    }
    pll cur = exgcd(y, x % y);
    return make_pair(cur.second, cur.first - (x / y) * cur.second);
}

const long long __mod__ = 998244353;

long long mod(long long x, long long p = __mod__)
{
    return ((x % p) + p) % p;
}

long long mmod()
{
    return 1LL;
}

template <typename T, typename ...U>
long long mmod(const T &head, const U &... tail)
{
    return mod(head * mmod(tail...), __mod__);
}

void print() {}
template <typename T, typename... U>
void print(const T &head, const U &... tail)
{
    cout << head << (sizeof...(tail) ? ' ' : '\n');
    print(tail...);
}

#ifdef ConanYu
#define debug(...) print(__VA_ARGS__)
#else
#define debug(...) 0
#endif

inline long long fmul(long long a, long long c, const long long& Mod = __mod__)
{
    a %= Mod, c %= Mod ;
    return (a * c - (long long)(((long double) a * c + 0.5) / Mod) * Mod) % Mod ;
}

long long gcd(long long x, long long y)
{
    return y == 0 ? x : gcd(y, x % y);
}

long long fpow(long long a, long long b, const long long & p = __mod__)
{
    ll ans = 1LL;
    for (a %= p; b; a = a * a % p, b >>= 1)
    {
        if (b & 1)
        {
            ans = ans * a % p;
        }
    }
    return ans;
}

void solve();
int main()
{
#ifdef ConanYu
    freopen("test.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // freopen("2.in", "r", stdin);
    // freopen("2.out", "w", stdout);
    clock_t st = clock();
#endif

#ifdef CPPIO
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif

    solve();

#ifdef ConanYu
    clock_t ed = clock();
    cerr << "time: " << ((ed - st) * 1.0 / CLOCKS_PER_SEC) << endl;
#endif
    return 0;
}

// *********************************************************************************************************

void solve()
{
    int n;
    cin >> n;
    if(n == 1)
    {
        print("Hello World");
    }
    else
    {
        int a, b;
        cin >> a >> b;
        cout << (a + b) << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]
c = [[ab[k][0] + ab[k][1], ab[k][0], ab[k][1]] for k in range(n)]
c.sort()
c.reverse()
taka = 0
aoki = 0
for i in range(n): # 第iターン (i=0, 1,..., n-1)
    if i%2 ==0: # 高橋くんのターン
        taka += c[i][1]
    else: # 青木くんのターン
        aoki += c[i][2]

print(taka - aoki)

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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	if (s.length() % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}
	string a, b;
	a = s.substr(0, s.length() / 2);
	b = s.substr(s.length() / 2);
	if (a == b)cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  string S;
  cin >> S;
  SORT(S);

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

  return 0;
}

Measured memory_bytes: 256
mod = 10**9 + 7
max_N = 2 * 10**5

def power(b, e):
	if e == 0: return 1

	half = power(b, e // 2)

	if e % 2 == 0:
		return (half * half) % mod
	else:
		return (((half * half) % mod) * b) % mod

def mod_inv(n):
	return power(n, mod - 2)

fac = [1] * (max_N + 1)
for i in range(1, max_N + 1):
	fac[i] = (i * fac[i - 1]) % mod

fac_inv = [1] * (max_N + 1)
fac_inv[max_N] = mod_inv(fac[max_N])
for i in range(max_N - 1, -1, -1):
	fac_inv[i] = (fac_inv[i + 1] * (i + 1)) % mod

def choose(n, k):
	return (((fac[n] * fac_inv[k]) % mod) * fac_inv[n - k]) % mod


if __name__ == "__main__":
	line = input().split(" ")
	N, K = int(line[0]), int(line[1])
	K = min(K, N - 1)

	ans = 0
	for i in range(K + 1):
		ans = (ans + (choose(N, i) * choose(N - i - 1 + i, i)) % mod) % mod

	print(ans)

Measured memory_bytes: 18804
// Add Sub Mul

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << max(max(a+b, a-b), a*b) << endl;

    return 0;
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define mod 1000000007
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

const i64 maxn = (i64)1e6 + 1000;
i64 x, y, pre[maxn];
 

i64 fac[maxn],inv[maxn];
i64 pow_mod(i64 a,i64 n)
{
    i64 ret =1;
    while(n)
    {
        if(n&1) ret=ret*a%mod;
          a=a*a%mod;
          n>>=1;
    }
    return ret;
}
void init()
{
    fac[0]=1;
    for(i64 i=1;i<maxn;i++)
    {
        fac[i]=fac[i-1]*i%mod;
    }
}
i64 Cc(i64 x, i64 y)
{
    return fac[x]*pow_mod(fac[y]*fac[x-y]%mod,mod-2)%mod;
}


int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin);
#endif
/*	
	pre[1] = 1;
	fore(i, 2, 1000000) {
		pre[i] = pre[i - 1] * i;
//		cerr << i << " " << pre[i] << endl;
		if (pre[i] > mod) pre[i] %= mod;
	}*/
	init();
	cin >> x >> y;
	if (x < y) swap(x, y);
	if (((x % 3) + (y % 3)) % 3 != 0) {
		cout << 0 << '\n';
		return 0;
	}
	i64 more = abs(x - y);
	i64 m1 = more;
	x -= 2 * more;
	y -= more;
	if (x < 0 || y < 0 || x != y) {
		cout << 0 << '\n';
		return 0;
	}
	i64 m2 = (x / 3);
	i64 n = m1 + 2 * m2;
	i64 m = m2;
	i64 ans = Cc(n, m);
	if (ans > mod) ans %= mod;
	cout << ans << endl;

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<iostream>
using namespace std;

int main()
{
	int A, B, C, D, N, M, i, j, k, l, m, n, sum, cnt, flag;
	sum = 0;
	flag = 0;
	cnt = 0;
	cin >> A >> B >> C >> D;
	if (B >= A) {
		N = A;
		A = B;
		B = N;
	}
	if (D >= C) {
		N = C;
		C = D;
		D = N;
	}

		
	cout<<B+D <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair <ll,ll>
#define vl vector <ll>
#define vp vector <pair<ll,ll>>
#define sort(x) sort(x.begin(), x.end())
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,x,y,i;
    cin>>n>>m;
    x = max(n,m);
    y = min(n,m);
    for(i=0;i<x;i++)
        cout<<y;
    return 0;
}


Measured memory_bytes: 256
import sys
N = int(input())
A_list = list(map(int,input().split()))
border = 10**18

if 0 in A_list:
  print(0)
  sys.exit()
else:
  A_list.sort(reverse=True)
  pro = 1
  for i in range(N):
    pro *= A_list[i]
    if pro > 10**18:
      print('-1')
      sys.exit()
    else:
      pass

print(pro)

Measured memory_bytes: 21592
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 2000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl

//ifstream in("Text.txt");cin.rdbuf(in.rdbuf());



int main() {

    ll N, M;
    cin >> N >> M;

    ll cou = 0;

    if (N == 1 && M == 1)cou = 1;

    else if (N == 1 && M >= 3)cou = M - 2;
    else if (N >= 3 && M == 1)cou = N - 2;

    else if (N == 2 || M == 2)cou = 0;

    else cou = (N - 2)*(M - 2);
    cout << cou << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
ll r,w,c,r1;
while(1){
	cin>>r>>w>>c>>r1;
	if(w==0)return 0;
	cout<<max(0ll,(w*c-r+r1-1)/r1)<<endl;
}
}



Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;
const int mod= 1e9 + 7;

ll kai(ll n) {
	if (n == 0)return 1;
	return n * kai(n - 1);
}

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


	map<pair<ll, ll>, ll>mp1;
	map<pair<ll, ll>, ll>mp2;
	ll N;
	cin >> N;
	FOR(i, 1, N+1) {
		ll cur = i;
		ll m = cur % 10;
		if (m == 0)continue;
		ll s = cur%10;
		while (cur > 0) { s = cur % 10; cur /= 10; }
		
		mp1[make_pair(s, m)]++;
		

	}

	ll ans = 0;
	FOR(i, 1, 10) {
		FOR(j, i, 10) {
			if (i == j)ans += mp1[make_pair(i, j)] * mp1[make_pair(i, j)];
			else {
				ans += 2 * mp1[make_pair(i, j)] * mp1[make_pair(j, i)];
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
// AOJ 2351 Closest Segment Pair
// 2018.3.17 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define INF     1e7
#define EPS     1e-5
#define RANGE	50
#define SIN     0.70710678118654752440084436210485    // Sin(45)
#define COS     0.70710678118654752440084436210485    // Cos(45)
#define SINCOS  SIN

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

typedef struct { double x1, y1, x2, y2; } S;
S seg[5105];

typedef struct { double x, y; } PP;
PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
double dot(PP a, PP b) { return a.x * b.x + a.y * b.y; }
double cross(PP a, PP b) { return a.x * b.y - a.y * b.x; }
double norm(PP a) { return a.x * a.x + a.y * a.y; }
double vabs(PP a) { return hypot(a.x, a.y); }
int ccw(PP p0, PP p1, PP p2) { PP a, b;	double t;
	a = vsub(p1, p0), b = vsub(p2, p0), t = cross(a, b);
	if (t >  EPS) return 1;	if (t < -EPS) return -1;
	if (dot(a, b) < -EPS) return 2;	if (norm(a) < norm(b)) return -2;
	return 0;
}
int is_intersectSS(PP s1s, PP s1e, PP s2s, PP s2e)
{
	return ccw(s1s, s1e, s2s) * ccw(s1s, s1e, s2e) <= 0 &&
		   ccw(s2s, s2e, s1s) * ccw(s2s, s2e, s1e) <= 0;
}
double distanceLP(PP ss, PP se, PP p) {
	return fabs(cross(vsub(se, ss), vsub(p, ss)) / vabs(vsub(se, ss))); }
double distanceSP(PP ss, PP se, PP p)
{
	if (dot(vsub(se, ss), vsub(p, ss)) < 0) return vabs(vsub(p, ss));
	if (dot(vsub(ss, se), vsub(p, se)) < 0) return vabs(vsub(p, se));
	return distanceLP(ss, se, p);
}
double distanceSS(PP s1s, PP s1e, PP s2s, PP s2e)
{
	double res, x;
	if (is_intersectSS(s1s, s1e, s2s, s2e)) return 0;
	res = distanceSP(s1s, s1e, s2s);
	x = distanceSP(s1s, s1e, s2e); if (x < res) res = x;
	x = distanceSP(s2s, s2e, s1s); if (x < res) res = x;
	x = distanceSP(s2s, s2e, s1e); if (x < res) res = x;
	return res;
}

int cmp(S *a, S *b)
{
	if (fabs(a->x1 - b->x1) < EPS) {
		if (fabs(a->y1 - b->y1) < EPS) return 0;
		if (a->y1 < b->y1) return -1; return 1;
	}
	if (a->x1 < b->x1) return -1; return 1;
}

int main()
{
	int N, i, j, lim;
	int x1, y1, x2, y2;
	double x, ans;
	PP s1s, s1e, s2s, s2e;

	N = in();
	if (N > 5100) { puts("0"); return 0; }
	for (i = 0; i < N; i++) {
		x1 = in(), y1 = in(), x2 = in(), y2 = in();
		seg[i].x1 = (x1 - y1) * SINCOS, seg[i].y1 = (x1 + y1) * SINCOS;
		seg[i].x2 = (x2 - y2) * SINCOS, seg[i].y2 = (x2 + y2) * SINCOS;
	}
	qsort(seg, N, sizeof(S), cmp);

	ans = INF;
	for (i = 0; i < N; i++) {
		s1s.x = seg[i].x1, s1s.y = seg[i].y1, s1e.x = seg[i].x2, s1e.y = seg[i].y2;
		lim = i+RANGE; if (lim > N) lim = N; 
		for (j = i+1; j < lim; j++) {
			s2s.x = seg[j].x1, s2s.y = seg[j].y1, s2e.x = seg[j].x2, s2e.y = seg[j].y2;
			x = distanceSS(s1s, s1e, s2s, s2e);
			if (x == 0) { ans = 0; goto done; }
			if (x < ans) ans = x;
		}
	}
done:
	printf("%.8lf\n", ans);
	return 0;
}


Measured memory_bytes: 2092
/*?????????????????????
N+1????????????
??????i-1??¨??????i??????????????¢ D
??????0~??????N?????§?????¶,M??\??\???????§??????????
1.??????i-1????????????i?????§?????\??????????§?????????????
2.?§????????????????,?????\?????????
M??\????????????j??\????????????????????????C
??????i-1????????????i?????§?§???????????????? C*D?????´???????????????

A.?????´??????????°????????±??????????
*/
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

unsigned long int dp[1003][1003];    //dp[??????][??\??????]
int N, M, D[1003], C[1003];//N:?????? M:??\?????? D:?????¢ C:??????

int main(){
	cin >> N >> M;
	for (int i = 0; i < M + 1; i++){
		for (int j = 0; j < N + 1; j++){
			dp[i][j] = 2147483647;//????????? 
		}
	}
	dp[0][0] = 0; // 1??\????????????0????????????
	for (int i = 0; i < N; i++){
		cin >> D[i];// ?????¢??\???
	}
	for (int i = 0; i < M; i++){
		cin >> C[i];// ??????????????\???
	}
	for (int i = 0; i < M; i++){
		for (int j = 0; j < N; j++){
			if (dp[i][j] != 2147483647){
				dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);//1??\??????
				dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + C[i] * D[j]);//1??\?????£????¬???????????§????
			}
		}
	}
	int ans = 2000000000;
	for (int i = 0; i < M + 1; i++){
		if (ans > dp[i][N]){
			ans = dp[i][N];//??????????????§??????????°????????????´?????¢??????
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	vector<int> a, b, c;
	int ans = 0;
	
	cin>>N;
	
	a.resize(N+1, 1);
	b.resize(N+1);
	c.resize(N+1);
	
	for(int i = 1; i <= N; i++){
		b[i] = i;
	}
	
	for(int i = 2; i <= N; i++){
		if(c[i] == true) continue;
		
		for(int j = i; j <= N; j += i){
			int con = 0;
			
			while(b[j] % i == 0){ //cout<<" b "<<b[j]<<endl;
				b[j] /= i;
				con++;
			}
			
			a[j] *= con + 1;
			
			c[j] = true;
		}
	}
	
	
	for(int i = 1; i <= N; i++){
		ans += i * a[i];
		// cout<<i<<" a[i] "<<a[i]<<endl;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 237608
import java.util.Arrays;

public class Main {


  private static void solve() {
    int n = ni();
    int[] a = na(n);
    
    Arrays.sort(a);
    if (a[0] + 2 <= a[n - 1]) {
      System.out.println("No");
      return;
    }
    
    int cnt = 0;
    for (;cnt < n && a[0] == a[cnt]; cnt ++) {
    }
    
    if (a[0] < a[n - 1]) {
      int color = a[n - 1];
      
      int last = color - cnt;
      if (last > 0 && last * 2 <= n - cnt) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    } else {
      if (a[0] == n - 1) {
        System.out.println("Yes");
      } else {
        
        int color = a[0];
        if (color * 2 <= n) {
          System.out.println("Yes");
        } else {
          System.out.println("No");
        }
      }
    }
    
   
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 38064
import sys
N, Y = map(int, input().split())
for x in reversed(range(N + 1)):
    for y in reversed(range(N - x + 1)):
        if x * 10000 + y * 5000 + (N - y - x) * 1000 == Y:
            if N - y - x < 0:
                continue
            print("{} {} {}".format(x, y, N - y - x))
            sys.exit()

print("{} {} {}".format(-1, -1, -1))

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

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

    while(a > 0 && c > 0)
    {
        c-=b;
        a-=d;
    }

    if(c<=0)
        printf("Yes\n");
    else
        printf("No");

    return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int N = intRead();
        int[] X = SpRead(' ').Select(a => int.Parse(a)).ToArray();
        int[] sX = X.OrderBy(a => a).ToArray();
        int[] B = new int[N];
        for (int i = 0; i < N; i++)
        {
            if (X[i] <= sX[N / 2 - 1]) B[i] = sX[N / 2];
            else if (sX[N / 2] <= X[i]) B[i] = sX[N / 2 - 1];
        }
        foreach (int i in B) Console.WriteLine(i);
    }

}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
}


Measured memory_bytes: 43000
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>
//#include <atcoder/all>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;
//using namespace atcoder;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;
template<typename T>
struct Edge {
    int u, v;
    T cost;
    Edge(int u, int v, T c) : u(u), v(v), cost(c) {}
    bool operator< (const Edge &e) const {return cost < e.cost;}
};

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans;

int main(void) {
    int k;
    cin >> k;
    string s;
    rep(i, 0, k) s += "ACL";

    
    cout << s << endl;
    return 0;
}





Measured memory_bytes: 3572
n=int(input())
*a,=map(int,input().split())
*b,=map(int,input().split())


ans=0
for i in range(n):
    if a[i]<b[i]:
        b[i]-=a[i]
        ans+=a[i]
        if a[i+1]>b[i]:
            a[i+1]-=b[i]
            ans+=b[i]
        else:
            ans+=a[i+1]
            a[i+1]=0
    else:
        ans+=b[i]
    #print(a)
    #print(b)
print(ans)

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(), h.end());
  k = min(n,k);
  ll ans = 0;
  rep(i,k) {
    h.pop_back();
  }
  rep(i,h.size()) ans += h[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define NUM 1000000007
#define MAX 100001
#define INF LLONG_MAX
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x1 = a;
    ll x2 = b;
    ll y1 = c;
    ll y2 = d;
    ll max1 = x1*y1;
    ll max2 = x1*y2;
    ll max3 = x2*y1;
    ll max4 = x2*y2;
    cout<<max(max1,max(max2,max(max3,max4)))<<endl;
    return 0;
}


Measured memory_bytes: 3664
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let n: usize;
    input!(n);
    let s = input_line_str().to_charvec();
    let mut count = 0;
    for i in 0..s.len() - 2 {
        if s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C' {
            count += 1;
        }
    }
    p(count);
}


Measured memory_bytes: 4352
int main(void) {
int n,count=0;
scanf("%d",&n);
long int a[n];
for(int i=0;i<n;i++)
scanf("%ld",&a[i]);
for(int i=0;i<n-2;i++)
{
  for(int j=i+1;j<n-1;j++)
  {
    for(int k=j+1;k<n;k++)
    {
      if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k] )
     { if( a[i]+a[j]>a[k] && a[j]+a[k]>a[i] && a[i]+a[k]>a[j])
     count++;}
    }
  }
}
printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1720
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;


int main() {
 ll X,Y;
  in(X>>Y);
 ll k=Y/X;
  ll ans =0;
    ll s = 1;
  while(k>=s){
   ans++;
    s *= 2;
  }
  out(ans);
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#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()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

PLL rot(PLL x){
	PLL ret;
	ret.fs = x.fs*0+x.sc*(-1);
	ret.sc = x.fs*1+x.sc*0;
	return ret;
}

int main(void){
	int32 N;
	while(cin >> N && N){
		int32 m;
		cin >> m;
		vector<PLL> base(m), b1(m), b2(m);
		REP(i, m) cin >> base[i].fs >> base[i].sc;
		for(int32 i = m-1;i >= 0;i--){
			b1[i].fs = base[i].fs-base[0].fs; b1[i].sc = base[i].sc-base[0].sc;
			b2[i].fs = base[m-i-1].fs-base[m-1].fs; b2[i].sc = base[m-i-1].sc-base[m-1].sc;
		}
		REP(i, N){
			cin >> m;
			vector<PLL> a(m);
			REP(j, m) cin >> a[j].fs >> a[j].sc;
			if(m != base.size()) continue;
			for(int32 j = m-1;j >= 0;j--){ a[j].fs -= a[0].fs; a[j].sc -= a[0].sc; }
			REP(k, 4){
				bool ok = 1, ok2 = 1;
				REP(j, m) a[j] = rot(a[j]);
				REP(j, m){
					ok = ok&(a[j] == b1[j]);
					ok2 = ok2&(a[j] == b2[j]);
				}
				if(ok || ok2){
					cout << i+1 << endl;
					break;
				}
			}
		}
		cout << "+++++" << endl;
	}
}


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

cin>>H>>W;
vector<string> vec(H);
for(int h=0;h<H;h++)
 {
   cin>>vec.at(h);
 }
 for(int l=0;l<W+2;l++)
 {cout<<"#";
 if(l==W+1)cout<<endl;
 }
for(int j=0;j<H;j++)
 {
   cout<<"#"<<vec.at(j)<<"#"<<endl;
 }
 for(int m=0;m<W+2;m++)
 {cout<<"#";
 if(m==W+1)cout<<endl;
 }
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[87];
int main()
{
    cin>>n;
    a[0]=2;
    a[1]=1;
    for(int i=2;i<=n;i++)
        a[i]=a[i-1]+a[i-2];
    cout<<a[n];
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

long long gcd(long long N, long long M){
    while (true){
        if (min(N,M)==0){
            return max(N,M);
        }else if (N>M){
            N%=M;
        }else{
            M%=N;
        }
    }
}

int main(){
    int K;
    cin >> K;
    ll sum_=0;
    for(ll i=1; i<=K; i++){
        for(ll j=1; j<=K; j++){
            for(ll k=1; k<=K; k++){
                sum_+=gcd(gcd(i,j),k);
            }
        }
    }
    cout << sum_ << endl;
}

Measured memory_bytes: 3632
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;

int main() {
    ll N, M, P; cin >> N >> M >> P;
    vector< vector< pair<ll, ll> > > G(N);
    vector<ll> dist(N, INF);
    for(int i=0; i<M; i++) {
        ll a, b, c; cin >> a >> b >> c;
        a--; b--;
        G[a].emplace_back(b, P - c);
    }

    dist[0] = 0;

    ll rec1, rec2;
    for(int i=0; i<2*N; i++) {
        for(int j=0; j<N; j++) {
            for(auto e : G[j]) {
                ll k, c; tie(k, c) = e;
                if(dist[j] != INF and dist[k] > dist[j] + c) {
                    dist[k] = dist[j] + c;
                }
            }
        }
        if(i == N - 1) rec1 = dist[N-1];
        if(i == 2*N - 1) rec2 = dist[N-1];
    }

    if(rec1 != rec2) cout << -1 << endl;
    else cout << max(0LL, -rec1) << endl;
    return 0;
}


Measured memory_bytes: 512