akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n; scanf("%d", &n);
	vi a(n);
	map<int,int> cnt;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		cnt[a[i]]++;
	}

	ll total = 0;
	for (auto p : cnt) total += (ll)(p.second) * (p.second - 1) / 2;
	for (int i = 0; i < n; i++) {
		ll tmp = cnt[a[i]] - 1;
		printf("%lld\n", total - tmp);
	}
}


Measured memory_bytes: 8320
#include<stdio.h>
int main(){
	int a,b;
	int d,r;
	double f;
	scanf("%d%d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/b;
	printf("%d %d %f\n",d,r,f);
	return 0;
}

Measured memory_bytes: 2760
length = list(map(int, input().split()))
dif_min = 10000000000
for i in range(2):
    h, w = length[i % 2], length[(i+1) % 2]
    for j in range(1, h):
        s1 = j * w
        h1 = h - j
        s2, s3 = (h1//2) * w, (h1-h1//2) * w
        dif1 = max(s1, s2, s3) - min(s1, s2, s3)

        s2, s3 = h1 * (w//2), h1 * (w-w//2)
        dif2 = max(s1, s2, s3) - min(s1, s2, s3)

        if min(dif1, dif2) < dif_min:
            dif_min = min(dif1, dif2)

print(dif_min)


Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#define BIT(nr) (1ULL << (nr))
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }


using namespace std;


signed main() {
    int N;
    cin >> N;
    vector<int> A(N + 1, 0), B(N + 1, 0), C(N + 1, 0), cuB(N+1, 0), numC(N+1, 0);

    REPS(i, N) cin >> A[i];
    REPS(i, N) cin >> B[i];
    REPS(i, N) cin >> C[i];
 
    sort(ALLOF(A));
    sort(ALLOF(B));
    sort(ALLOF(C));

    // cuB[i]: A[i]を選んだ時に使えるB, Cの場合の数
    // numC[i]: B[i]を選んだ時に使えるCの場合の数

    REPS(i, N) {
        // B[i]より真に大きい最小の場所をにぶたん
        auto it = lower_bound(ALLOF(C), B[i] + 1);
        int cnt = C.end() - it;
        numC[i] = cnt;
    }

    // cuB をnumc[i]-numc[N]までの和にする
    int su = 0;
    RREPS(i, N) {
        su += numC[i];
        cuB[i] = su;
    }

    int ans = 0;
    REPS(i, N) {
        auto it = lower_bound(ALLOF(B), A[i] + 1);
        if (it == B.end()) {
            // 真に大きいBがない
            break;
        }
        int ind = it - B.begin();
        ans += cuB[ind];
    }

    cout << ans << "\n";

    return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    string o, e;
    string s;
    cin >> o >> e;
    for(i32 tim = 1, i = 0, j = 0; i < o.size() || j < e.size(); ++ tim) {
        if(tim&1) {
            s.push_back(o[i]);
            ++i;
        }
        else {
            s.push_back(e[j]);
            ++j;
        }
    }

    cout << s << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 256
//om nama sivaya
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void solve(){
    string s;
    cin>>s;
    ll su=0;
    int x=s.length();
    for(int i=0;i<x;i++)
    su+=(s[i]-'0');
    if((su%9))
    cout<<"No";
    else
    cout<<"Yes";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
    solve();
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
bool can(int a,int b,int d){
    return abs(a-b)<=d;
}

int main()
{
    int a,b;
    while(~scanf("%d%d",&a,&b)){

        int x1= a+b;
        int x2 = a-b;
        int ans = max(x1,x2);
        int x3 = a*b;
        ans = max(x3,ans);
            
        printf("%d\n",ans);

    }
    return 0;
}


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

int main()
{
    int A, B, K;
    int g[100];
    int i;
    int k;
    cin >> A >> B >> K;

    k = 0;
    for(i = 1; i<=A && i<= B ; i++) {
        if(A%i == 0 && B%i == 0) {
            g[k] = i;
            k += 1;
        }
    }

    cout << g[k-K] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int  main()
{
	int ab,l,a[4],cnt;
	cnt = 0;
	ab = 0;
	for (int i = 0;i<4;i++){
		cin >> l;
		a[i] = l;
	}
	int search[4] = {1,9,7,4};
	for (int i = 0; i < 4; i++){
		for(int j = 0; j < 4; j++){
			if (a[i] == search[j])
				cnt++;
		}
	}
	for (int i = 0; i <3; i++){
		for (int j = 0; j+i <3; j++){
			//cout << a[i] << "==" << a[i+j + 1]<<'\n';
			if (a[i] == a[i+j+1]){
				cnt = 0;
			}
		}
	}
	if (cnt == 4){
		cout << "YES";
	}
	else{
		cout << "NO";
	}
	return 0;
}

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

static class Program{
    static void Main() {
        String s=Console.ReadLine();
        int n=s.Length;
        int ans0=0,ans1=0;
        for(int i=0;i<n;i++){
            if((s[i]=='0')^(i%2==0))ans0++;
        }
        for(int i=0;i<n;i++){
            if((s[i]=='1')^(i%2==0))ans1++;
        }
        Console.WriteLine(Math.Min(ans0,ans1));
    }
}


Measured memory_bytes: 11232
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

ans=0
pre=-1

for i in a:
  ans += b[i-1]
  if(i==pre+1):
    ans += c[i-2]
  pre=i
  
print(ans)

Measured memory_bytes: 3064
h,w = map(int,input().split())
field = [list(input())for i in range(h)]
for i in range(h):
    for j in range(w):
        res = 0
        if field[i][j] == '#':continue
        if i-1 >=0 and field[i-1][j] == '#':res+=1
        if j-1 >=0 and field[i][j-1] == '#':res+=1
        if i+1 <=h-1 and field[i+1][j] == '#':res+=1
        if j+1 <=w-1 and field[i][j+1] == '#':res+=1
        if i-1 >=0 and j-1 >= 0 and field[i-1][j-1] == '#':res+=1
        if i-1 >=0 and j+1 <= w-1 and field[i-1][j+1] == '#':res+=1
        if i+1 <=h-1 and j-1 >= 0 and field[i+1][j-1] == '#':res+=1
        if i+1 <=h-1 and j+1 <= w-1 and field[i+1][j+1] == '#':res+=1
        field[i][j] = str(res)
for i in range(h):
    print("".join(field[i]))
        
        

Measured memory_bytes: 3188
let n, m, r, ans, ds, rs = Scanf.(scanf "%d %d %d" @@ fun n m r -> Array.(n, m, r, ref max_int, make_matrix n n (1 lsl 40), init r @@ fun _ -> scanf " %d" pred))
let s, fs, is, es = Array.(ref 0, make r false, make r 0, init m @@ fun _ -> Scanf.scanf " %d %d %d" @@ fun a b t -> ds.(a - 1).(b - 1) <- t; ds.(b - 1).(a - 1) <- t; a - 1, b - 1, t)
let rec f i = if i >= r then ans := min !ans !s else for j = 0 to r - 1 do if not fs.(j) then (fs.(j) <- true; is.(i) <- j; let d = if i > 0 then ds.(rs.(is.(i - 1))).(rs.(j)) else 0 in s := !s + d; f (i + 1); fs.(j) <- false; s := !s - d) done
let _ = Array.(iteri (fun i d -> iteri (fun j _ -> if i = j then d.(j) <- 0) d) ds); for k = 0 to n - 1 do for i = 0 to n - 1 do for j = 0 to n - 1 do ds.(i).(j) <- min ds.(i).(j) @@ ds.(i).(k) + ds.(k).(j) done done done; f 0; Printf.printf "%d\n" !ans

Measured memory_bytes: 5760
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i <= i##_len; ++i)
#define rep3(i, l, r) for (int i = l, i##_len = (r); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = l, i##_len = (r); i <= i##_len; ++i)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef int64_t Int;
typedef long double Ld;

using namespace std;
template <class T>
using Graph = vector<vector<T>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 62;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

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

template <typename T>
inline T Gcd(T a, T b) {
    T c;
    while (b) {
        c = b;
        b = a % b;
        a = c;
    }
    return a;
}

Int Lcm(Int a, Int b) {
    if (a < b) {
        swap(a, b);
    }

    return a / Gcd(a, b) * b;
}

// 二分累乗法
template <typename T>
T modpow(T a, T n, T mod) {
    T ret = 1;

    if (mod == 1) {
        while (n > 0) {
            if (n & 1) {
                ret = ret * a;
            }
            a = a * a;
            n >>= 1;
        }
    } else {
        while (n > 0) {
            if (n & 1) {
                ret = ret * a % mod;
            }
            a = a * a % mod;
            n >>= 1;
        }
    }

    return ret;
}

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

    Int n, k, s;
    cin >> n >> k >> s;

    vector<Int> ans;
    if (s != 1000000000) {
        for (int i = 0; i < n; i++) {
            if (i < k) {
                ans.push_back(s);
            } else {
                ans.push_back(1000000000);
            }
        }
    } else {
        for (int i = 0; i < n; i++) {
            if (i < k) {
                ans.push_back(s);
            } else {
                ans.push_back(1);
            }
        }
    }

    for (int i = 0; i < n - 1; i++) {
        cout << ans[i] << ' ';
    }
    cout << ans[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 4264
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	a := ReadInt()
	fmt.Println(a + a*a + a*a*a)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }

func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;
ll modpow(ll a, ll n, ll mod) { 
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k; 
    cout << a + b + c + max({a, b, c}) * ((1 << k) - 1) << endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

const int N_MAX = pow(10, 5);
 
int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++) cin >> a[i];

	int curr = 0, ans = 0, cnt[N_MAX];
	fill(cnt, cnt+N_MAX, 0);
	while(1){
		if(cnt[curr] > 0){
			cout << -1 << endl;
			return 0;
		}else if(curr == 1){
			cout << ans << endl;
			return 0;
		}
		ans++;
		cnt[curr]++;
		curr = a[curr]-1;
	}
 
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            int c = Integer.parseInt(sc.next());
            int x = Integer.parseInt(sc.next());
            int y = Integer.parseInt(sc.next());
            int ret = 0;
            int common = Math.min(x, y);
            
            ret = Math.min(a+b, c*2) * common;
            
            ret += (x - common) * Math.min(a, c*2);
            
            ret += (y - common) * Math.min(b, c*2);
            
            //出力
            System.out.println(ret);
            sc.close();
        }
    }
	

Measured memory_bytes: 21716
import itertools
def nagosan():
    n=int(input())
    cnt=0
    for i in range(2,len(str(n))+1):
        a=list(itertools.product(['3','5','7'],repeat=i))
        for z in a:
            x=''.join(z)
            if int(x)>n:
                continue
            if '3' in x and '5' in x and '7' in x:
                cnt+=1
    return cnt
print(nagosan())

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

#define GYOU_MAX 256

int main(void) {


	char S[101], T[300];
	scanf("%s %s", S, T);

	strcat(T, S);
	printf("%s", T);


	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

int myPow(int i) {
    if(i == 0)return 1;
    return 2 * myPow(i - 1);
}

const int MAX_M = 1001;
const int MAX_N = 13;
int c[MAX_M];

int main() {
    int N, M;
    cin >> N >> M;
    int a[M], b[M];
    int tmp;
    rep(i, M) {
        cin >> a[i] >> b[i];
        rep(j, b[i]) {
            cin >> tmp;--tmp;
            c[i] += (1 << tmp);
        }
    }
    int dp[M + 1][myPow(N)]; //i番目までの鍵を見たとき，
    rep(i, M + 1)
        rep(j, myPow(N))
            dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i, M) {
        for(int bit = 0; bit < (1 << N); ++bit) {
            dp[i + 1][bit] = min(dp[i][bit], dp[i + 1][bit]);
            dp[i + 1][bit | c[i]] = min(dp[i + 1][bit | c[i]], dp[i][bit] + a[i]);
        }
    }
    cout << ((dp[M][(1 << N) - 1] == INF) ? -1 : dp[M][(1 << N) - 1]) << endl;
}


Measured memory_bytes: 16256
from collections import defaultdict
dic = defaultdict(int)
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
for x,y in zip(A,B):
  dic[x] += 1
  dic[y] += 1
L = list(dic.values())
MAX = max(L)
if MAX > N:
  print("No"); exit()
INF = float("inf")
dicA_min = defaultdict(lambda: INF); dicA_max = defaultdict(lambda: 0)
dicB_min = defaultdict(lambda: INF); dicB_max = defaultdict(lambda: 0)
for i in range(N):
  dicA_min[A[i]] = min(dicA_min[A[i]],i)
  dicA_max[A[i]] = max(dicA_max[A[i]],i)
  dicB_min[B[i]] = min(dicB_min[B[i]],i)
  dicB_max[B[i]] = max(dicB_max[B[i]],i)
#print(dicA_min,dicA_max)
L = list(dicB_min.keys())
mink = -INF
maxk = INF
Flag = False
for t in L:
  if dicA_min[t] == INF:
    continue
  mink = max(dicA_max[t]-dicB_min[t]+1,mink)
  maxk = min(dicA_min[t]+N-dicB_max[t]-1,maxk)
  Flag = True
if not Flag:
  print("Yes")
  print(*B)
  exit()
#print(mink,maxk)
if mink >= 0:
  ans = B[-mink:] + B[:-mink]
else:
  ans = B[-mink:] + B[:-mink]
print("Yes")
print(*ans)

Measured memory_bytes: 231072
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<ii> vii;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr(be, en) for(int i = be; i <= en; i++) 
ll mod = LLONG_MAX;
ll power(ll a, ll b)
{
	if(b == 0) return 1;
	ll ans = power(a, b/2);
	ans = (ans*ans)%mod;
	if(b%2) ans*=a;
	return ans%mod;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);
	cin.tie(NULL);
	double r;
	cin >> r;
	cout << setprecision(6) << std :: fixed << (double)2*3.14159265358979323846*r ;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define pb push_back
#define md 1000000007
int main()
{
	fast;
	ll x;
	cin>>x;
	
	for(int i=-1000; i<= 1000;i++)
	{
		for(int j=-1000;j<=1000;j++)
		{
			ll k = pow(i,5)-pow(j,5);
			if(k==x)
				{
					cout<<i<<" "<<j;
					return 0;
				}
		}
	}

	return 0;
}

Measured memory_bytes: 4072
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		 Scanner s = new Scanner(System.in);
		 int indexOfA = 0, indexOfZ = 0;
		 String str = s.nextLine();
		 for(int i = 0; i < str.length(); i++){
			 if(str.charAt(i)=='A'){
				 indexOfA = i;
				 break;
			 }
		 };
		 for(int i = str.length()-1; i >=0 ; i--){
			 if(str.charAt(i)=='Z'){
				 indexOfZ = i;
				 break;
			 }
		 };
		 System.out.println(indexOfZ - indexOfA + 1);
	}
}


Measured memory_bytes: 14612
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int n,a[205],ans;
int main()
{
	fast;
	cin>>n;
	for (int i=1;i<=2*n;i++)
	   cin>>a[i];
	sort (a+1,a+2*n+1);
	for (int i=1;i<=2*n;i+=2)
	   ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<stdio.h>
#define rep(i,n)for(int i=0;i<n;i++)
//printf("%.yf\n",x); xを小数点以下y桁で
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    if (a%2 == 0) {
        if (a / 2 >= b) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
    }
    else {
        if (a / 2+1 >= b) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

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

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


  int n;cin>>n;
  cout<<((n+1)/2)<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
	string s;
	cin>>s;
	map<char, ll> mp;
	for(int i=0;i<s.size();i++) {
		mp[s[i]] = 1;
	}
	if(mp.size() == 4) {
		cout<<"Yes\n";
	} else if(mp.size() == 2) {
		if(mp.find('S') != mp.end() && mp.find('N') != mp.end()) {
			cout<<"Yes\n";
		} else if(mp.find('E') != mp.end() && mp.find('W') != mp.end()) {
			cout<<"Yes\n";
		} else {
			cout<<"No\n";
		}
	} else {
		cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int humming(int A, int B) {
    int ans = 0;
    for(int i=0; i<20; i++) {
        int b1 = A >> i & 1;
        int b2 = B >> i & 1;
        if(b1 != b2) ans++;
    }
    return ans;
}

int node[1 << 18], id = 1;

void dfs(int cur, vector<int> &perm) {
    int c1 = 2*cur + 1;
    int c2 = 2*cur + 2;
    if(c1 < id) {
        dfs(c1, perm);
    }
    perm.push_back(node[cur]);
    if(c2 < id) {
        dfs(c2, perm);
    }
};

signed main() {
    int N, A, B; cin >> N >> A >> B;

    if(humming(A, B) % 2 == 0) {
        cout << "NO" << endl;
    }
    else {
        cout << "YES" << endl;

        vector<int> diff;
        for(int i=0; i<20; i++) {
            int b1 = A >> i & 1;
            int b2 = B >> i & 1;
            if(b1 != b2) diff.push_back(i);
        }

        int cnt = diff.size() / 2;
        for(int i=0; i<N; i++) {
            bool found = false;
            for(auto x : diff) {
                if(x == i) found = true;
            }
            if(!found) diff.push_back(i);
        }
        
        node[0] = 0;
        for(int i=1; i<N; i++) {
            for(int k=0; k<(1LL<<i); k++) {
                node[id++] = i;
            }
        }

        int idx = 1;
        while(cnt--) {
            int target = (1LL << (2*idx)) - 2; idx++;
            int c1 = 2*target + 1, c2 = c1 + 1;

            int v1 = node[target], v2 = node[c1];
            node[target] = v2;
            node[c1] = node[c2] = v1;
        }

        /*
        for(int i=0; i<(1<<N)-1; i++) {
            fprintf(stderr, "node[%2lld] = %lld\n", i, node[i]);
        }
        */

        vector<int> perm;
        dfs(0, perm);
        /*
        for(int i=0; i<(1<<N)-1; i++) {
            fprintf(stderr, "%lld ", perm[i]);
        }
        */

        vector<int> arg;
        for(int i=0; i<(1<<N)-1; i++) {
            arg.push_back(diff[ perm[i] ]);
        }

        vector<int> ans;
        int num = A;
        ans.push_back(num);

        for(int i=0; i<(1<<N)-1; i++) {
            num ^= (1LL << arg[i]);
            ans.push_back(num);
        }

        for(int i=0; i<(1<<N); i++) {
            printf("%lld%c", ans[i], i+1==(1LL<<N) ? '\n' : ' ');
        }
    }
    return 0;
}


Measured memory_bytes: 5236
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Main m = new Main();
		while (m.input()) {
			m.print();
		}
		m.release();
 	}
	
	BufferedReader reader = null;
	Main.HW hw = null;
	
	Main() {
		init();
	}
	
	public void init() {
		reader = new BufferedReader(
			new InputStreamReader(System.in)
			);
	}
	
	public void release() {
		if (reader == null) {
			return;
		}
		try {
			reader.close();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			reader = null;
		}
	}
	
	private void sharp(Main.HW hw) {
		if (hw.nonZeroW()) {
			System.out.print("#");
			sharp(hw.getDecW());
		}
	}
	
	private void line(Main.HW hw) {
		if (hw.nonZeroH()) {
			sharp(hw);
			System.out.println();
			line(hw.getDecH());
		} else {
			System.out.println();
		}
	}
	
	public void print() {
		if (hw == null) {
			return;
		}
		line(hw);
	}
	
	public boolean input() {
		if (reader == null) {
			init();
		}
		try {
			hw = new Main.HW(reader.readLine().split(" "));
			return !hw.isZero();
		} catch (IOException e) {
			e.printStackTrace();
		}
		hw = null;
		return false;
	}
	
	public static class HW
	{
		private final int h;
		private final int w;
		HW(int h, int w) {
			this.h = h;
			this.w = w;
		}
		HW(String[] data) {
			h = Integer.parseInt(data[0]);
			w = Integer.parseInt(data[1]);
		}
		public int getH() {
			return h;
		}
		public int getW() {
			return w;
		}
		public boolean isZero() {
			return (h == 0) && (w == 0);
		}
		public boolean nonZeroW() {
			return w > 0;
		}
		public boolean nonZeroH() {
			return h > 0;
		}
		public HW getDecW() {
			return new HW(h, w - 1);
		}
		public HW getDecH() {
			return new HW(h - 1, w);
		}
	}
}

Measured memory_bytes: 27956
#include <stdio.h>

void swap(int *a, int *b){
  int t;
  t = *a;
  *a = *b;
  *b = t;
}

int main(){
  int x, y, z;
  scanf("%d%d%d", &x, &y, &z);
  swap(&x, &y);
  swap(&x, &z);
  printf("%d %d %d", x, y, z);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
short num,n;
int main(){
    for(int i=0;i<3;i++){
        scanf("%d",&num);
        if(num==7)
            n++;
    }
    if(n==1)
        printf("YES");
    else
        printf("NO");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


long long mul_inv(long long a, long long b)
{
	long long b0 = b, t, q;
	long long x0 = 0, x1 = 1;
	if (b == 1) return 1;
	while (a > 1) {
		q = a / b;
		t = b, b = a % b, a = t;
		t = x0, x0 = x1 - q * x0, x1 = t;
	}
	if (x1 < 0) x1 += b0;
	return x1;
}

long long division(long long a, long long b, long long p) {		// (a / b) mod p = ((a mod p) * (b^(-1) mod p)) mod p
	long long ans, inv;
	inv = mul_inv(b, p);
	ans = ((a % p) * inv) % p;
	return ans;
}



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

	long long n, m, i, j, k, s, MOD = 1000000007, ans, a, b;
	cin >> n >> m;
	s = n + m;
	if (s % 3 != 0) ans = 0;
	else if (n > m * 2) ans = 0;
	else if (m > n * 2) ans = 0;
	else {
		s /= 3;	// total steps
		a = 2 * s - n;	// # of 1, 2
		ans = 1;
		b = 1;
		for (i = 1; i <= a; i++) {
			ans = (ans * (s + 1 - i)) % MOD;
			b = (b * i) % MOD;
		}
		ans = division(ans, b, MOD);
	}

	cout << ans << "\n";


	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int A, B;
  cin >> A >> B;

  int sum = A+B;
  if(sum == 3)
    cout << "3" << endl;
  else if(sum == 4)
    cout << "2" << endl;
  else if(sum == 5)
    cout << "1" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  vi a(n);
  cin>>a;
  rep(i,n) --a[i];
  if (n == 2 && a[0] == 1 && a[1] == 0) dame;
  vi cnt(n);
  rep(i,n) cnt[a[i]]++;
  vi ans;
  set<int> s;
  rep(i,n) s.insert(i);
  int no = -1, rest = n;
  auto add = [&](int i) {
    s.erase(i);
    ans.pb(i);
    no = a[i];
    cnt[no]--;
    --rest;
  };
  while (sz(s)) {
    auto it = s.begin();
    {
      int i = *it;
      int j = a[i];
      if (s.count(j) && cnt[j] == rest-1) { add(j); continue;}
    }
    while (1) {
      assert(it != s.end());
      int i = *it; ++it;
      if (i == no) continue;
      if (sz(s) == 3) {
        vi is;
        for (auto j : s) {
          if (i != j) is.pb(j);
        }
        int x = is[0], y = is[1];
        if (a[x] == y && a[y] == x) continue;
      }
      add(i);
      break;
    }
  }
  rep(i,n) ans[i]++;
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 5760
n, k = list(map(int, input().split()))

d = list()
s = set()
for _ in range(k):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        s.add(a)

c = 0
for i in range(1, n+1):
    if i not in s:
        c += 1

print(c)


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

def main():
    N = int(input())
    ab = [list(map(int, input().split())) for i in range(N)]

    count = 0
    for i in range(N-1, -1, -1):
        a, b = ab[i]
        tmp = (a + count) % b
        if tmp != 0:
            count += b - tmp
    print(count)

if __name__ == "__main__":
    main()

Measured memory_bytes: 27380
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
 
int main(){
 
    string n;cin>>n;
 
    if(n[0]=='7'||n[1]=='7'||n[2]=='7')cout<<"Yes\n";
    else cout<<"No\n";
 
    return 0;
 
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=200005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

int n,m,k;

int main(){
	Init();
	cin>>n>>m>>k;
	ll res=0;
	for(int i=0;i<=k;i++){
		(res+=m*Pow(m-1,n-i-1)%mod*nCk(n-1,i))%=mod;
	}
	cout<<res<<endl;
}

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

int n, A[50];

int solve(int i, int m) {
    if(m==0) {
        return 1;
    }
    if(i>=n) {
        return 0;
    }
    int res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;
}

int main() {
    int q, M, i;

    cin >> n;
    for(i=0; i<n; i++) {
        cin >> A[i];
    }
    cin >> q;
    for(i=0; i<q; i++) {
        cin >> M;
        if(solve(0, M)) {
            cout << "yes\n";
        }
        else {
            cout << "no\n";
        }
    }

    return 0;
}


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,m,x,y;
  cin>>n>>m>>x>>y;
  int xi[n];
  int yi[m];
  int xmax=x;
  int ymin=y;
  for(int i=0;i<n;i++){
    cin>>xi[i];
    xmax=max(xi[i],xmax);
  }
  for(int i=0;i<m;i++){
    cin>>yi[i];
    ymin=min(yi[i],ymin);
  }
  if(xmax<ymin)cout<<"No War"<<endl;
  else cout<<"War"<<endl;
  return 0;
}


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


using namespace std;

int main()
{
	int a,b,c;
	cin >> a >> b >>c ; 

	if (b - a == c - b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;

	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,c,d,e;
  cin >> a >> b;
  c = a+b;
  d = a-b;
  e = a*b;
  a = max(c,d);
  a = max(a,e);
  cout << a;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi = acos(-1.0);
#define memset(a,b) memset(a,b,sizeof(a))
const int mod = (1 ? 1000000007 : 998244353);
const int inf = (1 ? 0x3f3f3f3f : 0x7fffffff);
const int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
const ll INF = (1 ? 0x3f3f3f3f3f3f3f3f : 0x7fffffffffffffff);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll poww(ll a, ll b, ll mod) { ll s = 1; while (b) { if (b & 1)s = (s * a) % mod; a = (a * a) % mod; b >>= 1; }return s % mod; }


const int N = 1e5 + 10;
ll n, m;


void solve()
{
	cin >> n;
	cout << ((poww(10, n, mod) + poww(8, n, mod) - poww(9, n, mod) * 2) + (ll)mod * 10) % mod << endl;
	

}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	ll T = 1;
	//cin >> T;
	while (T--)solve();
	//while (cin >> n)solve();//HDU
	return 0;

}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int64_t k,n;
  cin >> k >> n;
  vector<int64_t> a(n);
  rep(i,n){
    cin >> a[i];
  }
  int64_t h = a[0];
  rep(i,n){
    a[i] -= h;
  }
  int64_t maxd = 0;
  rep(i,n-1){
    maxd = max(maxd,a[i+1]-a[i]);
  }
  maxd = max(maxd,k-a[n-1]);
  cout << k - maxd << endl;
  
    
}

Measured memory_bytes: 1792
loop do
  n,m,p = gets.chomp.split.map(&:to_i)
  break if (n|m|p) == 0

  player = []
  sum = 0
  n.times do
    x = gets.chomp.to_i
    sum += x * 100
    player << x
  end
  prize = sum * (100 - p) / 100

  puts player[m-1] == 0 ? 0 : prize / player[m-1]
end



Measured memory_bytes: 6872
#include<iostream>
using namespace std

;

int main(){

int a, b, c, t;

cin>> a>> b>> c;

if (a>b){

t=a;

a=b;

b=t;

}

if (b>c){

t=b;

b=c;

c=t;

}

if (a>b){

t=a;

a=b;

b=t;

}

cout << a <<" "<< b <<" "<< c <<"\n";

return 0;

}

Measured memory_bytes: 1164
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



string tostr( char s[], int a, int n) {
    string res = "" ;
    for ( int i = a; i < a+n; ++i) {
        if (s[i] != 0) res += s[i];
    }
    return res;
}


string str;
set<int> se1, se2;
map<int,int> ma;
vector<pint> res;

int a, b;

int main() {
    se1.clear(); se2.clear(); ma.clear(); res.clear();
    while (true) {
        getline(cin, str);
        if (str == "") break;
        for (int i = 0; i < str.size(); ++i) if (str[i] == ',') str[i] = ' ';
        istringstream sin(str);
        sin >> a >> b;
        se1.insert(a);
        ma[a]++;
    }
    while (getline(cin, str)) {
        for (int i = 0; i < str.size(); ++i) if (str[i] == ',') str[i] = ' ';
        istringstream sin(str);
        sin >> a >> b;
        if (se1.count(a)) se2.insert(a);
        ma[a]++;
    }
    EACH(it, ma) {
        if ( se2.count(it->first) ) {
            res.PB( MP(it->first, it->second) );
        }
    }
    sort(ALL(res)); 
    for (int i = 0; i < res.size(); ++i) {
        cout << res[i].first << " " << res[i].second << endl;
    }  
    
    return 0;
}


Measured memory_bytes: 1232
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < ((k)+(n)); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); --i)
#define FROMTO(i,f,t)       for(int i = f; i < t; i++)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define FILL(m,v)           memset(m, v, sizeof(m))
#define mp                  make_pair
#define pb                  push_back
template<class _T> _T MAX(_T p1,_T p2){return (p1>p2)?p1:p2;} 
template<class _T> _T MIN(_T p1,_T p2){return (p1<p2)?p1:p2;} 
template <class _Tv> inline string join(const _Tv &v,string sep=" "){
    ostringstream s;FOREACH(it,v){if(it!=v.begin())s<<sep;s<<*it;};return s.str();
}

typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef complex<D> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define X real()
#define Y imag()
#define EPS (1e-9)
#define DEQ(p1,p2) (abs((p1)-(p2)) < EPS)

#ifdef _DEBUG
template<class _Tv> inline void _prfe(const char *_n,const _Tv _c,bool _p=false){
    ITER(_c) _it=_c.begin();
    if(_p){cout<<_n<<" = ["<<endl;for(;_it!=_c.end();++_it)cout<<"    "<<*_it<<endl;cout<<"]"<<endl; }
    else{cout<<_n<<" = [ "<<*_it++;for(;_it!=_c.end();++_it)cout<<", "<<*_it;cout<<" ]"<<endl; }
}
#define pf printf
#define pr(n) do{cout<<#n" = "<<(n)<<endl;}while(0)
#define prfe(n) _prfe(#n, n)
#define prfep(n) _prfe(#n, n, true)
#define dbgchk(n) do{if(n)throw;}while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#define prfe(...) /* */
#define prfep(...) /* */
#define dbgchk(...) /* */
#endif

int solve(int n){
    int c = 0;
    while(n > 1){
        if(n%2) n=n*3+1; else n/=2; c++;
    }
    return c;
}

int main(){
    int n;
    while(cin >> n && n){
        cout << solve(n) << endl;
    }
    return 0;
}

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

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

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 60
#define MAX_SUM 3000

ll N, A;
ll X[MAX_N];
ll dp[MAX_N][MAX_N][MAX_SUM];

// i 番目まで見ていて、 j 枚選んでいて、現在の合計が sum のときのパターン数
ll dfs(ll i = 0, ll j = 0, ll sum = 0) {
    if(i >= N) {
        if(j > 0 && (sum % j == 0) && sum / j == A) { return 1; }
        return 0;
    }
    ll& res = dp[i][j][sum];
    if(~res) { return res; }
    res = 0;

    res += dfs(i+1, j+1, sum + X[i]);
    res += dfs(i+1, j, sum);
    return res;
}

signed main()
{
    cin >> N >> A;
    REP(i, N) { cin >> X[i]; }
    MINUS(dp);
    ll ans = dfs();
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 84608
H, W=map(int, input().split())
a=[list(map(int, input().split())) for i in range(H)]
out=[]
n=0
for i in range(H):
  for j in range(W-1):
    if a[i][j]%2==1:
      n+=1
      a[i][j]-=1
      a[i][j+1]+=1
      out.append([i+1, j+1, i+1, j+2])
      
      
for i in range(H-1):
  if a[i][-1]%2==1:
    n+=1
    a[i][-1]-=1
    a[i+1][-1]+=1
    out.append([i+1, W, i+2, W])
    
print(n)
for i in range(n):
  print(' '.join(map(str, out[i])))

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

#define FOR(i, l, r) for(size_t i = (l); i < (r); i = i + 1)
#define REP(i, n) FOR(i, 0, n)
using ll = long long;

int main() {
    int N;
    cin >> N;
    int K;
    cin >> K;
    int ans = 0;

    int sho = N;

    while(sho > 0) {
        sho /= K;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

N, D = map(int, input().split())
X = []
for i in range(N):
  X.append(list(map(int, input().split()))) # OK!

# Compute each distances
dis = [[0 for i in range(N)] for j in range(N)]
for i in range(N):
  for j in range(i+1, N):
    for k in range(D):
      dis[i][j] += (X[i][k]-X[j][k])**2 # OK!

# Check integer or not
dot = 0
for i in range(N):
  for j in range(i, N):
    dis[i][j] = np.sqrt(dis[i][j])
    if dis[i][j].is_integer() and dis[i][j] != 0:
      dot += 1

print(dot)

Measured memory_bytes: 27072
#include <bits/stdc++.h>
using namespace std;
//#define P pair<int,int>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)

// n個の中からk個選ぶ 0~n-1 bitで表現 n<=18 k<=n
vector<int> combination(int n,int k){
	vector<int> ans;
	int x = (1<<k)-1;
	int f = x<<(n-k);
	while(1){
		ans.push_back(x);
		if(x==f)return ans;
		x += x&-x;
		int pcount = bitset<64>(x).count();
		x|=(1<<(k-pcount))-1;
	}
}

struct Inversions{// tentosu
	// after init,u can get number of inversions num_inversion(A)
	vector<int> L,R;
	void initsize(int n){//input size of A
		L.resize(n/2+2);
		R.resize(n/2+2);
	}
	int merge(vector<int> &A,int n,int left,int mid,int right){
		int i,j,k;
		int cnt = 0;
		int n1 = mid - left;
		int n2 = right - mid;
		for(i=0;i<n1;i++)L[i]=A[left+i];
		for(i=0;i<n2;i++)R[i]=A[mid+i];
		L[n1]=R[n2]=INT_MAX;//
		i=j=0;
		for(k=left;k<right;k++){
			if(L[i]<=R[j]){
				A[k]=L[i++];
			}else{
				A[k]=R[j++];
				cnt += n1-i;
			}
		}
		return cnt;
	}
	int mergeSort(vector<int> &A,int n,int left,int right){
		int mid;
		int v1,v2,v3;
		if(left+1<right){
			mid = (left+right)/2;
			v1 = mergeSort(A,n,left,mid);
			v2 = mergeSort(A,n,mid,right);
			v3 = merge(A,n,left,mid,right);
			return v1+v2+v3;
		}else return 0;
	}
	int num_inversion(vector<int> A){
		vector<int> B=A;//Aの順番を変えたくないなら
		return mergeSort(B,B.size(),0,B.size());
	}
};


int main(){
	int N,n,ans=-1;
	cin >> N;
	n = N/2;
	if(N==1){
		cout << 0 << endl;
		return 0;
	}
	vector<int> A(N),B(N);
	for(int i=0;i<N;i++) cin >> A[i];
	for(int i=0;i<N;i++) cin >> B[i];
	for(int ch=0; ch<=n; ch++){
		auto chodd = combination( n,ch );
		auto cheve = combination( N-n,ch );
		for(auto odds : chodd){
			for(auto eves : cheve){
				vector<pair<int,int>> odd,eve;
				for(int i=0;i<n;i++){
					if(odds&(1<<i)){
						eve.push_back({B[2*i+1],2*i+1});
					}else{
						odd.push_back({A[2*i+1],2*i+1});
					}
				}
				for(int i=0;i<N-n;i++){
					if(eves&(1<<i)){
						odd.push_back({B[2*i],2*i});
					}else{
						eve.push_back({A[2*i],2*i});
					}
				}
				sort(odd.begin(), odd.end());
				sort(eve.begin(), eve.end());
				vector<int> to_ind,value;
				for(int i=0;i<n;i++){
					value.push_back(eve[i].first);
					to_ind.push_back(eve[i].second);
					value.push_back(odd[i].first);
					to_ind.push_back(odd[i].second);
				}
				if(N&1){
					value.push_back(eve[n].first);
					to_ind.push_back(eve[n].second);
				}
				bool none = false;
				for(int i=0;i<N-1;i++) if(value[i]>value[i+1]) none = true;
				if(none) continue;
				Inversions inv;
				inv.initsize(N);
				int cnt = inv.num_inversion(to_ind);
				if(ans==-1) ans = cnt;
				ans = min(ans,cnt);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256