akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define rep(i,k,n) for (ll i = k; i < n; ++i)
#define inputar(a,n) ll a[n];rep(i,0,n)cin>>a[i]
#define PI 3.14159265
const int MOD=1e9+7;
const int N=2e5+10;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()


#define test4(x,y,z,a) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cerr<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cerr<<"x is "<<x<<endl;

bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
} 
int binomialCoeff(int n, int k)  
{
    if (k == 0 || k == n)  
        return 1;  

    return binomialCoeff(n - 1, k - 1) +  
                binomialCoeff(n - 1, k);  
}  
long long power(ll a, ll b)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a);
        b/=2;
        a=(a*a);
    }
    return ans;
}

int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}

 vector<ll>v[N];
int main()
{
    IOS;
    ll n,m;
    cin>>n>>m;
   
    for(int i=0;i<n;i++)
    {
        ll a,b;
        cin>>a>>b;
        v[a].pb(b);
    }
    ll ans=0;
    priority_queue<ll>pq;
    for(int i=1;i<=m;i++)
    {
        for(int j=0;j<v[i].size();j++) pq.push(v[i][j]);
        if(!(pq.empty()))
        {
            ans+=pq.top();
            pq.pop();
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
        while(1){
            vector<int>x(2);
            for(auto&e:x){
                    scanf("%d",&e);
            }
            sort(x.begin(),x.end());
            if(x[0]==0 && x[1]==0) break;
            printf("%d %d\n",x[0],x[1]);
        }
        return 0;
}

Measured memory_bytes: 1184
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----
local MOD = math.floor(10^9)+7

local tmp = read.l():totable()
local S = {}
for i=1,#tmp do
    if tmp[i] == '?' then
        S[i] = '?'
    else
        S[i] = tonumber(tmp[i])
    end
end

local N = #S
local ti = array(1, 0)
local tio = array(1, 0)
tio[0] = 1
for i=1,N do
    if S[i] == '?' then
        local oldsum = tio[0] + tio[1] + tio[2] + tio[3] + tio[4] + tio[5] + tio[6] + tio[7] + tio[8] + tio[9] + tio[10] + tio[11] + tio[12]
        ti[0] = (oldsum - tio[4] - tio[8] - tio[12]) % MOD
        ti[1] = (oldsum - tio[3] - tio[8] - tio[12]) % MOD
        ti[2] = (oldsum - tio[3] - tio[7] - tio[12]) % MOD
        ti[3] = (oldsum - tio[3] - tio[7] - tio[11]) % MOD
        ti[4] = (oldsum - tio[2] - tio[7] - tio[11]) % MOD
        ti[5] = (oldsum - tio[2] - tio[6] - tio[11]) % MOD
        ti[6] = (oldsum - tio[2] - tio[6] - tio[10]) % MOD
        ti[7] = (oldsum - tio[1] - tio[6] - tio[10]) % MOD
        ti[8] = (oldsum - tio[1] - tio[5] - tio[10]) % MOD
        ti[9] = (oldsum - tio[1] - tio[5] - tio[9]) % MOD
        ti[10] = (oldsum - tio[0] - tio[5] - tio[9]) % MOD
        ti[11] = (oldsum - tio[0] - tio[4] - tio[9]) % MOD
        ti[12] = (oldsum - tio[0] - tio[4] - tio[8]) % MOD
    else
        local c = S[i]
        ti[(0 + c) % 13] = tio[0]
        ti[(10 + c) % 13] = tio[1]
        ti[(20 + c) % 13] = tio[2]
        ti[(30 + c) % 13] = tio[3]
        ti[(40 + c) % 13] = tio[4]
        ti[(50 + c) % 13] = tio[5]
        ti[(60 + c) % 13] = tio[6]
        ti[(70 + c) % 13] = tio[7]
        ti[(80 + c) % 13] = tio[8]
        ti[(90 + c) % 13] = tio[9]
        ti[(100 + c) % 13] = tio[10]
        ti[(110 + c) % 13] = tio[11]
        ti[(120 + c) % 13] = tio[12]
    end
    tio, ti = ti, tio
end
print(tio[5])

Measured memory_bytes: 4644
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:usize,
    b:[f64;a]
    }
    let mut c:f64=0.0;
    for i in 0..a {
        c+=b[i];
    }
    c/=a as f64;
    let mut y=10000000000.0;
    let mut z=0;
    for i in 0..a {
        if (c-b[i]).abs()<y{z=i;y=(c-b[i]).abs();}
    }
    println!("{}",z)
}

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

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

    int ct = 0, cx = 0, cy = 0;
    int t, x, y;
    for (int i = 0; i < N; ++i) {
        std::cin >> t >> x >> y;

        const int dt = t - ct;
        const int dist = std::abs(x - cx) + std::abs(y - cy);

        if (dt < dist) {
            std::cout << "No\n";
            return 0;
        }

        if (dist % 2 != dt % 2) {
            std::cout << "No\n";
            return 0;
        }

        ct = t;
        cx = x;
        cy = y;
    }

    std::cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))

Q = [(p + 1) / 2 for p in P]
now = sum(Q[:K])
ans = now
for i in range(N - K):
    now -= Q[i]
    now += Q[i + K]
    ans = max(ans, now)
print(ans)

Measured memory_bytes: 25060
n,m = map(int,input().split())
cnt=[]
l=[int(input()) for _ in range(m)]
for i in range(n+1):
    cnt.append(-1)
for i in range(m):
    cnt[l[i]]=0
cnt[0]=1
for i in range(1,n+1):
    if cnt[i]==0:
        continue
    else:
        cnt[i]=cnt[i-1]
        if i>1:
            cnt[i]+=cnt[i-2]
#print(cnt)
print(cnt[n]%1000000007)



Measured memory_bytes: 466104
//Prime Numbers
#include <iostream>
#include <cmath>

using namespace std;

bool isPrimeNumber(int n) {
    if(n < 2) return false;
    if(n == 2) return true;
    if(n % 2 == 0) return false;
    for(int i = 3; i <= sqrt(n); i += 2) {
        if(n % i == 0) return false;
    }
    return true;
}

int main() {
    int N, n, cnt = 0;
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> n;
        if(isPrimeNumber(n)) cnt++;
    }
    cout << cnt << endl;
}



Measured memory_bytes: 3084
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

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

#include <bits/stdc++.h>

using namespace std;

vector<int> v[22];
int fn;
int M =1e9+7;

int dp[22][1<<21];

int fun(int ms, int n){
    // cout<<ms<<" "<<n<<endl;
    if(ms==fn)return 1;
    if(n==0)return 0;
    // cout<<ms <<" "<<n<<" "<<dp[n][ms]<<endl;
    if(dp[n][ms]!=-1)return dp[n][ms];
    
    long long int ans =0;
    
    // ans+=fun(ms,n-1);
    ans%=M;
    for(int i=0;i<v[n].size();i++){
        if(!(ms&(1<<(-1+v[n][i])))){
            ans+=fun(ms|(1<<(-1+v[n][i])),n-1);
            
        }
    }
  ans%=M;
    // cout<<ans<<" ans "<<endl;
    return dp[n][ms]=ans;
    
}

int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin>>n;
    int a;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++){
            cin>>a;
            if(a)v[i].push_back(j);
        }
    
    fn = 1<<n;fn--;
    
    for(int j=1;j<=n;j++) 
        for(int i=0;i<fn;i++)dp[j][i]=-1;
    
    // cout<<"here "<<endl;
    cout<<fun(0,n)<<endl;
    return 0;
}


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

int main() {
    string s;
    int n, q;
    cin >> n >> q;
    cin >> s;

    vector<int> l(q), r(q);

    for (int i = 0; i < q; i++) {
      cin >> l[i] >> r[i];
    }

    // 累積和用vector
    vector<int> sum(n+1, 0);
    sum[0] = 0;
    sum[1] = 0;
    for (int i = 2; i < n + 1; i++) {
      sum[i] = sum[i - 1];
      if (s[i - 1] == 'C' && s[i - 2] == 'A') {
        sum[i]++;
      }
    }

    for (int i = 0; i < q; i++) {
      cout << sum[r[i]] - sum[l[i]] << endl;
    }     
}

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

typedef long long int ll;

ll powk(ll a, ll n = 2){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}


int main()
{
    vector<ll> cnt(10000010, 1);
    ll n;
    cin >> n;
    for(ll i = 2;i <= n;i++){
        ll t = i;
        while(t < cnt.size()){
            cnt[t - 1]++;
            t += i;
        }
    }

    ll ans = 0;

    for(ll i = 0;i < n;i++){
        ans += (i + 1) * cnt[i];
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 81224
#include<bits/stdc++.h>
using namespace std;
long long n,h[100010],dp[100010],k;

int main()
{
	scanf("%lld %lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&h[i]);
	}
	for(int i=2;i<=n;i++)
	{
	//	printf("%d %d %d %d\n",dp[i-1],dp[i-2],h[i-1]-h[i],h[i-2]-h[i]);
		for(int j=1;j<=k;j++)
		{
			if(i>j)
			{
				if(j==1)dp[i] = dp[i-j]+abs(h[i-j]-h[i]);
				else dp[i] = min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
			}
		}
	//	printf("%d. %d\n",i,dp[i]);
	}
	printf("%lld\n",dp[n]);
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
a = [int(i) for i in input().split()]
b = [i for i in a if i <= 10**5]
ans = len(a)-len(b)
import collections
c = collections.Counter(b)
for i in range(0,10**5+1):
  if c[i] < i:
    ans += c[i]
  if c[i] > i:
    ans += c[i]-i
print(ans)

Measured memory_bytes: 14268
extern crate core;

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    let list = input.split_whitespace().collect::<Vec<_>>();
    let a = list[0].parse::<i32>().unwrap();
    let b = list[1].parse::<i32>().unwrap();
    let s = list[2];
    if s.len() != (a + b + 1) as usize {
        "No"
    } else {
        if s.chars().enumerate().all(|(i, c)| {
            if i == a as usize {
                c == '-'
            } else {
                c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6'
                    || c == '7' || c == '8' || c == '9'
            }
        }) {
            "Yes"
        } else {
            "No"
        }
    }.to_string()
}

#[test]
fn test() {
    let tests = vec![
        ("3 4\n269-6650", "Yes"),
        ("1 1\n---", "No"),
        ("1 2\n7444", "No"),
    ];
    for (i, (input, output)) in tests.into_iter().enumerate() {
        println!("test:{}", i);
        assert_eq!(run(input.to_string()), output.to_string());
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int p[25252];
int a[25252],b[25252];
int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",p+i);
  REP(i,n)a[i] = (i+1)*20000;
  REP(i,n)b[i] = (n-i)*20000;
  int bef = 0;
  REP(i,n){
    int x = p[i]-1;
    a[x] += i;
    b[x] += i;
  }
  REP(i,n){
    printf("%d",a[i]);
    if(i==n-1)putchar('\n');
    else putchar(' ');
  }
  REP(i,n){
    printf("%d",b[i]);
    if(i==n-1)putchar('\n');
    else putchar(' ');
  }
  return 0;
}


Measured memory_bytes: 896
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
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);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
int solve()
{
	int n,m;
	cin>>n>>m;
	if(n==m)
		cout<<"Yes";
	else
		cout<<"No";



}
signed main()
{
	fastio;
	clock_t start, end;
//	test
	{
		start=clock();
		solve();
		end=clock();
		double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
//		cout<<time_taken<<endl;
	}
}


Measured memory_bytes: 256
use proconio::input;
use std::collections::HashMap;
use MyEither::{IsPrime, NotPrime, Undecided};

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let limit = 1000000;
    let m = 1000000007;
    let mut map = HashMap::new();
    let mut sieve: Vec<MyEither<usize>> = vec![Undecided; limit + 1];
    let mut num = 2;

    while num <= limit {
        if sieve[num] == Undecided {
            sieve[num] = IsPrime;
            let mut tmp = num * num;
            while tmp <= limit {
                sieve[tmp] = match &sieve[tmp] {
                    Undecided => NotPrime(num),
                    n => *n,
                };
                tmp += num;
            }
        }
        num += 1;
    }

    for &na in &a {
        let tmp = prime_factorize_fast(na, &sieve);
        for (&key, &value) in &tmp {
            let count = map.entry(key).or_insert(0);
            if *count < value {
                *count = value;
            }
        }
    }

    let mut lcm = 1usize;
    for (key, value) in &map {
        let mut tmp = 1;
        for _ in 0..*value {
            tmp = tmp * key % m;
        }
        lcm = lcm * tmp % m;
    }

    let mut ans = 0usize;
    for &na in &a {
        ans = ans + lcm * modinv(na as isize, m as isize) as usize % m;
        ans %= m;
    }

    println!("{}", ans);
}

#[derive(Clone, Copy, PartialEq)]
enum MyEither<T> {
    IsPrime,
    NotPrime(T),
    Undecided,
}

fn prime_factorize_fast(mut n: usize, sieve: &Vec<MyEither<usize>>) -> HashMap<usize, usize> {
    let mut res = HashMap::new();

    while sieve[n] != IsPrime {
        match &sieve[n] {
            NotPrime(num) => {
                let entry = res.entry(*num).or_insert(0);
                *entry += 1;
                n = n / *num;
            }
            _ => break,
        }
    }
    let entry = res.entry(n).or_insert(0);
    *entry += 1;

    res
}

fn prime_factorize(mut n: usize) -> Vec<(usize, usize)> {
    let mut res = vec![];
    let mut a = 2;
    while a * a <= n {
        if n % a != 0 {
            a += 1;
            continue;
        }
        let mut ex = 0;

        while n % a == 0 {
            ex += 1;
            n /= a;
        }

        res.push((a, ex));
        a += 1;
    }
    if n != 1 {
        res.push((n, 1));
    }

    res
}

use std::mem;

fn modinv(mut a: isize, m: isize) -> isize {
    let mut b: isize = m;
    let mut u: isize = 1;
    let mut v = 0;

    while b != 0 {
        let t = a / b;
        a -= t * b;
        mem::swap(&mut a, &mut b);
        u -= t * v;
        mem::swap(&mut u, &mut v);
    }

    u %= m;

    if u < 0 {
        u += m;
    }
    u
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define pb push_back

#define INF int(1e9)
#define EPS 1e-9
#define MOD int(1e9 + 7)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int a, b, c;
	cin >> a >> b >> c;
	cout << (c - min(c, a - b)) << '\n';
	return 0;
}


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


int main(){
long long n,m;
cin>>n>>m;
vector<pair<long long,long long> > v(n);
long long ans=0;
for(long long i=0;i<n;i++){
    cin>>v[i].first>>v[i].second;
   
}
sort(v.begin(),v.end());
long long cnt=0;
for(long long i=0;i<v.size();i++){
ans+=v[i].first*v[i].second;
cnt+=v[i].second;
if(cnt>=m){
    ans-=(cnt-m)*v[i].first;
    break;
}
}

cout<<ans;
        return 0;

}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, m, x[1001], y[1001], z[1001], mmax = 0, result = 0;
  ll one[8] = {1, 1, 1, 1, -1, -1, -1, -1};
  ll two[8] = {1, 1, -1, -1, 1, 1, -1, -1};
  ll thr[8] = {1, -1, 1, -1, 1, -1, 1, -1};
  cin >> n >> m;
  rep(i, n) {
    cin >> x[i] >> y[i] >> z[i];
  }
  rep(i, 8) {
    vector<int> v;
    rep(j, n) {
      v.pb(x[j] * one[i] + y[j] * two[i] + z[j] * thr[i]);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    ll sum = 0;
    rep(j, m) {
      sum += v[j];
    }
    result = max(result, sum);
  }
  cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005
 
typedef struct pp {
    char name[100];
    int t;
}P;
 
P Q[LEN];
int head, tail, n;
 
void enqueue(P x) {
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}
 
P dequeue() {
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}
 
int min(int a, int b) { return a < b ? a : b; }
 
int main() {
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);
 
    for (i = 1; i <= n; i++) {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1; tail = n + 1;
 
    while (head != tail) {
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if (u.t > 0)enqueue(u);
        else {
            printf("%s %d\n", u.name, elaps);
        }
    }
    return 0;
}


Measured memory_bytes: 11832
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
string s;cin >> s;
for(int i = 0; i < 12; ++i){
cout << s[i];
if(i==3)cout << " ";
}
cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
     
int main() {
    int n;
    cin >> n;
    int a[n];
    int b = 0;
    for (int i = 0;i < n;i++) {
    	cin >> a[i];
    	while (a[i]%2 != 1) {
    		b++;
    		a[i]/=2;
    	}
    }
    cout << b;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) {
    res[n]++;
  }
  return res;
}

long long gcd(long long a, long long b) {
  if (b == 0) return a;

  return gcd(b, a % b);
}

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

long long modpow(long long a, long long b) {
  a %= MOD;
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a) % MOD;
    }
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}

long long modinv(long long a) {
  long long b = MOD, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) u += MOD;
  return u;
}

ll N;
ll A[10101];
ll B[10101];

int main() {
  cin >> N;
  map<ll, ll> lcmfac;
  rep(i, 0, N) {
    cin >> A[i];
    auto mp = prime_factor(A[i]);
    for (auto e : mp) {
      chmax(lcmfac[e.first], e.second);
    }
  }

  ll lcmmod = 1;
  for (auto e : lcmfac) {
    lcmmod *= modpow(e.first, e.second);
    lcmmod %= MOD;
  }

  ll ans = 0;
  rep(i, 0, N) {
    ans += lcmmod * modinv(A[i]) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,ret=0; cin>>n;
	for (int i=1; i<=n; i++) {
		string cur=to_string(i);
		if(cur.size()%2)
			ret++;
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256
use std::io::prelude::*;

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

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

#[allow(unused_macros)]
macro_rules! debug {
    ($var:expr) => {
        match &$var { v => eprintln!(concat!(stringify!($var), "={:?}"), v) }
    };
    ($var:expr, $($vars:expr),*) => {
        match &$var { v => eprint!(concat!(stringify!($var), "={:?} "), v) }
        debug!($($vars),*);
    };
}

fn main() {
    let n: i64 = input();

    println!("{}", dfs(0, n, false, false, false));
}

fn dfs(x: i64, n: i64, has7: bool, has5: bool, has3: bool) -> i64 {
    if x > n {
        0
    } else {
        let mut ans = if has7 && has5 && has3 { 1 } else { 0 };
        ans += dfs(x * 10 + 7, n, true, has5, has3);
        ans += dfs(x * 10 + 5, n, has7, true, has3);
        ans += dfs(x * 10 + 3, n, has7, has5, true);
        ans
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e10;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    ll n,k,s;
    cin >> n >> k >> s;
    ll a;
    if (k == n){
        a = s;
        rep(i,n-1) cout << a << ' ';
        cout << a << endl;
    }
    else if (s == 1){
        rep(i,k) cout << 1 << ' ';
        rep(i,n-k-1) cout << 1000000000 << ' ';
        cout << 1000000000 << endl;
    }
    else if (s == 1000000000){
        rep(i,k) cout << s << ' ';
        rep(i,n-k) cout << 1 << ' ';
        cout << endl;
    }
    else{
        rep(i,k){
            cout << s << ' ';
        }
        rep(i,n-k) cout << 1000000000 << ' ';
        cout << endl;
    }
}

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


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  vector<ll> v(3);
  for (int i = 0; i < 3; i++) {
    cin >> v.at(i);
    if (v.at(i) % 2 == 0) {
      cout << "0\n";
      return 0;
    }
  }
  sort(v.begin(), v.end());
  cout << v.at(0) * v.at(1) << endl;
  

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	//input
	ll D, G;
	cin >> D >> G;
	vector<ll> p(D), c(D);
	for (int i = 0; i < D; i++) {
		cin >> p[i] >> c[i];
	}

	string s;
	ll score, total_prob, min_total_prob = INF, tmp;
	int last_zero = -1;
	for (int j = 0; j < int(round(pow(2, D))); j++) {
		score = 0;
		total_prob = 0;
		s = bitset<10>(j).to_string();
		for (int i = 9; i >= 10 - D; i--) {
			if (s[i] == '1') {
				score += 100 * (10 - i) * p[10 - i - 1] + c[10 - i - 1];
				total_prob += p[10 - i - 1];
			}
			else {
				last_zero = 10 - i;
			}
		}
		if (score >= G) {
			if (min_total_prob > total_prob) {
				min_total_prob = total_prob;
			}
		}
		else {
			tmp = ceil((double)(G - score) / (100 * last_zero));
			if (tmp > p[last_zero - 1]) {
				continue;
			}
			else {
				total_prob += ceil((double)(G - score) / (100 * last_zero));
				if (min_total_prob > total_prob) {
					min_total_prob = total_prob;
				}
			}

		}
	}

	cout << min_total_prob;
	return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val src: List[List[Int]] = io.Source.stdin.getLines.map(_.split(",").toList.map(_.toInt)).toList
  val org: List[Int] = List.range(1, src.head(0) + 1)
  val operations: List[List[Int]]= src.drop(2)

  def func(org: List[Int], li: List[Int]): List[Int] = {
    org.updated(li(0)-1, org(li(1)-1)).updated(li(1)-1, org(li(0)-1))
  }

  ((org /: operations)(func)).foreach(println)
}

Measured memory_bytes: 45036
##2^(|S|-1)
from copy import deepcopy
from collections import deque

S = input()

s = deque([])
for i in S:
    s += [i]
    s += [""]
s.pop()

ans = 0
l = len(S)

for n in range(2**(l-1)):
    tmp = deepcopy(s)
    for i in range(l-1):
        if (n>>i)&1:
            tmp[2*i+1] = "+"
    ans += eval("".join(tmp))

print(ans)

Measured memory_bytes: 3572
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);



int main(){
	FAST_IO
	
	string input; cin >> input;
	int Q, op; cin >> Q;
	bool rev = false;
	char c;
	deque<char> front, rear;
	
	auto util = [&](char add, bool key){
		if(rev ^ key) front.push_back(add);
		else rear.push_back(add);
	};
	
	auto print = [&](deque<char> &a, bool role){
		while(!role && !a.empty()){
			cout << a.front();
			a.pop_front();
		}
		
		while(role && !a.empty()){
			cout << a.back();
			a.pop_back();
		}
	};
	
	while(Q--){
		cin >> op;
		if(op == 1) rev ^= true;
		else{
			cin >> op;
			cin >> c;
			util(c, (op == 1));
		}
	}
	
	if(rev){
		print(rear, true);
		reverse(ALL(input));
		cout << input;
		print(front, false);
	}else{
		print(front, true);
		cout << input;
		print(rear, false);
	}
	
	
	return 0;
}


Measured memory_bytes: 848
#include<iostream>
#include<string.h>

int n;
int a[5001];

void add( int i, int x )
{	
	while( i <= n ){
		a[i] += x;
		i += i & (-i);
	}
	
	return;
}

int sum( int i )
{
	if( i == 0 ) return 0;

	int s = 0;
	while( i > 0 ){
		s += a[i];
		i -= i & (-i);
	}
	
	return s;
}

int main()
{
	while( 1 ){
		memset( a, 0, sizeof( a ) );
	
		std::cin >> n;
		if( !n ) break;
		
		for( int i = 1; i <= n; i++ ){
		 	int x;
			std::cin >> x;
			add( i, x );
		}
		
		int ans = -100001;
		
		for( int i = 0; i < n; i++ ){
		 	for( int j = i + 1; j <= n; j++ ){
				ans = std::max( ans, sum( j ) - sum( i ) );
			}
		}
		
		std::cout << ans << std::endl;
	}
	
 	return 0;
}

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

int main(){
    ll a, b;  cin >> a >> b;
    if(a*b <= 0) cout << "Zero" << endl;
    else if(a > 0) cout << "Positive" << endl;
    else if((b - a + 1)%2 == 0) cout << "Positive" << endl;
    else cout << "Negative" << endl;
}

Measured memory_bytes: 256
mod = 10**9+7
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)

if len(a) != len(set(a)) or len(b) != len(set(b)):
    print(0)
    exit()

a = set(a)
b = set(b)

c = 1
N = 0
M = 0
for k in range(n*m, 0, -1):
    if k in a and k in b:
        N += 1
        M += 1
    elif k in a:
        c *= M
        N += 1
    elif k in b:
        c *= N
        M += 1
    else:
        c *= M*N - (m*n-k)
    c %= mod

print(c)


Measured memory_bytes: 3188
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <fstream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <algorithm>
using namespace std;
# define pi acos(-1.0)
# define IOS ios::sync_with_stdio(false)
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define For(i,n,a) for(int i=n; i>=a; --i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define Fo(i,n,a) for(int i=n; i>a ;--i)
typedef long long LL;
typedef unsigned long long ULL;
inline int Scan() {
    int 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;
}
///coding...

int main()
{
#ifdef FLAG
    freopen("in.txt","r",stdin);
#endif /// FLAG
    int a;
    cin>>a;
    cout<<"ABC"<<a<<endl;
    return 0;
}
///delete # define FLAG...

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    cout << v[n-1]-v[0] << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		long k = saori.saorihayami();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i =0;i < n;i++){
			a[i] = saori.saori_hayami();
			b[i] = saori.saori_hayami();
		}
		long[] sort = new long[1000001];
		for(int i = 0;i < n;i++){
			sort[a[i]] += b[i];
		}

		for(int i = 1;i < sort.length;i++){
			if(sort[i] >= k){
				System.out.println(i);
				break;
			}
			k -= sort[i];
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 42392
import Data.Bool

main = do
 [n,a,b,c,d] <- map read . words <$> getLine :: IO [Integer]
 putStrLn $ bool "NO" "YES" $ moderate n a b c d

moderate n a b c d = any (within b) [(a + i*d + j*c, a + i*c + j*d) | i<-[-(n-1)..0], let j = (n-1) - abs i]

within x (a,b) = a <= x && x <= b

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define li          long
#define ll          long long
#define ull         unsigned long long
#define ff          first
#define ss          second
#define pii         pair<int,int>
#define pli         pair<li,li>
#define pll         pair<ll,ll>
#define pb          push_back
#define fo(i,k,n)   for(int i = k;i<n; i++)
#define ro(i,k,n)   for(int i = k; i>=n; i--)
#define fd(i,k,n,d) for(int i = k; i<n; i+=d)
#define tc          int t;cin>>t;while(t--)
#define all(v)      v.begin(),v.end()
#define inf         INT_MAX
#define ninf        INT_MIN
#define W(x)        cout<<x<<endl
#define WW(x,y)     cout<<x<<' '<<y<<endl;
#define in(x)       cin>>x
#define v(x)        vector<x>
#define int         long long
#define ar(x,y)       array<x,y>
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

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

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

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

template<class T>
T power(T a,T b){
    T res = (T)1;
    while(b>0){
        if(b&1)res = res*a;
        b>>=1;
        a*=a;
    }
    return res;
}

template<class T>
T power(T a,T b,T m){
    T res = (T)1;
    a%=m;
    while(b>0){
        if(b&1)res = (res*a)%m;
        b>>=1;
        a = (a*a)%m;
    }
    return res;
}

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

struct dsu{
  map<int,int> pr,sz;
  dsu(){
    (this->pr).clear();
    (this->sz).clear();
  }
  void make(int x){
    pr[x] = x;
    sz[x] = 1;
  }
  int getpar(int x){
    if(pr[x] == x)return x;
    return pr[x] = getpar(pr[x]);
  }
  void merge(int x,int y){
    x = getpar(x);
    y = getpar(y);
    if(sz[x]<sz[y])swap(x,y);
    pr[y] = x;
    sz[x]+=sz[y];
    sz[y] = 0;
  }
};

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


void solve(){
  int n;
  cin>>n;
  v(string) a(n);
  fo(i,0,n)cin>>a[i];
  v(int) ans(4,0);
  for(int i = 0; i<n; i++){
    if(a[i] == "AC")ans[0]++;
    if(a[i] == "WA")ans[1]++;
    if(a[i] == "TLE")ans[2]++;
    if(a[i] == "RE")ans[3]++;
  }
  cout<<"AC "<<"x "<<ans[0]<<"\n";
  cout<<"WA "<<"x "<<ans[1]<<"\n";
  cout<<"TLE "<<"x "<<ans[2]<<"\n";
  cout<<"RE "<<"x "<<ans[3]<<"\n";
}

signed main(){
    fastio();
    int cs = 1;
    //cin>>cs;
    while(cs--){
        solve();
    }
}


Measured memory_bytes: 6368
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	string s;
	int n;
	cin >> n >> s;
	vector<bool> ok(n,false);
	int numl=0,numr=0;
	REP(i,n){
		if(s[i]=='(') numl++;
		else numr++;
	}
	
	bool flag=false;
	do{
		flag = false;
		int r=-1;
		REP(i,n){
			if(ok[i]) continue;
			if(s[i]=='('){
				r = i;
			}else{
				if(r!=-1){
					ok[i] = true;
					ok[r] = true;
					numr--;
					numl--;
					r = -1;
					flag = true;
				}
			}
		}
	}while(flag);
	
	string ans;
	if(numr!=0 && numl != 0){
		ans = string(numr,'(') + s + string(numl, ')');
	}else if(numr!=0){
		ans = string(numr,'(') + s;
	}else if(numl!=0){
		ans = s+string(numl, ')');
	}else{
		ans = s;
	}
	
	cout << ans << endl;
	
	
	
	return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main{
	public static void main(String[] args){

		GetNum test = new GetNum();
		test.ChangeSec();
			
	}
}

class GetNum{
	public void ChangeSec(){
		
			String sec = new Scanner(System.in).nextLine()	;
			int num = Integer.parseInt(sec);
			int test = num / 60;

			int h = test / 60;
			int m = test % 60;
			int s = num % 60;

			System.out.println(h + ":" + m + ":" + s); 

		}
}

Measured memory_bytes: 26208
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N = int(input())

if N % 2 == 0:
    print(0.5)
else:
    print(1.0-((N-1)//2.0)/N)


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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N, Q;
	ll S, T;
	cin >> N >> Q >> S >> T;
	vector<ll> A(N + 1);
	for (int i = 0; i < N + 1; i++) {
		cin >> A[i];
	}
	ll tem = 0;
	vector<ll> d(N);
	for (int i = 0; i < N; i++) {
		d[i] = A[i + 1] - A[i];
		if (d[i] >= 0) {
			tem -= d[i] * S;
		}
		else {
			tem -= d[i] * T;
		}
	}
	while (Q--) {
		int L, R, X;
		cin >> L >> R >> X; L--;
		if (d[L] >= 0) {
			tem += d[L] * S;
		}
		else {
			tem += d[L] * T;
		}
		d[L] += X;
		if (d[L] >= 0) {
			tem -= d[L] * S;
		}
		else {
			tem -= d[L] * T;
		}
		if (R < N) {
			if (d[R] >= 0) {
				tem += d[R] * S;
			}
			else {
				tem += d[R] * T;
			}
			d[R] -= X;
			if (d[R] >= 0) {
				tem -= d[R] * S;
			}
			else {
				tem -= d[R] * T;
			}
		}
		printf("%lld\n", tem);
	}
	return 0;
}



Measured memory_bytes: 6016
#include <stdio.h>

int main(void)
{
    int x;
      
    scanf("%d",&x);
  
    int n={x},a={0};
  
     while(n>0) {
          a+=n%10;
          n=n/10;
     }
     
     if(x%a==0) printf("Yes\n");
     else printf("No\n");
  
     return 0;
}  
 

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int mod = (int)1e9+7;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	set<string> ans;
	string s;
	map<string,int> mp;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		mp[s]++;
	}
	int cnt = 0;
	for(auto p: mp){
		if(cnt<p.second){
			cnt = p.second;
		}
	}
	
	for(auto p : mp){
		if(p.second == cnt){
			ans.insert(p.first);
		}
	}
	for( string x : ans){
		cout<<x<<"\n";
	}
	
	
	
	return 0;
}









Measured memory_bytes: 33280
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int D1, D2;
int N2;
vector<pair<int, int> > P1, P2;

void build(vector<pair<int, int> > &p, int d) {
    REP (i, N2) REP (j, N2) if (i*i + j*j == d) {
	p.emplace_back(i, j);
	p.emplace_back(-i, j);
	p.emplace_back(i, -j);
	p.emplace_back(-i, -j);
    }
}
bool in(int y, int x) {
    return 0 <= y && y < N2 && 0 <= x && x < N2;
}

int S[611][611];
int C[16];

void MAIN() {
    scanf("%d%d%d", &N, &D1, &D2);
    N2 = N+N;
    build(P1, D1);
    build(P2, D2);

    vector<pair<int, int> > st;
    REP (t, 2) {
	int mask = 5<<t;
	const vector<pair<int, int> > &P = (t? P2: P1);
	REP (i, N2) REP (j, N2) if ((S[i][j] & mask) == 0) {
	    S[i][j] |= 1<<t;
	    st.emplace_back(i, j);
	    while (!st.empty()) {
		int y = st.back().first;
		int x = st.back().second;
		st.pop_back();
		EACH (e, P) {
		    int yy = y + e->first;
		    int xx = x + e->second;
		    if (in(yy, xx) && (S[yy][xx]&mask) == 0) {
			S[yy][xx] |= mask & ~S[y][x];
			st.emplace_back(yy, xx);
		    }
		}
	    }
	}
    }

    REP (i, N2) REP (j, N2) C[S[i][j]]++;
    int k = max_element(C, C+16) - C;
    int cnt = 0;
    REP (i, N2) REP (j, N2) if (S[i][j] == k && cnt < N*N) {
	cnt++;
	printf("%d %d\n", i, j);
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    bool x = false;
    for(int i = 0; i <= K; i++)
    {
        int CC = C, BB = B;
        CC *= pow(2, i);
        BB *= pow(2, K - i);
        if (BB > A && CC > BB)
            x = true;
    }
    cout << (x ? "Yes" : "No");
}

Measured memory_bytes: 4000
#author : dokueki

import sys
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    n, m = map(int, sys.stdin.readline().split())
    a = list(map(int, sys.stdin.readline().split()))
    s = sum(a)
    if s > n:
        print(-1)
    else:
        print(n-s)


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()


Measured memory_bytes: 68072
import java.util.Scanner;
public class Main {


    public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
        int N= scan.nextInt();
       long A[]=new long[N+1];
       long s=1;
int K=1;
int OOO=1;
int KK=0;
       for(int i=0;i<N;i++){A[i]= scan.nextLong();
           if(A[i]==0){s=0;}
       }

        for(int i=0;i<N&&s>0&&KK<19;i++){
            s=s*A[i];
            String m=String.valueOf(s-1);
            K=m.length();
            String j=String.valueOf(A[i+1]);
            KK=K+j.length()-1;

        }

if (s<0||KK>=19){s=-1;}
System.out.println(s);

    }
}







Measured memory_bytes: 50832
#include <stdio.h>

#define SIZE 2000000

int main() {
  static int A[SIZE];
  int H=0;
  int i, l, largest, tmp, n;
  static char com[21], buf[20];
  buf[19]='\n';
  char *p;
  do {
    fgets(com, 20, stdin);
    if (*com == 'i') {
      A[++H] = 0;
      p = com+7;
      do {
        A[H] = A[H]*10+*p-'0';
        p++;
      } while (*p&0x20);

      for (i=H; i>1 && A[i>>1]<A[i];i>>=1) {
        tmp = A[i>>1];
        A[i>>1] = A[i];
        A[i] = tmp;
      }

    } else if (com[1]=='x') { // extract
      n = A[1];
     for (i=18; n>0; n/=10) buf[i--]=(n%10)+'0';
      fputs(buf+i+1, stdout);
      A[1] = A[H];
      i = 1;
      do {
        l = i<<1;
        if (l < H && A[l] > A[i])        largest = l;
        else         largest = i;
        if (l+1 < H && A[l+1] > A[largest])  largest = l+1;
        if (largest == i) break;
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        i = largest;
      } while (1);
      H--;
    }
  } while (com[2]!='d');
  return 0;
}


Measured memory_bytes: 5496
#include <iostream>
#include <vector>

using namespace std;

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

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

    __int128 res = 1;
    for (int i = 0; i < n; i++) {
        if (res > 0) {
            res *= a[i];
        }

        if (a[i] == 0) {
            res = 0;
        } else if (res > 1000000000000000000L) {
            res = -1;
        }
    }

    cout << static_cast<long long>(res) << endl;
}



Measured memory_bytes: 3976