akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ちゃんとユニークな配列にする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int main() {
  int N;
  cin >> N;
  vector<int> C; // iは実際のiより1小さい
  vector<int> S;
  vector<int> F;
  rep(i, (N - 1)) {
    int ci, si, fi;
    cin >> ci >> si >> fi;
    C.pb(ci);
    S.pb(si);
    F.pb(fi);
  }

  // 500個ぐらいだし貪欲法
  rep(i, N) {
    int currentPos = i;
    int t = 0;
    while(currentPos < (N - 1)) {
      // DEBUG(currentPos);
      // DEBUG(t);
      if(S[currentPos] <= t 
         && (t % F[currentPos]) == 0)  {
        t = t + C[currentPos];
        currentPos++;
      } else {
        t++;
      }
    }
    cout << t << endl;
  }
}


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

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  
  int ans;
  if (A == B) ans = C;
  else if (B == C) ans = A;
  else ans = B;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn chmin<T>(x: &mut T, y: T) -> bool
where
    T: PartialOrd + Copy,
{
    *x > y && {
        *x = y;
        true
    }
}

#[allow(dead_code)]
fn chmax<T>(x: &mut T, y: T) -> bool
where
    T: PartialOrd + Copy,
{
    *x < y && {
        *x = y;
        true
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input!(n: usize, d: usize, xs: [[i64; d]; n]);

    let mut ans = 0;
    for i in 0..n {
        for j in i + 1..n {
            let mut x = 0;
            for k in 0..d {
                x += (xs[i][k] - xs[j][k]).pow(2);
            }
            let sq = (x as f64).sqrt().floor();
            if sq * sq == x as f64 {
                ans += 1;
            }
        }
    }

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


Measured memory_bytes: 4352
import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

# 約数の全列挙
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort(reverse=True)  # ソート
    return divisors

def sol():
    N = int(input())

    divs = divisors(N)
    ans = INF
    for d in divs:
        M = N // d
        ans = min(ans, M - 1 + d - 1)

    print(ans)

sol()

Measured memory_bytes: 3592
import Control.Monad
import qualified Data.Map as M
main = do
    [h, w] <- map read . words <$> getLine 
    (gridMap, whites) <- toMap h w <$> replicateM h getLine
    let l = bfs h w gridMap [((1, 1), 1)]
    print $ if l == -1 then -1 else whites - l

bfs _ _ _ [] = -1 
bfs h w g (((i,j),l):q) | (i, j) == (h, w) = l
                        | g M.! (i,j) == '#' = bfs h w g q
                        | otherwise = bfs h w (M.insert (i, j) '#' g) (q ++ neighbors)
    where neighbors = map (\p -> (p, l+1)) [(i-1, j), (i+1, j), (i, j-1), (i, j+1)]

toMap h w xss = toMap' h w 1 1 xss
  where
    toMap' h w _ _ [] = (M.fromList [((i,j),'#')|i<-[0..h+1],j<-[0..w+1],i==0||i==h+1||j==0||j==w+1], 0)
    toMap' h w i j ([]:xss) = toMap' h w (i+1) 1 xss
    toMap' h w i j ((x:xs):xss) = (M.insert (i,j) x map', if x == '.' then ws+1 else ws)
        where (map', ws) = toMap' h w i (j+1) (xs:xss)

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

int main(){
	int N, A, B, i;
	scanf("%d%d%d", &N, &A, &B);
	string S;
	cin >> S;
	int a = 0, b = 0;
	for(i = 0; i < N; i++){
		if(S[i] == 'a'){
			if(a + b < A + B){
				printf("Yes\n");
				a++;
			}
			else{
				printf("No\n");
			}
		}
		else if(S[i] == 'b'){
			if(a + b < A + B && b < B){
				printf("Yes\n");
				b++;
			}
			else{
				printf("No\n");
			}
		}
		else{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int countNum[26];
int main () {
	string s;
	cin >> s;
	for (int i = 0; i < (int)s.size(); ++i)
	{
		countNum[s[i] - 'a']++;
	}
	int num = -1;
	for (int i = 0; i < 26; ++i)
	{
		if(countNum[i] == 0){
			num = i;
			break;
		}
	}
	if(num == -1){
		cout << "None" << endl;
	}else{
		cout << (char)('a' + num) << endl;
	}
}

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	int n;cin>>n;
	n*=(1+n+n*n);
	db(n);
	
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



Measured memory_bytes: 3592
#include <cstdio>
int main() {
	int N,M,P;
	while(scanf("%d %d %d",&N,&M,&P),N) {
		int sum=0,size=0;
		for(int i=0;i<N;i++) {
			int X;
			scanf("%d",&X);
			sum+=X;
			if(i==M-1) size=X;
		}
		sum*=100-P;
		if(size==0) {
			printf("0\n");
		}else {
			printf("%d\n",sum/size);
		}
	}
}

Measured memory_bytes: 1040
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n, x; cin >> n >> x;
    vector<ll> l(n);
    REP(i, n) cin >> l[i];

    ll d = 0, ans = 1;
    REP(i, n) {
        d += l[i];
        if (d <= x) ans++;
    }
    cout << ans << endl;
    
}

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

using namespace std;

struct UnionFind{

vector<int> d;

UnionFind(int n=0) : d(n,-1){};

int find(int x){
  if(d[x]<0) return x;
  return d[x] = find(d[x]);
}
bool unite(int x,int y){
  x = find(x);y = find(y);
  if(x == y) return false;
  if (d[x] > d[y] ) swap(x,y);
  d[x] += d[y];
  d[y] = x;
  return true;
}
bool same(int x,int y){return find(x) == find(y);}
int size(int x){ return -d[find(x)];}

};

int main(){
  
  int n,m; cin >> n >> m;
  vector<int> a(m),b(m);

  
  for (int i = 0; i < m; ++i)
   {
     cin >> a[i] >> b[i];
     a[i]--;b[i]--;
   } 

 vector<long long> cnt(m);
 UnionFind uf(n);
 cnt[m-1] = (long long)n*(n-1)/2;
 for (int i = m-1; i > 0; i--)
 {
   if (uf.same(a[i],b[i]))
   {
     cnt[i-1] = cnt[i];
     continue;
   }
    cnt[i-1] =cnt[i]-1ll*(long long)uf.size(a[i]) * (long long)uf.size(b[i]);
    uf.unite(a[i],b[i]);
   
 }

for (int i = 0; i <= m-1; ++i)
{
  cout << cnt[i] << "\n";
}
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;

#define sz(s) (int)(s.size())
#define eb emplace_back

const int N = 2e5 + 5;
const int sZ = (1 << 19);

#define ll long long

void solve() {
	char c;
	cin >> c;
	cout << char(c + 1);
}

int main () {
	cerr << "Ready\n";
	solve();
	return 0;
}


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

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

int main() {
    int k;
    scanf("%d",&k);
    int res = 0;
    for(int i=1;i<=k;i++) {
        for(int j=1;j<=k;j++) {
            for(int l=1;l<=k;l++) {
                res += gcd(gcd(i,j),l);
            }
        }
    }
    printf("%d\n", res);
}


Measured memory_bytes: 3760
from math import gcd


def eratosthenes(n):
    is_prime = [0, 0] + [1] * (n - 1)
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i] == 1:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = 0
    return [i for i in range(n + 1) if is_prime[i] == 1]


def factorize(N):  # 素因数分解
    PRIME = set()
    for p in prime_list:
        if p * p > N:
            break
        while N % p == 0:
            N //= p
            PRIME.add(p)
    if N > 1:
        PRIME.add(N)
    return PRIME


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

ans = 0
for ai in a:
    ans = gcd(ans, ai)
if ans != 1:
    print('not coprime')
    exit()

prime_list = eratosthenes(10 ** 6)
num = set()
for ai in a:
    prime = factorize(ai)
    if len(prime & num) > 0:
        print('setwise coprime')
        break
    num |= prime
else:
    print('pairwise coprime')


Measured memory_bytes: 196572
import sys
input = sys.stdin.readline

def solve():
  n,m = (int(i) for i in input().split())
  query = []
  for i in range(m):
      a = list(int(i) for i in input().split())
      query.append(a)
  p = list(int(i) for i in input().split())
  #print(query)
  
  A = []
  for i in range(n):
    A.append(i+1)
    
  ans = 0
  #探索
  for i in range(1 << n):
    flag = 1
    output = []
    for j in range(n):
     if ((i >> j) & 1) == 1:
       output.append(A[j])

    for s in range(m): 
     if len(query)==0: 
      if not p[s] == 0:
        flag = 0
        break
     a = query[s]
     times = a[0]
     thischeck = 0
     for k in range(times):
       checker = a[k+1]

       if checker in output:
        thischeck += 1
       else:
        thischeck += 0
     if p[s] == thischeck%2:
       pass
     else:
       flag = 0
       break
  
    if flag:
      
      ans += 1
    else:
      pass
  print(ans)
solve()

Measured memory_bytes: 3064
program ABC148A
    implicit none
    integer(8)::A,B,i
    integer(8),dimension(3)::L
    read(5,*)A,B
    L=0
    L(A)=1
    L(B)=1
    do i=1,3
        if(L(i)==0)then
            print'(i0)',i
        end if
    end do

end program ABC148A

Measured memory_bytes: 640
//I Guds namn
#include <deque>
#include <iostream>
#include <stack>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n; cin >> n;
	string s; cin >> s;
	int sum = 0;
	deque<char> ans;
	for(int i = 0;i < n;i++)
	{
		ans.push_back(s[i]);
		sum += (s[i] == '(' ? 1 : -1);
		if(sum < 0)
		{
			ans.push_front('(');
			sum++;
		}
	}
	while(sum-- > 0)
		ans.push_back(')');
	for(auto &c : ans)
		cout << c;
	cout << endl;
	return 0;
}

Measured memory_bytes: 888
S = input()
ans = 1
now = S[0]
flag = False
for i in range(1, len(S)-1):
    if flag:
        flag = False
        continue
    if len(now) == 1:
        if S[i] == now:
            ans += 1
            now = S[i] + S[i+1]
            flag = True
        else:
            ans += 1
            now = S[i]
    else:
        ans += 1
        now = S[i]
if not flag and S[-1] != now:
    ans += 1
print(ans)

Measured memory_bytes: 3500
#include <iostream>

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

int main() {
    int n, k, x;
    int ans = 0;
    std::cin >> n >> k;
    rep(i, n) {
        std::cin >> x;
        if (k - x > x) {
            // type A
            ans += 2*x;
        } else {
            // type B
            ans += 2*(k - x);
        }
    }
    std::cout << ans << std::endl;
    return 0;
}



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

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

using namespace std;

int main() {
	DOUBLE ANS = 1000000000;
	SINT32 ANS2 = 0;
	SINT32 N = 0;
	DOUBLE T = 0;
	DOUBLE A = 0;
	cin >> N;
	cin >> T;
	cin >> A;
	
	for (SINT32 i = 0; i < N; i++) {
		DOUBLE BUF = 0;
		cin >> BUF;
		BUF = T -BUF*0.006;
		BUF = ABS(A-BUF);

		if (ANS > BUF) {
			ANS2 = i+1;
		}
		ANS = MIN(ANS,BUF);
	}

	cout << ANS2 << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000000000000
#define mod 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	int h, w, n;
	cin >> h >> w >> n;
	int ans[114][514], a[10656];
	rep(i, n) {
		cin >> a[i];
	}
	int now = 0;
	rep(i, h) {
		rep(j, w) {
			if (a[now] == 0) {
				now++;
			}
			if (i % 2 == 0) {
				a[now]--;
				ans[j][i] = now + 1;
			}
			else {
				a[now]--;
				ans[w - 1 - j][i] = now + 1;
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			cout << ans[j][i] << " ";
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 768
N, K, C = map(int, input().split())
S = input()

r = []
l = []
i = 0
while 1:
    if S[i] == "x":
        i += 1
        continue
    r.append(i)
    if len(r) >= K:
        break
    i += C + 1

i = N - 1
while 1:
    if S[i] == "x":
        i -= 1
        continue
    l.append(i)
    if len(l) >= K:
        break
    i -= (C + 1)
for a, b in zip(r, reversed(l)):
    if a == b:
        print(a + 1)

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

const int INF = 1000000000;
int n, k;

int si(vector <int> & pear, vector <int> & bery) {
    int out = INF;
    rep (i, pear.size()) if (0 <= k - i - 2 && k - i - 2 < bery.size()) {
        out = min(out, pear[i] * 2 + bery[k - i - 2]);
    }
    return out;
}

int sanai(vector <int> & va) {
    if (va.size() >= k) return va[k - 1];
    else return INF;
}

int main() {
    cin >> n >> k;
    vector <int> hu, se;
    rep (i, n) {
        int x;
        cin >> x;
        vector <int> & va = (x >= 0 ? se : hu);
        va.push_back(abs(x));
    }
    sort(hu.begin(), hu.end());

    cout << min({si(se, hu), si(hu, se), sanai(se), sanai(hu)}) << endl;
    return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mode        998244353
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323



void solve()
{
       ll x,y,z,k; cin>>x>>y>>z>>k;
       ll a[x], b[y], c[z];
       rep(i,0,x) cin>>a[i];
       rep(i,0,y) cin>>b[i];
       rep(i,0,z) cin>>c[i];
       priority_queue<ll>pq;
       rep(i,0,x) rep(j,0,y) pq.push(a[i]+b[j]);
       priority_queue<ll>res;
       ll cnt=0;
       while(cnt<k && !pq.empty())
       {
              ll tp=pq.top();
              pq.pop(); cnt++;
              rep(i,0,z) res.push(tp+c[i]);
       }
       cnt=0;
       while(cnt<k)
       {
              ll tp=res.top();
              res.pop();
              cnt++;
              cout<<tp<<endl;
       }
}


int main() {
	ll T = 1;
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


Measured memory_bytes: 42852
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int alice = 0;
        int bob = 0;
        for(int i = 0; i <= n-1; i++){
            if(i%2 == 0){
                alice = alice + a[n-1-i];
            } else {
                bob = bob + a[n-1-i];
            }
        }
        System.out.print(alice - bob);
    }
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    reverse(s.begin(), s.end());
    if(s==t) cout << "YES\n";
    else cout << "NO\n";

    return 0;
}


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

using ll = long long;

// 辺の情報
struct edge {
   ll to, cost;
};

const ll INF = 1e18;
ll N, M; // Nはノードの個数、Mは辺の個数
ll dist[1010]; // 最短距離
vector<edge> Graph[2010]; // グラフ

bool bellman() {
   // for (int i = 0; i < N; i++) {
   //    dist[i] = -INF;
   // }
   // dist[0] = 0;
   for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
         if (dist[i] == -INF) continue;
         for (edge e : Graph[i]) {
            if (dist[e.to] < dist[i] + e.cost) {
               dist[e.to] = dist[i] + e.cost;
               if (k == N-1) return true;
            }
         }
      }
   }
   return false;
}

// ベルマンフォード法
void bellmanFord() {
   for (int i = 0; i < N; i++) {
      dist[i] = -INF;
   }
   dist[0] = 0;
   while (true) {
      bool update = false;
      for (int i = 0; i < N; i++) {
         if (dist[i] == -INF) continue;
         for (edge e : Graph[i]) {
            if (dist[e.to] < dist[i] + e.cost) {
               dist[e.to] = dist[i] + e.cost;
               update = true;
            }
         }
      }
      if (!update) break;
   }
}

int main() {
   cin >> N >> M;
   for (int i = 0; i < M; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      a--, b--;
      Graph[a].push_back(edge{b, c});
   }

   for (int i = 0; i < N; i++) dist[i] = -INF;
   dist[0] = 0;
   bellman();
   ll ans1 = dist[N-1];

   bellman();
   ll ans2 = dist[N-1];

   if (ans1 != ans2) {
      puts("inf");
   } else {
      cout << dist[N-1] << endl;
   }

   return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

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

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,x,N,M,ans;
  string s,w="WA",a="AC";
  cin>>M>>N;
  vec v(M,0),ch(M,0);
  rep(i,N){
    cin>>x>>s;
    x--;
    if(s==a){
      ch[x]=1;
    }else if(!ch[x]){
      v[x]++;
    }
  }
  ans=x=0;
  rep(i,M){
    x+=ch[i];
    ans+=ch[i]*v[i];
  }
  print(x<<" "<<ans);
  return 0;
}

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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

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 input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n)cin >> a.at(i);
    ll ans = 0;
    REP(i,n)FOR(j,i+1,n)ans += a.at(i)*a.at(j);
    cout << ans << endl;
}


Measured memory_bytes: 256
/*    Don’t Quit
    
    When things go wrong as they sometimes will;
        When the road you’re trudging seems all uphill;
            When the funds are low, and the debts are high;
                And you want to smile, but you have to sigh;
                    When care is pressing you down a bit
                        Rest if you must, but don’t you quit.
*/
#pragma gcc optimize ("unroll-loop")
#pragma gcc optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=2e5+5;
int gcd(int n,int m)
{
    if(n==0)
        return m;
    else
        return gcd(m%n,n);
}
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    cout<<(n*n*n)<<endl;
    
         
}


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

vector<string>adj;
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};

int bfs(int rotx,int roty,int tox,int toy){
	vector<vector<int>>dist(h,vector<int>(w,1e7));
	dist[rotx][roty]=0;

	using piii =pair<int,pair<int,int>>;

	priority_queue<piii,vector<piii>,greater<piii>>pq;
	pq.push({0,{rotx,roty}});

	while(!pq.empty()){
		int x = pq.top().second.first;
		int y = pq.top().second.second;
		pq.pop();
		for(int i=0;i<4;i++){
			int nx=x+dx[i];
			int ny=y+dy[i];
			if(nx>=0&&ny>=0&&nx<h&&ny<w && adj[nx][ny]=='.'){
				if(dist[nx][ny]>dist[x][y]){
					dist[nx][ny]=dist[x][y];
					pq.push({dist[nx][ny],{nx,ny}});
				}
			}
		}
		for(int i=x-2;i<=x+2;i++){
			for(int j=y-2;j<=y+2;j++){
				if(i>=0&&j>=0&&i<h&&j<w &&adj[i][j]=='.'){
					if(dist[i][j]>dist[x][y]+1){
						dist[i][j]=dist[x][y]+1;
						pq.push({dist[i][j],{i,j}});
					}
				}
			}
		}
	}

	return dist[tox][toy];
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>h>>w;
	int ch,cw,dh,dw;
	cin>>ch>>cw>>dh>>dw;
	ch--;cw--;dh--;dw--;
	for(int i=0;i<h;i++){
		string s;
		cin>>s;
		adj.push_back(s);
	}
	int ans = bfs(ch,cw,dh,dw);
	if(ans>=1e7)ans=-1;
	
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 8476
i = list(map(int, input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

if abs(a - c) <= d:
  print('Yes')
elif abs(a - b) <= d and abs(b - c) <= d:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair 
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define rrep(i,a,b) for(int i = a; i >=b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
#define all(x) (x).begin(),(x).end()
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using ii = pair<int, int>;
using pli = pair<ll, int>;
using vi = vector<int>;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using pil = pair<int,ll>;
using vvi = vector<vi>;
using vpi = vector<ii>;

const int N = 100100;
ll mod=1000000007;

ll ceil_div(ll a, ll b) {
    return a / b + ((a ^ b) > 0 && a % b != 0);
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,x;
	cin>>n>>x;
	vll a(n);
	rep(i,0,n-1)cin>>a[i];
	ll ans = 0;
	if(a[0] > x){
		ans+= a[0] - x;	
		a[0] = x;
	}
	rep(i,1,n-1){
		if(a[i] + a[i-1] > x){
			ll to_remove = min(a[i] + a[i-1] - x,a[i]);
			a[i] -= to_remove;
			ans += to_remove;
		}
	}
	cout<<ans<<nl;
	return 0;
}




Measured memory_bytes: 3980
n = int(input())
reds = [list(map(int, input().split())) for _ in range(n)]
blues = [list(map(int, input().split())) for _ in range(n)]
reds = sorted(reds, key=lambda x:x[1])
blues = sorted(blues, key=lambda x:x[0])
used = [0 for _ in range(n)]

for blue in blues:
    possible_x = 0
    possible_y = 0
    possible_i = float('inf')
    for i in range(len(reds)):
        if blue[0] >= reds[i][0] and blue[1] >= reds[i][1] and used[i] == 0:
            if possible_y <= reds[i][1]:
                possible_x = reds[i][0]
                possible_y = reds[i][1]
                possible_i = i
    if possible_i != float('inf'):
        used[possible_i] = 1
    
print(sum(used))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int dig=52;
inline ll read(){
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n;
ll x,a1,a2;
int main(){
	n=read();
	a1=read(),a2=read();
	for(int i=3;i<=n;++i){
		x^=read();
	}
	ll tmp=a1+a2-x;
	if(tmp&1){
		printf("-1\n");
		return 0;
	}
	tmp>>=1;
	if(a1<tmp){
		printf("-1\n");
		return 0;
	}
	for(int i=dig;i>=0;--i){
		if((x>>i)&1&&(tmp>>i)&1){
			printf("-1\n");
			return 0;
		}
	}
	ll ans=a1-tmp;
	for(int i=dig;i>=0;--i){
		if((x>>i)&1&&ans>=(1LL<<i)){
			ans-=1LL<<i;
		}
	}
	cout<<(ans==a1?-1:ans)<<endl;
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int n;
    cin >> n;
    vector<ld> x(n);
    ves u(n);
    ld sum = 0;
    rep(i,n){
        cin >> x[i] >> u[i];
        if(u[i]=="BTC") x[i] *=380000.0;
        //cout << x[i]<<endl;
        sum += x[i];
    }
    cout << fixed << setprecision(5) << sum <<endl;

    return 0;

}


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

using namespace std;

const int O = 1e6 + 5;

int n, a[O];

map <int, int> cnt;

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++ i){
        cin >> a[i];
        cnt[a[i]] ++;
    }
    int sum = 0;
    for (int i = 1; i <= n; ++ i){
        sum += cnt[i] * (cnt[i] - 1) / 2;
    }
    for (int i = 1; i <= n; ++ i){
        sum -= (cnt[a[i]] - 1);
        cout << sum << '\n';
        sum += (cnt[a[i]] - 1);
    }
}

Measured memory_bytes: 16640
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

res = 0
for i in range(N):
  a = A[i]
  b = B[i]
  d = max(min(a, b), 0)
  res += d
  
  r = b - d
  if r > 0:
    d = min(A[i+1], r)
    A[i+1] -= d
    res += d
print(res)

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

using namespace std;
                      
int main()
{
	int n, m, count = 0;
	scanf("%d", &n);
	
	vector<int> v;
	
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &m);
		v.push_back(m);
	}
	
	sort(v.begin(), v.end());
	
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &m);
		
		if(binary_search(v.begin(), v.end(), m))
			count++;
	}
	
	printf("%d\n", count);
	
	return 0;
}


Measured memory_bytes: 3524
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main(string[] args) {
        string w=Console.ReadLine();
        List<char> w_col = new List<char>();
        for(int i = 0; i < w.Length; i++) {
            if (w_col.Contains(w[i])) {
                w_col.Remove(w[i]);
            }else {
                w_col.Add(w[i]);
            }
        }
        if (w_col.Count == 0)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}


Measured memory_bytes: 2776
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll A[n + 1], B[n + 1];
    vector<ll> vec;
    bool flag = false;
    for(int i = 0; i < n; i++) cin >> A[i];
    for(int i = 0; i < n; i++) cin >> B[i];
    ll sum = 0, ans = 0;
    ll check = 0;
    for(int i = 0; i < n; i++)
    {
        if(A[i] < B[i])
        {
             sum += A[i] - B[i];
             ans++;
        }
        else vec.push_back(A[i] - B[i]);
        check += A[i] - B[i];
    }
    if(check < 0)
    {
        cout << -1 << endl;
        return 0;
    }
    if(vec.size() == n)
    {
        cout << 0 << endl;
        return 0;
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    int pos = 0;
    while(sum < 0)
    {
        sum += vec[pos];
        pos++;
        ans++;
    }
    cout << ans << endl;
	return 0;
}



Measured memory_bytes: 2936
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
#include <algorithm>
using namespace std;
typedef long long lint;
#define ni (next_num<int>())
#define nl (next_num<lint>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?(c=getchar()):0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){
	if(a<b){a=b;}
}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){
	if(b<a){a=b;}
}
inline int abs(int x){
	return x>=0?x:-x;
}
const int N=100010;
namespace G{
	const int E=N*2;
	int to[E],bro[E],head[N],e;
	int color[N],sum[N],diff[N];
	int a,b;
	inline void init(int n){
		a=b=e=0;
		memset(head+1,-1,n<<2);
		memset(color+1,0,n<<2);
		memset(sum+1,0,n<<2);
		memset(diff+1,0,n<<2);
	}
	inline void ae(int u,int v){
		to[e]=v,bro[e]=head[u],head[u]=e++;
	}
	inline void add(int u,int v){
		ae(u,v),ae(v,u);
	}
	void dfs(int x,int e){
		sum[x]=color[x];
		for(int i=head[x],v;~i;i=bro[i]){
			if(i!=e){
				v=to[i];
				if(color[v]){
					a=x,b=v;
				}else{
					color[v]=-color[x];
					dfs(v,i^1);
					sum[x]+=sum[v];
					diff[x]+=diff[v];
				}
			}
		}
	}
	void dfs2(int x,int e){
		sum[x]=color[x];
		for(int i=head[x],v;~i;i=bro[i]){
			if(i!=e){
				v=to[i];
				if(!((x==a&&v==b)||(x==b&&v==a))){
					dfs2(v,i^1);
					sum[x]+=sum[v];
					diff[x]+=diff[v];
				}
			}
		}
	}
	int c[N];
	inline int work(){
		int n=ni,m=ni;
		init(n);
		for(int i=1;i<=m;i++){
			add(ni,ni);
		}
		if(n&1){
			return -1;
		}
		color[1]=1;
		dfs(1,-1);
		if(m<n){
			assert(m+1==n);
			if(sum[1]){
				return -1;
			}
			int ans=0;
			for(int i=2;i<=n;i++){
				ans+=abs(sum[i]);
			}
			return ans;
		}
		if(color[a]==color[b]){
			int ans=0;
			if(sum[1]){
				ans=abs(sum[1]/2);
				color[a]-=sum[1]/2;
				color[b]-=sum[1]/2;
				dfs2(1,-1);
			}
			assert(sum[1]==0);
			for(int i=2;i<=n;i++){
				ans+=abs(sum[i]);
			}
			return ans;
		}else{
			if(sum[1]){
				return -1;
			}
			diff[a]=1,diff[b]=-1;
			dfs2(1,-1);
			int cs=0,ans=0;
			assert(diff[1]==0&&sum[1]==0);
			for(int i=2;i<=n;i++){
				if(diff[i]){
					c[cs++]=sum[i]*diff[i];
				}else{
					ans+=abs(sum[i]);
				}
			}
			nth_element(c,c+(cs>>1),c+cs);
			int x=c[cs>>1];
			for(int i=0;i<cs;i++){
				ans+=abs(c[i]-x);
			}
			return ans+abs(x);
		}
	}
}
int main(){
	printf("%d\n",G::work());
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, C; cin >> N >> C;
    int wf[C][C]; rep(i, C) rep(j, C) cin >> wf[i][j];
    /*
    rep(k, C){
        rep(i, C){
            rep(j, C){
                wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
            }
        }
    }
    */
    

    int col[3][30];
    rep(i, 3) rep(j, 30) col[i][j] = 0;
    rep(i, N){
        rep(j, N){
            int c; cin >> c; c--;
            col[(i+j)%3][c]++;
        }
    }
    ll ans = LLINF;
    vector<int> use(3);
    for(int i = 0; i < C; i++){
        use[0] = i;
        for(int j = i+1; j < C; j++){
            use[1] = j;
            for(int k = j+1; k < C; k++){
                use[2] = k;
                do{
                    ll res = 0;
                    rep(x, 3){
                        int to = use[x];
                        rep(y, 30){
                            int from = y;
                            res += wf[from][to]*col[x][y];
                        }
                    }
                    ans = min(ans, res);
                }while(next_permutation(use.begin(), use.end()));
            }
        }
    }
    cout << ans << endl;

    /*
    rep(i, C){
        rep(j, C){
            cout << wf[i][j] << " ";
        }
        cout << endl;
    }
    */
    return 0;
}

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

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF ll 1 << 60
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

int dig(int d){
    int ans = 1;
    if(d == 0) return ans;
    while(d != 0){
        d--;
        ans*=100;
    }
    return ans;
}
int c['z'+1];

void solve(void){
    int n;
    cin >> n;
    if(n == 1 || n == 2 || n == 3)  cout <<  1 << endl;
    rrep(i,n,2){
        rep(j,2,sqrt(i)+2){
            bool flag; 
            int tmp = i;
            while(true){
                if(tmp == 1) break; 
                
                if(tmp % j == 0) {
                    flag = true;
                    tmp /= j;           
                }else{
                    flag = false;
                    break;
                }
            }

            if(flag){cout << i <<endl;return;}
        }  
    }
}

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

Measured memory_bytes: 256
def match_len(S, T):
    ls, lt = len(S), len(T)
    ret = 0
    for i in range(ls - lt + 1):
        tmp = 0
        for x, y in zip(S[i:], T):
            tmp += x == y
        ret = tmp if tmp > ret else ret
    return ret

S = input()
T = input()
print(len(T) - match_len(S, T))

Measured memory_bytes: 73316
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define yorn(f) puts((f)?"Yes":"No")
ll n;
//ld ;
//string s;
 
int main() {
  ll a[3][3];
  for(ll i1=0; i1<3; i1++){
    for(ll i2=0; i2<3; i2++){
      cin >> a[i1][i2];
    }
  }
  cin >> n;
  for(ll i=0; i<n; i++){
    ll b = 0;
    cin >> b;
    for(ll j1=0; j1<3; j1++){
      for(ll j2=0; j2<3; j2++){
        if(a[j1][j2] == b) a[j1][j2] = 0;
      }
    }
  }
  bool bingo = false;
  for(ll k=0; k<8; k++){
    ll sum = 999;
    if(k<3) sum = a[0][k] + a[1][k] + a[2][k];
    if(k>=3&&k<6) sum = a[k-3][0] + a[k-3][1] + a[k-3][2];
    if(k==6) sum = a[0][0] + a[1][1] + a[2][2];
    if(k==7) sum = a[2][0] + a[1][1] + a[0][2];
    if(sum==0) bingo = true;
  }
  yorn(bingo);
  return 0;
}

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

char c[1001][1001];
vector<vector<int>> vi(1050,vector<int>(1050,-2));
queue<pair<int,int>> q;
int H,W;
const int dh[] = {0, 0, 1, -1};
const int dw[] = {-1, 1, 0, 0};

int solve(){
    while(!q.empty()){
        pair<int,int> now=q.front();q.pop();
        int i=now.first,j=now.second;
        rep(k,0,4){
            int ni=i+dh[k],nj=j+dw[k];
            if (ni<0||ni>=H||nj<0||nj>=W)continue;
            if(vi[ni][nj]==-1){
                vi[ni][nj]=vi[i][j]+1;
                q.push(make_pair(ni,nj));
            }
        }
    }
    
    int ans=0;
    rep(i,0,H){
        rep(j,0,W) ans=max(ans,vi[i][j]);
    }
    return ans;
}

int main() {
    cin >> H >> W;
    rep(i,0,H){
        rep(j,0,W){
            cin>>c[i][j];
            if(c[i][j]=='#'){
                q.push(make_pair(i,j));
                vi[i][j]=0;
            }
            else vi[i][j]=-1;
        }
    }
    cout << solve() << endl;
}

Measured memory_bytes: 13712
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING

     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥


    EXPLAINATION BELOW->
    2d-dp;
   
*/
//
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
int h,w;
vector<vector<char>>G;
vector<vector<int>>dp;
int traverse(int x,int y)
{
    if(x==h-1&&y==w-1)return 1;
    if(dp[x][y]!=0)return dp[x][y]%MOD7;
    
    if(x+1<h&&G[x+1][y]!='#')dp[x][y]+=traverse(x+1,y)%MOD7;
    if(y+1<w&&G[x][y+1]!='#')dp[x][y]+=traverse(x,y+1)%MOD7;
    return dp[x][y]%MOD7;
}
void iterative()
{
    int i,j;
    dp[h-1][w-1]=1;
    for(i=h-1;i>=0;i--)
    {
        for(j=w-1;j>=0;j--)
        {
            if(G[i][j]=='#')dp[i][j]=0;
            else
            {
               if(i+1<h)dp[i][j]+=dp[i+1][j]%MOD7;
               if(j+1<w)dp[i][j]+=dp[i][j+1]%MOD7;
            }
        }
    }
}
void solve()
{
    cin>>h>>w;
    G=vector<vector<char>>(h,vector<char>(w));
    dp=vector<vector<int>>(h+1,vector<int>(w+1,0));
    int i,j;
    fo(i,0,h)
    fo(j,0,w)cin>>G[i][j];
    //traverse(0,0);
    iterative();
    cout<<dp[0][0]%MOD7<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, z);
    swap(z, y);

    cout << x << " " << y << " " << z;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int w,a,b,ans;
    cin>> w>>a>>b;
    if((a+w)<b){
        ans = (a+w)-b;
    }else if(a> (b+w)){
        ans = a - (b+w);
    }else{
        ans = 0;
    }
    cout<<abs(ans)<<endl;

    return 0;
}

Measured memory_bytes: 256