akhauriyash/Code-Regression huggingface dataset:
#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 fbo find_by_order
#define ook order_of_key
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define MOD 998244353
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 300003
#define pc(x) putchar_unlocked(x);
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;
bool ya[mx];
string ss;
int n,bit[mx],a[mx],kanan[mx];
vector<int>isi[30];
long long jaw=0;

int cari(int idx){
	int ret=0;
	for(;idx;idx-=idx&-idx)ret+=bit[idx];
	return ret;
}

void upd(int idx){
	for(;idx<=n;idx+=idx&-idx)bit[idx]++;
}

int main(){
	cin>>ss;
	n=ss.length();
	for(int i=0;i<n;i++){
		a[i]=ss[i]-'a';
	}	
	for(int i=0;i<n;i++){
		isi[a[i]].pb(i);
	}
	int cnt=0;
	for(int i=0;i<26;i++){
		if(isi[i].size()%2==1)cnt++;
	}
	if(cnt>=2){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=0;i<26;i++){
		int r=isi[i].size()-1;
		for(int j=0;j<isi[i].size();j++){
			if(j>r)break;
		//	debug(j);
		//	debug(r);
			if(j==r)ya[isi[i][j]]=true;
			kanan[isi[i][r]]=kanan[isi[i][j]]=isi[i][r];
			r--;
		}
	}
	int sim=-1;
	for(int i=0;i<n;i++){
		//if(ya[i])debug(i);
		if(ya[i]){
			sim=i;
			continue;
		}
		if(kanan[i]!=i)jaw=jaw+cari(kanan[i]);
	//	debug(jaw);
	//	cout<<"----\n";
		upd(kanan[i]+1);
	//	cout<<"////\n";
	}
	if(sim!=-1){
		for(int i=0;i<n;i++){
			if(i==sim)continue;
			if(kanan[i]==i)continue;
			if(i<sim && kanan[i]>sim)continue;
			jaw++;
		}
	}
	cout<<jaw<<endl;
}




Measured memory_bytes: 3452
import Data.Array

main = do
  li <- getLine
  let n = read li
  s <- getLine
  let ans = compute n s
  print ans

{-
'a'から'z'までの個数を数えておく
1文字左に移すたびに、左++右--して、両方>0な要素数を数えて最大値をとる
左はカウントアップする必要がなかった
-}

compute :: Int -> String -> Int
compute n s = maximum $ map comCnt $ scanl step (l0,r0) s
  where
    l0 = listArray ('a','z') $ replicate 26 False
    r0 = accumArray (+) 0 ('a','z') [ (c,1) | c <- s ]
    step (la,ra) c = (accum (||) la [(c,True)], accum (+) ra [(c,-1)])
    comCnt (la,ra) = length [ () | i <- ['a'..'z'], la ! i, ra ! i > 0 ]


Measured memory_bytes: 508
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 50;
int N;
int A[MAX_N], B[MAX_N];
bool S[MAX_N+1];
int G[MAX_N][MAX_N];

ll pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = pow(x*x, n/2);
  if (n & 1) res *= x;
  return res;
}

const int MAX_V = 51, INF = 1e9;
int V = MAX_V;
int d[MAX_V][MAX_V];

void warshall_floyd() {
  for (int k = 0; k < V; ++k) {
    for (int i = 0; i < V; ++i) {
     for (int j = 0; j < V; ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> A[i];
  for (int i = 0; i < N; ++i) cin >> B[i];

  for (int i = 1; i < 50; ++i) S[i] = true;

  for (int i = 49; i >= 0; --i) {

    // iより大きいtrueの数と、i以下の数でグラフを作る
    for (int i = 0; i <= 50; ++i) {
      for (int j = 0; j <= 50; ++j) {
        if (i != j) d[i][j] = INF;
      }
    }
    for (int i = 0; i <= 50; ++i) {
      for (int k = 1; k <= 49; ++k) {
        if (S[k]) { d[i][i%k] = 1; }
      }
    }

    // A[i]からB[i]にたどり着けるかどうか判定
    warshall_floyd();
    bool ok = true;
    for (int i = 0; i < N; ++i) {
      if (d[A[i]][B[i]] >= INF) ok = false;
    }

    // 全て書き換え可能ならS[i]をfalse、書き換え不可能ならS[i+1]をtrue。
    if (!ok) S[i+1] = true;
    S[i] = false;
  }

  if (S[50]) {
    cout << -1 << endl;
  } else {
    ll ans = 0;
    for (int k = 1; k < 50; ++k) if (S[k]) { ans += pow(2, k); }
    cout << ans << endl;
  }

  return 0;
}


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

void solve(long long N, long long K, std::vector<long long> x) {
    ll ans = 1e10;
    if (x[0] >= 0 && x[N - 1] >= 0) {
        cout << x[K - 1] << endl;
        return;
    }
    if (x[0] <= 0 && x[N - 1] <= 0) {
        cout << abs(x[N - K]) << endl;
        return;
    }
    for (ll i = 0; i <= N - K; i++) {
        ll left = x[i];
        ll right = x[i + K - 1];

        ll minabs = min(abs(left), abs(right));
        ll maxabs = max(abs(left), abs(right));
        ll tmpans = 2 * minabs + maxabs;
        ans = min(ans, tmpans);
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> x(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &x[i]);
    }
    solve(N, K, std::move(x));
    return 0;
}


Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
const int N = 100000+5;

int n, a, c[N], x, y, q;
long long sum;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a); c[a]++, sum += a;
    }
    scanf("%d", &q);
    while (q--) {
        scanf("%d%d", &x, &y);
        sum -= 1ll*x*c[x];
        sum += 1ll*y*c[x];
        c[y] += c[x];
        c[x] = 0;
        printf("%lld\n", sum);
    }
    return 0;
}


Measured memory_bytes: 4196
#include<cstdio>
char c;
int a[10];
int main()
{
	for(int i=0;i<3;i++)
	{
		scanf("%c",&c);
		a[c-'a']++;
	}
	if(a[0]==1&&a[1]==1&&a[2]==1)printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define P pair
#define X first
#define Y second
#define VSORT(v) sort(v.begin(), v.end())
#define VREV(v) reverse(v.begin(), v.end())
#define VMAX_P(v) max_element(v.begin(), v.end())
#define VMIN_P(v) min_element(v.begin(), v.end())
#define VMAX_IDX(v) distance(v.begin(), VMAX_P(v))
#define VMIN_IDX(v) distance(v.begin(), VMIN_P(v))
#define VCOPY(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define SUPPER(src, dst) transform(src.begin(), src.end(), dst.begin(), toupper);
#define SLOWER(src, dst) transform(src.begin(), src.end(), dst.begin(), tolower);

using namespace std;
using ll = long long;

void displayVec(vector<int> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    cout << endl;
}

int binarySearch(vector<int> v, int target)
{
    int left = -1;
    int right = v.size();

    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (v[mid] >= target)
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }

    if (right < v.size() && v[right] == target)
    {
        return right;
    }
    return -1;
}

void solve(int n, string s)
{
    if (n == 0)
    {
        cout << s << endl;
    }
    else
    {
        char c[3] = {'a', 'b', 'c'};
        for (int i = 0; i < 3; i++)
        {
            solve(n - 1, s + c[i]);
        }
    }
}

int main(int argc, const char *argv[])
{
    vector<int> v(3);
    for (int i = 0; i < 3; i++)
    {
        cin >> v[i];
    }
    VSORT(v);
    cout << v[0] + v[1] << endl;
}


Measured memory_bytes: 256
menu = [int(input()) for _ in range(5)]
mods = [food % 10 if food % 10 != 0 else 10 for food in menu ]
max_food = mods.index(min(mods))

times = 0

for i, food in enumerate(menu):
  if i == max_food or food % 10 == 0:
    times += food
  else:
    times += (food // 10 + 1) * 10
    
print(times)

Measured memory_bytes: 3060
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let x = get!();
    let mut ans = 1;
    let mut d = 0;
    for _ in 0 .. n {
        let l = get!();
        d += l;
        if d <= x {
            ans += 1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
def resolve():
    N,K,Q = list(map(int,input().split()))
    A = [input() for i in range(Q)]
    P = [K] * N

    def calc(n):
        return n-Q

    for i in range(Q):
        P[int(A[i])-1] += 1

    P = list(map(calc, P))

    for i in range(N):
        if P[i] <= 0:
            print("No")
        else:
            print("Yes")
resolve()

Measured memory_bytes: 62680
x1, x2, x3, x4, x5 = map(int, input().split())
if x1 == 0:
    print('1')
if x2 == 0:
    print('2')
if x3 == 0:
    print('3')
if x4 == 0:
    print('4')
if x5 == 0:
    print('5')


Measured memory_bytes: 9036
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define sz(x) ll(x.size())
using namespace std;

int main(){
  ll n,ans=0,cnt=1;
  cin>>n;
  vector<ll>a(n);
  rep(i,n){
  	cin>>a[i];
  	if(a[i]!=cnt)ans++;
  	else cnt++;
  }
  if(ans==n) ans=-1;
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min, Ordering,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::num::{NonZeroU32, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Index, IndexMut, Mul, MulAssign, Neg, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,
    SubAssign,
};
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, multinomial, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, Num, NumAssignOps, NumOps, One, Pow, Zero};
use permutohedron::Heap;
use proconio::{
    fastout, input, is_stdin_empty,
    marker::{Bytes, Chars, Isize1, Usize1},
};
use rand::random;

pub const MOD10E9_7: usize = 1000000007;
pub const MOD99_: usize = 998244353;
pub const MAX: usize = std::usize::MAX;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 65;

// code...
// #[fastout]
fn main() {
    input! {
        l: usize,
        r: usize,
        d: usize,
    }

    let mut c = 0;
    for i in l..=r {
        if i % d == 0 {
            c += 1;
        }
    }

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


Measured memory_bytes: 2136
A, B = map(int, input().split())
S = list(input())
x = len(S)
if len(S) != A + B + 1:
  print('No')
if S[A] == '-' :
  if S.count('-') == 1:
  
    print('Yes')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 9056
function main(input) {
    var inputs = input.split("\n");
    var tmp = inputs[1].split(" ");
    const kikan = parseInt(inputs[0].split(" ")[0], 10);
    let amari = 0;
    let ptmp = tmp.map(function (tmpitem) {
        return parseInt(tmpitem, 10);
    });
    ptmp.forEach(function (ikko) {
        amari = amari + ikko;
    });
    const kekka = kikan - amari;
    if (kekka < 0) {
        console.log(-1);
    } else {
        console.log(kekka);
    }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 33108
#include<iostream>
#include<cmath>

using namespace std;

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

int main() {
  int a, b, c;
  while (true) {
    cin >> a >> b >> c;
    if (a == 0 && b == 0 && c == 0) break;
    int res1 = 1000000000, res2 = 1000000000, resb = -1, resc = -1;
    for (int i = -b; i <= b + c / a; ++i) {
      if ((c - a * i) % b == 0) {
	int j = abs(i), k = abs((c - a * i) / b);
	if (res1 > j + k || (res1 == j + k && res2 > j * a + k * b)) {
	  res1 = j + k;
	  res2 = j * a + k * b;
	  resb = j;
	  resc = k;
	}
      } 
    }
    cout << resb << " " << resc << endl;
  }
  return 0;
}

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

ll n;
void solve(string s, char c) {
  if (s.size() == n) {
    cout << s << endl;
    return;
  }
  for (char i = 'a'; i <= c; i++) solve(s + i, (i == c ? c + 1 : c));
}

int main() {
  cin >> n;
  solve("", 'a');
  return 0;
}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

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

		long[] H = new long[N+1];
		for(int i=0; i<N; i++) {
			H[i] = sc.nextLong();
		}
		sc.close();

		boolean flag = true;

		for(int i=N-1; i>0; i--) {
			if(H[i]< H[i-1]) {
				if(H[i-1]-1 <= H[i]) {
					H[i-1]--;
				}else {
					flag = false;
					break;
				}
			}
		}
		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<lli, lli> pi;

lli fac[2002], inv[2002], mod = 1000000007;

lli bigmod(lli a, lli b, lli m)
{
    lli gg = a%m;
    lli ret = 1;
    while(b){
        if(b%2){
            ret = (ret*gg) % m;
        }
        gg = (gg*gg) % m;
        b/=2;
    }
    return ret;
}

lli ncr(lli n, lli r)
{
    if(r > n) return 0LL;
    lli ret;
    ret = (fac[n]*inv[r]) % mod;
    ret = (ret*inv[n-r]) % mod;
    return ret;
}

int main()
{
    fac[0] = 1;
    inv[0] = bigmod(1, mod-2, mod);
    for(lli i=1; i<=2001; i++){
        fac[i] = (i*fac[i-1]) % mod;
        inv[i] = bigmod(fac[i], mod-2, mod);
    }
    lli n, k;
    cin >> n >> k;
    lli x = n-k+1;
    for(lli i=1; i<=k; i++){
        if(i == 1LL){
            cout << ncr(x, i) << "\n";
        }
        else{
            cout << (ncr(k-1, i-1)*ncr(x, i))%mod << "\n";
        }
    }

    return 0;
}


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

using namespace std;

int main(){

  int N,b;
  long long int A[200000], Ai[200000], abs_sum = 0;

  cin >> N;

  for(int i = 0; i < N; i++){
    cin >> A[i];
    Ai[i] = A[i] - (i+1);
  }

  sort(Ai, Ai+N);

  if(N%2){
    b = Ai[N/2];
  }
  else{
    b = (Ai[N/2 - 1] + Ai[N/2]) / 2;
  }

  for(int i = 0; i < N; i++){
    abs_sum += abs(A[i] - (b + i + 1));
  }

  cout << abs_sum << "\n";
  
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
    int a, b;
    char op;
    while( cin >> a >> op >> b, op != '?' ){
        if( op == '+' ){
            cout << a+b << endl;
        }else if( op == '-' ){
            cout << a-b << endl;
        }else if( op == '*' ){
            cout << a*b << endl;
        }else{
            cout << a/b << endl;
        }
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n, y;
	cin >> n >> y;
	y /= 1000;
	rep(i, n+1) {
		rep(j, n - i+1) {
			int k = n - i - j;
			if (i * 10 + j * 5 + k * 1 == y) {
				cout << i <<" " << j << " " << k << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	vector<int> A(M);

	int num, tmp;
	for (int i = 0; i < N; i++) {

		cin >> num;

		for (int j = 0; j < num; j++) {

			cin >> tmp;
			A[tmp - 1]++;

		}
	}

	int ans = 0;
	for (const auto &elem : A) {

		if (elem == N) ans++;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d;cin>>n>>d;
  vector<vector<int>> x(n,vector<int>(d));
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      cin>>x[i][j];
    }
  }
  int count=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      int dis=0;
      for(int k=0;k<d;k++){
        dis+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      if(sqrt(dis)==(int)sqrt(dis))count++;
    }
  }
  cout<<count<<endl;
}

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

//エイリアス
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};



int main(){
    Stream io;

    ll K;
    io.read(K);

    vector<int> v(K, 0);
    int ans = 1;
    int term = 7 % K;
    while(term && !v[term]){
        v[term] = 1;
        term = (term * 10 + 7) % K;
        ans++;
    }
    if(!v[term]) cout << ans;
    else cout << -1;
    return 0;
}


Measured memory_bytes: 7152
S = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]
H = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]
C = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]
D = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]
gets.to_i.times do
  a = gets.split
  case a[0]
  when "S"
    S.delete(a[1])
  when "H"
    H.delete(a[1])
  when "C"
    C.delete(a[1])
  when "D"
    D.delete(a[1])
  end
end
S.length.times do |i|
  puts "S #{S[i]}"
end
H.length.times do |i|
  puts "H #{H[i]}"
end
C.length.times do |i|
  puts "C #{C[i]}"
end
D.length.times do |i|
  puts "D #{D[i]}"
end

Measured memory_bytes: 8624
l=[input() for _ in range(5)]
i=0
m=9
for s in l:
    s=int(s[-1])
    if s==0:
        i+=1
        continue
    m=min(m,s)
a=0
for s in l:
    a+=(int(s)+9)//10*10
print(a if i==len(l) else a-10+m)


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

int main(){
    long long n;
    cin >> n;
    long long a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    map<int,int> mp;
    for(int i=0;i<n;i++) mp[a[i]]++;
    int ans=0;
    for(auto p:mp){
        int b=p.first;
        int c=p.second;
        if(c<b) ans+=c;
        else ans+=c-b;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5504
/*
author:Manson
date:7.7.2018
theme:
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1005;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	int a,b,c;
	a = n/100;
	b = n/10%10;
	c = n%10;
	if(a == 9){
		a = 1;
	}else if(a == 1){
		a = 9;
	}
	if(b == 9){
		b = 1;
	}
	else if(b == 1){
		b = 9;
	}
	if(c == 9){
		c = 1;
	}
	else if(c == 1){
		c = 9;
	}
	cout<<100*a+10*b+c<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
long long ans;
int n,k,x,y;
int main(){
	scanf("%d%d",&n,&k);
	if(k&1){
		x=n/k;
		ans=1ll*x*x*x;
	}else{
		y=n/k;x=n/(k/2)-y;
		ans=1ll*x*x*x+1ll*y*y*y;
	}
	std::cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

n,m,x = MI()
a = []
c = []
for i in range(n):
  dd = LI()
  c.append(dd[0])
  dd = dd[1:]
  a.append(dd)


INF = 1e14
ans = INF
for iters in range(1,n+1):
  xx = list(itertools.combinations(range(n), iters))
  for u in xx:
    bad = False
    score = [0] * m
    money = 0
    for i in u:
      money += c[i]
      for j in range(m):
        score[j] += a[i][j]

    for j in range(m):
      if score[j] < x:
        bad = True
        break
    # print(u, money, score)
    if not bad:
      ans = min(money, ans)

  # if ans < INF:
  #   break
    
if ans == INF:
  print(-1)
else:
  print(ans)

    

Measured memory_bytes: 10360
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int min = Integer.MAX_VALUE;
		int max = 0;
		for(int i = 0; i < n; i++){
		    int a = sc.nextInt();
		    min = min(min, a);
		    max = max(max, a);
		}
		
		// 計算
		int result = max - min;
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 22740
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back   
#define sz(a) ((int)a.size())
using namespace std;
typedef long long ll ; 
const ll inf = 1e18 ;
const int mod = 1e9 + 7;
const int N = 3e5 + 5; 
const int SZ = 101;
ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
typedef pair<int , int> pii;

int a[(1 << 18) + 5];


void get_better(pair<pii, pii>& p , pair<pii , pii> add){
    if(p.ff > add.ff){
        if(p.ss < add.ff)
            p.ss = add.ff;
    }else if(p.ff < add.ff){
        if(p.ff < add.ss){
            p = add;
        }else{
            p.ss = p.ff ;
            p.ff = add.ff;
        }
    }else{
        if(p.ss < add.ss){
            p.ss = add.ss; 
        }
    }
}

void solve(){
    int n ;
    cin >> n ;
    for(int i = 0 ; i < (1 << n) ; ++i) cin >> a[i];
    pair<pii , pii> dp[1 << n] = {} ;
    for(int i = 0 ; i < (1 << n) ; ++i){
        get_better(dp[i] , {{a[i] , i} , {-1 , -1}});
        for(int b = 0 ; b < n ; ++b){
            if(i >> b & 1) continue ;
            get_better(dp[i | (1 << b)] , dp[i]);
        }
    }
    int ans = 0 ;
    for(int i = 0; i < (1 << n) ; ++i){
        // print(dp[i]);
        ans = max(ans , dp[i].ff.ff + dp[i].ss.ff);
        if(i) cout << ans << '\n';
    }
}

int main()
{
    ios::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL);
    int TC = 1, t = 0;
    // cin >> TC ;
    while(t++ < TC)
    {
        // cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 8684
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int A,B,m,i,ans=mod,sa=mod,sb=mod;cin>>A>>B>>m;
	vector<int>a(A);for(i=0;i<A;i++){cin>>a[i];chmin(sa,a[i]);}
	vector<int>b(B);for(i=0;i<B;i++){cin>>b[i];chmin(sb,b[i]);}
	ans=sa+sb;
	for(i=0;i<m;i++){
		int x,y,z;cin>>x>>y>>z;x--;y--;
		chmin(ans,a[x]+b[y]-z);
	}
	cout<<ans<<endl;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a > b && a > c){ 
    swap(a,c);
    if(a > b) swap(a,b);
  }
  if (b > c && b > a) {
    swap(b,c);
    if(a > b) swap(a,b);
  }
  if (a > c && c > b) {
    swap(c,a);
    if(a > b) swap(a,b);
  }
  cout << a << " " << b << " " << c << endl;
  return 0;
}
  


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

public class Main {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		
		/*
		* input temple
		int n = sc.nextInt();
		String s = sc.next();
		char[] l = sc.next().toCharArray();
		*/
		String ans = "Yes";

		int N = sc.nextInt();
		int a = 0;
		int b = 0;
		int now = 0;
		for (int i = 0; i < N; i++) {
			int target = sc.nextInt();
			int subTurn = target - now;
			
			int nextA = sc.nextInt();
			int nextB = sc.nextInt();
			int distance = Math.abs(nextA-a) + Math.abs(nextB-b);
			
			int rest = subTurn - distance;
			
			if (rest<0) {
				ans = "No";
				break;
			}else if (rest>0) {
				if (distance%2==0 && subTurn%2==1) {
					ans = "No";
					break;
				}
				if (distance%2==1 && subTurn%2==0) {
					ans = "No";
					break;
				}
			}
			a = nextA;
			b = nextB;
			now = target;
		}

		out.println(ans);
		out.close();
	}

	//-----------http://codeforces.com/blog/entry/7018---------------------------------
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	//--------------------------------------------------------

}



Measured memory_bytes: 39328
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;
using Graph = vector<vector<int>>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

vector<bool> seen;

void dfs(const Graph& G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int abs_B(long long num, long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

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

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

bool permutation(vector<int>& vec, vector<int>& P) {
    bool ok = true;
    for (int i = 0; i < vec.size(); i++) {
        //cout << vec.at(i);
        if (vec.at(i) != P.at(i)) {
            ok = false;
        }
    }
    return ok;
}

/*bool nibu(vector<int>& retu,int key) {

}*/

const long long MOD = 1000000007;
const int INF = 1001001001;

int main() {
    vector<int> retu(3);
    cin >> retu.at(0) >> retu.at(1) >> retu.at(2);
    sort(retu.begin(), retu.end());
    cout << retu.at(0) << " " << retu.at(1) << " " << retu.at(2) << endl;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define int long long
#define fr first
#define sc second

using namespace std;

signed main()
{
    string s;
    cin >> s;
    int k;
    cin >> k;
    int n = s.size();
    if(n == 1){
        cout << k/2;
        return 0;
    }
    int z = 0, w = 0;
    vector<pair<int, int> > block;
    int cnt = 1;
    for(int i = 1; i < s.size(); i++){
        if(s[i] == s[i-1]){
            cnt++;
        }
        else{
            block.push_back({i-cnt, i-1});
            cnt = 1;
        }
    }
    block.push_back({n-cnt, n-1});
    for(int i = 0; i < block.size(); i++){
        if((block[i].sc - block[i].fr + 1) & 1){
            for(int j = block[i].fr+1; j < block[i].sc; j+=2){
                z++;
            }
        }
        else{
            for(int j = block[i].fr; j < block[i].sc; j+=2){
                z++;
            }
        }
    }
    if(block.size() == 1){
        cout << (k * n) / 2;
        return 0;
    }
    else{
        if(s[0] == s[s.size()-1] && ((block[0].sc - block[0].fr + 1) & 1) && ((block.back().sc - block.back().fr + 1) & 1) ){
            w = 1;
        }
    }
    int ans = z * k;
    ans += w * (k-1);
    cout << ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>
using namespace std;
typedef long long ll;

bool isprime(int n) {
    if (n < 2) return false;
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    for (int i=3; i*i<=n; i+=2) {
        if (n % i == 0 && n != i) {
            return false;
        }
    }
    return true;
}

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

    int N;
    cin >> N;
    unordered_map<int,int> checked;
    int m, ans = 0;
    for (int i=0; i<N; ++i) {
        cin >> m;
        if (isprime(m) && ! checked[m]) {
            ++ ans;
            checked[m] = 1;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <vector>

using namespace std;

const int kInf = 1e9;

void Solve() {
	int n;
	cin >> n;
	vector<int> a(n+1);

	int max_cnt = 0, min_cnt = 0;
	int maxv = 0;

	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		maxv = max(maxv, a[i]);
	}

	for (int i = 1; i <= n; ++i) {
		if (maxv == a[i]) {
			++max_cnt;
		} else {
			if (maxv - 1 != a[i]) {
				cout << "No\n";
				return;
			}
			++min_cnt;
		}
	}

	if (maxv == n-1 && max_cnt == n) {
		cout << "Yes\n";
		return;
	}

	if (!(min_cnt + 1 <= maxv && maxv <= n-1 && 2 * (maxv - min_cnt) <= max_cnt)) {
		cout << "No\n";
		return;
	}

	if (max_cnt == 1) {
		cout << "No\n";
		return;
	}

	cout << "Yes\n";
}

int main() {
	int tests = 1;
	for (;tests; --tests) {
		Solve();
	}
}

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

using namespace std;
void func()
{
	int A,B;
	cin >> A >>B;

	int minB,maxB;
	minB = B * 10;
	maxB = (B+1) * 10;

	for(int i= minB; i< maxB; i++)
	{
		if ((int)(i * 0.08) == A)
		{
			cout << i << endl;
			return;
		}
	}
	cout << "-1\n";	
}

int main() {
//	while(1)
	func();
	return 0;
}


Measured memory_bytes: 3164
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Node[] nodes = new Node[N];
        for(int i = 0; i < N; i++){
            nodes[i] = new Node(i);
        }
        
        for(int i = 0; i < N - 1; i++){
            int v1 = sc.nextInt() - 1;
            int v2 = sc.nextInt() - 1;
            int w  = sc.nextInt();
            
            nodes[v1].adjacents.put(nodes[v2], w);
            nodes[v2].adjacents.put(nodes[v1], w);
        }
        
        bfs(nodes[0]);
        
        for(Node n : nodes){
            System.out.println(n.color);
        }

    }
    
    public static void bfs(Node n0){
        
        Queue<Node> queue = new LinkedList<>();
        
        n0.color = 0;
        queue.add(n0);
        
        while(!queue.isEmpty()){
            
            Node n = queue.poll();
            
            for( Node na : n.adjacents.keySet() ){
                if( na.color != -1 ) continue;
                
                int na_kyori = n.adjacents.get(na);
                if ( na_kyori % 2 == 0 ){
                    na.color = n.color % 2;
                } else {
                    na.color = (n.color + 1) % 2;
                }
                
                queue.add(na);
                
            }
        }
    }
    
    static class Node{
        int id;
        // 白 : 0、 黒 : 1
        int color = -1;
        Map<Node, Integer> adjacents = new HashMap<>();
        
        public Node(int id){
            this.id = id;
        }
    }
}


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

int main(){
    int H, W;
    cin >> H >> W;
    while((H!=0)||(W!=0)){
        for(int i=0; i<W; i++) cout << "#";
        cout << endl;
        for(int i=0; i<H-2; i++){
            cout << "#";
            for(int j=0; j<W-2; j++){
                cout << ".";
            }
            cout << "#" << endl;
        }
        for(int i=0; i<W; i++) cout << "#";
        cout << endl;
        cout << endl;
        cin >> H >> W;
    }
    return 0;
}


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

int main() {
	int n;
	int count = 0;
	cin >> n;

	for (int i = 0; i <= 3; i++) {
		if (n % 10 == 2) {
			count++;
		}
		n /= 10;
	}

	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353 
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        int x,y;
        cin>>x>>y;
        if(y%2==0&&y>=2*x&&y<=4*x)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3640
def main():
    N = int(input())
    A = list(map(int,input().split()))

    ans = 0
    for i in range(N-1):
        if A[i] <= A[i+1]:
            continue
        else:
            diff = A[i] - A[i+1]
            ans += diff
            A[i+1] = A[i]
    
    print(ans)
    
if __name__ == "__main__":
    main()

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

int main()
{
    int a,b;

    scanf("%d", &a);
    scanf("%d", &b);
    if (a>b)
        printf("a > b\n");
    else if (a<b)
        printf("a < b\n");
    else
        printf("a == b\n");
    return 0;
}

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

#define f first
#define s second
#define ins insert
#define pb push_back
#define endl '\n'
#define ll long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int,int>
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
#define tc ll t; cin >> t; while (t--)
#define sz(c) (int) (c).size()
#define trav(x,c) for (auto &x : c)
#define all(c) (c).begin(), (c).end()
#define rll(c) (c).rbegin(), (c).rend()
#define db(x) cout << #x << ": " << x << endl;
#define _db(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios_base::sync_with_stdio(0); cin.tie(0);

int main() { 
	godspeed;
	
	int n, sum = 0; cin >> n;
	int k; cin >> k;

	vi v(n);
	for (int i = 0 ; i < n ; ++i) cin >> v[i];
	sort(all(v));
	
	for (int i = 0 ; i < k ; ++i) {sum += v[i];}

	cout << sum;
}

Measured memory_bytes: 3656
/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-11-3 11:47:21
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  int A, B;
  cin >> A >> B;
  cout << max(max(A + B, A - B), A * B) << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

//決め打ち二分探索
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;

    vector<ll> a(n);
    for(ll i=0; i<n; i++) {
    	cin>>a[i];
    }
    vector<ll> f(n);
    for(ll i=0; i<n; i++) {
        cin>>f[i];
    }
    sort(a.begin(), a.end(), greater<ll>());
    sort(f.begin(), f.end());

    ll left = -1;
    ll right = 1000000000001;

    auto ok = [&](ll x) {
        bool fit = false;
        ll cnt = 0;
        for (ll i = 0; i < n; i++) {
            if(a[i] * f[i] > x) {
                cnt += a[i] - (x / f[i]);
            }
        }
        if(cnt <= k) {
            fit = true;
        }
        return fit;
    };

    while (right - left > 1) {
        ll mid = (left + right) / 2;
        if (!ok(mid)) {
            left = mid;
        } else {
            right = mid;
        }
//        dbg(mid);
    }

    cout << right << endl;
    return  0;
}


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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n-1; i >= 0; i--)
#define FOR(i, n, m) for(int i = n; i < (int)(m); i++)
#define PRINT(x) cout << x << endl

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

ll MOD = 1000000007;


int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    vector<ll> B(N*2);
    REP(i, N) {
        B[i] = A[i];
        B[N+i] = A[i];
    }
    ll cnt1 = 0;
    REP(i, N) {
        FOR(j, i+1, N) {
            if (A[i] > A[j]) cnt1++;
        }
    }
    ll cnt2 = 0;
    REP(i, N*2) {
        FOR(j, i+1, N*2) {
            if (B[i] > B[j]) cnt2++;
        }
    }
    ll t = cnt2 - cnt1 * 2;

    ll ans = cnt1 * K;
    ans %= MOD;
    ll tmp = (K-1)*K;
    tmp /= 2;
    tmp %= MOD;
    tmp *= t;
    tmp %= MOD;
    ans += tmp;
    ans %= MOD;
    PRINT(ans);
    return 0;
}


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

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

    cin>>s;
    a=0;
    for(int i=0;i<3;){
        if(s[i]=='R'){
            while(s[i]=='R'){sum++;i++;a=max(sum,a);}
        }
        else{
            i++;
            sum=0;
        }
    }


    cout<<a<<endl;



    return 0;
}



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

using namespace std;

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

    size_t n;
    cin >> n;
    vector<int> a1, a2;
    for (size_t i = 0; i < n; ++i) {
        int a;
        cin >> a;
        a1.push_back(a);
    }
    for (size_t i = 0; i < n; ++i) {
        int a;
        cin >> a;
        a2.push_back(a);
    }

    vector<int> r1(n), r2(n), r3(n);
    partial_sum(cbegin(a1), cend(a1), begin(r1));
    partial_sum(crbegin(a2), crend(a2), rbegin(r2));
    transform(cbegin(r1), cend(r1), cbegin(r2), begin(r3), plus<int>());
    cout << *max_element(cbegin(r3), cend(r3)) << endl;

    return 0;
}


Measured memory_bytes: 256
//1:18
#include <stdio.h>
#include <string.h>
#include <algorithm>

typedef long long ll;
ll max(ll a, ll b){return(a>b)?a:b;}
ll min(ll a, ll b){return(a<b)?a:b;}
ll abs(ll a){return(a<0)?-a:a;}

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

ll a[2*100000];
int main(){
        int N;
        scanf("%d",&N);

        ll totalsum = 0;
        for(int i = 0; i < N; i ++){
                scanf("%lld",a+i);
                totalsum += a[i];
        }

        ll sum = 0;
        ll minab = 4000000000LL*100000LL+1LL;
        for(int i = 0; i < N-1; i ++){
                sum += a[i];
                if(minab > abs(2*sum-totalsum)){
                        minab = abs(2*sum-totalsum);
                }
        }
        printf("%lld\n",minab);

}

Measured memory_bytes: 1664
#include <stdbool.h>
#include <stdio.h>
int h[100000], l[100000][2];
bool isHigher[100000];
int main() {
	int n, m, cnt = 0;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
		isHigher[i] = true;
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < 2; j++) {
			scanf("%d", &l[i][j]);
		}
		if (h[l[i][0] - 1] < h[l[i][1] - 1]) {
			isHigher[l[i][0] - 1] = false;
		} else if (h[l[i][0] - 1] > h[l[i][1] - 1]) {
			isHigher[l[i][1] - 1] = false;
		} else {
			isHigher[l[i][0] - 1] = isHigher[l[i][1] - 1] = false;
		}
	}
	for (int i = 0; i < n; i++) {
		if (isHigher[i]) {
			cnt++;
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 2956
//A Point in a Triangle

#include <iostream>
using namespace std;

int main() {
	double x1, y1, x2, y2, x3, y3, xp, yp;
	double a, b, c;
	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
		int flag = false;
		a = (x2 - x1)*(yp - y2) - (y2 - y1)*(xp - x2);
		b = (x3 - x2)*(yp - y3) - (y3 - y2)*(xp - x3);
		c = (x1 - x3)*(yp - y1) - (y1 - y3)*(xp - x1);
		//cout << "a:" << a << endl;
		//cout << "b:" << b << endl;
		//cout << "c:" << c << endl;
		
		if(a > 0 && b > 0 && c > 0) {
			flag = true;
		}
		else if(a < 0 && b < 0 && c < 0) {
			flag = true;
		}
		
		if(flag == true) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#include<iostream>
#include<queue>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <functional>
//#define vector<int> ans;
using namespace std;

int main() {
  int n,so=0,st=0;
  cin>>n;
  vector<int> A(n);
  vector<int> ans;
  for(int i=0;i<n;i++) {
    cin>>A[i];
  }
  for(int t=0;t<n;t++){
    so=0;
    st=0;
    for(int i=0;i<t;i++){
      so+=A[i];
    }
    for(int i=t;i<n;i++){
      st+=A[i];
    }
    ans.push_back(max(so,st)-min(so,st));
    //cout<<so<<" "<<st<<" "<<max(so,st)-min(so,st)<<endl;
  }
  sort(ans.begin(), ans.end());
  //for(int i=0;i<n;i++) cout<<ans[i]<<" ";
  cout<<ans[0]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>

using namespace std;

int main(){
	int N;
	cin >> N;
	set<int> S;
	for(int i = 0; i < N; i++){
		int x;
		cin >> x;
		S.insert(x);
	}
	cout << S.size() << "\n";
}


Measured memory_bytes: 256