akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>


int main(void)
{
	//変数の宣言
	
	int n;
	int p[20010];
	int q[20010];
	int i,j;
	int a[20010];
	int b[20010];
	
	//データの読み込み
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&q[i]);
		p[q[i]-1]=i+1;
	}
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	a[0]=p[0];
	b[0]=0;
	
	for(i=1;i<n;i++){
		if(p[i-1]>p[i]){
			a[i]=a[i-1]+1;
			b[i]=p[i]-a[i];
		}else{
			b[i]=b[i-1]-1;
			a[i]=p[i]-b[i];
		}
	}
	
	
/*	for(i=0;i<n;i++){
		if(i!=0) printf(" ");
		printf("%d",a[i]);
	}
	
	printf("\n");
	
	for(i=0;i<n;i++){
		if(i!=0) printf(" ");
		printf("%d",b[i]);
	}
	printf("\n");
*/	
	for(i=0;i<n;i++){
		b[i]=b[i]+a[n-1];
	}
	
	
	
	
//	printf("計算部分終了\n");
	
	//出力
	for(i=0;i<n;i++){
		if(i!=0) printf(" ");
		printf("%d",a[i]);
	}
	
	printf("\n");
	
	for(i=0;i<n;i++){
		if(i!=0) printf(" ");
		printf("%d",b[i]);
	}
	
//	printf("結果の出力終了\n");
	
	return 0;
}

Measured memory_bytes: 768
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

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

	int K, X;
	cin >> K >> X;

	if (500 * K >= X) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 888
n=int(input())

countlist=[0]*n
maxn=int(n**0.5)
for i in range(1,maxn+1):
    for j in range(1,maxn+1):
        for k in range(1,maxn+1):
            tmp=i**2+j**2+k**2+i*j+j*k+k*i
            if tmp <= n :
                countlist[tmp-1] += 1

for count in countlist:
    print(count)

Measured memory_bytes: 9492
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] d = new int[n];
		for (int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
		}
		int sum = 0;
		for (int i = 0; i < n - 1; i++) {
			for (int j = i + 1; j < n; j++) {
				sum += d[i] * d[j];
			}
		}
		System.out.println(sum);
	}
}


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

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

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 999999999999971;
const Int INF = 1LL << 61;

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

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

Int digits(Int n) {
    return (Int)to_string(n).size();
}

bool isOK(const vector<Int> &A, Int lim, Int k) {
    Int t = 0;

    for (auto e : A) {
        t += Ceil(e, lim) - 1;
    }

    if (t <= k) {
        return true;
    } else {
        return false;
    }
}

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

    Int n, k;
    cin >> n >> k;
    vector<Int> a(n);
    Int ma = -1, mi = INF;
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
        ma = max(ma, a[i]);
        mi = min(mi, a[i]);
    }

    Int ng = 0;
    Int ok = ma;

    while (abs(ok - ng) > 1) {
        Int mid = ng + (ok - ng) / 2;

        if (isOK(a, mid, k)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    cout << ok << endl;

    return 0;
}


Measured memory_bytes: 4724
while True:
    l = input().split()
    a = int(l[0])
    b = int(l[2])
    op = l[1]
    if op == '?':
        break
    if op == '+':
        ans = a + b
        print(ans)
    elif op == '-':
        ans = a - b
        print(ans)
    elif op == '*':
        ans = a * b
        print(ans)
    elif op == '/':
        ans = int(a / b)
        print(ans)

Measured memory_bytes: 7668
#include <stdio.h>
int main(void) {
  int A[100];
  int i,j,N,k,v;

  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  for(i=0;i<N;i++){
    v = A[i];
    j = i - 1;
    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
    }
    for (k = 0; k < N-1; k++) {
      printf("%d ",A[k]);
    }
    printf("%d",A[k]);
    printf("\n");
  }
}



Measured memory_bytes: 2072
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))

N = int(input())

B = []
for i in range(N):
    B.append(int(input()))

O1 = [0,0,0]
O2 = [0,0,0]
O3 = [0,0,0]

output ="No"

for i in range(N):
    for j in range(3):
        if B[i]==A1[j]:
            O1[j]=1
        if B[i]==A2[j]:
            O2[j]=1
        if B[i]==A3[j]:
            O3[j]=1

if sum(O1)>=3:
    output = "Yes"
if sum(O2)>=3:
    output = "Yes"
if sum(O3)>=3:
    output = "Yes"
if O1[0]+O2[0]+O3[0]>=3:
    output = "Yes"
if O1[1]+O2[1]+O3[1]>=3:
    output = "Yes"
if O1[2]+O2[2]+O3[2]>=3:
    output = "Yes"
if O1[0]+O2[1]+O3[2]>=3:
    output = "Yes"
if O1[1]+O2[1]+O3[0]>=3:
    output = "Yes"
print(output)

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N + 1);
	rep(i, N + 1) {
		cin >> A[i];
	}
	vector<int> B(N);
	rep(i, N) {
		cin >> B[i];
	}
	int64_t ans = 0;
	rep(i, N) {
		if (B[i] >= A[i] + A[i + 1]) {
			ans += A[i] + A[i + 1];
			A[i + 1] = 0;
		}
		else if (B[i] >= A[i]) {
			ans += B[i];
			A[i + 1] -= B[i] - A[i];
		}
		else {
			ans += B[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;
 
//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;
 
//少数点表示
//cout << std::fixed << std::setprecision(14) << 値
 
int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    string s,t;
    cin >> s >> t;
    ll len = s.length();
    ll count = 0;
    rep(i,len){
        if(s[i]!=t[i]) count++;
    }
    cout << count <<endl;
    return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
int z,cnt;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++){
		if(z<a[i]){
			cnt++;
			z=a[i];
		}
	}
	cout<<cnt<<endl;
}


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

using namespace std;

int main(int argc, char * argv[]) {
    vector<int> b(3);
    cin >> b[0] >> b[1] >> b[2];

    swap(b[0], b[1]);
    swap(b[0], b[2]);

    cout << b[0] << " " << b[1] <<  " " << b[2] << endl;
}



Measured memory_bytes: 256
import itertools
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
from math import factorial

sys.setrecursionlimit(4100000)
from functools import lru_cache

INF = 1 << 60
MOD = 10 ** 9 + 7

#Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ここから書き始める
n, p = map(int, input().split())
is_all_even = True
a = [0] * n
a = list(map(int, input().split()))
for i in a:
    if i % 2 == 1:
        is_all_even = False
        break
ans = 0
if is_all_even:
    if p == 0:
        ans = 2 ** n
    else:
        ans = 0
else:
    ans = 2 ** (n - 1)
print(ans)


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

int main() {
  int n,k;
  cin>>n>>k;
  if ((n-1)*(n-2)/2<k) {
    cout<<-1<<endl;
    return 0;
  }
  int cnt=0;
  cout<<(n-1)*(n-2)/2-k+(n-1)<<endl;
  for (int i=1; i<n; i++) {
    cout<<1<<' '<<i+1<<endl;
  }
  for (int i=1; i<n; i++) {
    for (int j=i+1; j<n; j++) {
      if (cnt==(n-1)*(n-2)/2-k) return 0;
      cnt++;
      cout<<i+1<<' '<<j+1<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

signed main() {
    SS(ll,h,w)
    if(h==1||w==1){
        p(1);
        return 0;
    }
    ll ans=h*w/2;
    h*w%2!=0?p(ans+1):p(ans);
}


Measured memory_bytes: 256
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0):
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    n = int(input())
    if n == 1:
        print('Hello World')
    else:
        a = int(input())
        b = int(input())
        print(a + b)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38764
// atcoder/abc140/F/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<int> a(1 << n);
    cin >> a;
    sort(a.begin(), a.end());

    bool f = true;
    vector<int> b;
    b.push_back(a.back());
    a.pop_back();
    while (f && a.size()) {
      const int n = b.size();
      for (int i = 0; i < n; ++i) {
        auto itr = lower_bound(a.begin(), a.end(), b[i]);
        if (itr == a.begin()) {
          f = false;
          break;
        }
        --itr;
        b.push_back(*itr);
        a.erase(itr);
      }
    }

    cout << (f ? "Yes" : "No") << endl;
  }

  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i,N) cin >> d[i];
  int ans=0;
  while(N>1){
    rep(i,N-1) ans+=d[N-1]*d[i];
    N--;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N, cnt=0, Max_cnt=0;
  string S;
  cin >> N;
  map<string, int> M;
  rep(i, N){
    cin >> S;
    M[S]++;
    if(M.at(S)>Max_cnt) Max_cnt=M.at(S);
  }
  for(auto x:M){
    if(x.second==Max_cnt) cout << x.first << endl;
  }
}

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

int main(){
  int n,m,c[5000]={0};
  vector<int> w[5000];
  bool f=false;
  cin>>n>>m;
  for(int i=0;i<m;++i){
    int a,b;
    cin>>a>>b;--a;--b;
    w[a].push_back(b);
    ++c[b];
  }
  queue<int> q;
  for(int i=0;i<n;++i) if(!c[i]) q.push(i);
  while(!q.empty()){
    if(q.size()>1) f=true;
    n=q.front();
    cout<<n+1<<endl;
    q.pop();
    for(int i=0;i<w[n].size();++i) if(!(--c[w[n][i]])) q.push(w[n][i]);
  }
  cout<<(f?1:0)<<endl;
  return 0;
}

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s, t; cin >> s >> t;
	int n = s.size();
	if(s==t){
		cout << "Yes" << endl;
		return 0;
	}
	string u = s;
	for(int i=0;i<n;i++){
		string w = u;
		for(int j=0;j<n;j++){
			if(j==0){
				w[j] = u[n-1];
			}else{
				w[j] = u[j-1];
			}
		}
		//cout << w << endl;
		if(w==t){
			cout << "Yes" << endl;
			return 0;
		} u = w;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.List;
import java.util.Scanner;

public class Main {

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

	void run() {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[][] tb=new int[N][26];

		for (int i = 0; i < N; i++) {

			char[] buf=sc.next().toCharArray();

			for (int j = 0; j < buf.length; j++) {
				++tb[i][buf[j]-'a'];
			}

		}

		for (int j = 0; j < 26; j++) {
			int min=Integer.MAX_VALUE;
			for (int i = 0; i < N; i++) {
				min=Math.min(min,tb[i][j]);
			}

			for (int k = 0; k < min; k++) {
				System.out.print(numtochar(j));
			}
		}
	}

	//以下テンプレート

	public static String numtochar(int i) {

		String alpha="abcdefghijklmnopqrstuvwxyz";

		return alpha.substring(i, i+1);

	}

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

	static int lcm(int a, int b) {
		return a * b / gcd(a, b);
	}

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


Measured memory_bytes: 23636
#include <iostream>
#define SENTINEL 2000000000
#define MAX 200000

typedef long long llong;

using namespace std;

int L[MAX / 2 + 2], R[MAX / 2 + 2];


llong merge(int A[], int n, int left, int mid, int right)
{
	int i, j, k;
	llong cnt = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	for (i = 0; i < n1; i++) L[i] = A[left + i];
	for (i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = SENTINEL;
	R[n2] = SENTINEL;
	i = j = 0;
	for (k = left; k < right; k++)
	{
		if (L[i] <= R[j])
		{
			A[k] = L[i++];
		}
		else
		{
			A[k] = R[j++];
			cnt += n1 - i;
		}
	}
	return cnt;
}


llong mergeSort(int A[], int n, int left, int right)
{
	int mid;
	llong v1, v2, v3;
	if (left + 1 < right)
	{
		mid = (left + right) / 2;
		v1 = mergeSort(A, n, left, mid);
		v2 = mergeSort(A, n, mid, right);
		v3 = merge(A, n, left, mid, right);
		return v1 + v2 + v3;
	}
	else return 0;
}

int main()
{
	int A[MAX], n, i;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> A[i];
	}

	llong ans = mergeSort(A, n, 0, n);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4652
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=1e5+6;
int n;
LL ans[N];
struct data{
	int u,d;
	inline bool operator<(const data&rhs)const{return d==rhs.d?u<rhs.u:d>rhs.d;}
}a[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		int x;
		scanf("%d",&x);
		a[i]=(data){i,x};
	}
	sort(a+1,a+n+1);
	int id=a[1].u,cnt=a[1].d;
	for(int i=2;i<=n+1;++i)if(cnt>a[i].d){
		ans[id]+=(cnt-a[i].d)*(i-1LL);
		cnt=a[i].d;
		id=min(id,a[i].u);
	}
	for(int i=1;i<=n;++i)printf("%lld\n",ans[i]);
	return 0;
}

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

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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    ll sum = 0; 
    vector<pair<ll,pair<ll, ll>>>a(n);
    rep(i, 0, n){
        ll p, q;
        cin >> p >> q;
        a[i].first = p+q;
        a[i].second.first = p;
        a[i].second.second = q;
        sum -= q;
    }
    sort(a.begin(),a.end(),greater<pair<ll,pair<ll, ll>>>());
    
    for(int i = 0; i <n; i+=2){
        sum += a[i].first;
    }
    cout << sum << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    int cnt[2] = {0, 0};
    for (char &c : S) cnt[c - '0']++;

    int ans = min(cnt[0], cnt[1]) * 2;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<string>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> W(N);
  int sum = 0;
  for (int i=0; i<N; i++) {
    cin >> W[i];
    sum += W[i];
  }
  int ans = 10000;
  for (int i=1; i<=N-1; i++) {
    int s1 = 0;
    for (int j=0; j<i; j++) {
      s1 += W[j];
    }
    int s2 = sum-s1;
    ans = min(ans,abs(s1-s2));
  }
  cout << ans << endl;
}

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

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};

/*==================================================*/
/*variable*/
ll N;
/*==================================================*/
/*function*/

/*==================================================*/

/*
 * 意味が強い変数にi, jを使用しない.
 * 最大,最小は問題をよく読んで確認する.
 * */

int main() {

    ll ans = LLINF;

    cin>>N;
    REP(a,1,N){
        ll b = N-a;

        ll sum = 0LL;
        ll d = 10;

        REP(i,0,6){
            sum += (a%d)/(d/10);
            sum += (b%d)/(d/10);
            d*=10;
        }
        ans = min(ans, sum);

    }

    cout<<ans<<endl;


    return 0;
}


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

int main()
{
	std::string c;
	std::cin >> c;

	if (c[0] == 'a') {
		std::cout << "vowel" << std::endl;
	}
	else if (c[0] == 'i') {
		std::cout << "vowel" << std::endl;
	}
	else if (c[0] == 'u') {
		std::cout << "vowel" << std::endl;
	}
	else if (c[0] == 'e') {
		std::cout << "vowel" << std::endl;
	}
	else if (c[0] == 'o') {
		std::cout << "vowel" << std::endl;
	}
	else {
		std::cout << "consonant" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repeat(i,a,b) for(int i=(a),_=(b);i<_;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,_=(a);i>=_;i--)
#define mst(a,x) memset(a,x,sizeof(a))
#define vector basic_string
#define fi first
#define se second
#ifndef qwq
int cansel_sync=(ios::sync_with_stdio(0),cin.tie(0),0);
#endif
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=200010; const double err=1e-11; typedef long long ll; const int inf=~0u>>2; const ll INF=~0ull>>2; ll read(){ll x; if(scanf("%lld",&x)==-1)exit(0); return x;} typedef double lf; typedef long double llf; const lf pi=acos(-1.0); lf readf(){lf x; if(scanf("%lf",&x)==-1)exit(0); return x;} template<typename T> T sqr(const T &x){return x*x;} typedef pair<int,int> pii; template<typename A,typename B> ostream &operator<<(ostream &o,const pair<A,B> &x){return o<<'('<<x.fi<<','<<x.se<<')';}
const int mod=(1?1000000007:998244353); ll mul(ll a,ll b,ll m=mod){return a*b%m;} ll qpow(ll a,ll b,ll m=mod){ll ans=1; for(;b;a=mul(a,a,m),b>>=1)if(b&1)ans=mul(ans,a,m); return ans;} ll getinv(ll v,ll m=mod){return qpow(v,m-2,m);}
//#define int ll
int n,m,cnt;
lf a[N],s=0;
signed main(){
	cin>>n>>m;
	repeat(i,0,n)cin>>a[i],s+=a[i];
	s/=4*m;
	repeat(i,0,n)if(a[i]>=s-err)cnt++;
	cout<<(cnt>=m?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        string s = Console.ReadLine();
        string t = Console.ReadLine();

        int cnt = 0;

        for(var i = 0; i<s.Length; i++)
        {
            if(!(s.Substring(i,1) == t.Substring(i,1)))
            {
                cnt++;
            }
        }

        Console.WriteLine(cnt);
    }
}



Measured memory_bytes: 36828
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    string s;
    cin >> s;

    int ans = 0;
    char tmp = s[0];
    for(int i=0; i<s.size(); i++){
        if(tmp != s[i]){
            ans ++;
            tmp = s[i];
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3728
#include <stdio.h>

int main()
{
      int r,d,x,i=0,arr[20];
      scanf("%d%d%d",&r,&d,&x);
      
      arr[0]=x;
      
      while(i<10)
      {
          arr[i+1]=(r*arr[i])-d;
          printf("%d\n",arr[i+1]);
          i++;
      }
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  cout << max(a + b, max(a-b,a*b));
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
//配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

constexpr ll NOT_SPECIFIED_VALUE_MIN = INT64_MIN;
constexpr ll NOT_SPECIFIED_VALUE_MAX = INT64_MAX;

int main() {
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	cout << s << endl;
}



Measured memory_bytes: 2992
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
using namespace std;

int main(){
    int n,k,b=INT_MAX;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    for(int i=0;i<=n-k;i++){
        if(a[i+k-1]-a[i]<b){
            b=a[i+k-1]-a[i];
        }
    }
    cout << b;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

results = A[0]
can = True
zero = False
for i in range(N):
    if A[i]==0:
        zero = True
        break

if zero:
    print(0)
else:
    for i in range(N):
        if i==0:
            continue
        results *= A[i]
        if results>10**18:
            can = False
            break

    if can:
        print(results)
    else:
        print(-1)

Measured memory_bytes: 88820
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <math.h>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

int main()
{
	string a, b;
	cin >> a >> b;
	if (a.at(0) == b.at(2) && a.at(2) == b.at(0) && a.at(1) == b.at(1))
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void YN(bool f){ cout << (f ? "YES" : "NO");}
void yn(bool f){ cout << (f ? "yes" : "no");}
void YeNo(bool f) {cout << (f ? "Yes" : "No");}
signed main(){
    int n,Q;
    cin >> n >> Q;
    vector<vector<int>>edge(n);
    for(int i = 0; i < n - 1; ++i){
        int a,b;
        cin >> a >> b; --a,--b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<int>cnt(n,0LL);
    vector<int>ans(n,0LL);
    vector<bool>memo(n,false);
    rep(_,Q){
        int p,x; cin >> p >> x;
        --p;
        cnt[p] += x;
    }
    function<void(int,int)> visitor = [&](int v, int cost){
        memo[v] = true;
        for(auto nv : edge[v]){
            if(memo[nv]) continue;
            ans[nv] = cost + cnt[nv];
            visitor(nv,ans[nv]);
        }
        return;
    };
    ans[0] = cnt[0];
    visitor(0,cnt[0]);
    for(size_t i = 0; i < ans.size(); ++i){
        if(i)cout << " ";
        cout << ans[i];
    }
    cout << endl;
}


Measured memory_bytes: 28928
#include<bits/stdc++.h> 
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n,s=0,m=1e7;
	cin>>n;
	for(int i=1;i<=m;i++){
		s=s*10+7;
		if(s%n==0){
			cout<<i<<"\n";
			return 0;
		}
		s=s%n;
	}
	cout<<-1<<"\n"; 
	return 0;
}


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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;

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


int main() {
    int x; cin >> x;
    if (x == 7 || x == 5 || x == 3) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


    


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long d = sc.nextLong();
    long d2 = d * d;
    int answer = 0;
    for(int i = 0; i < n; i++){
      long x = sc.nextLong();
      long y = sc.nextLong();
      long distance2 = (x * x) + (y * y);
      if(d2 >= distance2) answer++;
    }
    System.out.println(answer);
  }
}

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

ans = 'No'
for i in range(N-2):
    if (D[i][0] == D[i][1]) and (D[i+1][0]==D[i+1][1]) and  (D[i+2][0]==D[i+2][1]):
        ans = 'Yes'
print(ans)

Measured memory_bytes: 9200
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int ll
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define vi vector<int>
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
int dp[2001][2001];
int pre[2001][2001];
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int s;
	cin>>s;	
	repa(i,3,s+1){
		dp[0][i] = 1;
		add(pre[0][i],dp[0][i]);
		add(pre[0][i],pre[0][i-1]);
	}
	repa(i,1,s+1){
		repa(j,3,s+1){
			add(dp[i][j],pre[i-1][j-3]);
			// add(dp[])
		}
		repa(j,3,s+1){
			add(pre[i][j],dp[i][j]);
			add(pre[i][j],pre[i][j-1]);
		}
	}
	int ans = 0;
	rep(i,s+1){
		add(ans,dp[i][s]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 65956
<?php
fscanf(STDIN, "%s", $S);
$a = str_split($S);
$cnt = count($a);
$sum = [0];

define('STEP', 100010);
for ($i = 0; $i < $cnt - 1; $i++) {
    if ($a[$i] === 'L' && $a[$i + 1] === 'R') {
        $sum[] = $i + 1;
    }    
    if ($a[$i] === 'R' && $a[$i + 1] === 'L') {
        $sum[] = $i;
    }
}
$sum[] = $cnt;
$ans = array_pad(array(), $cnt, 0);
for ($i = 0; $i < count($sum) - 1; $i += 2) {
    for ($j = $sum[$i]; $j < $sum[$i+2]; $j++) {
        // echo $j . " ";
        $step = STEP;
        if ($a[$j] === "R") {
            $step -= $sum[$i+1] - $j;
            $loc = $sum[$i+1] + ($step % 2);
        }
        if ($a[$j] === "L") {
            $step -= $j - ($sum[$i+1] + 1);
            $loc = $sum[$i+1] + 1 - ($step % 2);
        }
        $ans[$loc]++;
    }
}
echo implode(" ", $ans);


Measured memory_bytes: 20088
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  8000000000000000037
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N;
    cin>>N;
    vector<ll> A(N);
    map<ll,ll> mp;
    rep(i,N) cin>>A[i];
    rep(i,N) ++mp[A[i]];
    ll ans=0;
    for(auto pe: mp){
        ans+=(pe.second)*(pe.second-1)/2;
    }
    rep(i,N){
        ll now=mp[A[i]];
        ll anss=ans-(now)*(now-1)/2;
        anss+=(now-1)*(now-2)/2;
        cout<< anss <<"\n";
    }



}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 11136
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    char[] c = s.toCharArray();
    long r = 0;
    long g = 0;
    long b = 0;
    for(int i = 0; i < n; i++){
      if(c[i] == 'R'){
        r++;
      }
      if(c[i] == 'G'){
        g++;
      }
      if(c[i] == 'B'){
        b++;
      }
    }
    long ans = r*g*b;
   for(int i = 0; i < n; i++) {
	   for(int j = i + 1; j < n; j++) {
		   int k = j+j-i;
		   if(k <n && c[i] != c[j] && c[j] != c[k] && c[i] !=c[k]) {
			   ans--;
		   }
	   }
   }
   System.out.println(ans);
  }
}

Measured memory_bytes: 35828
#include<bits/stdc++.h>
#define N 100005
#define ll long long
#define debug(x) cout<<#x<<":"<<x<<endl;
using namespace std;
int n;
ll ans[N],tot,A[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]),tot+=A[i];
	A[0]=A[n];
	ll res=0;
	for(int i=2;i<=n;i+=2)res+=A[i];
	ans[1]=tot-res*2;
	for(int i=2;i<=n;i++)ans[i]=A[i-1]*2-ans[i-1];
	for(int i=1;i<=n;i++)printf("%d ",ans[i]);
	return 0;
}


Measured memory_bytes: 2816
import copy

def print_tab(tab):
    for row in tab:
        print(" ".join(map(str, row)))

def tab_calc(tab):
    for row in tab:
        row.append(sum(row))
    last_row = []
    for i in range(len(tab[0])):
        last_row.append(sum((r[i] for r in tab)))
    tab.append(last_row)

if __name__ == '__main__':
    r, c = [int(s) for s in input().split()]
    tab = []
    for _ in range(r):
        row = [int(s) for s in input().split()]
        assert len(row) == c
        tab.append(row)
    tab_calc(tab)
    print_tab(tab)



Measured memory_bytes: 6392
/*
 © 2020-01-31 19:54:48 crystaalroo all Rights Reserved
*/
#include <bits/stdc++.h>
#define fore(i, a, b) for(int i = (a); i <(b); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(15);
#define sz(x) (int) (x).size()
#define f first
#define s second
#define pb push_back
using namespace std;

typedef long long lli;
typedef pair<int,int > ii;
#define ENDL '\n'
#define deb(x) cout << #x": " << (x) << endl;

int main(){_
  string s,t;
  cin>>s>>t;
  int ss=sz(s),tt=sz(t);
  int dp[ss+1][tt+1];
  ii pr[ss+1][tt+1];
  fore(i,0,ss+1)fore(j,0,tt+1){dp[i][j]=0;pr[i][j]={-1,-1};}
  fore(i,0,ss)fore(j,0,tt){
    if(s[i]==t[j]){
      if(dp[i][j]+1 > dp[i+1][j+1]){
        dp[i+1][j+1] = dp[i][j] + 1;
        pr[i+1][j+1]={i,j};
      }
    }
    else{
      if(dp[i][j+1]>dp[i+1][j]){
        if(dp[i][j+1]>dp[i+1][j+1]){
          dp[i+1][j+1] = dp[i][j+1];
          pr[i+1][j+1]={i,j+1};
        }
      }
      else{
        if(dp[i+1][j]>dp[i+1][j+1]){
          dp[i+1][j+1] = dp[i+1][j];
          pr[i+1][j+1]={i+1,j};
        }
      }
    }
  }
//  fore(i,0,ss+1){fore(j,0,tt+1)cout<<dp[i][j]<<' ';cout<<ENDL;}
    ii pos = {ss,tt};
    ii bad = {-1,-1};
    string res = "";
    while(pos!=bad){
    //  cout<<pos.f<<' '<<pos.s<<ENDL;
      if(s[pos.f-1]==t[pos.s-1] and pos.s !=0 and pos.f!=0)res+=s[pos.f-1];
      pos = pr[pos.f][pos.s];
    }
    reverse(all(res));
    //deb(sz(res));
    cout<<res;
}


Measured memory_bytes: 105856
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define lll pair<ll,ll>
#define ii pair<int, int>
#define vii vector<ii>
#define vi vector<int>
#define ff first
#define ss second
#define pb(a) push_back(a)
#define ppb() pop_back()
#define mkp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define vs vector<string>
#define vc vector<char>
#define deb1(a) cout<<#a<<" "<<a<<"\n"
#define deb2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<"\n";
#define deb3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<"\n"
#define mms0(a) memset(a,0,sizeof(a))
#define mms1(a) memset(a,-1,sizeof(a))
#define FOR(a,b,c) for(int i=(a);i<(b);i+=(c))
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define _ 0
#define mod 1000000007
using namespace std;

double dp[3000][3000];

double rec(double *data,int N,int idx,int req){
   if(req == 0) return 1;
   if(idx>N) return 0;
   if(dp[idx][req] != -1.0) return dp[idx][req];
   double Head = data[idx]*rec(data,N,idx+1,req-1);
   double Tail = (1.000 - data[idx])*rec(data,N,idx+1,req);

   //cout<<idx<<" "<<Head<<" "<<Tail<<"\n";
   return dp[idx][req] = Head + Tail;
}

void solve(){
   int N;
   cin>>N;
   double data[N+1];
   FOR(1,N+1,1) scanf("%lf",&data[i]);
   FOR(_,N+1,1) for(int j=0;j<=N+1;j++) dp[i][j] = -1.0;
   double ans = rec(data,N,1,N/2+1);
   printf("%.11lf",ans);
}




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

Measured memory_bytes: 74296
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int min2(int a, int b){
  if(a>b) return b;
  else return a;
}

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

  int B[300];
  for (int i=0; i<N-1; i++){
    cin >> B[i];
  }
  int ans = 0;
  ans += B[0];
  ans += B[N-2];
  for (int i=0; i<N-2; i++){
    ans +=  min2(B[i],B[i+1]);
  }



  cout << ans  << endl;

  return 0;
}

Measured memory_bytes: 256
fun main() {
    val s = buildString {
        next().forEach {
            when (it) {
                'B' -> if (length > 0) {
                    deleteCharAt(lastIndex)
                }
                else -> append(it)
            }
        }
    }
    println(s)
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun gcd(x: Int, y: Int): Int {
    fun innerGcd(x: Int, y: Int): Int {
        return if (x % y == 0) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

fun gcd(x: Long, y: Long): Long {
    fun innerGcd(x: Long, y: Long): Long {
        return if (x % y == 0L) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

// classes
class UnionFindTree(val size: Int) {
    private val r = sizedArray(size, -1)
    fun root(x: Int): Int {
        if (r[x] < 0) return x
        return root(r[x])
    }

    fun unite(x: Int, y: Int) {
        var rx = root(x)
        var ry = root(y)
        if (rx == ry) return
        if (r[rx] > r[ry]) {
            rx = ry.also { ry = rx }
        }
        r[rx] += r[ry]
        r[ry] = rx
    }

    fun size(x: Int) = -r[root(x)]

    override fun toString(): String {
        return r.joinToString(separator = ", ")
    }
}

Measured memory_bytes: 35668
n,a,b,c = map(int,input().split())
ans = []
S = []
for i in range(n):S.append(input())
for i in range(n):
    s = S[i]
    id = (i+1)%n
    if s=="AB":
        if a>b:
            a-=1
            b+=1
            ans.append("B")
        elif a<b:
            a+=1
            b-=1
            ans.append("A")
        elif a==b:
            if S[id] =="AC":
                a+=1
                b-=1
                ans.append("A")
            else:
                a-=1
                b+=1
                ans.append("B")

    if s=="AC":
        if a>c:
            a-=1
            c+=1
            ans.append("C")
        elif a<c:
            a+=1
            c-=1
            ans.append("A")
        elif a==c:
            if S[id] =="AB":
                a+=1
                c-=1
                ans.append("A")
            else:
                a-=1
                c+=1
                ans.append("C")

    if s=="BC":
        if b>c:
            b-=1
            c+=1
            ans.append("C")
        elif b<c:
            b+=1
            c-=1
            ans.append("B")
        elif b==c:
            if S[id] =="AC":
                c+=1
                b-=1
                ans.append("C")
            else:
                c-=1
                b+=1
                ans.append("B")

    if b<0 or c<0 or a<0:
        print("No")
        exit()
print("Yes")
for an in ans:print(an)


Measured memory_bytes: 17060
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    cin >> n;
    ll cnt = 0;
    rep(i, n){
        ll a;
        cin >> a;
        if(a&1)cnt++;
    } 
    if(cnt&1)cout << "NO";
    else cout << "YES";
}

Measured memory_bytes: 256