akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif

using namespace std;
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
const ll mod = 1000000007;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


const int N = 1e6 + 5,M = 1e6 + 5;

int n,m;
struct node{
	int l,r,id;
}q[M];
int pos[N];
int c[N],col[N];
int ans[M];

int lowbit(int x)
{
	return x & (-x);
}

void add(int p, int v)
{
	for(int i = p; i <= n; i += lowbit(i))
		c[i] += v;
}

int get(int p)
{
	int res = 0;
	for(int i = p; i; i -= lowbit(i))
		res += c[i];

	return res;
}

int main()
{
	fastIO;
	cin >> n >> m;
	for(int i = 1; i <= n; ++i) cin >> col[i];
	for(int i = 1; i <= m; ++i) 
	{
		cin >> q[i].l >> q[i].r;
		q[i].id = i;
	}

	sort(q + 1, q + 1 + m, [&](node &a, node &b){
		return a.r < b.r;
	});

	int last = 1;
	for(int i = 1; i <= m; ++i) 
	{		
		for(int j = last; j <= q[i].r; ++j)
		{
			if(pos[col[j]]) add(pos[col[j]],-1);
			add(j,1); 
			pos[col[j]] = j;
		}
		last = q[i].r + 1;
		ans[q[i].id] = get(q[i].r) - get(q[i].l - 1);
	}
	for(int i = 1; i <= m; ++i) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 17408
#include<iostream>
using namespace std;
int main()
{
	int n,m;
	while(cin>>n>>m)
	{
	int t=0;
		while(n>0)
		{
			n=n-m*2-1;
			t++;
		}
		cout<<t<<endl;
	}
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
// using ll = boost::multiprecision::int128_t;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
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; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;


int main() {
  string s; cin >> s;
  int n = s.size();

  rep(i, n) {
    if (s[i] == '?') s[i] = 'D';
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 3780
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

# N <= 300 O(n ** 3)まで
# 何通り dp or combo
N = getN()
# 1つ目の譜面
B = [list(input()) for i in range(N)]
# 2つ目にはなにも書かれてない
# 2つ目の盤面に縦にi、横にjずらして数字を記入する

# 対角線に対して線対称なものの数を求める
# 整数a, bの選び方が何通りあるか

def judge(a, b):
    res = [[''] * N for i in range(N)]
    # 盤面１のB[i][j]を盤面2に書き込む
    for i in range(N):
        for j in range(N):
            res[(i + a) % N][(j + b) % N] = B[i][j]

    for i in range(N):
        for j in range(N):
            if res[i][j] != res[j][i]:
                return 0
        else:
            continue
        break
    else:
        return 1

# 全てのa, bについて調べるなら１つの(a, b)についてO(N)で求める必要がある
# 判定する際、節約出来ないか？

# N * N のゾーンをずらしていく
# a [b  a] b
# c [a  c] a
# a  b  a  b
# c  a  c  a 対称軸がずれる 軸は2N - 1本ある
# 良い盤面になる条件

# 斜めにずらしていくことで前の結果を利用できる
# 1本の軸について判定した時、1つの盤面が良い盤面なら他全ても良い盤面
# 軸に刺さっている盤面の数を求めればいい

# 軸は2N - 1本ある
# 縦に対角線をずらす
ans = 0
for i in range(N):
    # 軸(0, i)にはN - i本の盤面が連なっている
    # 連なっている全ての盤面は全てTrueか全てFalse
    ans += (N - i) * judge(i, 0)

# 横に対角線をずらす
for i in range(1, N):
    ans += (N - i) * judge(0, i)
print(ans)

Measured memory_bytes: 111096
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define  sci(x)   scanf("%d", &x)
#define  scl(x)   scanf("%lld", &x)
#define  scd(x)   scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)

int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//CODE TONOY
	ll x,y,a,b,c,ans=0;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a),q(b),r(c);
    for(int i=0;i<a;i++) cin >> p[i];
    for(int i=0;i<b;i++) cin >> q[i];
    for(int i=0;i<c;i++) cin >> r[i];
    sort(p.begin(),p.end());
    reverse(p.begin(),p.end());
    sort(q.begin(),q.end());
    reverse(q.begin(),q.end());
    for(int i=0;i<x;i++) r.push_back(p[i]);
    for(int i=0;i<y;i++) r.push_back(q[i]);
    sort(r.begin(),r.end());
    reverse(r.begin(),r.end());
    for(int i=0;i<x+y;i++) 
	ans+=r[i];
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6000
n = int(input())
V = list(map(int, input().split()))
V.sort()
V.reverse()

if len(V) == 2:
  print((V[0]+V[1])/2)
else:
  ans = 0
  for i in range(n-1):
    ans += V[i]/(2**(i+1))
  ans += V[n-1]/(2**(n-1))
  print(ans)


Measured memory_bytes: 3060
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [n]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const s: string[] = tmp.shift().split(" ")[0].split("");
    let pre = "";
    let result = 0;
    for (let i = 0; i < n; i++) {
      if (pre != s[i]) {
        pre = s[i];
        result++;
      }
    }
    return `${result}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 8140
from sys import stdin
import fractions

s = stdin.readline().rstrip()
t = stdin.readline().rstrip()

li = []
for i in range(len(s)):
    li.append((s[i],t[i]))
li.sort()

for i in range(len(li)-1):
    if li[i][0] == li[i+1][0]:
        if li[i][1] != li[i+1][1]:
            print("No")
            exit()

li.sort(key=lambda x:(x[1]))

for i in range(len(li)-1):
    if li[i][0] != li[i+1][0]:
        if li[i][1] == li[i+1][1]:
            print("No")
            exit()

print("Yes")

Measured memory_bytes: 23168
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int cnt4 = 0, cntodd = 0;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		if(a % 4 == 0) cnt4++;
		if(a % 2 == 1) cntodd++;
	}
	// cout << cntodd << " " << cnt4 << endl;
	if(cnt4 >= cntodd || (cnt4 == cntodd - 1 && cnt4 + cntodd == n)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int m=n/2;
  int b[n];
  for(int i=0;i<n;i++){
    b[i]=a[i];
  }
  sort(b,b+n);
  for(int i=0;i<n;i++){
    if(a[i]<b[m]){
      cout << b[m] << endl;
    }
    else{
      cout << b[m-1] << endl;
    }
  }
}

Measured memory_bytes: 3712
N = int(input())
print(0)
res = input()
if res == "Vacant":
    exit(0)

print(N-1)
res2 = input()
if res2 == "Vacant":
    exit(0)
seat = [""]*N
seat[0] = res
seat[N-1] = res

first = 0
last = N-1

for i in range(18):
    ret = (first + last) // 2
    if ret == first:
        ret += 1
    print(ret)
    res = input()
    seat[ret] = res
    if res == "Vacant":
        exit(0)
    else:
        if (res == seat[first] and (ret - first) % 2 == 0) or (res != seat[first] and (ret - first) % 2 == 1):
            first = ret
        else:
            last = ret-1


Measured memory_bytes: 39748
#include <iostream>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

int main() {
    string s1 = "", s2 = "";
    cin >> s1;
    s2 = s1;
    reverse(s1.begin(), s1.end());
    if(s1 == s2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main() {
	//input
	int64_t N, M, K;
	cin >> N >> M >> K;

	vector<int64_t> A(N), B(M);
	for (int64_t i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int64_t i = 0; i < M; i++) {
		cin >> B[i];
	}

	//calculation
	vector<int64_t> sum_A(N + 1), sum_B(M + 1);
	int64_t temp_sum = 0;
	sum_A[0] = 0;
	for (int64_t i = 0; i < N ; i++) {
		temp_sum += A[i];
		sum_A[i + 1] = temp_sum;
	}
	temp_sum = 0;
	sum_B[0] = 0;
	for (int64_t i = 0; i < M; i++) {
		temp_sum += B[i];
		sum_B[i + 1] = temp_sum;
	}

	int64_t output = 0;
	for (int64_t i = 0; i <= N ; i++) {
		int64_t start_j = output - i;
		if (start_j < 0) {
			start_j = 0;
		}
		for (int64_t j = start_j; j <= M ; j++) {
			if (sum_A[i] + sum_B[j] > K) {
				break;
			}
			if (output < i + j) {
				output = i + j;
			}
		}
	}

	//output
	cout << output << endl;


	return 0;
}


Measured memory_bytes: 9580
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
int arr[100];

int dp[2][100][100][100];

int ans,nd;
int parity(int prev,int pos,int od,int ev)
{
     if(pos==nd) return 0;
     if(dp[prev][pos][od][ev]!=-1) return dp[prev][pos][od][ev];
     int x=INT_MAX,y=INT_MAX,p=INT_MAX,q=INT_MAX,m=INT_MAX,n=INT_MAX,k=INT_MAX,l=INT_MAX;


    if(arr[pos]==0)
    {
        if(prev==1)
        {
          if(od!=0) x=parity(1,pos+1,od-1,ev)+0;
          if(ev!=0) y=parity(0,pos+1,od,ev-1)+1;
        }
        else
        {

           if(ev!=0) q=parity(0,pos+1,od,ev-1)+0;
           if(od!=0) p=parity(1,pos+1,od-1,ev)+1;

        }

    }
    else
    {
        if(arr[pos]%2 && prev==1) m=parity(1,pos+1,od,ev)+0;
        if(arr[pos]%2 && prev==0) n=parity(1,pos+1,od,ev)+1;
        if(arr[pos]%2==0 && prev==0) k=parity(0,pos+1,od,ev)+0;
        if(arr[pos]%2==0 && prev==1) l=parity(0,pos+1,od,ev)+1;


    }
   dp[prev][pos][od][ev]=min({p,q,m,n,x,y,k,l});
   return dp[prev][pos][od][ev];
}


int main()
{
ll n,k;
cin>>n>>k;
ll arr[n];
for(int i=0;i<n;i++)
{
    cin>>arr[i];
}
sort(arr,arr+n);
ll sum=0;

for(ll i=0;i<n-k;i++)
{
    sum+=arr[i];
}
cout<<sum<<endl;

}















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

using namespace std;

int check(int a, int b, int x)
{
    long long ab = (long long) a * b;
    int s, t;
    if (x <= a + 2)
    {
        s = x;
        t = a + 1;
    }
    else if ((a + 1 - x) % 2 == 0)
    {
        s = t = (a + 1 + x) / 2;
    }
    else
    {
        s = (a + 1 + x) / 2;
        t = s + 1;
    }
    return (long long) s * t < ab;
}

int main()
{
    int q;
    cin >> q;
    while (q--)
    {
        int a, b;
        cin >> a >> b;
        if (a > b)
            swap(a, b);
        int ans = a - 1;
        int x = 0;
        for (int jump = b / 2 + 1; jump > 0; jump /= 2)
        {
            while (x + jump < b && check(a, b, x + jump))
                x += jump;
        }
        ans += x;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
    string s;
    cin >> s;
    int ans = 0;
    FOR(i,0,s.size()){
        ans += s[i] == '1';
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
<?php
list($a, $b, $m) = explode(' ', trim(fgets(STDIN)));
$a_arr = explode(' ', trim(fgets(STDIN)));
$b_arr = explode(' ', trim(fgets(STDIN)));
$m_arr = array();
for($i = 0; $i < $m; $i++){
	$m_arr[] = explode(' ', trim(fgets(STDIN)));
}

$min = min($a_arr) + min($b_arr);

foreach($m_arr as $val_arr){
	$sum = $a_arr[$val_arr[0] - 1] + $b_arr[$val_arr[1] - 1] - $val_arr[2];
	if($sum <= $min){
		$min = $sum;
	}
}
echo $min;
?>


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

using namespace std;

typedef long long ll;

struct segtree{
	ll T1[606060], T2[606060];
	ll n, s, sz = 1 << 18;
	
	void init(ll _n)
	{
		ll i;
		
		for(i=1; i<sz+sz; i++){
			T1[i] = T2[i] = 1e18;
		}
		
		n = _n;
	}
	
	void update(ll p, ll v)
	{
		v -= s;
		T1[p + sz] = min(T1[p + sz], v - p);
		T2[p + sz] = min(T2[p + sz], v + p);
		
		for(p=p+sz>>1; p; p>>=1){
			T1[p] = min(T1[p << 1], T1[p << 1 | 1]);
			T2[p] = min(T2[p << 1], T2[p << 1 | 1]);
		}
	}
	
	void add(ll v) { s += v; }
	
	ll getmin(ll *T, ll l, ll r)
	{
		ll ret = 1e18;
		
		l += sz, r += sz;
		
		for(; l<=r; ){
			if(l & 1) ret = min(ret, T[l]);
			if(~r & 1) ret = min(ret, T[r]);
			l = l + 1 >> 1;
			r = r - 1 >> 1;
		}
		
		return ret;
	}
	
	ll getval(ll p)
	{
		ll ret = getmin(T1, 1, p) + p;
		ret = min(ret, getmin(T2, p, n) - p);
		
		return ret + s;
	}
	
	ll getans()
	{
		ll i, ret = 1e18;
		
		for(i=1; i<=n; i++){
			ret = min(ret, T1[sz + i] + i);
		}
		
		return ret + s;
	}
};

segtree T;
ll n;

int main()
{
	ll q, a, b, x;
	
	scanf("%lld%lld%lld%lld", &n, &q, &a, &b);
	
	T.init(n);
	T.update(a, 0);
	
	for(; q--; ){
		scanf("%lld", &a);
		x = T.getval(a);
		T.add(abs(b - a));
		T.update(b, x);
		b = a;
	}
	
	printf("%lld\n", T.getans());
	
	return 0;
}

Measured memory_bytes: 9088
#include<iostream>
#include<string>
#include <cstdlib>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include <iomanip>
#include<stack>
#include <unordered_map>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
// #define pi acos(-1)
// #include<bits/stdc++.h>
typedef long long ll;
#define INF 0x7f7f7f7f //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
#define STDIN freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);
#define Quick ios::sync_with_stdio(false);cin.tie(NULL);
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m,n) for (int i = m;  i < n; i++)
#define PII pair<int,int>
#define PLL pair<long, long>
#define lowbit(x) (x&-x)

const int maxn = 50;
#define ERR 1e-6
#define fabs(a) (a < 0 ? -(a) : a)
#define square(a) ((a) * (a))
const int N = 4e5 + 10;
int n;


int x, y, a, b, c;
int aa[N];
int bb[N];
int cc[N];
bool cmp(int a, int b)
{
    return a > b;
}
int main()
{
    //STDIN
    cin >> x >> y >> a >> b >> c;
    for (int i = 0; i < a; i++) scanf("%d", &aa[i]);
    for (int i = 0; i < b; i++) scanf("%d", &bb[i]);
    for (int i = 0; i < c; i++) scanf("%d", &cc[i]);
    sort(aa,aa + a, cmp);
    sort(bb, bb + b, cmp);
    int j = c;
    for (int i = 0; i < x; i++)
    {
        cc[j++] = aa[i];
    }
    for (int i = 0; i < y; i++) cc[j++] = bb[i];
    sort(cc, cc+c + x+y, cmp);
    long long sum = 0ll;
    for (int i = 0; i < x+ y; i++) sum += cc[i];
    cout << sum << endl;
}

Measured memory_bytes: 3840
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    long long r, d, x;    cin >> r >> d >> x;
    for (int i = 1; i <= 10; i++)
    {
        x = r * x - d;
        cout << x << '\n';
    }
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 256
#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

typedef tree< pair<int,int>, null_type, less< pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update>Order_Set;

Order_Set X;

const int mxn = 1e7+100;
const int Mod = 1e9+7;

int arr[mxn], qs[mxn];
int bitOn[55];
map<int,int>Mp, cnt, op;
vector< pair<int, pair<int,int> > >Pi, Ans;
vector<int>G[mxn];
set<int>seet[mxn];

int main()
{
     ios::sync_with_stdio(false);

     long long a,b;
     cin>>a>>b;
     long long Ans = (a*b)/__gcd(a,b);
     cout<<Ans<<endl;

     return 0;
}




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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> card(n);
    map<int, int> card_num;
    rep(i, n) {
        cin >> card[i];
        ++card_num[card[i]];
    }

    stl_rep(itr, card_num) {
        if (itr->second >= 3) {
            if (itr->second % 2 == 0) itr->second = 2 - itr->second % 2;
        }
    }

    int cnt_of_two = 0;
    stl_rep(itr, card_num) {
        if (itr->second == 2) ++cnt_of_two;
    }

    cout << card_num.size() - cnt_of_two % 2 << endl;

    return 0;
}

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

int main(void){
  int n;
  char a[100][2];
  int i,j;
  
  //read input
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",a[i]);
    if(strcmp(a[i],"Y")==0){
      printf("Four\n");
      return 0;
    }
  }
  printf("Three\n");
  
  return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

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

vector<ll> Prime(1000000,0);
void sosu(ll n){
  Prime.at(0)=2;
  ll t=1;
  for(ll i=3;i<n;i++){
    rep(j,t){
      if(i%Prime.at(j)==0){
        break;
      }
      if(j==t-1){
        Prime.at(t)=i;
        t++;
      }
    }
  }
}

int main(){
  ll A,B,G,ans=1,t=0;
  cin >> A >> B;
  G=gcd(A,B);
  for(ll i=2;i*i<=G;i++){
    if(G%i==0){
      ans++;
      while(G%i==0){
        G/=i;
      }
    }
  }
  if(G!=1){
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8064
n = int(input())
l = list(map(int,input().split()))
cou = 0

for i in range(0,n-1):
  if l[i]==i+1:
      l[i],l[i+1] = l[i+1], l[i]
      cou += 1
if l[-1]==n:
  cou += 1
print(cou)

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

int main(void){
    int n,k,q;
    vector<int> a;
    vector<int> p;
    cin >> n >> k >> q;
    a.resize(n);
    
    rep(i,q){
        int x;
        cin >> x;
        a[x-1] += 1;
    }
    rep(i,n){
        p.push_back(k);
    }
    rep(i,n){
        p[i] -= (q-a[i]);
    }
  	
    rep(i,n){
        if(p[i]>0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    
    
    return 0;
}





Measured memory_bytes: 1528
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
n = int(input())
ans1 = make_divisors(n-1)
ans2 = make_divisors(n)
for i in ans2:
  if i==1:
    continue
  n1 = n
  while n1%i==0:
    n1//=i
  if n1%i==1:
    ans1.append(i)
ans = list(set(ans1))
print(len(ans)-1)
    

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

int main() {
	int N, M, Q;
	int L[200000], R[200000];
	int nijigen[501][501] = {};
	cin >> N >> M >> Q;
	repeat(i, M) {
		cin >> L[i] >> R[i];
		nijigen[L[i]][R[i]] += 1;
	}
	int p[100000], q[100000];
	repeat(i, Q) {
		cin >> p[i] >> q[i];
	}

	
	int ruikei[502][502] = {};

	repeat(i, N) {
		repeat(ii, N) {
			ruikei[i + 1][ii + 1] = ruikei[i + 1][ii] + nijigen[i + 1][ii + 1];
		}
	}

	repeat(ii, N) {
		repeat(i, N) {
			ruikei[N - i][ii + 1] = ruikei[N - i + 1][ii + 1] + ruikei[N - i][ii + 1];
		}
	}

	repeat(i, Q) {
		printf("%d\n", ruikei[p[i]][q[i]]);
	}
	return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<lint, lint> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	lint N, M;
	cin >> N >> M;
	vector<P>V(N);
	rep(i, N) {
		cin >> V[i].first >> V[i].second;
	}
	sort(V);
	lint j = 0;
	lint A = 0;
	lint ans = 0;
	rep(i,M){
			ans += V[j].first;
			V[j].second--;
			A++;
			if (V[j].second == 0) {
				j++;
			}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
n, m = gets.split.map(&:to_i)

graph = Array.new(n + 1) { [] }

m.times do
  a, b = gets.split.map(&:to_i)
  graph[a].push(b)
  graph[b].push(a)
end

dist = Array.new(n + 1, -1)
dist[1] = 0

que = []
que.push(1)

ans = Array.new(n + 1, -1)

until que.empty?
  v = que.shift

  graph[v].each do |nv|
    next if dist[nv] != -1

    dist[nv] = dist[v] + 1
    que.push(nv)
    ans[nv] = v
  end
end

puts "Yes"
puts ans[2..-1]


Measured memory_bytes: 33432
from heapq import heappop, heappush


def dijkstra(links, n, m, freezables, s, t):
    queue = [(0, 0, s, m)]
    visited = [0] * n
    while queue:
        link_cost, cost, node, remain = heappop(queue)
        if node == t:
            # Congratulations!
            if link_cost <= m:
                return link_cost
            return cost - remain
        if visited[node] >= remain:
            continue
        visited[node] = remain
        for cost2, node2 in links[node]:
            if remain < cost2:
                continue
            if node2 in freezables:
                heappush(queue, (link_cost + cost2, cost + cost2 * 2 + m - remain, node2, m))
            else:
                heappush(queue, (link_cost + cost2, cost + cost2, node2, remain - cost2))
    return 'Help!'


while True:
    n, m, l, k, a, h = map(int, input().split())
    if n == 0:
        break
    freezables = set(map(int, input().split())) if l > 0 else set()
    links = [set() for _ in range(n)]
    for _ in range(k):
        x, y, t = map(int, input().split())
        links[x].add((t, y))
        links[y].add((t, x))
    print(dijkstra(links, n, m, freezables, a, h))

Measured memory_bytes: 9596
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n_a = I()
As = [0]
for i in range(n_a):
    n_t = I()
    Ts = []
    for j in range(n_t):
        Ts.append(Is())
    As.append(Ts)

cand = []
def dfs(i,st):
    if i < n_a:
        dfs(i+1,st+[i+1])
        dfs(i+1,st)
    elif i == n_a:
        flag = True
        tf = [None] * (n_a + 1)
        for j in range(1,n_a+1):
            if j in st:
                tf[j] = 1
            else:
                tf[j] = 0
        for j in range(1,n_a+1):
            if j not in st:
                continue
            for e in As[j]:
                x,y = e
                if tf[x] != y:
                    #print("false",i,tf,st)
                    flag = False
        if flag:
            #print("true",i,tf,st)
            cand.append(tf)
dfs(0,[])
ans = 0
for e in cand:
    ans = max(ans,e.count(1))
print(ans)

Measured memory_bytes: 10612
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int main(){
    LL A,B;
    cin>>A>>B;
    LL ans=0;
    for(LL i=A;i%4!=0;i++){
        ans^=i;
    }
    for(LL i=max(A,B/4*4);i<=B;i++){
        ans^=i;
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;

const ll maxn = 222, MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}



int main(){
    ll a; cin>>a;
    if (a & 1) cout<<a * 2<<endl;
    else cout<<a<<endl;
    return 0;
}



Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

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

n = int(readline())
a = list(map(int, readline().split()))

counter = [0 for _ in range(n + 1)]
for i in a:
    counter[i] += 1

total = 0 
diff = [0 for _ in range(n + 1)]
for i, c in enumerate(counter):
    x = c * (c - 1) // 2
    total += x
    if c - 1 <= 0:
        diff[i] = x
    else:
        y = (c - 1) * (c - 2) // 2
        diff[i] = x - y

for i in range(n):
    print(total - diff[a[i]])

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
   ll a, b, k; cin >> a >> b >> k;
   ll d = gcd(a, b);
   Vi x;
   REP(i, d){
      if( d % (d - i) == 0) x.push_back(d - i);
   }
   cout << x[k-1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
long long int diff(long long int i, long long int h, long long int w){
  long long int s[3];
  s[0] = i*w;
  s[1] = (h-i)*(w/2);
  s[2] = (h-i)*(w-(w/2));
  sort(s, s+3);
  return s[2]-s[0];
}
int main(void){
  long long int h, w;
  long long int ans = INT_MAX;
  cin >> h >> w;
  if(h%3 == 0 || w%3 == 0){
    cout << 0 << endl;
    return 0;
  }
  ans = min(h, w);
  for(int i = 1; i < h; i++) ans = min(ans, diff(i, h, w));
  for(int i = 1; i < w; i++) ans = min(ans, diff(i, w, h));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

bool check(string s){
  map<char, int> m;
  REP(i, s.length()) m[s[i]] += 1;
  if(m['A'] == 2 && m['U'] == 1 && m['I'] == 1 && m['D'] == 1 && m['N'] == 2 && m['Y'] == 1) return true;
  return false;
}

int main() {
  string s; cin >>s;
  REP(i, (int)(s.length()) - 7){
    if(check(s.substr(i, 8))){
      s = s.substr(0, i) + "AIZUNYAN" + s.substr(i + 8);
      i += 7;
    }
  }
  cout <<s <<endl;
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long ll;
typedef std::pair<int, int> P;
 
#define frep(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) frep(i, 0, (n))
#define rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define all(i, x) for(typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define pb push_back
 
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX = 100010;
const int INF = 1e9;
const int MOD = 1000000007;
const string END = "\n";

void solve(){
	ll x, y; cin >> x >> y;
	ll n = y / x, cnt = 0;
	while(n / 2 > 0){
		n /= 2; cnt += 1;
	}
	cout << cnt + 1 << END;
}
 
int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	solve();
	return 0;
}

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

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] ball=new int[n];
        long[] num=new long[n];
        for(int i=0;i<n;i++){
            ball[i]=sc.nextInt();
            num[ball[i]-1]++;
        }
        long gt=0;
        for(int i=0;i<n;i++){
            gt+=num[i]*(num[i]-1)/2;
        }
        for(int i=0;i<n;i++){
            System.out.println(gt-(num[ball[i]-1]-1));
        }
    }
}

Measured memory_bytes: 104744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int h,n;
vector<int>arr1,arr2;
vector<ll>visited(10001);
vector<ll>memo(10001);
ll dp(ll var)
{
	if(var<=0)
	 return 0;
	if(visited[var])
	 return memo[var];
	visited[var]=1;
	ll mx=1e9;
	for(int i=0; i<n; i++){
		mx=min(mx,arr2[i]+dp(var-arr1[i]));
	}
	memo[var]=mx;
	return memo[var];
}
int main()
{
	cin>>h>>n;
	arr1.resize(n);
	arr2.resize(n);
	for(int i=0; i<n; i++){
		cin>>arr1[i]>>arr2[i];
	}
	ll ans=dp(h);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4324
#![allow(non_snake_case)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

fn main() {
    input!(
        a: isize,
        b: isize,
    );
    println!("{}", cmp::max(cmp::max(a+b, a-b), a*b));
}


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

int main()
{
  int A, B, M, mina = 100000, minb = 100000;
  cin >> A >> B >> M;
  vector<int> X(A), Y(B);
  for (int i = 0; i < A; i++)
  {
    cin >> X.at(i);
    mina = min(mina, X.at(i));
  }
  for (int i = 0; i < B; i++)
  {
    cin >> Y.at(i);
    minb = min(minb, Y.at(i));
  }
  int minc = mina + minb;
  int x, y, c, cost;
  for (int i = 0; i < M; i++)
  {
    cin >> x >> y >> c;
    cost = X.at(x - 1) + Y.at(y - 1) - c;
    minc = min(cost, minc);
  }
  cout << minc << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	ll a, b, c; cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << endl;
	}
	else cout << min({ b*c,a*b,a*c }) << endl;
	return 0;
}

Measured memory_bytes: 256
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
    os<<endl;
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, map<T,S> const&M){
    for(auto e:M){
        os<<e;
    }
    os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;

struct cumsum2D{
    int H,W;
    vector<vector<int64>> cumsum;
    cumsum2D(vector<vector<int64>> A) :H(A.size()), W(A[0].size()){
        cumsum.assign(H+1, vector<int64>(W+1,0));
        for(int h=0;h<H;h++){
            for(int w=0;w<W;w++){
                cumsum[h+1][w+1] = A[h][w];
            }
        }

        for(int h=0;h<H;h++){
            for(int w=0;w<W;w++){
                cumsum[h+1][w+1] += cumsum[h+1][w] + cumsum[h][w+1] - cumsum[h][w];
            }
        }
    }

    // return sum(A[h][w]) {h,w | h in [h_begin, h_end) and w in [w_begin, w_end)}
    int64 get(int h_begin, int h_end, int w_begin, int w_end){
        return cumsum[h_end][w_end] - cumsum[h_begin][w_end] - cumsum[h_end][w_begin] + cumsum[h_begin][w_begin];
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    const int MAX_Z = 1000;
    vector<vector<int64>> A(MAX_Z+1,vector<int64>(MAX_Z+1));
    REP(i,N){
        int l,u,r,d; cin >> l >> u >> r >> d;
        A[l][u]++; A[r][d]++;
        A[l][d]--; A[r][u]--;
    }
    cumsum2D C(A);
    int64 ans = 0;
    for(auto a:C.cumsum) chmax(ans,*max_element(ALL(a)));
    cout << ans << endl;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    ll r, D, x;
    cin >> r >> D >> x;
    for (int i = 0; i < 10; i++) {
        x = r * x - D;
        cout << x << endl;
    }

}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
const int n = 4;

int main(){
  map<char, int> count;
  bool flag=true;
  for(int i=0; i<n; i++){
    char a; cin >> a;
    count[a] += 1;
    if(count[a] > 2) flag=false;
  }
  if(count.size()>2) flag=false;
  
  cout << (flag ? "Yes" : "No") << "\n";
} 

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

int main()
{
int N,M;scanf("%d %d",&N,&M);vector<int> road(N+2,0);
for(int L,R,i=0;i<M;i++)
{
  scanf("%d %d",&L,&R);
  road[L]++;road[R+1]--;
}
int ans=0;
for(int i=1;i<N+2;i++)
{
  road[i]+=road[i-1];
  if(road[i]==M)ans++;
}
printf("%d\n",ans);
}

Measured memory_bytes: 3856
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
	
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int[n];
		int sum=0;
		int num=0;
		
		for(int i=0;i<n;++i) {
			a[i]=sc.nextInt();
			sum=sum+a[i];
		}
		double ave=(double)sum/n;
		for(int i=0;i<n;++i) {
			if(Math.abs(a[num]-ave)>Math.abs(a[i]-ave))num=i;
		}
		
		System.out.println(num);
		
	}
}

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

using namespace std;

int main(){
    int a, b, m;
    cin >> a >> b >> m;
    vector<int> A(a), B(b);
    copy_n(istream_iterator<int>(cin), a, A.begin());
    copy_n(istream_iterator<int>(cin), b, B.begin());
    int ans = accumulate(A.begin(), A.end(), A[0] + B[0], [](int l, int r){return min(l, r);})
        + accumulate(B.begin(), B.end(), A[0] + B[0], [](int l, int r){return min(l, r);});

    for (int i = 0; i < m; i++){
        int x, y, c;
        cin >> x >> y >> c;
        x--; y--;
        ans = min(ans, A[x] + B[y] - c);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
N,K = map(int,input().split())
MOD = 10**9+7
a = list(map(int,input().split()))
b = []
c = []
d = []
num_z = 0
for val in a:
    if val>0:
        b.append(val)
        d.append(val)
    elif val<0:
        c.append(-val)
        d.append(-val)
    else:
        num_z += 1
        d.append(0)
num_b = len(b)
num_c = len(c)
res = 1
if (N==num_c and K%2==1):
    d = sorted(d)
    for val in d[:K]:
        res = res*val%MOD
    res = -res%MOD
elif (N==K and num_c>0):
    c = sorted(c)
    for val in a:
        res = res*val%MOD
elif num_b==0:
    if K%2==0:
        if num_c >= K:
            c = sorted(c,reverse=True)
            for val in c[:K]:
                res = res*val%MOD
        else:
            res = 0
    else:
        res = 0
else:
    b = sorted(b,reverse=True)
    c = sorted(c,reverse=True)
    bidx = 0
    cidx = 0
    tmp = 0
    if num_b+num_c < K:
        res = 0
    else:
        if num_b >= K:
            bidx = K
        elif num_c>=2:
            bidx = num_b
            cidx = K-bidx
            if (K-num_b)%2==1:
                if cidx == num_c:
                    print(0)
                    exit()
                bidx -= 1
                cidx += 1
        else:
            print(0)
            exit()
        #print(bidx,cidx)
        for val in b[:bidx]:
            res = res*val%MOD
        for val in c[:cidx]:
            res = res*val%MOD
        for k in range(100000):
            if bidx<=1 or cidx+1 >= num_c:
                break
            if b[bidx-1]*b[bidx-2] > c[cidx]*c[cidx+1]:
                break
            else:
                res *= c[cidx]
                res *= c[cidx+1]
                res = res%MOD
                res = res*pow(b[bidx-1],MOD-2,MOD)
                res = res*pow(b[bidx-2],MOD-2,MOD)
                res = res%MOD
                bidx -= 2
                cidx += 2
print(res%MOD)



Measured memory_bytes: 36164
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int x,y; cin >>x >>y;
  int f=4*x-y;
  if(f%2==0 and 0<= f){
    if(f/2 <= x)
      print("Yes");
    else print("No");
  }
  else print("No");
}


Measured memory_bytes: 3588
import sys
sys.setrecursionlimit(1000000)

n = int(input())
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    if w % 2 == 0:
        graph[u].append((v, 1))
        graph[v].append((u, 1))
    else:
        graph[u].append((v, -1))
        graph[v].append((u, -1))
            
color = [None for i in range(n)]
def set_color(v, c):
    color[v] = c
    for next_v, d in graph[v]:
        if color[next_v] is None:
            set_color(next_v, d * c)

set_color(0, 1)
for c in color:
    if c != 1:
        print(0)
    else:
        print(1)

Measured memory_bytes: 76520
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        //Solve();
        return;
    }

    public static string Solve()
    {
        string S = Read();
        for (int i = 0; i < 3; i++)
        {
            if (S[i] == S[i + 1])
            {
                return "Bad";
            }
        }

        return "Good";
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 11092