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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int N;cin>>N;
  int sign = 1;
  int S = 0;
  vector<int> vec (N,0);  
  for (int i = 0; i < N; i++)
  {
    int X;cin>>X;
    S += sign*X;
    sign *= -1;
    vec[i] = X;
  }
  vector<int> res;
  res.push_back(S);
  for (int i = 0; i < N-1; i++)
  {
    res.push_back((vec[i] - res.back()/2)*2);
  }

  for (int i = 0; i < res.size(); i++)
  {
      if(i != 0)cout<<char(32);
      cout<<res[i];
  }
  cout<<endl;
  
  

  
  
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 5044
#include<stdio.h>
int main(){
   int a,n,m=0;
   double i;
   scanf("%d",&n);
   if(n!=1){
   for(a=1;a<=n;a++)
   {
       if(a%2!=0)
        m++;
   }
      i=(long double)m/n;
   }else{
       i=(long double)(m+1)/n;
   }
   printf("%.10f",i);
}


Measured memory_bytes: 128
N, K = map(int, input().split())
A = list(map(int, input().split()))

dic = {}

for a in A:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1

li = [0] * (N + 1)

#  li[i] = j  i:ボールの数 j:種類

for a in dic:
    li[dic[a]] += 1

ans = 0
k = len(dic)

for i in range(N):
    if li[i] > 0:
        if k - li[i] >= K:
            ans += i * li[i]
            k -= li[i]
        else:
            ans += i * (k - K)
            k -= li[i]

    if k <= K:
        break

print(ans)

Measured memory_bytes: 34844
ln = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a = int(input())
print(ln[a-1])

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

char s[55];

int main()
{
	int n,k;
	cin>>n>>k;
	for(int i = 1;i<=n;++i)
	    cin>>s[i];
	    
	for(int i = 1;i<=n;++i){
		if(i != k) cout<<s[i];
		else{
			if(s[i] == 'A') cout<<'a';
			else if(s[i] == 'B') cout<<'b';
			else cout<<'c';
		}
	}
	return 0;
}

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

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
   if (N) os << " ";
   os << get<N>(t);
   out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
   os << "(";
   out<0,tuple<Ts...>,Ts...>(os, t);
   os << ")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
   os << "(" << e.to << ", " << e.cost << ")";
   return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
   int N, K;
   cin >> N >> K;

   int ans;

   if (K == 1) {
      ans = 0;
   } else {
      ans = N - K;
   }

   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double PI = 3.14159265358979323846;

int main(void) {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
    ans += i * (n / i * (n / i + 1) / 2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m,k,a[10010];
char s[10010];
main()
{
	scanf("%d%d%d",&n,&m,&k);
	if (k==0)
	{
		puts("Yes");
		return 0;
	}
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
		{
			if (k==i*j+(n-i)*(m-j))
			{
				puts("Yes");
				return 0;
			}
		}
	puts("No");
}

Measured memory_bytes: 128
import java.util.Scanner

val sc = Scanner(System.`in`)
val n = sc.nextInt()
val k = sc.nextInt()
val s = sc.next()

fun main(args: Array<String>) {
    var rst: String = ""
    for (i in 0 until n) {
        if (k-1 == i) {
            rst += if ('A' == s[i]) {
                "a"
            } else if ('B' == s[i]) {
                "b"
            } else {
                "c"
            }
        } else {
            rst += s[i]
        }
    }
    println(rst)
}

Measured memory_bytes: 29592
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n = II()
    d = defaultdict(int)
    a = LI()
    ans = 1
    d[0] = 3
    for i in range(n):
        y = d[a[i]]
        ans *= y
        ans %= mod
        d[a[i]] -= 1
        d[a[i] + 1] += 1
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


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

using namespace std;
typedef long long ll;

ll N,K;
ll R,S,P;
string T;
ll dp[100000][3];

int main(){
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            dp[i][j] = 0;
        }
    }
    for(int base=0;base<K;base++){
        if(T[base] == 'r'){
            dp[base][2] += P;
        }
        if(T[base] == 's'){
            dp[base][0] += R;
        }
        if(T[base] == 'p'){
            dp[base][1] += S;
        }
        for(int i=1;base+i*K<N;i++){
            if(T[base+i*K] == 'r'){
                dp[base+i*K][2] = P + max(dp[base+(i-1)*K][0],dp[base+(i-1)*K][1]);
                dp[base+i*K][0] = max(dp[base+(i-1)*K][1],dp[base+(i-1)*K][2]);
                dp[base+i*K][1] = max(dp[base+(i-1)*K][0],dp[base+(i-1)*K][2]);
            }
            if(T[base+i*K] == 's'){
                dp[base+i*K][0] = R + max(dp[base+(i-1)*K][1],dp[base+(i-1)*K][2]);
                dp[base+i*K][1] = max(dp[base+(i-1)*K][0],dp[base+(i-1)*K][2]);
                dp[base+i*K][2] = max(dp[base+(i-1)*K][0],dp[base+(i-1)*K][1]);
            }
            if(T[base+i*K] == 'p'){
                dp[base+i*K][1] = S + max(dp[base+(i-1)*K][0],dp[base+(i-1)*K][2]);
                dp[base+i*K][0] = max(dp[base+(i-1)*K][1],dp[base+(i-1)*K][2]);
                dp[base+i*K][2] = max(dp[base+(i-1)*K][0],dp[base+(i-1)*K][1]);
            }
        }
    }
    ll score = 0;
    for(int i=0;i<K;i++){
        score += max(dp[N-1-i][0],max(dp[N-1-i][1],dp[N-1-i][2]));
    }
    cout << score << endl;
    return 0;
}

Measured memory_bytes: 2816
import sys
sys.setrecursionlimit(10**8)
input = lambda: sys.stdin.readline()[:-1]
n,q=map(int,input().split())
ab=[tuple(map(int,input().split())) for i in range(n-1)]
px=[tuple(map(int,input().split())) for i in range(q)]
# ab.sort(key=lambda tup:(tup[0],tup[1]))
visited=[0]*(n+1)
cnt=[0]*(n+1)
data=[[] for i in range(n+1)]

for i in ab:
	data[i[0]].append(i[1])
	data[i[1]].append(i[0])
for j in px:
	cnt[j[0]]+=j[1]

visited[1]=1
stack=[1]

while stack:
	v=stack.pop()
	for to in data[v]:
		if visited[to]:
			continue
		visited[to]=1
		cnt[to]+=cnt[v]
		stack.append(to)

	
print(*cnt[1:])

Measured memory_bytes: 130284
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,n[1000];

void push(int x){
  n[++top]=x;
}

int pop(){
  top--;
  return n[top+1];
}

int main(){
  int a,b;
  top=0;
  char s[100];
  while( scanf("%s",s) != EOF ){
    if ( s[0] == '+'){
      a=pop();
      b=pop();
      push(a+b);
    } else if ( s[0] == '-'){
      b=pop();
      a=pop();
      push(a-b);
    } else if ( s[0] == '*'){
      a=pop();
      b=pop();
      push(a*b);
    } else{
      push(atoi(s));
    }
  }

  printf("%d\n",pop());
  return 0;
}



Measured memory_bytes: 2108
#include <stdio.h>

int main()
{
  int i,d;

  while (scanf("%d",&d)!=EOF){
    int sum=0;
    for (i=d;i<=600-d;i+=d){
      sum+=i*i*d;
    }
    printf("%d\n",sum);
  }

  return 0;
}

Measured memory_bytes: 596
N,M = map(int,input().split())
f = [[] for i in range(N)]
for i in range(M):
    A,B = map(int,input().split())
    f[A-1].append(B-1)
    f[B-1].append(A-1)
from collections import deque
d = deque()
x = [-1]*N
for i in range(N):
    if x[i] == -1:
        x[i] = i
        d.append(f[i])
    while len(d) > 0:
        z = d.popleft()
        for j in z:
            if x[j] == -1:
                x[j] = i
                d.append(f[j])
import collections
ans = collections.Counter(x)
print(ans.most_common()[0][1])

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

struct sushi {
  int kind;
  long long taste;
};
bool operator < (const sushi &l, const sushi &r) {
  return l.taste < r.taste;
}
bool operator > (const sushi &l, const sushi &r) {
  return l.taste > r.taste;
}

int main() {
  int n, k;
  cin >> n >> k;
  priority_queue<sushi> unused_sushi;
  for ( int i = 0; i < n; i++ ) {
    int t;
    long long d;
    cin >> t >> d;
    unused_sushi.push({t, d});
  }

  long long kind_num = 0, taste_value = 0;
  vector<bool> used_kind(n+1, false);
  priority_queue<sushi, vector<sushi>, greater<sushi>> delete_sushi_list;
  for ( int i = 0; i < k; i++ ) {
    sushi tmp = unused_sushi.top();
    unused_sushi.pop();
    taste_value += tmp.taste;
    if ( used_kind[tmp.kind] ) {
      delete_sushi_list.push(tmp);
    } else {
      used_kind[tmp.kind] = true;
      kind_num++;
    }
  }

  long long ans = taste_value + (kind_num * kind_num);
  while ( unused_sushi.size() > 0 && delete_sushi_list.size() > 0 ) {
    sushi tmp = unused_sushi.top();
    unused_sushi.pop();
    if ( !used_kind[tmp.kind] ) {
      used_kind[tmp.kind] = true;
      kind_num++;
      taste_value += (tmp.taste - delete_sushi_list.top().taste);
      delete_sushi_list.pop();
      ans = max(ans, taste_value + (kind_num * kind_num));
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6588
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
#define int long long
using namespace std;
map<int,int> mope;
ll comb(int n,int k){
	ll res = 1;
	for(int i=1;i<=k;i++){
		res *= n-i+1;
		res /= i;
	}
	return res;
}
signed main(){
	int n,a,b;
	cin>>n>>a>>b;
	vector<ll> v;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		v.pb(x);
		mope[x]++;
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	if(v[0]==v[a-1]){
		int cnt = mope[v[0]];
		double ans = 1.0 * v[0];
		int ans2 = 0;
		for(int i=a;i<=min(mope[v[0]],b);i++){
			ans2 += comb(mope[v[0]],i);
		}
		cout<<setprecision(12)<<ans<<endl;
		cout<<ans2<<endl;
	}
	else{
		int cnt = mope[v[a-1]];
		double ans = 0.0;
		int fl=-1;
		for(int i=0;i<a;i++){
			ans += 1.0*v[i];
			if(v[i]!=v[a-1])fl=i;
		}
		ans /= 1.0 * a;
		int cnt2 = a-1-fl;
		int ans2 = comb(cnt,cnt2);
		cout<<setprecision(12)<<ans<<endl;
		cout<<ans2<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

int main()
{
    int n;
    cin >> n;

    vector<int> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    auto tot = accumulate(s.begin(), s.end(), 0);
    if (tot%10 != 0) {
        cout << tot << endl;
    } else {
        auto e = remove_if(s.begin(), s.end(),
                           [](int n){ return n%10==0; });
        if (e == s.begin()) {
            cout << 0 << endl;
        } else {
            cout << tot - *min_element(s.begin(), e) << endl;
        }
    }
    return 0;
}

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int X, Y, Z;

	cin >> X >> Y >> Z;
	cout << Z << ' ' << X << ' ' << Y << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		String h=sc.next();
		
		int a=N;
		int[] d=new int[N];
		
		int tmp=0;
		for(int i=0;i<N;i++){
			char y=h.charAt(i);
			if(y=='E'){
				d[i]=1;
				tmp++;
			}else{
				d[i]=0;
			}
		}
		
		tmp-=d[0];
		if(tmp<a){a=tmp;}
		
		for(int i=1;i<N;i++){
			tmp-=d[i];
			tmp+=d[i-1]^1;
			if(tmp<a){a=tmp;}
		}
		
		
		System.out.println(a);
	}
}

Measured memory_bytes: 28936
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>a>>b;
    Cout(a-b+1);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static boolean[] prime=new boolean[300001];
	static void primes(int x) {
		for(int i=2; i*x<300000; i++) {
			prime[x*i]=false;
		}
	}

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int[] numprime=new int[300000];
			int k=0;
			for(int i=2; i<300000; i++) {
				prime[i]=true;
			}
			for(int i=2; i<300000; i++) {
				if(prime[i]) {
					if(i%7==1 || i%7==6) {
						numprime[k]=i;
						k++;
						primes(i);

					}
					else {
						prime[i]=false;
					}
				}
			}

			while(sc.hasNext()) {
				int n=sc.nextInt();
				if(n==1) break;
				int count=0;
				for(int i=0; i<k; i++) {
					if(numprime[i]<=n && n%numprime[i]==0) {
						if(count==0) {
							System.out.printf("%d: %d", n, numprime[i]);
							count++;
						}
						else {
							System.out.printf(" %d", numprime[i]);
						}
					}
				}
				System.out.println();


			}
		}
	}
}


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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

int main() {
  string s;
  cin >> s;

  for (int i = 0; i < 3; ++i) {
    if (s[i] == '1') {
      s[i] = '9';
    } else {
      s[i] = '1';
    }
  }
  
  cout << stoi(s) << endl;
}

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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP(x) cerr << #x << " = " << (x) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent=false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);

template<typename T = int> inline T in() { T x; cin >> x; return x; }
template<typename T = int> inline vector<T> in(int n) { vector<T> xs(n); rep(i, n) cin >> xs[i]; return xs; }
template<typename T = int> inline vector<vector<T>> in(int n, int m) { vector<vector<T>> xs(n, vector<T>(m)); rep(i, n) rep(j, m) cin >> xs[i][j]; return xs; }

int main(void) {
	double a, b;
	cin >> a >> b;
	printf("%.12f\n", a * b / (a + b));

    return 0;
}



Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
S=get_nsp
$ans={}
def dfs(i,k,s)
  #puts "#{k} #{i} #{s}"
  w=array(10,0)
  cnt=0
  i.upto(N-3+k-1) do|j|
      if w[S[j].to_i].zero?
        if k==3
            $ans[s+S[j]]=1
        else
            dfs(j+1,k+1,s+S[j])
        end
        w[S[j].to_i]=1
        cnt+=1
      end
      break if cnt==10
  end
end
dfs(0,1,"")
#p $ans
puts $ans.size

Measured memory_bytes: 3836
def popcount(x):
    return bin(x)[2:].count("1")

def f(x):
    cnt=0
    while(x>0):
        x%=popcount(x)
        cnt+=1
    return cnt

n=int(input())
s=input()
d=s.count("1")
if d==0:
    for i in range(n):
        print(1)
elif d==1:
    if s[-1]=="1":
        for i in range(n-1):
            print(2)
        else:
            print(0)
    else:
        for i in range(n-1):
            if s[i]=="1":
                print(0)
            else:
                print(1)
        print(2)
else:
    ints=int(s,2)
    m=ints%(d-1)
    M=ints%(d+1)
    s=s[::-1]
    toaddm=-1
    toaddM=1
    res=[None for i in range(n)]
    for i in range(n):
        if s[i]=="1":
            res[i]=f((m+toaddm)%(d-1))+1
        else:
            res[i]=f((M+toaddM)%(d+1))+1
        toaddm*=2
        toaddm%=d-1
        toaddM*=2
        toaddM%=d+1
    for i in res[::-1]:
        print(i)


Measured memory_bytes: 81008
#include<iostream>
#include<cstdio>
#define MN 200000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,head[MN+5],c[MN+5],num,inq[MN+5],Fa[MN+5],cnt,found,in[MN+5],sg[MN+5],sg2[MN+5],vis[MN+5],now,f[MN+5],Vis[MN+5];
struct edge{int to,next;}e[MN+5];
inline void ins(int f,int t){e[++cnt]=(edge){t,head[f]};head[f]=cnt;}
void FindCircle(int x)
{
    if(found) return;inq[x]=1;Vis[x]=1;
    for(int i=head[x];i;i=e[i].next)
        if(inq[e[i].to])
        {
            for(int t=x;t!=e[i].to;t=Fa[t]) c[++num]=t;
            c[++num]=e[i].to;found=1;
        }
        else if(!Vis[e[i].to]) Fa[e[i].to]=x,FindCircle(e[i].to);
    inq[x]=0;
}
void Dp(int x)
{
    for(int i=head[x];i;i=e[i].next)
        if(!in[e[i].to]) Dp(e[i].to);
    ++now;for(int i=head[x];i;i=e[i].next) if(!in[e[i].to]) vis[sg[e[i].to]]=now;
    for(;vis[sg[x]]==now;++sg[x]);
    for(sg2[x]=sg[x]+1;vis[sg2[x]]==now;++sg2[x]);
}
int main()
{
    n=read();
    for(int i=1;i<=n;++i) ins(read(),i);
    for(int i=1;i<=n;++i) if(!vis[i]) FindCircle(i);
    for(int i=1;i<=num;++i) in[c[i]]=1;
    for(int i=1;i<=num;++i) Dp(c[i]);
    f[1]=sg[c[1]];
    for(int i=2;i<=num;++i) f[i]=f[i-1]==sg[c[i]]?sg2[c[i]]:sg[c[i]];
    if(f[num]!=sg[c[1]]) return 0*puts("POSSIBLE");
    f[1]=sg2[c[1]];
    for(int i=2;i<=num;++i) f[i]=f[i-1]==sg[c[i]]?sg2[c[i]]:sg[c[i]];
    if(f[num]==sg[c[1]]) return 0*puts("POSSIBLE");
    puts("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 14720
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>


using namespace std;



int main() {
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double pi = 3.1415926535;
	double ax = a * cos(2*pi*(h + m / 60.0) / 12.0);
	double ay = a * sin(2*pi*(h + m / 60.0) / 12.0);
	double bx = b * cos(2*pi*m / 60.0);
	double by = b * sin(2*pi*m / 60.0);
	printf("%0.9f", hypot(ax - bx, ay - by));
	


	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	if(s=="SUN") cout<<7;
	if(s=="MON") cout<<6;
	if(s=="TUE") cout<<5;
	if(s=="WED") cout<<4;
	if(s=="THU") cout<<3;
	if(s=="FRI") cout<<2;
	if(s=="SAT") cout<<1;
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<vector<int>> v,vz;
    REP(i,n) {
        vector<int> p(3);
        cin >> p[0] >> p[1] >> p[2];
        if (p[2] != 0) {
            v.push_back(p);
        } else {
            vz.push_back(p);
        }
    }

    REP(i,101) REP(j,101) {
        int htmp = 0;
        bool b = true;
        for(auto p:v) {
            if (htmp == 0) {
                htmp = p[2] + abs(i-p[0]) + abs(j-p[1]);
            } else {
                if (htmp != p[2] + abs(i-p[0]) + abs(j-p[1])) {
                    b = false;
                    break;
                }
            }
        }

        for(auto p:vz) {
            if ( htmp > abs(i-p[0]) + abs(j-p[1])) {
                b = false;
                break;
            }
        }

        if (b) {
            cout << i << " " << j <<" " << htmp << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[1000000];

int main()
{
	int n;
	cin>>n;
	int a[n];
	for( int i=0;i<n;i++)
		cin>>a[i];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for( int i=2;i<n;i++)
	{
		dp[i]=min(abs(a[i]-a[i-2])+dp[i-2],abs(a[i]-a[i-1])+dp[i-1]);
	}
	
	cout<<dp[n-1]<<endl;

}

Measured memory_bytes: 4420
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <math.h>
#include <typeinfo>
#include <numeric>
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
using namespace std;

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

	int m = max(A + B, max(A-B, A*B));

	cout << m << endl;

	return 0;
 
}

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

#define N 200123
#define mod 1000000007

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    if(fopen("input.in", "r")){
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n;
    long long ans = 0;
    vector<int> rd, gr, bl;
    string s;
    char a, b, c;
    cin >> n;
    cin >> s;

    for(int i = 0 ; i < n ; i++){
    	if(s[i] == 'R') rd.push_back(i);
    	if(s[i] == 'G') gr.push_back(i);
    	if(s[i] == 'B') bl.push_back(i);
    }

    for(int i = 3 ; i < n ; i++){
    	for(int j = 1 ; j < i ; j++){
    		if(s[i] == s[j]) continue;
    		a = s[i];
    		b = s[j];
    		
    		if(a > b) swap(a, b);
    		if(a == 'B' && b == 'G') c = 'R';
			if(a == 'B' && b == 'R') c = 'G';
    		if(a == 'G' && b == 'R') c = 'B';

    		int diff = i-j;
    		if(j-diff >= 0){
    			if(s[j-diff] == c) ans--;
    		}
    		if(c == 'R'){
    			ans += (long long)(lower_bound(rd.begin(), rd.end(), j) - rd.begin()); 
    		} else if(c == 'G'){
    			ans += (long long)(lower_bound(gr.begin(), gr.end(), j) - gr.begin());
    		} else {
    			ans += (long long)(lower_bound(bl.begin(), bl.end(), j) - bl.begin());
    		}
    	}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3664
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
from numba import njit

MOD = 10**9 + 7

N = int(readline())
S = np.array(list(read().rstrip()), np.int8)

R = np.sum(S == ord('R'))
B = np.sum(S == ord('B'))
G = np.sum(S == ord('G'))

@njit
def f(S):
    N = len(S)
    ret = 0
    for i in range(N):
        for j in range(i + 1, N):
            k = j + j - i
            if k >= N:
                break
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                ret += 1
    return ret

answer = R * B * G - f(S)
print(answer)


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

int main(){
    int X;
    cin >> X;

    int flag = 0;
    if(X == 3){
       cout << "YES" << endl; 
       flag = 1;
    }
    if(X == 5){
       cout << "YES" << endl; 
       flag = 1;
    }
    if(X == 7){
       cout << "YES" << endl; 
       flag = 1;
    }

    if(flag != 1){
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int h[5050], p[5050], a[5050];
int n;
LL dp[5050];
int compare(int k1, int k2) {
	return h[k1] + p[k1] < h[k2] + p[k2];
}

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> h[i] >> p[i];
	}
	for (int i = 1; i <= n; i++) a[i] = i;
	sort(a + 1, a + n + 1, compare);
	REP(i, 5050)dp[i] = HLINF;
	dp[0] = 0;
	for (int i = 1; i <= n; i++)for (int j = n; j >= 0; j--)if (dp[j] <= h[a[i]]) dp[j + 1] = min(dp[j + 1], dp[j] + p[a[i]]);
	int ans = 0;
	for (int i = 1; i <= n; i++) if (dp[i] < HLINF) ans = i;
	cout << ans << endl;
}

Measured memory_bytes: 384
n = int(input())
data = []
for i in range(n):
    data.append(list(map(int, input().split())))
data.sort(key = lambda x : x[1])
now = 0
for i in range(n):
    now += data[i][0]
    if now > data[i][1]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 116296
#include <iostream>
using namespace std;
int main() {

	int a;
	int b;

	cin >> a;
	cin >> b;

	if(a < b){
		cout << "a < b" << endl;
	}

	if (a > b) {
		cout << "a > b" << endl;
	}

	if (a == b) {
		cout << "a == b" << endl;
	}
	return 0;
}



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

static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair <int, int> > adj[MAX];

// int prim() {
//    int u, minv;
//    int d[MAX], p[MAX], color[MAX];

//    // 初期化
//    rep(i, n) {
//       d[i] = INFTY;
//       p[i] = -1;
//       color[i] = WHITE;
//    }

//    d[0] = 0;

//    while(1) {
//       minv = INFTY;
//       u = -1;

//       rep(i, n){
//          if (minv > d[i] && color[i] != BLACK) {
//             u = i;
//             minv = d[i];
//          }
//       }
//       if(u == -1) break;
//       // uの決定
//       color[u] = BLACK;

//       rep(v, n) {
//          if(color[v] != BLACK && M[u][v] != INFTY) {
//             if(d[v] > M[u][v]) {
//                d[v] = M[u][v];
//                p[v] = u;
//                color[v] = GRAY;
//             }
//          }
//       }
//    }
//    int sum = 0;
//    rep(i, n) {
//       if(p[i] != -1) sum += M[i][p[i]];
//    }
//    return sum;
// }

// void dijkstra() {
//    int minv;
//    int d[MAX], color[MAX];

//    // 初期化
//    rep(i, n) {
//       d[i] = INFTY;
//       color[i] = WHITE;
//    }

//    d[0] = 0;
//    color[0] = GRAY;

//    while(true) {
//       minv = INFTY;
//       int u = -1;
//       rep(i, n) {
//          if(minv > d[i] && color[i] != BLACK) {
//             u = i;
//             minv = d[i];
//          }
//       }
//       if (u == -1) break;

//       // 最も小さいコストのuが決まる 初回は必ず0になる
//       color[u] = BLACK;

//       rep(v, n) {
//          // 0 ~ n-1の頂点が未訪問かつuとの経路がある場合
//          if(color[v] != BLACK && M[u][v] != INFTY) {
//             // 頂点uを通った方が目的地に近い場合
//             if (d[v] > d[u] + M[u][v]) {
//                d[v] = d[u] + M[u][v];
//                color[v] = GRAY;
//             }
//          }
//       }
//    }

//    rep(i, n) {
//       cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
//    }
// }

void dijkstra() {
   priority_queue< pair<int, int> > PQ;
   int color[MAX];
   int d[MAX];

   rep(i, n) {
      d[i] = INFTY;
      color[i] = WHITE;
   }

   d[0] = 0;
   PQ.push(make_pair(0, 0));
   color[0] = GRAY;

   while(!PQ.empty()) {
      pair<int, int> f = PQ.top(); PQ.pop();
      int u = f.second;
      color[u] = BLACK;

      if( d[u] < f.first * (-1)) continue;

      rep(j, adj[u].size()) {
         int v = adj[u][j].first;
         if (color[v] == BLACK) continue;
         if (d[v] > d[u] + adj[u][j].second) {
            d[v] = d[u] + adj[u][j].second;
            PQ.push(make_pair(d[v] * (-1), v));
            color[v] = GRAY;
         }
      }
   }
   rep(i, n) {
      cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
   }
}


int main(){
   cin >> n;
   int k, c, u, v;
   rep(i, n) {
      cin >> u >> k;
      rep(j, k){
         // v は頂点 cはコスト
         cin >> v >> c;
         adj[u].push_back(make_pair(v, c));
      }
   }

   dijkstra();

   return 0;
}



Measured memory_bytes: 7984
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 int  n ;
 cin >> n ;
vector<int> A(n) ;
vector<int> B(n) ;
vector<int> 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(C.begin(),C.end()) ;
ll ans=0 ;
rep(i,n){
ll p= lower_bound(A.begin(),A.end(),B[i])-A.begin() ;
ll q= upper_bound(C.begin(),C.end(),B[i])-C.begin() ;
ans+= p*(n-q) ;
}
 
 cout <<ans<<endl ;
     return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include<math.h>
 
int main() {
	int heya[4][3][10]={0};
	int b,f,r,v=0,i,n,B,F,R;
	
	scanf("%d",&n);
	
	for(i=1;i<=n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
			heya[b-1][f-1][r-1]=heya[b-1][f-1][r-1]+v;
	}
	
	for(B=0;B<=3;B++){
		for(F=0;F<=2;F++){
			for(R=0;R<=9;R++){
				printf(" %d",heya[B][F][R]);
			}
			printf("\n");
		}
		if(B!=3){
			printf("####################\n");
		}
	}
return 0;
}

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

using ll = long long;
static const ll MOD = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  vector<int> s(n), t(m);
  for (int i = 0; i < n; i++) cin >> s.at(i);
  for (int i = 0; i < m; i++) cin >> t.at(i);
  
  vector<vector<ll>> dp(n + 1, vector<ll>(m + 1)), sum(n + 1, vector<ll>(m + 1));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (s.at(i - 1) == t.at(j - 1)) dp.at(i).at(j) = sum.at(i - 1).at(j - 1) + 1;
      else dp.at(i).at(j) = 0;
      dp.at(i).at(j) %= MOD;
      sum.at(i).at(j) = sum.at(i).at(j - 1) + sum.at(i - 1).at(j) - sum.at(i - 1).at(j - 1) + dp.at(i).at(j) + MOD;
      sum.at(i).at(j) %= MOD;
    }
  }
  
  cout << (sum.at(n).at(m) + 1) % MOD << '\n';
}

Measured memory_bytes: 62976
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<cmath>
#include<queue>
using namespace std;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",strout);
	int ans=1,n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		ans+=min(ans,k);
	}
	printf("%d\n",ans);
	return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  
  int k=-1;
  
  for(int i=b*10;i<b*10+10;i++){
    if(i*2/25==a){
      k=i;
      break;
    }
  }
  cout << k << endl;
}

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

int main() {

    int n;
    cin >> n;
    int a[100000], b[100000], c[100000];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) cin >> c[i];
    sort(b, b + n);
    sort(c, c + n);
    // あるb[i]に適合するcの数を列挙する。
    // あるiに対し、bc2[i] = Σ_{k=i}^(n-1) bc[k] とする。
    // long long bc[100000];
    long long bc2[100001];
    bc2[n] = 0;
    long long sum = 0;
    for (int i = n - 1; i >= 0; i--) {
        int p = upper_bound(c, c + n, b[i]) - c; //pは0～n
        long long v = (long long)n - (long long)p;
        sum += v;
        // bc[i] = v;
        bc2[i] = sum;
    }
    // あるa[i]に適合するb-cの数を列挙する。
    long long totalSum = 0;
    for (int i = 0; i < n; i++) {
        int p = upper_bound(b, b + n, a[i]) - b; // pは0～n
        totalSum += bc2[p];
    }
    cout << totalSum;
    return 0;

}

Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;

struct UnionFind {
        int n;
        vector<int> parent;
        vector<int> rank;
        vector<int> num;
        int find(int x) {
                if (parent[x] == x) return  x;
                return parent[x] = find(parent[x]);
        }
        UnionFind(int n_) {
                n = n_;
                parent.resize(n);
                for (int i = 0; i < n; i ++) parent[i] = i;
                rank.assign(n, 0);
                num.assign(n, 1);
        }
        void unite(int x, int y) {
                if ((x = find(x)) != (y = find(y))) {
                        if (rank[x] < rank[y]) {
                                parent[x] = y;
                                num[y] += num[x];
                        } else {
                                parent[y] = x;
                                if (rank[x] == rank[y]) rank[x] ++;
                                num[x] += num[y];
                        }
                        n --;
                }
        }
        bool same(int x, int y) { return find(x) == find(y); }
        int get() { return n; }
        int get(int x) { return num[find(x)]; }
};

long long get(long long sz1, long long sz2) {
        return sz1 * (sz1 - 1) / 2 + sz2 * (sz2 - 1) / 2;
}

int main() {
        int n, m;
        scanf("%d%d", &n, &m);
        UnionFind uf(n);
        for (int i = 0; i < m; i ++) {
                int a, b;
                scanf("%d%d", &a, &b);
                a --, b --;
                uf.unite(a, b);
        }
        int x = uf.get(0);
        int y = uf.get(1);
        if (x >= y) x = n - y;
        else y = n - x;
        printf("%lld\n", get(x, y) - m);
        return 0;
}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{
   long k, s;
   while(cin>>k>>s)
   {
       long x,cc=0,i,j;
       for(i=0;i<=k;i++)
       {
           for(j=0;j<=k;j++)
           {
               x=s-(i+j);
               if(x<=k&&x>=0)
               {
                  // cout<<x<<" ";
                    cc++;
               }

           }
       }
       cout<<cc<<"\n";

   }
    return 0;
}


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

ll n,x,S=0;
vl a,b,c;

bool f(ll t){
	vpll d(n);
	ll m=t%x,M=0,sum=0;
	for(int i=0;i<n;i++) d[i]={a[i]*b[i]+(x-a[i])*c[i],(m<a[i]?m*b[i]:a[i]*b[i]+(m-a[i])*c[i])};
	sort(d.rbegin(),d.rend());
	for(int i=0;i<t/x;i++) sum+=d[i].first;
	for(int i=0;i<n;i++){
		if(i<t/x) M=max(M,sum-d[i].first+d[i].second+d[t/x].first);
		else M=max(M,sum+d[i].second);
	}
	return M>=S;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>x;
	a=b=c=vl(n);
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i]>>c[i];
		S+=a[i]*b[i];
	}
	ll l=-1,r=n*x;
	while(r-l>1){
		ll m=(l+r)/2;
		if(f(m)) r=m;
		else l=m;
	}
	cout<<r<<endl;
}

Measured memory_bytes: 4224
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll sum = 0;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        sum ^= a[i];
    }
    rep(i,n) cout << (sum ^ a[i]) << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 4764
def comb(n,k):
  s=1
  r=min(k,n-k)
  p=10**9+7
  for c in range(r):
    s=(s*(n-c)*pow(c+1,p-2,p))%p
  return s

x,y=map(int,input().split())

if (x+y)%3:
  print(0)
else:
  m=y-(x+y)//3
  n=x-(x+y)//3
  if m < 0 or n < 0:
    print(0)
  else:
    print(comb(m+n,m))


Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    int H[N];
    for(int i=0;i<N;i++){
        cin >> H[i];
    }

    int dp[N];
    dp[0] = 0;
    for(int i=1;i<N;i++){
        dp[i] = 1569325056;
    }

    for(int i=1;i<N;i++){
        for(int j=1;j<=K;j++){
            if(i >= j){
                dp[i] = min(dp[i],(dp[i-j]+abs(H[i] - H[i-j])));
                //cout << dp[i] << endl;
            }
        }
    }

    /*

    for(int i=0;i<N;i++){
        cout << dp[i] << endl;
    }
    */

    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
x,y=map(int,input().split())
if(y%2!=0):
    print("No")
    exit()
q=y-(2*x)
if q%2 or q<0:
    print("No")
    exit()
q=q//2
r=x-q
if r<0:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 9192
n, m = map(int, input().split())
p = list(map(lambda x: int(x) - 1, input().split()))
xy = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]

par = [i for i in range(n)]
rank = [0 for _ in range(n)]


def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]


def is_same(x, y):
    return root(x) == root(y)


def union(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1


for x, y in xy:
    union(x, y)

count = 0
for i, p_i in enumerate(p):
    count += 1 if is_same(i, p_i) else 0
print(count)


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

int main(){
  string s;
  int c;
  bool tmp,a[] = {0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,0,1,0};

  while(1){
    cin >> s;
    if(s == "#")break;

    tmp = a[s[0]-'a'];
    c = 0;
    for(int i=1;i<s.size();i++){
      if(tmp != a[s[i]-'a']){
	c++;
	tmp = 1 - tmp;
      }
    }

    cout << c << endl;
  }
}

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

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var buffer = Console.ReadLine().Split(' ');
            var H = int.Parse(buffer[0]);

            var skill = new List<int>();
            buffer = Console.ReadLine().Split(' ');
            foreach (var v in buffer)
                skill.Add(int.Parse(v));
            int sum = skill.Aggregate((n1, n2) => n2 += n1);

            if (H <= sum)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 26904
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W,K;
  scanf("%d%d%d",&H,&W,&K);
  int A,B;
  long long C;
  vector<vector<long long>> Z(H+1,vector<long long>(W+1));
  for(int i=0;i<=H;i++){
    for(int j=0;j<=W;j++){
      Z[i][j]=0;
    }
  }
  for(int i=0;i<K;i++){
    scanf("%d%d%lld",&A,&B,&C);
    Z[A-1][B-1]=C;
  }
  vector<vector<vector<long long>>> DP(H+1,vector<vector<long long>>(W+1,vector<long long>(5)));
  for(int i=0;i<=H;i++){
    for(int j=0;j<=W;j++){
      for(int k=0;k<5;k++){
        DP[i][j][k]=0;
      }
    }
  }
  DP[0][0][1]=Z[0][0];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      for(int k=0;k<4;k++){
        DP[i+1][j][0]=max(DP[i+1][j][0],DP[i][j][k]);
        DP[i+1][j][1]=max(DP[i+1][j][1],DP[i][j][k]+Z[i+1][j]);
        DP[i][j+1][k]=max(DP[i][j+1][k],DP[i][j][k]);
        DP[i][j+1][k+1]=max(DP[i][j+1][k+1],DP[i][j][k]+Z[i][j+1]);
      }
    }
  }
  long long ANS=0;
  for(int i=0;i<4;i++){
    ANS=max(ANS,DP[H-1][W-1][i]);
  }
  printf("%lld",ANS);
}

Measured memory_bytes: 706652