akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
typedef long long ll;

ll INF = 1e18;
int N,K;
vector<ll> x(55),y(55);

bool judge(ll xi,ll xj,ll yi,ll yj){
    int ct = 0;
    rep(k,N){
        if((x[k] - xi)*(x[k]- xj) <= 0 && (y[k] - yi)*(y[k]- yj) <= 0) ct++;
    }
    if(ct >= K) return true;
    else return false;
}


int main(){
    cin >> N >> K;
    rep(i,N) cin >> x[i] >> y[i];
    
    ll ans = 5*INF;
    
    rep(i,N) rep(j,N){ 
        if(i <= j) continue;
        
        rep(k,N) rep(h,N){
            if(k <= h) continue;

            ll lx = abs(x[j] - x[i]);
            ll ly = abs(y[k] - y[h]);
            if(judge(x[i],x[j],y[k],y[h])) ans = min(ans, lx*ly);
        }
    }
    
    cout << ans << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;


int main(){
    
    string s;
    cin >> s;
    int num[100] = {0};

    rep(i,s.size()){
        num[s[i]-97]++;
    }


    for(int i = 0; i<26; i++){
        if(!num[i]) {
            char c = 97 + i;
            cout << c << endl;
            break;
        }
        if(i==26-1) {
            cout << "None" << endl;
            break;
        }
    }


    return 0;
};



Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;


int main(){
    int N,K,one;
    int A[100010];
    cin>>N>>K;
    rep(i,0,N){
        cin>>A[i];
        if(A[i]==1)one=i+1;//左からなんこめ
    }
    int l,r;
    l=one/(K-1);
    if(one%(K-1)!=0)l++;
    r=(N-1-one)/(K-1);
    if((N-1-one)%(K-1)!=0)r++;
    
    int ans=(N-1)/(K-1);
    
    if((N-1)%(K-1)!=0)ans++;
    
    cout<<ans<<endl;

    

}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int cnt[2][112345];
int main(){
  int n;cin>>n;
  repeat(i,n){
    int v;cin>>v;
    cnt[i&1][v]++;
  }
  ll ans=0;
  int a[2][2]={{0,0},{0,0}},acnt[2][2]={{0,0},{0,0}};
  repeat(i,2){
    repeat(j,100001){
      if(acnt[i][0]<cnt[i][j]){
        a[i][1] = a[i][0];
        acnt[i][1] = acnt[i][0];
        a[i][0] = j;
        acnt[i][0] = cnt[i][j];
      }else if(acnt[i][1]<cnt[i][j]){
        a[i][1] = j;
        acnt[i][1] = cnt[i][j];
      }
    }
  }
  if(a[0][0]!=a[1][0]){
    ans = n - (acnt[0][0]+acnt[1][0]);
  }else{
    ans = n - max(acnt[0][1]+acnt[1][0],acnt[0][0]+acnt[1][1]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
i=0
xArray=[]
yArray=[]
while True:
    x,y=(int(num) for num in input().split())
    if x==0 and y==0:
        break
    else:
        xArray.append(x)
        yArray.append(y)
        i+=1
for count in range(i):
    if xArray[count] < yArray[count]:
        print(xArray[count],yArray[count])
    else:
        print(yArray[count],xArray[count])


Measured memory_bytes: 6136
def main():
    from bisect import bisect_left

    n = int(input())
    *a, = map(int, input().split())

    a.sort()

    i0 = bisect_left(a, 0)
    # 0以上の値を指す最小のindex
    # [0,i0) : 負
    # [i0,n) : 正

    sum_ = 0
    if i0 == 0:
        # 0以上のみ
        # [-++...+]
        # [S...E]
        # E-(S-1-2-...)
        ret = []
        s = a[0]
        e = a[-1]
        for x in a[1:-1]:
            ret.append((s, x))
            s -= x
        ret.append((e, s))
        e -= s
        sum_ = e

    elif i0 == n:
        # 負のみ
        # [--...-+]
        # [...S]
        # S-1-2-...
        ret = []
        s = a[-1]
        for x in a[:-1]:
            ret.append((s, x))
            s -= x
        sum_ = s

    else:
        # 正負混在
        # [--...-++...+]
        # [Mm...mp...pP]
        # (P-m-m...)-(M-p-p...)
        ret = []
        m = a[0]
        for x in a[i0:-1]:
            ret.append((m, x))
            m -= x

        p = a[-1]
        for x in a[1:i0]:
            ret.append((p, x))
            p -= x

        ret.append((p, m))
        sum_ = p - m

    print(sum_)
    for row in ret:
        print(*row)


if __name__ == '__main__':
    main()


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

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


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
#define int long long
using namespace std;
int n,ans;
signed main()
{
	scanf("%lld",&n);
	for (int i=1;i<=n;i++)
	{
		if (i%3==0 || i%5==0) continue;
		ans+=i;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 3828
#include <iostream>
using namespace std;
int h, w, cnt[4][2000][2000], ans = 0;
string s[2000];
int main(void){
    
    cin >> h >> w;
    for(int i=0;i<h;i++){
        cin >> s[i];
    }
    for(int k=0;k<4;k++){
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cnt[k][i][j] = 0;
            }
        }
    }

    int c;
    
    c = 0; // 0 : left
    for(int i=0;i<h;i++){
        if(s[i][0] == '.')cnt[c][i][0] = 1;
        for(int j=1;j<w;j++){
            if(s[i][j] == '.'){
                cnt[c][i][j] = 1 + cnt[c][i][j-1];
            }
        }
    }
    
    c = 1; // 1 : right
    for(int i=0;i<h;i++){
        if(s[i][w-1] == '.')cnt[c][i][w-1] = 1;
        for(int j=w-2;j>=0;j--){
            if(s[i][j] == '.'){
                cnt[c][i][j] = 1 + cnt[c][i][j+1];
            }
        }
    }
    
    c = 2; // 2 : up
    for(int j=0;j<w;j++){
        if(s[0][j] == '.')cnt[c][0][j] = 1;
        for(int i=1;i<h;i++){
            if(s[i][j] == '.'){
                cnt[c][i][j] = 1 + cnt[c][i-1][j];
            }
        }
    }
    
    c = 3; // 3 : down
    for(int j=0;j<w;j++){
        if(s[h-1][j] == '.')cnt[c][h-1][j] = 1;
        for(int i=h-2;i>=0;i--){
            if(s[i][j] == '.'){
                cnt[c][i][j] = 1 + cnt[c][i+1][j];
            }
        }
    }
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j] == '.'){
                int tmp = 0;
                for(int k=0;k<4;k++){
                    tmp += cnt[k][i][j];
                }
                ans = max(ans, tmp-3);
            }
        }
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 66816
#include<bits/stdc++.h>
using namespace std;
int n, m, cnt;
int flg[9];
vector<int> r[9];
void func(int p){
	int f = 1;
	for(int i = 1; i <= n; i++){
		if(flg[i] != 1){
			f = 0;
			break;
		}
	}
	if(f == 1) cnt++;
	else {
		for(int i = 0; i < r[p].size(); i++){
			if(flg[r[p][i]] != 1){
				flg[r[p][i]] = 1;
				func(r[p][i]);
				flg[r[p][i]] = 0;
			}
		}
	}
}
int main(void){
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		r[a].push_back(b); r[b].push_back(a);
	}
	fill(flg, flg + n + 2, 0);
	flg[1] = 1;
	cnt = 0;
	func(1);
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        a: [usize;n]
    }
    let mut plus_count: HashMap<usize, usize> = HashMap::new();

    for i in 0..n {
        let count = plus_count.entry(i + 1 + a[i]).or_insert(0);
        *count += 1;
    }

    //println!("{:?}", plus_count);

    let mut ans = 0;
    for i in 0..n {
        if i + 1 >= a[i] {
            ans += plus_count.get(&(i + 1 - a[i])).unwrap_or(&0);
            //println!("{} {}", i, ans);
        }
    }

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

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


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

#define PI acos(-1)
#define all(a) a.begin(), a.end()
#define full(a, n) a, a + n
#define ma(type, size) (type *)malloc(sizeof(type) * size)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define f0n(i, n) for (i = 0; i < (n); i++)
#define f1n(i, n) for (i = 1; i <= (n); i++)
#define fab(i, a, b) for (i = (a); i <= (b); i++)
#define fr(i, b, a) for (i = (b); i >= (a); i--)

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> indexed_set;
//*/
typedef long long int ll;
typedef long int lo;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

//* utility function
inline bool compare(ll i, ll j)
{
    return i < j;
}
//*/

//* function prototypes

//*/

//int row, column;
int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1};
#ifdef DEBUG
#endif // DEBUG

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    ll a;
    string s;
    cin >> a >> s;
    if (a < 3200)
        cout << "red";
    else
        cout << s;
    cout << endl;


    return 0;
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll a, b; cin >> a >> b; a+=b;
  if(a > 9) fin("error")
  else
  {
    fin(a)
  }
  
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
# 解説見た

def solve(n, x):
    if x in {1, n * 2 - 1}:
        return ['No']

    if n == 2:
        a = ['Yes'] + [1, 2, 3]
        return a

    a = [-1] * (n * 2 - 1)
    a[n - 1] = x

    if x == 2:
        a[n - 2] = n * 2 - 2
        a[n] = 1
        a[n + 1] = n * 2 - 1
    else:
        a[n - 2] = 1
        a[n] = n * 2 - 1
        a[n + 1] = 2

    remains = set(range(1, n * 2)) - set(a)
    for ind, a_ in enumerate(a):
        if a_ == -1:
            a[ind] = remains.pop()

    a = ['Yes'] + a
    return a


if __name__ == '__main__':
    n, x = map(int, input().split())
    print(*solve(n, x), sep='\n')


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

using namespace std;

int main(){
	int con = 0;
    string s , t;
    cin >> s >> t;
    for(int i = 0 ; i < s.size(); i++){
    	if(s[i] == t[i]) con ++;
	}
	cout << con << endl;
	return 0;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,j,k=0;
  int N;
  scanf("%d",&N);
  int A[N];
  for(i=0;i<N;i++){
    scanf("%d ",&A[i]);
  }
  
  for(i=1;i<N;i++){
    for(j=0;j<i;j++){
      if(A[j] > A[i])
        break;
    }
    if(j==i)
      k++;
  }
  
  printf("%d\n",k+1);
  return 0;
}

Measured memory_bytes: 128
// Name: Kanisht Agarwal Copyright Think before u copy //
//Connect with me at LinkedIn

#include <bits/stdc++.h>
#define mod 1000000007
#define ull unsigned ll
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi acos(-1)
#define nui 100
#define INF 100000000000

#define F(i,a,n) for(ll i=a;i<n;i++)
#define B(i,a,n) for(ll i=n-1;i>=a;i--)
#define tc int t;cin>>t;while(t--)
#define tcf int t;cin>>t;for(int w=1;w<=t;w++)



using namespace std;


ull binpow(ll a, ll b)
{
    ull res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res *= a;
        }
        a *= a;
        b >>= 1;
    }
    return res;
}

ll fermat_inv(ll y) {return binpow(y, mod - 2);}


int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //Problem A:

    int a;
    cin >> a;
    ll k = a * ((a + 1) * (a + 1) - a);
    cout << k << "\n";

    return 0;

}







Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF=1001001001;

long long int answ(long long int x){
  if(x==1) return 1;
  if(x>1) return 2*answ(x/2)+1;
}
int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    
    int x=a/d;
    int y=c/b;
    if(a-x*d>0) x++;
    if(c-y*b>0) y++;
    if(x>=y) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define sort(a) sort(all(a))
using P = pair<int, int>;
using ll = long long;
using ld = long double;
int dx[4] = { 0, 1, 0,-1 };
int dy[4] = { 1, 0,-1, 0 };

signed main() {
  int a,b;
  cin >> a >> b;
  int ans = max(0LL, a-2*b);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
const ll SIZE = 1e6+1;
bool isprime[SIZE];
vector<ll> primes;
map<ll, ll> factors;
void make_primes(){
    for (ll i = 0; i < SIZE; ++i)
        isprime[i] = true;
    isprime[0] = isprime[1] = false;
    for (ll i = 2; i*i <= SIZE; ++i)
    {
        if (isprime[i]){
            ll j = i+i;
            while (j < SIZE)
            {
                isprime[j] = false;
                j += i;
            }
        }
    }
    for (ll i = 0; i < SIZE; i++)
        if (isprime[i])
            primes.push_back(i);
}

void prime_factorize(ll x){
    for (ll i : primes)
    {
        while (x % i == 0)
        {
            ++factors[i];
            x /= i;
        }
    }
    if (x != 1)
        ++factors[x];
}
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    ll n; cin >> n;
    make_primes();

    prime_factorize(n);
    int ans = 0;
    for (auto &&i : factors)
    {
        int x = 1;
        while(i.second-x >= 0){
            i.second-=x;
            ans++;
            x++;
        }
    }
    cout << ans << endl;
}

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

int main()
{
  int n,t,time,c,i,min;

  cin>>n>>time;
  min=1001;

  for(i=0;i<n;i++){
    cin>>c>>t;

    if(time>=t){
      if(min>c) min=c;
    }
  }

  if(min!=1001) cout<<min<<endl;
  else cout<<"TLE"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    int cnt=0;
    string s1,s2;
    cin>>s1>>s2;
    for(int i=0;i<s1.length();i++)  cnt+=(s1[i]!=s2[i]);
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;



int main(){
    int k, a, b;
    cin >> k >> a >> b;
    for(int i=a; i<=b; i++){
        if(i%k==0){
            cout << "OK" <<endl;
            return 0;
        }
    }
    cout << "NG" << endl;

   

}

Measured memory_bytes: 3576
N=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
distance=[0 for _ in range(N)]
for i in range(N):
    distance[i]=abs(x[i]-y[i])
for i in range(1,5):
    P=0
    for j in range(N):
        P+=distance[j]**i
    if i<4:
        print(P**(1/i))
    else:
        print(max(distance))



Measured memory_bytes: 5648
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        Integer[] a = new Integer[n];
        Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
        sc.close();

        // 主処理
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            int d = Math.abs(a[i] - x);
            pq.add(d);
        }

        int result = pq.poll();
        while (!pq.isEmpty()) {
            int num = pq.poll();
            result = gcd(result, num);
        }

        // 出力
        System.out.println(result);
    }

    public static int gcd(int a, int b) {
        int temp;
        while ((temp = a % b) != 0) {
            a = b;
            b = temp;
        }
        return b;
    }
}


Measured memory_bytes: 47416
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
#include <cctype>
#include <cstdio>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI 3.141592653
#define rep(i, k, n) for(ll i = k; i < n; i++)

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

  vll v(4,0);

  rep(i, 0, n){
    string s; cin >> s;
    if(s == "AC"){v[0]++;}
    else if(s == "WA"){v[1]++;}
    else if(s == "TLE"){v[2]++;}
    else if(s == "RE"){v[3]++;}
  }

  cout << "AC x " << v[0] << endl;
  cout << "WA x " << v[1] << endl;
  cout << "TLE x " << v[2] << endl;
  cout << "RE x " << v[3] << endl;
  
}


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

template<class T = int>
struct SegmentTree {
using Func = function<T(T, T)>;
private:
    int n = 1;
    T def;
    vector<T> node;
    const Func f;
public:
    SegmentTree(int sz, T _def, Func _f);
    void update(int x, T val);
    T query(int a, int b, int k = 0, int l = 0, int r = -1);
};

template<class T>
inline SegmentTree<T>::SegmentTree(int sz, T _def, Func _f) : def(_def), f(_f) {
    while (n < sz) n *= 2;
    node.resize(2 * n - 1, def);
}

template<class T>
inline void SegmentTree<T>::update(int x, T val) {
    x += n - 1;
    node[x] = val;
    while (x > 0) {
        x = (x - 1) / 2;
        node[x] = f(node[2 * x + 1], node[2 * x + 2]);
    }
}

template<class T>
inline T SegmentTree<T>::query(int a, int b, int k, int l, int r) {
    if (r < 0) r = n;
    if (r <= a || b <= l) return def;
    if (a <= l && r <= b) return node[k];
    T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return f(vl, vr);
}

int main() {
    int N, Q;
    string S;
    cin >> N >> S >> Q;
    SegmentTree<int> seg(N, 0, [](int a, int b) {
        return a | b;
    });
    for(int i = 0; i < N; ++i) {
        int n = S[i] - 'a';
        seg.update(i, 1 << n);
    }
    while(Q--) {
        int q; cin >> q;
        if(q == 1) {
            int i;
            char c;
            cin >> i >> c;
            i--;
            int n = c - 'a';
            seg.update(i, 1 << n);
        } else {
            int l, r;
            cin >> l >> r;
            l--;
            int n = __builtin_popcount(seg.query(l, r));
            cout << n << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 4996
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int

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

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

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

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


int main() {

int a,b;
cin>>a>>b;
if(a<b)
{
    for(int i=0;i<b;i++)
    {
        cout<<a;
    }
} else{
    for(int i=0;i<a;i++)
    {
        cout<<b;
    }
}
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n, d;
  scan(n, d);
  int m = d * 2 + 1;
  print((n+m-1) / m);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string s; cin>>s;
	string t=s;
	reverse(all(t));
	if(s==t) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 3616
#define taskname ""
#include <bits/stdc++.h>

using namespace std;

const int maxN = 1e5;

int n;
int a[maxN];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    if (is_sorted(a, a + n))
    {
        cout << "YES";
        return 0;
    }
    for (int i = 0; i < n - 1; ++i)
    {
        for (int j = i + 1; j < n; ++j)
        {
            swap(a[i], a[j]);
            if (is_sorted(a, a + n))
            {
                cout << "YES";
                return 0;
            }
            swap(a[i], a[j]);
        }
    }
    cout << "NO";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

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

		long N = sc.nextLong();
		long K = sc.nextLong();

		long result = N;

		//あまり求める
		if(result > K) {
			result = result % K;
		}

		//差分求める
		long tmp = result;
		if(tmp < K) {
			tmp = K - tmp;
		} else {
			tmp = tmp - K;
		}

		if(result > tmp) {
			result = tmp;
		}

		if(result > N) {
			result = N;
		}

		System.out.println(Math.abs(result));

	}
}

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

using namespace std;
typedef long long ll;
typedef long double ld;

vector<int> vec;

const int N = 300030;
int A[N];
int P[N];
int ov[N];
int n;

int qu(int o) {
  int lo=0, hi=n;
  while (lo<hi) {
    int mid = (lo+hi+1)/2;

    if (mid != 0 && vec[mid-1] < o) {
      hi = mid-1;
    }
    else {
      lo = mid;
    }
  }

  int ans = lo+(P[n]-P[lo])/o;
  //cerr << " o = " << o << " :: " << ans << " ,, " << lo << " + (" << P[n] << "-" << P[lo] << ")/" << o << endl;
  return ans;
}

int solve(int k) {
  int lo = 0, hi = n;
  while (lo < hi) {
    int o = (lo+hi+1)/2;

    int va = ov[o];

    if (va < k) {
      hi = o-1;
    } else {
      lo = o;
    }
  }
  return lo;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i=1; i<=n; ++i) {
    int x;
    cin >> x;
    ++A[x];
  }
  for (int i=1; i<=n; ++i) {
    vec.push_back(A[i]);
  }
  sort(vec.rbegin(), vec.rend());
  for (int i=1; i<=n; ++i) {
    P[i] = P[i-1]+vec[i-1];
  }

  ov[0] = n;
  for (int i=1; i<=n; ++i) {
    ov[i] = qu(i);
  }
 
  for (int i=1; i<=n; ++i) {
    cout << solve(i) << "\n";
  }


  return 0;
}


Measured memory_bytes: 7980
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int n,b,f,r,v; //n件数,b棟,f階,r番目,v人
    int college[4][3][10] = {0,0,0}; //初期値0
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> b >> f >> r >> v;
        college[b-1][f-1][r-1]+=v;  //
    }
    for (int i=0; i<4; i++) {
        for (int j=0; j<3; j++) {
            for (int k=0; k<10; k++) {
                cout <<" "<< college[i][j][k];
                if (k==9) {
                    cout << endl;  //改行
                }
            }
        }
        if (i!=3) { //最後は区切りなし
            cout << "####################"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3104
(defparameter *r* (read))
(defparameter *D* (read))
 
(defun next-x (x)
  (- (* *r* x) *D*))
 
(defparameter x (read))
 
(loop for i from 1 to 10
      do (progn (setq x (next-x x))
           		(format t "~a~&" x)))

Measured memory_bytes: 12260
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,K;

int main(){
    cin>>N>>K;
    if(K==0){
        cout<<N*N<<endl;
        return 0;
    }
    ll ans=0;
    for(ll b=K;b<=N;b++){
        ans+=N/b*(b-K);
        ans+=max(0ll,min(N,(N/b+1)*b-1)-(N/b*b+K)+1);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    a, b, c, k = MI()
    # print(a,b,c,k)

    aa = min(a, k)
    # print(aa)
    k -= aa
    bb = min(b, k)
    # print(bb)
    k -=bb
    cc = min(c, k)
    # print(cc)
    print(aa - 1 * cc)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 300003;

struct edge{int to,cap,cost,rev;};
struct MinimumCostflow{//ant book p.200
	int V;
	vector<vector<edge> > G;
	vector<int> prevv,preve,dist;

	void initsize(int nv){
		G.resize(nv);
		preve.resize(nv);
		prevv.resize(nv);
		dist.resize(nv);
		V=nv;
	}
	void add_edge(int from,int to,int cap,int cost){
		G[from].push_back((edge){to,cap,cost,G[to].size()});
		G[to].push_back((edge){from,0,-cost,G[from].size()-1});
	}
	int min_cost_flow(int s,int t,int f){
		int res = 0;
		while(f>0){
			fill(dist.begin(),dist.end(),INT_MAX);
			dist[s] = 0;
			bool update=true;
			while(update){
				update = false;
				for(int v=0;v<V;v++){
					if(dist[v]==INT_MAX)continue;
					for(int i=0;i<G[v].size();i++){
						edge &e = G[v][i];
						if(e.cap>0&&dist[e.to]>dist[v]+e.cost){
							dist[e.to] = dist[v]+e.cost;
							prevv[e.to]=v;
							preve[e.to]=i;
							update = true;
						}
					}
				}
			}
		
			if(dist[t]==INT_MAX)return -1;
			int d=f;
			for(int v=t;v!=s;v=prevv[v]){
				d = min(d,G[prevv[v]][preve[v]].cap);
			}
			f -=d;
			res += d*dist[t];
			for(int v=t;v!=s;v=prevv[v]){
				edge &e = G[prevv[v]][preve[v]];
				e.cap -= d;
				G[v][e.rev].cap += d;
			}
		}
		return res;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	MinimumCostflow mf;
	int v,e,f;
	cin>>v>>e>>f;
	mf.initsize(v);
	FOR(i,0,e){
		ll x,y,c,d;cin>>x>>y>>c>>d;
		mf.add_edge(x,y,c,d);
	}
	cout<<mf.min_cost_flow(0,v-1,f)<<endl;
	return 0;
}



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

float han(float a, float b, float c, float d, float e, float f, float g, float h){
	float ans = (c - a)*(g - e) + (d - b) * (h - f);
	return ans;
}

int main(){
	float xa[2], xb[2], ya[2], yb[2];
	while (cin >> xa[0] >> ya[0] >> xa[1] >> ya[1] >> xb[0] >> yb[0] >> xb[1] >> yb[1]){
		float ans = han(xa[0], ya[0], xa[1], ya[1], xb[0], yb[0], xb[1], yb[1]);
		if(ans == 0){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3068
import java.util.*;

class P
{
	char first;
	char second;
	P(char first, char second)
	{
		this.first = first;
		this.second = second;
	}
}
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int n = stdIn.nextInt();
			if(n == 0)
			{
				break;
			}
			List<P> list = new ArrayList<P>();
			for(int i = 0; i < n; ++i)
			{
				char first = stdIn.next().charAt(0);
				char second = stdIn.next().charAt(0);
				list.add(new P(first, second));
			}
			int m = stdIn.nextInt();
			for(int i = 0; i < m; ++i)
			{
				char c = stdIn.next().charAt(0);
				boolean flag = false;
				for(int j = 0; j < list.size(); ++j)
				{
					if(list.get(j).first == c)
					{
						System.out.print(list.get(j).second);
						flag = true;
					}
				}
				if(!flag)
				{
					System.out.print(c);
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    a,b = LI()
    if abs(a-b) < 2:
        return 'Brown'

    return 'Alice'


print(main())


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

using namespace std;
typedef long long ll;
typedef pair <int,int> pa;
const int N = 2e5+100;

int n,h;
int a[N],b[N];
void solve()
{
   cin>>n>>h;
   for(int i=1;i<=n;i++) {
    cin>>a[i]>>b[i];
   }
   sort(a+1,a+1+n,greater<int>());
   sort(b+1,b+1+n,greater<int>());
   int kk=a[1];
   int ans=0;
   int pos=1;
   while(1){
     if(h<=0) {
        cout<<ans<<endl;
        return ;
     }
     if(b[pos]>kk) {
        h-=b[pos++];
        ans++;
     }
     else break;
   }
   ans+=h/kk;
   if(h%kk) ans++;
   cout<<ans<<endl;

}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 4424
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
int x[105][105];
int main() {
  IOS;
  int n, d;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> x[i][j];
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ll s = 0;
      for (int k = 0; k < d; k++)
        s += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      ll ns = sqrt(s);
      ns *= ns;
      if (s == ns)
        cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3628
#include<stdio.h>

int main(){
	int x,y;
	scanf("%d %d",&x,&y);
	if(y < x * 2 || x * 4 < y){
		printf("No");
	} else if(y % 2 == 1){
		printf("No");
	} else {
		printf("Yes");
	}


	return 0;
}


Measured memory_bytes: 1692
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		if(N==1){
			Console.WriteLine("First");
		} else {
		int[,]A = new int[N,2];
		for(var i=0;i<N-1;i++){
			string[]str = Console.ReadLine().Split();
			A[i,0] = int.Parse(str[0]);
			A[i,1] = int.Parse(str[1]);
		}
		var list = new List<int>[N];
		for(var i=0;i<N;i++){
			list[i] = new List<int>();
		}
		for(var i=0;i<N-1;i++){
			list[A[i,0]-1].Add(A[i,1]-1);
			list[A[i,1]-1].Add(A[i,0]-1);
		}
		var list1 = new List<int>();
		list1.Add(0);
		int[] C = new int[N];
		C[0] = 1;
		int maxi = -1;
		int max = 0;
		while(list1.Count > 0){
			var list2 = new List<int>(list1);
			list1.Clear();
			foreach(int a in list2){
				foreach(int b in list[a]){
					if(C[b]==0){
						C[b] = C[a]+1;
						if(C[b] > max){
							max = C[b];
							maxi = b;
						}
						list1.Add(b);
					}
				}
			}
		}
		C = new int[N];
		list1.Add(maxi);
		C[maxi] = 1;
		maxi = -1;
		max = 0;
		while(list1.Count > 0){
			var list2 = new List<int>(list1);
			list1.Clear();
			foreach(int a in list2){
				foreach(int b in list[a]){
					if(C[b]==0){
						C[b] = C[a]+1;
						if(C[b] > max){
							max = C[b];
							maxi = b;
						}
						list1.Add(b);
					}
				}
			}
		}
		if(max % 3 == 2){
			Console.WriteLine("Second");
		} else {
			Console.WriteLine("First");
		}
		}
	}
}

Measured memory_bytes: 43296
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
#define pii pair<int,int>
#define pil pair<int, long long>
int n, UF[101000];
vector<int>G[101000];
vector<pii>H[101000];
vector<pil>U[101000];
vector<long long>S[101000];
struct point {
	int a, b, c;
	bool operator<(const point &p)const {
		return c < p.c;
	}
}w[101000];
int cnt = 0;
int Find(int a) {
	if (a == UF[a])return a;
	return Find(UF[a]);
}
void Merge(int a, int b, int c) {
	a = Find(a), b = Find(b);
	cnt++;
	if (G[a].size() < G[b].size())swap(a, b);
	int i;
	for (i = 0; i < G[b].size(); i++) {
		int x = G[b][i];
		H[x].push_back({ a,cnt });
	}
	U[a].push_back({ cnt, 1ll * G[b].size() * c });
	U[b].push_back({ cnt, 1ll * G[a].size() * c });
	for (i = 0; i < G[b].size(); i++)G[a].push_back(G[b][i]);
	UF[b] = a;
}
int main() {
	int i, j;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		UF[i] = i;
		G[i].push_back(i);
		H[i].push_back({ i,0 });
	}
	for (i = 1; i < n; i++) {
		scanf("%d%d%d", &w[i].a, &w[i].b, &w[i].c);
	}
	sort(w + 1, w + n);
	for (i = n-1; i >=1; i--){

		Merge(w[i].a, w[i].b, w[i].c);
	}
	for (i = 1; i <= n; i++) {
		S[i].resize(U[i].size() + 1);
		for (j = 0; j < U[i].size(); j++) {
			S[i][j + 1] = S[i][j] + U[i][j].second;
		}
	}
	for (i = 1; i <= n; i++) {
		long long r = 0;
		for (j = 0; j < H[i].size(); j++) {
			int x = H[i][j].first, t = H[i][j].second;
			pil tp = { t + 1, 0ll };
			int p = lower_bound(U[x].begin(), U[x].end(), tp) - U[x].begin(), sz = U[x].size();
			r += S[x][sz] - S[x][p];
		}
		printf("%lld\n", r);
	}
}

Measured memory_bytes: 35832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  bool ok=false;
  while (true)
  {
    /* code */
    c-=b;
    
    if (a<=0||c<=0)
    {
      /* code */
      break;
    }
    a-=d;
    if (a<=0||c<=0)
    {
      /* code */
      break;
    }
    
  }
  if (a<=0)
  {
    /* code */
    cout<<"No"<<endl;
  }
  else
  {
    cout<<"Yes"<<endl;
  }
  
  
  
  }

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

using namespace std;
typedef long long ll;

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

	int ans = 0;
	for (int i = 0; i < s.size() / 2; i++) {
		if (s.at(i) != s.at(s.size() - 1 - i)) {
			ans++;
		}
	}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> ans(3,0);
  int a,b,c;
  for(int i=0;i<n;i++)
  {
    cin>>a;
   	a+=ans[0];
    cin>>b;
    b+=ans[1];
    cin>>c;
    c+=ans[2];
    ans[0]=max(b,c);
    ans[1]=max(a,c);
    ans[2]=max(a,b);
  }
  cout<<max(max(a,b),c);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
int x[100010];
int main() {
	int n,m;
	cin >> n >> m;
	if (n >= m) {
		cout << 0 << endl;
		return 0;
	}
	rep(i,m) cin >> x[i];
	sort(x,x+m);
	
	vector<int> len(m-1);
	rep(i,m-1) {
		len[i] = x[i+1] - x[i];
	}
	sort(len.begin(), len.end(), greater<int>());
	ll ans = x[m-1] - x[0];
	rep(i,n-1) {
		ans -= len[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}

using Graph = vector<vector<int>>;
Graph G;

int dfs(int v) {
  V depth;
  for (auto nv : G[v]) {
    depth.push_back(dfs(nv));
  }
  sort(all(depth));
  reverse(all(depth));
  int res = 0;
  rep(i, depth.size()) chmax(res, depth[i]+i);
  return res+1;
}

int main() {
  int N; cin >> N;
  G = Graph(N);
  for (int i = 0; i < N-1; i++) {
    int a;
    cin >> a;
    a--;
    G[a].push_back(i+1);
  }
  int ans = dfs(0)-1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 13568
#include<stdio.h>

int main(){
    int i, j;
    
    for(i = 1; i<=9; i++) {
        for(j = 1; j <=9; j++) {
            int answer = i * j;
            printf("%dx%d=%d\n", i, j, answer);
        }
        j = 1;
    }
    return 0;
}

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

char a[2000][2000];
char b[2000][2000];

int main(){
	int n,m;	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++)cin>>a[i][j];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++)cin>>b[i][j];
	}

	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(a[i][j]!=b[i][j])ans++;
		}
	}

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



Measured memory_bytes: 10932
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=5e2+10;
int a[maxn][maxn];
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int main(){
	int i,j,n,m,k;
	n=read();m=read();k=read();
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++){
			if(((i+j)/k)&1)
				a[i][j]+=2;
			if(((m-j+i)/k)&1)
				a[i][j]+=1;
		}
	for(i=1;i<=n;i++,puts(""))
		for(j=1;j<=m;j++){
			if(a[i][j]==0) printf("Y");
			if(a[i][j]==1) printf("G");
			if(a[i][j]==2) printf("B");
			if(a[i][j]==3) printf("R");
		}
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
int main(){
  lint n,k,zer,mini,sum,i;mini=500000000;
  cin>>n>>k;
  vint x(n);
  for(i=0;i<n;i++){
    cin>>x[i];
  }
  for(i=n-1;i>=k-1;i--){
    if((x[i]>0)&&(x[i-k+1]<0)){
     sum=min(2*x[i]+abs(x[i-k+1]),x[i]+2*abs(x[i-k+1]));
    }else{
     sum=max(abs(x[i]),abs(x[i-k+1]));
    }
    if(mini>=sum){mini=sum;}
  }
  cout<<mini<<endl;
}


Measured memory_bytes: 640
import sys, re, os
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
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 S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
N = INT()
A = LIST()
count = 0
b = 0
for i in range(N):
    if A[i] % 2 == 0:
        count += 1
        if A[i] % 3 == 0 or A[i] % 5 == 0:
            b += 1
if count == b:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 5756
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
const int INF = 100000000, mod = 1000000007;
using namespace std;



int main() {
    int check[200] = {};
    bool ans=true;
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        check[s[i]] += 1;
        if (check[s[i]] == 2) {
            ans = false;
            break;
        }
    }

    if (ans) cout << "yes" << endl;
    else cout << "no" << endl;

    return 0;
}

Measured memory_bytes: 256
n,d,a=map(int,input().split())
d*=2
xh=[list(map(int,input().split()))for _ in range(n)]
xh.sort()
x=[i for i,j in xh]+[10**20]
h=[j for i,j in xh]
notimos=[0]*(n+1)
c=0
ans=0
from bisect import bisect_right
for i in range(n):
  c+=notimos[i]
  xx,hh=xh[i]
  hh=max(0,hh-c*a)
  m=0--hh//a
  ans+=m
  c+=m
  notimos[bisect_right(x,xx+d)]-=m
print(ans)

Measured memory_bytes: 101152
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	k=0; l=0;
	ll ar[n];
	for(i=0;i<n;i++){
		cin>>ar[i];
		if(ar[i]<0) l++;
		ar[i]=abs(ar[i]);
		k+=ar[i];
	}
	sort(ar,ar+n);
	if(l%2==1) k-=(2*ar[0]);
	cout<<k;
	return 0;
}


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

int main()
{
  int n,k,x,y,l;
  cin>>n>>k>>x>>y;
  if(n<=k)
    l=n*x;
  else
   l=k*x + (n-k)*y;
  cout<<l;
  return 0;
}

Measured memory_bytes: 256