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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n,m;
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl; 
    return 0;
}

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

const int N = 1e5 + 50;

int n, pos, a[N];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%d", a + i);
	sort(a + 1, a + 1 + n, greater<int> () );
	for(pos = 1; pos <= n; ++pos) {
		if(a[pos] < pos) break;
	}
	--pos;
	cerr << "pos = " << pos << '\n';
	if((a[pos] - pos) & 1) return 0 * puts("First");
	for(int j = n; j > pos; --j) {
		if(a[j] == pos) {
			if((j - pos) & 1)
				return 0 * puts("First");
			break;
		}
	}
	puts("Second");
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
	long long int n,l;
	scanf("%lld%lld",&n,&l);
	int i;
	int a[100009];
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int lastcut=-1;
	for(i=0;i<n-1;i++){
		if(a[i]+a[i+1]>=l){
			lastcut=i+1;
			break;
		}
	}
	if(lastcut==-1){
		printf("Impossible\n");
	}else{
		printf("Possible\n");
		for(i=1;i<lastcut;i++){
			printf("%d\n",i);
		}
		for(i=n-1;i>=lastcut;i--){
			printf("%d\n",i);
		}
	}

	return 0;

}


Measured memory_bytes: 1152
import itertools
import math

N = int(input())

town = []
for n in range(N):
    town.append(list(map(int, input().split())))

dis ={}

for i in range(len(town)):
    for j in range(i+1, len(town)):
        distance = math.sqrt((town[i][0] - town[j][0])**2 + (town[i][1] - town[j][1])**2)
        dis[str(i)+str(j)] = distance
        dis[str(j)+str(i)] = distance
permutations = list(itertools.permutations(list(range(N))))

all_dis = 0
for p in permutations:
    for i in range(len(p)-1):
        all_dis += dis[str(p[i])+str(p[i+1])]

print(all_dis / len(permutations))

Measured memory_bytes: 13820
//go:generate echo "https://atcoder.jp/contests/dp/tasks/dp_a"
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) IntSlice(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func iabs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func solve(n int, heights []int) int {
	t := make([]int, n+1, n+1)
	for i := range t {
		t[i] = math.MaxInt64
	}

	t[0] = 0
	for i := 1; i < n; i++ {
		if v := t[i-1] + iabs(heights[i]-heights[i-1]); v < t[i] {
			t[i] = v
		}
		if 1 < i {
			if v := t[i-2] + iabs(heights[i]-heights[i-2]); v < t[i] {
				t[i] = v
			}
		}
	}

	return t[n-1]
}

func main() {
	sc := newScanner(os.Stdin)
	n := sc.Int()
	heights := sc.IntSlice(n)
	ans := solve(n, heights)
	fmt.Println(ans)
}


Measured memory_bytes: 3796
import sys
from collections import Counter
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

ans = 0
for c in C:
    if c > C[c]:
        ans += C[c]
    elif c < C[c]:
        ans += C[c] - c
print(ans)

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

int main()
{
    int N;
    cin >> N;
    ll L[N+3];
    L[0] = 2, L[1] = 1;
    for(int i = 2; i <= N; ++i) 
        L[i] = L[i-1] + L[i-2];
    cout << L[N] << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
long long int A;
long double B;

int main()
{
	cin >> A >> B;
	long long int ans = (long int)(A *B+0.001);
	//10進法で、B*100はB*100の正確な値からMax2e-14くらいずれている
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3696
/*input
3
8 3
0 1
4 8
*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N
#define bit(x,y) ((x>>y)&1LL)
#define loop(x) for(int xv=1; xv<=x; xv++)

#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &a) {
	return os << '(' << a.first << ", " << a.second << ')';
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &a) {
	os << '[';
	for (unsigned int i = 0; i < a.size(); i++)
		os << a[i] << (i < a.size() - 1 ? ", " : "");
	os << ']';
	return os;
}
template <class T>
ostream &operator<<(ostream &os, const set<T> &a) {
	os << '{';
	for (typename set<T>::iterator it = a.begin(); it != a.end(); it++) {
		typename set<T>::iterator jt = it;
		os << *it << (++jt != a.end() ? ", " : "");
	}
	os << '}';
	return os;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, map<T1, T2> &a) {
	os << "{\n";
	for (typename map<T1, T2>::iterator it = a.begin(); it != a.end(); it++) {
		typename map<T1, T2>::iterator jt = it;
		os << "  " << it->first << ": " << it->second << (++jt != a.end() ? ",\n" : "\n");
	}
	os << '}';
	return os;
}

int n;
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	bool equal = true;
	int sum = 0; int mn = 2e9;
	for (int i = 1; i <= n; i++) {
		int x, y;
		cin >> x >> y;
		if (x != y) equal = false;
		sum += x;
		if (x > y)
			mn = min(mn, y);
	}
	if (equal) cout << 0 << endl;
	else cout << sum - mn << endl;
}

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

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

int main(){
  int K;
  int sum = 0;
  cin >> K;
  rep(i, K) rep(j, K) rep(k, K){{{sum += gcd(gcd(i, j), k);}}}
  cout << sum << endl;
}


Measured memory_bytes: 3636
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
if n % k:
    print(1)
else:
    print(0)

Measured memory_bytes: 38256
// ボール: 区別あり, 箱：区別あり, 入れ方: 箱の中身は 1 つ以下
#include <iostream>
using namespace std;
const int MOD = 1000000007;

int perm(int k, int n) {
  if(k < n) return 0;
  long long ret = 1;
  for(int i = 0; i < n; i++) {
    ret *= (k - i);
    ret %= MOD;
  }
  return ret;
}

int main() {
  // kPn
  int n, k; cin >> n >> k;
  cout << perm(k, n) << endl;
  return 0;
}



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

using namespace std;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int ans = 0;
  for(int i = 0; i < N -1; i++){
    vector<bool> left(100,false);
    vector<bool> right(100,false);
    for(int j = 0; j <= i; j++){
      left[S[j] - 'a'] = true;
    }
    for(int j = i + 1; j < N; j++){
      right[S[j] - 'a'] = true;
    }
    int tmp = 0;
    for(int k = 0; k < 100; k++){
      if(left[k] && right[k]) tmp++;
    }
    ans = max(tmp, ans);
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>

const int MAXN = (int)1e5 + 3;
int64_t ans[MAXN];
std::pair<int,int> edge[MAXN];
int fa[MAXN];
int num[MAXN];

int find(int u) {
  if (fa[u] == u)
    return u;
  fa[u] = find(fa[u]);
  num[fa[u]] += num[u];
  num[u] = 0;
  return fa[u];
}

void union_set(int u, int v) {
  fa[u] = v;
  num[v] += num[u];
  num[u] = 0;
}

void solve(int n, int m) {
  ans[m + 1] = (int64_t)n * (n - 1) / 2;
  for (int i = 1; i <= n; ++i) {
    fa[i] = i;
    num[i] = 1;
  }
  for (int i = m; i > 0; --i) {
    int u = edge[i].first;
    int v = edge[i].second;
    int fau = find(u);
    int fav = find(v);
    if (fau == fav)
      ans[i] = ans[i + 1];
    else {
      ans[i] = ans[i + 1] - (int64_t)num[fau] * num[fav];
      union_set(fau, fav);
    }
  }  
}

int main() {
  int n, m;
  std::cin >> n >> m;
  for (int i = 0; i < m; ++i) 
    std::cin >> edge[i].first >> edge[i].second;
  solve(n, m);
  for (int i = 1; i <= m; ++i) 
    std::cout << ans[i] << std::endl;
  return 0;
}



Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int P=1e9+7,N=1e5+5;
int n,k;ll ans=1;
vector<int>G[100001];
void dfs(int x,int f,int res)
{
	ans*=(k-res);
	ans%=P;
	int cnt=0;
	for(int i=0;i<G[x].size();i++)
	{
		int y=G[x][i];
		if(y==f)continue;
		if(x==1)dfs(y,x,1+cnt);else dfs(y,x,2+cnt);
		cnt++;
	}
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(1,0,0);
	printf("%lld",ans);
}

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

bool solve(int,int,int,int,int);

int main()
{
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if(solve (W,H,x,y,r)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
	}
	
bool solve(int W,int H,int x,int y,int r)
{
		if(!(x > 0 && x < W && y > 0 && y < H)) return false;
		else if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) return true;
		else return false;
}

Measured memory_bytes: 3096
from math import factorial

S = int(input())
MOD = 10**9 + 7

count = 1
result = 0
while 3 * count <= S:
    # 最初に3個ずつ分配
    target = S - (3 * count)
    up = factorial(target+count-1)
    down = (factorial(target) * factorial(count-1)) % MOD

    result += ((up * pow(down, MOD - 2, MOD)) % MOD)
    result %= MOD
    count += 1

print(result)


Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>




int t, n, m, k, a[300010], q, l;
string s;


int32_t main(){
INIT
cin>>k>>s;

for(int i=0; i<min(k, (int)(s.length()) ); i++){
    cout<<s[i];
}

if(k<s.length()){
    cout<<"...";
}

return 0;
}


Measured memory_bytes: 3656
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    d=Dict{String,String}(["Sunny"=>"Cloudy","Cloudy"=>"Rainy","Rainy"=>"Sunny"])
    println(d[chomp(readline())])
end
main()

Measured memory_bytes: 164908
var
 i,x:longint;
 s:ansistring;
 s1:string;
begin
 readln(s);
 for i:=1 to 2 do
  begin
   s1:=s1+s[1];
   x:=pos(' ',s);
   delete(s,1,x);
 end;
 s1:=s1+s[1];
 writeln(s1);
end.

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

int main() {
  int64_t N,Q;
  cin>>N;
  vector<int64_t> A(100001,0);
  rep(i,N){
    int64_t a;
    cin>>a;
    A.at(a)++;
  }
  int64_t ans=0;
  rep(i,100001){
    ans+=i*A.at(i);
  }
  cin>>Q;
  rep(i,Q){
    int64_t b,c;
    cin>>b>>c;
    ans+=(c-b)*A.at(b);
    A.at(c)+=A.at(b);
    A.at(b)=0;
    cout<<ans<<endl;
  }
}



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

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

ll gcd(ll x, ll y){
  ll r;
  while((r = x % y) != 0){
    x = y;
    y = r;
  }
  return y;
}

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll i;
  for(i = 0; i < n; i++){
    cin >> a[i];
  }
  
  for(i = 0; i < n - 1; i++){
    a[i + 1] = gcd(a[i], a[i + 1]);
    //cout << i + 1 << " " << a[i + 1] << endl;
  }
    
  cout << a[n - 1] << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define INFTY 999999



int main(void){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);

    int D=B/A;

    if(D>C){
        printf("%d\n",C);
    }
    else{
        printf("%d\n",D);
    }


    return 0;
}

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

int main() {
    string a, b;
    cin >> a >> b;
    if(a.size() > b.size()) {
        cout << "GREATER" << endl;
        return 0;
    }
    if(a.size() < b.size()) {
        cout << "LESS" << endl;
        return 0;
    }
    if(a.size() == b.size()) {
        rep(i, a.size()) {
            int ai = a.at(i) - '0';
            int bi = b.at(i) - '0';
            if(ai > bi) {
                cout << "GREATER" << endl;
                return 0;
            }
            if(ai < bi) {
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
    return 0;
}

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

const int MOD = 1000000007;
struct modint {
  long long val;
  modint(long long val=0) : val((val % MOD + MOD) % MOD){}
  modint operator-() const { return modint(-val); }
  modint& operator+=(const modint a) { if ((val += a.val)     >= MOD) val -= MOD; return *this; }
  modint& operator-=(const modint a) { if ((val += MOD-a.val) >= MOD) val -= MOD; return *this; }
  modint& operator*=(const modint a) { (val *= a.val) %= MOD; return *this; }
  modint operator+(const modint a) const { return (modint)*this += a; }
  modint operator-(const modint a) const { return (modint)*this -= a; }
  modint operator*(const modint a) const { return (modint)*this *= a; }
  modint pow(long long n) const { modint r(1), m(val); while (n > 0) { if (n & 1) {r *= m;} m *= m; n >>= 1; } return r; }
  modint inv() const { return pow(MOD-2); }
  modint& operator/=(const modint a) { return (*this) *= a.inv(); }
  modint operator/(const modint a) const { return (modint)*this /= a; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  friend ostream &operator<<(ostream &os, const modint &p) { return os << p.val; }
  friend istream &operator>>(istream &is, modint &a) { long long t; is >> t; a = modint(t); return (is); }
};

struct mod_combination {
  /* initialize: O(n) */
  /* choose    : O(1) */
  vector<modint> fact, fact_inv, inv;
  mod_combination(int n) : fact(n+1, 1), fact_inv(n+1, 1), inv(n+1, 1) {
    for (int i = 2; i <= n; i++) {
      fact[i] = fact[i - 1] * i;
      inv[i] = -inv[MOD % i] * (MOD / i);
      fact_inv[i] = fact_inv[i - 1] * inv[i];
    }
  }
  modint choose(int n, int k) { return fact[n] * fact_inv[k] * fact_inv[n - k]; }
};

int n,k; 

signed main() {
  cin >> n >> k;

  mod_combination mc(n);

  modint ans = 0;
  for(int i=0; i<=min(n-1,k); i++) {
    cerr << i << "\t" << mc.choose(n,i) << "\t" <<  mc.choose(n-1, i) << endl;
    ans += mc.choose(n,i) * mc.choose(n-1, i);
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    int k,s;
    cin>>k>>s;
    //simple brute force approach whereas i was struck in finding a better soultion that works for even bigger value of x y and z
    int ans=0;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            int z=s-x-y;
            if(z>=0 && z<=k)ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //0m 1f 2r
        int[] test = new int[3];
        String result = "";
        
        while(true){
            for(int i=0; i<3; i++){
                test[i] = sc.nextInt();
            }
            
            if(test[0]==-1 && test[1]==-1 && test[2]==-1){
                break;
            }
            
            if(test[0]==-1 || test[1]==-1){
                result = "F";
            }else if(test[0]+test[1] >= 80){
                result = "A";
            }else if(test[0]+test[1] >= 65){
                result = "B";
            }else if(test[0]+test[1] >= 50){
                result = "C";
            }else if(test[0]+test[1] >= 30){
                if(test[2] >= 50){
                    result = "C";
                }else{
                    result = "D";
                }
            }else{
                result = "F";
            }
            System.out.println(result);
        }
    }
}


Measured memory_bytes: 26380
import java.util.Scanner;

public class Main {

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

		String S = sc.next();
		String haco;
		int image = 0;

		if(S.length() != 4) {
			// ここでおしまい
		}else {
			for(int i = 0; i < 4; i++) {
				haco = S.substring(i, i+1);
				if(haco.equals("+")) {
					image++;
				}else if(haco.equals("-")) {
					image--;
				}else {
					// なにもしない
				}
			}
			System.out.println(image);
		}
	}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

vector<string> explode(string const & s, char delim) {
    vector<string> result;
    istringstream iss(s);

    for (string token; getline(iss, token, delim);) {
        result.push_back(move(token));
    }
    return result;
}

void solve() {
    int n, q;
    cin >> n >> q;
    deque<pair<string, int>> que;
    string nm;
    int tm;
    REP(i, n) {
        cin >> nm >> tm;
        que.emplace_back(nm, tm);
    }
    int c = 0;
    while (!que.empty()) {
        auto p = que.front(); que.pop_front();
        if (p.second <= q) {
            cout << p.first << " " << c + p.second << endl;
            c += p.second;
        } else {
            que.emplace_back(p.first, p.second - q);
            c += q;
        }
    }
}



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

import bisect

ans=0
for i in range(n):
    num_a=bisect.bisect_left(a,b[i])
    idx_c=bisect.bisect_right(c,b[i])
    num_c=n-idx_c
    ans+=num_a*num_c
print(ans)



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

#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int main()
{
    int t, p, r;
    while (cin >> t >> p >> r, t) {
        vector<vector<int>> result(t, vector<int>(3+p,0));
        loop (t, i) result[i][0] = i+1;
        loop (r, i) {
            int tid, pid, time;
            string msg;
            cin >> tid >> pid >> time >> msg;
            if (msg == "CORRECT") {
                if (result[tid-1][pid+2] != -1) {
                    result[tid-1][1]++;
                    result[tid-1][2] += result[tid-1][pid+2]*1200 + time;
                    result[tid-1][pid+2] = -1;
                }
            } else {
                if (result[tid-1][pid+2] != -1)
                    result[tid-1][pid+2]++;
            }
        }
        sort(all(result),
                [](vector<int> a, vector<int> b) {
                    if (a[1] != b[1]) return a[1] > b[1];
                    if (a[2] != b[2]) return a[2] < b[2];
                    return a[0] < b[0];
                });
        for (auto t : result)
            cout << t[0] << ' ' << t[1] << ' ' << t[2] << endl;
    }
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
typedef long long ll;

#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card a[], int n, int l, int m, int r){
  int n1 = m-l;
  int n2 = r-m;
  rep(i, n1) L[i] = a[l+i];
  rep(i, n2) R[i] = a[m+i];
  L[n1].value = SENTINEL;
  R[n2].value = SENTINEL;
  int i = 0;
  int j = 0;
  REP(k, l, r-1){
    if(L[i].value <= R[j].value) a[k] = L[i++];
    else a[k] = R[j++];
  }
}

void mergeSort(struct Card a[], int n, int l, int r){
  if(l+1 < r){
    int m = (l+r)/2;
    mergeSort(a, n, l, m);
    mergeSort(a, n, m, r);
    merge(a, n, l, m, r);
  }
}

int partition(struct Card a[], int n, int p, int r){
  Card x = a[r];
  int i = p-1;
  REP(j, p, r){
    if(a[j].value <= x.value) swap(a[++i], a[j]);
  }
  return i;
}

void quickSort(struct Card a[], int n, int p, int r){
  if(p < r){
    int q = partition(a, n, p, r);
    quickSort(a, n, p, q-1);
    quickSort(a, n, q+1, r);
  }
}

int main(){
  int n; cin >> n;
  struct Card a[MAX], b[MAX];
  rep(i, n){
    char c;
    int v;
    cin >> c >> v;
    a[i].suit = b[i].suit = c;
    a[i].value = b[i].value = v;
  }

  mergeSort(a, n, 0, n);
  quickSort(b, n, 0, n-1);

  bool ok = true;
  rep(i, n){
    if(a[i].suit != b[i].suit){
      ok = false;
      break;
    }
  }
  cout << (ok ? "Stable" : "Not stable") << endl;

  rep(i, n){
    printf("%c %d\n", b[i].suit, b[i].value);
  }

  return 0;
}






Measured memory_bytes: 5464
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
	int n;
	while(cin >> n){
		vector<int> m(26, 1000);
		for(int i=0;i<n;i++){
			string s; cin >> s;
			vector<int> t(26, 0);
			for(int j=0;j<s.size();j++) t[s[j]-'a']++;
			for(int j=0;j<m.size();j++) m[j] = min(m[j], t[j]);
		}
		for(int i=0;i<m.size();i++){
			for(int j=0;j<m[i];j++) cout << char(i+'a');
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int h,w,i,j;
  	cin>>h>>w;
  	char a[101][101];
  	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cin>>a[i][j];
        }
    }
	for(i=0;i<w+2;i++){
		cout<<'#';
    }
  	cout<<endl;
  	for(i=0;i<h;i++){
		cout<<'#';
      for(j=0;j<w;j++){
		cout<<a[i][j];
      }
      	cout<<'#'<<endl;
    }
  for(i=0;i<w+2;i++){
		cout<<'#';
    }
}
		





Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  n <- (read::String -> Int) <$> getLine
  arr <- map (read::String -> Int) . words <$> getLine
  let all = sum arr
  let cumsum = init $ scanl1 (+) arr
  let diff = map (\val -> abs (all - 2 * val)) cumsum
  print $ minimum diff

Measured memory_bytes: 59772
#include <iostream>
#include <string>
#include <set>
using namespace std;
set<pair<char,char> >s={
	{'A','B'},{'A','D'},
	{'B','A'},{'B','C'},{'B','E'},
	{'C','B'},{'C','F'},
	{'D','A'},{'D','E'},{'D','G'},
	{'E','B'},{'E','D'},{'E','F'},{'E','H'},
	{'F','C'},{'F','E'},{'F','I'},
	{'G','D'},{'G','H'},
	{'H','E'},{'H','G'},{'H','I'},
	{'I','F'},{'I','H'},
};
int main(){
	int i;
	string str;
	for(;cin>>str;){
		for(i=1;i<str.size();i++)if(s.find(make_pair(str[i-1],str[i]))==s.end())break;
		if(i==str.size())cout<<str<<endl;
	}
}

Measured memory_bytes: 1180
while True :
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(int(a/b))
    elif op == "?":
        break



Measured memory_bytes: 5592
#include <stdio.h>
#include <stdbool.h>

int dist(int a, int b) {
	if (a < b) return b - a;
	else return a - b;
}

int main() {
	int a;
	int b;
	int c;
	int d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	
	bool res = false;
	if (dist(a, c) <= d) res = true;
	if (dist(a, b) <= d && dist(b, c) <= d) res = true;
	
	printf("%s", res ? "Yes" : "No");
	
	return 0;
}


Measured memory_bytes: 128
I=lambda:list(map(int,input().split()))
n,Ma,Mb=I()
m=[[0,0,0]]+[I()for _ in range(n)]
dp=[[[10**18]*(10*n+1)for _ in range(10*n+1)]for _ in range(n+1)]
dp[0][0][0]=0
for i in range(1,n+1):
    for j in range(10*n+1):
        if j-m[i][0]<0:
            dp[i][j]=dp[i-1][j]
            continue
        for k in range(10*n+1):
            if k-m[i][1]<0:
                dp[i][j][k]=dp[i-1][j][k]
            else:
                dp[i][j][k]=min(dp[i-1][j-m[i][0]][k-m[i][1]]+m[i][2],dp[i-1][j][k])
ans=10**18
for i in range(1,10*n+1):
    j=Mb*i/Ma
    if j==int(j) and j<10*n+2:
        ans=min(ans,dp[-1][i][int(j)])
print(-(ans==10**18)or ans)

Measured memory_bytes: 95196
import math
n = int(input())

dic = {}

cnt = 0
for i in range(n):
    s = input()
    ent = []
    lst = list(s)
    lst.sort()
    for c in lst:
        ent.append(c)

    t = tuple(ent)

    if t in dic:
        dic[t] += 1
    else:
        dic[t] = 1

for k in dic:
    v = dic[k]
    if v > 1:
        for i in range(v):
            cnt += i


print(cnt)


Measured memory_bytes: 23648
fun main(args : Array<String>) {
    val S = readLine()!!
    var index = 0
    var current = ""

    var answer = 0
    var before = ""
    while (index < S.length) {
        current += S[index]
        if (before == current) {
        } else {
            before = current
            current = ""
            answer++
        }
        index++
    }
    println(answer)
}

Measured memory_bytes: 43076
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N;
	cin >> N;
	vector<string>S(N);
	rep(i, N) {
		cin >> S[i];
	}
	int M;
	cin >> M;
	vector<string>T(M);
	rep(i, M) {
		cin >> T[i];
	}
	string A;
	int cnt = 0;
	int ans = -1;
	rep(i, N) {
		A = S[i];
		rep(j, N) {
			if (S[j] == A) {
				cnt++;
			}
		}
		rep(j, M) {
			if (T[j] == A) {
				cnt--;
			}
		}
		ans = max(ans, cnt);
		cnt = 0;
	}
	if (ans < 0) {
		cout << 0 << endl;
	}
	else {
		cout << ans << endl;
	}
}

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

long long count(long long A, long long t){
  long long ret = max(0LL,A%(2*t)-t+1) + (A/2/t)*t;
  return ret;
}

int main(){
  long long A, B;
  cin >> A >> B;
  if(A > 0) --A;
  long long ans = 0, t = 1;
  while(t <= B){
    ans += t*((count(B,t)-count(A,t))%2);
    t *= 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
while (x = gets.to_i) != 0 
    score_ary = gets.split.map(&:to_i)
    a = 0
    m = score_ary.inject(:+) / score_ary.length.to_f
    for i in score_ary 
        a += (i - m)**2        
    end
    printf("%.4f\n", (a/score_ary.length)**0.5)
end


Measured memory_bytes: 6976
#!python3

from collections import deque


def LI():
    return list(map(int, input().split()))

# input
N = int(input())
A = LI()


def main():
    dq = deque()
    rev = False
    for a in A:
        if rev:
            dq.appendleft(a)
        else:
            dq.append(a)
        rev = not rev
    
    if rev:
        dq.reverse()
    
    print(*dq)


if __name__ == "__main__":
    main()


Measured memory_bytes: 25404
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define f first
#define s second
#define mset(m,v) memset(m,v,sizeof(m))
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
long double EPS = 1e-9;
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(int x, int y) { x -= y; if (x < 0) x += mod; return x; }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
void solve() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k <= a) {
		cout << k << endl;
	}
	else if (k <= a + b) {
		cout << a << endl;
	}
	else {
		cout << a - (k - (a + b)) << endl;
	}
}
signed main()
{
	fastio;
	//cout<<fixed<<setprecision(15);
	//clock_t begin = clock();
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--) {
		solve();
	}
	//clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}


//Error?
// clear lists for every test case
// print new line for each tc
// check for int or ll
// check if problem can be solved without any heavy DS like priority_queue or map



Measured memory_bytes: 3648
def nCr(n,r):
  if n < 0 or r < 0 or n < r: return 0
  if n - r < r: r = n - r
  if r == 0: return 1
  if r == 1: return n
  
  # 分子のn*(n-1)*...がr個分続くやつ
  numerator = [n-r+k+1 for k in range(r)]
  # 分母：r!=r*(r-1)*...*3*2の要素
  denominator = [k+1 for k in range(r)]
  
  # 分母の要素で割れる部分を割っていく部分
  for p in range(2, r+1):
    # 分母は1,2,3,...rのようになっており、1は意味がないのでスキップした形か
    pivot = denominator[p-1]
    if pivot > 1:
      # 分子のX番目と分母のX-offset番目が共通の約数を持つということだと思う。piv分ずれているのだから、pivの倍数というところか
      offset = (n-r) % p
      for k in range(p-1, r, p):
        # 約分できる要素について割る
        numerator[k - offset]  /= pivot
        denominator[k] /= pivot
        
  ret = 1
  for k in range(r):
    if numerator[k] > 1: ret *= int(numerator[k])
      
  return ret


def main():
    X, Y = map(int, input().split())
    if (2*Y - X) % 3 != 0:
        print(0)
    else:
        A = (2*Y - X) // 3
        B = Y - 2*A
        print(nCr(A+B,A)%(10**9+7))


if __name__ == "__main__":
    main()

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N, K; cin >> N >> K;
  ll a[N+1]={}; 
  rep(i,N) { cin >> a[i+1]; a[i+1] += a[i]; }
  vector<ll> sum; rep(i,N+1) for (int j=i+1; j<=N; j++) sum.push_back(a[j]-a[i]);

  ll result = 0;
  for(int i=40; i>=0; i--) {
    ll now = (1ull<<i);
    int count = 0;
    for (auto x: sum) {
      if ((x&(result+now))==result+now) count++;
    }
    if (count>=K) result += now;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 6384
#include<algorithm>
#include<iostream>
#include<vector>

using namespace std;

constexpr int MAX_N = 100000;
vector<int> pre_order(MAX_N, -1);
vector<int> post_order(MAX_N, -1);
vector<int> parent(MAX_N, -1);
vector<bool> visited(MAX_N, false);

vector<vector<int>> G(MAX_N);

vector<int> ans;

void add_edge(int s, int t) {
	G[s].emplace_back(t);
	G[t].emplace_back(s);
}

void dfs(const vector<vector<int>>& G, int u = 0, int prev_u = -1, int timer = 1) {
	pre_order[u] = timer;
	post_order[u] = timer;
	++timer;

	visited[u] = true;

	for (auto&& v:G[u]) {
		if (!visited[v]) {
			parent[v] = u;
			dfs(G, v, u, timer);
			post_order[u] = min(post_order[u], post_order[v]);
		}
		else if (v != prev_u) {
			post_order[u] = min(post_order[u], pre_order[v]);
		}
	}
}

void articulation_points(const vector<vector<int>>& G, int G_sz, int root = 0) {
	dfs(G, root);
	vector<bool> used(G_sz, false);
	int root_child = 0;
	for (int j = 0; j < G_sz; ++j) {
		if (parent[j] == root)++root_child;
		if (root_child == 2) {
			ans.emplace_back(root);used[root]=true;
			break;
		}
	}
	for (int i = 1; i < G_sz; ++i) {
		if (parent[i] != root
			&&pre_order[parent[i]] <= post_order[i]
			&& !used[parent[i]]) {
		        ans.emplace_back(parent[i]);
			used[parent[i]] = true;
		}
	}
	sort(ans.begin(), ans.end());
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N, E;cin >> N >> E;
	int s, t;
	for (int i = 0; i < E; ++i) {
		cin >> s >> t;
		add_edge(s, t);
	}
        articulation_points(G, N);
	for (auto&& v : ans) {
		cout << v << endl;
	}
}

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

int main(){
	int x , y;
	cin >> x >> y;
	int ans = 0;
	if(x == 3) ans += 100000;
	if(x == 2) ans += 200000;
	if(x == 1) ans += 300000;
	if(y == 3) ans += 100000;
	if(y == 2) ans += 200000;
	if(y == 1) ans += 300000;
	if(x == 1 && y == 1) ans += 400000;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
A,B,C,K = map(int,input().split())
if(K == 0):
  ans = A - B
elif(K % 2 == 1):
  ans = B - A
else:
  ans = A - B
if(ans > 10 ** 18):
  print("Unfair")
else:
  print(str(ans))

Measured memory_bytes: 3060
N, D = map(int, input().split())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))

cnt = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        d = 0
        for xi, xj in zip(X[i], X[j]):
            d += (xi - xj)** 2
        if d ** (1 / 2) == int(d ** (1 / 2)):
            cnt += 1

print(cnt)

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

int i;

int main()
{
    int n, c, k, count, num = 0;
    cin >> n >> c >> k;
    vector<int> t(n);
    for (i = 0; i < n; i++)
    {
        cin >> t[i];
    }

    sort(t.begin(), t.end());

    for (i = 0; i < n;)
    {
        num = i;
        count++;
        while (i < n && t[i] <= t[num] + k && i - num < c)
        {
            i++;
        }

    }

    cout << count;
}

Measured memory_bytes: 640
require 'prime'

N = gets.to_i
division_result = N.prime_division
count = 0
division_result_count = division_result.map{|a| a[1]}

division_result_count.each do |result|
  for i in 1..10 ** 12
    result = result - i
    break if result < 0
    count += 1
  end
end

puts count


Measured memory_bytes: 14384
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

int main(){
  
  // read problem from input
  long long int N, tmp;
  std::vector<long long int> A, B;
  
  scanf("%lld", &N);
  for(long long int i = 0; i < N+1; i++){
    scanf("%lld", &tmp);
    A.push_back(tmp);
  }
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    B.push_back(tmp);
  }
  
  // solve problem
  long long int ans = 0;
  for(long long int i = 0; i < N; i++){
    // i-th hero cannot kill monsters in (i+1)-th city
    if(A[i] >= B[i]){
      ans += B[i];
      continue;
    }
    // i-th hero kill B[i] monsters
    else if(A[i]+A[i+1] >= B[i]){
      ans += B[i]; // defeat B[i] monsters
      A[i+1] -= B[i] - A[i]; // update A[i]
    }
    // i-th hero kill all the monsters in i-th city and (i+1)-th city
    else{
      ans += A[i] + A[i+1]; // kill all the monsters in the two cities
      A[i+1] = 0;
    }
  }
  
  std::cerr << "Answer:" << std::endl;
  std::cout << ans << std::endl;
  
  return 0;
}


Measured memory_bytes: 2548
package main

import "fmt"

func main() {
  var N, M int
  fmt.Scanf("%d %d\n", &N, &M)
  arr := make([]int, N)
  for i := 0; i < N; i++ {
    arr[i] = 0
  }
  
  for i := 0; i < M; i++ {
    var d int
    fmt.Scanf("%d\n", &d)
    for j := 0; j < d; j++ {
      var a int
      fmt.Scanf("%d", &a)
      arr[a-1] = 1
    }
  }
  cnt := 0
  for i := 0; i < N; i++ {
    if arr[i] == 0 {
      cnt++
    }
  }
  fmt.Println(cnt)
}


Measured memory_bytes: 2532
extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::fmt::{Display, Error, Formatter};
use std::ops::{Index, IndexMut, Add, AddAssign, Sub, SubAssign, Mul, MulAssign};
use std::collections::VecDeque;
use std::f32::MAX;

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}


fn main() {
    loop {
        let_all!(n: usize, m: usize, k: usize);
        if n == 0 && m == 0 && k == 0 {
            return
        }
        let mut memo = vec![0_f64; n * m + 1];
        memo[0] = 1_f64;
        for _ in 0 .. n {
            for i in 0..memo.len() {
                let idx = memo.len() - i - 1;
                if memo[idx] > 0_f64 {
                    for j in idx + 1..min(memo.len(), idx + m + 1) {
                        memo[j] += memo[idx] / m as f64;
                    }
                    memo[idx] = 0_f64;
                }
            }
        }
        let mut result = 0_f64;
        for i in 1 .. memo.len() {
            if i <= k {
                result += memo[i];
            }else {
                result += (i - k) as f64 * memo[i];
            }
        }
        println!("{:.*}", 15, result);
    }
}


Measured memory_bytes: 5056
#include<iostream>
using namespace std;
int main(){
  int x,i,g=0,c;
  for(i=0;i<10000;i++){
    cin>>x;
    g++;
  if(x==0){
    break;
  }
  cout<<"Case"<<' '<<g<<":"<<' '<<x<<'\n';
  }
  return 0;
}
      
      



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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 1e2 + 2;

set<int> s;

int findGrun() {
	for(int i=0;;i++){
		if(!s.count(i)){return i;}
	}
}

int main(){
	int n,k,i,j;
	scanf("%d %d",&n,&k);
	int a[maxn];
	for(i=0;i<n;i++){scanf("%d",&a[i]);}
	int grun[100010];
	grun[0] = 0;
	for(i=1;i<=k;i++){
		s.clear();
		for(j=0;j<n;j++){
			if(i-a[j] >= 0){
				s.insert(grun[i-a[j]]);
				// printf("diinsert: %d\n",i-a[j]);
			}
		}
		grun[i] = findGrun();
		// printf("grun[%d]: %d\n\n",i,grun[i]);
	}
	if(grun[k] == 0){printf("Second\n");}
	else{printf("First\n");}
	return 0;
};

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
ll fact[N];

ll binpow(ll a, ll b, ll p) {
	ll ret = 1;
	a %= p;
	while (b) {
		if (b & 1) ret = ret * a % p;
		a = a * a % p;
		b >>= 1;
	}
	return ret % p;
}

ll cnk(ll n, ll k) {
	return ((fact[n] * binpow(fact[k], mod-2, mod)) % mod * binpow(fact[n-k], mod-2, mod)) % mod;
}

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	fact[0] = 1;
	for (int i = 1; i <= n; i++) {
		fact[i] = (fact[i - 1] * i) % mod;
	}
	ll ans = 0;
	for (int i = 0; i <= min(n - 1, k); i++) {
		ans = (ans + (cnk(n, i) * cnk(n-1, n-i-1)) % mod) % mod;
	}
	printf("%lld\n", (ans + mod) % mod);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define pb push_back 
#define mp make_pair
using namespace std;

const int maxn=807;
typedef long long ll;

int n,m,ans,k,h,w,sx,sy;
int a[maxn][maxn];
char s[maxn][maxn];
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};

bool check(int x,int y)
{
	if(x>=1&&x<=h&&y>=1&&y<=w) return 1;
	return 0;
}

int dis(int x,int y)
{
	int ans=x-1;
	ans=min(ans,h-x);
	ans=min(ans,w-y);
	ans=min(ans,y-1);
	return ans;
}

void bfs(int x,int y)
{
	queue<pair<int,int> >q;
	q.push(mp(x,y));
	
	while(!q.empty())
	{
		int nx=q.front().first,ny=q.front().second;
		q.pop();
		if(a[nx][ny]==k) break;
		for(int i=0;i<4;++i)
		{
			int tx=nx+dx[i];
			int ty=ny+dy[i];
			if(check(tx,ty)&&a[tx][ty]==-1&&s[tx][ty]=='.')
			{
				a[tx][ty]=a[nx][ny]+1;
				q.push(mp(tx,ty));
			}
		}
	}
}

int main()
{
	int i,j;
	scanf("%d%d%d",&h,&w,&k);
	for(i=1;i<=h;++i)
	  scanf("%s",s[i]+1);
	
	for(i=1;i<=h;++i)
	  for(j=1;j<=w;++j)
	    if(s[i][j]=='S')
	      sx=i,sy=j;
	
	memset(a,-1,sizeof(a));
	
	a[sx][sy]=0;
	bfs(sx,sy);
	
	int dist=500;
	for(i=1;i<=h;++i)
	  for(j=1;j<=w;++j)
	    if(a[i][j]!=-1)
	    {
	    	dist=min(dist,dis(i,j));
	    }
	
	printf("%d",1+(dist+k-1)/k);
	return 0;
}


Measured memory_bytes: 3456
sa=list(input())
sb=list(input())
sc=list(input())
flg="a"

while True:
  if flg=="a":
    if len(sa)==0:
      break
    else:
      flg=sa[0]
      sa.pop(0)
  elif flg=="b":
    if len(sb)==0:
      break
    flg=sb[0]
    sb.pop(0)
  elif flg=="c":
    if len(sc)==0:
      break
    else:
      flg=sc[0]
      sc.pop(0)
print("A" if flg=="a" else "B" if flg=="b" else "C")

Measured memory_bytes: 61844
#include<iostream>
#include<algorithm>
using namespace std;
int N;
pair<long,int>A[2000];
long dp[2001][2001];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>A[i].first;
		A[i].second=i;
	}
	sort(A,A+N);
	reverse(A,A+N);
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<=i;j++)
		{
			int k=N-(i-j);
			dp[j+1][k]=max(dp[j+1][k],dp[j][k]+A[i].first*abs(A[i].second-j));
			dp[j][k-1]=max(dp[j][k-1],dp[j][k]+A[i].first*abs(A[i].second-(k-1)));
		}
	}
	long ans=0;
	for(int i=0;i<=N;i++)ans=max(ans,dp[i][i]);
	cout<<ans<<endl;
}


Measured memory_bytes: 26244
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,i;
  cin >> n;
  string s1,s2;
  int t=0,h=0;
   
  for(i=0;i<n;i++){
    cin >> s1 >> s2;
    if(s1.compare(s2)==0) {
      t++;h++;
    }else if(s1.compare(s2)>0) t+=3;
    else h+=3;
  }
  cout << t << " " << h << endl;
}


Measured memory_bytes: 3152
<?php

fscanf(STDIN, "%d", $n);
$l_list = explode(' ', trim(fgets(STDIN)));
$answer = 0;
for ($i = 0; $i < $n; ++$i) {
    for ($j = $i + 1; $j < $n; ++$j) {
        for ($k = $j + 1; $k < $n; ++$k) {
            if ($l_list[$i] === $l_list[$j] || $l_list[$j] === $l_list[$k] || $l_list[$k] === $l_list[$i]) {
                continue;
            }

            if ($l_list[$i] + $l_list[$j] > $l_list[$k] && $l_list[$j] + $l_list[$k] > $l_list[$i] && $l_list[$k] + $l_list[$i] > $l_list[$j]) {
                ++$answer;
            }
        }
    }
}

echo $answer;


Measured memory_bytes: 16176
#include"bits/stdc++.h"
using namespace std;

int main() {
	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
		return 0;
	}
	cout << "consonant" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
int main(){
    ll n, m, k, s, count, ans=0, onCheck;
    cin >> n >> m;
    vector<vector<ll>> M(m);
    ll check[m];
    for(ll i=0;i<m;i++){
        cin >> k;
        for(ll j=0;j<k;j++){
            cin >> s;
            M[i].push_back(s);
        }
    } 
    for(ll i=0;i<m;i++){
        cin >> check[i];
    }

    for(ll i=0;i<1<<n;i++){
        onCheck = 0;
        for(ll j=0;j<m;j++){
            count = 0;
            for(auto itr=M[j].begin();itr!=M[j].end();itr++){
                if(i & (1<<(*itr-1))){
                    count++;
                }
            }
            if(check[j] == count%2){
                onCheck++;
            }
        }
        if(onCheck==m){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
 
}


Measured memory_bytes: 256