akhauriyash/Code-Regression huggingface dataset:
// Bismillahirrahmanirrahim
// AgriCoder IPB
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <cctype>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <bitset>
#include <sstream>
#include <clocale>
#include <ctime>
#include <climits>
#include <cassert>
//#include <unordered_map>
using namespace std;

#define FOR(i, agri, coder) for (int i = (int)agri; i <= (int)coder; i++)
#define REP(agri,coder) for (int agri = 0; agri < (int)coder; agri++)
#define FOREACH(i,agricoder) for (typeof((agricoder).end()) i = (agricoder).begin(); i != (agricoder).end(); ++i)
//for (auto& it: agricoder)
#define RESET(agri,coder) memset(agri, coder, sizeof(agri))
#define pb push_back
#define mp make_pair
#define NL printf("==========================\n")
#define getchar_unlocked getchar // for codeforces

int arahbar[8] = {0,1,0,-1,1,1,-1,-1};
int arahkol[8] = {1,0,-1,0,1,-1,-1,1};
int kudabar[8] = {-2,-1,1,2, 2,1 , -1 ,-2};
int kudakol[8] = {1 ,2 ,2,1,-1,-2 , -2,-1};

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef unsigned int UNi;

template<typename T>
T getNum() {
   T res=0;
   char c;
   while(1)
   {
      c=getchar_unlocked();
      if(c==' ' || c=='\n') continue;
      else break;
   }
   bool negatif;
   if (c=='-') {
       negatif = true;
       res = 0;
   }
   else {
       res=c-'0';
       negatif = false;
   }
   while(1)
   {
      c=getchar_unlocked();
      if('0'<=c && c<='9') res=res*10 + c-'0';
      else break;
   }
   if (negatif) res*=-1;
   return res;
}

inline void boost() { //dont use with cstdio, dont use in interactives
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
}
//freopen("badmilk.in", "r", stdin);
//freopen("badmilk.out", "w", stdout);
//fclose(stdin);
//fclose(stdout);
#define INF 1000000000
#define EPS 1e-9
#define MAX_N 100005
// ================================  TEMPLATE ENDS HERE ================================================== //

LL V[105];
LL W[105];
int n;

map< pair<int,LL> , LL > dp;

LL rek(int pos,LL sisa) {
	if (pos==n) return 0;
	if ( dp.find(mp(pos,sisa)) != dp.end() ) return dp[mp(pos,sisa)];
	if (W[pos]>sisa) return dp[mp(pos,sisa)] = rek(pos+1,sisa);
	
	return dp[mp(pos,sisa)] = max( rek(pos+1,sisa) , V[pos] + rek(pos+1,sisa-W[pos]) );
	
}
int main() {
	LL tas;
	cin >> n >> tas;
	REP(i,n) cin >> W[i] >> V[i];
	
	cout << rek(0,tas) << endl;
	return 0;
}
//Alhamdulillahirabbilalamin


Measured memory_bytes: 6272
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      xys: [(f64, f64); n],
    }

    let mut xys: Vec<_> = xys.iter().map(|&(x, y)| (y.atan2(x), x, y)).collect();
    xys.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap());

    let mut ans = 0.0f64;
    for i in 0..n {
        for j in 1..n+1 {
            let mut x = 0.0;
            let mut y = 0.0;
            for k in i..i+j {
                x += xys[k%n].1;
                y += xys[k%n].2;
            }
            let d = x*x + y*y;
            if d >= ans {
                ans = d;
            }
        }
    }
    puts!("{}\n", ans.sqrt());
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(void){
	int a[100], n, i;
	int *p = a;
	scanf("%d",&n);
	for(i=0;i++<n;)
		scanf("%d",p++);
	while(--n)
		printf("%d ",*--p);
	printf("%d\n",*a);
	return 0;
}

Measured memory_bytes: 596
from math import factorial
N = factorial(int(input()))
mod = 10**9 + 7
ans = 1
i = 2

while i*i <= N:
    cnt = 1
    while N%i == 0:
        cnt += 1
        N //= i
    ans *= cnt
    i += 1

if N != 1:
    ans *= 2
print(int(ans%mod))


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    ll sum = 0, s = 0;
    int ans = 0, cnt = 0;
    rep(i,n) cin >> a[i];
    vector<int> d;
    rep(i,n) { 
        cin >> b[i]; 
        if(a[i] > b[i])  { 
            d.push_back(a[i]-b[i]);
            s+=a[i]-b[i];
        }
        if(b[i] > a[i]) {
            sum+=b[i]-a[i];
            cnt++;
        }
    }
    if(s < sum) { cout << -1 << endl; return 0;}
    sort(all(d));
    reverse(all(d));
    ans = cnt;
    rep(i,d.size()) {
        if(sum<=0) break;
        sum-=d[i];
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4424
ar=[]
n,m=map(int,input().split())
for i in range(n):
    ar.append(list(map(int,input().split())))


b=[]
for i in range(m):
    b.append(int(input()))

for i in range(n):
    ans=0
    for j in range(m):
        ans+=ar[i][j]*b[j]
    print(ans)


Measured memory_bytes: 5984
import math
A, B, H, M = map(int, input().split())

# 分針の角度を求める 1min = 6度
Mangle = 6*M
# 時針
Hangle = 30*H + 0.5*M

angle = abs(Mangle - Hangle)
#print(angle)
angle = min(angle, 360-angle)
#print(angle)
angle = math.radians(angle)


answer = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(angle))
print(answer)

Measured memory_bytes: 62360
use std::io::{BufRead, Write};

fn main() {
    const MAXA: usize = 1_000_000;

    let stdin = std::io::stdin();
    let stdout = std::io::stdout();
    let mut reader = std::io::BufReader::new(stdin.lock());
    let mut writer = std::io::BufWriter::new(stdout.lock());

    let n: usize = {
        let mut buf = String::new();
        reader.read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let mut a: Vec<usize> = {
        let mut buf = String::new();
        reader.read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };

    a.sort();

    let mut check = vec![false; MAXA + 1];

    let mut ans = 0;
    for i in 0..n {
        if check[a[i]] { continue; }
        if i == n - 1 || a[i] != a[i + 1] {
            ans += 1;
        }
        let mut x = a[i];
        while x <= MAXA {
            check[x] = true;
            x += a[i];
        }
    }
    writeln!(writer, "{}", ans).unwrap();
}

Measured memory_bytes: 5312
def main():
    N, K = map(int, input().split())

    x = 0
    y = 0
    for i in range(1, N + 1):
        if i % K == 0:
            x += 1
        elif i % K == int(K / 2):
            y += 1

    if K % 2 == 0:
        print(x ** 3 + y ** 3)
    else:
        print(x ** 3)


main()

Measured memory_bytes: 39408
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<assert.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 1e6+10, M = 1e6+10;
int s;
ll f[2010];
int main() {
	cin>>s;
	f[0] = 1;
	for(int i = 3;i <= s;i++) {
		for(int j = 3;j <= i;j++) {
			f[i] = (f[i] + f[i - j]) % mod;
		}
	}
	cout<<f[s]<<"\n";
	return 0;
}

Measured memory_bytes: 3592
from collections import Counter, defaultdict
from queue import Queue
G = defaultdict(list)

C = Counter()
N = int(input())
ans = {}
o = []
for i in range(N-1):
    a, b = map(int, input().split())
    C[a] += 1
    C[b] += 1
    G[a].append(b)
    G[b].append(a)
    ans[(a, b)] = 0
    o.append((a,b))

cs = [0] * (N+1)
def bfs(v):
    ret = 0
    visited = set()
    q = Queue()
    visited.add(v)
    q.put(v)
    while not q.empty():
        v = q.get()
        counter = 1
        for c in G[v]:
            if not c in visited:
                visited.add(c)
                if counter == cs[v]:
                    counter += 1
                cs[c] = ans[(c,v)] = ans[(v,c)] = counter
                counter += 1
                q.put(c)

bfs(1)
print(C.most_common(1)[0][1])
for a,b in o:
    print(ans[(a,b)])

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int a, b;
	cin >> a >> b;

	if ((a + b) % 2 == 0) {
		out((a + b) / 2);
	}
	else {
		out("IMPOSSIBLE");
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  int a,b;cin>>a>>b;
  cout<<a*b;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N;
  cin>>N;
  vector<double> V(N);
  rep(i,N){
    cin>>V.at(i);}
  sort(V.begin(),V.end());
  double v=V.at(0);
  for(int i=1;i<N;i++){
    v=(v+V.at(i))/2;}
    std::cout << std::setprecision(50)<<v<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;


bool solve(){
	int n, m, a;
	cin>> n>> m>> a;
	if(!(n|m|a)) return false;
	vector<vector<int> > vv(1002, vector<int>(n,0));
	for(int i=0;i<1002;i++){
		for(int j=0;j<n;j++){
			vv[i][j] = j+1;
		}
	}
	for(int i=0;i<m;i++){
		int h, p, q;
		cin>> h>> p>> q;
		vv[h][p-1] = q;
		vv[h][q-1] = p;
	}
	for(int i=1001;i>=0;i--){
		a = vv[i][a-1];
	}
	cout<< a<< endl;
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	while(solve());

	return 0;
}

 

Measured memory_bytes: 1600
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] num = new int[2*n];
		for(int i = 0; i < 2*n; i++) {
			num[i] = sc.nextInt();
		}
		Arrays.sort(num);
		long ans = 0L;
		for(int i = 0; i < 2*n; i+=2) {
			ans += num[i];
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
use std::io::*;
use std::str::FromStr;
use std::cmp::*;

fn main() {
    let n: usize = read();
    let w: usize = read();
    let wv: Vec<(usize, i64)> = (0..n).map(|_| (read(), read())).collect();

    // dp[i][j] = value_max
    let mut dp: Vec<Vec<i64>> = vec![vec![0; w+1]; n+1];
    for i in 0..n {
        let (wi, vi) = wv[i];
        for j in 0..w+1 {
            if j >= wi {
                dp[i+1][j] = max(dp[i+1][j], dp[i][j - wi] + vi);
            }
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    println!("{}", dp[n][w]);
}

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


Measured memory_bytes: 106748
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>


using namespace std;

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

    vector<string> s(n);

    for(int i = 0; i < n; i++) {
        cin >> s[i];
    }

    sort(s.begin(), s.end());
    
    int cnt = 1;
    string tmp = s[0];
    for (int i = 1; i < n; i++) {
        if(s[i] == tmp) continue;
        cnt++;
        tmp = s[i];
    }

    cout << cnt << endl;
}

Measured memory_bytes: 9548
import itertools

N, M, Q = map(int, raw_input().split())
data = [None] * Q
for i in range(Q):
    data[i] = map(int, raw_input().split())

def calc_score(data, A):
    score = 0
    for a, b, c, d in data:
        if A[b-1] - A[a-1] == c:
            score += d
    return score

print max(calc_score(data, A) for A in itertools.combinations_with_replacement(range(1, M+1), N))


Measured memory_bytes: 78440
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	int k, t;
	cin >> k >> t;
	int cnt = k / 2;
	cnt += k % 2;
	vint a(t);
	int ans = 0;
	int tmp = -1;
	rep(i, t) {
		cin >> a[i];
		if (cnt < a[i]) {
			tmp = a[i];
		}
	}
	if (tmp == -1) {
		cout << 0 << endl;
		return 0;
	}
	ans = 2 * (tmp - k / 2);
	if (k % 2 == 0) {
		ans -= 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    string s, t;
    cin >> s >> t;

    map<char, vector<int>> m;
    REP(i, s.size()) m[s[i]].pb(i);

    int j = -1;
    ll cnt = 0;
    REP(i, t.size()) {
        char c = t[i];

        if (m[c].size() == 0) {
            print(-1);
            return 0;
        }

        auto it = lower_bound(ALL(m[c]), j + 1);
        if (it == m[c].end()) {
            cnt++;
            j = m[c][0];
        } else {
            j = *it;
        }
    }

    print(s.size() * cnt + j + 1);
    
}


Measured memory_bytes: 4152
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
const long long MOD = 1000000007, INF = 1e18;
/*
#define endl '\n'
#define IOS()                     \
	ios_base::sync_with_stdio(0); \
	cin.tie(0)
*/
string get_str(string s)
{
	s += ',';
	string ret = "";
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == ',')
			ret += "=%ld, ";
		else
			ret += s[i];
	}
	return ret;
}
#define dump(...)                                       \
	printf(get_str(#__VA_ARGS__).c_str(), __VA_ARGS__); \
	cout << endl
//******************************************************************************

int A, B, C, D, E, F, G, N, M, K, X, Y, Z;
string s, t;

signed main()
{
	int T;
	cin >> A >> B >> T;
	cout << T / A * B << endl;
}

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

/// Defining variable types.
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

/// Defining usable key words
#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

/// Defining constant variables.
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

/// Defining some useful lines.
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);


/// Code of debugger.
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}


int main()
{
    optimize();

    int a[]={1,3,5,7,8,10,12};
    int b[]={4,6,9,11};
    int cnt=0;
    int x,y;
    cin>>x>>y;

    if(x==2 || y==2)
    {
        cout<<"No"<<endl;
        return 0;
    }


    for(int i=0;i<7;i++)
    {
        if(a[i]==x)cnt++;
        if(a[i]==y)cnt++;
    }

    if(cnt==2)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    else if(cnt==1)
    {
        cout<<"No"<<endl;
        return 0;
    }

   else
    cout<<"Yes";

   /* for(int i=0;i<4;i++)
    {
        if(b[i]==x)cnt++;
        if(b[i]==y)cnt++;
    }

    if(cnt==2)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    else
    {
        cout<<"No"<<endl;
        return 0;
    }
*/












    return 0;
}


Measured memory_bytes: 3588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] tmp = br.readLine().split(" ");
			int n = Integer.parseInt(tmp[0]);
			int x = Integer.parseInt(tmp[1]);
			if(n == 0 && x == 0){
				break;
			}
			int start = x / 3 + 1;
			int count = 0;
			for(int i = start;i <= n;i++){
				for(int j = ((start << 1) - (i + 1));j < i;j++){
					for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
							break;
						}
					}
				}
			}
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 19176
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
ans = 0
for i in range(1, N+1):
	if i >= K:
		ans += 1/N
	else:
		ans += (1/N) * ((1/2)**ceil(log2(K/i)))
print(ans)


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

long long ope_cnt(vector<long long> a, int n, bool plus) {
	long long sum = 0, ret = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
		if (plus && sum <= 0) {
			ret += 1 - sum;
			sum = 1;
		}
		else if (!plus && sum >= 0) {
			ret += 1 + sum;
			sum = -1;
		}
		plus = !plus;
	}
	return ret;
}

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

	long long ans_p = ope_cnt(a, n, true);
	long long ans_m = ope_cnt(a, n, false);
	cout << min(ans_p, ans_m) << endl;
}


Measured memory_bytes: 1804
#include<cstdio>

typedef long long ll;


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

int main(void)
{
	int n, t, ti, ti_prev, i;
	ll s;

	while(scanf("%d%d", &n, &t)==2)
	{
		s=0;

		for(i=0;i<n;i++)
		{
			scanf("%d", &ti);
			if(i==0) ti_prev=ti;

			s+=min(ti-ti_prev, t);

			ti_prev=ti;
		}
		s+=t;
		printf("%lld\n", s);
	}

	return 0;
}


Measured memory_bytes: 128
#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>;

string divide[4] = {"dream","dreamer","erase","eraser"};

int main(){
  string s;
  cin>>s;
  reverse(s.begin(),s.end());
  rep(i,4) reverse(divide[i].begin(),divide[i].end());
  int f1=1;
  for(int i=0;i<s.size();){
    int f2=0;
    rep(j,4){
      string d = divide[j];
      if(s.substr(i,d.size())==d){
        i+=d.size();
        f2=1;
      }
  	}
    if(1-f2){
      f1=0;
      break;
    }
  }
  if(f1) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    string s;
    cin >>s;
    int n = s.size();

    int star = -1;
    rep(i,n)if(s[i]=='*') star = i;

    int ans = 0;
    stack<int> st;
    rep(i,n){
        if(s[i]=='*') continue;

        if(s[i]=='(') st.push(i);
        else{
            int l = st.top();
            st.pop();
            ans += (l<star && star<i);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3192
# C - Peaks

n,m = map(int, input().split())
h = list(map(int,input().split()))
ab = []
for i in range(m):
    ab.append(list(map(int,input().split())))

peak = [1]*n
for i in range(m):
    if h[ab[i][0]-1] >= h[ab[i][1]-1]:
        peak[ab[i][1]-1] = 0
    if h[ab[i][0]-1] <= h[ab[i][1]-1]:
        peak[ab[i][0]-1] = 0
print(sum(peak))


Measured memory_bytes: 31972
#!/usr/bin/env python3

from typing import *



# def solve(S: str) -> str:
def solve(S):
    if S[-1:] == 's':
        return S+'es'
    else:
        return S+'s'

def main():
    S = input()
    a = solve(S)
    print(a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 10196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;
int main() {
   int a, b;
   cin >> a >> b;
   if(a < b)
      printf("a < b\n");
   else if(a > b)
      printf("a > b\n");
   else if(a == b)
      printf("a == b\n");
   return 0;
}


Measured memory_bytes: 3008
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
vel solve(V<vel>& ab, int ex) {
	if (ex == 0) { return { 1, 0 }; }
	V<V<vel>> qab(2);
	for (vel x : ab) {
		int a1 = x[0];
		int b1 = x[1];
		qab[x[1] & 1].push_back({ x[0] / 2,x[1] / 2 });
		if (x[0] & 1) { qab[(x[1] + 1) & 1].push_back({ x[0] / 2,(x[1] + 1) / 2 }); }
	}
	V<vel> c(3,vel(2));
	rep(i, 2) {
		for (auto x : qab[i]) {
			int qc = (3 - x[0] + x[1]) % 3; qc = (qc + 3) % 3;
			if (qc == 0) { c[i][0] ^= 1; }
			if (qc == 1) { c[i][1] ^= 1; }
			if (qc == 2) { c[i][0] ^= 1; c[i][1] ^= 1; }
		}
	}
	if (c[0] == c[2]) {
		vel ans = solve(qab[1], ex - 1);
		ans[0] *= 2; ans[1] *= 2;ans[1]++;
		return ans;
	}
	if (c[1] == c[2]) {
		vel ans = solve(qab[0], ex - 1);
		ans[0] *= 2; ans[1] *= 2;
		return ans;
	}
	rep(i, ab.size()) { ab[i][0]++; }
	vel ans = solve(ab, ex); ans[0]--;
	return ans;
}
signed main() {
	int inf = 2e17;
	int n; cin >> n;
	V<vel> ab(n);
	rep(i, n) {
		int a, b; cin >> a >> b;
		ab[i] = { a + inf,b + inf };
	}
	vel ret = solve(ab, 70);
	cout << ret[0] - inf << " " << ret[1] - inf << "\n";
}

Measured memory_bytes: 37052
#include<stdio.h>

int min(int, int);

int main() {

	//入力
	int n;
	scanf("%d", &n);
	int b[99];
	for (int i = 0; i < n - 1; i++) {
		scanf("%d", b + i);
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (i == 0) ans += b[0];
		else if (i == n - 1) ans += b[i - 1];
		else ans += min(b[i - 1], b[i]);
	};

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

int min(int a, int b) {
	if (a >= b) return b;
	else return a;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;

int main(){
    int H, W, N, c; cin >> H >> W >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++)  cin >> a[i];
    int p[H][W];
    int mode, j, k;
    j = 0;
    k = 0;
    mode = 1;
    for(int i=0; i<N; i++){
        c = a[i];
        while(k > -1 && k < W && c > 0){
            p[j][k] = i+1;
            c--;
            if(mode == 1)   k++;
            else    k--;
            if(k == W){
                j++;
                k--;
                mode = -1;
            }else if(k == -1){
                j++;
                k++;
                mode = 1;
            }
        }
    }
    for(int i=0; i<H; i++){
        for(int j=0; j<W-1; j++){
            cout << p[i][j] << " ";
        }
        cout << p[i][W-1] << endl;
    }
}

Measured memory_bytes: 3672
pairs (x:y:xs) = scanl (\(_, b) c -> (b, c)) (x, y) xs
pairs _ = []
total l = sum $ (abs.uncurry (-)) <$> pairs (0:l++[0])
skips [] = []
skips (x:xs) = xs : fmap (x:) (skips xs)
skipTotal t (x:y:z:xs) | (x-y)*(y-z) >= 0 = t : skipTotal t (y:z:xs)
                       | otherwise = t - abs (x-y) - abs (y-z) + abs (x-z) : skipTotal t (y:z:xs)
skipTotal t _ = []

main = do
  _ <- getLine
  l <- fmap read.words<$>getLine
  mapM_ putStrLn $ show <$> skipTotal (total l) (0:l++[0])


Measured memory_bytes: 31100
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
string s;
ll memo[1001000][2];

ll dp(int i, int j){
    if(i == -1 && j == 0){
        return 0;
    }
    if(i == -1) return INF;
    //if(i == 0 && j == 1) return INF;
    if(memo[i][j] != INF){
        return memo[i][j];
    }

    ll res = INF;
    int now = s[i] - '0';
    //cout << "s" << now << endl;
    if(j){
        for(int k = 0; k < 2; k++){
            res = min(res, dp(i - 1, k) + 10 - (now + (k?1:0)));
        }
    } else {
        for(int k = 0; k < 2; k++){
            res = min(res, dp(i - 1, k) + now + (k?1:0));
        }
    }
    //cout << i << " " << j << " " << res << endl;
    return memo[i][j] = res;

}

int main(void){
    cin >> s;
    reverse(s.begin(), s.end());
    s += '0';
    for(int i = 0; i <= s.size(); i++){
        for(int j = 0; j < 2; j++){
            memo[i][j] = INF;
        }
    }
    cout << dp(s.size() - 1, 0) << endl;
}

Measured memory_bytes: 79492
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ans =0;
		
		while(N>0) {
			N /=K;
			ans++;
		}

		System.out.println(ans);

	}

}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
const int MD=1e9+7;
int a[N];
int quick_pow(int x,int y) {
	int ans=1;
	while(y) {
		if(y&1) ans=1LL*ans*x%MD;
		y>>=1;
		x=1LL*x*x%MD;
	}
	return ans;
}
void add(int &x,int y) {
	x+=y;
	if(x>=MD) x-=MD;
}
int main() {
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%d",&a[i]);
	}
	if(n==1) printf("%d\n",1LL*2*a[0]%MD);
	else {
		sort(a,a+n);
		int ans=0,x=quick_pow(2,n-2),t=1LL*x*2%MD;
		for(int i=n-1;i>=0;i--) {
			add(ans,1LL*a[i]*t%MD);
			add(t,x);
		}
		printf("%d\n",1LL*ans*quick_pow(2,n)%MD);
	}
	return 0;
}

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

int main(){
    ll k, n; cin >> k >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];

    ll m = -1;
    rep(i, 0, n){
        ll dr, dl;
        if(i+1 >= n) dr = a[0] + k - a[i];
        else dr = a[i+1] - a[i];
        if(i-1 < 0) dl = a[i] + k - a[n-1];
        else dl = a[i] - a[i-1];
        m = max(m, dr);
        m = max(m, dl);
    }

    cout << k - m << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<map>
using namespace std;
int main(){
    int H,A;
    cin>>H>>A;
    if(H%A == 0){
        cout<<H/A<<endl;
    }
    else{
        cout<<H/A+1<<endl;
    }
    return 0;
}


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

int main()
{
	int n, sum=0;
	cin >> n;
	int a[n+1];
	a[0]=0;
	a[n+1]=0;

	for(int i=1; i<=n; i++){
        cin >> a[i];
        sum += abs(a[i] - a[i-1]);
    }
    sum += abs(a[n+1] - a[n]);

    for(int i=1; i<=n; i++){
        cout << sum - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i+1] - a[i-1]) << endl;
    }

    return 0;
}


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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

int N, M;

bool f(vector<string> a, vector<string> b, int h, int w){
    for (int i=0;i<M;i++){
        for (int j = 0; j < M; j++){
            if(a[h+i][w+j] != b[i][j]) return false;
        }
    }
    return true;
}

int main()
{
    cin >> N >> M ;
    vector<string> A(N),B(M);
    rep(i,N) cin >> A[i];
    rep(i, M) cin >> B[i];

    for (int h = 0; h <= N - M;h++){
        for (int w = 0;w<=N-M;w++){
            if(f(A,B,h,w)){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3644
input_arr = input().split(" ")
a = int(input_arr[0])
b = int(input_arr[1])
c = int(input_arr[2])
d = int(input_arr[3])

AC = a * c
AD = a * d
BC = b * c
BD = b * d

l = [AC, AD, BC, BD]
print(max(l))

Measured memory_bytes: 9208
import java.util.Scanner;
import java.util.ArrayList;;

public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		ArrayList<int[]> data = new ArrayList<int[]>();
		
		long res = 0;
		for(int i = 0;i<N;i++) {
			int[] input = new int[2];
			input[0]=sc.nextInt();
			input[1]=sc.nextInt();
			data.add(input);
		}
		data.sort((a,b)->Integer.compare(a[0], b[0]));
		
		int i = 0;
		int count_m = 0;
		int count = 0;
		
		while(M != count_m) {
			res += data.get(i)[0];
			count++;
			count_m++;
			
			int next_i = count/data.get(i)[1];
			count = count%data.get(i)[1];
			i += next_i;
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 84400
#include <stdio.h>

int main(void)
{
	int H, W, i, j;

	while (1)
	{
		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0)break;

		for (j = 0; j < W; j++)
			printf("#");
		putchar('\n');
		for (i = 1; i < H - 1; i++)
		{
			printf("#");
			for (j = 1; j < W - 1; j++)
				printf(".");
			printf("#");
			putchar('\n');
		}
		for (j = 0; j < W; j++)
			printf("#");
		putchar('\n');
		putchar('\n');
	}

	return 0;
}

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

using namespace std;
using ll = long long;

int main()
{
    int h, w; cin >> h >> w;
    vector<vector<int>> g(h, vector<int>(w));
    auto dp = g;
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++)cin >> g[i][j];

    for(int i = 0; i < h; i++)dp[i][0] = !g[i][0];
    for(int i = 0; i < w; i++)dp[0][i] = !g[0][i];


    for(int i = 1; i < h; i++) {
        for(int j = 1; j < w; j++) {
            if(g[i][j])continue;
            dp[i][j] = min({dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]}) + 1;
        }
    }

    int nin = 0;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            nin = max(nin, dp[i][j]);
        }
    }
    cout << nin * nin << endl;
}


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

using namespace std;
int n, x,a,i=0;
vector<int> vec;
int main(void){
    cin >> n >> x;
    for(i=0;i<n;i++){
        cin >> a;
        vec.push_back(a);
    }
    
    sort(vec.begin(),vec.end());
    
    for(i=0;i<n;i++){
if(vec[i]>x){
cout << i<< '\n';
return 0;
}else if(vec[i]==x){
cout << i+1<< '\n';
return 0;
}
        x-=vec[i];
    }

    if(x>0)n--;
    cout << n<< '\n';
    return 0;
}


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

    ans = n * (n + 1) // 2 - 3 * (n // 3) * (n // 3 + 1) // 2 - 5 * \
        (n // 5) * (n // 5 + 1) // 2 + 15 * (n // 15) * (n // 15 + 1) // 2

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61860
// D - String Equivalence
// DFS version
#include <bits/stdc++.h>
using namespace std;

int N;

void dfs(string pre){
	if(pre.size() >= N){
		cout<< pre <<endl;
		return;
	}
	set<char> types{'a'}; for(auto c:pre) types.insert(c+1);
	for(auto c:types) dfs(pre+c);
}

int main(){
	cin>>N;
	dfs("a");
}

Measured memory_bytes: 1536
# import bisect
# from collections import Counter, defaultdict, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    a, b, c = list(map(int,ipti().split()))
    if a <= c <= b:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define	debug(ccc)	cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e6+10;
const ll inf = 1e18;

ll power(ll a,ll n){
	if(n==0){
		return 1;
	}
	ll b = power(a,n/2);
	b = b*b%mod;
	if(n%2) b= b*a%mod;
	return b;
}

int add(int a,int b){ return (a+b)%mod;}
int mul(int a,int b){ return (ll)a*b%mod;}

pll A[N];
ll B[N];

int main(){
 // 	freopen("nice.in","r",stdin);
 // freopen("nice.out","w",stdout);
	int n; scanf("%d",&n);
	REP(i,n) scanf("%lld",&A[i].X);
	REP(i,n) A[i].Y = i;
	sort(A,A+n);

	ll cnt = 0,in=-1, al=0,last = 0;
	for(int i=n-1;i>=0;i--){
		if(in==-1){
			in = i;cnt++; 
			last = A[i].X;
			continue;
		}
		// printf("%lld %lld %lld\n",A[i].X,A[i].Y,in);
		if(A[i].Y<A[in].Y){
			if(A[i].X==A[in].X){
				// printf("hi %lld %lld %lld\n",A[i].X,A[in].X,in);
				al+=cnt*(last-A[i].X);
				last = A[i].X;	
			 	in=i,cnt++;
			}
			else{
				al+=cnt*(last-A[i].X);
				B[A[in].Y]=al;
				// printf("%lld %lld %lld %lld %lld\n",al,in,cnt,last,A[i].X);
				al=0;
				last = A[i].X;
				in = i;
				cnt++;
			}
		}else{
			al+= cnt*(last - A[i].X);
			last = A[i].X;
			cnt++;
		}
	}
	al+=cnt*last;
	B[A[in].Y]=al;
	REP(i,n) printf("%lld\n",B[i]);

	return 0;
}




Measured memory_bytes: 6016
#include <iostream>
#include <cstdlib>
#include <bitset>
#include <map>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>
#include <math.h>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecchar vector<char>
#define vecstr vector<string>
#define vec2str vector<vector<string>>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

#define Pi 3.1415926535897932384626

int main() {
	ll n, ans = 0,max = 0;
	bool flag = false;
	string s;

	cin >> n;

	vecll x(n);

	forll(i, 0, n)
		cin >> x[i];

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

	forll(i, 0, n-2) {
		forll(j, i+1, n-1) {
			forll(k, j + 1, n) {
				if (x[i] != x[j] && x[j] != x[k] && (x[i] + x[j]) > x[k])
				{
					ans++;
				}
			}
		}
	}

	cout << ans;
}


Measured memory_bytes: 3632
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
  long long int n,d,x,y;
  cin>>n>>d;
  long int count=0;
  for(int i=0;i<n;i++)
  {
    cin>>x>>y;
    if((x*x)+(y*y)<=d*d)
      count++;
  }
  cout<<count;
}


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

int main() {
  string s;
  cin >> s;
  
  for (int i = 1; i <= 5; i++) {
    string t = "";
    for (int j = 0; j < i; j++) {
      t += "hi";
    }
    
    if (s == t) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define MAX 100001

int main(){
	int n, q;
	cin >> n;
	vector <int> v (MAX, 0);
	long long sum = 0;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		v[a]++;
		sum += a;
	}
	
	cin >> q;
	while (q > 0){
		int b, c;
		cin >> b >> c;
		int d = v[b];
		v[b] = 0;
		v[c] += d;
		sum -= b*d;
		sum += c*d;
		cout << sum << '\n';
		q--;
	}
	return 0;
}

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

vector<int> S1;

int Euclidean(int a, int b) {
  if (a % b == 0) {
    return b;
  } else {
    int x = a % b;
    return Euclidean(max(b,x), min(b,x));
  }
}

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

  long long A, B;
  cin >> A >> B;

  long long res = Euclidean(max(A,B), min(A,B));
  res = (A * B) / res;
  cout << res << '\n';
  return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

vector<i64> fact;
void init_fact(i64 n,i64 m){
	fact.resize(n+1);
	fact[0]=fact[1]=1;
	for(i64 i=2; i<=n; ++i) fact[i]=(i*fact[i-1])%m;
}

i64 extgcd(i64 a,i64 b,i64 &x,i64 &y){
	i64 d=a;
	if(b!=0){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	} else {
		x=1; y=0;
	}
	return d;
}

i64 mod_inverse(i64 a,i64 m){
	i64 x,y;
	if(extgcd(a,m,x,y)==1) return (x+m)%m;
	return 0;
}

i64 rep_pow(i64 x,int64_t y,i64 mod){
	i64 res(1);
	while(y>0){
		if(y&1) res=res*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return res;
}

vector<vector<i64>> comb;
void init_mod_comb(int n,int k,i64 mod){
	comb.resize(n+1);
	for(int i=0; i<=n; ++i){
		comb[i].resize(min(i+1,k+1));
		comb[i][0]=1;
		if(i<=k) comb[i][i]=1;
	}
	for(int i=1; i<=n; ++i){
		for(int j=1; j<=min(i-1,k); ++j){
			comb[i][j]=(comb[i-1][j]+comb[i-1][j-1])%mod;
		}
	}
}

void solve(){
	i64 mod=1000000007;
	init_mod_comb(1024,1024,mod);
	init_fact(1024*1024,mod);
	/*
	vector<i64> inv(1001*1001);
	rep(i,1,1001*1001) inv[i]=mod_inverse(i,mod);
	*/

	int table_size=100000;
	i64 inv_table[table_size];
	rep(i,1,table_size) inv_table[i]=mod_inverse(i,mod);
	auto inv=[&](i64 x){
		if(x<table_size) return inv_table[x];
		return mod_inverse(x,mod);
	};

    i64 N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    static i64 dp[1024][1024];
    fill_n((i64*)dp,1024*1024,0);
    dp[A][0]=1;
    rep(i,C,D+1){
        if(A*i>N) break;
        dp[A][A*i]=comb[N][A*i]*fact[A*i]%mod*inv(fact[i]*rep_pow(fact[A],i,mod)%mod)%mod;
    }

	rep(i,A,B){
		rep(j,0,N+1){
			dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
			rep(k,C,D+1){
				if(j+(i+1)*k>N) break;
				dp[i+1][j+(i+1)*k]=(dp[i+1][j+(i+1)*k]+dp[i][j]*comb[N-j][(i+1)*k]%mod*fact[(i+1)*k]%mod*inv(fact[k]*rep_pow(fact[i+1],k,mod)%mod)%mod)%mod;
			}
		}
	}

	cout << dp[B][N] << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 21632
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

int main(){
    int64_t a;
    long double b;
    cin >> a >> b;

    cout << (int64_t)(a * b) << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<int> T(N + 1, 0);
  int total = 0;
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &T[i]);
    total += T[i];
  }
  int M; scanf("%d", &M);
  vector<int> P(M + 1), X(M + 1);
  for (int i = 1; i <= M; ++i) {
    scanf("%d %d", &P[i], &X[i]);
  }
  for (int i = 1; i <= M; ++i) {
    printf("%d\n", total - (T[P[i]] - X[i]));
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  string s;
  cin>>s;
  int ans=999999;
  rep(i,2){
    int cnt=0;
    rep(j,s.size()){
      if(j%2==0 && s[j]==(char)(i+'0'))
         cnt++;
      if(j%2==1 && s[j]!=(char)(i+'0'))
         cnt++;
    }
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
}
              

Measured memory_bytes: 3644
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;

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


const int BIG_NUM = 1e8;
const ll INF = 1000000000000000000;

const int MAX_A = 1000000;

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

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

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

	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += p[i];
	}

	cout << sum << endl;
	
}

Measured memory_bytes: 3608