akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll a[200005];
bool used[200005];

int main(void){
    scanf("%d",&n);
    vector<ll> vec;
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        vec.push_back(a[i]);
    }
    sort(vec.begin(),vec.end());
    int cnt=0;
    for(int i=35;i>=0;i--){
        vector<ll> que;
        memset(used,false,sizeof(used));
        int r=vec.size()-1;
        //printf("%d\n",r);
        for(int j=0;j<vec.size();j++){
            ll v=(1LL<<i)-vec[j];
            while(r>=0 && vec[r]>v)r--;
            if(v<=0LL || r==-1)continue;
            //printf("%d %d %d %lld %lld\n",i,j,r,vec[r],v);
            if(vec[r]==v && j<r){
                used[r]=true;
                used[j]=true;
                r--;
                cnt++;
            }
        }
        for(int j=0;j<vec.size();j++){
            if(!used[j]){
                que.push_back(vec[j]);
            }
        }
        vec.clear();
        for(int j=0;j<que.size();j++){
            vec.push_back(que[j]);
        }
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 7828
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  ll N;
  cin>>N;
  vector<ll> X(N);
  vector<ll> A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);
  ll S=A.at(N-1);
  for(int i=0;i<N-1;i=i+2) S=S+A.at(i)-A.at(i+1);
  X.at(0)=S;
  for(int i=0;i<N-1;i++) X.at(i+1)=2*A.at(i)-X.at(i);
  for(int i=0;i<N;i++) cout<<X.at(i)<<" ";  
return 0;}

Measured memory_bytes: 4840
#include <bits/extc++.h>
using namespace std;
using i64=int64_t;

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

    int n; cin>>n;
    i64 ans=0;
    i64 acc=0;
    int mod=1e9+7;
    for(int i=0; i<n; ++i)
    {
        i64 a; cin>>a;
        ans+=a*acc%mod;
        if(ans>=mod) ans-=mod;
        acc+=a;
        if(acc>=mod) acc-=mod;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 3652
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N,A,B;
bool ans[100009];
string s;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>A>>B>>s;
    
    int tot=0,cntb=0;
    rep(i,s.size()){
        char c=s[i];
        if(c=='a'){
            ans[i]=1;
            tot++;
        }else if(c=='b'&&cntb<B){
            ans[i]=1;
            tot++;
            cntb++;
        }
        if(tot>=A+B) break;
    }
    
    rep(i,N){
        cout1((ans[i]?"Yes":"No"))
    }
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

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

  map<int, ll> prime_factor_cnt;
  for (int i = 2; i <= N; ++i) {

    int k = i;
    for (int j = 2; k > 1;) {
      if (k % j == 0) {
        prime_factor_cnt[j]++;
        k /= j;
      } else {
        j++;
      }
    }
  }

  ll ans = 1;
  for (auto v : prime_factor_cnt) {
    ans = ans*(v.second+1)%mod;
  }

  cout << ans << endl;
}

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

#define int long long
const int N = 1e5 + 10 ;
int dp[N] ;
vector<int> g[N] ;

int solve(int start){
	if(~dp[start]) return dp[start] ;
	dp[start] = 0 ;
	for(auto i : g[start]){
		solve(i) ;
		dp[start] = max(1 + dp[i] , dp[start]) ;
	}
	return dp[start] ;
}

int32_t main(){
	int n , m ;
	cin >> n >> m ;
	memset(dp , -1 , sizeof(dp)) ;
	for(int i = 0 ; i < m ; i++){
		int f , s ;
		cin >> f >> s ;
		f-- , s-- ;
		g[f].push_back(s) ;
	}
	int ans = 0 ;
	for(int i = 0 ; i < n ; i++){
		ans = max(ans , solve(i)) ;
	}
	cout << ans ;
	return 0 ;
}



Measured memory_bytes: 11756
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
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;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
	int n,m;
	cin>>n>>m;
	vi x(m),y(m);
	REP(i,m){
		cin>>x[i]>>y[i];
	}
	vector<map<int,int>> ma(n+100);
	REP(i,m){
		ma[x[i]][y[i]]++;
	}
	REP(i,n+1){
		int cnt=1;
		for(auto itr:ma[i]){
			ma[i][itr.fi]=cnt;
			cnt++;
		}
	}
	REP(i,m){
		printf("%06d%06d\n",x[i],ma[x[i]][y[i]]);
	}
	return 0;
}

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

int main (){
    ll n;
    cin>>n;
    string s[n];
    for(ll i=0;i<n;i++){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
    }
    sort(s,s+n);
    ll count=1,ans=0;
    for(ll i=1;i<n;i++){
        if(s[i]==s[i-1])    count++;
        else{
            ans+=count*(count-1)/2;
            count=1;
        }
    }
    ans+=count*(count-1)/2;
    cout<<ans;
    return 0;
}

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

int main(){
  string s,t,ans="";cin>>s>>t;
  REP(i,s.size()-t.size()+1){
      string tmp="";
      bool f=0;
      REP(j,s.size()){
          if(i<=j && j<i+t.size()){
              if(s.at(j)=='?' || s.at(j)==t.at(j-i)) tmp.push_back(t.at(j-i));
              else{
                  f=1;
                  break;
              }
          }else{
              if(s.at(j)=='?') tmp.push_back('a');
              else tmp.push_back(s.at(j));
          }
      }
      if(!f&&(ans=="" || (ans!="" && tmp<ans))) ans=tmp;
  }

  cout<<(ans==""?"UNRESTORABLE":ans);
}

Measured memory_bytes: 256
from collections import deque

k = int(input())

ans = deque([i for i in range(1, 10)])

for i in range(k):
    x = ans.popleft()
    modx = x%10
    if modx != 0:
        ans.append(x*10 + modx - 1)
    ans.append(x*10 + modx)
    if modx != 9:
        ans.append(x*10 + modx + 1)
print(x)


Measured memory_bytes: 11956
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
import numpy as np
# from copy import deepcopy
from collections import deque
import numba

N = int(input())
P = np.array(list(map(int, sysread().split())))
#@numba.njit("void(i8,i8[:])")
@numba.njit
def run():
    seats = np.zeros((N,N), dtype=np.int16)
    seen = np.zeros((N,N), dtype=np.int8)  # there is a person : 1
    up, down = 0, N - 1
    dist = 0
    while True:
        seats[up, up:down+1] = dist
        seats[down, up:down+1] = dist
        seats[up:down+1, up] = dist
        seats[up:down+1, down] = dist
        up += 1
        down -= 1
        dist += 1
        if up > down:
            break

    ret = 0
    ###
    for i in range(N ** 2):
        # print(seats)
        cur_i, cur_j = (P[i] - 1) // N, (P[i] - 1) % N
        ret += seats[cur_i,cur_j]
        seen[cur_i,cur_j] = 1
        stack = [(cur_i, cur_j)]
        while stack:
            cur_i, cur_j = stack.pop()
            for i, j in ((1, 0), (0, 1), (-1, 0), (0, -1)):
                n_i = cur_i + i
                n_j = cur_j + j
                del_val = seats[cur_i, cur_j]
                if 0 <= n_i <= N - 1 and 0 <= n_j <= N - 1:
                    if seen[cur_i, cur_j]:
                        if del_val < seats[n_i, n_j]:
                            seats[n_i, n_j] = del_val
                            stack.append((n_i, n_j))
                    else:
                        if del_val + 1 < seats[n_i, n_j]:
                            seats[n_i, n_j] = del_val + 1
                            stack.append((n_i, n_j))

    print(ret)


if __name__ == "__main__":
    run()

Measured memory_bytes: 135116
#include<iostream>
#include<vector>
#include<map>
#include<queue>
using namespace std;

int main() {
	int N, M;
	cin>>N>>M;
	int X[M], Y[M], Z[M];
	for(int i=0;i<M;++i){
		cin>>X[i]>>Y[i]>>Z[i];
		X[i]--;
		Y[i]--;
	}
	vector<vector<int> > arr;
	vector<int> tmp;
	for(int i=0;i<N;++i){
		arr.push_back(tmp);
	}
	for(int i=0;i<M;++i){
		arr[X[i]].push_back(Y[i]);
		arr[Y[i]].push_back(X[i]);
	}
	/**
	for(int i=0;i<N;++i){
		for(int j=0;j<arr[i].size();++j){
			cout<<arr[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
	**/
	queue<int> que;
	int state;
	map<int, int> statemap;
	int ans = 0;
	for(int i=0;i<N;++i){
		//cout<<i<<" "<<statemap[i]<<endl;
		if(statemap[i]==0){
			statemap[i]++;
			que.push(i);
		}
		else continue;
		while(!que.empty()){
			state = que.front();
			que.pop();
			for(int j=0;j<arr[state].size();++j){
				//cout<<arr[state][j]<<endl;
				if(statemap[arr[state][j]]!=0)continue;
				statemap[arr[state][j]]++;
				que.push(arr[state][j]);
			}
		}
		ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 12400
X, K, D = map(int, input().split())

t = abs(X) // D

if X < 0: sign = -1
else: sign = 1

if K < t:
    x = X - sign*K*D
else:
    x = X - sign*t*D
    if (K - t) % 2 == 1:
        x = D - abs(x)

print(abs(x))

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

int main () {
  int N, K;
  int64_t cnt;
  cin >> N >> K;
  cnt = 0;
  vector<int> enemy(N);
  for( int i = 0; i < N; i++ ) {
    cin >> enemy.at(i);
  }
  sort(enemy.begin(), enemy.end());
  
  if ( N - K <= 0 ) {
    cout << 0;
  }
  else {
    for( int j = 0; j < N - K; j++ ) {
      cnt = cnt + enemy.at(j);
    }
    cout << cnt;
  }
}

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

use std::cmp;
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

pub const MOD: usize = 1000000007;

fn main() {
    let (n, x, y): (usize, i64, i64) = input_three();
    let mut ans = vec![0; n - 1];

    for i in 0..n - 1 {
        for j in i + 1..n {
            let d = min(
                j - i,
                (x - 1 - i as i64).abs() as usize + (y - 1 - j as i64).abs() as usize + 1,
            );
            // dbg!(i, j, d);
            // println!();
            ans[d - 1] += 1;
        }
    }

    for i in ans {
        println!("{}", i);
    }
}

pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


Measured memory_bytes: 4352
fun main(args: Array<String>) {
    val (H, W) = listOfLong()
    var ans = Long.MAX_VALUE
    if (H * W % 3 == 0L) return println(0)
    fun solv(H: Long, W: Long) {
        for (h in 1 until H) { // Ｔ型
            val d1 = h * W
            val d2 = (H - h) * (W / 2)
            val d3 = (H * W) - d1 - d2
            val d = listOf(d1, d2, d3).sorted()
            ans = Math.min(ans, d.last() - d.first())
        }
        for (h in 1 until H) { // 三型
            val d1 = h * W
            val d2 = (H - h) / 2 * W
            val d3 = (H * W) - d1 - d2
            val d = listOf(d1, d2, d3).sorted()
            ans = Math.min(ans, d.last() - d.first())
        }
    }
    solv(H, W); if (W == H) return println(ans)
    solv(W, H); println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }
fun listOfLong(offset: Long = 0L) = listOfString().map { it.toLong() + offset}


Measured memory_bytes: 50548
#include <iostream>
 
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
 
#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;
 
void printAns(long long a) { cout << a << endl; }
 
void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }
 
void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }
 
typedef long long ll;
typedef unsigned long ul;
typedef long double ld;
 
template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7
 
using Graph = vector<vector<pair<int, int>>>;
 
int color[100100];
Graph G(100100);
 
void dfs(int v, ll dis) {
    color[v] = dis % 2;
    for (auto next_v:G[v]) {
        if(color[next_v.first]==-1)
            dfs(next_v.first, dis + next_v.second);
    }
}
 
 
 
//番号ズレ注意！！
int main() {
    int N;
    cin >> N;
    REP(i, N - 1) {
        int from, to, length;
        cin >> from >> to >> length;
        G[from].push_back(make_pair(to, length));
        G[to].push_back(make_pair(from, length));
    }
    REP(i,N+1){
        color[i]=-1;
    }
    dfs(1, 0);
    REP_1(i, N) {
        cout << color[i] << endl;
    }
}

Measured memory_bytes: 7552
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main()
{
    int n;
    while (cin >> n, n)
    {
        int cnt = 0;
        for (int i = 0; i * i <= n; i++)
        {
            for (int j = i; i * i + j * j <= n; j++)
            {
                for (int k = j; i * i + j * j + k * k <= n; k++)
                {
                    for (int h = k; i * i + j * j + k * k + h * h <= n; h++)
                    {
                        if (i * i + j * j + k * k + h * h == n)
                            cnt++;
                    }
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}




Measured memory_bytes: 2984
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdint>
using namespace std;

int culc_gcd(int a, int b) {
    int u, v, r;

    if(a < b) {
        u = b;
        v = a;
    }
    else {
        u = a;
        v = b;
    }

    do {
        r = u % v;
        u = v;
        v = r;
    }while(r != 0);
    
    return u;
}

int main() {
    int N, X;

    cin >> N >> X;
    int ans;
    for(int i = 0; i < N; i++) {
        int x;
        cin >> x;
        ans = (i == 0) ? abs(x - X) : culc_gcd(ans, abs(x - X));
    }

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


Measured memory_bytes: 256
<?php

function gcd($i,$j){
    if($j===0){
        return $i;
    }else{
        return gcd($j, $i%$j);
    }
}

while(fscanf(STDIN,"%d %d",$a,$b)){
    $x=gcd(max($a,$b),min($a,$b));
    $y=$a*$b/$x;
    echo $x." ".$y."\n";
}

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

typedef pair<int, int> pii;

int N;
vector<pii> B;

int main() {
    scanf("%d", &N);
    B.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%d %d", &B[i].first, &B[i].second);
        if(B[i].first > B[i].second) swap(B[i].first, B[i].second);
    }
    int rmn = 1e9, rmx = 0;
    int bmn = 1e9, bmx = 0;
    for(int i = 0; i < N; i++) {
        rmn = min(rmn, B[i].first);
        rmx = max(rmx, B[i].first);
        bmn = min(bmn, B[i].second);
        bmx = max(bmx, B[i].second);
    }
    long long ans = (long long)(rmx - rmn)*(bmx - bmn);
    sort(B.begin(), B.end());
    bmn = rmn;
    int tmn = 1e9;
    for(int i = 0; i < N; i++) {
        tmn = min(tmn, B[i].second);
        rmn = tmn;
        if(i != N - 1) rmn = min(rmn, B[i + 1].first);
        rmx = max(rmx, B[i].second);
        ans = min(ans, (long long)(bmx - bmn)*(rmx - rmn));
    }
    printf("%lld", ans);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+5,inf=1e18,mod=1e9+7;
#define test ll testcases;cin>>testcases; while(testcases--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define ppll pair<ll,pair<ll,ll>>
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))
const ld pi=3.141592653589793238;

bool check_prime(ll n)
{
	ll flag=0,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(n==1)
	{
		return false;
	}
	else if(flag==0 || n==2 || n==3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll fastexpo(ll a,ll b,ll MOD) 
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		{
			result=(result*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return result;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,ans;
    cin>>n>>x>>t;
    ans=t*ceil((ld)n/x);
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue - 10;
	const long INFL = long.MaxValue - 10;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	int N, M, C;
	int[] A, B;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		int N = cin.nextInt();
		int x = cin.nextInt();
		int[] a = new int[N];
		int[] b = new int[N + 1];
		for (int i = 0; i < N; i++)
		{
			a[i] = cin.nextInt();
		}
		for (int i = 0; i < N; i++)
		{
			b[i] += a[i];
			b[i + 1] += a[i];
		}
		long ans = 0;
		for (int i = 0; i < N+1; i++)
		{
			if (b[i] > x)
			{
				int num = b[i] - x;
				ans += num;
				b[i + 1] -= num;
			}
		}
		Console.WriteLine(ans);
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 17240
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;

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

  int ans;

  int N_pat=N*(N-1)/2;
  int M_pat=M*(M-1)/2;

  ans=N_pat+M_pat;
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;
ll dp[100005][13];

signed main(void) {
	int N;
	cin >> N;
	vector<int> d(N);
	rep(i, N) {
		cin >> d[i];
	}

	int ans = 0;
	rep(i, N) {
		for(int j=i+1; j<N; j++) {
			ans += d[i] * d[j];
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

ll N, K;
ll a[55];
ll mem[111][55][55];

ll rec(ll k, ll l, ll r) {
  if(mem[k][l][r]!=-1) return mem[k][l][r];
  if(l>r) return 0;
  if(K<k) return 0;
  
  ll res=0;
  chmax(res, a[l]+rec(k+1, l+1, r));
  chmax(res, a[r]+rec(k+1, l, r-1));
  chmax(res, rec(k+2, l+1, r));
  chmax(res, rec(k+2, l, r-1));
  
  return mem[k][l][r]=res;
}

int main(void) {
  cin >> N >> K;
  ll i;
  
  memset(mem, -1, sizeof(mem));
  for(i=0; i<N; i++) cin >> a[i];
  
  pt(rec(1, 0, N-1));
}








Measured memory_bytes: 2816
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:input()

"""========main code==============="""

#t=ii()
t=1
for _ in range(t):
    a,b,c,d=ml()
    print(max(a*c,a*d,b*c,b*d))

Measured memory_bytes: 65240
// C - Scc Puzzle
// https://atcoder.jp/contests/arc069/tasks/arc069_a
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, n, m, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n >> m;
  count = m / 2;
  ans = min(count, (n * 2 + m) / 4);
  cout << ans << endl;
}

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

int main(){

  int num[100],n;
  int a=0;

  for(int i=0;i<100;i++)
    num[i] = 0;

  while(cin >> n)
    num[n]++;

  for(int i=0;i<100;i++)
    a = max(a,num[i]);

  for(int i=0;i<100;i++)
    if(a==num[i])
      cout << i << endl;

  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{
	int in, ret, i;
	while (scanf("%d", &in) != EOF) {
		ret = 0;
		for (i = in; i < 600; i += in)
			ret += i * i * in;
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int max(int a,int b){
  if(a > b){
    return a;
  }
  return b;
}

int main(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);

  printf("%d\n",a+b+c-max(a,max(b,c)));

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#define ll long long int
#define ld long double
#define pi acos(-1)
#define pb push_back
using namespace std;
int main()
{
    ll i,j,a,k,b,c,n,t,m,p,q,d,e,f,x,y,g,z,h;
    ld aa,bb,cc,dd,ee,ff,kk,gg;
//    vector<ll > v,s,vv;
//    vector<pair<ll,ll> > sv;
//    map<ll,ll> sa,ta,ma,pa;
//    map<pair<ll,ll>, ll> mm;
//    map<pair< deque<ll>,deque<ll> >,ll  > me;
//    priority_queue<char,vector<ll>,greater<ll> > aq,tq,pq;
//    string st,et,ft,pt,ct;
//    deque<ll> de,pe,ne;
//    ios_base::sync_with_stdio(false);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
        cin>>a>>b>>d;
        c = 0;
        for(i=a;i<=b;i++){
            if(i%d==0)c++;
        }
        cout<<c<<endl;
}


Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
#include<map>
#include<queue>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>a;
	vector<int>ans(n);
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		a.push_back(k);
	}
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			ans[0] += a[i];
		}
		else {
			ans[0] -= a[i];
		}
	}
	int res = ans[0] / 2;
	for (int i = 1; i < n; i++) {
		ans[i] = (a[i-1] - res) * 2;
		res = ans[i]/2;
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
}

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

#define int long long
typedef pair<int, int> P;
//#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
	os << "(" << pair_var.first << ", " << pair_var.second << ")";
	return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	os << "{";
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
	}
	os << "}";
	return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
	os << "{";
	repi(itr, map_var) {
		os << *itr;
		itr++;
		if (itr != map_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
	os << "{";
	repi(itr, set_var) {
		os << *itr;
		itr++;
		if (itr != set_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}

#define DUMPOUT cerr

void dump_func() {
	DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
	DUMPOUT << head;
	if (sizeof...(Tail) > 0) {
		DUMPOUT << ", ";
	}
	dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

// a^k mod p
int modpow(int a, int k, int p) {
	int ans = 1;
	while (k > 0) {
		if (k % 2 == 1) {
			ans *= a;
			ans %= p;
		}
		a = (a * a) % p;
		k = k / 2;
	}
	return ans;
}

signed main() {

	int N;
	cin >> N;

	vector<int> cnt(123456, 0);
	vector<int> D(N);
	int ma = -INF;
	const int mod = 998244353;

	rep(i, N) {
		cin >> D[i];
		cnt[D[i]]++;
		ma = max(D[i], ma);
	}

	if(cnt[0]!=1) { cout << 0 << endl; return 0; }
	if(D[0]!=0) { cout << 0 << endl; return 0; }
	rep(i, ma+1){
		if (cnt[i] == 0) { cout << 0 << endl; return 0; }
	}

	int ans = 1;
	rep(i, ma) {
		ans *= modpow(cnt[i], cnt[i + 1], mod);
		ans %= mod;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2048
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int N=in();
	vector<int> H(1001000,0);
	int m = 0;
	do{
		H[N]++;
		m++;
		if(H[N]>1){
			break;
		}
		if(N%2) N = 3*N+1;
		else N /= 2;
	}while(true);
	
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define int long long
const int N = 3e5 + 5;
const int M = 1e6 + 5;
const int mod = 998244353;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
int n , a , b , k;
int mul[N] , dv[N];
int po(int x ,int y)
{
	if(y == 0) return 1LL;
	int temp = po(x , y >> 1);
	if((y & 1)) return temp * temp % mod * x % mod;
	else return temp * temp % mod;
}
int pre()
{
	mul[0] = dv[0] = 1;
	for(int i = 1 ; i <= n ; ++i) mul[i] = mul[i - 1] * i % mod;
	dv[n] = po(mul[n] , mod - 2) % mod;
	for(int i = n - 1 ;  i >= 0 ; --i) dv[i] = dv[i + 1] * (i + 1) % mod;
}
int c(int k,int n)
{
	return mul[n] * dv[k] % mod * dv[n - k] % mod;
}
	
signed main(){
	cin >> n >> a >> b >> k;
	int ans = 0; pre();
	for(int i = 0 ; i <= n && a * i <= k ; ++i)
		if((k - a * i) % b == 0 && (k - a * i) <= b * n)
		{
			int j = (k - a * i) / b ;
			ans = (ans + c(i , n) * c(j , n) % mod) % mod;
		}
	cout << ans;
}
		
	

Measured memory_bytes: 4992
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
A, B, C, X, Y = 0, 0, 0, 0, 0


def set_inputs():
    global A, B, C, X, Y
    A, B, C, X, Y = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    if 2 * C <= A + B:
        a = min(A, 2 * C)
        b = min(B, 2 * C)
        print(min(X, Y) * 2 * C + max(0, X - min(X, Y)) * a + max(0, Y - min(X, Y)) * b)
    else:
        print(A * X + B * Y)
    return
    # dp = [[0 for _ in range(Y + 1)] for _ in range(X + 1)]
    # for i in range(1, X + 1):
    #     dp[i][0] = dp[i-1][0] + A
    # for j in range(1, Y + 1):
    #     dp[0][j] = dp[0][j-1] + B
    # for i in range(1, X + 1):
    #     for j in range(1, Y + 1):
    #         dp[i][j] = min(
    #             dp[i-1][j] + A,
    #             dp[i][j-1] + B,
    #             dp[i-1][j-1] + C * 2)
    # print(dp[X][Y])
    # return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5972
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int, int>;
//加算代入演算子は+=！！！！！

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    ll sum = 0;
    for (int bit = 0; bit < (1 << n - 1); bit++)
    //2^n繰り返す
    {
        ll temp = s[0] - '0';
        rep(i, n - 1)
        {
            if (bit & (1 << i))
            //1が立っていればホニャララ
            {
                sum += temp;
                temp = s[i + 1] - '0';
            }
            else
            {
                temp *= 10;
                temp += s[i + 1] - '0';
            }
        }
        sum += temp;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

public class VC0207_A {
  public static void Main() {
    int c = int.Parse(Console.ReadLine());
    var music = new string[c];
    var time = new int[c];
    for(int i = 0;i < c;i++) {
      string[] ss = Console.ReadLine().Split(' ');
      music[i] = ss[0];
      time[i] = int.Parse(ss[1]);
    }
    
    string title = Console.ReadLine();
    int num = Array.IndexOf(music, title);
    int result = 0;
    for(int i = num + 1;i < c;i++) {
      result += time[i];
    }
    Console.WriteLine(result);
  }
}

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

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int MaxN = 2e5;

int a[MaxN + 5], b[MaxN + 5], head[MaxN + 5];

int main(){
	int n, ans = 0, xsum;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]), b[i] = 0;
	for(int i = n; i >= 1; i--){
		xsum = 0;
		for(int j = i + i; j <= n; j += i)
			xsum ^= b[j];
		if(xsum != a[i]) b[i] = 1, head[++ans] = i;
	}
	printf("%d\n", ans);
	for(int i = ans; i >= 1; i--) 
		printf("%d%c", head[i], i == 1 ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 2944
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m,k = mi()
a = li()
b = li()

asum = sum(a)
acur = n-1
bsum = 0
bcur = -1

# acumsum = []
# bcumsum = []
# atmp = 0
# btmp = 0
# for i in range(n):
#     atmp += a[i]
#     acumsum.append(atmp)
# for i in range(m):
#     btmp += b[i]
#     bcumsum.append(btmp)

if asum > k:
    while asum > k:
        asum -= a[acur]
        acur -= 1
    while 1:
        if asum + bsum + b[bcur+1] <= k:
            bsum += b[bcur+1]
            bcur += 1
        else:
            break
        if bcur == m-1:
            break
else:
    while 1:
        if asum + bsum + b[bcur+1] <= k:
            bsum += b[bcur+1]
            bcur += 1
        else:
            break
        if bcur == m-1:
            break

read_max = acur + 1 + bcur + 1

# print(read_max)
# print(acur+1,bcur+1)

# print(acumsum)
# print(bcumsum)



for i in range(n):
    acur -= 1
    if acur == -2:
        break
    
    asum -= a[acur+1]
    if bcur == m-1:
        break

    while 1:
        if asum + bsum + b[bcur+1] <= k:
            bsum += b[bcur+1]
            bcur += 1
        else:
            break
        if bcur == m-1:
            break

    # print('cur',acur+1,bcur+1,asum+bsum)

    read_max = max(read_max, acur + 1 + bcur + 1)

    if bcur == m-1:
        break
print(read_max)

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    int n; cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    int MAX = 1000005;
    vi cnt(MAX, 0);
    for(int i : a){
        if(cnt[i] != 0){
            cnt[i] = 2;
            continue;
        }
        for(int x = i; x < MAX; x += i)
            cnt[x]++;
    }
    int ans = 0;
    for(int i : a){
        if(cnt[i] == 1) ans++;
    }

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

Measured memory_bytes: 7952
n,a,b = map(int,input().split())
def power(x,b):
  if x == 1:
    return b
  if x%2 == 0:
    return (power(x//2,b)**2)%(10**9+7)
  else:
    return (b*power(x-1,b))%(10**9+7)
ans = power(n,2)-1
x1 = 1
y1 = 1
x2 = 1
y2 = 1
for i in range(a):
  x1 = (x1*(n-i))%(10**9+7)
  y1 = (y1*(i+1))%(10**9+7)
for i in range(b):
  x2 = (x2*(n-i))%(10**9+7)
  y2 = (y2*(i+1))%(10**9+7)
ans -= x1*power(10**9+5,y1)
ans -= x2*power(10**9+5,y2)
print(ans%(10**9+7))
  

Measured memory_bytes: 38896
n=int(input())
import math
l=0
a=[ list(map(int,input().split())) for _ in range(n)]
for i in range (n):
  for j in range(i+1,n):
    l+=math.sqrt((a[i][0]-a[j][0])**2+(a[i][1]-a[j][1])**2)
print(2*l/n)
    
    

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};

int main() {
	int n;
	cin >> n;
	int *a = new int[n];
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int res = 0;
	for (int i = 0; i < n; ++i) {
		if (a[i] == res + 1) {
			++res;
		}
	}
	if (res == 0) {
		cout << (-1) << endl;
	}
	else {
	cout << (n - res) << endl;}
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
happiness = [list(map(int, input().split())) for i in range(n)]
dp = [[0] * 3 for i in range(n + 1)]

for i in range(n):
  dp[i + 1][0] = max(dp[i][1], dp[i][2]) + happiness[i][0]
  dp[i + 1][1] = max(dp[i][2], dp[i][0]) + happiness[i][1]
  dp[i + 1][2] = max(dp[i][1], dp[i][0]) + happiness[i][2]

print(max(dp[n]))


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

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; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int N;
  cin>>N;
  bool can = false;
  int l = 0;
  while(l*(l+1)<2*N) l++;
  if(l*(l+1)==2*N) can=true;
  if(can) {
    cout<<"Yes"<<endl;
    vector<vector<int>> v(l+1,vector<int>(l));
    for(int i = 0; i < l; i++){
      for(int j = i; j < l; j++){
        if(i==0&&j==0) v[i][j]=1;
        else if(j==i)v[i][j]=v[i-1][l-1]+1;
        else v[i][j]=v[i][j-1]+1;
      }
      for(int j = i+1; j < l+1; j++){
        if(j==i+1) v[j][i]=v[i][i];
        else v[j][i]=v[j-1][i]+1;
      }
    }
    cout<<l+1<<endl;
    for(auto x:v){
      cout<<l<<" ";
      for(auto y:x) cout<<y<<" ";
      cout<<endl;
    }
  }
  else cout<<"No"<<endl;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){
    ll n; cin >> n;
    vll e(100001, 0), o(100001, 0);
    rep(i, n/2){
        ll in1, in2;
        cin >> in1 >> in2;
        e[in1]++;
        o[in2]++;
    }

    ll i = max_element(all(e))-e.begin();
    ll j = max_element(all(o))-o.begin();

    ll ans;
    if(i!=j){
        ans = n-e[i]-o[j];
    }
    else{
        sort(rall(e));
        sort(rall(o));
        ans = min(n-e[0]-o[1], n-e[1]-o[0]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4716
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-02 23:05:02
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<(x)>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l) {
    if (l > 0) return gcd(l, k%l);
    else return k;
}

ostringstream oss_global;
string s_global = oss_global.str();

int times(int n) {
    if (n % 100 == 0) {
        return 1 + times(n/100);
    } else {
        return 0;
    }
}

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

    int ans, cnt;
    cnt = 0;
    for (int i = 1; i <= INF; i++) {
        int t = times(i);
        
        if (t == d) cnt++;

        if (cnt == n) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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() {
  int X, A, B;
  cin >> X >> A >> B;

  cout << (X - A) % B << endl; 

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3604