akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::Ordering::{Equal, Greater, Less};
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;

// collatz-problem.rs --- Collatz Problem
// author: Seong Yong-ju <sei40kr@gmail.com>

// tanakah's input macro
// cf https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn f(x: u32) -> u32 {
    if x % 2 == 0 {
        x / 2
    } else {
        3 * x + 1
    }
}

fn main() {
    input! {
        s: u32,
    };

    let mut memo = [false; 1_000_001];

    let mut x = s;
    let mut ans = 1;
    while !memo[x as usize] {
        memo[x as usize] = true;
        ans += 1;
        x = f(x);
    }

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


Measured memory_bytes: 5244
#include <iostream>

using namespace std;

int main()
{
	int a, b, c;
	int a2, b2, c2;
	int num = 0, num1 = 0;
	char dot, dot1;

	while ( cin >> a >> dot >> b >> dot1 >> c )
	{
		a2 = a * a;
		b2 = b * b;
		c2 = c * c;

		if ( a == b )
		{
			if ( a2 + b2 != c2 )
				num1 = num1 + 1;
		}
		else 
		{
			if ( a2 + b2 == c2 )
				num = num + 1;
		}
	}

	cout << num << endl;
	cout << num1 << endl;

	return 0;
}

Measured memory_bytes: 2972
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<ll>a(n),b(n);
    REP(i,n)cin >> a[i]; REP(i,n)cin >> b[i];
    vector<ll>dif(n);
    REP(i,n)dif[i] = a[i]-b[i];
    SORT(dif);
    int m = 0;
    ll total = 0;
    REP(i,n){
        if(dif[i] < 0){
            m++;
            total-=dif[i];
        }else break;
    }
    reverse(ALL(dif));
    ll temp=0;
    int p = 0;
    if(temp >= total){
        cerr << "aaa" << endl;
        cout << 0 << endl;
        return 0;
    }
    REP(i,n){
        temp+=dif[i];
        p++;
        if(temp >= total){
            cout << m+p << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 5580
import java.util.Scanner;

public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        int a =sc.nextInt();
        int b =sc.nextInt();
        if(a < b){
            System.out.println("a < b");
            } else if(a > b) {
			System.out.println("a > b");
		} else if(a == b){
			System.out.println("a == b");
		}

		sc.close();
	}
}




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

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

def main():
	lis = ["Sunny", "Cloudy", "Rainy"]
	s = input()
	print(lis[lis.index(s) - 2])


if __name__=='__main__':
	main()


Measured memory_bytes: 5396
#include <bits/stdc++.h>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
const int MAXN=100100;
char s[1000];
bool check(int p){
    if(s[p]=='A' && s[p+1]=='B' && s[p+2]=='C') return 1;
    return 0;
}
int main()
{
    ios;
    int n,cnt=0;
    cin>>n;
    cin>>s+1;
    int len=strlen(s+1);
    for(int i=1;i<=len;i++){
        if(s[i]=='A'){
            if(check(i)){
                cnt++;
                i+=2;
            }
        }
    }
    cout<<cnt<<'\n';
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int N;
int pat[200020];
int last[200020];
const int M = 1000000000 + 7;

int main() {
  while (cin >> N) {
    pat[0] = 1;
    for (int i = 1; i <= N; ++i) {
      int c;
      cin >> c;
      pat[i] = pat[i-1];
      if (last[c] > 0 && i - last[c] > 1) {
	pat[i] = (pat[i] + pat[last[c]]) % M;
      }
      last[c] = i;
    }
    cout << pat[N] << endl;
  }
}


Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=0;
    if(n==1){
        if(a==b) ans=1;
    }else{
        if(a<=b) ans=(n-2)*(b-a)+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define sc second
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define pb push_back
#define endl '\n'
#define po(x) (1ll<<x)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pp;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> satan_set;
const ll DIM = 100+7;
const ll INF = 10E16;

int main()
{
    //freopen("input.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s,t;
    cin>>s>>t;
    cout<<t<<s<<endl;
    return 0;
}

// 1 2 3
//


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, M;
std::string S, T;

LL gcd(LL a, LL b)
{
	if (a < b) std::swap(a, b);
	LL r = a % b;
	while (r != 0)
	{
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

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

int main()
{
	in >> N >> M >> S >> T;
	LL L = lcm(N, M);
	std::map<LL, char>res1, res2;
	rep(i, N)
	{
		LL pos = i * (L / N);
		res1[pos] = S[i];
	}
	rep(i, M)
	{
		LL pos = i * (L / M);
		res2[pos] = T[i];
	}
	for (LL i = 0; i < L; i += lcm(L / N, L / M))
	{
		if (res1[i] != '\0' && res2[i] != '\0' && res1[i] != res2[i])
		{
			out << -1 << std::endl;
			return 0;
		}
	}
	out << L << std::endl;
	return 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
         
    int main() {
        string S, T;
        cin >> S >> T;

        int A, B;
        cin >> A >> B;

        string U;
        cin >> U;

        if(S == U)
            cout << A-1 << " " << B << endl;
        else if(T == U)
            cout << A << " " << B-1 << endl;
        
        }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int n;

double rec(int i, int j, int k){
    static vector<vector<vector<double>>> dp(310, vector<vector<double>>(310, vector<double>(310, 0.0)));
    if(dp[i][j][k] > 0){
            return dp[i][j][k];
    }
    if(i + j + k == 0){
        return 0.0;
    }
    double res = 0.0;
    if(i > 0){
        res += rec(i-1, j, k) * i;
    }
    if(j > 0){
        res += rec(i+1, j-1, k) * j;
    }
    if(k > 0){
        res += rec(i, j+1, k-1) * k;
    }
    res = (res + n) / (i + j + k);
    return dp[i][j][k] = res;
}

int main(){
    cin >> n;
    vector<int> v(4);
    REP(i, n){
        int a;
        cin >> a;
        v[a]++;
    }
    cout << setprecision(10) << rec(v[1], v[2], v[3]) << endl;
    
    return 0;
}

Measured memory_bytes: 237696
let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => {
  content += buf;
});

process.stdin.on('end', () => {
  const result = content
    .trim()
    .split('')
    .map(char => char.charCodeAt(0))
    .map(code => {
      if (isLowerCase(code)) {
        return code - 32;
      } else if (isUpperCase(code)) {
        return code + 32;
      } else {
        return code;
      }
    })
    .map(code => String.fromCharCode(code))
    .join('');

  console.log(result);
});

const isLowerCase = charCode => charCode >= 97 && charCode <= 122;

const isUpperCase = charCode => charCode >= 65 && charCode <= 90;


Measured memory_bytes: 16720
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, C):
    ans = 0
    ri = []
    for i,c in enumerate(C):
        if c == 'R':
            ri.append(i)

    for i, c in enumerate(C):
        if c == 'W' and ri and ri[-1] > i:
            ans += 1
            ri.pop()

    return ans


def main():
    N = read_int()
    C = read_str()
    print(slv(N, C))


if __name__ == '__main__':
    main()


Measured memory_bytes: 92040
https://atcoder.jp/contests/abc081/tasks/abc081_a
function Main(input) {
  console.log(input.split('').reduce((acc, cur) => Number(acc) + Number(cur), 0))
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

long double p[3010];
long double dp[3010][3010];

int main(){
    int n;
    cin >> n;
    rep(i, n) cin >> p[i];

    dp[0][0] = 1;

    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= i; j++){
            if (i >= j+1) dp[i][j] = (1-p[i-1])*dp[i-1][j] + p[i-1]*dp[i-1][j-1];
            else dp[i][j] = p[i-1]*dp[i-1][j-1];
        }
    }

    long double ans = 0;
    rep(i, n+1) if (i > n/2) ans += dp[n][i];

    cout << fixed << setprecision(15) << ans << endl;

    return 0;
}


Measured memory_bytes: 139776
#include <stdio.h>
int main(){
int x;
scanf("%d",&x);
if(x<=999 && x>=1)
{


if(x%10==2 || x%10==4 || x%10==5 || x%10==7 || x%10==9)
{
    printf("hon");
}
else if(x%10==0 || x%10==1 || x%10==6 || x%10==8)
{
    printf("pon");
}
else if(x%10==3)
{
    printf("bon");
}
return 0;
}
}




Measured memory_bytes: 1732
N = int(input())
counts = [[0]*10 for i in range(10)]
top = 1
for i in range(1,N+1):
    if i == top*10:
        top *= 10
    a_top = i//top
    a_bottom = i%10
    
    counts[a_top][a_bottom] +=1


sums = 0
for i in range(1,10):
    for j in range(1,10):
        sums+= counts[i][j]*counts[j][i]

print(sums)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<tuple<string, int, int>> a;
  for(int i = 1; i <= N; i++){
    string s;
    int p;
    cin >> s >> p;
    p = -p;
    a.push_back(tie(s, p, i));
  }
  
  sort(a.begin(), a.end());
  
  for(int i = 0; i < N; i++){
    cout << get<2>(a[i]) << endl;
  }
}

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

int main(void)
{
  int N, M;
  int total = 0;
  scanf("%d", &N);
  scanf("%d", &M);
  int A[M];
  for(int i = 0; i < M; i++){
    scanf("%d", &A[i]);
    total += A[i];
  }
  if(total > N){
    printf("-1\n");
  }
  else{
    printf("%d\n", N - total);
  }

  return 0;
  }


Measured memory_bytes: 1760
#include <iostream>
#include <string>

using namespace std;

int main(void) {
    string S;
    cin >> S;
    int N = S.size();
    int red = 0;
    int blue = 0;
    for(int i=0; i<N; i++) {
        if(S.at(i) == '0') {
            red++;
        } else {
            blue++;
        }
    }
    cout << 2 * min(red, blue) << endl;
    return 0;
}


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

int keta(int N,int K){
  return (N<K?1:keta(N/K,K)+1);
}

int main(){
  int N,K;
  cin>>N>>K;
  cout << keta(N,K);
}

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

int main() {
	string S, T;
	cin >> S >> T;

	int sLen = S.size();
	if (T.size() != sLen + 1) {
		cout << "No";
		return 0;
	}

	if (T.substr(0, sLen) == S) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3136
#include <cstdio>

using namespace std;

int main(void){
  int n, ans;
  char c;
  
  ans = 3;
  scanf("%d", &n);
  for (int i=0; i<n; i++){
    while (scanf("%c", &c), c<'A' && c>'Z');
    if (c=='Y' && ans==3) ans=4;
  }
  
  puts(ans==3?"Three":"Four");
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
char ch[2005];
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	scanf("%s",ch);
	For(i,0,2)putchar(ch[i]);
}


Measured memory_bytes: 3760
N, M = map(int, input().split())
V = [-1]*N

if M == 0 and N == 1:
	print(0)
	exit()

for i in range (0, M):
	A, B = map(int, input().split())
	if V[A-1] == -1 or V[A-1] == B:
		V[A-1] = B
	else:
		print(-1)
		exit()
        
if V[0] == 0 and len(V) > 1:
	print(-1)
	exit()

for i in range (0, N):
	if V[i] == -1:
		if i ==0:
			V[i] = 1
		else:
			V[i] = 0

print(*V, sep="")

Measured memory_bytes: 9100
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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 maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}

vector<ll> pw2(51,1);vector<ll> pw10(19,1);
ll high_order_bit(ll n){
    ll tmp=1,i=-1;
    while(tmp<=n){
        tmp*=2;
        i++;
    }
    if(n==0) return 0;
    else return i;
}
vector<ll> binary_expansion(ll n){
    vector<ll> B(high_order_bit(n)+1);
    ll tmp=n;
    for(ll i=high_order_bit(n);i>=0;i--){
        B[i]=tmp/pw2[i];
        tmp%=pw2[i];
    }
    return B;
}
vector<ll> divisor(ll x){
    vector<ll> div;
    for(int i=1;i*i<=x;i++){
        if(i*i!=x && x%i==0){
            div.pb(i);
            div.pb(x/i);
        }
        else if(x%i==0) div.pb(i);
    }
    sort(all(div));
    return div;
}
vector<ll> vectorprime(ll x){
    vector<bool> is_prime(x+1);
    vector<ll> prime;
    rep(i,x+1) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<=x;i++){
        if(is_prime[i]){
            prime.pb(i);
        }
        for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
    }
    return prime;
}
ll binary_search(vector<ll> v,ll key){ //key以上が初めて出てくる添字(0-index)
    int l=0,r=sz(v)-1;
    while(r-l>=1){
        int i=(l+r)/2;
        //cout<<l<<" "<<r<<" "<<i<<endl;
        if(v[i]<key) l=i+1;
        else r=i;
    }
    if(v[l]>=key) return l;
    else return INF;
}

int main(){
    {rep1(i,50) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    ll ans=0;
    vector<ll> L(N,0);
    rep(i,N) cin>>L[i];
    sort(all(L));
    rep(i,N-2)FOR(j,i+1,N-1){
        ll lim=L[i]+L[j]; //これより短く
        ll tmp=binary_search(L,lim);
        if(tmp==INF) ans+=(N-1-j);
        else{
            ans+=tmp-1-j;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3648
#include<iostream>

using namespace std;

int main(){
	int n;
	cin>>n;
	const int m=n;
	int a[m];
	int b[m];
	int sum=0;
	for(int i=0;i<m;i++){
		cin>>a[i];
		}
	for(int i=0;i<m;i++){
		cin>>b[i];
		b[i]=a[i]-b[i];
		}
    for(int i=0;i<m;i++){
		if(b[i]>0){
			sum=sum+b[i];
			}
		}
	cout<<sum;
	}
/*	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++){
			if(b[j]>bi){
				bi=b[j];
				t=j;
				}
			v=j;
			}
		sw=b[t];
		b[t]=b[v];
		b[v]=sw;
		}	
	*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define ll long long
#define ldb long double
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(i,a,b) for (int i = (a); i < (b); ++i)
#define rrof(i,a,b) for (int i = (b)-1; i >= (a); --i)


const int MOD = 1e9+7;
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n){
	ll res=1;

	while(n){
		if(n%2)
		res*=a;
		a*=a;
		n/=2;
	}
	
	return res;
}

int main(){
	fast;
	
	ll int h;
	cin>>h;
	
	ll int x=1;
	while(h!=0){
		h=h/2;
		x=x*2;
	}	
		
	cout<<x-1;
	return 0;
}


Measured memory_bytes: 256
let N = stdin.ReadLine() |> int64
let A = stdin.ReadLine().Split() |> Array.map int64

let minTotal = 
    A 
    |> Array.fold 
        (fun (before, total) next ->
            let plusOrZero x = if x >= 0L then x else 0L 
            let step = plusOrZero (before - next)
            step + next, total + step ) 
        (0L, 0L)
    |> snd

stdout.WriteLine (string minTotal)

Measured memory_bytes: 60968
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	int N,d,t,q;
	const int L = 16 * 9 * 5 * 7 * 11;
	while(cin >> N && N){
		int Q[25][25] = {{0}};
		for(int i = 0; i < N; i++){
			cin >> d >> t;
			for(int j = 0; j < d; j++){
				cin >> q;
				Q[d][(j+d-t)%d] += q;
			}
		}
		int sum = 0, T[L] = {0};
		for(int d = 1; d <= 24; d++){
			if(d == 13 || d == 17 || d == 19 || d == 23)
				sum += *max_element(Q[d],Q[d]+d);
			else
				for(int i = 0; i < L; i++) T[i] += Q[d][i%d];
		}
		cout << sum + *max_element(T,T+L) << endl;
	}
	return 0;
}

Measured memory_bytes: 1384
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())

INF = 10**9


def main():
    N, A, B = in_nn()
    diff = A - B
    h = list(in_all())

    def is_ok(mid):

        cnt = 0
        for i in range(N):
            x = h[i] - mid * B
            if x > 0:
                cnt += (x + diff - 1) // diff

        return cnt <= mid

    def binary_search(ng, ok):

        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok

    ans = binary_search(0, INF + 1)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18664
// 配りDPと集めDP
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}

const long long INF = 1LL << 60;

int N;
long long h[100010];

// dp
long long dp[100010];

int main() {
    int N,K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    dp[0] = 0;

    for (int i = 1; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            if (i > j-1) chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll S;
    cin >> S;
    ll h, m, s;
    h = S / 3600;
    S %= 3600;
    m = S / 60;
    s = S % 60;
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define hell 1000000007
    using namespace std;
    int n;
    vector < int > v(200050);
    void call()
    {
        vector < int > vv(n+1);
        for(int i=0;i<n;i++)
        {
            int d=i-v[i];
            d=max(d,0);
            //cout<<d<<" ";
            vv[d]++;
            d=i+v[i]+1;
            d=min(d,n); //cout<<d<<endl;
            vv[d]--;
        }
        v[0]=vv[0];
        for(int i=1;i<n;i++)
        {
            vv[i]+=vv[i-1];
            v[i]=vv[i];
        }
        int y=0;
        for(int i=0;i<n;i++)
        {
            if(vv[i]>=n)
                y++;
        }
        if(y==n)
            {for(int i=0;i<n;i++) cout<<n<<" ";
        exit(0);}
    }
    void solve()
    {
     ll a,b,c,p,q,r,k;
    cin>>n>>k; int i;
    rep(i,0,n) cin>>v[i];
    rep(i,0,k)
    {
        call();
    }
    for(i=0;i<n;i++) cout<<v[i]<<" ";

}

    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
        //cin>>t;
        while(t--)
        solve();
    }


Measured memory_bytes: 4988
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  ll ans = 0;
  string t = to_string(n);
  string z="";
  for(int i=1;i<t.size();i++) z+=t[i];

  vll tn(15, 1);rep(i, 1, 15) tn[i] = tn[i-1]*10;
  for(ll i=1;i<=n;i++){
    string tmp = to_string(i);
    char A = tmp[tmp.size()-1], B = tmp[0];
    // 1keta
    if(A=='0') continue;
    if(A==B) ans++;
    for(ll k=2;k<t.size();k++) ans+=tn[k-2];
    if(t.size()==1) continue;
    if(A-'0'>t[0]-'0') continue;
    if(A-'0'<t[0]-'0'){
      ans += tn[t.size()-2];
    }else{
      ll y=0;
      if(B-'0'>t[t.size()-1]-'0') y++;
      ll x = stoll(z);
      x/=10;
      ans += x+1-y;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


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


int main() {
  
  long long L,R;
  cin >> L >> R;

  

  if(R - L >= 2019) {
      cout << 0 << endl;
  }else {
      int mini = 20000;
      for(int i = L;i < R;i++) {
          for(int j = i + 1;j <= R;j++) {
              int rest = ((i % 2019) * (j % 2019)) % 2019;
              mini = min(rest,mini);
          }
        }

        cout << mini << endl;
   }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string S;
  string T;
  cin >> N >> S >> T;
  
  for (int i=0; i<N; i++) {
    cout << S[i] << T[i];
  }
  cout << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
x = list(map(int,input().split()))
x.sort()
x_cm = np.cumsum(x)[::-1]
x = x[::-1]
count = 1
for i in range(N-1):
    if x[i]<=x_cm[i+1]*2:
        count += 1
    else:
        break

print(count)

Measured memory_bytes: 38760
#include<iostream>

using namespace std;

int main() {
	int a,b;
	cin >> a >> b;
	if (a == 1)a += 13;
	if (b == 1)b += 13;
	if (a > b)cout << "Alice" << endl;
	else if (b > a)cout << "Bob" << endl;
	else cout << "Draw" << endl;
	return 0;
}

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

int main(){
  int n;cin>>n;int ans=0;
  vector<int> p(n);
  for(int i=0;i<n;i++)cin>>p[i];
  for(int i=0;i<n-2;i++)if(min(p[i],p[i+2])<p[i+1]&&p[i+1]<max(p[i],p[i+2]))ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;



int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    vector<int> m(n);
    m[0] = p[0];
    rrep(i,n-1) m[i] = min(m[i-1], p[i]);
    int ans = 0;
    rep(i,n) if(m[i] == p[i]) ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define smax(a, b) ((a) < (b) ? ((a)=(b), true) : false)
#define smin(a, b) ((a) > (b) ? ((a)=(b), true) : false)
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;

int n;
int dp[100000][3];
int arr[100000][3];
int main() {
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    }
    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];
    
    for(int i = 1; i < n; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            for(int h = 0; h < 3; h++)
            {
                if(j != h)
                {
                    dp[i][j] = max(dp[i][j], dp[i-1][h] + arr[i][j]);
                }
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < 3; i++)
    {
        ans = max(ans, dp[n-1][i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long a, b, c, e;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << '0' << "\n";
	}
	else if(max(a, max(b, c)) == c) {
		cout << a * b << "\n";
	}
	else if (max(a, max(b, c)) == b) {
		cout << a * c << "\n";
	}
	else {
		cout << b * c << endl;
	}
	max(a, max(b, c));
	cin >> e;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    ll n;
    IN n;
    ll h = sqrt(n);
    P(h*h);;
    
	return  0;
}

Measured memory_bytes: 256
// ABC 040 C
#include<bits/stdc++.h>
 
using namespace std;
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())

#define PB(a) push_back(a)

#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


//------------------------------------------
//Greatest Common Devider
LL gcd(LL a,LL b){
  if(b == 0) return a;
  return gcd(b,a%b);
}
//------------------------------------------
//Least Common Multiple
//Must be used with GCD
LL lcm(LL a,LL b){
  LL g = gcd(a,b);
  return a / g * b;
}
//------------------------------------------

int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  LL n,ans;
  cin >> n;
  cin >> ans;
  REP(i,n-1){
    LL t;
    cin >> t;
    ans = lcm(t,ans);
  }
  cout << ans << endl;
  return 0;
}


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

const int MAX = 510000;
const int MOD = 1000000007;
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() {
  int n, k;
  cin>>n>>k;
  long long a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  sort(a, a + n);
  long long ans = 0;
  COMinit();
  for (int i=n-1; i>=k-1; i--) {
    if (a[i] < 0) {
      a[i] = ((-a[i] - 1) / MOD + 1) * MOD + a[i];
    }
    ans += a[i] * COM(i, k - 1);
    ans %= MOD;
  }
  for (int i=0; i<=n-k; i++) {
    if (a[i] < 0) {
      a[i] = ((-a[i] - 1) / MOD + 1) * MOD + a[i];
    }
    ans -= a[i] * COM(n - 1 - i, k - 1);
    if (ans < 0) {
      ans = ((-ans - 1) / MOD + 1) * MOD + ans;
    }
    ans %= MOD;
  }
  cout<<ans<<endl;
}

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

int main() {
    int n, x;
    cin>>n>>x;
    
    int m[n];
    int i;
    
    for(i=0; i<n; i++){
        cin>>m[i];
    }
    
    int all_var=0; //全て１個づつ
    for(i=0; i<n; i++){
        all_var += m[i];
    }
    
    int m_min=x; //一番材料の少ないもの
    for(i=0; i<n; i++){
        if(m_min>m[i]){
            m_min = m[i];
        }
    }
    
    int num_output;
    num_output = n + (x-all_var)/m_min;
    
    cout<<num_output<<endl;
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
MM = input().split()
total = 1
for i in MM:
  total = total*int(i)

  if total > 10**18:
    break
for i in MM:
  if int(i) == 0:
    total = 0
if total > 10**18:
  print(-1)
else:
  print(total)
  

Measured memory_bytes: 19376
#include <iostream>

int main()
{
    int w, h, x, y, r;
    std::cin >> w >> h >> x >> y >> r;

    bool result = (r <= x) && (x <= w - r) && (r <= y) && (y <= h - r);
    if (result) {
        std::cout << "Yes" << std::endl;        
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = unsigned long long;

int main() {

	int n, d;
	int cnt = 0;
	cin >> n >> d ;

	vector<vector<int>> x(n, vector<int>(d) );

	rep(i, n) {
		rep(j, d) {
			cin >> x[i][j];
		}
	}

	rep(i,n){
		for(int j=i+1;j<n;j++) {

			ll aa = 0;
			rep(p, d) {
				aa += pow(x[i][p] - x[j][p], 2);
			}
			long double D = sqrt(aa);
			int I = sqrt(aa);
			
			if ((double)D - I ==0 )cnt++;
		}
	}


	std::cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

const int MAX = 100010;
const int INF = 1e9;
vector<P> G[MAX];
//bool seen[MAX];
int D[MAX];
int n;

void dfs(int now){
    for(int i = 0; i < G[now].size(); i++){
        P p = G[now][i];
        int to = p.first;
        int cost = p.second;
        if(D[to] > D[now] + cost){
            D[to] = D[now] + cost;
            dfs(to);
        }
    }
}

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

    cin >> n;
    for(int i = 0; i < n - 1; i++){
        int s, t, w;
        cin >> s >> t >> w;
        G[s].push_back({t, w});
        G[t].push_back({s, w});
    }

    for(int i = 0; i < n; i++){
        D[i] = INF;
    }

    D[0] = 0;
    dfs(0);

    int maxi = -1e9;
    for(int i = 0; i < n; i++){
        if(D[i] > maxi){
            maxi = D[i];
        }
    }

    vector<int> I;
    for(int i = 0; i < n; i++){
        if(D[i] == maxi){
            I.push_back(i);
        }
    }

    int ans = -1e9;
    for(int i = 0; i < I.size(); i++){
        for(int j = 0; j < n; j++){
            D[j] = INF;
        }
        D[I[i]] = 0;
        dfs(I[i]);

        maxi = -1e9;
        for(int i = 0; i < n; i++){
            maxi = max(maxi, D[i]);
        }
        ans = max(ans, maxi);
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13648
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

ans = 0
hq = []
n,m = inpl()
ab = [[] for i in range(m)]
for i in range(n):
    a,b = inpl()
    if a <= m:
        ab[a-1].append(b)

heapq.heapify(hq)
for i in range(m):
    for j in ab[i]:
        heapq.heappush(hq,-j)
    if hq:
        ans -= heapq.heappop(hq)
print(ans)


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

int a, b, c, d, n;

signed main()
{
    cin >> n >> a >> b >> c >> d;
    printf("%lld\n", min(((n + a - 1) / a) * b, ((n + c - 1) / c) * d));


    return 0;
}



Measured memory_bytes: 3220
var input: string = require('fs').readFileSync('/dev/stdin', 'utf8');
var inputLines: string[] = input.trim().split("\n");
var parts = inputLines[0].split(" ");

var a = parseInt(parts[0]);
var b = parseInt(parts[1]);
var c = parseInt(parts[2]);

console.log(b - a == c - b ? "YES" : "NO");

Measured memory_bytes: 7372
#include<iostream>
#include<string>
#include<cstdlib>
#include<stdio.h>
using namespace std;

int main(){

    long long int x ,k, d;
    cin >> x >> k >> d;

    if(x > 0){
        if(k<x/d){cout << llabs(x - k*d) <<endl;}
        else{
        k = k - (x/d);
        x = x - (x/d)*d;
        if(k % 2 == 0 ){
        cout << llabs(x) << endl;    
        }else{
           cout << llabs(x-d) << endl;
        }
        }
    }else
    {   if(k<llabs(x/d)){cout << llabs(x + k*d) <<endl;}
        else{
        k = k + (x/d);
        x = x - (x/d)*d;
        if(k % 2 == 0 ){
        cout << llabs(x) << endl;    
        }else{
           cout << llabs(x+d) << endl;
        }
        }
    }
    

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

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

    if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9){
        cout << "hon" << endl;
    } else if(n%10==3){
        cout << "bon" << endl;
    } else {
        cout << "pon" << endl;
    }
    return 0;

}


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

#define M 1000001
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

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

int find(char str[]){
    long long key, i, h;
    key = getKey(str);

    for (i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0) return 1;
    else if (strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]){
long long key, i, h;
    key = getKey(str);

    for (i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }



}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}


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

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray(int n)
        {
            var array = Array();
            var result = new int[n];
            for (int i = 0; i < n; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }


        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }

        public uint NextUint()
        {
            return uint.Parse(Next());
        }
    }

    class Program
    {
        private int N, K;
        private int[] A;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            K = sc.NextInt();
            A = sc.IntArray();
        }


        public void Solve()
        {
            Scan();
            int a = N - 1;
            int b = K - 1;
            Console.WriteLine((a + b - 1) / b);
        }


        static void Main() => new Program().Solve();
    }
}

Measured memory_bytes: 18912
program main
  implicit none
  character(len=100000) :: S
  character :: S1
  integer :: N,i,ic
  integer :: out
  read(*,*) S

  N=len(trim(S))
  S1=S(1:1)
  ic=1
  out=0
  do i = 2,N
     if (S1 == S(i:i)) then
        ic = ic+1
        cycle
     else
        out = out + ic/2
        S1=S(i:i)
        if (mod(ic,2) == 0) then
           ic = 2
        else
           ic = 1
        end if
     end if
  end do
  out = out + ic/2
  write(*,'(i0)') out
  stop
end program main

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

using namespace std;

int N;
int t[100010], x[100010], y[100010];

int main()
{
    cin >> N;
    N++;
    for (int i = 1; i < N; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }

    bool isPossible = true;
    for (int i = 1; i < N; i++) {
        int r = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
        int dt = t[i] - t[i - 1];
        if (r > dt || (r ^ dt) % 2) {
            isPossible = false;
            break;
        }
    }

    cout << (isPossible ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 1408
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int x=in();int y=in();int z=in();int K=in();
	vector<int> a(x),b(y),c(z);
	trav(i,a)i=in();sort(a.rbegin(),a.rend());
	trav(i,b)i=in();sort(b.rbegin(),b.rend());
	trav(i,c)i=in();sort(c.rbegin(),c.rend());
	vector<int> val;
	for(int i=0;i<x;i++)
	for(int j=0;j<y;j++)
	for(int k=0;k<z;k++)
	{
		if((i+1)*(j+1)*(k+1)<=K)
		val.push_back(a[i]+b[j]+c[k]);
		else break;
		
	}
	
	sort(val.rbegin(),val.rend());
	for(int i=0;i<K;i++)cout<<val[i]<<'\n';
	
}

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

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int X, Y;
    cin >> X >> Y;

    for (int i = 0; i <= X; i++) {
        int j = X - i;
        if (i * 2 + j * 4 == Y) {
            cout << "Yes\n";
            return 0;
        }
    }

    cout << "No\n";
}

Measured memory_bytes: 3636