akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int N, W;
	cin >> N >> W;
	vi v(N), w(N);
	rep(i, N) cin >> v[i] >> w[i];
	vector<vi> dp(N+1, vi(W+1));
	for(int i = 1; i <= N; i++) {
		for(int j = 0; j <= W; j++) dp[i][j] = dp[i-1][j];
		for(int j = 0; j + w[i-1] <= W; j++) {
			dp[i][j + w[i-1]] = max(dp[i][j] + v[i-1], dp[i][j + w[i-1]]);
		}
	}
	int ans = 0;
	for(int j = 0; j <= W; j++) ans = max(dp[N][j], ans);
	cout << ans << endl;
}



Measured memory_bytes: 6836
import java.util.*;
import javax.lang.model.util.ElementScanner6;

public class Main {

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

        // 入力
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        // 処理
        Arrays.sort(a);
        String out = "YES";
        for (int i = 0; i < n - 1; i++) {
            if (a[i] == a[i + 1]) {
                out = "NO";
                break;
            }
        }

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

Measured memory_bytes: 89300
// By Atul Rathore

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

#define ll long long int
#define f(n) for(int i=0;i<n;i++)
#define p(x) cout<<x<<endl;
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007




 
int main()
{
	fastio;
	double a,b,c,d;
	cin>>a>>b>>c>>d;
	int x=ceil(a/d);
	int y=ceil(c/b);
	if(x>=y)cout<<"Yes";
	else cout<<"No";
	
	
	
}

	
	
	



Measured memory_bytes: 3736
#include <bits/stdc++.h>
typedef long long ll;
typedef double db;
#define mk make_pair
#define pa pair<int,int>
using namespace std;
const ll mod=1e9+7;
inline int rd() {
	int x=0,f=1;char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-1;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
ll qpow(ll a,ll b) {
	ll ans=1;
	for(;b;b>>=1,a=(a*a)%mod) if(b&1) ans=(ans*a)%mod;
	return ans%mod;
}
int N,M;
int np[4000010];
int prime[4000010],pcnt;
pa fac[60];int fcnt;
ll fp[4000010],inv[4000010];
ll C(ll a,ll b) {
	return fp[a]*inv[a-b]%mod*inv[b]%mod;
}
ll ans=1;
//main=============================
int main() {
//	printf("%lld\n",qpow(2,10));
	N=rd(),M=rd();
	if(N==1) {
		printf("1\n");
		exit(0);
	}
	for(int i=2;i<=400000;++i) {
		if(np[i]) continue;
		else prime[++pcnt]=i;//,printf("%d ",i);
		for(int j=2;i*j<=400000;++j) 
			np[i*j]=1;
	}
	for(int j=1;j<=pcnt;++j) {
		if(M==1||M<=0) break;
		if(M%prime[j]==0) {
			fac[++fcnt].first=prime[j];
			while(M%prime[j]==0) M/=prime[j],++fac[fcnt].second;			
		}
	}
	if(M!=1) fac[++fcnt]=mk(M,1);
	//for(int i=1;i<=fcnt;++i) printf("%d^%d%c",fac[i].first,fac[i].second,(i==fcnt?'\n':'*'));
	fp[0]=1;
	for(int i=1;i<=400005;++i) fp[i]=(fp[i-1]*i)%mod;
	inv[400005]=qpow(fp[400005],mod-2);
	for(int i=400004;i>=0;--i) inv[i]=(inv[i+1]*(i+1))%mod;
	for(int i=1;i<=fcnt;++i) {
		ll t=fac[i].second;
		ans=ans*C(N+t-1,N-1)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 12544
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
const LL mod = 1e9 + 7;
LL a[N];
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%lld", &a[i]);
	LL sum = 0;
	LL ans = 0;
	for(int i = 1; i <= n; i++)
	{
		ans = (ans + sum * a[i] % mod) % mod;
		sum = (sum + a[i]) % mod;
	}
	cout<<ans<<endl;
	return 0;
}

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


using namespace std;

int main()
{
    int K,X;
    int minrange,maxrange;

    cin >> K >> X;

    maxrange = min(X+(K-1),1000000); 
    minrange = max(X-(K-1),-1000000);

    for(int i=minrange;i<=maxrange;i++) cout << i << " ";
    cout << endl;




}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int k, t;
    cin>>k>>t;
    vector<int>v(t);
    priority_queue<pair<int, int> > que;
    rep(i, t) {
        int a;
        cin>>a;
        que.push(make_pair(a, i));
    }
    int bef = -1;
    int ans = 0;
    while(!que.empty()){
        pair<int, int> p = que.top();
        que.pop();
        if(p.second != bef){
            bef = p.second;
            p.first --;
            if(p.first>0) que.push(make_pair(p.first, p.second));
        }
        else{
            if(que.size() == 0){
                ans++;
                p.first--;
                bef = p.second;
                if(p.first>0) que.push(make_pair(p.first, p.second));
            }
            else{
                auto u = que.top();
                bef = u.second;
                que.pop();
                u.first--;
                if(u.first>0) que.push(make_pair(u.first, u.second));
                que.push(p);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int W, H, x, y;
    cin >> W >> H >> x >> y;
    double area = 0.5 * W * H;
    cout << fixed << setprecision(10) 
        << area << " " << ((W == 2 * x && H == 2 * y) ? 1 : 0) << endl;
    return 0;
};


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

int main() {
  int A,B,N,i,j;
  int count=0,sum;
  
  cin >> N >> A >> B;
  
  for(i=1;i<=N;i++) {
    sum = 0;
    
    for(j=i;j!=0;j/=10) {
      sum += j%10;
    }
  
    if(sum>=A && sum<=B) {
      count += i;
    }
  }
  
  cout << count <<endl;
  
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main()
{
    string s;
    cin >> s;
    if(s[2]== s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string S; std::cin >> S;
  if ( S == "SUN" ) std::cout << 7 << std::endl;
  if ( S == "MON" ) std::cout << 6 << std::endl;
  if ( S == "TUE" ) std::cout << 5 << std::endl;
  if ( S == "WED" ) std::cout << 4 << std::endl;
  if ( S == "THU" ) std::cout << 3 << std::endl;
  if ( S == "FRI" ) std::cout << 2 << std::endl;
  if ( S == "SAT" ) std::cout << 1 << std::endl;
  return 0;
}


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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n, c, k; 
  cin>>n>>c>>k;
  vi t(n);
  rep(i,0,n) cin>>t[i];
  int last = -1;
  sort(all(t));
  int ans = 0;
  for(int i = n-1; i>=0;) {
    last = t[i];
    int cnt = 0;
    while(i>=0 && cnt<c && last - t[i]<=k) {
      cnt++;
      i--;
    }
    debug(i);
    ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>


int main(){

    int a,b;

    scanf("%d",&a);
    scanf("%d",&b);
    int plus = a+b;
    int times = a*b;
    int minus = a-b;

    if (plus > times && plus >minus){
        printf("%d\n",plus);
       
    }

    else if (times > plus && times >minus){
        printf("%d\n",times);
       
    }
    else{
            printf("%d\n",minus);
           

    }











//3+1=4, 3−1=2 and 3×1=3. The largest among them is 4.
    return 0;
}


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

int main() {
   int n; cin>>n;
   V v(n);
   rep(i,0,n) cin>>v[i];
   int ans=0;
   bool f=false;
   while(1){
      rep(i,0,n){
         int vv=v[i];
         if(vv%2!=0){
            f=true;
            break;
         }
         v[i]/=2;
      }
      if(f) break;
      ans++;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)


def DFS(x,y):
    color[x][y]="gray"
    for i,j in [[-1,1],[-1,0],[-1,-1],[0,1],[0,-1],[1,-1],[1,0],[1,1]]:
        X,Y=x+i,y+j
        if 0<=X<h and 0<=Y<w:
            if C[X][Y]==1 and color[X][Y]=="white":
                DFS(x+i,y+j)
    color[x][y]="black"


while 1:
    w,h=map(int,input().split())
    if w==0 and h==0:break
    C=[list(map(int,input().split())) for _ in range(h)]
    color=[["white" for _ in range(w)] for _ in range(h)]
    cnt=0
    for i in range(h):
        for j in range(w):
            if color[i][j]=="white" and C[i][j]==1:
                DFS(i,j)
                cnt +=1
    print(cnt)


Measured memory_bytes: 9764
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<int, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 600010;
const int MAXK = 110;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    cout << n * n;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i< (n);i++)
#define SORT(a) sort((a).begin(),(a).end());
#define che(a,string) cout<<string<<":"<<(a)<<endl;
#define ch(a,string) cout<<string<<":"<<(a)<<" ";
using namespace std;
typedef pair<int,int> p;
#define INF 2000000000
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; }

//入力
int n;
long long a[100010][3];  //ai,bi,ciをそれぞれ、a[i][0],a[i][1],a[i][2]に格納

//DP テーブル
long long	dp[100010][3];//一個前にaを選んだ時のi番目の幸福度の最大値をdp[i][0] 

	int main(){
 		int n;cin>>n;
		for(int i = 0; i < n ; ++i){
			for(int j = 0 ; j<3 ;++j){
				cin>>a[i][j];
			}
		}
		for(int i = 0 ; i<n ; ++i){
			for(int j=0; j<3 ; ++j){	
				for (int k =0; k<3; ++k){
					if(j!=k){
						chmax(dp[i+1][k], dp[i][j]+ a[i][k]);
					}
				}
			}
		}

		//答え
		long long ans = 0 ;
		for(int j = 0; j < 3; ++j){
			chmax(ans, dp[n][j]);
		}
		cout<<ans<<endl;
	}



Measured memory_bytes: 4992
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))

for i in range(n):
    p[i] -= 1

l = []

todo = [0] * n
for i in range(n):
    if todo[i] == 1:
        continue
    todo[i] = 1
    lis = [c[i]]
    now = p[i]
    while todo[now] == 0:
        todo[now] = 1
        lis.append(c[now])
        now = p[now]
    l.append(lis)

ans = -float('inf')
for i in l:
    s = [i[0]]
    for j in range(1, len(i)):
        s.append(s[-1] + i[j])
    unit = s[-1]
    for j in range(len(i)):
        s.append(s[-1] + i[j])
    for j in range(len(i)):
        s.append(s[-1] + i[j])

    num = k
    if s[-1] > 0:
        if num // len(i) > 1:
            score = (num // len(i) - 1) * unit
            num %= len(i)
            num += len(i)
        else:
            score = 0
    else:
        score = 0
        num = len(i)
    
    for a in range(len(i)):
        for b in range(a + 1, a + num + 1):
            if score + s[b] - s[a] > ans:
                ans = score + s[b] - s[a]

print(ans)

Measured memory_bytes: 69228
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


class Combination:
    def __init__(self, n, mod):

        g1 = [1, 1]
        g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, n + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod // i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

    def __call__(self, n, r):
        if (r < 0 or r > n):
            return 0
        r = min(r, n - r)
        return self.g1[n] * self.g2[r] * self.g2[n - r] % self.MOD


# --------------------------------------------

dp = None


def main():
    x, y, z = input().split()

    print("A{}C".format(y[0]))


main()


Measured memory_bytes: 4932
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

static const ll MAX = 20001;
ll a[MAX] = {};
ll b[MAX] = {};

int main() {
   

    ll n;
    cin >> n;
    for (ll i=1;i<=n;i++){
        a[i] = MAX*i;
        b[i] = MAX*(n-i+1);
    }
    for (ll i=1;i<=n;i++){
        ll p;
        cin >> p;
        a[p] -= n-i;
    }
    for(ll i=1;i<=n;i++){
        cout << a[i] << " ";
    }
    cout << endl;
    for (ll i=1;i<=n;i++){
        cout << b[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 896
def main():
    class unionfind():
        #size:要素数,tree：unionfind木
        def __init__(self,size):#self,要素数
            self.size=size
            self.tree=[i for i in range(self.size)]#root,depth
        
        #rootを探す
        def root(self,index):
            temp_list=[]
            temp=self.tree[index]
            while index!=temp:
                temp_list.append(index)
                index=temp
                temp=self.tree[index]
            for i in temp_list:
                self.tree[i]=index
            return index
        
        #結合
        def unite_r(self,index1,index2):
            r1=self.root(index1)
            r2=self.root(index2)
            if r1<r2:
                self.tree[r1]=r2
            else:
                self.tree[r2]=r1

        def unite_l(self,index1,index2):
            r1=self.root(index1)
            r2=self.root(index2)
            if r1>r2:
                self.tree[r1]=r2
            else:
                self.tree[r2]=r1

        #同じか判定
        def same(self,index1,index2):
            r1=self.root(index1)
            r2=self.root(index2)
            return r1==r2
            
    n=int(input())
    a=list(map(int,input().split()))
    d=[0]*n
    for i,j in enumerate(a):
        d[j-1]=i+2
    vis=[False]*(n+4)
    u_r=unionfind(n+4)
    u_l=unionfind(n+4)
    ans=0
    for j,i in enumerate(d[:-1]):
        vis[i]=True
        if vis[i+1]==True:
            u_r.unite_r(i,i+1)
            u_l.unite_l(i,i+1)
            k1=u_r.root(i+1)+1
        else:
            k1=i+1
        if vis[k1+1]==True:
            cnt1=u_r.root(k1+1)+1
        else:
            cnt1=k1+1
        cnt1=min(cnt1,n+2)
        if vis[i-1]==True:
            u_r.unite_r(i,i-1)
            u_l.unite_l(i,i-1)
            k2=u_l.root(i-1)-1
        else:
            k2=i-1
        if vis[k2-1]==True:
            cnt2=u_l.root(k2-1)-1
        else:
            cnt2=k2-1
        cnt2=max(cnt2,1)
        ans+=((k2-cnt2)*(k1-i)+(cnt1-k1)*(i-k2))*(j+1)
    print(ans)
main()

Measured memory_bytes: 21092
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;

  int s;
  if (a >= 1 && a <= 9 && b >= 1 && b <= 9) {
    s = a * b;
  } else {
    s = -1;
  }

  cout << s << endl;

  return 0;
}


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

int main () {
    string n;
    cin >> n;
    ll sum = 0;
    for (int i = 0;i < n.length();i++) {
        sum += (n[i] - '0'); 
    }
    if (sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return(0);
}


Measured memory_bytes: 3716
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef int64_t i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}
#pragma endregion

template<typename T>
struct CumulativeSum{
    // usage: CumulativeSum<i64> ps(a); // (a := vector<i64>) - construct particial sum array
    //        query(a, b) - return sum[a, b)
    vector<T> sum;
    CumulativeSum(vector<T> a){
        sum = vector<T>(a.size() + 1);
        sum[0] = 0;
        for(int i = 0; i < a.size(); ++i){
            sum[i + 1] = sum[i] + a[i];
        }
    }
    T query(T x, T y){
        return -sum[min(x, y)] + sum[max(x, y)];
    }
};

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	vector<P> v;
	int f = -1, cnt = 0;
	for(int i = 0; i < n; ++i){
		if(f == -1){
			f = (int)s[i] - (int)'0';
			cnt = 1;
		}else if(s[i] == '0'){
			if(f == 0){
				cnt++;
			}else{
				v.push_back(P(1, cnt));
				cnt = 1;
				f = 0;
			}
		}else{
			if(f == 1){
				cnt++;
			}else{
				v.push_back(P(0, cnt));
				cnt = 1;
				f = 1;
			}
		}
	}
	v.push_back(P(f, cnt));
	cnt = 0;
	int l = 0, ans = 0, kc = 0;
	for(int i = 0; i < v.size(); ++i){
		if(v[i].first == 0){
			if(kc >= k){
				if(v[l].first == 0){
					cnt -= v[l].second;
					++l;
				}else{
					cnt -= v[l].second + v[l + 1].second;
					l += 2;
				}
			}
			cnt += v[i].second;
			++kc;
		}else{
			cnt += v[i].second;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}

// assyuku

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
template<typename T1, typename T2>
inline bool cmn (T1& a, T2 b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
inline bool cmx (T1& a, T2 b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
class binary_indexed_tree {
    size_t sz;
    vector<T> tr;
    function<T(T, T)> sum;
    function<T(T, T)> dif;
    T id;
  public:
    binary_indexed_tree (
        size_t n,
        function<T(T, T)> sum,
        function<T(T, T)> dif,
        T id
      ) :
      sz(n), tr(n, id),
      sum(sum), dif(dif), id(id)
      {}
    auto cum (size_t r) const -> T {
      assert(0 <= r && r <= sz);
      int k = (int)r;
      k--;
      T ret = 0;
      for (; k >= 0; k &= k + 1, k--) ret = sum(ret, tr[k]);
      return ret;
    }
    auto query (size_t l, size_t r) const -> T {
      assert(0 <= l && l <= r && r <= sz);
      return dif(query(0, r), query(0, l));
    }
    auto operator[] (size_t i) const -> T {
      assert(0 <= i && i < sz);
      return query(i, i + 1);
    }
    auto at (size_t i) const -> T {
      return operator[](i);
    }
    void add (size_t i, T x) {
      for (; i < sz; i |= i + 1) tr[i] = sum(tr[i], x);
    }
    void print(string name = "bit") {
      cout << name << ": ";
      for (size_t i = 0; i < sz; i++) {
        if (i) cout << " ";
        cout << operator[](i);
      }
      cout << endl;
    }
};
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> b(n), w(n);
  for (int pos = 0; pos < 2 * n; pos++) {
    char c; int i;
    cin >> c >> i;
    i--;
    (c == 'B' ? b : w).at(i) = pos;
  }
  constexpr int inf = 1 << 30;
  vector<vector<int>> dp(n + 1, vector<int> (n + 1, inf));
  dp[0][0] = 0;
  binary_indexed_tree<int> bit(2 * n, plus<int>(), minus<int>(), 0);
  for (int i = 0; i <= n; i++) {
    binary_indexed_tree<int> wit(2 * n, plus<int>(), minus<int>(), 0);
    for (int j = 0; j <= n; j++) {
      auto cal = [&] (int k) {
        return k - bit.cum(k) - wit.cum(k);
      };
      if (i < n) cmn(dp[i + 1][j], dp[i][j] + cal(b[i]));
      if (j < n) cmn(dp[i][j + 1], dp[i][j] + cal(w[j]));
      if (j < n) wit.add(w[j], 1);
    }
    if (i < n) bit.add(b[i], 1);
  }
  cout << dp[n][n] << endl;
  return 0;
}

Measured memory_bytes: 16000
object Main extends App {
  var a = readLine.split(" ").map(_.toLong)
  var b = readLine.split(" ").map(_.toLong).sorted
  var sum = 0L
  for(i <- 0 until a(0).toInt - 1 if(a(1) >= b(i))) {
      a(1) = a(1) - b(i)
      sum = sum + 1
  }
    if(a(1) == b(a(0).toInt - 1)) {
      sum = sum + 1
    }
  print(sum)
}

Measured memory_bytes: 25420
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std; typedef long long ll; const int INF=1e9; typedef pair<int,int> P;

int main() {
  ll x,y,a,b,c; cin>>x>>y>>a>>b>>c;
  ll an=0;
  ll p[a]; for(int i=0;i<a;i++) cin>>p[i];
  ll q[b]; for(int i=0;i<b;i++) cin>>q[i];
  ll r[c]; for(int i=0;i<c;i++) cin>>r[i];
  sort(p,p+a,greater<ll>());
  sort(q,q+b,greater<ll>());
  sort(r,r+c,greater<ll>());
  priority_queue<ll,vector<ll>,greater<ll>> que;
  for(int i=0;i<x;i++) que.push(p[i]);
  for(int i=0;i<y;i++) que.push(q[i]);
  for(int i=0;i<c;i++) {
    ll worst = que.top();
    if (worst < r[i]) que.pop(), que.push(r[i]);
    else break;
  }
  while(!que.empty()) {
    an += que.top(); que.pop();
  }
  cout<<an<<endl;
}

Measured memory_bytes: 4852
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
using ll = long long;
const char E = '\n';
const int N = 1005;
const ll mod = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(); cout.tie(0);
    double n;
    double a, b, c, ans;
    cin >> n;
    a = n/3;
    b = n/3;
    c = n/3;
    ans = a*b*c;
    cout << fixed << setprecision(6) << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
string s;
int combo,ans;
int main() {
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='R'){
			combo++;
			ans=max(ans,combo);
		}
		else combo=0;
	}
	cout<<ans;
	return 0;
}

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

int main(){
  string a, b, c, d, e, f;
  cin >> a;
  b = a;
  reverse(b.begin(), b.end());
  if (a.compare(b)) {
    cout << "No" << endl;
    return 0;
  }
  c = a.substr(0, (a.length() - 1) / 2);
  d = c;
  reverse(d.begin(), d.end());
  if (c.compare(d)) {
    cout << "No" << endl;
    return 0;
  }
  e = a.substr(((a.length() + 3) / 2) - 1);
  f = e;
  reverse(e.begin(), e.end());
  if (e.compare(f)) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;
 
int main(int argc, char *argv[])
{
    std::string S;
    std::cin >> S;
    
    if (std::stoi(S.substr(5, 2)) >= 5) {
        std::cout << "TBD" << std::endl;
    } else {
        std::cout << "Heisei" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		System.out.println(N * N * N);
	}

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
#define rep(i, n, k) for(long i = k; i < n; i++)
using namespace std;

int main(){
  string s;
  cin >> s;
  int flag = 0;
  rep(i,s.size(),1){
    if(s[i] == s[i-1]) flag = 1;
  }
  if(flag) cout << "Bad" << endl;
  else cout << "Good" << endl;
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, t;
  cin >> n >> t;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int min_v = 1e9 + 1;
  int ans = 0, diff = 0;
  for (int i = 0; i < n; i++) {
    min_v = min(min_v, a[i]);
    if (diff < a[i] - min_v) {
      diff = a[i] - min_v;
      ans = 1;
    } else if (diff == a[i] - min_v) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {

	long long int N, T, sum = 0, tmp = 0;

	cin >> N >> T;

	tmp = -T;
	vector<long long int> t(N);


	for (int i = 0; i < N; i++) {
		cin >> t[i];
		if (t[i] - tmp >= T) {
			sum += T;
		}
		else {
			sum += t[i] - tmp;
		}
		tmp = t[i];
	}

	cout << sum;

	return 0;
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
int main(){
    string S;
    cin >> S;
    int64_t count_d = 0, count_u = 0, ans = 0;
    int64_t cor = 0;
    bool way = false;
    rep(i, 0, S.size()){
        char x = S.at(i);
        if(x == '<'){
            way = true;
            count_u++;
        }
        if(x == '>'){
            if(way){
                ans += max(cor, count_d);
                ans += ((count_u) * (count_u - 1) + (count_d) * (count_d - 1)) / 2;
                cor = count_u;
                count_u = 0;
                count_d = 0;
                way = false;
                //cout << ans << endl;
            }
            count_d++;
        }
    }
    ans += max(cor, count_d);
    ans += ((count_u) * (count_u + 1) + (count_d) * (count_d - 1)) / 2;
    cout << ans << endl;
}

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

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    int N;
    cin >> N;
    string s1, s2;
    cin >> s1 >> s2;
    ll MOD = pow(10, 9) + 7;
    bool judge = 0;
    ll ans = 1;
    vector<int> A;
    rep(i, N) {
        if (s1[i] == s2[i])
            A.push_back(1);
        else
            A.push_back(0), i++;
    }

    if (A[0] == 1) {
        ans *= 3;
        ans %= MOD;
        int prev = 1;
        for (int i = 1; i < A.size(); i++) {
            if (prev == 1 && A[i] == 1) {
                ans *= 2;
                ans %= MOD;
            } else if (prev == 1 && A[i] == 0) {
                ans *= 2;
                ans %= MOD;
            } else if (prev == 0 && A[i] == 1) {
                ans *= 1;
            } else if (prev == 0 && A[i] == 0) {
                ans *= 3;
                ans %= MOD;
            }

            prev = A[i];
        }

        cout << ans << endl;
        return 0;
    } else {
        ans *= 6;
        ans %= MOD;
        int prev = 0;
        for (int i = 1; i < A.size(); i++) {
            if (prev == 1 && A[i] == 1) {
                ans *= 2;
                ans %= MOD;
            } else if (prev == 1 && A[i] == 0) {
                ans *= 2;
                ans %= MOD;
            } else if (prev == 0 && A[i] == 1) {
                ans *= 1;
            } else if (prev == 0 && A[i] == 0) {
                ans *= 3;
                ans %= MOD;
            }

            prev = A[i];
        }

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

Measured memory_bytes: 256
/*ॐॐ*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* “Strength is the only thing that matters in this world. Everything else is just a delusion for the weak.” – Vegeta */

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

ll M,N;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
  cin>>N;

  ll ac = 0 , tle = 0 , re = 0, wa = 0;
   string temp;

   for(ll i = 0 ; i<N ; i++){
     cin>>temp;

     if(temp == "AC")
      ac++;

    else if(temp == "TLE")
      tle++;

    else if(temp == "RE")
      re++;

    else
      wa++;
   }

   cout<<"AC"<<' '<<"x"<<' '<<ac<<'\n';
   cout<<"WA"<<' '<<"x"<<' '<<wa<<'\n';
   cout<<"TLE"<<' '<<"x"<<' '<<tle<<'\n';
   cout<<"RE"<<' '<<"x"<<' '<<re<<'\n';
 


}



int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
   solve();

  return 0;
}


Measured memory_bytes: 3664
a1, b1 = map(int, input().split())
a2 = str(a1) * b1
b2 = str(b1) * a1
if int(a2[0]) > int(b2[0]):
    print(b2)
elif int(a2[0]) < int(b2[0]):
    print(a2)
else:
    print(a2)

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

main()
{
    int k; cin>>k;
    long long x=7%k;
    int ans=1;
    bool ap[1<<20]={};
    for(int i=0;i<=k;ans++)
    {
        if(ap[x])
        {
            cout<<"-1\n";
            return 0;
        }
        ap[x]=1;
        if(!x)
        {
            cout<<ans<<endl;
            return 0;
        }
        x=x*10+7;
        x%=k;
    }
}

Measured memory_bytes: 4652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

int main() {
    int H,N; cin>>H>>N;
    vector<int> v(H+1); v[0] = 0;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; ++i) {
        cin>>A[i]>>B[i];
    }
    for (int h = 1; h <= H; ++h) {
        v[h] = iinf;
        for (int i = 0; i < N; ++i) {
            int tmp = (h - A[i] < 0) ? 0 : v[h-A[i]];
            v[h] = min(v[h], B[i] + tmp);
        }
    }
    cout << v[H] << endl;

    return 0;
}


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

struct Node{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x){
    while( x->left != NIL) x = x->left;
    return x;
}

Node * find(Node *u, int k){
    while(u != NIL && k != u->key){
        if (k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

Node * treeSuccessor(Node *x){
    if (x->right != NIL) return treeMinimum(x->right);

    Node *y = x->parent;
    while( y != NIL && x == y->right){
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node *z){
    Node *y; //Deleted node
    Node *x; //child of y

    if (z->left == NIL || z->right == NIL) y = z;
    else y = treeSuccessor(z);

    if (y->left != NIL){
        x = y->left;
    } else {
        x = y->right;
    }

    if (x != NIL){
        x->parent = y->parent;
    }

    if (y->parent == NIL){
        root = x;
    } else {
        if (y == y->parent->left){
            y->parent->left = x;
        } else {
            y->parent->right = x;
        }
    }

    if (y != z){
        z->key = y->key;
    }

    free(y);

}

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while( x != NIL){
        y = x;
        if (z->key < x->key){
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if(y == NIL){
        root = z;
    } else{
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}

void inorder(Node *u){
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n, i, x;
    string com;

    scanf("%d", &n);

    for (i=0; i<n; i++){
        cin >> com;
        if (com[0] == 'f'){
            scanf("%d", &x);
            Node *t = find(root, x);
            if (t != NIL) printf("yes\n");
            else printf("no\n");
        } else if (com == "insert"){
            scanf("%d", &x);
            insert(x);
        } else if (com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if (com == "delete"){
            scanf("%d", &x);
            treeDelete(find(root, x));
        }
    }

    return 0;
}

Measured memory_bytes: 20008
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> p(N);
    for(int i=0; i<N; i++) {
        cin >> p.at(i);
    }
    cout << accumulate(p.begin(), p.end(), 0) - *max_element(p.begin(), p.end()) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   int h1,h2,k1,k2,a,b,c,d;
   cin >> h1 >> h2;
   cin >> k1 >> k2;
   cin >> a >> b >> c >> d;
   int x=h1*a+h2*b+h1/10*c+h2/20*d;
   int y=k1*a+k2*b+k1/10*c+k2/20*d;
   if(x > y){
       cout << "hiroshi" << endl;
   }
   else if(x < y){
       cout << "kenjiro" << endl;
   }
   else if(x == y){
       cout << "even" << endl;
   }
}


Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;
typedef long long int ll;

// 親がいれば親IDを、根ならば-(サイズ数)をデータとして持つ
struct UnionFind {
    vector<int> d;
    // データ数nを全て-1で初期化
    UnionFind(int n): d(n,-1) {}
    // ｘの所属(=xの根)を探す関数
    int find(int x) {
        if (d[x] < 0) return x;
        // return find(d[x]);
        return d[x] = find(d[x]);  // d[x]=とすることでメモ化する
    }
    // xとyを連結する関数
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        // すでに連結済みの場合は何もせずfalseを返す
        if (x == y) return false;
        // yのサイズの方が大きい場合はxとyを入れ替える
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];  // yのサイズの分を足す
        d[y] = x;  // yの親をxにする
        return true;
    }
    // xとyが同じ連結集合に属するか否かを判定する関数
    bool same(int x, int y) { return find(x) == find(y); }
    // xが所属する連結集合のサイズを求める関数
    int size(int x) { return -d[find(x)]; }
};
    
int main()
{
    int N, M, K;
    cin >> N >> M >> K;

    UnionFind uf(N);
    // 友達関係の処理
    int friend_number[100000] = { 0 };
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        uf.unite(A, B);
        friend_number[A]++;
        friend_number[B]++;
    }

    // ブロック関係の処理
    vector<int> block[100000];
    for (int i = 0; i < K; i++) {
        int C, D;
        cin >> C >> D;
        C--;
        D--;
        block[C].push_back(D);
        block[D].push_back(C);
    }

    for (int i = 0; i < N; i++) {
        // 連結集合のサイズ - 自分自身 - 友達の数
        int ans = uf.size(i) - 1 - friend_number[i];
        // iとブロック関係にあるものの中で、同じ連結集合に含まれるものの数だけ引く
        for (auto itr = block[i].begin(); itr != block[i].end(); itr++) {
            if (uf.same(i, *itr)) ans--;
        }
        if (i != N - 1) cout << ans << ' ';
        else cout << ans << endl;
    }
    return 0;
}


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

#define pai 3.1415926535
#define N 10



int main(void) {

	int A, B;
	scanf("%d%d", &A, &B);

	if ((A == 1) && (B == 2) || (A == 2) && (B == 1)) {
		printf("%d", 3);
	}
	else if ((A == 1) && (B == 3) || (A == 3) && (B == 1)) {
		printf("%d", 2);
	}
	else {
		printf("%d", 1);
	}

	return 0;


}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	if (n == 0) return 1;
	if (n % 2) return (x * modpow(x * x % mod, n / 2) % mod + mod) % mod;
	return (modpow(x * x % mod, n / 2) + mod) % mod;
}

int fact(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= (i + 1);
		ans %= mod;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) swap(n, r);
	if (n - r < r) r = n - r;
	return fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) % mod;
}

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

template <typename T>
void greater_sort(vector<T>& vec) {
	sort(all(vec), greater<T>());
	return;
}
int n, l;
int a[222];
int sum = 0;
int ans = inf;
signed main() {
	cin >> n >> l;
	rep(i, n) {
		a[i] = l + i;
		sum += a[i];
	}
	rep(i, n) {
		int cnt = 0;
		rep(j, n) {
			if (j != i) cnt += a[j];
		}
		if (abs(sum - ans) > abs(sum - cnt)) ans = cnt;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
X = list(map(int,input().split()))

X.sort()
dist = []
for i in range(M-1):
  dist.append(X[i+1]-X[i])

dist.sort()
ans = 0
if N <= M:
	for i in range(M-N):
		ans += dist[i]

print(ans)

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

int dfs(int h, int w, vector<vector<int>> &v, vector<vector<int>> &field) {
    v[h][w] = 1;
    int dh[] = {0, 1, 0, -1};
    int dw[] = {-1, 0, 1, 0};
    
    for (int i = 0; i < 4; i++) {
        int nh = h + dh[i];
        int nw = w + dw[i];
        if (field[nh][nw] == 1 && v[nh][nw] == 0) {
            dfs(nh, nw, v, field);
        }
    }
    return 0;
}

int solve(int H, int W) {
    vector<vector<int>> field(H+2, vector<int>(W+2, 0));
    
    int startH;
    int startW;
    for (int h = 1; h <= H; h++) {
        for (int w = 1; w <= W; w++) {
            char c; cin >> c;
            if (c == '.') {
                field[h][w] = 1;
            } else if (c == '@') {
                field[h][w] = 1;
                startH = h;
                startW = w;
            }
        }
    }
    
    int ret = 0;
    vector<vector<int>> v(H+2, vector<int>(W+2, 0));
    dfs(startH, startW, v, field);
    for (int h = 1; h <= H; h++) {
        for (int w = 1; w <= W; w++) {
            if (v[h][w] == 1) {
                ret++;
            }
        }
    }
    return ret;
}

int main(void){
    // Your code here!
    int W, H;
    vector<int> ans;
    while (1) {
        cin >> W >> H;
        if (!W && !H) break;
        ans.push_back(solve(H, W));
    }
    for (auto &i : ans) {
        cout << i << endl;
    }
}



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

long long N, K;
double P[200000]; 

int main(){
	cin >> N >> K;
	for(long long i = 0; i < N; i++) {
		double p;
		cin >> p;
		P[i] = (1.0 + p)/2.0;
	}

	double ans = 0;
	double sum = 0;
	for(long long i = 0; i < K; i++) {
		sum += P[i];
	}
	ans  = sum;

	for(long long i = K; i < N; i++) {
		sum += P[i];
		sum -= P[i-K];
		ans = max(ans, sum);
	}

	printf("%.10f\n", ans);




}


Measured memory_bytes: 5304