akhauriyash/Code-Regression huggingface dataset:
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~ Aashutosh Rathi~~~~~~
// ~~~~~~~~aashutoshrathi~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
// Use memcpy while copying matrix :D
// o_O Never do calculation in if block -_- 
// Use __builtin_popcount(z) to get set bit count of z
 
#include <bits/stdc++.h> 	// Apne aap me sab kuch hai isme 
#include <stdio.h>

using namespace std;	// Kyuki yahi mai-baap hai
 
#define mod(x) 			x%1000000007
#define MIN(n1, n2)     ((n1) > (n2) ? (n2) : (n1))
#define MAX(n1, n2)     ((n1) > (n2) ? (n1) : (n2))
#define MID(s, e)       (s+(e-s)/2)
#define fast fin; fout; fio;
#define fin cin.tie(NULL)
#define fout cout.tie(NULL)
#define fio ios::sync_with_stdio(false)
typedef pair <long, long> lpairs;
typedef long long ll;

int main() {
    fast
    ll n;
    cin >> n;
    ll a[n];
    for(ll i=0; i<n; i++) {
        cin >> a[i];
    }
    sort(a, a+n);
    long double res = a[0];
    for(ll i=1; i<n; i++) {
        res = (res+a[i])/2.0;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long
int main () {
    ll X, Y;
    cin >> X >> Y;
    if (X%Y==0)
        cout << "-1";
    else{
        ll cnt=0;
        for (int i=2;cnt==0;i++){
            if ((i*X)%Y!=0)
                cnt=i*X;
        }
        cout << cnt;
    }
    return 0;
}

Measured memory_bytes: 256
N,X = map(int,input().split())
L = list(map(int,input().split()))
D = 0
a = [0]
count = 0
for i in range(N):
  Di = D + L[i]
  D = Di
  a.append(Di)
for i in a:
  if i <= X:
    count += 1
print(count)

Measured memory_bytes: 3064
num=int(input())
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
ans=num2alpha(num)
print(str.lower(ans))

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int num[100010];
ll powmod(ll x, ll k, ll m){
    if(k == 0) return 1;
    if(k % 2 == 0) return powmod(x * x % m, k / 2, m);
    else return x * powmod(x, k - 1, m) % m;
}


int main(void){
	int n; cin >> n;
	rep(i, n){
		int a; cin >> a;
		num[a]++;
	}
	if(n % 2 == 0){
		for (int i = 1; i <= n - 1; i += 2){
			if(num[i] != 2){
				printf("0\n");
				return 0;
			}
		}
	}else{
		if(num[0] != 1){
			printf("0\n");
			return 0;
		}
		for (int i = 2; i <= n - 1; i+= 2){
			if(num[i] != 2){
				printf("0\n");
				return 0;
			}
		}
	}
	printf("%lld\n", powmod(2, n / 2, MOD));

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int ans = 0;  
  for (int i = 0; i < N; i++) {
    int L, R;
    cin >> L >> R;
    ans += R - L + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] H = new int[N+1];
		for( int i=1; i<=N; i++ ){
			H[i] = sc.nextInt();
		}
		int[] good = new int[N+1];
		for( int i=0; i<M; i++ ){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if( H[a]<H[b] ){
				good[a]++;
			}
			if( H[b]<H[a] ){
				good[b]++;
			}
			if( H[a]==H[b] ){
				good[a]++;              
				good[b]++;
			}
		}
		int ans = 0;
		for( int i=1; i<=N; i++ ){
			if( good[i]==0 ){
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 60280
#include<iostream>
#include<vector>
#include<queue>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define ll long long


int main(){
    int n,m; std::cin >> n >> m;
    std::vector<std::vector<int> > p(n);
    std::vector<bool> visited(n,false);
    rep(i,m){
        int a,b;
        std::cin >> a >> b; --a; --b;
        p[a].push_back(b);
        p[b].push_back(a);
    }
    int max_network_size=-1;
    rep(i,n){
        if(visited[i]) continue;
        std::queue<int> que; que.push(i);
        int network_size=0;
        while(!que.empty()){
            int q=que.front(); que.pop();
            if(visited[q]) continue;
            ++network_size;
            visited[q] = true;
            for(auto f : p[q]){
                if(visited[f]) continue;
                que.push(f);
            }
        }
        max_network_size = std::max(max_network_size, network_size);
    }
    std::cout << max_network_size << std::endl;

    return 0;
}

Measured memory_bytes: 14840
import heapq
t = 1
def max(a,b):
	if a > b:
		return a
	return b
while t > 0:
	t -= 1
	# n,k,q = map(int,input().split())
	# v = []
	# l = []
	x = int(input())
	if x <= 599:
		print("8")
	elif x <= 799:
		print("7")
	elif x <= 999:
		print("6")
	elif x <= 1199:
		print("5")
	elif x <= 1399:
		print("4")
	elif x <= 1599:
		print("3")
	elif x <= 1799:
		print("2")
	elif x <= 1999:
		print("1")
	
	# v = list(map(int,input().strip().split()))[0:n]
	# for i in range(q):
	# 	p = int(input().strip())
	# 	v.append(p)
	# for i in range(n):
	# 	l.append(0)
	# for i in v:
	# 	l[i-1] += 1
	# for i in range(n):
	# 	if(l[i] <= q-k):
	# 		print("No")
	# 	else:
	# 		print("Yes")


Measured memory_bytes: 62300
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
  unsigned int N, K, a, b, c, temp = 0;
  int count = 0, sum;
  cin >> N >> K;
  // N = 5, K = 3;
  int A[N], diff[N-K+1] = {0};
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  // A[0] = 10, A[1] = 15, A[2] = 11, A[3] = 14, A[4] = 12;


  sort(A, A+N, greater<int>());

  for(int i = 0; i < N; i++){      
    // cout << A[i] << ' ';
  }
  // cout << endl;

    for(int i = 0; i < N-K+1; i++){
      diff[i] = abs(A[i] - A[i+K-1]);
      
      // cout << diff[i] << ' ';
    }
    // cout << endl;

    sort(diff, diff+N-K+1);
    for(int j=0; j<K; j++){
      temp += diff[j];
    }
  

  cout << diff[0] << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll N, K, X, Y;
    scanf("%lld %lld %lld %lld", &N, &K, &X, &Y);
    if(N<=K){
        printf("%lld\n", N*X);
        return 0;
    }
    else {
        printf("%lld\n", K*X + (N-K)*Y);
        return 0;
    }
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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 vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int H,W,K,ans=0,T=0;
  cin>>H>>W>>K;
  char C[H+1][W+1];
  REP(i,H){
    REP(j,W){
      cin>>C[i][j];
      if(C[i][j]=='#') T++;
    }
  }
  
  for(int i=0; i<(1<<H); ++i){
    for(int j=0; j<(1<<W); ++j){
      vector<pair<int,int>> S;
      int cnt=0,L=0;
      for(int ii=0; ii<H; ++ii){
        for(int jj=0; jj<W; ++jj){
          if(i&(1<<ii) || j&(1<<jj)){
            S.PB(MP(ii,jj));
            L++;
          }
        }
      }
      REP(p,L){
        if(C[S[p].first][S[p].second]=='#') cnt++;
      }
      if(T-cnt==K){
        ans++;
      }
    }
  }
  
  co(ans);
  return 0;
}

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

using namespace std;
typedef long int li;
typedef long long ll;

int main() {
    
    string s; cin >> s;
    int a = 0, b = 0, c = 0;

    for (int i=0; i<s.size(); i++) {
        if (s[i]=='a') a += 1;
        else if (s[i]=='b') b += 1;
        else if (s[i]=='c') c += 1;
    }

    if (abs(a-b)<=1&&abs(b-c)<=1&&abs(c-a)<=1) {
        cout << "YES" << "\n";
        return 0;
    }

    cout << "NO" << "\n";

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<int> a(n-1);
  for(int i=0;i<n-1;i++) cin >> a[i];

  vector<int> sub(n);
  for(int i=0;i<n-1;i++){
    sub[a[i]-1]++;
  }

  for(int i=0;i<n;i++){
    cout << sub[i] << endl;
  }
}


Measured memory_bytes: 4840
from time import time
import random
random.seed(0)

now = time()

MAX = 26

d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
t = []
for row in s:
    mxi = 1
    mx = 0
    for i, e in enumerate(row, 1):
        if e > mx:
            mx = e
            mxi = i

    t.append(mxi)

last = [0] * MAX

score = 0
for day, e in enumerate(t, 1):
    score += s[day-1][e-1]
    last[e-1] = day

    for ec, elast in zip(c, last):
        score -= ec * (day - elast)

di = 1

c_sum = sum(c)
c_li = []
for i, e in enumerate(c, 1):
    c_li += [i] * e

while time() - now <= 1.85:
    prev_score = score

    di -= 1
    ed = (di + d - 1) % d + 1
    qi = random.randint(0, c_sum - 1)
    eq = c_li[qi]

    q_old = t[ed-1]
    d_prev = {q_old: 0, eq: 0}

    c_old = c[q_old-1]
    c_new = c[eq-1]

    for day, e in enumerate(t, 1):
        if e in d_prev.keys():
            d_prev[e] = day

        score += c_old * (day - d_prev[q_old])
        score += c_new * (day - d_prev[eq])

    score -= s[ed-1][q_old-1]
    score += s[ed-1][eq-1]

    t[ed-1] = eq

    d_prev = {q_old: 0, eq: 0}

    for day, e in enumerate(t, 1):
        if e in d_prev.keys():
            d_prev[e] = day

        score -= c_old * (day - d_prev[q_old])
        score -= c_new * (day - d_prev[eq])

    if prev_score > score:
        t[ed-1] = q_old
        score = prev_score

print(*t, sep="\n")


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

using ll = long long;

#define dbg(x) cerr << "[" #x << " : " << x << "]\n"

const int mod = (int)1e9+7;

int main()
{
    int n;
    scanf("%d", &n);
    ll ans = 0;
    map<pair<int, int>, int> m;
    for(int i = 1; i <= n; i++) {
        string s = to_string(i);
        m[{s[0] - '0', s[s.length()-1] - '0'}]++;
    }
    for(auto it : m) {
        int x = it.first.first;
        int y = it.first.second;
        ans += it.second * m[{y, x}];
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i = 0; i < n; i++)
const int INF = 1e9;
const int N = 2e5+7;
const int MOD = 1e9+7;

int a[N];

int main(){

  int n; cin >> n;
  REP(i,n) cin >> a[i];

  deque<int> dq;
  REP(i,n){
    if(i%2) dq.push_front(a[i]);
    else dq.push_back(a[i]);
  }

  if(n%2) reverse(dq.begin(),dq.end());
  REP(i,n) cout << dq[i] << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
vector<string> A(0);
long flo(long a,long b,long x){
  return ((a*x)/b)-a*(x/b);
}

int main() {
  long A,B,N;cin>>A>>B>>N;
  cout<<flo(A,B,min(B-1,N))<<endl;
}


Measured memory_bytes: 3624
#!/usr/bin/env pypy

import sys
inp = sys.stdin.readline
out = print
MAX = 10**9
 
n, k = map(int, inp().split())
cost = list(map(int, inp().split()))
dp = [MAX] * (n)
dp[0] = 0
 
for i in range(1, n):
    dp[i] = min(dp[j] + abs(cost[i] - cost[j]) for j in range(max(0, i - k), i))
 
out(dp[-1])

Measured memory_bytes: 85204
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}
fn main() {
let primes = [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381];
    let n = get!(usize);
    let mut ans = String::new();
    for i in 0..n {
        ans += &primes[i].to_string();
        if i != n - 1 {
            ans += " ";
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
import math
n = int(input())
k = int(input())
ans = 0


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def partical(L, K, M):  # L:対象の数の長さ K:0以外の個数 M:最大位の数値
    res = 0
    # 最大位の一つ前の位まで
    if L - K > 1:
        res += combinations_count(L - 1, K) * (9 ** K)
    # 最大位の直近の位まで
    if L > 1 and K > 1:
        res += (M - 1) * combinations_count(L - 1, K - 1) * (9 ** (K - 1))
    # 最大位計算の場合
    if K == 1:
        res += M
    return res


def calcLM(target):
    L = len(str(target))
    M = int(str(target)[0])
    return (L, M)


while k > 0:
    L, M = calcLM(n)
    ans += partical(L, k, M)
    n = n - int(str(n)[0]) * (10 ** (len(str(n))-1))
    k = k - 1

print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, M, X, Y = map(int, input().split())
    XN = list(map(int, input().split()))
    YM = list(map(int, input().split()))
    result = 'War'

    for z in range(X + 1, Y + 1):
        if X < z <= Y and max(XN) < z <= min(YM):
            result = 'No War'
    print(result)


if __name__ == "__main__":
    main()


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

using namespace std;

using ll = long long;

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

    map<ll, int> m;
    ll ans = 0;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ans += m[i - a];
        m[i + a]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 26348
#include <cstdio>
inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}
const int N = 3e3 + 5;
int n, a[N], que[N], qn, fa[N], g[N];
int tot, first[N], next[N << 1], end[N << 1];
void AddEdge(int x, int y) {
	next[++tot] = first[x], first[x] = tot, end[tot] = y;
	next[++tot] = first[y], first[y] = tot, end[tot] = x;
}
inline bool check(int x) {
	que[qn = 1] = x, fa[x] = 0;
	for (int ql = 1, u; u = que[ql], ql <= qn; ++ql)
		for (int k = first[u], v; v = end[k], k; k = next[k])
			if (v != fa[u]) fa[v] = u, que[++qn] = v;
	
	for (int qr = qn, u; u = que[qr], qr; --qr) {
		g[u] = 0;
		for (int k = first[u], v; v = end[k], k; k = next[k])
			if (fa[v] == u) g[u] |= ((!g[v]) && (a[u] > a[v])); 
	}
	
	return g[x];
}
int main() {
	n = Get();
	for (int i = 1; i <= n; ++i) a[i] = Get();
	for (int i = 1; i < n; ++i) AddEdge(Get(), Get());
	
	for (int i = 1; i <= n; ++i) 
		if (check(i)) printf("%d ", i);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  map<string, int> mp;
  mp["AC"] = 0;
  mp["RE"] = 0;
  mp["TLE"] = 0;
  mp["WA"] = 0;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  vector<string> ls= {"AC", "WA", "TLE", "RE"};
  for(auto x: ls) {
    cout << x << " x " << mp[x] << endl;
  }
  return 0;
  
}

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

const int MAX_N = 10010;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> Array;
typedef vector<Array> Graph;
typedef pair<double, double> pdd;
const ull mod = 1000000000 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

const int CODE_MAX = 362880;
const int SIZE = 9;
int visited[CODE_MAX];

int factorial(int n){
    if(n==1) return 1;
    return n*factorial(n-1);
};

struct Board{
    int num[SIZE];
    void print(){
        for(int i=0;i<SIZE;i++) cout << num[i] << " ";
        cout << endl;
    }
};

int encode(Board &b){
    int res = 0;
    int temp_b[SIZE];
    for(int i=0;i<SIZE;i++) temp_b[i] = b.num[i];
    for(int i=0;i<SIZE-1;i++){
        res += factorial(SIZE-1-i)*temp_b[i];
        for(int j=i+1;j<SIZE-1;j++){
            if(temp_b[i]<temp_b[j]) temp_b[j]--;
        }
    }
   return res;
}

Board decode(int encoded){
    Board b;
    int tmp[SIZE];
    for(int i=0;i<SIZE-1;i++){
        int fact = factorial(SIZE-1-i);
        tmp[i] = encoded/fact;
        encoded %= fact;
    }
    tmp[SIZE-1] = 0;
    int tmp2[SIZE];
    bool check[SIZE];
    for(int i=0;i<SIZE;i++){
        tmp2[i] = i;
        check[i] = false;
    }
    for(int i=0;i<SIZE;i++){
        int j=0;
        while(tmp[i]!=tmp2[j] || check[j]) j++;
        b.num[i] = j;
        check[j] = true;
        while(j<SIZE){
            tmp2[j]--;
            j++;
        }
    }

    return b;
}

int get_adjacent(int now, int i){
    // "i" represents the direction of zero movement.0 up, 1 down, 2 left, 3 right
    Board b = decode(now);
    int zero=0;
    while(b.num[zero]!=0) zero++;
    if(i==0){
        if(zero<3) return -1;
        swap(b.num[zero], b.num[zero-3]);
    }
    if(i==1){
        if(zero>5) return -1;
        swap(b.num[zero], b.num[zero+3]);
    }
    if(i==2){
        if(zero%3<1) return -1;
        swap(b.num[zero], b.num[zero-1]);
    }
    if(i==3){
        if(zero%3>1) return -1;
        swap(b.num[zero], b.num[zero+1]);
    }
    return encode(b);
}

int heuristic_func(int enc1, int enc2){
    Board b1 = decode(enc1);
    int zero1 = 0;
    while(zero1!=0) zero1++;
    Board b2 = decode(enc2);
    int zero2 = 0;
    while(zero2!=0) zero2++;
    return abs(zero1/3 - zero2/3) + abs(zero1%3 - zero2%3);
}

int main(){
    Board b;
    for (int i=0;i<SIZE;i++){
        cin >> b.num[i];
    }
    for(int i=0;i<CODE_MAX;i++){
        visited[i] = -1;
    }

    const int start = encode(b);
    const int goal = 46233;
    priority_queue<pii, vector<pii>, greater<pii> > que;
    que.push(make_pair(heuristic_func(start, goal), start));
    visited[start] = 0;
    while(visited[goal]==-1){
        pii x = que.top();
        que.pop();
        int now = x.second;
        for(int i=0;i<4;i++){
            int adj = get_adjacent(now, i);
            if(adj==-1 || visited[adj]!=-1) continue;
            visited[adj] = visited[now]+1;
            que.push(make_pair(heuristic_func(adj, goal) + visited[adj], adj));
        }
    }
    cout << visited[goal] << endl;
    return 0;
}

Measured memory_bytes: 4640
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = 1000000007;

LL N,M,K,C;
LL a,b,c,d;
int main(){
    cin>>  a>>b>>c;

    cout<<a+b+c-max(a,max(b,c))<<endl;
    return 0;
}


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

int main(){
	int m;
	scanf(" %d", &m);
	for(int i=0; i<m; ++i){
		long st;
		int y, n;
		scanf(" %ld %d %d", &st, &y, &n);
		
		long max=0;
		
		for(int j=0; j<n; ++j){
			int k;
			double p;
			long t;
			scanf(" %d %lf %ld", &k, &p, &t);
			
			long tmp=st;
			
			if(k==1){ //単利
				for(int x=0; x<y; ++x){
					long b=floor((double)tmp*p);
					tmp+=b-t;			
				}
			}
			else{ //複利
				long risi=0;
				for(int x=0; x<y; ++x){
					long b=floor((double)tmp*p);
					risi+=b;
					tmp-=t;			
				}
				tmp+=risi;
			}
			
			if(tmp>max) max=tmp;
			//printf(" %ld\n", tmp);
		}
		
		printf("%ld\n", max);	
	}
}

Measured memory_bytes: 1216
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>


using namespace std;

int main(){
  int N; cin >> N;
  vector<vector<int>> to(N) ; vector<vector<int>> cost(N);
  
  for(int i = 1; i < N; i++){
  int a, b, w; cin >> a >> b >> w; a--; b--;
    to[a].push_back(b); cost[a].push_back(w);
    to[b].push_back(a); cost[b].push_back(w);}
  
  vector<int> ans(N,-1); queue<int> q;
  
  ans[0] = 0; q.push(0);
  
  while(!q.empty()){
    
    int v = q.front();
    q.pop();
   for(int i = 0; i < to[v].size(); i++){
    
      int s = to[v][i];
      int t = cost[v][i];
      if( ans[s] != -1){continue;}
      ans[s] = ( ans[v] + t ) % 2;
      q.push(s);}}
  
  for(int i = 0; i < N; i++){
    cout << ans[i] << endl;}
  
  return 0;
}
      
      
    

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


int par[100000];
int drank[100000];
int k;

int find(int x){
	if(par[x]==x){
		return x;
	}
	else{
		return par[x] = find(par[x]);
	}
}


void unite(int x,int y){
	x = find(x);
	y = find(y);
	if(x==y) return;
	if(drank[x]<drank[y]){
		par[x] = y;
		k--;
	}
	else{
		par[y] = x;
		k--;
		if(drank[x] == drank[y]) drank[x]++;
	}

}

bool same(int x,int y){
	return find(x) == find(y);
}

int main() {
    int N,M;
    cin >> N >> M;

    

    for(int i=0;i<N;i++){
    	par[i] = i;
    	drank[i] = 0;
    	k = N;
    }

    int x,y,z;
    for(int i=0;i<M;i++){
    	cin >> x >> y >> z;
    	unite(x,y);
    }

    cout << k << endl;



}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main()
{
  int n,k;
  int r,s,p;
  string t;
  cin >> n >> k;
  cin >> r >> s >> p;
  cin >> t;

  vector<char> c(n);
  for(int i=0;i<n;i++){
    if(t[i] == 'r') c[i] = 'p';
    else if(t[i] == 's') c[i] = 'r';
    else if(t[i] == 'p') c[i] = 's';
    if(i >= k){
      if(c[i] == c[i-k]){
        c[i] = 'n';
      }
    }
  }

  ll ans = 0;
  for(int i=0;i<n;i++){
    if(c[i] == 'r') ans += r;
    else if(c[i] == 's') ans += s;
    else if(c[i] == 'p') ans += p;
  }

  cout << ans << endl;

}

Measured memory_bytes: 3776
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=998244353;
const long double PI = acos(-1),eps=1.0e-14;

void solve(){
    long double a,b,c;
    cin>>a>>b>>c;
    cout<<(sqrt(a)+sqrt(b)+eps<sqrt(c)?"Yes":"No")<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3740
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define P pair<int, int>
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int a, b, m;
    cin >> a >> b >> m;
    vector<int>an(a);
    vector<int>bn(b);
    int amin, bmin;
    amin = 100010;
    bmin = 100010;
    for(int i = 0; i < a; i++){
        cin >> an.at(i);
        amin = min(amin, an.at(i));
    }
    for(int i = 0; i < b; i++){
        cin >> bn.at(i);
        bmin = min(bmin, bn.at(i));
    }
    vector<vector<int> >c(m, vector<int>(3));
    for(int i = 0; i < m; i++){
        for(int j = 0; j < 3; j++){
            cin >> c.at(i).at(j);
        }
    }
    int ans = amin + bmin;
    for(int i = 0; i < m; i++){
        ans = min(ans, an.at(c.at(i).at(0) - 1) + bn.at(c.at(i).at(1) - 1) - c.at(i).at(2));
    }
    cout << ans << endl;
    solve();
    return 0;
}



Measured memory_bytes: 6528
n=int(input())
ab=[list(map(int,input().split())) for i in range(n)]
cd=[list(map(int,input().split())) for i in range(n)]
cd.sort()
count=0
for i in range(n):
    c,d=cd[i]
    m=-1
    memo=-1
    for j in range(len(ab)):
        a,b=ab[j]
        if a<c and m<b<d:
            memo=j
            m=b
    if memo!=-1:
        ab.pop(memo)
        count+=1
print(count)
    

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, K;
    cin >> N >> K;
    cout << N - (N / K) * K << endl;
    return 0;
}

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

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  vector<ll> x(n);
  for(ll i=0;i<n;i++) {
    cin >> x[i];
  }
  ll ans=0;
  for(ll i=0;i<n-1;i++) {
    ans+=min(b,a*(x[i+1]-x[i]));
  }
  cout << ans << endl;
}

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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    int x,y;
    cin>>x>>y;
    int a=0,b=0,d1[7]={1,3,5,7,8,10,12},d2[4]={4,6,9,11},d3[1]={2};
    for(int i=0;i<7;i++){
        if(x==d1[i]){
            a=1;
        }
        if(y==d1[i]){
            b=1;
        }
    }
    for(int i=0;i<4;i++){
        if(x==d2[i]){
            a=2;
        }
        if(y==d2[i]){
            b=2;
        }
    }
    if(x==2){
        a=3;
    }
    if(y==2){
        b=3;
    }
    if(a==b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
  let n:u32=read();
  let a:u32=read();
  let b:u32=read();
  let ans=(1..n+1)
                  .filter(|x|{let sum=x.to_string()
                    .chars()
                    .map(|c|(c as u8-b'0')as u32)
                    .sum::<u32>(); 
                    a<=sum&&sum<=b
                  })
                .sum::<u32>();
  println!("{}",ans);

}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main() {
int r,c,n,num[101][101]={},row[101]={},line[101]={};
cin>>r>>c;
for(int i=0;i<r;i++){
  for(int j=0;j<c;j++){
  cin>>n;
  num[i][j]=n;
  row[i]+=n;
  }
  num[i][c]=row[i];
}
for(int i=0;i<=c;i++){
  for(int j=0;j<r;j++){
  line[i]+=num[j][i];
  }
  num[r][i]=line[i];
}
for(int i=0;i<=r;i++){
  for(int j=0;j<=c;j++){
    if(j<c){ cout<<num[i][j]<<" ";
  }else{cout<<num[i][j]<<endl;}
  }
}
  return 0;
}

Measured memory_bytes: 1208
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

int a[5][5];

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	int n; cin >> n;
	set<int>s;
	for (int i = 0; i < n; i++) {
		int t; cin >> t; s.insert(t);
	}

	bool f = false;
	for (int i = 0; i < 3; i++) {
		bool ff = true;
		for (int j = 0; j < 3; j++) {
			if (!s.count(a[i][j])) ff = false;
		}
		if (ff) f = true;
	}
	for (int i = 0; i < 3; i++) {
		bool ff = true;
		for (int j = 0; j < 3; j++) {
			if (!s.count(a[j][i])) ff = false;
		}
		if (ff) f = true;
	}
	if (s.count(a[0][0]) && s.count(a[1][1]) && s.count(a[2][2])) f = true;
	if (s.count(a[0][2]) && s.count(a[1][1]) && s.count(a[2][0])) f = true;
	if (f) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}

	return 0;
}

/*


*/

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

int main(void){
    while(true){
        int n, kouho[55], stone;
        for(int i=0;i<55;++i) kouho[i] = 0;
        cin >> n >> stone;
        if(n==0 && stone==0) break;
        int i=0;
        while(true){
            i %= n;
            if(stone!=0){
                kouho[i] += 1;
                --stone;
                ++i;
                int cnt=0, ans=0;
                if(stone==0){
                    for(int j=0;j<n;++j){
                        if(kouho[j]==0) ++cnt;
                        else ans = j;
                    }
                    if(cnt==(n-1)){
                        cout << ans << endl;
                        break;
                    }
                }
            }else{
                stone += kouho[i];
                kouho[i] = 0;
                ++i;
            }
        }
    }
}


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

int main(){
	long long int x;
	cin>>x;
	int buf=0;
	if(x%11==0) buf=0;
	else if(x%11<=6) buf=1;
	else buf=2;

	cout<<2*(x/11)+buf<<endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool isP(string s) {
    int left = 0;
    int right = s.length() - 1;
    bool result = true;
    while (left <= right) {
        if (s[left] == s[right]) {
            left++;
            right--;
        } else {
            result = false;
            break;
        }
    }

    return result;
}
int main() {
    SS(string,s);
    bool ans =true;
    if(!isP(s))ans=false;
    if(!isP(s.substr(0,(s.length()-1)/2))) ans=false;
    debug(s.substr(0,(s.length()-1)/2));
    if(!isP(s.substr((s.length()+3)/2-1,s.length()-(s.length()+3)/2+1))) ans=false;
    debug(s.substr((s.length()+3)/2-1,s.length()-(s.length()+3)/2+1));
    Yes(ans);
}

Measured memory_bytes: 256
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 998244353;
const int maxn = 3e5 + 5;

ll fac[maxn], ifac[maxn];

ll C(ll n, ll m){return fac[n] * ifac[n - m] % INF * ifac[m] % INF;}
ll qpow(ll x, ll y){
	ll ret = 1;
	for(; y; y >>= 1){
		if(y & 1)
			(ret *= x) %= INF;
		(x *= x) %= INF;
	}
	return ret;
}

ll n, a, b, k, ans;

int main(){
	scanf("%lld%lld%lld%lld", &n, &a, &b, &k);
	fac[0] = 1;
	REP(i, 1, n)
		fac[i] = fac[i - 1] * i % INF;
	ifac[0] = 1;
	REP(i, 1, n)
		ifac[i] = qpow(fac[i], INF - 2);
	for(ll i = 0; i <= n; ++i){
		ll j = (k - i * a) / b;
		if(i * a + j * b != k || j > n || j < 0)
			continue;
		(ans += C(n, i) * C(n, j) % INF) %= INF;
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 4992
ABC = list(map(int, input().split()))

ABC.sort()


miin = min(ABC)

ABC[0] -= miin
ABC[1] -= miin
ABC[2] -= miin

res=0


if ABC[1] %2 != 0:
        res+=1
        ABC[1] -= 1


res+= (ABC[1]/2) + (ABC[2] - ABC[1])


print(int(res))

Measured memory_bytes: 3064
n, k = map(int, input().split())
d = []
a = []
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int, input().split())))

tricked = [0] * n
for i in range(k):
    for j in range(d[i]):
        tricked[a[i][j]-1] = 1

print(n-sum(tricked))


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  int m4 = 0, m2 = 0, others = 0;
  int a;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a);
    if (a % 4 == 0) { ++m4; }
    else if (a % 2 == 0) { ++m2; }
    else { ++others; }
  }
  others += (m2 % 2);
  printf("%s\n", (others - m4) > 1 ? "No" : "Yes");
  return 0;
}


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

int main() {
    int c[3][3];
    for (int i=0;i<9;i++)
        cin>>c[i/3][i%3];
    int d[2]={c[0][1]-c[0][0],c[0][2]-c[0][1]};
    int f=1;
    for (int i=1;i<3;i++)
        for (int j=0;j<2;j++)
            f&=c[i][j+1]-c[i][j]==d[j];
    if (f)
        puts("Yes");
    else
        puts("No");
    return 0;
}

Measured memory_bytes: 256
/*
 KMP
 */

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;


#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define all(x) x.begin(),x.end()

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}

const ll MOD =998244353;
const ll hell=1000000007;
const int INF=1e15;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

const int N=3005;

ldb dp[301][301][301];int n;
ldb solve(int i,int j,int k)
{
    if(i==0&&j==0&&k==0)
    {
        return dp[i][j][k]=0;
    }
    if(dp[i][j][k]!= -1)
        return dp[i][j][k];
    dp[i][j][k]=0;ldb p1;
    if(i)
    {
        p1=(ldb)i/(i+j+k);
        p1=p1*(solve(i-1,j,k));
        dp[i][j][k]+=p1;
    }
    if(j)
    {
        p1=(ldb)j/(i+j+k);
        p1=p1*(solve(i+1,j-1,k));
        dp[i][j][k]+=p1;
    }
    if(k)
    {
        p1=(ldb)k/(i+j+k);
        p1=p1*(solve(i,j+1,k-1));
        dp[i][j][k]+=p1;
    }
    dp[i][j][k]+=(ldb)n/(i+j+k);
    return dp[i][j][k];
}


void solve()
{
    
    memset(dp,-1,sizeof(dp));
   // int n;
    cin>>n;
    int cnt[4]={0};int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        cnt[a[i]]++;
    }
    cout<<setprecision(15);
    cout<<solve(cnt[1],cnt[2],cnt[3])<<endl;
    
}


int32_t main()
{
    
    IOS;
   
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    int t;
    t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 426496
#include<stdio.h>
#define N 10


int main() {
    int ary[N];
    int i, j, temp;

    for(i=0; i<N; i++) {
        scanf("%d", &ary[i]);
    }

    for(i=0; i<N-1; i++) {
        for(j=0; j<N-i; j++) {
            if(ary[j] < ary[j+1]) {
               temp = ary[j];
               ary[j] = ary[j+1];
               ary[j+1] = temp;
            }
        }
    }

    printf("%d\n%d\n%d\n", ary[0], ary[1], ary[2]);

    return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
struct node
{
	long long d;
	int id;
	friend bool operator < (node a,node b){return a.d>b.d;}
}p[100010];
int n,siz[100010],ans[100010][2];
map<long long,int>mp;
vector<int>E[100010];
long long sum;
void dfs(int v,int dep)
{
	sum+=dep;
	for(auto u:E[v])dfs(u,dep+1);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%lld",&p[i].d),p[i].id=i;
	sort(p+1,p+1+n);
	for(int i=1;i<=n;++i)mp[p[i].d]=p[i].id,siz[i]=1;
	for(int i=1;i<n;++i)
	{
	//	printf("%lld %d\n",p[i].d,n-2*siz[p[i].id]);
		mp.erase(p[i].d);
		if(!mp.count(p[i].d-n+2*siz[p[i].id]))return printf("-1"),0;
		ans[i][0]=p[i].id,ans[i][1]=mp[p[i].d-n+2*siz[p[i].id]];
		siz[ans[i][1]]+=siz[ans[i][0]];
		E[ans[i][1]].emplace_back(ans[i][0]);
	}
	dfs(p[n].id,0);
	if(sum!=p[n].d)return printf("-1"),0;
	for(int i=1;i<n;++i)printf("%d %d\n",ans[i][0],ans[i][1]);
	return 0;
}


Measured memory_bytes: 14336
# import bisect
# # import heapq
# # from copy import deepcopy
# # from collections import deque
# # from collections import Counter
# # from itertools import accumulate
# # from itertools import permutations
# import numpy as np
# # import math

a,b,c = map(int, input().split())
# n = int(input())
# p = list(map(int, input().split()))

ans = 'No'

if c-a-b>0 and 4*a*b < (c-a-b)**2:
    ans = 'Yes'
    
print(ans)

Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

int main(){
  int H, W;
  cin >> H >> W;

  int p4 = (W / 2) * (H / 2);
  int p2 = (H % 2) * (W / 2) + (W % 2) * (H / 2);
  int p1 = 0;

  if((H % 2) == 1 && (W % 2) == 1){
    p1 = 1;
  }

  char G[100][100];
  int cs[30];
  int cnt = 0;

  REP(i, 0, H){
    REP(j, 0, W){
      cin >> G[i][j];
      // cout << G[i][j];
    }
    // cout << endl;
  }


  while(1){
    int piece = 0;
    char l = '.';
    REP(i, 0, H){
      REP(j, 0, W){
        if(l != G[i][j]){
          l = G[i][j];
          break;
        }
      }
      if(l != '.'){
        break;
      }
    }

    if(l == '.'){
      //all counted
      break;
    }

    REP(i, 0, H){
      REP(j, 0, W){
        if(G[i][j] == l){
          G[i][j] = '.';
          piece++;
        }
      }
    }
    cs[cnt] = piece;
    
    cnt++;
  }

  REP(i, 0, cnt){
    int tmp = cs[i] / 4;
    tmp = min(tmp, p4);
    p4 -= tmp;
    cs[i] -= 4 * tmp;
    if(p4 == 0){
      break;
    }
  }

  REP(i, 0, cnt){
    int tmp = cs[i] / 2;
    p2 -= tmp;
    cs[i] -= 2 * tmp;
  }

  REP(i, 0, cnt){
    int tmp = cs[i];
    p1 -= cs[i];
    cs[i] -= tmp;
  }

  // cout << "p4:" << p4 << endl;
  // cout << "p2:" << p2 << endl;
  // cout << "p1:" << p1 << endl;

  if(p4 == 0 && p2 == 0 && p1 == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256