akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
#include <iomanip>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(1000001); //n!(mod M)
vector<ll> ifac(1000001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
void setcomb() {
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 1000000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
	}
	ifac[1000000] = mpow(fac[1000000], M - 2);
	for (ll i = 1000000; i > 0; i--) {
		ifac[i - 1] = ifac[i] * i%M;
	}
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
ll perm(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	return fac[a] * ifac[a - b] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	int n;
	cin >> n;
	cout << n * 800 - n / 15 * 200 << endl;
}


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

int main() {
    ll S, W;
    cin >> S >> W;
    if(S > W){
        cout << "safe" << endl;
    } else {
        cout << "unsafe" << endl;
    }
}

Measured memory_bytes: 3636
#include<cmath>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;

long long sum= 0;

int main()
{
	long long n, t;
	cin>> n >> t;
	long long l = 0, r = 0;
	while (n--)
	{
		long long ti = 0;
		cin>> ti;
		if (ti < l && ti + t >= l)
		{
			l = ti;
		} 
		else if (ti <= r && ti + t > r)
		{
			r = ti + t;
		} 
		else
		{
			sum += r - l;
			l = ti;
			r = ti + t;
		}
	}
	sum += r - l;
	cout<< sum <<endl;
	return 0;	
}

Measured memory_bytes: 888
N = gets.to_i
a_list = gets.strip.split(/ /).collect{|n| n.to_i - 1}


c = -1
len = 0

count = 0

(N + 1).times{|i|
	if i < N
		a = a_list[i]
	else
		a = -1
	end
	
	if c == a
		len += 1
	else
		if len % 2 == 0
			count += len / 2
		else
			count += (len - 1) / 2
		end
		c = a
		len = 1
	end
}
puts count



Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

using R = double;
constexpr R pi = acos((R)-1);
using C = complex<R>;
C& operator*=(C& l, const C& r) {
    return l = {real(l) * real(r) - imag(l) * imag(r), real(l) * imag(r) + imag(l) * real(r)};
}
void fft(V<C>& a, bool inv = false) {
    int n = a.size();
    int j = 0;
    for (int i = 1; i < n; ++i) {
        int w = n >> 1;
        while (j >= w) j -= w, w >>= 1;
        j += w;
        if (i < j) swap(a[i], a[j]);
    }
    static VV<C> xi(30);
    for (int k = 0; 1 << k < n; ++k) if (xi[k].empty()) {
        xi[k].resize(1 << k);
        for (int i = 0; i < 1 << k; ++i) {
            xi[k][i] = polar<R>(1, i * pi / (1 << k));
        }
    }
    for (int k = 0; 1 << k < n; ++k) {
        const int w = 1 << k;
        for (int s = 0; s < n; s += 2 * w) {
            for (int i = s; i < s + w; ++i) {
                j = i + w;
                C p = a[i], q = a[j] * (inv ? conj(xi[k][i - s]) : xi[k][i - s]);
                a[i] = p + q, a[j] = p - q;
            }
        }
    }
}

int main() {
    int m, n, k, l; cin >> m >> n >> k >> l;
    int N = 1 << __lg(2 * n - 1);
    VV<C> a(N, V<C>(N));
    VV<C> b(N, V<C>(N));
    for (int i = 0; i < m; ++i) for (int j = 0; j < m; ++j) {
        char c; cin >> c;
        int v = c == 'X';
        b[i][j].real(v); 
    }
    {
        string s; cin >> s;
        int x = 0, y = 0;
        for (char c : s) {
            if (c == 'U') --x;
            if (c == 'D') ++x;
            if (c == 'L') --y;
            if (c == 'R') ++y;
            a[x][y].real(a[x][y].real() + 1);
        }
    }
    auto fn = [&](VV<C>& a, bool inv = false) {
        for (auto&& v : a) fft(v, inv);
        for (int j = 1; j < N; ++j) for (int i = 0; i < j; ++i) {
            swap(a[i][j], a[j][i]);
        }
        for (auto&& v : a) fft(v, inv);
        for (int j = 1; j < N; ++j) for (int i = 0; i < j; ++i) {
            swap(a[i][j], a[j][i]);
        }
        if (inv) {
            for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) {
                a[i][j] /= N * N;
            }
        }
    };

    fn(a), fn(b);
    for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) {
        a[i][j] *= b[i][j];
    }
    fn(a, true);
    int res = 0;
    for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) {
        // cerr << a[i][j].real() << " \n"[j == N - 1];
        res += a[i][j].real() + 0.5 >= k;
    }
    cout << res << endl;
}


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

const double pi = acos(0)*2;
int main(){
	int r; cin >> r;
	double ans = 2*r*pi;
	printf("%.2lf\n", ans);
	return 0;	
}


	







Measured memory_bytes: 3712
"""
0-1ナップザック
wi = wlst[i]...i個目の重さ
vi = vlst[i]...i個目の価値

2次元

dp[i][j]...i個目までの宝で重さjの時の価値の最大
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - wi] + vi)  (wi <= j)
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])                          (wi >  j)

or

dp[j]...重さjの時の価値の最大
temp...1つ前のdp
dp[j] = max(dp[j], dp[j - 1], temp[j - wi] + vi)  (wi <= j)
dp[j] = max(dp[j], dp[j - 1])                     (wi >  j)

"""

INF = 10 ** 20

def main():
  case = 0

  while True:
    w = int(input())
    if not w:
      break
  
    case += 1
  
    n = int(input())
  
    vlst = [0]
    wlst = [0]
  
    for _ in range(n):
      vin, win = map(int, input().split(","))
      vlst.append(vin)
      wlst.append(win)

    dp = [0 for _ in range(w + 1)]
    
    for i in range(1, n + 1):
      vi, wi = vlst[i], wlst[i]
      temp = dp[:]
      for j in range(1, w + 1):
        if j >= wi:
          dp[j] = max(dp[j], dp[j - 1], temp[j - wi] + vi)
        else:
          dp[j] = max(dp[j], dp[j - 1])
  
    print("Case " + str(case) + ":")
    print(dp[w])
    print(dp.index(dp[w]))
main()



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

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

const ll MAXN = 1e5 + 10;
ll N,A,B;
ll h[MAXN];

bool check(ll val){
    vector<ll> ok;

    FOR(i,1,N) if(h[i] - B*val > 0) ok.push_back(h[i]-B*val);

    ll ans = 0;

    for(ll v:ok) ans += (v+(A-B-1))/(A-B);

    return (ans <= val);
}

void solve(){
    cin>>N>>A>>B;

    FOR(i,1,N) cin>>h[i];

    ll s = 1,e = *max_element(h+1,h+N+1);

    ll ans = e;

    while(s<=e){
        ll mid = (s+e)>>1;
        if(check(mid)) ans = mid,e = mid-1;
        else s = mid+1;
    }

    cout<<ans<<endl;
}   

signed main(){

   FastRead;    


    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}




Measured memory_bytes: 2916
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ======================================================================
    public void solve() {
    	char[] C = ns().toCharArray();
    	long ans = 0;
    	int up = 0, wk;
    	for (int i = C.length - 1; i >= 0; i--) {
			wk = (int)(C[i]-'0');
			wk += up;
			up = 0;
			if(wk >= 1 && wk <= 4) {
				ans += wk;
			} else if(wk == 5) {
				ans += 5;
				if(i > 0 && ((int)(C[i-1]-'0') >= 5)) {
					up++;
				}
			} else if(wk >= 6) {
				ans += (10 - wk);
				up++;
			} else {
				up = 0;
			}
		}
    	ans += up;
    	out.println(ans);
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 34776
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		final long N = sc.nextInt();
		final long M = sc.nextInt();
		
		//1*1か
		if(N == 1 && M == 1) {
			System.out.println(1);
		} else {
			//1列or1行か
			if(N == 1 || M == 1) {
				System.out.println(Math.max(N - 2, M - 2));
			} else {
				System.out.println((N - 2) * (M - 2));
			}
		}
	}
}


Measured memory_bytes: 20692
import math

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

    # divisors.sort()
    return divisors

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

n = int(input())
s = input()

ans = [0,0,0]
past = [0 for i in range(n)]

now = [0 for i in range(10)]
left=[]
right=[]
for i in range(n):
    now[int(s[i])] = 1
    left.append(list(now))
now = [0 for i in range(10)]
for i in range(n):
    now[int(s[n-1-i])] = 1
    right.append(list(now))

a=1
ans = [[[0 for i in range(10)] for j in range(10)] for k in range(10)]
for i in range(n-2):
    llist=left[i]
    rlist=right[n-3-i]
    nownum = int(s[i+1])
    for j in range(10):
        for k in range(10):
            if(llist[j]==1 and rlist[k]==1):
                ans[j][nownum][k]=1
ANS = 0
for i in range(10):
    for j in range(10):
        ANS += sum(ans[i][j])
print(ANS)

Measured memory_bytes: 53084
// CODE by Kazhybay Askar

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

using namespace std;
using namespace __gnu_pbds;

/*
find_by_order(k);
order_of_key(k);
ordered_set(int) s;
*/

/*
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
rng();
shuffle(permutation.begin(), permutation.end(), rng);
*/

/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC    optimize("Ofast")
#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#define F      first
#define S      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define nl     '\n'
#define ordered_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>

typedef unsigned long long ull;
typedef long long ll;
typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

const int MAXN  = 5e5  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

ll n,a[MAXN];

void solve(){
    double r;
    cin>>r;
    cout<<fixed<<setprecision(9)<<2*r*pi;
}



int main(){
    //freopen("A.in","r",stdin);
    //freopen("A.out","w",stdout);
    Speed;
    ll T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    r0;
}


Measured memory_bytes: 3772
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (h,w,d) = get!(usize,usize,usize);
    let a = get!([usize];h);
    let q = get!(usize);
    let lr = get!(usize, usize; q);

    let mut map = vec![(0,0); h*w+1];

    for i in 0..h {
        for j in 0..w {
            map[a[i][j]]=(i as isize,j as isize);
        }
    }

    let mut vec = vec![vec![0;h*w/d+1];d+1];

    for i in 1..(d+1) {
        let mut j = i+d;
        while j <= h*w {
            let x = map[j-d];
            let y = map[j]; 
            vec[i][(j-1)/d] = vec[i][(j-1)/d-1] + (x.0-y.0).abs() + (x.1-y.1).abs();
            j += d;
        }
    }

    for (l,r) in lr {
        let st = (l-1)%d+1;
        println!("{}", vec[st][(r-1)/d]-vec[st][(l-1)/d]);
    }
}


Measured memory_bytes: 18940
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

int main(){
  int n, m;
  cin >> n >> m;
  int a[m], b[m], p[n + 1][n + 1] = {0};
  REP(i, m){
    cin >> a[i] >> b[i];
    p[a[i]][b[i]] = 1;
    p[b[i]][a[i]] = 1;
  }

  vector<int> v;
  REP(i, n) v.pb(i + 1);

  int cnt, ans = 0;

  do{
    cnt = 0;
    REP(i, n - 1){
      if(p[v[i]][v[i + 1]]) cnt++;
    }
    if(cnt == n - 1) ans++;
  }while(next_permutation(v.begin() + 1, v.end()));

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
bool sortbysec(const pair<pair<string,int>,int> &a, 
              const pair<pair<string,int>,int> &b) 
{ 
	if(a.first.first==b.first.first)
		return a.first.second > b.first.second;
    return (a.first.first < b.first.first); 
} 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
       ll a,b,t,sum=0;
       cin>>a>>b>>t;
       if(a>t)
       {
           cout<<"0";
           exit(0);
       }
       for(ll i=1;;i++)
       {
           if((a*i<=t))
           {
               sum=sum+b;
           }
           else
           break;
       }
       cout<<sum;
    } 
    return 0;
}


Measured memory_bytes: 3652
// Last Change: 03/28/2019 18:09:36.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

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

  if (A <= 8 and B <= 8) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 888
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    String ans = "Yes";

    for(int i = 0; i < s.length(); i++){
      if(i % 2 == 0){
        if(s.charAt(i) == 'L'){
          ans = "No";
          break;
        }
      }
      if(i % 2 == 1){
        if(s.charAt(i) == 'R'){
        ans = "No";
        break;
        }
      }
    }

    System.out.println(ans);
  }
}


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

int main(){
	string s;
	cin>>s;
	
	int ans=700;
	if(s[0]=='o') ans+=100;
	if(s[1]=='o') ans+=100;
	if(s[2]=='o') ans+=100;	 

	cout<<ans<<endl;
}


Measured memory_bytes: 256
import math

P = [0 for k in range(100000)]
P[1] = 1
for k in range(3,100000,2):
    f = 1
    for l in range(2,int(math.sqrt(k))+1):
        if k % l == 0:
            f = 0
            break
    if f==1:
        P[k] = 1

R = [0 for k in range(100000)]
R[3] = 1
for k in range(3,100000,2):
    if P[k] and P[(k+1)//2]:
        R[k] = 1

for k in range(1,100000):
    R[k] += R[k-1]

for k in range(int(input())):
    l, r = map(int, input().split())
    print(R[r]-R[l-1])


Measured memory_bytes: 7216
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
const long long INF = numeric_limits<long long>::max();
int main() {
    ll N;
    cin >> N;
    vector<ll> datas[2];
    REP(i, 2) {
        datas[i].resize(N);
        REP(j, N) {
            cin >> datas[i][j];
        }
    }

    ll sum = 0;
    for (ll i = 0; i < N; ++i) {
        ll s = 0;
        for (ll j = 0; j <= i; ++j) {
            s += datas[0][j];
        }
        REP2(j, i, N) {
            s += datas[1][j];
        }
        sum = max(s, sum);
    }

    PR(sum);
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	scanf("%lld",&n);
	ll b;
	n-=1;
	if(n%2==0)
	b=n/2*(n+1);
	else b=(n+1)/2*n;
	printf("%lld\n",b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        cin >> b[i];
    }
    rep(i,n){
        cin >> c[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    auto ita = a.begin();
    auto itc = c.begin();
    ll cnt = 0;
    rep(i,n){
        ita = lower_bound(a.begin(),a.end(),b[i]);
        itc = upper_bound(c.begin(), c.end(), b[i]);
        cnt += (ita - a.begin()) * (c.end() - itc);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <set>
#include <vector>
using namespace std;

int main(){

    int n, W;
    int weight[110],value[110];

    int dp[110][10010];

    cin >> n >> W;
    for(int i = 0; i < n; ++i) cin >> value[i] >> weight[i];

    for(int w = 0; w < W; ++w) dp[0][w] = 0;

    for(int i = 0; i < n; ++i){
        for(int w = 0; w <= W; ++w){
            if(w >= weight[i]){
                dp[i+1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w]);
            }else{
               dp[i+1][w] = dp[i][w]; 
            }
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}


Measured memory_bytes: 7008
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long a = in.nextLong();
        long b = in.nextLong();
        long x = in.nextLong();
        long r = b/x - a/x;
        if(a%x == 0)r++;
        System.out.println(r);
    }
}


Measured memory_bytes: 27060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
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; }
const ll LINF=0x1fffffffffffffff;
int main(){
	ll n,k;
	cin>>n>>k;
	vector<ll> dp(n,LINF),h(n);
	rep(i,0,n) cin>>h[i];
	dp[0]=0;
	rep(i,0,n){
		rep(j,1,k+1){
			if(i-j>=0)chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int[][] css;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        css = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                css[i][j] = sc.nextInt();
            }
        }
        solve();
    }

    void solve() {
        boolean flag = true;
        if (!(css[0][0] - css[0][1] == css[1][0] - css[1][1] &&
                css[1][0] - css[1][1] == css[2][0] - css[2][1])) {
            flag = false;
        } else if (!(css[0][1] - css[0][2] == css[1][1] - css[1][2] &&
                css[1][1] - css[1][2] == css[2][1] - css[2][2])) {
            flag = false;
        }
        if (flag) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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


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

using namespace std;

typedef long long ll;

const ll mod = 998244353;

char S[303030];
ll R[101010], G[101010], B[101010], D[303030];
ll n, r, g, b, s1, s2, ans;

void mark(ll a, ll b, ll c)
{
	if(a > b && a > c) D[a] = 2;
	else if(a < b && a < c) D[a] = 0;
	else D[a] = 1;
}

int main()
{
	ll i;
	
	scanf("%lld%s", &n, S);
	
	for(i=0; i<n+n+n; i++){
		if(S[i] == 'R') R[r++] = i;
		else if(S[i] == 'G') G[g++] = i;
		else B[b++] = i;
	}
	
	for(i=0; i<n; i++){
		mark(R[i], G[i], B[i]);
		mark(G[i], B[i], R[i]);
		mark(B[i], R[i], G[i]);
	}
	
	ans = 1;
	
	for(i=0; i<n+n+n; i++){
		if(D[i] == 0) s1 ++;
		else if(D[i] == 1){
			ans = ans * s1 % mod; s1 --;
			s2 ++;
		}
		else{
			ans = ans * s2 % mod; s2 --;
		}
	}
	
	for(i=1; i<=n; i++){
		ans = ans * i % mod;
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 5248
n = int(input())
a, w, t, r = 0, 0, 0, 0
for i in range(n):
  key = input()
  if key == "AC":
    a += 1
  if key == "WA":
    w += 1
  if key == "TLE":
    t += 1
  if key == "RE":
    r += 1

print("AC x " + str(a))
print("WA x " + str(w))
print("TLE x " + str(t))
print("RE x " + str(r))

Measured memory_bytes: 9212
x,y,u,v=map(int,input().split())

p=u-x
q=v-y

S="U"*q+"R"*p+"D"*q
S+="L"*(p+1)+"U"*(q+1)+"R"*(p+1)+"D"+"R"+"D"*(q+1)+"L"*(p+1)+"U"
print(S)


Measured memory_bytes: 3060
fun main(args: Array<String>) {

//    val list = arrayListOf<Double>()
//    input.forEach { list.add(it.toDouble()) }

    while (true) {
        val input = readLine()?.split(" ") ?: return
        when (input[1]) {
            "+" -> println("${input[0].toInt() + input[2].toInt()}")
            "-" -> println("${input[0].toInt() - input[2].toInt()}")
            "*" -> println("${input[0].toInt() * input[2].toInt()}")
            "/" -> println("${input[0].toInt() / input[2].toInt()}")
            else -> return
        }
    }
}



Measured memory_bytes: 31760
# coding: utf-8
# Here your code !

def func():
    result=""
    while(True):
        try:
            line = input().rstrip()
            elements = line.split(" ")
            elements[0] = int(elements[0])
            elements[2] = int(elements[2])
        except:
            print("input error")
            return -1
        
        operator=elements[1]
        if(operator == "+"):
            print(elements[0]+elements[2])
#            result+=str(elements[0]+elements[2])+"\n"
        elif(operator == "-"):
            print(elements[0]-elements[2])
#            result+=str(elements[0]-elements[2])+"\n"
        elif(operator == "*"):
            print(elements[0]*elements[2])
#            result+=str(elements[0]*elements[2])+"\n"
        elif(operator == "/"):
            print(elements[0]//elements[2])
#            result+=str(elements[0]//elements[2])+"\n"
        elif(operator == "?"):
#            result.rstrip()
            break
        else:
            print("input error")
            return -1
        
#    print(result)

func()
    

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

int main() {
	string s;
	cin>>s;
	bool valid=false;
	int cnt=0;
	for(int i=2;i<s.length();i++)
	{ if(s[i]=='C'&&i!=s.length()-1){cnt++;}}
	if(cnt==1){valid=true;} else { cout<<"WA"; return 0;}
	
	int cc=0;
	if(valid==true&&s[0]=='A'&&s[1]!='C')
	{

	for(int i=1;i<s.length();i++)
	{
		if(islower(s[i]))
		{
			cc++;
		}
	}
	} else {cout<<"WA"; return 0;}
	if(cc==s.length()-2){cout<<"AC";}else{cout<<"WA";}
	
}

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

int main() {
    long l, r;
    cin >> l >> r;
    long min_m = 2019;
    for (long i = l; i <= r - 1; i++) {
        for (long j = i + 1; j <= r; j++) {
            if (i % 2019 == 0 || j % 2019 == 0 || (i * j) % 2019 == 0) {
                min_m = 0;
                goto out;
            }
            long ij = (i * j) % 2019;
            min_m = min(ij, min_m);
        }
    }
    out:
    cout << min_m << endl;
}

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

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

	int amari;
	cin >> a >> b;

	c = a * b;
	while (c != 0 && c != 1) {
		c = c % 2;
		//cout << c << endl;
	} 

	if (c == 0) {
		cout << "Even";
	}else{
		cout << "Odd";
	}

	
   
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
struct HopcroftKarp {
  vector<int> match;

  HopcroftKarp(int left, int right) : left(left), graph(left), match(left + right, -1), level(left) {}

  void add_edge(int u, int v) { graph[u].emplace_back(left + v); }

  int solve() {
    int res = 0;
    while (true) {
      bfs();
      int tmp = 0;
      REP(i, left) {
        if (match[i] == -1 && dfs(i)) ++tmp;
      }
      if (tmp == 0) return res;
      res += tmp;
    }
  }

private:
  int left;
  vector<vector<int> > graph;
  vector<int> level;

  void bfs() {
    fill(ALL(level), -1);
    queue<int> que;
    REP(i, left) {
      if (match[i] == -1) {
        que.emplace(i);
        level[i] = 0;
      }
    }
    while (!que.empty()) {
      int ver = que.front(); que.pop();
      for (int e : graph[ver]) if (match[e] != -1 && level[match[e]] == -1) {
        level[match[e]] = level[ver] + 1;
        que.emplace(match[e]);
      }
    }
  }

  bool dfs(int ver) {
    for (int e : graph[ver]) {
      int tmp = match[e];
      if (tmp == -1 || (level[tmp] == level[ver] + 1 && dfs(tmp))) {
        match[e] = ver;
        match[ver] = e;
        return true;
      }
    }
    return false;
  }
};

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  vector<vector<int> > a(n, vector<int>(m)); REP(i, n) REP(j, m) cin >> a[i][j];
  vector<vector<vector<int> > > type(n, vector<vector<int> >(n));
  REP(i, n) REP(j, m) type[i][(a[i][j] + m - 1) / m - 1].emplace_back(a[i][j]);
  REP(j, m) {
    HopcroftKarp hk(n, n);
    REP(x, n) REP(y, n) {
      if (type[x][y].size() > 0) hk.add_edge(x, y);
    }
    hk.solve();
    REP(i, n) {
      int match = hk.match[i] - n;
      a[i][j] = type[i][match].back();
      type[i][match].pop_back();
    }
  }
  REP(i, n) {
    REP(j, m) cout << a[i][j] << (j == m - 1 ? '\n' : ' ');
  }
  vector<vector<int> > s(m);
  REP(i, n) REP(j, m) s[j].emplace_back(a[i][j]);
  REP(j, m) {
    sort(ALL(s[j]));
    REP(i, n) a[i][j] = s[j][i];
  }
  REP(i, n) {
    REP(j, m) cout << a[i][j] << (j == m - 1 ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 1010101010;
int A[2][1000],root;
int G[2][1000][2];
int f(string s,int flag)
{
    int nowroot=root++;
    int cnt=0,i=0;
    for(;i<(int)s.size();i++)
    {
        if(s[i]=='(')cnt++;
        else if(s[i]==')')cnt--;
        if(cnt==0)break;
    }
    if(i>1)G[flag][nowroot][0]=f(s.substr(1,i-1),flag);
    else G[flag][nowroot][0]=-1;
    int j=i+2;
    for(;s[i]!=']';i++);
    A[flag][nowroot]=stoi(s.substr(j,i-j));
    if(i+3<s.size())G[flag][nowroot][1]=f(s.substr(i+2,s.size()-i-3),flag);
    else G[flag][nowroot][1]=-1;
    return nowroot;
}
string solve(int a,int b)
{
    string ans="["+to_string(A[0][a]+A[1][b])+"]";
    if(G[0][a][0]>=0&&G[1][b][0]>=0)ans="("+solve(G[0][a][0],G[1][b][0])+")"+ans;
    else ans="()"+ans;
    if(G[0][a][1]>=0&&G[1][b][1]>=0)ans+="("+solve(G[0][a][1],G[1][b][1])+")";
    else ans+="()";
    return ans;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s,t;
    cin>>s>>t;
    int aroot=f(s,0);
    root=0;
    int broot=f(t,1);
    cout<<solve(aroot,broot)<<endl;   
    return 0;
}


Measured memory_bytes: 3388
;; -*- coding:utf-8 -*-

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter O3 '(optimize (speed 3) (safety 0) (debug 0)))
  (defparameter O2 '(optimize (speed 3) (safety 1))))

(defmacro print-line (obj &optional (stream '*standard-output*))
  `(prog1 (princ ,obj ,stream) (terpri ,stream)))


;; Hauptteil


(defmacro split-and-bind (arg-lst string &body body)
  (let ((pos1 (gensym "POS"))
	(pos2 (gensym "POS"))
	(str-fixed (gensym "STR")))
    (labels ((make-bind (arg-lst &optional (init-pos1 t))
	       (if (null arg-lst)
		   `(progn ,@body)
		   `(let* ((,pos1 ,(if init-pos1 0 `(1+ ,pos2)))
			   (,pos2 (position #\space ,str-fixed :start ,pos1 :test #'char=))
			   (,(car arg-lst) (parse-integer ,str-fixed :start ,pos1 :end ,pos2)))
		      ,(make-bind (cdr arg-lst) nil)))))
      `(let ((,str-fixed ,string))
	 ,(make-bind arg-lst)))))

(deftype unum () '(integer 0 200000))
(defun main ()
  (declare #.O3)
  (let* ((n (read))
	 (m (read))
	 (island-arr (make-array (+ n 1) :element-type 'list :initial-element nil)))
    (declare (unum n m))
    (dotimes (x m)
      (split-and-bind (a b) (read-line)
	(push b (aref island-arr a))
	(push a (aref island-arr b))))
    (dolist (neighbors1 (aref island-arr 1))
      (dolist (neighbors2 (aref island-arr neighbors1))
	(when (= neighbors2 n)
	  (write-line "POSSIBLE")
	  (return-from main))))
    (write-line "IMPOSSIBLE")))

#-swank(main)


;; Für Test
(defun get-clipbrd ()
  (with-output-to-string (out)
    (run-program "C:/msys64/usr/bin/cat.exe" '("/dev/clipboard") :output out)))

(defun test ()
  (with-input-from-string (*standard-input* (delete #\return (get-clipbrd)))
    (main)))


;; Für Benchmark
(defparameter *file-path* *load-pathname*)
(defparameter *dir-path* (pathname (directory-namestring *file-path*)))
(defparameter *dat-path* (merge-pathnames "test.dat" *dir-path*))

#+swank
(with-open-file (out *dat-path*
		     :direction :output :if-exists :supersede)
  )

(defun bench ()
  (let ((*standard-output* (make-broadcast-stream)))
    (with-open-file (*standard-input* *dat-path*)
      (time (main)))))


Measured memory_bytes: 61928
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
       	int t = sc.nextInt();
      	int ans = 0;
      	if( n % x != 0 ){
          ans = n / x;
          ans++;
        }else{
          ans = n / x;
        }
      System.out.println(ans*t);
      
	}
}

Measured memory_bytes: 26972
#include <stdio.h>
int main(){
    while(1) {
        int i, j, h, w;
        scanf("%d %d", &h, &w);
        if(h == 0 && w == 0) {
            break;
        }
        for(i = 1; i <= h; i++){
            for(j = 1; j <= w; j++){
                if(i != 1 && i != h && j != 1 && j != w) {
                    printf(".");
                }else{
                    printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2044
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<queue>
#include<cmath>
#include <string>
#include<map> 
#include<deque>  
#include<vector>
#include<bitset>
#include<string>  
#include<cstring> 
#include<stack>  
#include<set>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> pll;
int n,a[100005],b[100005],c[100005];
ll ans1[100005],ans2[100005],ans;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
	}sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",b+i);
	}sort(b,b+n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",c+i);
	}sort(c,c+n);
	//cout<<endl;
	for(int i=0;i<n;i++){
	//	cout<<a[i]<<" ";
		if(i)
		ans1[i]=ans1[i-1]+lower_bound(a,a+n,b[i])-a;else
		ans1[i]=lower_bound(a,a+n,b[i])-a;
	}//cout<<endl;
	for(int i=0;i<n;i++){
	//	cout<<b[i]<<" ";
		ans2[i]=lower_bound(b,b+n,c[i])-b==0?0:ans1[(lower_bound(b,b+n,c[i])-b-1)];
		ans+=ans2[i];
	}//cout<<endl;
//	for(int i=0;i<n;i++)cout<<c[i]<<" ";cout<<endl<<endl;
//	for(int i=0;i<n;i++)cout<<ans1[i]<<" ";cout<<endl;
//	for(int i=0;i<n;i++)cout<<ans2[i]<<" ";cout<<endl;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2944
import itertools

n = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

num = [i for i in range(1, n+1)]
V = list(itertools.permutations(num))

pf, qf = False, False
for i in range(len(V)):
    if V[i] == tuple(P):
        p = i
        pf = True
    if V[i] == tuple(Q):
        q = i
        qf = True
    if pf and qf:
        break

print(abs(p-q))


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

int main( void )
{
    char x,y;
    cin >> x >> y;
    
    if ( x > y )
        cout << '>' << endl;
    else if ( x < y )
        cout << '<' << endl;
    else if ( x == y )
        cout << '=' << endl;
}


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

int main(void)
{
	int n, k;
	cin >> n >> k;
	if (k == 1) { cout << 0 << endl; }
	else{ cout << n - k << endl; }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main(){
    int a,b,c; cin >> a >> b >> c;
    if(a + b == c)print("Yes");
    else if(a + c == b)print("Yes");
    else if(b + c == a)print("Yes");
    else print("No");
}

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

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

    if(a>b){
        tmp = b;
        b = a;
        a = tmp;
    }
    if(b>c){
        tmp = c;
        c = b;
        b = tmp;
    }
    if(a>b){
        tmp = b;
        b = a;
        a = tmp;
    }

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

    return 0;
}


Measured memory_bytes: 3068
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))



def main():
    n = ii()
    a = li()

    a = sorted(a)
    
    for i in range(1,n):
        if a[i] == a[i-1]:
            print('NO')
            exit()

    print('YES')
            




main()


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

#define int ll
#define FOR(i,n,k) for(int i=n;i<k;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int D[10];

int32_t main()
{
    IOS;
    string s;
    cin>>s;
    string w="";
    FOR(i,0,s.size())
    {
        if(w=="" && s[i] == 'B') continue;
        else if(s[i] == 'B') w = w.substr(0,w.size()-1);
        else w+=s[i];
    }
    cout<<w<<"\n";
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

const (
	initialBufSize = 10000
	maxBufSize     = 100000000
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	return sc
}()

func scanIntNums() (nums []int) {
	sc.Scan()
	numString := strings.Split(sc.Text(), " ")

	nums = make([]int, len(numString))
	var err error

	for i := 0; i < len(nums); i++ {
		nums[i], err = strconv.Atoi(numString[i])
		if err != nil {
			panic(err)
		}
	}
	return nums
}

func main() {
	inputs := scanIntNums()
	S := inputs[0]
	W := inputs[1]
	if S <= W {
		fmt.Println("unsafe")
	} else {
		fmt.Println("safe")
	}
}


Measured memory_bytes: 1756
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    ll n;
    cin >> n;
    int m = 18;
    VVL cnt(m + 1, VL(m + 1));
    ll ans = 0;
    REP(i,n){
        double d;
        cin >> d;
        ll x = 1e9 * d + 0.1;
        int two = 0, five = 0;
        while (x % 2 == 0){
            x /= 2;
            two++;
        }
        while (x % 5 == 0){
            x /= 5;
            five++;
        }
        chmin(two, m);
        chmin(five, m);
        REP(i,m+1) REP(j,m+1){
            if (two + i >= m && five + j >= m) ans += cnt[i][j];
        }
        cnt[two][five]++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> x(n);
	rep(i, n) cin >> x[i];
	int ans = 0;
	rep(i,n){
		ans += min(2*abs(x[i]), 2*abs(k-x[i]));
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256