akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#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 repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

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<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<Pii> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<Pii> res(1, Pii(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0) x /= p, ++y;
      if (y != 0) res.emplace_back(p,y);
    }
    if (x != 1) res.emplace_back(x,1);
    return res;
  }
};



void Main(){
	int N;
	ll ans=0;
	cin >> N;

	Sieve s(N);
	FOR(i, 1, N){
		ll sum=1;
		vector<Pii> res = s.factor(i);
		rep(j, res.size()){
			sum *= res[j].se + 1;
		}
		ans += sum * i;
	}


 cout << ans << endl;



}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


Measured memory_bytes: 46488
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;

const ll mod = 1000000007;
const int N = 1e2+6;
const int M = 2e6+6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
int n;
int nt[N];
struct Point {
    ll x, y;
    bool operator < (const Point c) const {
        return atan2(y, x) < atan2(c.y, c.x);
    }
}p[N];
int main() {
    /*
        两个向量之间的角度越小，那么两个向量相加的向量的长度最长
        所以我们按照极脚排序，答案一定是一个连续的子区间
        为什么呢？
        假设你排完序了
        假设1 3是最大的
        那么显然1 2 3结果更大
    */
    scanf("%d", &n);
    rep(i, 1, n + 1) scanf("%lld%lld",&p[i].x,&p[i].y), nt[i] = i + 1;
    nt[n] = 1;
    sort(p + 1, p + n + 1);
    ll ans = 0;
    rep(i, 1, n + 1) {
        ll x = p[i].x, y = p[i].y;
        ans = max(ans, x * x + y * y);
        for(int j = nt[i]; j != i; j = nt[j]) {
            x += p[j].x; y += p[j].y;
            ans = max(ans, x * x + y * y);
        }
    }
    printf("%.12f\n", sqrt(ans));
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, K;
    string S;
    cin >> N >> S >> K;
    char c = S[K - 1];
    REP(i, N) {
        if (S[i] == c) cout << c;
        else cout << "*";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define int long long
#define MOD (long long)(1e9+7)
#define MAX_VAL (long long)(1e6+10)

long long fac[MAX_VAL], mmi[MAX_VAL], temp[MAX_VAL];

void factorial(){
	fac[0] = fac[1] = 1;
	for(long long i = 2; i < MAX_VAL; fac[i]%=MOD,i++)
		fac[i] = fac[i-1]*(i%MOD);
}


long long power_mod(long long x, long long n){
	long long ans = 1;
	for(;n;n>>=1,x*=x,ans%=MOD,x%=MOD)
		if(n&1)ans*=x;
	return ans%MOD;
}

void modular_multiplicatibe_inverse(){
	mmi[MAX_VAL-1] = power_mod(fac[MAX_VAL-1],MOD-2);
	for(long long i = MAX_VAL-2; i >= 0; mmi[i]%=MOD,i--)
		mmi[i] = mmi[i+1]*((i+1)%MOD);

}

long long combination(long long n, long long r){
	return fac[n]*(mmi[r]*mmi[n-r]%MOD)%MOD;
}

signed main(){
	int H, W, A, B, ans = 0;
	cin>>H>>W>>A>>B;
	
	factorial();
	modular_multiplicatibe_inverse();

	for(int i = B+1; i <= W; ans%=MOD,i++)
		ans += combination(i+H-A-2,H-A-1)*combination(A+W-i-1,W-i)%MOD;
	
	cout<<ans<<endl;

}

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

using namespace std;

const int N = 105;
int n, m;
int a[N][N];
int f[N][N], cl[N][N];
int dx[2] = {-1, 0}, dy[2] = {0, -1};
queue<pair<int, int>> q;

int dfs(int x, int y, int id) {
    int res = 1e9;
    q.push(make_pair(x, y));
    cl[x][y] = id;
    while (!q.empty()) {
        x = q.front().first;
        y = q.front().second;
        q.pop();
        for (int i = 0; i < 2; i++) {
            int u = x + dx[i], v = y + dy[i];
            if (u > 0 && v > 0 && a[u][v] == a[x][y] && cl[u][v] != id) {
                cl[u][v] = id;
                q.push(make_pair(u, v));
            }
            if (u == 0  || v == 0 || a[u][v] != a[x][y]) {
                res = min(res, f[u][v]);
            }
        }

    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
               char ch;
            cin >> ch;
            a[i][j] = (ch == '#' ? 1 : 0);
        }
    }
    for (int i = 2; i <= max(n,m); i++) {
        f[i][0] = 1e9;
        f[0][i] = 1e9;
    }
    f[1][0] = f[0][1] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            f[i][j] = dfs(i, j, (i - 1) * m + j) + a[i][j];
        }
    }
    cout << f[n][m];
    return 0;
}


Measured memory_bytes: 384
use std::io::{self, BufRead};
use std::collections::HashMap;

fn attack(memo: &mut HashMap<i64, i64>, h: i64) -> i64 {
  if h == 1 {
    1
  } else if memo.contains_key(&h) {
    memo[&h]
  } else {
    let x = h / 2;
    1 + 2 * attack(memo, x)
  }
}

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let line = lines.next().unwrap().unwrap();
  let h: i64 = line.parse().unwrap();
  let mut memo = HashMap::new();
  let count = attack(&mut memo, h);
  println!("{}", count);
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {

	string st; cin >> st;
	vector<int>nums(st.size());
	for (int i = 0; i < st.size(); ++i) {
		nums[i] = st[i] - 'a';
	}
	int N; cin >> N;
	int rest(N);
	for (int i = 0; i < st.size(); ++i) {
		int num;
		if (nums[i] == 0)continue;
		if (rest >= 26 - nums[i]) {
			num = 26 - nums[i];
		}
		else {
			num = 0;
		}
		rest -= num;
		nums[i] += num;
		nums[i] %= 26;
		assert(rest >= 0);
	}
	assert(rest >= 0);
	nums[st.size() - 1] += rest;
	nums[st.size() - 1] %= 26;
	for (int i = 0; i < st.size(); ++i) {
		char c('a' + nums[i]);
		cout << c;
	}
	cout << endl;


	//int R, C; cin >> R >> C;

	return 0;
}

Measured memory_bytes: 896
X, N = map(int, input().split())
p = list(map(int, input().split()))
k = 0
ans = 0
c = True

while c:
    if (X - k) not in p:
        ans = X -  k
        c = False
        break
    elif (X + k) not in p:
        ans = X + k
        c = False
        break
    else:
        k += 1
        
print(ans)

Measured memory_bytes: 9192
package main

import "fmt"

var mod int = 1000000007
var memo []int

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	memo = make([]int, N+1)
	for i := 0; i <= N; i++ {
		memo[i] = -1
	}
	for i := 0; i < M; i++ {
		var t int
		fmt.Scan(&t)
		memo[t] = 0
	}

	memo[0] = 1
	fmt.Println(dfs(N))
}

func dfs(n int) int {
	if n < 0 {
		return 0
	}
	if memo[n] != -1 {
		return memo[n]
	}

	memo[n] = (dfs(n-1) + dfs(n-2)) % mod
	return memo[n]
}


Measured memory_bytes: 10496
using System;
public class Eratosthenes
{
	public static void Main(string[] args)
	{
		int count = int.Parse(Console.ReadLine());
		int sum = 0;//?´???°???????¨?
		
		for (int i = 0; i < count; i++)
		{
			//?????????????±????????????????
			int target = int.Parse(Console.ReadLine());
			//????????????
			//target???3??\????????£???????????§??????????????????if?????????????????\????????????
			if(target==2||target==3)
			{
				sum++;
			}
			if ((target > 3) && ((target % 2) != 0)) 
			{
				
				int j = 3;
				do{				
					if (target % j == 0)
					{//?´???°??§?????????
						break;
					}
					
					
					j+=2;
				}while(j<=target/j);
				if (j  > target / j)
					{
						//break?????????????????´????????????????????\???
						sum ++;
						
					}
				
			}
			
		}
		
		Console.WriteLine(sum);
	}
}

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

int main(){
  string S;
  int N,K;
  cin >> N >> S >> K;
  for (int i = 0; i<N;i++){
   if(S.at(i) != S.at(K-1)){
   S.at(i) = '*';
   }
  }
  cout << S << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;
int main(void){
  int n,q;
  cin >> n;

  ll array[100010];
  ll total = 0;
  rep(i,100010) array[i] = 0;

  rep(i,n){
    int a;
    cin >> a;
    array[a]++;
    total += a;
  }

  cin >> q;
  rep(i,q){
    int b,c;
    cin >> b >> c;
    array[c] += array[b];
    total += array[b]*(c-b);
    array[b] = 0;

    cout << total << endl;
  }

}


Measured memory_bytes: 4416
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;
#define int ll
using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<int, int> pii;
typedef long double ld;
typedef pair<ld, ld> pld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
#define rep(x, y, a) for (int x = (y); x < (int)(a); ++x)
#define asd(n) rep(i, 0, n)
#define jkl(n) rep(j, 0, n)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

namespace IO {

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a);

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a);

    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
        return out;
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;


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

void solve() {
    int n, k;
    cin >> n >> k;
    vpii a(k);
    cin >> a;
    vi dp(n), pref(n + 1);
    int cur = 0;
    const int M = 998244353;
    dp[0] = 1;
    pref[1] = 1;
    rep(i, 1, n) {
        jkl(k) dp[i] = ((dp[i] + pref[max(0ll, i - a[j].first + 1)] - pref[max(0ll, i - a[j].second)]) % M + M) % M;
        pref[i + 1] = (pref[i] + dp[i]) % M;
    }
    put(dp.back());
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
    int q = 1;
//    cin >> q;

    while (q--) solve();
}


Measured memory_bytes: 5952
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: i32,
        m: usize,
        v: [i32;m],
    }

    let mut ret = n;
    for i in v{
        ret = ret - i;
    }

    if ret < 0{
        println!("-1");
    } else {
        println!("{}", ret);
    }

}

Measured memory_bytes: 2132
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int count = 0;
    for (int i = 1; i <= a; i++) {
      for (int j = 1; j <= 12; j++) {
        if (i == a && j > b) break;
        if (i == j) count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 21716
use whiteread::parse_line;

fn main() {
    let (n, k): (usize, usize) = parse_line().unwrap();
    let mut h: Vec<usize> = Vec::new();
    let mut diff = std::usize::MAX;

    for _ in 0..n {
        h.push(parse_line().unwrap());
    }
    h.sort();

    for i in 0..=(n - k) {
        diff = diff.min(h[i + k - 1] - h[i]);
    }
    println!("{}", diff);
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main() {
    int n; cin >> n;
    vector<double> v(n);
    rep(i, n) cin >> v[i];

    sort(all(v));
    reverse(all(v));

    for (int i=0;i<n;++i) {
        if (i == n-1) rep(j, i) v[i] /= 2;
        else rep(j, i+1) v[i] /= 2;
    }

    double ans = 0.0;
    rep(i, n) ans += v[i];

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define MAX 2000200
#define MIN -2000000300
typedef long ll;
  
int pindex;
ll Array[MAX];
  
int getParent(int i){
  return i/2;
}
  
int getLeft(int i){
  return 2*i;
}
  
int getRight(int i){
    return 2*i+1;
}
  
  
int heapIncreaseKey(int i,ll key){
  ll h;
  if(key < Array[i])return -1;
  Array[i] = key;
  while(i > 1 && Array[getParent(i)] < Array[i]){
    h = Array[i];
    Array[i] = Array[getParent(i)];
    Array[getParent(i)] = h;
    i = getParent(i);
  }
}
  
void maxHeapify(int i){
  ll l = getLeft(i);
  ll r = getRight(i);
  ll largest;
  ll h;
  if(l <= pindex && Array[l] > Array[i])largest=l;
  else largest=i;
  if(r<=pindex && Array[r] > Array[largest])largest = r;
  if(largest != i){
    h = Array[i];
    Array[i] = Array[largest];
    Array[largest] = h;
    maxHeapify(largest);
  } 
}
  
  
void Insert(ll key){ //maxHeapInsert
  ++pindex;
  Array[pindex] = MIN;
  heapIncreaseKey(pindex,key);
}
  
ll heapExtractMax(){
  ll max;
  if(pindex < 1)return -1;
  max = Array[1];
  Array[1] = Array[pindex];
  pindex--;
  maxHeapify(1);
  return max;
}
  
  
  
  
int main(){
  char op[1000];
  ll val;
  
  while(1){
    scanf("%s",op);
    if(strcmp(op,"insert") == 0){
      scanf("%ld",&val);
      Insert(val);
    }
    else if(strcmp(op,"extract") == 0){
      printf("%ld\n",heapExtractMax());
    }
    else if(strcmp(op,"end") == 0)break;
  }
  
  return 0;
}


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

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define D(x) cerr << #x << " is " << (x) << "\n";

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}

int main()
{
	int n;
	scanf("%i",&n);
	multiset<int> a;
	int pos=0,neg=0;
	for(int i=0;i<n;i++){
        int b;
        scanf("%i",&b);
        if(b>0)
            pos++;
        a.insert(b);
	}
	vector<pair<int,int> > operations;
	while(a.size()>1)
    {
        int f=(*a.begin());
        auto it=a.end();
        it--;
        int s=(*it);
        a.erase(a.begin());
        a.erase(it);
        if(f>0)
            pos--;
        if(s>0)
            pos--;
        if(pos>0)
            swap(s,f);
        if(s-f>0)
            pos++;
        a.insert(s-f);
        operations.pb({s,f});
    }
    printf("%i\n",(*a.begin()));
    for(auto p:operations)
        printf("%i %i\n",p.f,p.s);
    return 0;
}


Measured memory_bytes: 7412
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int l,r,s;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>l>>r;
        s+=r-l+1;
    }
    cout<<s<<endl;
    return 0;
}

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


//SHORTCUTS

#define ll long long
#define endl '\n'
#define i1(a) cin>>a
#define i2(a,b) cin>>a>>b
#define i3(a,b,c) cin>>a>>b>>c
#define o1(a) cout<<a<<endl
#define o2(a,b) cout<<a<<" "<<b<<endl
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define f(i,a,b) for(int i = a;i<b;i++)
#define fe(i,a,b) for(int i = a;i<=b;i++)
#define fi(i,a,b) for(i=a;i<b;i++)
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair


// DEBUG CODE & FAST OUTPUT

#define printv(a) for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
#define printvl(a) for (int i = 0; i < a.size(); i++) cout << a[i] << endl;
#define printa(a, n) for (int i = 0; i< n; i++) cout << a[i] << ' ';
#define printal(a, n) for (int i = 0; i < n; i++) cout << a[i] << endl;


//DATA STRUCTURES

#define pq priority_queue
#define ms multiset
// #define y0 _y0_
// #define y1 _y1_
// #define div divi

typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;


//IMP CONSTANT
const int mod = 1e9 + 7, inf = 1e9 + 7;
const ll infll = 1e18 + 7;
bool google_contest = false;

//MODULAR OPERATIONS
ll myadd(ll a,ll b){
    ll ans = a+b;
    ans-= ans>=mod ? mod : 0;
    return ans; 
}
ll mysub(ll a, ll b){
    return (a-b+mod)%mod;
}
ll mymul(ll a,ll b){
    return (a*b)%mod;
}
ll mypow(ll a, ll b){
    ll ans = 1;
    while(b>0)
        if(b&1) ans = mymul(ans,a),b--;
        else a = mymul(a,a),b >>= 1;
    return ans;
}
ll nCr(ll n,ll r){
    if(r==0)return 1;
    if(r==1)return n;
    if(n==0)return 0;
    return mymul(n,mymul(nCr(n-1,r-1),mypow(r,mod-2)));
}




const int dx[4] = {1, -1, 0,  0};
const int dy[4] = {0, 0,  1, -1};
//    /\    |  |\  /|                      
//   /__\   |  | \/ |           
//  /    \  |  |    | 



int main(){

ios_base::sync_with_stdio(0);
cin.tie(0); 
cout.tie(0);

int t,tt;
t=1;
// i1(t);
if(google_contest)tt=1;

while(t--){
ll a,b,v,w;

i2(a,v);
i2(b,w);

ll time;
i1(time);

ll s = v-w; 
if(s<=0){
    o1("NO");
    return 0;
}
if(a>b)swap(a,b);
ll ttt = (b-a)/s;
if((b-a)%s!=0)ttt++;
if(ttt>time){
    o1("NO");
}else{
    o1("YES");
}

if(google_contest){
    cout<<"Case "<<tt++<<": ";
}
}

return 0;   
}


//    /\    |  |\  /|                      
//   /__\   |  | \/ |           
//  /    \  |  |    |   OVER!!!!


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define REP(i,a,b) for(int i = a; i <= b; i++)
#define REPN(i,a,b) for(int i = a; i >= b; i--)
typedef long long ll;

using namespace std;

int main() {
	// #ifndef ONLINE_JUDGE
	//     freopen("input.txt", "r", stdin);
	//     freopen("output.txt", "w", stdout);
	// #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;
    int d = n%10;
    if(d==2||d==4||d==5||d==7||d==9) {
    	cout<<"hon"<<"\n";
    }
    else if (d==3) {
    	cout<<"bon\n";
    }
    else cout<<"pon\n";
	return 0;
}

Measured memory_bytes: 3612
n = int(input())
c = list(input())

counter = 0
k = 0

i = 0
j = n-1

while i < j and i < n and 0 <= j:
	if c[i] == 'W' and c[j] == 'R':
		counter += 1
		i += 1
		j -= 1
	elif c[i] == 'W' and c[j] == 'W':
		j -= 1
	elif c[i] == 'R' and c[j] == 'R':
		i += 1
	else:
		i += 1
		j -= 1 
print(counter)

Measured memory_bytes: 10780
A = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

n = int(input())
for i in range(n):
    b,f,r,v = map(int,input().split())
    A[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        for r in range(10):
            print('',A[b][f][r],end='')
        print()
    if b != 3:
        print('#'*20)

Measured memory_bytes: 5636
#include<bits/stdc++.h>
    template < typename T > std::string to_string( const T& n )
    {
        std::ostringstream stm ;
        stm << n ;
        return stm.str() ;
    }
using namespace std;

int main(void){
    int N;
    cin >> N;
    int digit = to_string(N).length();
    int ans = 0;

    if(digit % 2 == 1){
        ans += N - pow(10, digit - 1) + 1;
        digit--;
        //cerr << ans << endl;
    }
    
    while(digit >= 1){
        if(digit % 2 == 0){
            ans += pow(10, digit-1) - pow(10, digit-2);
        }
        //cerr << digit << pow(10, digit-2) << endl;
        digit-=2;
    }

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

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


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

    ll n;cin>>n;
    vll a(n-1); REP(i,n-1) cin>>a[i];
    map<ll,ll>  mp;
    REP(i,n-1){
        // cout <<a[i]<<endl;
        mp[a[i]]++;
        // cout<<mp[1]<<endl;;
    }
    
    REP(i,n){
        if (mp[i+1]) cout<<mp[i+1]<<endl;
        else cout<<0<<endl;
    }
    return 0;
}

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

int main(){
  int N, Y;
  cin >> N >> Y;
  int milx=Y/1000;
  int tenx=Y/10000;
  int a=-1;
  int b=-1;
  int c=-1;
  for(int i=0; i<=tenx; i++){
    for(int j=0; j<=milx; j++){
      if(10000*i+1000*j+5000*(N-i-j)==Y && N-i-j>=0){
        a=i;
        b=N-i-j;
        c=j;
      }
    }
  }
  cout << a << ' ' << b << ' ' << c << endl;
}

Measured memory_bytes: 256
from fractions import gcd
from functools import reduce
MOD = 10**9+7
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)  

n = int(input())
aa = list(map(int,input().split()))
           
l = lcm(*aa)        
ans = 0
for ai in aa:
  ans += l//ai

print(ans % MOD)

Measured memory_bytes: 6136
#include<iostream>
#include<string>
#include<cstdlib>

#define N 100000
using namespace std;


typedef struct{
  int num[N];
  int head;
  int tail;
}Queque;


//grobal
Queque que;

  //add to head position
void push(int);
  //delete head position
void pop(void);
  //return now of stck
int front(void);


int main(){
  //format
  que.head=0;
  que.tail=0;
  int pasttime=0;

  int i,n,q,tim=0;
  int j=0;
  int time[N];
  string name[N];
  int finishcount=0;
  int flag[N];
  int st;

  //load n and q
  cin >>n>>q;

  //load name and time
  for(i=0;i<n;i++){
    cin >>name[i]>>tim;
    push(tim);
  }

  //format flag
  for(i=0;i<n;i++){
    flag[i]=0;
  }
  
  i=0;
  while(1){
    if(finishcount==n) break;
    else if(i==n){
      i=0;
      continue;
      }
      else if(flag[i]==1){
      i++;
      continue;
    }

    st=front();

    if(st>q){
      push(st-q);
      pop();
      pasttime+=q;
    }
    else{
      pop();
      pasttime+=st;
      flag[i]=1;
      finishcount++;
      cout <<name[i]<<" "<<pasttime<<endl;
    } 
    
    i++;
  }
    
  
  return 0;
  
}

  //add to head position
  void push(int x){
    que.num[que.tail]=x;
    que.tail++; 
 }
  //delete head position
  void pop(void){
    que.head++;
  }
  //return now of stck
  int front(void){
    return que.num[que.head];
  }

Measured memory_bytes: 0
# coding: utf-8
# Your code here!
W=input()
c=0

while True:
    t=input()
    
    if t=="END_OF_TEXT":
        break
    else:
        T=t.lower()
        T=T.split()
        
        for i in range(len(T)):
            if T[i]==W:
                c+=1
print(c)


Measured memory_bytes: 5560
#include<stdio.h>

int main(void){
	int a,b,c,n,x;
	int s,sum;
	
	while(1){
		scanf("%d %d",&n,&x);
		sum = 0;
		if(n==0 && x==0){
			break;
		}
		for(a=1;a<=n;a++){
			for(b=1;b<=n;b++){
				for(c=1;c<=n;c++){
					if(c == b||b == a|| a == c){
					}else{
						s = a + b + c;
						if( s == x){
							sum += 1;
						}
					}
				}
			}
		}
		
		printf("%d\n",sum/6);
		
	}
	return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <math.h>

#define timemax 1260+1
using namespace std;

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);
	
	//imos法を用いる
	
	while(1) {
		int N, M, r, q;
		int v_log[] = {-1,1};
		vector<vector<int>> logchk;

		
		cin >> N >> M;
		if( N == 0 && M == 0 ) break;

		//ログイン情報取得部分
		for(int i = 0; i < M + 1; i++) {
			vector<int> newchk;
			for(int j = 0; j < timemax; j++)
				newchk.push_back(0);
			logchk.push_back(newchk);
		}


		cin >> r;

		for(int i = 0; i < r; i++) {
			int t, n, m, s;
			cin >> t >> n >> m >> s;
			logchk.at( m ).at( t ) += v_log[s];
		}

		for(int i = 0; i < M + 1; i++) 
			for(int j = 1; j < timemax; j++)
				logchk.at(i).at(j) += logchk.at(i).at( j - 1 );



		//質問処理部分
		cin >> q;
		for(int i = 0; i < q; i++) {
			int t_s, t_e, m, ans = 0;
			cin >> t_s >> t_e >> m;
			for(int j = t_s; j < t_e; j++) {
				if( logchk.at(m).at(j) ) ans ++;
			}
			cout << ans << endl;
		}
	}

	
	//while(1){}
	return 0;
}

Measured memory_bytes: 49120
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

using namespace std;
using pii=pair<int,int>;
using ll=long long;

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    
    int n;
    string s;
    cin>>n>>s;
    vector<int> v(n);
    for(int i=0; i<n; i++){
        if(s[i]=='R') v[i]=0;
        else if(s[i]=='G') v[i]=1;
        else v[i]=2;
    }
    vector<vector<int>> sum(n,vector<int>(3));
    sum[0][v[0]]=1;
    for(int i=1; i<n; i++){
        for(int j=0; j<3; j++) sum[i][j]=sum[i-1][j];
        sum[i][v[i]]+=1;
    }
    ll answer=0;
    for(int i=1; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(v[i]!=v[j]){
                int c=0;
                for(c=0; c<3; c++) if(c!=v[i] && c!=v[j]) break;
                ll now=sum[i-1][c];
                if(i-(j-i)>=0 && v[i-(j-i)]==c) now-=1;
                answer+=now;
            }
        }
    }
    cout<<answer;

    return 0;
}


Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int calc(int a,int b){
  if(a<=b) return b-a;
  return 1001001001;
}

int main(){
  
  ll a,b;
  cin >> a >> b;
  int ans = 1001001001;
  ans = min(ans,calc(a,b));
  ans = min(ans,calc(-a,b)+1);
  ans = min(ans,calc(a,-b)+1);
  ans = min(ans,calc(-a,-b)+2);
  cout << ans << endl;
  
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n, v) rep(i, n) cin >> v[i]

using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1, 0, -1, 0}, y_pos[4] = {0, 1, 0, -1};
int ctoi(char c)
{
	if (c >= '0' && c <= '9')
	{
		return c - '0';
	}
	return 0;
}

char upper(char c)
{
	return c - 0x20;
}

char lower(char c)
{
	return c + 0x20;
}

void unique_vector(vector<int> &v)
{
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	std::fill((T *)array, (T *)(array + N), val);
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y)
{
	if (y == 0)
		return x;
	return gcd(y, x % y);
}

//最小公倍数
ll lcm(ll x, ll y)
{
	ll g = gcd(x, y);
	return x / g * y;
}

ll myPow(ll x, ll n, ll m)
{
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

//k!
ll facctorialMethod(ll k)
{
	ll sum = 1;
	for (ll i = 1; i <= k; ++i)
	{
		sum *= i;
		sum %= MOD;
	}
	return sum;
}

//nCr
ll permutationMethod(ll n, ll r)
{
	ll n_sum, r_sum;
	r = n - r;
	n_sum = facctorialMethod(n);
	r_sum = facctorialMethod(r);
	return n_sum / r_sum;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll pow_kai(int a, int n)
{ //aのn乗を計算します。
	ll x = 1;
	while (n > 0)
	{ //全てのbitが捨てられるまで。
		if (n & 1)
		{ //1番右のbitが1のとき。
			x = (x * a) % MOD;
		}
		a = (a * a) % MOD;
		n >>= 1; //bit全体を右に1つシフトして一番右を捨てる。
	}
	return x % MOD;
}

int main()
{
	string s;
	cin >> s;
	ll ans = 0;
	for (int i = 0; i < (1 << (s.length() - 1)); i++)
	{
		int before = 0;
		for (int k = 0; k < s.length() - 1; k++)
		{
			if(i & (1<<k)){
				int length = k - before + 1;
				string ns = s.substr(before, length);
				before = k+1;
				ans += stoll(ns);
			}
		}
		ans += stoll(s.substr(before, s.length() - before));
		
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
def int_multiple():
    return  [int(c) for c in input().split()]

def int_single():
    return int(input())

def str_multiple():
    return [c for c in input().split()]

def str_single():
    return input()

# start
a, b = int_multiple()

print(max(a+b, a-b, a*b))


Measured memory_bytes: 2940
import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

tmp = seachPrimeNum(100021)
n = int(input())
for i in tmp:
    if n <= i:
        print(i)
        break


Measured memory_bytes: 16628
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    ll n, x;
    cin >> n >> x;

    ll b[n], l[n], u[n];
    ll sm = 0;
    for (int i = 0; i < n; i++) {
        cin >> b[i] >> l[i] >> u[i];
        sm += b[i] * l[i];
    }

    vector <ll> benefit(n);
    for (int i = 0; i < n; i++) benefit[i] = b[i] * l[i] + (x - b[i]) * u[i];

    sort(benefit.begin(), benefit.end(), greater<ll>());

    vector <ll> sum(n+1, 0);
    for (int i = 0; i < n; i++) {
        sum[i+1] = sum[i] + benefit[i];
    }

    ll mn = -1, mx = n * x;
    while (mx > mn + 1) {
        ll k = (mx + mn) / 2; // k点で満たすか
        ll p = k / x;
        ll q = k % x;

        bool possible = false;
        for (int i = 0; i < n; i++) {
            ll tmp = 0;
            if (q <= b[i]) {
                tmp += q * l[i];
            } else {
                tmp += b[i] * l[i] + (q - b[i]) * u[i];
            }

            tmp += sum[p];
            ll t = b[i] * l[i] + (x - b[i]) * u[i];
            if (p > 0 && t >= benefit[p-1]) {
                tmp = tmp + benefit[p] - t;
            }

            if (tmp >= sm) {
                possible = true;
                break;
            }
        }

        if (possible) {
            mx = k;
        } else {
            mn = k;
        }
    }

    cout << mx << "\n";
    return 0;
}

Measured memory_bytes: 4224
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
//const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;


void solve(){
	string s , t ;
	cin >> s >> t ;
	for(int i = 0 ; i < sz(s) ; i++){
		if(s[i] != t[i]){
			return cout << "No\n" , void() ;
		}
	}
	cout << "Yes\n" ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 3680
#include <stdio.h>
int main(void){
    int N, ans;
    
    ans = 0;
    scanf("%d", &N);
    
    if(N%2 != 0){
        ans = (N/2)+1;
    } else if(N%2 == 0){
        ans = N/2;
    }
    
    printf("%d\n", ans);
    
}


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

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N, A, B = map(int, input().split())
    print(min(A * N, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
import bisect
n, k = map(int, input().split())
M = sorted([ list(map(int, input().split())) for _ in range(n) ])
L = []
S = [0]
for a, b in M:
  L.append(a)
  S.append(S[-1]+b)
S = S[1:]
t = bisect.bisect_left(S, k)
print(L[t])

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

long long n;
vector<long long> a, v;
bitset<4000005> bits[2];

long long solve();

int main() {
  cin >> n;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  bits[0][0] = 1;
  for(int i = 0; i < n; ++i)
    bits[(i + 1) % 2] = bits[i % 2] | (bits[i % 2] << a[i]);

  for(int i = 0; i < 4000001; ++i)
    if(bits[n % 2][i]) v.push_back(i);
  return *(
      lower_bound(v.begin(), v.end(), (v.back() + 1) / 2));
}


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

using namespace std;

#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define NACHO ios_base::sync_with_stdio(0);cin.tie(NULL);

typedef long long tint;

int main(){
	string s; cin >> s;
	if(s == "SUN") cout << 7;
	if(s == "MON") cout << 6;
	if(s == "TUE") cout << 5;
	if(s == "WED") cout << 4;
	if(s == "THU") cout << 3;
	if(s == "FRI") cout << 2;
	if(s == "SAT") cout << 1;  
}
//Paso 1: Calcular los largos de mis bordes de mis strings. Ej: abracadabra: 1-4-11
//Paso 2: Tenes un TRIE. Insertas cada uno de los strings. Pasas también en insertar la lista de bordes. 
//Por cada borde que tenga mi string, mme fijo en el trie mi respuesta óptima.
//Para cada nodo del trie donde termina una palabra, me guardo la máxima respuesta para esa palabra.




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

using namespace std;

typedef long long ll;

int main(){
  ll N, x , y;
  cin >> N;
  ll ans = N;
  for (ll i = 1; i <= sqrt(N); i++){
    if (i * (N/i) == N){
      x = i;
      y = N/i;
      ans = min(ans, (x-1)+(y-1));
    } 
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
from collections import defaultdict

INF = 2 ** 60
dp = defaultdict(lambda: -INF)

n = int(input())
a = list(map(int, input().split())) + [0] * 10

dp[(0, 0)] = 0
dp[(1, 1)] = a[0]

for i in range(n):
    for j in range(i // 2 - 2, i // 2 + 3):
        dp[(i + 2, j + 1)] = max([dp[(i + 2, j + 1)], dp[(i, j)] + a[i + 1]])
        dp[(i + 1, j)] = max([dp[(i + 1, j)], dp[(i, j)]])

print(dp[(n, n // 2)])


Measured memory_bytes: 241308
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[1001],p[1001],t[8],tmp;
	int q,a,b,i,j,k;
	scanf("%s%d",str,&q);
	for(i=0;i<q;i++){
		scanf("%s%d%d",t,&a,&b);
		if(strcmp(t,"print")==0){
			for(j=a;j<=b;j++)printf("%c",str[j]);
			puts("");
		}
		else if(strcmp(t,"reverse")==0){
			for(j=a;j<b;j++){
				for(k=b;k>j;k--){
					tmp=str[k-1];
					str[k-1]=str[k];
					str[k]=tmp;
				}
			}
		}
		else{
			scanf("%s",p);
			j=a;
			k=0;
			while(j<=b){
				str[j]=p[k];
				j++;
				k++;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2112
#include <stdio.h>

int main(void) {
  int a, b, c;
  int x, y;
  
  scanf("%d %d %d", &a, &b, &c);
  
  x = b - a;
  y = c - b;
  
  if (x == y) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>
#include <iomanip>
#include <unordered_map>

using namespace std;

#define MAX 30001
#define ll long long int



int main()
{
   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    double a,b,ans=-1;
    cin>>a>>b;
    for(int i=1;i<1300;i++)
    {
        if(floor(i*0.08)==a && floor(i*0.1)==b)
        {
            ans=i;
            break;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
# 1118 のような、3 つ以上の同じ数字が連続して並んだ 4 桁の整数を 良い整数 とします。
# 4 桁の整数 N が与えられるので、N が 良い整数 かどうかを答えてください。

n = gets.chomp
result = false
2.times do |i|
    result = true if n[i] == n[i+1] && n[i] == n[i+2]
end
puts result ? "Yes" : "No"

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

int main() {
  while(true){
    int n,x;
    cin >> n >> x;
    int comb=0;
    if(n==0 && x==0) break;
    for(int i = 1; i <= n; i++){
      for(int j=i+1; j <=n; j++){
        for(int k= j+1; k <=n; k++){
          if(i+j+k >x) break;
          if(i+j+k==x) comb++;
        }
     }
    }
   cout << comb << endl;
  }
}


Measured memory_bytes: 3072
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        tmp = 0
        for k in range(D):
            tmp += (X[i][k] - X[j][k]) ** 2
        if (tmp ** (1/2)).is_integer():
            ans += 1

print(ans)


Measured memory_bytes: 3316
#include <stdio.h>

int main(void){
  int a,b,c;

  scanf("%d %d",&a,&b);
  c=a*b;
  if(c%2==1){
    printf("Odd\n");
  }
  else if(c%2==0){
    printf("Even\n");
  }
  return 0;
}


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

int main() {  
  long long N,A,B;
  cin >> N >> A >> B;
  vector<long long> X(100009);
  for(int i=0;i<N;i++)cin >> X[i];
  long long ans=0;
  for(int i=0;i<N-1;i++){
    long long q=X[i+1]-X[i];
    ans+=min(B,q*A);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define Mod 1000000007

int main() {
    ll n,k;
    cin>>n>>k;
    k++;
    ll go[n],gone[n]={0};
    for (int i = 0; i < n; ++i) {
        cin>>go[i];
    }
    ll now=1,flag=0;
    ll count=0,icount=0;
    while(gone[now-1]!=2){
        //cout<<now<<endl;
        gone[now-1]++;
        now=go[now-1];
        if(gone[now-1]==1 and flag==0)flag=1;
        if(flag)count++;
        if(!flag)icount++;
    }
    icount++;
    count--;
    icount-=count;
    //cout<<count<<" "<<icount<<endl;
    if(k>icount) {
        k = k - icount;
        k %= count;
        //cout<<k<<endl;
        if (k == 0)k = count;
        for (ll j = 0; j < k-1; ++j) {
            now=go[now-1];
        }
    }
    else{
        k--;
        now=1;
        for (ll i = 0; i < k; ++i) {
            now=go[now-1];
        }
    }
    cout<<now<<endl;
    return 0;
}


Measured memory_bytes: 6724
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define P pair<int,int>
using namespace std;
signed main(){
    string s;
    cin >> s;
    int n = s.size();
    vec(a,n);
    if(n == 2 && s[0] == s[1]){
        cout << "1 2" << endl;
        return 0;
    }
    REP(i,n-2){
        if(s[i] == s[i+1]){
            cout << i+1 << " " << i+3;
            return 0;
        }
        else if(s[i] == s[i+2]){
            cout << i+1 << " " << i+3;
            return 0;
        }
    }
    if(s[n-2] == s[n-1]){
        cout << n-2 << " " << n;
    }
    else{
        cout << "-1 -1" << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
n,*A=map(int,open(0).read().split())
f=[1]*(n+2);r=f[:]
MOD=10**9+7
for i in range(n+1):f[i+1]=e=f[i]*-~i%MOD;r[i+1]=pow(e,MOD-2,MOD)
B=[0]*(n+1)
for a in A:B[a]+=1
i=B.index(2)
L=A.index(i);R=A.index(i,L+1)
for k in range(1,n+2):
    print((f[n+1]*r[k]*r[n+1-k]-(k<=L+n+1-R and f[L-1+n+1-R]*r[k-1]*r[L+n+1-k-R]))%MOD)

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

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

    long double sum = 0;
    int cnt = 0;

    vector<int> perm(N);
    iota(begin(perm), end(perm), 0);
    

    do {
        long double dists = 0;
        for (int i = 0; i+1 < N; ++i) {
            dists += hypot((double)X[perm[i]]-X[perm[i+1]], (double)Y[perm[i]]-Y[perm[i+1]]);
        }
        // cout << dists << endl;
        sum += dists;
        ++cnt;
    } while (next_permutation(begin(perm), end(perm)));

    cout << fixed << setprecision(20);
    cout << sum / cnt << endl;
}

Measured memory_bytes: 256