akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b;cin >> n >> a >> b;
	vector<ll> h(n);
	rep(i,n) cin >> h.at(i);
	ll l=0,r=1000000000;
	while(r-l>1){
		ll mid=(r+l)/2,sum=0;
		rep(i,n){
			if(h.at(i)>mid*b) sum+=(h.at(i)-mid*b+(a-b-1))/(a-b);
		}
		if(sum<=mid) r=mid;
		else l=mid;
	}
	cout << r << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    bool a=false ,b = false,c= false;
    for(int i = 0;i<s.size();i++){
        if(s[i] == 'a'){
            a = true;
        }
        else if(s[i] == 'b'){
            b = true;
        }
        else if(s[i] == 'c'){
            c=true;
        }
    }
    if(a && b && c){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }

}


Measured memory_bytes: 256
///                         .
///                     /   ))     |\         )               ).
///               c++. (\  ( `.    / )  (\   ( `.     ).     ( (
///               | |   ))  ) )   ( (   `.`.  ) )    ( (      ) )
///               | |  ( ( / _..----.._  ) | ( ( _..----.._  ( (
/// ,-.           | |---) V.'-------.. `-. )-/.-' ..------ `--) \._
/// | /===========| |  (   |      ) ( ``-.`\/'.-''           (   ) ``-._
/// | | / / / / / | |--------------------->  <-------------------------_>=-
/// | \===========| |                 ..-'./\.`-..                _,,-'
/// `-'           | |-------._------''_.-'----`-._``------_.-----'
///               | |         ``----''            ``----''
///               | |
///               c++`

///██╗ ██████╗ ██╗    ██████╗  ██████╗  ██████╗   ██████╗
///██║██╔═══██╗██║    ╚════██╗██╔═████╗ ╚════██╗ ██╔═████╗
///██║██║   ██║██║     █████╔╝██║██╔██║  █████╔╝ ██║██╔██║
///██║██║   ██║██║    ██╔═══╝ ████╔╝██║ ██╔═══╝  ████╔╝██║
///██║╚██████╔╝██║    ███████╗╚██████╔╝ ███████╗ ╚██████╔╝
///╚═╝ ╚═════╝ ╚═╝    ╚══════╝ ╚═════╝  ╚══════╝  ╚═════╝

#include<bits/stdc++.h>
#include<fstream>
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define mlojins cout.tie(NULL);
#define bzbz cin.tie(NULL);
#define CODER ios_base::sync_with_stdio(0)  ;
#define p_b pop_back
#define p_f pop_front
#define Qulukh
#define quluq return 0;
#define Zohiri_dzd
#define Mekh
#define Black_star
using namespace std ;

const ll N = 1e6 + 1;

map <ll , ll> mp , pm ;
map <char , ll> hs ;
deque <ll> v , vc , ve ,vv , vd ;
deque <char> p , pe ;
deque <string> ts , ss , st ;
deque <double> sd , ds ;
ll a , b , c , d , e , f , cnt , ans , r , n , l , x , y ;
ld q , t , cnt1 , cnt2 ;
string g , h , w , o , m , s ;
char z , u ;
bool re , rt ;
vector<pair < ll , string > > pr , rp , pp ;
map < pair < char , char > , ll > aw , wa ;

int main ()
{
    bzbz
    mlojins
    Qulukh
    Mekh
    CODER
    Zohiri_dzd
    Black_star
    ///freopen("input.txt" , "r" , stdin );
    ///freopen("output.txt", "w" , stdout );
    ///Author of the greatest code :: Murtazoev Alijon
    cin >> a ;
    cnt = a / 500 ;
    n = cnt * 1000 ;
    a -= cnt * 500 ;
    cnt = a / 5 ;
    n += cnt * 5 ;
    a -= cnt * 5 ;
    cout << n ;
}
///Mmavl studios
///Eco students


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
 
long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g){
    
    for(int i = g; i<n; i++){
        
        int v = A[i];
        int j =i-g;
        while ( j>=0 && A[j] > v ){
            
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
}



void shellSort(int A[], int n){
    
    for (int h=1; ; ){
        if(h>n) break;
        G.push_back(h);
        h = 3*h + 1;
    }
    
    for (int i = G.size()-1; i >= 0; i--){
        insertionSort(A, n, G[i]);
    }
}


int main()
{
    cin >> n;
    for(int i=0; i<n; i++) scanf("%d", &A[i]);
    cnt = 0;
    
    
    shellSort(A,n);
    
    
    cout<< G.size()<<endl;
    for(int i=G.size()-1; i>=0; i-- ){
        
        printf("%d",G[i]);
        if(i) printf(" ");
        
    }
    
    
    printf("\n");
    printf("%d\n", cnt);
    for(int i=0; i <n; i++) printf("%d\n",A[i]);
    
    
    return 0;
}






Measured memory_bytes: 7168
n,k=map(int,input().split())
l,r=0,k+1
while r-l>1:
  m=(l+r)//2
  res = m
  t = m
  for i in range(n-1):
    t //= 2
    res += t
    if t == 0:
      break
  if res > k:
    r = m
  else:
    l = m
print(l)


Measured memory_bytes: 5600
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;



int main(void){
    string s,t="";
    cin>>s;
    vector<ll>sum;
    for(int i=0;i<s.length();){
        if(i<s.length()-1){
            if(s[i]=='B'){
                if(s[i+1]=='C'){
                    t+='X';
                    i+=2;
                }
                else{
                    t+=s[i];
                    i++;
                }
            }
            else{
                t+=s[i];
                i++;
            }
        }
        else{
            t+=s[i];
            i++;
        }
    }
    ll cnt=0;
    for(ll i=0;i<t.length();i++){
        if(t[i]=='A')cnt++;
        else{
            if(t[i]=='X')sum.push_back(cnt);
            else cnt=0;
        }
    }
    ll ans=0;
    for(ll i=0;i<(ll)sum.size();i++)ans+=sum[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstring>
#include <cctype>
#include <ctime>
#include <vector>
#include <stack>

using namespace std;
typedef long long llong;
#define M 1046527
#define L 30
char H[M][L];

llong h1(llong key) {return key % M;}
llong h2(llong key) {return (key % (M - 1) + 1);}

llong getKey(char word[])
{
    llong key = 0, p = 1;
    for(int i = 0; i < strlen(word); i ++)
    {
        key += p * word[i];
        p *= 5;
    }
    return key;
}
int insert(char word[])
{
    llong key = getKey(word);
    for(int i = 0;; i ++)
    {
        llong h = (h1(key) + i * h2(key) ) % M;
        if(strcmp(H[h], word) == 0 ) return 0;
        else if(strlen(H[h]) == 0) {strcpy(H[h], word); return 1;}
    }
    return 0;
}
int find(char word[])
{
    llong key = getKey(word);
    for(int i = 0;; i ++)
    {
        llong h = (h1(key) + i * h2(key) ) % M;
        if(strcmp(H[h], word) == 0 ) return 1;
        else if(strlen(H[h]) == 0) return 0;
    }
}
int main()
{
    char ins[L], word[L];
    int n;
    cin >> n;
    for(int i = 0; i < n; i ++)
    {
        cin >> ins >> word;
        switch (ins[0])
        {
            case 'i':
                insert(word);
                break;
            case 'f':
                int judge = 0;
                judge = find(word);
                if(judge)
                {
                    cout << "yes" << endl;
                    break;
                }
                else
                {
                    cout << "no" << endl;
                    break;
                }
        }
    }
    return 0;
}



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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()

#define uint8_t unsigned char
#define uint16_t unsigned short
#define uint32_t unsigned int
#define uint64_t unsigned long long

#define int8_t signed char
#define int16_t signed short
#define int32_t signed int
#define int64_t signed long long

using namespace std;

int main(int argc, char const* argv[])
{
    int N = 0;
    int W = 0;
    cin >> N >> W;

    int w_tmp = 0;
    int v_tmp = 0;
    vector<int> w;
    vector<int> v;

    while (cin >> w_tmp >> v_tmp) {
        w.push_back(w_tmp);
        v.push_back(v_tmp);
    }

    long long dp[N+1][W+1] = {};
    //REP(i, N) REP(j,W+1){dp[i][j] = INT_MIN;}

    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int sum_w = 0; sum_w <= W; sum_w++) {
            if (sum_w - w[i] >= 0) {
                dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - w[i]]+v[i]);

                //cout << "dp[" << i+1 << "][" << sum_w << "]" << dp [i+1][sum_w] << endl;
            }
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w]);

        }
    }

    cout << dp[N][W] << endl;

    return 0;
}



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

int main() {
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  
  int sum =0,num;
  
  rep(i,a+1){
    rep(j,b+1){
      rep(k,c+1){
        num = 500*i + 100*j + 50*k;
        if(num == x){
          sum++;
        }
      }
    }
  }
  cout << sum << endl;
}

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

using namespace std;


int main(){
  long x;
  long y=100;
  long ans = 0;
  cin >> x;
  while(1){
    if(y >= x ){
      cout << ans;
      break;
    }
    y += y/100;
    ans ++;

    

  }

  
}


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

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

int main() {
    int n;
    cin>>n;
    cout<<(1000-n%1000)%1000<<endl;
}

Measured memory_bytes: 3536
def burst(S,H,W):
    for i in range(H):
        S[i] += "d" #dummy
    S.append("d" * (W+1))
    tate_burst = [[] for _ in range(W)]
    yoko_burst = [[] for _ in range(H)]
    #tate_burst[j]:j列目の連続する"."の(左端,右端)
    #yoko_burst[i]:i行目の連続する"."の(上端,下端)

    for j in range(W):
        sp,ep = None,None
        for i in range(H):
            if S[i][j] == ".":
                if sp == None:
                    sp = i
                    if S[i+1][j] != ".":
                        ep = i
                        tate_burst[j].append((sp,ep))
                        sp,ep = None,None
                elif S[i+1][j] != ".":
                    ep = i
                    tate_burst[j].append((sp,ep))
                    sp,ep = None,None

    for i in range(H):
        sp,ep = None,None
        for j in range(W):
            if S[i][j] == ".":
                if sp == None:
                    sp = j
                    if S[i][j+1] != ".":
                        ep = j
                        yoko_burst[i].append((sp,ep))
                        sp,ep = None,None
                elif S[i][j+1] != ".":
                    ep = j
                    yoko_burst[i].append((sp,ep))
                    sp,ep = None,None

    return tate_burst,yoko_burst

def score(tate_burst,yoko_burst,H,W):
    T = [[-1 for _ in range(W)] for _ in range(H)]

    for j in range(W):
        for st,go in tate_burst[j]:
            for i in range(st,go+1):
                T[i][j] += (go-st+1)

    for i in range(H):
        for st,go in yoko_burst[i]:
            for j in range(st,go+1):
                T[i][j] += (go-st+1)

    return T

def max_score(T,H,W):
    output = 0
    for i in range(H):
        for j in range(W):
            output = max(output,T[i][j])

    return output

def main():
    H,W = map(int,input().split())
    S = [input() for _ in range(H)]

    B = burst(S,H,W)
    tate_burst,yoko_burst = B[0],B[1]
    T = score(B[0],B[1],H,W)
    ans = max_score(T,H,W)

    print(ans)

if __name__ == "__main__":
    main()


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

#define int long long
#define double long double

using namespace std;

#define REP(i, a, b) for (int(i) = (a); i < (b); (i)++)
#define rep(i, n) REP(i, 0, n)
#define PER(i, a, b) for (int(i) = (a - 1); i >= (b); (i)--)
#define per(i, n) PER(i, n, 0)
#define each(i, n) for (auto &i : n)
#define clr(a) memset((a), 0, sizeof(a))
#define mclr(a) memset((a), -1, sizeof(a))
#define all(a) (a).begin(), (a).end()
#define dum(val) cerr << #val " = " << val << " ";
#define dump(val) cerr << #val " = " << val << endl;
#define FILL(a, v) fill(a, a + sizeof(a) / sizeof(*a), v)

typedef pair<int, int> P;

const int mod = 1e9 + 7;
const int INF = 1e9;

int n;
vector<vector<int>> e;
vector<int> v;
vector<int> c;
vector<int> f;

signed main() {
	cin >> n;
	int m = n;
	n *= 2;
	e.resize(n);
	v.resize(n, 0);
	c.resize(n, 0);
	f.resize(n, 0);

	rep(i, m - 1) {
		int a, b;
		cin >> a >> b;
		e[a].push_back(m + i);
		e[b].push_back(m + i);
		e[m + i].push_back(a);
		e[m + i].push_back(b);
	}

	queue<int> q, q2;

	int count = 0;
	rep(i, n) {
		if (e[i].size() == 1) {
			v[i] = 1;
			q.push(i);
		}
	}

	int ma = 1;

	set<int> se;
	while (q.size()) {
		int t = q.front();
		q.pop();
		if (f[t]) continue;
		f[t] = 1;
		each(i, e[t]) {
			if (f[i]) continue;
			v[i] += v[t];
			if (e[i].size() >= 3) {
				se.insert(i);
			} else {
				q.push(i);
			}
		}
	}
	int ans = 0;

	each(i, se) {
		q2.push(i);
		v[i]--;
		ans += v[i];
	}

	cout << max(1ll, ans) << endl;

	return 0;
}


Measured memory_bytes: 17792
A, B, C = map(int, input().split())
# n*B+C = kAとなるnとkが存在するか
# k = (n*B+C)/A (n,kは整数)
# これを満たすnを順番に調べる。A回繰り返せば必ず1周もしくは答え

n = 0
cnts = [0]*A
while True:
    mod = (n*B+C)%A
    if cnts[mod] == 1:
        print('NO')
        break
    if mod == 0:
        print('YES')
        break
    n += 1
    cnts[mod] = 1


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

int main(){
        int i,j,Q;
        vector<int> s(100001);
        vector<int> p(100001, 1);
        p[0] = 0;
        p[1] = 0;
        for(i=2;i*i<=100000;i++){
                if(p[i]==0)continue;
                else{
                        for(j=2;j*i<=100000;j++){
                                p[j*i] = 0;
                        }
                }
        }
        for(i=3;i<=100000;i=i+2){
                if(p[i]==1 && p[(i+1)/2]==1){
                        s[i] = s[i-2]+1;
                }
                else{
                        s[i] = s[i-2];
                }
        }
        cin >> Q;
        vector<int> l(Q);
        vector<int> r(Q);
        for(i=0;i<Q;i++){
                cin >> l[i] >> r[i];
        }
        for(i=0;i<Q;i++){
                cout << s[r[i]] - s[l[i]-2] << endl;
        }
        return 0;
}

Measured memory_bytes: 2176
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let mut sc = Scanner::new();
    let n = sc.next_usize();
    let mut a = Vec::with_capacity(n);
    a.push(0);
    for _ in 0..n {
        let ai = sc.next_isize();
        a.push(ai);
    }
    a.push(0);

    let mut cost = 0;
    for i in 1..=n + 1 {
        cost += (a[i] - a[i - 1]).abs();
    }

    for i in 1..=n {
        println!(
            "{}",
            cost - (a[i - 1] - a[i]).abs() - (a[i] - a[i + 1]).abs() + (a[i + 1] - a[i - 1]).abs()
        );
    }
}

pub struct Scanner {
    buf: std::collections::VecDeque<String>,
}

impl Scanner {
    pub fn new() -> Self {
        Self {
            buf: std::collections::VecDeque::new(),
        }
    }

    fn scan_line(&mut self) {
        let mut flag = 0;
        while self.buf.is_empty() {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let mut iter = s.split_whitespace().peekable();
            if iter.peek().is_none() {
                if flag >= 5 {
                    panic!("There is no input!");
                }
                flag += 1;
                continue;
            }

            for si in iter {
                self.buf.push_back(si.to_string());
            }
        }
    }

    pub fn next<T: std::str::FromStr>(&mut self) -> T {
        self.scan_line();
        self.buf
            .pop_front()
            .unwrap()
            .parse()
            .unwrap_or_else(|_| panic!("Couldn't parse!"))
    }

    pub fn next_usize(&mut self) -> usize {
        self.next()
    }

    pub fn next_isize(&mut self) -> isize {
        self.next()
    }

    pub fn next_chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect()
    }

    pub fn next_string(&mut self) -> String {
        self.next()
    }

    pub fn next_char(&mut self) -> char {
        self.next()
    }

    pub fn next_float(&mut self) -> f64 {
        self.next()
    }
}


Measured memory_bytes: 8392
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr, tails, sort)
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

isTriangle :: Int -> Int -> Int -> Bool
isTriangle a b c = a < b + c && b < c + a && c < a + b

naive = do
  n <- readLn :: IO Int
  xs <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  print $ length [ (a,b,c) | a:xss <- tails xs, b:xsss <- tails xss, c <- xsss, isTriangle a b c ]

-- v は昇順にソートされているとする。
-- count a v は a 以上の要素の個数を数える。
countGE :: Int -> U.Vector Int -> Int
countGE !a = loop 0
  where
    loop !s !v | U.null v = s
               | U.length v == 1 = case compare a (U.head v) of
                                     LT -> s + 1
                                     EQ -> s + 1
                                     GT -> s
               | otherwise = let n = U.length v
                                 n2 = n `quot` 2
                             in case compare a (v U.! n2) of
                                  LT -> loop (n - n2 + s) (U.take n2 v)
                                  EQ -> loop (n - n2 + s) (U.take n2 v)
                                  GT -> loop s (U.drop n2 v)

main = do
  n <- readLn :: IO Int
  xs <- mergeSort . U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  print $ sum [ n - (j+1) - countGE c_max ys
              | i <- [0..n-1]
              , let a = xs U.! i
              , j <- [i+1..n-1]
              , let b = xs U.! j
              , let c_max = a + b {- c < a + b, b - a < c, a - b < c -}
              , let ys = U.drop (j+1) xs
              ]

mergeSortBy :: (U.Unbox a) => (a -> a -> Ordering) -> U.Vector a -> U.Vector a
mergeSortBy !cmp !vec = doSort vec
  where
    doSort vec | U.length vec <= 1 = vec
               | otherwise = let (xs, ys) = U.splitAt (U.length vec `quot` 2) vec
                             in merge (doSort xs) (doSort ys)
    merge xs ys = U.create $ do
      let !n = U.length xs
          !m = U.length ys
      result <- UM.new (n + m)
      let loop !i !j
            | i == n = U.copy (UM.drop (i + j) result) (U.drop j ys)
            | j == m = U.copy (UM.drop (i + j) result) (U.drop i xs)
            | otherwise = let !x = xs U.! i
                              !y = ys U.! j
                          in case cmp x y of
                               LT -> do UM.write result (i + j) x
                                        loop (i + 1) j
                               EQ -> do UM.write result (i + j) x
                                        UM.write result (i + j + 1) y
                                        loop (i + 1) (j + 1)
                               GT -> do UM.write result (i + j) y
                                        loop i (j + 1)
      loop 0 0
      return result

mergeSort :: (U.Unbox a, Ord a) => U.Vector a -> U.Vector a
mergeSort = mergeSortBy compare


Measured memory_bytes: 1020
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n,a;
    std::cin >> n;
    std::cin >> a;
    n %= 500;
    if(n>a){
        std::cout << "No" << std::endl;
    }else{
        std::cout << "Yes" << std::endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void maxHeapify(int i) {
  int l, r, largest;
  l = 2 * i;
  r = 2 * i + 1;

  if ( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;
  if ( r <= H && A[r] > A[largest] ) largest = r;

  if ( largest != i ) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int extract() {
  int maxv;
  if ( H < 1 ) return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key) {
  if ( key < A[i] ) return;
  A[i] = key;
  while ( i > 1 && A[i / 2] < A[i] ) {
    swap(A[i], A[i / 2]);
    i = i / 2;
  }
}

void insert(int key) {
  H++;
  A[H] = -INFTY;
  increaseKey(H, key);
}

int main() {
  int key;
  char com[10];

  while ( 1 ) {
    scanf("%s", com);
    if ( com[0] == 'e' && com[1] == 'n' ) break;
    if ( com[0] == 'i') {
      scanf("%d", &key);
      insert(key);
    } else {
      printf("%d\n", extract());
    }
  }

  return 0;
}


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

main(){
	int n,p,d1,d2 ;
	while( cin >> n , n ){
		int ans,mx = -1 ;
		for( int i=0 ; i<n ; i++ ){
			cin >> p >> d1 >> d2 ;
			if( mx < d1 + d2 ){
				mx = d1 + d2 ;
				ans = p ;
			}
		}
		cout << ans << " " << mx << endl ;
	}
}

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

using namespace std;

template <class T>
T gcd(T a, T b) {
	return b == 0 ? a : gcd(b, a % b);
}

template <class T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}


int main() {
	long long a, b;
	cin >> a >> b;

	long long ans = lcm(a, b);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream> 
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int a,b,c;
long long k;
int main()
{
	cin>>a>>b>>c>>k;
	if (k&1) cout<<b-a;else cout<<a-b;
	return 0;
}

Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<Integer> one = nextIntArray();
      int K = one.get(0);
      int X = one.get(1);
      myout((K * 500 >= X) ? "Yes" : "No");
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32964
#include<iostream>
#include<math.h>
using namespace std;

int main(){
 int x, temp, max1, max2=1;
 cin>>x;
 if(x==1){
  cout<<"1\n";
  return 0;
  }
 for(int i=2;i<=sqrt(x);i++){
  for(int j=1;;j++){
   temp=pow(i, j);
   if(temp>x){
    max1=temp/i;
    break;
   }
  }if(max2<max1)max2=max1;
 }cout<<max2<<"\n";
}

Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;

ll gcd(ll x, ll y){
  if(x%y==0) return y;
  return gcd(y, x%y);
}

const int MAX = 1000000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  ll N, A, B; ll K; cin >> N >> A >> B >> K;
  if(A<B) swap(A, B); int cnta = -1, cntb = -1;
  rep(i, N+1){
    if((K - A*i)%B==0 && K>=A*i){
      cnta = i; cntb = (K - A*i)/B; break;
    }
  }
  if(cnta==-1){
    cout << 0 << endl; return 0;
  }
  COMinit();
  ll G = gcd(A, B);
  if(K%G){
    cout << 0 << endl; return 0;
  }
  ll ans = 0;
  while(cnta<=N){
    ans+=(COM(N, cnta)*COM(N, cntb)%mod);
    ans%=mod;
    cnta+=(B/G); cntb-=(A/G);
  }
  cout << ans << endl;
}

Measured memory_bytes: 23680
n = int(input())
a = list(map(int, input().split()))
a_pop = {}

for ai in a:
  if not a_pop.get(ai):
    a_pop[ai] = 1
  else:
    a_pop[ai] += 1

hoge = sum(v * (v - 1) // 2 for v in a_pop.values())

for ai in a:
  ans = hoge
  v = a_pop[ai]
  print(ans - (v - 1))
 

Measured memory_bytes: 26012
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
	int n;
	double ans;
	cin >> n;
	if (n % 2 == 0)
		ans = 0.5;
	else ans = ((n / 2) + 1) / (double)n;
	cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define ll long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 998244353 
        #define inf 2e18
        
        int main() {

        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        ll k;
        cin>>k;
        queue<ll> q;
        ll ans;
        for(ll i=1;i<=9;i++)
        {  
            q.push(i);
        }
        ll c=0;
        ll fl=0;
        while(!q.empty()){
            c++;
            ll t=q.front();
            q.pop();
            if(fl) continue;
            if(c==k) {ans=t; fl=1; continue;}

            if(t%10==0){
                q.push(t*10);
                q.push(t*10+1);
            }else if(t%10==9){
                q.push(t*10+8);
                q.push(t*10+9);
            }else{
                q.push(t*10+ (t%10)-1);
                q.push(t*10+ (t%10));
                q.push(t*10+ (t%10)+1);
            }

        }


        cout<<ans;
        return 0;
    }

Measured memory_bytes: 1792
use std::collections::HashMap;
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let _ = scan!(usize);
    let s = scan!();

    let mut m = HashMap::new();
    for c in s.chars() {
        let v = m.entry(c).or_insert(0);
        *v += 1;
    }

    let mut ans = 1;
    for (_, v) in m {
        ans *= v + 1;
        ans %= 1e9 as i64 + 7;
    }
    println!("{}", ans - 1)
}


Measured memory_bytes: 4352
#!/usr/bin/env python3
# ITP2_11_C: Bitset 2 - Enumeration of Subsets 3

from functools import lru_cache


def subset(n, mask):
    @lru_cache(maxsize=None)
    def _subset(i):
        if i < 0:
            return [(0, [])]
        m = mask[i]
        return (_subset(i-1) +
                [(v + (1 << m), vs + [m]) for v, vs in _subset(i-1)])

    return _subset(len(mask)-1)


def run():
    n = int(input())
    mask = tuple([int(i) for i in input().split()][1:])

    for i, vs in subset(n, mask):
        print("{}:{}".format(i, "".join([" {}".format(v) for v in vs])))


if __name__ == '__main__':
    run()



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

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}

impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

type P = (f64, f64);
fn rotate(p1: P, p2: P, rad: f64) -> P {
    (
        p1.0 + (p2.0 - p1.0) * rad.cos() - (p2.1 - p1.1) * rad.sin(),
        p1.1 + (p2.0 - p1.0) * rad.sin() + (p2.1 - p1.1) * rad.cos(),
    )
}

fn koch(mut v: &mut Vec<P>, p1: P, p2: P, lv: usize) {
    if lv == 0 {
        v.push(p1);
        return;
    }
    let l = ((p2.0 - p1.0) / 3.0, (p2.1 - p1.1) / 3.0);
    let s = (p1.0 + l.0, p1.1 + l.1);
    let t = (p1.0 + l.0 * 2.0, p1.1 + l.1 * 2.0);
    let rad = std::f64::consts::PI / 3.0;
    let u = rotate(s, t, rad);
    koch(&mut v, p1, s, lv - 1);
    koch(&mut v, s, u, lv - 1);
    koch(&mut v, u, t, lv - 1);
    koch(&mut v, t, p2, lv - 1);
}

fn main() {
    let mut sc = Scanner::default();
    let out = &mut BufWriter::new(stdout());
    let n = sc.next();
    let mut ans = vec![];
    koch(&mut ans, (0.0, 0.0), (100.0, 0.0), n);
    ans.push((100.0, 0.0));
    for p in &ans {
        writeln!(out, "{} {}", p.0, p.1).ok();
    }
}



Measured memory_bytes: 5068
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  multiset<int> st={inf};
  //map<int,int> mp;
  reverse(all(a));
  rep(i,n){
    if(*st.upper_bound(a[i])==inf){
      st.insert(a[i]); //mp[a[i]]++;
    }
    else{
      st.erase(st.find(*st.upper_bound(a[i])));
      st.insert(a[i]); //mp[a[i]]++;
    }
  }
  /*
  int ans=0;
  for(int v:st){
    ans+=mp[v];
  }
  */
  int ans=st.size()-1;
  cout << ans << endl;
}

Measured memory_bytes: 5376
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main() {
  int i, j;

  char str[60];

  scanf("%[^\n]%*c", str);

  int n = strlen(str);
  n -= 8;
  for (i = 0; i < n; i++) {
    printf("%c", str[i]);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
using namespace std;
string s;
int aa[200];
signed main(){
	cin>>s;
	rep(i,s.size()){
		aa[s[i]]++;
	}
	rep(i,26){
		if(aa[i+97]==0){
			char c='a'+i;
			cout<<c;
			return 0;
		}
	}
	cout<<"None";
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		final int R = sc.nextInt();
		if(R < 1200) {
			System.out.println("ABC");
		} else if(R < 2800) {
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}
	}
}


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

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

    for(int i = 0;i < S.size();i++){
        if(S.at(i) + N <= 'Z'){
            S.at(i) = S.at(i) + N;
            cout << S.at(i);
        }else{
            S.at(i) = S.at(i) + N - 26;
            cout << S.at(i);
        }
    }

    cout << endl;
}

Measured memory_bytes: 256
// import chie template :) {{{
import std.stdio,
       std.algorithm,
       std.array,
       std.string,
       std.math,
       std.conv,
       std.range,
       std.container,
       std.bigint,
       std.ascii,
       std.typecons;
// }}}
// tbh.scanner {{{
class Scanner {
  import std.stdio;
  import std.conv : to;
  import std.array : split;
  import std.string : chomp;

  private File file;
  private dchar[][] str;
  private uint idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  private dchar[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    dchar[] s;
    while (s.length == 0) {
      s = file.readln.chomp.to!(dchar[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(uint len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  foreach (i; 0 .. 3) {
    string s = cin.next!string;
    write(s[i]);
  }
  writeln();
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Aug  4 22:01:34 2019

@author: miz18
"""




class SegmentTree:
    def __init__(self, L, op, ide):
        self.op = op
        self.ide = ide
        self.sz = len(L)
        self.n = 1
        self.s = 1
        for i in range(1000):
            self.n *= 2
            self.s += 1
            if self.n >= self.sz:
                break
        self.node = [self.ide]*(2*self.n-1)

        for i in range(self.sz):
            self.node[i+self.n-1] = L[i]

        for i in range(self.n-2,-1,-1):
            self.node[i] = self.op(self.node[i*2+1],self.node[i*2+2])
    
    def add(self, a, x):
        k = a+self.n-1
        self.node[k] += x
        for i in range(1000):
            k = (k-1)//2
            self.node[k] = self.op(self.node[2*k+1], self.node[2*k+2])
            if k <= 0:
                break
    
    def substitute(self, a, x):
        k = a+self.n-1
        self.node[k] = min(x,self.node[k])
        for i in range(1000):
            k = (k-1)//2
            self.node[k] = self.op(self.node[2*k+1], self.node[2*k+2])
            if k <= 0:
                break

    def get_one(self, a):
        k = a+self.n-1
        return self.node[k]
    
    def get(self, l, r):
        res = self.ide
        n = self.n
        if self.sz <= r or 0 > l:
            print("ERROR: the indice are wrong.")
            return False

        for i in range(self.s):
            count = 2**i-1
            a = (r+1)//n
            b = (l-1)//n
            if a-b == 3:
                res = self.op(self.node[count+b+1],res)
                res = self.op(self.node[count+b+2],res)
                right = a*n
                left = (b+1)*n-1
                break
            if a-b == 2:
                res = self.op(self.node[count+b+1],res)
                right = a*n
                left = (b+1)*n-1
                break
            n = n//2

        #left
        n1 = n//2        
        for j in range(i+1,self.s):
            count = 2**j-1 
            a = (left+1)//n1
            b = (l-1)//n1
            if a-b == 2:
                res = self.op(self.node[count+b+1],res)
                left = (b+1)*n1-1                
            n1 = n1//2

        #right
        n1 = n//2        
        for j in range(i+1,self.s):
            count = 2**j-1 
            a = (r+1)//n1
            b = (right-1)//n1
            if a-b == 2:
                res = self.op(self.node[count+b+1],res)
                right = a*n1                
            n1 = n1//2
        return res


N,M = list(map(int,input().split()))

road = []
for i in range(M):
    road.append(list(map(int,input().split())))

road.sort(key = lambda x: x[2])
road.sort(key = lambda x: x[0])

R = [10**27]*N
R[0] = 0
ST = SegmentTree(R,min,10**27)

for i in range(M):
    now_min = ST.get(road[i][0]-1,road[i][1]-1)
    ST.substitute(road[i][1]-1,now_min+road[i][2])
ans  = ST.get_one(N-1)

if ans>=10**27:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 95320
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class A
{
	public static void Main()
	{
		string strN = Console.ReadLine();
		bool ans = (strN[0] == strN[1]) && (strN[1] == strN[2]);
		ans |= (strN[1] == strN[2]) && (strN[2] == strN[3]);

		Console.WriteLine(ans ? "Yes" : "No");
	}
}





Measured memory_bytes: 13140
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
using namespace std;

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 a,b,c;
	cin >> a>> b>>c;
	cout << min(a*b,c) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int s,i = 1;
    cin >> s;
    vector<int> data(1000000);
    data.at(0) = s;
    bool flag_m = 0;
    while(1){
        if(data.at(i-1) % 2 == 0){//偶数だったら

            data.at(i) = data.at(i-1) / 2;

            for (int j = 0; j < i; j++){
                if(data.at(i) == data.at(j)) 
                    flag_m = 1;
            }

        }else{//奇数だったら

            data.at(i) = data.at(i-1) * 3 + 1;

            for (int j = 0; j < i; j++){
                if(data.at(i) == data.at(j)) 
                    flag_m = 1;
            }

        }
        i++;
        if(flag_m)break;
    }
    cout << i << endl;
}

Measured memory_bytes: 7224
import java.util.Scanner;

public class Main {

	private static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}

	private static long lcm(long m, long n) {
	    return m * n / gcd(m, n);
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long A = sc.nextInt();
		long B = sc.nextInt();

		sc.close();
		System.out.println(lcm(A,B));
	}


}


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

using namespace std;

const int MAX = 101;

vector<int> G[MAX];
int d[MAX], f[MAX];
int *T;

void dfs(int u) {

    if (!d[u]) d[u] = ++(*T);

    for (int v : G[u]) {
        if (!d[v]) {
            d[v] = ++(*T);
            dfs(v);
        }
    }

    if (!f[u]) f[u] = ++(*T);
}

int main() {

    int n;
    cin >> n;

    int t = 0;
    T = &t;
    fill(d, d + MAX, 0);
    fill(f, f + MAX, 0);

    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            G[u].push_back(v);
        }
    }

    for (int i = 1; i <= n; i++) {
        if (!d[i]) dfs(i);
    }


    for (int i = 1; i <= n; i++) {
        cout << i << " " << d[i] << " " << f[i] << endl;
    }
}


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

int main()
{
    string s;
    cin >> s;

    vector<int> cum_cnt(s.size() + 1, 0);
    rep(i, 0, s.size())
        cum_cnt[i + 1] = cum_cnt[i] + int(s[i] == 'B');
    
    ll ans = 0;
    rep(i, 0, s.size())
    if (s[i] == 'W')
        ans += cum_cnt[i ];

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

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

int main(){
  int n;cin>>n;
  int x[8],y[8];rep(i,n)cin>>x[i]>>y[i];
  vector<vector<double>>dst(n,vector<double>(n,0));
  rep(i,n){
    rep(j,n){
      dst[i][j]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    }
  }
  vector<int> v(n);rep(i,n)v[i]=i;
  double sum=0;
  do{
    rep(i,n-1){
      sum+=dst[v[i]][v[i+1]];
    }
  }while(next_permutation(all(v)));
  
  int p=1;rep(i,n)p*=(i+1);
  cout << fixed << setprecision(10);
  cout<<sum/p;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from collections import *
import math
from bisect import *
import functools
INF = float('inf')
mod = 10**9+7

class BIT:
    def __init__(self, N):
        self.N = N
        self.bit = [0 for _ in range(N+1)]
    def add(self, x, a):
        while x <= self.N:
            self.bit[x] += a
            x += x & -x
    def sum(self, x):
        ret = 0
        while x != 0:
            ret += self.bit[x]
            x -= x & -x
        return ret

N, K = map(int, input().split())
A = [int(x) for x in input().split()]
bit = BIT(2001)
cnt = 0
for a in A:
    cnt += bit.sum(2000)-bit.sum(a)
    bit.add(a, 1)
X = 0
for a in A:
    X += bit.sum(a-1)
print((cnt*K+X*(K-1)*K//2)%mod)

Measured memory_bytes: 40688
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 10005
#define MAX_E 30005
#define NIL -1
#define WHITE 0
#define BLACK 1
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

class Edge {
    ll t, w;
    Edge(ll t, ll w): t(t), w(w) {}
};

ll N;
ll t[101]={}, v[101]={};

int main(void) {
    string s;
    cin >> s;
    
    ll cntg=0, cntp=0;
    ll ans=0;
    for(ll i=0; i<s.size(); i++) {
        if(cntp<cntg) {
            cntp++;
            if(s[i]=='g') {
                ans++;
            }
        }else {
            cntg++;
            if(s[i]=='p') {
                ans--;
            }
        }
    }
    
    prin(ans);
    
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
using namespace std;
typedef long long ll;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
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 int INF = 1e9;
const int MAX_N = 200000;

int main() {
    int N; cin >> N;
    vector<int> P(N);
    rep(i,N) cin >> P[i];
    int ans = 0;
    int mn = INF;
    rep(i,N) {
        chmin(mn, P[i]);
        if(mn >= P[i]) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val mod = 998244353L
    val (n, s) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map { it.toInt() }
    val dp = Array(n + 1) { Array(s + 1) { 0L } }
    dp[0][0] = 1
    (1..n).forEach { i ->
        (0..s).forEach { j ->
            dp[i][j] += dp[i - 1][j] * 2; dp[i][j] %= mod
            if (j + a[i-1] <= s) {
                dp[i][j + a[i-1]] += dp[i - 1][j]
                dp[i][j + a[i-1]] %= mod
            }
        }
    }
    println(dp[n][s])
}

Measured memory_bytes: 409076