akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
const double EPS = 1e-10;
struct Vec2 {
  double x;
  double y;

  Vec2() : x(0.0),y(0.0){} 
  Vec2(double _x,double _y) :x(_x),y(_y){}  
  
  Vec2 operator+(const Vec2& other) const { return { x + other.x , y + other.y }; }
  Vec2 operator-(const Vec2& other) const { return { x - other.x , y - other.y }; }
  bool operator==(const Vec2& other) const { return (abs(x - other.x) < EPS && abs(y - other.y) < EPS ); } 
  bool operator<(const Vec2& other) const { if(abs(x - other.x) < EPS) return y < other.y; else return x < other.x; }
 
  double dot(const Vec2& other) const { return x * other.x + y * other.y; }
  double cross(const Vec2& other) const { return x * other.y - y * other.x; }
  double length() const { return sqrt(x * x + y * y); }

  void Show() { printf("%.8f %.8f\n", x, y); }
};

struct Line {
  Vec2 s; // 始点
  Vec2 t; // 終点

  Line() : s({0, 0}), t({0, 0}) {}
  Line(Vec2 s, Vec2 t) : s(s), t(t) {}

  Vec2 V() { return t - s; }
  double dot(const Line &other) const { return (t - s).dot(other.t - other.s); }
  double cross(const Line &other) const { return (t - s).cross(other.t - other.s); }
  double length() const { return (t - s).length(); }  
};
// A とB のなす角θ cosθ, sinθ を返す
double Cos(const Line &A, const Line &B) {
  if(A.length() < EPS || B.length() < EPS) return 0;
  return A.dot(B) / (A.length()*B.length());
}
double Sin(const Line &A, const Line &B) {
  if(A.length() < EPS || B.length() < EPS) return 0;
  return A.cross(B) / (A.length()*B.length());
}
// 線分ABをB方向に長さlに延長する
Line ExpandB(const Line &AB, const double &l) {
  Line v(Vec2(0,0), Vec2(1,0));
  Vec2 d(l * Cos(v, AB), l * Sin(v, AB));
  return Line(AB.s, AB.s + d);
}

// 直線ABと点Cの距離
double DistLinePoint(const Line &AB, const Vec2 &C) {
  Line AC(AB.s, C);
  return AC.length() * abs(Sin(AB, AC));
}
// 直線AB上に点Cを射影した点
Vec2 Proj(const Line &AB, const Vec2 &C) {
  Line AC(AB.s, C);
  double l = AC.length() * Cos(AB, AC);
  Line res = ExpandB(AB, l);
  return res.t;
}

int main()
{
  Vec2 p1, p2;
  cin >> p1.x >> p1.y >> p2.x >> p2.y;
  Line AB(p1, p2);
  int q; cin >> q;
  while(q-- > 0) {
    Vec2 p;
    cin >> p.x >> p.y;
    Vec2 res = Proj(AB, p);
    res.Show();
  }
  return 0;
}



Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n, m;
    cin >> n >> m;
    int s[10][10];
    int k[10];
    int p[10];
    int a=1;
    int ans = 0;
    int count;
    for (int i = 0; i < m;i++){
        cin >> k[i];
        for (int j = 0; j < k[i];j++){
            cin >> s[i][j];
        }
    }
    for (int i = 0; i < m;i++){
        cin >> p[i];
    }
    
    for (int i = 0; i < n; i++)
    {
        a *= 2;
    }
    int list[n];
    for (int i = 0; i < a; i++){
        int light = 0;
        int x = i;
        for (int j = 0; j < n;j++){
            list[j] = x % 2;
            x /= 2;
        }
        for (int j = 0; j < m; j++)
        {
            count = 0;
            for (int l = 0; l < k[j]; l++)
            {
                if(list[s[j][l]-1]==1){
                    count++;
                }
            }
            if(p[j]==count%2){
                light++;
            }else{
                break;
            }
        }
        if (light == m)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  int N; cin >> N;
  v<int> A(N);
  unordered_map<int,int> map;
  rep(i,N){
    cin >> A[i];
    map[A[i]]++;
  }
  int ans=0;
  fore(j,map){
    ans+=j.second*(j.second-1)/2;
  }
  rep(i,N){
    cout << ans-map[A[i]]+1 << endl;
  }

  return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<pair<int,int>>S; 
	vector<pair<int, int>>E;
	for (int m = 0;m < N;++m) {
		string s;
		cin >> s;
		int num = 0;
		int mini = 0;
		for (int n = 0; n < s.size(); ++n) {
			if ('(' == s[n]){
				num++;
			}
			else {
				num--;
			}
			mini = min(num,mini);
		}
		if (num >= 0) {
			//S.push_back(make_pair(mini, num));
			S.push_back(make_pair(-mini, -num));
		}
		else {
			//E.push_back(make_pair(mini-num, -num));
			E.push_back(make_pair(-mini + num, num));
		}
	}
	//前半部は
	//miniが大きいものをから並べて
	//numも大きいものから並べる
	sort(S.begin(),S.end());
	int sum = 0;
	for (int n = 0;n<S.size();++n) {
		//cout << sum << " "<<-S[n].first<<endl;
		if (sum - S[n].first < 0) {
			cout <<"No"<<endl;
			return 0;
		}
		sum -= S[n].second;
	}
	sort(E.begin(), E.end());
	int sum2 = 0;
	for (int n = 0; n < E.size(); ++n) {
		//cout << sum << " "<<-S[n].first<<endl;
		if (sum2 - E[n].first < 0) {
			cout << "No" << endl;
			return 0;
		}
		sum2 -= E[n].second;
	}
	if (sum ==sum2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



	return 0;
}

Measured memory_bytes: 11232
A,B,M = [int(i) for i in input().split()]

a =  [int(i) for i in input().split()]
b =  [int(i) for i in input().split()]
x = [0 for i in range(M)]
y = [0 for i in range(M)]
c = [0 for i in range(M)]

ans = 1e20
for i in range(M):
    x[i], y[i], c[i] = [int(j) for j in input().split()]
    ans = min(ans, a[x[i]-1]+b[y[i]-1] - c[i])

ans = min(ans, min(a) + min(b))

print(ans)



Measured memory_bytes: 23384
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
 
#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};
 
signed main(){
    
    int H,W,h,w,a=0;
    cin>>H>>W>>h>>w;
    int ans[H][W];
    if(H%h==0&&W%w==0){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
        a=1;
    }
    
    if(H%h!=0){
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if((i+1)%h==0)ans[i][j]=-10000*(h-1)-1;
                else{
                    ans[i][j]=10000;
                }
            }
        }
    }
    
    if(W%w!=0){
        for(int i=0;i<W;i++){
            for(int j=0;j<H;j++){
                if((i+1)%w==0)ans[j][i]=-10000*(w-1)-1;
                else{
                    ans[j][i]=10000;
                }
            }
        }
    }
    
    if(a==1){
     for(int i=0;i<H;i++){
            for(int j=0;j<W-1;j++){
                cout<<ans[i][j]<<" ";
            }
            cout<<ans[i][W-1]<<endl;
        }
    }
}

Measured memory_bytes: 2816
using System;
using System.Linq;

namespace A_Iroha_and_Haiku_Easy
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x)).ToArray();

            var fiveCount = 0;
            var sevenCount = 0;
            foreach (var number in inputs)
            {
                if (number == 5)
                {
                    fiveCount++;
                }
                if (number == 7)
                {
                    sevenCount++;
                }
            }
            if ((fiveCount == 2) && (sevenCount == 1))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 13268
a, b, k = list(map(int, input().split()))

def koyaku(x):
    i = 1
    koyaku_list = []
    while i * i <= x:
        if x % i == 0:
            koyaku_list.append(i)
            koyaku_list.append(x // i)
        i += 1
    return list(set(koyaku_list))

a_koyaku = koyaku(a)
b_koyaku = koyaku(b)

common_koyaku = set(a_koyaku).intersection(set(b_koyaku))
ans = sorted(common_koyaku, reverse=True)[k-1]

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef pair<double,ll> pdl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<pdd> vdd;
typedef vector<pdi> vdi;
typedef vector<pdl> vdl;
typedef vector<string> vs;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
const ll MAXLL=0x3f3f3f3f3f3f3f3f;
const int MAX=0x3f3f3f3f;
const ll MOD=1000000007;
const ll mod=998244353;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template<class T>
void rsort(vector<T>& v){
	sort(v.rbegin(),v.rend());
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
template<class T>
bool is_sorted(vector<T>& v){
	return is_sorted(v.begin(),v.end());
}
template<class T>
bool sorted(vector<T>& v){
	return is_sorted(v);
}
void precompute(){

	return;
}
void solve(){
	int n;
	string s;
	cin>>s;
	n=s.size();
	ll ans=0;
	int temp=0;
	for(int i=0;i<n;i++){
		if(s[i]=='B'){
			temp++;
		}
		else ans+=temp;
	}
	cout<<ans;
}

int main(){
	ios::sync_with_stdio(0);
	int numberofsubtestcases=1;
//	cin>>numberofsubtestcases;
	precompute();
	for(int looping=1;looping<=numberofsubtestcases;looping++){
//		cout<<"Case #"<<looping<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3784
fun main(args: Array<String>) {
    abc083c()
}

fun abc083c() {
    val (x, y) = readLine()!!.split(" ").map { it.toLong() }

    var curr = x
    var answer = 0
    while (curr <= y) {
        curr *= 2
        answer++
    }

    println(answer)
}


Measured memory_bytes: 35980
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#define all(x) x.begin(), x.end()
#define dd(x) cout << #x << " : " << x << endl
using namespace std;
using ll = int64_t;

constexpr ll mod = 1e9+7;

ll comb(ll n, ll c) {
    const ll N = 1e5;
	static ll fact[N+1], factr[N+1], inv[N+1];
	if (!fact[0]) {
		inv[1] = fact[0] = factr[0] = 1;
        loop(i, 2, N+1) inv[i] = inv[mod % i] * (mod - mod/i) % mod;
        loop(i, 1, N+1) fact[i] = fact[i-1]*i%mod, factr[i] = factr[i-1]*inv[i]%mod;
	}
	if(c < 0 || c > n) return 0;
	return factr[c]*fact[n]%mod*factr[n-c]%mod;
}

int main(){
    int n, k; cin >> n >> k;
    vector<ll> a;
    rep(i, n) {
        ll x; cin >> x;
        a.push_back(x);
    }
    sort(all(a));

    ll ans = 0;
    rep(ri, 2){
        rep(i, n){
            if(ri) ans -= a[i]*comb(i, k-1)%mod;
            else ans += a[i]*comb(i, k-1)%mod;
        }
        reverse(all(a));
    }
    ans %= mod;
    cout << ans << endl;
    return 0;
}

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

#define int long long

int ope(int a,int b)
{
	return a + b;
}

int l_ope(int node,int lazy)
{
	return node + lazy;
}

int l_throw(int lazy)
{
	return lazy / 2;
}

int l_add(int l,int r,int x)
{
	return (r - l) * x;
}

struct LazySegment
{
	vector<int> node;
	vector<int> lazy;
	int n;


	int init = 0;

	LazySegment(const vector<int>& vec)
	{
		int sz = vec.size();

		n = 1;
		while(n < sz) n <<= 1;

		node.resize(2 * n - 1,init);
		lazy.resize(2 * n - 1,0);

		for(int i = 0;i < sz;i++)
		{
			node[n - 1 + i] = vec[i];
		}

		for(int i = n - 2;i >= 0;i--)
		{
			node[i] = ope(node[i * 2 + 1] , node[i * 2 + 2]);
		}
	}

	void eval(int k,int l,int r)
	{
		if(lazy[k] != 0)
		{
			node[k] = l_ope(node[k],lazy[k]);

			if(r - l > 1)
			{
				lazy[2 * k + 1] += l_throw(lazy[k]);
				lazy[2 * k + 2] += l_throw(lazy[k]);
			}

			lazy[k] = 0;
		}
	}

	void add_inter(int a,int b,int x,int k = 0,int l = 0,int r = -1)
	{
		if(r < 0) r = n;

		eval(k,l,r);

		if(b <= l || r <= a) return ;

		if(a <= l && r <= b)
		{
			lazy[k] += l_add(l,r,x);
			eval(k,l,r);
		}

		else
		{
			add_inter(a,b,x,2 * k + 1,l,(l + r) / 2);
			add_inter(a,b,x,2 * k + 2,(l + r) / 2,r);
			node[k] = ope(node[2 * k + 1], node[2 * k + 2]);
		}
	}

	int get_inter(int a,int b,int k = 0,int l = 0,int r = -1)
	{
		if(r < 0) r = n;

		eval(k,l,r);
		if(b <= l || r <= a) return init;

		if(a <= l && r <= b) return node[k];

		int lv = get_inter(a,b,k * 2 + 1,l , (l + r) / 2);
		int rv = get_inter(a,b,k * 2 + 2,(l + r) / 2 , r);

		return ope(lv , rv);
	}
};

signed main()
{
	int n;
	int q;
	cin >> n >> q;
	LazySegment seg(vector<int>(n,0));

	for(int i = 0;i < q;i++)
	{
		int t;
		cin >> t;
		if(t == 0)
		{
			int a,b,x;
			cin >> a >> b >> x;
			a--;
			b--;
			seg.add_inter(a,b + 1,x);
		}
		else
		{
			int a,b;
			cin >> a >> b;
			a--;
			b--;

			cout << seg.get_inter(a,b + 1) << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 7564
#include<bits/stdc++.h>
using namespace std;
     
     
//#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define pld(x) printf("%lld\n",x)
#define pd(x) printf("%d\n",x)

#define pqueue priority_queue<int,vector<int>,greater<int >> 
     
     
int main(){

	int k , x;

	sd(k); sd(x);

	for(int i = x - (k-1) ; i <= x + (k -1) ; i++){
		printf("%d ",i );
	}
           
     printf("\n");
     
     
        
    return 0;
}


Measured memory_bytes: 256
# input here
_INPUT = """\
apple
"""
"""
K = int(input())
H, W, K = map(int, input().split())
a = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(N)]
p = tuple(map(int,input().split()))
"""
def main():
    S = input()

    if S[-1] == "s":
        print(S + "es")
    else:
        print(S + "s")


            
if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools
    from collections import deque

    # sys.stdin = io.StringIO(_INPUT)
    main()

Measured memory_bytes: 65332
# https://www.leighhalliday.com/weighted-quick-union-find-algorithm-in-ruby
class UnionFind

  attr_accessor :nodes, :sizes

  def initialize(num)
    self.nodes = []
    self.sizes = []

    num.times do |n|
      self.nodes[n] = n
      self.sizes[n] = 1
    end
  end

  def root(i)
    # Loop up the chain until reaching root
    while nodes[i] != i do
      # path compression for future lookups
      nodes[i] = nodes[nodes[i]]
      i = nodes[i]
    end
    i
  end

  def union(i, j)
    rooti = root i
    rootj = root j

    # already connected
    return if rooti == rootj

    # root smaller to root of larger
    if sizes[i] < sizes[j]
      nodes[rooti] = rootj
      sizes[rootj] += sizes[rooti]
    else
      nodes[rootj] = rooti
      sizes[rooti] += sizes[rootj]
    end
  end

  def connected?(i, j)
    root(i) == root(j)
  end

end

N, M = gets.split.map &:to_i
P = gets.split.map &:to_i
xy = $<.map{|s|
  s.split.map &:to_i
}


uf = UnionFind.new(N)
xy.each{|x, y|
  uf.union(x-1, y-1)
}

p N.times.count{|i|
  uf.connected?(i,P[i]-1)
}


Measured memory_bytes: 20740
from collections import defaultdict

N = int(input())
A = list(map(int,input().split()))

d = defaultdict(int)

for i in A:
    d[i] += 1

Q = int(input())

res = sum(A)

for _ in range(Q):
    b,c = map(int,input().split())
    res -= b*d[b]
    res += c*d[b]
    d[c] += d[b]
    d[b] = 0

    print(res)

Measured memory_bytes: 23996
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n, m, q = map(int,input().split())
    ABCD = [None] * q
    for i in range(q):
        a, b, c, d = map(int,input().split())
        ABCD[i] = (a, b, c, d)

    def dfs(A):
        # base case
        if len(A) == n + 1: # score を計算して返す
            # print(A)
            score = 0
            for a, b, c, d in ABCD:
                if A[b] - A[a] == c:
                    score += d
            return score
        # iterate
        res = -INF
        for i in range(A[-1], m + 1):
            res = max(res, dfs(A + [i]))
        return res

    print(dfs([1]))
resolve()

Measured memory_bytes: 73568
N = int(input())
S = list(input())
WL = 0
WR = 0
BL = 0
BR = 0

for i in range(N):
    if S[i] == '#':
        BR += 1
    else:
        WR += 1

ans = BL+WR

for i in range(N):
    if S[i] == '#':
        BR -= 1
        BL += 1
    else:
        WR -= 1
        WL += 1
    ans = min(ans,BL+WR)
print(ans)


Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
     ll n;
     cin>>n;
     ll s=n/500;
     s=s*1000;
     ll d=n%500;
     ll q=d/5;
     s=s+q*5;
     cout<<s<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/


ll f(string s)
{
	ll ans = 0;
	RREP(i, s.size())
	{
		ll a = 0;
		if (s[i] == 'i') {
			a = 1;
			if (i > 0 && isdigit(static_cast<unsigned char>(s[i - 1]))) {

				a *= s[i - 1] - '0';
			}
		}
		if (s[i] == 'x') {
			a = 10;
			if (i > 0 && isdigit(static_cast<unsigned char>(s[i - 1]))) {
				a *= s[i - 1] - '0';
			}
		}
		if (s[i] == 'c') {
			a = 100;
			if (i > 0 && isdigit(static_cast<unsigned char>(s[i - 1]))) {
				a *= s[i - 1] - '0';
			}
		}
		if (s[i] == 'm') {
			a = 1000;
			if (i > 0 && isdigit(static_cast<unsigned char>(s[i - 1]))) {
				a *= s[i - 1] - '0';
			}
		}
		ans += a;
	}
	return ans;
}

//string fa(ll x)
void fa(ll x)
{
	string s;
	ll a[4];
	a[0] = x / 1000;
	x -= a[0] * 1000;
	a[1] = x / 100;
	x -= a[1] * 100;
	a[2] = x / 10;
	x -= a[2] * 10;
	a[3] = x;

	char t;
	REP(i, 4)
	{
		if (a[i] != 0) {
			if (i == 0) {
				t = 'm';
			}
			if (i == 1) {
				t = 'c';
			}
			if (i == 2) {
				t = 'x';
			}
			if (i == 3) {
				t = 'i';
			}
			if (a[i] != 1) {
				s.push_back(a[i]+'0');
			}
			s.push_back(t);
		}
	}
	cout << s << endl;
}

int main(void)
{
	cin >> n;

	REP(i,n){
		string a, b;
		ll x, y;
		string t;
		cin >> a >> b;
		x = f(a);
		y = f(b);
		fa(x+y);
	}
}

Measured memory_bytes: 3100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int[] tmp = parceIntArray(br.readLine().split(" "));
		int n = tmp[0];
		int m = tmp[1];
		tmp = null;
		int[][] matrix = new int[n][m];
		int[][] vector = new int[m][1];
		for(int i = 0;i < n;i++){
			matrix[i] = parceIntArray(br.readLine().split(" "));
		}
		for(int i = 0;i < m;i++){
			vector[i][0] = Integer.parseInt(br.readLine());
		}
		for(int i = 0;i < n;i++){
			int sum = 0;
			for(int j = 0;j < m;j++){
				sum += matrix[i][j] * vector[j][0];
			}
			System.out.println(sum);
		}
	}
	
	static int[] parceIntArray(String[] strArr)throws NumberFormatException{
		int [] arr = new int[strArr.length];
		for(int i = 0;i < arr.length;i++){
			arr[i] = Integer.parseInt(strArr[i]);
		}
		return arr;
	}
}

Measured memory_bytes: 22716
#include<stdio.h>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<stack>
#include<algorithm>
#include<string>
#include<string.h>
#include<assert.h>
#include<iomanip>
#include<unordered_map>
#define F first
#define S second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;

int main(){
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  ll x; cin >> x;
  ll cur = 100;
  int ans = 0;
  while(cur < x){
    cur += cur / 100;
    ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
int dp[606][606];
int a[303],b[303];
int cnt[606];
int h[606];
int main()
{
	int n,m,ans=0;
	bool ok;
	scanf("%d%d",&n,&m);
	n<<=1;
	memset(cnt,0,sizeof(cnt));
	for(int i=1;i<=n;i++)
		cnt[i]=1;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		cnt[a[i]]--;
		cnt[b[i]]--;
	}
	for(int i=2;i<=n;i++)
		cnt[i]+=cnt[i-1];
	memset(h,0,sizeof(h));
	h[0]=1;
	for(int i=2;i<=n;i+=2)
		h[i]=(long long)h[i-2]*(i-1)%mod;
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)
		{
			ok=true;
			for(int k=1;k<=m;k++)
				if((i<=a[k]&&a[k]<=j)!=(i<=b[k]&&b[k]<=j))
					ok=false;
			if(ok)
			{
				dp[i][j]=h[cnt[j]-cnt[i-1]];
				for(int k=i;k<j;k++)
					(dp[i][j]+=mod-(long long)dp[i][k]*h[cnt[j]-cnt[k]]%mod)%=mod;
				ans=((long long)dp[i][j]*h[cnt[n]-cnt[j]+cnt[i-1]]+ans)%mod;
			}
		}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>

#define MOD 1000000007

long long int modepow(long long int a, long long int n){
    long long int res = 1;
    while(n>0){
        if(n&1){
            res = res*a % MOD;
        }
        a = a*a % MOD;
        n >>= 1;
    }
    return res;
}

int main(){
    int n;
    scanf("%d", &n);
    long long int a[n];
    int cnt_1[61], cnt_0[61];
    for(int i=0; i<=60; i++){
        cnt_1[i] = 0;
        cnt_0[i] = 0;
    }
    for(int i=0; i<n; i++){
        scanf("%lld", &a[i]);
    }
    long long int ans = 0;
    for(int i=0; i<n; i++){
        long long int buf = a[i];
        for(int j=0; j<=60; j++){
            if(buf % 2){
                cnt_1[j]++;
                ans += (cnt_0[j] * modepow(2, j)) % MOD;
                ans = ans % MOD;
            }else{
                cnt_0[j]++;
                ans += (cnt_1[j] * modepow(2, j)) % MOD;
                ans = ans % MOD;
            }
            buf = buf / 2;
        }
    }
    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 2560
while True:
    (N, Q) = [int(x) for x in input().split()]
    if N==0 and Q==0:
        exit()
    Date = [0]*100
    meeting_day = 0
    member_num = 0
    for i in range(N):
        M = [int(x) for x in input().split()]
        for j in range(1, M[0]+1):
            Date[M[j]-1] += 1
    for i in range(100):
        if Date[i] >= Q and Date[i]>member_num:
            meeting_day = i+1
            member_num = Date[i]
    print(meeting_day)

Measured memory_bytes: 6720
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = long long;
vector <int> to[100005];


int main() {

	int n, m;

	cin >> n >> m;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	queue <int> q;
	vector <int> dis(n, -1);
	vector <int> sign(n, -1);
	dis[0] = 0;
	q.push(dis[0]);
	while (!q.empty()) {

		int v = q.front(); q.pop();
		for (int u : to[v]) {
			if (dis[u] != -1) continue;
			q.push(u);
			dis[u] = dis[v] + 1;
			sign[u] = v;
		}

	}

	cout << "Yes" << endl;
	rep(i, n) {
		if (i == 0) continue;
	
		cout << sign[i] + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 10584
import java.util.*;

/**
 * B
 */
public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();

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

        while(b != 0) {
            
            int c = a%b;
            a = b;
            b = c;

        }

        System.out.println(a);

    }
}


Measured memory_bytes: 26372
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MOD 998244353
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int main()
{
    int n, i, count=0, a[100000];
    lli sum=0, ans=0, min=1e9;
    scanf("%d",&n);
    for(i=0; i<n; i++) {
        scanf("%d",a+i);
        if(a[i] < 0) {
            a[i] *= -1;
            count++;
        }
        min = MIN(min, a[i]);
        sum += a[i];
    }
    if(count%2 == 0) {
        ans = sum;
    } else {
        ans = (lli)sum - 2*min;
    }
    printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define X first
#define Y second
#define PB push_back
#define ll long long
#define pii pair<ll,ll>
#define MEM(x,y) memset(x,y,sizeof(x))
#define bug(x) cout<<"debug "#x" is "<<x<<endl;
#define FIO ios::sync_with_stdio(false);
#define ALL(x) x.begin(),x.end()
#define LOG 20
#define lson(x) ((x)<<1)
#define rson(x) ((x)<<1|1)

const int maxn=1e6+10;
using namespace std;
int n;
int a[maxn];
int main()
{
	map<ll,ll> m;
	cin>>n;
	ll ans = 0;
	for(int i=0;i<n;i++)cin>>a[i],m[a[i]]++;
	for(auto i :m){
        ans += i.Y*(i.Y-1)/2;
	}
	for(int i=0;i<n;i++){
        cout<<ans-m[a[i]]+1<<endl;
	}
    return 0;
}

Measured memory_bytes: 10240
import sys

sys.setrecursionlimit(10**7)

N,M = map(int,input().split())
maxL = 0
minR = N+1
for _ in range(M):
    l,r = map(int,input().split())
    maxL = max(maxL,l)
    minR = min(minR,r)
ans = max(0,minR - maxL + 1)
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <stack>
#include <string>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;

/*------------------------------------------------------------------------------*/

int main(){
  int K, T;

  cin >> K >> T;

  VI nums(T);
  int max = 0, index = 0;

  REP(i, 0, T){
    cin >> nums[i];
    if(max < nums[i]){
      max = nums[i];
      index = i;
    }
  }

  int rest = 0;
  REP(i, 0, T){
    if(i != index){
      rest += nums[i];
    }
  }

  int ans = nums[index] - rest;

  if(ans < 0){
    cout << 0 << endl;
  } else {
    cout << ans - 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int a, b, c,d;
	cin >> a >> b >> c>>d;
	int ans = 0;
	rep(i, a+1) {
		rep(j, b+1) {
			rep(k, c+1) {
				if (500 * i + 100 * j + 50 * k == d) {
					ans++;
				}
			}
		}
	}
	cout << ans;
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <utility>
#include <vector>

using namespace std;

//????????¢??°???

int partition(  vector<pair< char, int > > &A, int p ,int r){

    int x = A[r].second;
    int i, j;

    i = p - 1;

    for( j = p ; j < r ; j++ ){

        if( A[j].second <= x ){

            i = i + 1;

            swap(A[i], A[j] );

        }

    }

    swap( A[i+1], A[r] );

    return i + 1;

}

void quick_sort(  vector<pair< char, int > > &A, int p, int r){

    int q;

    if( p < r ){

        q = partition( A , p , r );
        quick_sort( A , p , q-1 );
        quick_sort( A , q+1 , r );

    }

}

//??????????????????

int merge( vector<pair< char, int > > &A, int left, int mid, int right){

    int n1, n2, i, j , k ;

    n1 = mid - left;
    n2 = right - mid;

    vector<pair< char, int > > L, R;


    for( i = 0 ; i < n1 ; i++ ){

        L.push_back( make_pair(A[ left + i ].first, A[ left + i ].second) );

    }

    for( i = 0 ; i < n2 ; i++ ){

        R.push_back( make_pair(A[ mid + i ].first, A[ mid + i ].second) );

    }

    L.push_back( make_pair('a', 200000000) );
    R.push_back( make_pair('a', 200000000) );

    i = 0;
    j = 0;

    for( k = left ; k < right ; k++ ){

        if( L[i].second <= R[j].second ){
        
            A[k].first = L[i].first;
            A[k].second = L[i].second;
            i = i + 1;

        }else{
            
            A[k].first = R[j].first;
            A[k].second = R[j].second;
            j = j + 1 ;

        }

    }

}

int mergesort( vector<pair< char, int > > &A, int left, int right){

    int mid;

    if( left + 1 < right ){

        mid = ( left + right ) / 2 ;

        mergesort( A, left, mid );
        mergesort( A, mid, right );

        merge( A , left , mid , right );

    } 

}


//??¬???

int main(){

    char c, trash;

    int n, i, r, j, p, left, right;

    scanf("%d", &n);
    scanf("%c", &trash);

    p = 0;
    left = 0;

    r = n - 1;
    right = n;

    vector<pair< char, int > > A,B;

    for( i = 0; i < n ; i++ ){

        scanf("%c", &c);
        scanf("%d", &j);
        scanf("%c", &trash);

        A.push_back( make_pair( c , j ) );
        B.push_back( make_pair( c , j ) );

    }

    //quick sort

    quick_sort( A, p, r);

    //merge sort

    mergesort( B, left, right );

    int stable = 1;

    for( i = 0; i < n; i++ ){

        if( A[i] != B[i] ) stable = 0;

    }

    if( stable ) printf("Stable\n");
    else printf("Not stable\n");

    for( i = 0 ; i < n ; i++ ){

        printf("%c %d\n", A[i].first, A[i].second);

    }


    return 0;

}

Measured memory_bytes: 5264
n, m = map(int, input().split())
pre = [[] for i in range(n)]

for j in range(m):
    p, y = map(int, input().split())
    pre[p - 1].append((y, j))

inums = [0] * m
for k in range(n):
    if len(pre[k]) == 0:
        pass
    else:
        sorted_y = sorted(pre[k])
        for l in range(len(sorted_y)):
            s1 = str(k + 1).zfill(6)
            s2 = str(l + 1).zfill(6)
            inums[sorted_y[l][1]] = s1 + s2

print(*inums, sep = "\n")

Measured memory_bytes: 37480
#include<iostream>
#include<algorithm>
#define MAX 10001
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n,m,t,sx[MAX],sy[MAX],nx[MAX],ny[MAX];
	bool flag;
	while(cin>>n,n){
		cin>>m;
		rep(i,m)
		cin>>sx[i]>>sy[i];
		rep(i,n){
			flag=false;
			cin>>t;
			rep(j,t)
				cin>>nx[j]>>ny[j];
			if(t==m){
				for(int k=0;k<4&&!flag;k++){
					rep(j,t){
						swap(sx[j],sy[j]);
						sx[j]=-sx[j];
					}
					rep(j,t-1){
						if(!(nx[j]-nx[j+1]==sx[j]-sx[j+1]&&ny[j]-ny[j+1]==sy[j]-sy[j+1])){
							//cout<<ny[j]-ny[j+1]<<' '<<sx[j]-sx[j+1]<<endl;
							//cout<<ny[j]<<' '<<ny[j+1]<<endl;
							//cout<<"--------"<<j<<endl;
							break;
						}
						if(j==t-2)
							flag=true;
					}
					rep(j,t-1){
						if(!(nx[t-j-2]-nx[t-j-1]==sx[j]-sx[j+1]&&ny[t-j-2]-ny[t-j-1]==sy[j]-sy[j+1])){
							//cout<<"-------"<<j<<endl;
							//	cout<<nx[t-j-2]-nx[t-j-1]<<' '<<sx[j]-sx[j+1]<<endl;
							break;
						}
						if(j==t-2)
							flag=true;
					}
				}
			}
			if(flag)
			cout<<i+1<<endl;
		}
		cout<<"+++++"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{
	long long i, N, A[100001];
	scanf("%lld", &N);
	for (i = 0; i < N; i++) scanf("%lld", &(A[i]));
	A[N] = A[0];

	long long sum = 0, diff[100001];
	for (i = 1; i <= N; i++) {
		sum += A[i];
		diff[i] = A[i] - A[i-1];
	}
	if (sum % (N * (N + 1) / 2) != 0) printf("NO\n");
	else {
		sum /= N * (N + 1) / 2;
		for (i = 1, diff[0] = 0; i <= N; i++) {
			diff[i] = (sum - diff[i]) / N;
			if (diff[i] < 0 || diff[i] > sum) break;
			else diff[0] += diff[i];
		}
		if (i <= N || diff[0] != sum) printf("NO\n");
		else {
			for (i = 1; i <= N; i++) A[N] -= diff[i] * (N - i + 1);
			if (A[N] != 0) printf("No\n");
			else printf("YES\n");
		}
	}
	fflush(stdout);
	return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define printii(x)  for(auto it=x.begin();it!=x.end();it++) cout<<*it.F<<' '<<*it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,x,t,m;
	cin>>n;
	if(n%2){
		cout<<0;
		return 0;
	}
	x = 2;
	ll ans = 0;
	for(int i=0;i<27;i++){
		x*=5;
		ans+=n/x;
	}
	cout<<ans;


	return 0;
}







Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using ProCon.Util;

namespace ProCon
{
    class Program
    {
        static void Main(string[] args)
        {
            AC135B();
        }

        static void AC135B()
        {
            //https://atcoder.jp/contests/abc135/tasks

            string answer = "YES";

            int failCount = 0;

            var n = int.Parse(Console.ReadLine());
            var listP = Console.ReadLine().Split().Select(int.Parse).ToArray();

            for (int i = 0; i < n; i++ )
            {
                if(listP[i] != i + 1)
                {
                    failCount++;
                    if(failCount > 2)
                    {
                        answer = "NO";
                        break;
                    }
                }
            }

            Console.WriteLine(answer);
            Console.ReadKey();

        }

    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)));
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(typename vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int a[3];

int main(){
	scanf("%d%d%d" , &a[0] , &a[1] , &a[2]);
	sort(a , a + 3);
	int x = 1;
	if(a[1] != a[0]) ++x;
	if(a[2] != a[1]) ++x;
	printf("%d\n" , x);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(void)
{
    int A, B, max;

    cin >> A >> B;

    max = A+B;

    if(A-B > max){
	max = A-B;
    }

    if(A*B > max){
	max = A*B;
    }

    cout << max << endl;

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, M, C) = readLine()!!.split(" ").map { it.toInt() }
    val b = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()
    val aList = (1..N).map { readLine()!!.split(" ").map { it.toInt() }.toTypedArray() }

    var count = 0

    for(a in aList){

        var sum = 0
        for(i in 0 until M){
            sum += a[i]*b[i]
        }
        sum += C

        if(sum > 0) count++
    }

    println(count)
}


Measured memory_bytes: 37864
def nc2(n):
    return n * (n-1) // 2


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


count = dict()
for i in a:
    if i in count:
        count[i] += 1
    else:
        count[i] = 1
ans = dict()

this = 0
for i, c in count.items():
    this += nc2(c)


for i, c in count.items():
    ans[i] = this - nc2(c) + nc2(c-1)

for x in a:
    print(ans[x])

Measured memory_bytes: 95180
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
  int a[12];
  for(int i = 0; i < 12; i++) {
    cin >> a[i];
  }
  sort(a, a + 12);
  bool ok = true;
  for(int i = 0; i < 3; i++) {
    ok &= a[i*4 + 0] == a[i*4 + 1] && a[i*4 + 1] == a[i * 4 + 2] && a[i * 4 + 2] == a[i * 4 + 3];
  }
  if(ok) {
    cout << "yes" << endl;
  } else {
    cout << "no" << endl;
  }

}

Measured memory_bytes: 3112
N, Q = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(N - 1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

neighbor = [[] for x in range(N)]
ans = [0] * N
summed = [False] * N
for i in range(N - 1):
    neighbor[AB[i][0] - 1].append(AB[i][1])
    neighbor[AB[i][1] - 1].append(AB[i][0])
for i in range(Q):
    ans[PX[i][0] - 1] += PX[i][1]

from collections import deque
deque=deque([0])
summed[0] = True

while len(deque) != 0:
    tmp = deque.popleft()
    for i in neighbor[tmp]:
        if summed[i - 1]:
            continue
        deque.append(i - 1)
        summed[i - 1] = True
        ans[i - 1] += ans[tmp]
print(*ans)

Measured memory_bytes: 118852
#include <stdio.h>
#include <math.h>

#define N 100
#define INF 1000000000

int main(){
	int n,P[N+1],m[N+1][N+1];
	int i,j,k,l;

	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d %d",&P[i-1],&P[i]);
	}
		
	for(i=1;i<=n;i++)m[i][i] = 0;
	for(l=2;l<=n;l++){
		for(i=1;i<=n-l+1;i++){
			j = i + l - 1;
			m[i][j] = INF;
			for(k = i;k <= j-1;k++){
				    if( m[i][j] >= m[i][k] + m[k+1][j] + P[i-1] * P[k] * P[j] ) m[i][j] = m[i][k] + m[k+1][j] + P[i-1] * P[k] * P[j];
				//m[i][j]=fmin(m[i][j],m[i][k]+m[i][k]+m[k+1][j]+P[i-1]*P[k]*P[j]);
			}
		}
	}
	printf("%d\n",m[1][n]);

	return 0;

}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair <int,int> PII;
typedef pair <int,string> PIS;
typedef vector <int> vec;
#define endl '\n'
#define pi 3.141592653589793
#define fori(z,n) for(int i=z;i<n;i++)
#define forii(z,n) for(int i=z;i<=n;i++)
int main() 
{ 
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
        int n;
        cin>>n;
        vector <int> v;
        for(int i=0;i<n;i++)
        {
            int p;
            cin>>p;
            v.push_back(p);
        }
        sort(v.begin(),v.end());
        int m1=v.at(n/2-1);
        int m2=v.at(n/2);
        int out = m2-m1;
        cout<<out<<endl;
        /* cout<<m1<<"  "<<m2; */
    cerr<<"Time elapsed"<<1.0*clock()/CLOCKS_PER_SEC<<"s\n";
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int n;
  cin >> n;
  vector<vector<pair<int, int> > > data(n);
  for (int i = 0; i < n; i++) {
    int sz;
    cin >> sz;
    data[i].resize(sz);
    for (int j = 0; j < sz; j++) {
      cin >> data[i][j].first >> data[i][j].second;
      data[i][j].first--;
    }
  }
  int mask = (1 << n) - 1, ans = 0;
  while (mask > 0) {
    int ppl = mask, i = n - 1;
    bool poss = true;
    while (ppl) {
      if (ppl & 1) {
        for (pair<int, int> p : data[i]) {
          if (p.second ^ (bool)(1 << (n - 1 - p.first)&mask))
            poss = false;
        }
      }
      ppl /= 2;
      i--;
    }
    if (poss) {
      ans = max(ans, __builtin_popcount(mask));
    }
    mask--;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3560
n,l=map(int,input().split())

ans=0
x=[]
y=[]

for i in range(1,n+1):
    ans=ans+l+i-1
    x.append(l+i-1)
    y.append(abs(l+i-1))

if min(x)<0:
    ans=ans+min(y)
    print(ans)
else:
    ans=ans-min(y)
    print(ans)

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e3;
const char e = '.',
d3[10][10] = {
    ".aa",
    "b..",
    "b..",
},
d4[10][10] = {
    "aabc",
    "ddbc",
    "efgg",
    "efhh",
},
d5[10][10] = {
    "aabbc",
    "dde.c",
    "ffegg",
    "..hij",
    "..hij",
},
d6[10][10] = {
    "aabbcc",
    "ddeeff",
    "ghi...",
    "ghi...",
    "...jkl",
    "...jkl",
},
d7[10][10] = {
    "a..mmnn",
    "ab.ll..",
    ".bjjkk.",
    "c....hi",
    "c....hi",
    "dee...g",
    "dff...g",
};
int n;
char ans[nsz + 5][nsz + 5];

void inline paint(int x, int y, int len, const char d[10][10]) {
    loop (i, len) {
        loop (j, len) {
            ans[x + i][x + j] = d[i][j];
        }
    }
}

void inline print() {
    cont (i, n) {
        cont (j, n) {
            cout << ans[i][j];
        }
        cout << ln;
    }
}

int exgcd(int a, int b, int &x, int &y) {
    if (!b) {
        x = 1, y = 0;
        return a;
    }
    int px, py, g = exgcd(b, a % b, px, py);
    x = py, y = px - a / b * py;
    return g;
}

void inline calc(int a, int b, int c, int &x, int &y) {
    int g = exgcd(a, b, x, y), k = b / g;
    x = (x + k) * c / g;
    x = (x % k + k) % k;
    y = (c - a * x) / b;
}

int main() {
    ios::sync_with_stdio(0);
    cin >> n;
    cont (i, n) {
        cont (j, n) {
            ans[i][j] = e;
        }
    }
    if (n <= 2) {
        cout << -1 << ln;
    } else if (n % 2 == 0) {
        int p = 1, x, y;
        calc(4, 6, n, x, y);
        cont (i, x) {
            paint(p, p, 4, d4);
            p += 4;
        }
        cont (i, y) {
            paint(p, p, 6, d6);
            p += 6;
        }
        print();
    } else if (n % 3 == 0) {
        int p = 1;
        for (; p <= n; p += 3) {
            paint(p, p, 3, d3);
        }
        print();
    } else if (n == 7) {
        paint(1, 1, 7, d7);
        print();
    } else if (n == 11) {
        paint(1, 1, 7, d7);
        paint(8, 8, 4, d4);
        print();
    } else {
        int p = 1, x, y;
        calc(4, 5, n, x, y);
        cont (i, x) {
            paint(p, p, 4, d4);
            p += 4;
        }
        cont (i, y) {
            paint(p, p, 5, d5);
            p += 5;
        }
        print();
    }
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
using namespace std;
const int mod=1000000007;
typedef long long ll;
typedef pair<int,int> P;

vector<ll> a,f;
int n;
ll k;

bool check(ll th){
    ll ans = 0;
    rep(i,0,n-1){
        ans += max((ll)0,a[i] - th/f[i]);
    }
    // cout << th << " " << ans << " " << k << endl;
    if(ans <= k)return true;
    else return false;
}

int main(){
    cin >> n >> k;
    a.resize(n);f.resize(n);
    rep(i,0,n-1){
        cin >> a[i];
    }
    rep(i,0,n-1)cin >> f[i];
    ll total = 0;
    sort(f.begin(),f.end());
    sort(a.begin(),a.end(),greater<int>());
    rep(i,0,n-1)total += a[i] * f[i];

    if(check(0)){
        puts("0");
        return 0;
    }

    ll r=total,l=0;
    while(r-l>1){
        // cout << l << " " << r << endl;
        ll mid = (r+l)/2;
        if(check(mid)){
            r = mid;
        }else{
            l = mid;
        }
    }

    cout << r << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a+b==16){
        if(a!=b){
            cout<<":(\n";
        }else{
            cout<<"Yay!\n";
        }
    }else{
        if(max(a,b)*2<=16){
            cout<<"Yay!\n";
        }else{
            cout<<":(\n";
        }
    }
    return 0;
}

Measured memory_bytes: 764
n, m = map(int, input().split())
ans = [0]*(n+1)
ans[0] = 1
ans[1] = 1
j = 0
a = []
for _ in range(m):
    a_ = int(input())
    if a_ == 1:
        ans[1] = 0
        j = 1
    a.append(a_)
a.append(-1)
for i in range(2, n+1):
    if i == a[j]:
        j += 1
    else: ans[i] = ans[i-1]+ans[i-2]
print(ans[n]%(10**9+7))

Measured memory_bytes: 460020