akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC optimize("Ofast")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T1, typename T2>
T2 sum_mod(T1 x, T2 MOD) {
	if (x < 0)
		x += MOD;
	if (x >= MOD)
		x -= MOD;
	return x;
}

template <typename T1, typename T2>
T2 mul_mod(T1 x, T2 MOD) {
	if (x < 0)
		return (abs(x) % MOD == 0 ? 0 : MOD - abs(x) % MOD);
	return x % MOD;
}

template <typename T>
bool uax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T>
bool uin(T& a, const T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 18;
const int N = (int)3e5 + 7;
const int MAXN = (int)2e6 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e17;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

int n, ans[N];

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	cin >> n;
	for (int i = 1; i < n; i++) {
		int x; cin >> x;
		ans[x]++;
	}
	for (int i = 1; i <= n; i++)
		cout << ans[i] << endl;

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

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

int main() {
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<=n;i++)
    {
        cin>>a[i];
    }
    long ans=INT_MAX,s;
    for(int i=1;i<=100;i++)
    {
        s=0;
        for(int j=0;j<n;j++)
        s+=(a[j]-i)*(a[j]-i);
        ans=min(s,ans);
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 256
S = input()
danceable = True
for i in range(len(S)):
    if i%2 == 0 and S[i] == 'L':
        print('No')
        danceable = False
        break
    if i%2 == 1 and S[i] == 'R':
        print('No')
        danceable = False
        break
if(danceable):
    print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll int>
#define vs vector<string>
#define v vector<int>
#define mi map<int,int>
#define mc map<char,int>
//ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	vs A(3);
	for(auto &x:A)cin>>x;
	string s=A[0], s1=A[1], s2=A[2];
	cout<<s[0] <<s1[0] <<s2[0] <<"\n";
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}
 
ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}


void solve(long long N, std::vector<long long> A, std::vector<long long> B){
    ll ans = 0;
    ll prev = 0;
    for(int i = N - 1; i >= 0; i--)
    {
        A[i] += ans;
        if(A[i] % B[i] == 0){
            prev = 0;
        }else{
            prev = B[i] - (A[i] % B[i]);
        }
        ans += prev;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


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

int main(){
 int a,b;
  cin >> a ;
  cin >> b;
  
  if(a%2 == 0 || b%2 == 0){
    cout <<  "Even"<< endl;
  }else{
    cout << "Odd" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f(a,b) for(int i=a;i<b;i++)
#define nitro cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define mod 1000000007
#define m 100007
using namespace std;
int dp[100005];
ll solve(int arr[],int n,int idx)
{
    if(dp[idx]!=-1)
        return dp[idx];
    if(idx==n-1)
        return dp[idx]=0;
    if(idx>=n)
        return dp[idx]=INT_MAX;
    ll fs=abs(arr[idx]-arr[idx+1])+solve(arr,n,idx+1);
    ll ts=abs(arr[idx]-arr[idx+2])+solve(arr,n,idx+2);
    ll ans=0;
    ans+=min(fs,ts);
    return dp[idx]=ans;
}

int main()
{
    int n;
    cin>>n;
    int arr[n];
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++)
        cin>>arr[i];
    cout<<solve(arr,n,0)<<endl;
}


Measured memory_bytes: 12196
import heapq

n, m = map(int, input().split())
x = list(map(int, input().split()))
if n >= m:
    print(0)
    exit()
dist = []
heapq.heapify(x)
tmp = heapq.heappop(x)
minlen = tmp
for i in range(m - 1):
    tmp1 = heapq.heappop(x)
    leng = (tmp1 - tmp) * (-1)
    dist.append(leng)
    if i == m - 2:
        maxlen = tmp1
    tmp = tmp1
totallen = maxlen - minlen
heapq.heapify(dist)
if n == 1:
    print(totallen)
else:
    for i in range(n - 1):
        length = heapq.heappop(dist) * (-1)
        totallen -= length
    print(totallen)


Measured memory_bytes: 72232
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N,count = 1;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++)
    {
        cin >> d.at(i);
    }
    sort(d.begin(),d.end());
    for (int i = 1; i < N; i++)
    {
        int k = d.at(i) - d.at(i-1);
        if(k > 0){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3160
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
# stdin = open("sample.txt")

MOD = 1000000007

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def combination(m,n):
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def main():
    s = stdin.readline().rstrip()
    ans = ""
    for i in range(len(s)):
        if s[i] == "?":
            ans += "D"
        else:
            ans += s[i]
    print(ans)
main()

Measured memory_bytes: 10332
N,M = gets.chomp.split.map(&:to_i) # スペースで区切られた複数の整数
a = gets.chomp.split.map(&:to_i)  # スペースで区切られた複数の整数
N.freeze
M.freeze

syukudai = 0

for num in 0..M-1 do
  syukudai = syukudai + a[num]
end

ans = N - syukudai

if ans >= 0 then
  puts ans
else
  puts "-1"
end

Measured memory_bytes: 14720
import java.util.*;

public class Main {

    // global
    static long fact[];
    static long inverse[];
    static int mod = 998244353;

    static long pow(long a,int n) {
        long res=1;
        while (n>0) {
            if ((n-n/2*2)==1) {
                res=res*a%mod;
            }
            a=a*a%mod;
            n>>=1;
        }
        return res;
    }

    static long modinv(long n) {
        return pow(n, mod-2);
    }

    static long comb(int n,int k){
        if(n<0 || k<0 || n<k)return 0;
        return fact[n]*(inverse[k]*inverse[n-k]%mod) %mod;
    }

    static long gcd(long a,long b) {
        long temp;
        while ((temp=a%b)!=0) {
            a=b;
            b=temp;
        }
        return b;
    }

    public static void main(String[] args) {

        // main method
        fact=new long[500000];
        fact[0]=1;
        inverse=new long[500000];
        inverse[0]=1;
        for(int i=1;i<500000;i++){
            fact[i]=(fact[i-1]*(long)i)%mod;
            inverse[i]=modinv(fact[i]);
        }

        Scanner sc = new Scanner(System.in);
        long N = Long.parseLong(sc.next());
        long A = Long.parseLong(sc.next());
        long B = Long.parseLong(sc.next());
        long K = Long.parseLong(sc.next());

        // divide by gcd(A, B)
        long gcd = gcd(A, B);
        if (K%gcd!=0) {
            System.out.println(0);
            return;
        }
        A/=gcd;
        B/=gcd;
        K/=gcd;

        // solve Ax+By=K
        long ans = 0L;
        ArrayList<ArrayList<Long>> list = new ArrayList<ArrayList<Long>>();
        for (int i=0;i<=N;i++) {
            if ((K-A*i)%B==0) {
                long j = (K-A*i)/B;
                if (0<=j && j<=N) {
                    ArrayList<Long> add = new ArrayList<Long>();
                    add.add((long)i);
                    add.add(j);
                    list.add(add);
                    ans = (ans + comb((int)N, i)*comb((int)N, (int)j)%mod)%mod;
                }
            }
        }

        // long ans = 0L;
        // for (int i=0;i<list.size();i++) {
        //     long x = list.get(i).get(0);
        //     long y = list.get(i).get(1);
        //     long min = Math.min(x, y);
        //     for (int j=(int)min;j>=0;j--) {
        //         int green = j;
        //         int red = (int)x-j;
        //         int blue = (int)y-j;
        //         if (x+y-j>N) break;
        //         ans = (ans + ((((fact[(int)N]*inverse[green])%mod*inverse[red])%mod*inverse[blue])%mod*inverse[(int)N-green-red-blue])%mod)%mod;
        //     }
        // }
        // System.out.println(list);
        System.out.println(ans);
    }
}

Measured memory_bytes: 79184
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long c = sc.nextLong();

		if(c>=2800){
System.out.println("AGC");
		}else if(c>=1200){
System.out.println("ARC");

		}else{
System.out.println("ABC");

		}



	}


	public static boolean cIstrue(BigDecimal cc){
		BigDecimal forty = new BigDecimal("140");
		BigDecimal fseventy = new BigDecimal("170");
		int yon=cc.compareTo(forty);
		int nana=cc.compareTo(fseventy);

			// System.out.println("if140  "+yon);
			// System.out.println("if170  "+nana);
		if(yon==(-1)||yon==0){
			// System.out.println("goalFalse"+cc);
			return false;
		}
		if(nana==(-1)){
			// System.out.println("goalTrue"+cc);
			return true;
		}
		if(nana==(1)||nana==0){
			BigDecimal two = new BigDecimal("2");
			return cIstrue(cc.divide(two));
		}
		return false;
	}
}

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int k;
    cin >> k;
    int a=0;
    vector<bool> v(k,0);
    for(int i=1;;i++)
    {
        a=(10*a+7)%k;
        if(v[a]==1)
        {
            cout << "-1\n";
            break;
        }
        if(a==0)
        {
            cout << i << "\n";
            break;
        }
        v[a]=1;
    }
    return 0;
}


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

struct Bc{
  int b,c;

  Bc(int inputB, int inputC){
    b = inputB;
    c = inputC;
  }

  bool operator<(const Bc &another) const{
    return c < another.c;
  }
};

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  vector<Bc> bc;
  int tmp_b,tmp_c;
  for(int i=0; i<M; i++){
    cin >> tmp_b >> tmp_c;
    bc.push_back(Bc(tmp_b,tmp_c));
  }

  sort(A.begin(),A.end());
  sort(bc.begin(),bc.end());
  reverse(bc.begin(),bc.end());
  int point =0;
  bool brk = false;
  for(auto itr:bc){
    for(int i=0; i<itr.b; i++){
      if(A.at(point) < itr.c){
        A.at(point) = itr.c;
        point++;
        if(point >= A.size()){
          brk = true;
          break;
        }
      }else{
        brk = true;
        break;
      }
    }
    if(brk){
      break;
    }
  }
  
  int64_t sum = 0;
  for(int i=0; i<A.size(); i++){
    sum += A.at(i);
  }
  cout << sum << endl;

}

Measured memory_bytes: 1784
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
///////////////////////////////////////


int main() {
	int A, B, M; cin >> A >> B >> M;
	int a[100100], b[100100];
	int am = INF;
	int bm = INF;
	REP(i, A) {
		cin >> a[i];
		am = min(am, a[i]);
	}
	REP(i, B) {
		cin >> b[i];
		bm = min(bm, b[i]);
	}

	int ans = am + bm;
	REP(i, M) {
		int x, y, c;
		cin >> x >> y >> c;
		x--, y--;
		ans = min(ans, a[x] + b[y] - c);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
a_e=[int(i) for i in a if i%2==0]
a_35=[int(i) for i in a_e if i%3==0 or i%5==0]
if len(a_e)==len(a_35):print('APPROVED')
else:print('DENIED')

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#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() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;
	string res = "Yes";
	REP(i, S.size()) {
		if (i % 2 == 0) {
			if (S[i] == 'L') res = "No";
		}
		else if (S[i] == 'R') res = "No";
	}
	cout << res << endl;

	return 0;
}


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

ll a,b,c,n,m;
ll ans=100000000000;

string s;

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

  cin>>n;
  vector<string> v(n);
  rep(i,n)cin>>v[i];
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  cout<<v.size();

  return 0;
}

Measured memory_bytes: 9500
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let m: i64 = input();
    let k: i64 = input();

    if m == 0 {
        if k == 0 {
            println!("0 0");
        } else {
            println!("-1");
        }
    } else if m == 1 {
        if k == 0 {
            println!("0 0 1 1");
        } else {
            println!("-1");
        }
    } else {
        if k < (1 << m) {
            for i in 0..(1 << m) {
                if i != k {
                    print!("{} ", i);
                }
            }
            print!("{} ", k);
            for i in (0..(1 << m)).rev() {
                if i != k {
                    print!("{} ", i);
                }
            }
            println!("{}", k);
        } else {
            println!("-1");
        }
    }
}


Measured memory_bytes: 5884
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int mozi_size=0 , flagout = 0;
  string row_moziretu , change_moziretu;
  cin>>row_moziretu;
  cin>>change_moziretu;
  mozi_size = row_moziretu.size();
//  char row_mozi[mozi_size] , change_mozi[mozi_size];
  for(int i = 0 ; i < mozi_size ; i++){
  	if(change_moziretu.at(i) != row_moziretu.at(i)){
  	flagout++;
    	}
  	}
  cout<<flagout<<endl;
  }

Measured memory_bytes: 3844
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    let n:usize = read();
    let a:Vec<i64> = (0..n).map(|_| read()).collect();

    let mut ans:i64 = 0;
    for &el in a.iter() {
        ans += el-1;
    }

    println!("{}", ans);

}


Measured memory_bytes: 4352
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
const int MAXN = 10;
bool f=true;
int a[MAXN+5];
int main()
{
	int n, res=0, t=0;
	cin>>n; 
	int tot=0;
	while(n)
	{
		a[++t] = n%10;
		if(!a[t])
			tot++;
		n/=10;
	}
	if(a[t]==1&&tot==t-1)
	{
		cout<<"10";
		return 0;
	}
	for(int i=1; i<=t; i++)
		res += a[i];
	cout<<res;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

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

        int d;

        while (sc.hasNextInt()) {
            d = sc.nextInt();
            System.out.println(100 * (600 - d) * (1200 - d));
        }
    }
}

Measured memory_bytes: 25988
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>
#include <memory>

constexpr long long MOD = 1000000007;

int main()
{
  int A, B, C;
  std::cin >> A >> B >> C;
  if ((A < C && C < B) || (B < C && C < A))
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
  return 0;
}



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

#define ldb long double
#define ll long long

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    ll n;
    cin >> n;
    vector<ll> a(n + 1);
    vector<ll> cnt(n + 1);
    
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        cnt[a[i]]++;
    }
    
    ll sum = 0;
    
    for(int i = 1; i <= n; i++)
    {
        sum += cnt[i] * (cnt[i] - 1) / 2;
    }
    
    for(int i = 1; i <= n; i++)
    {
        ll temp = sum - cnt[a[i]] * (cnt[a[i]] - 1) / 2;
        temp += (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2;
        
        cout << temp << "\n";
    }

    return 0;
}


Measured memory_bytes: 5760
n = gets.to_i
price, b = gets.split.map &:to_i
calorie = gets.to_f
max = calorie / price
$<.map(&:to_f).sort.reverse.each{|c|
    price += b
    calorie += c
    r = calorie / price
    break if r <= max
    max = r
}
p max.to_i

Measured memory_bytes: 6108
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

class UnionFind {
private:
    int n;
    vector<int> uni;
public:
    UnionFind(int _n) {
        n = _n;
        uni.clear();
        uni.resize(n, -1);
    }
    int root(int x) {
        if (uni[x] < 0) return x;
        return uni[x] = root(uni[x]);
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (uni[x] > uni[y]) swap(x, y);
        uni[x] += uni[y];
        uni[y] = x;
    }
    void print() {
        for (auto x : uni) cout << x << " ";
        cout << endl;
    }
};

struct edge {
    int from, to, cost;
    edge(){}
    edge(int _from, int _to, int _cost) : from(_from), to(_to), cost(_cost) {}
    bool operator< (const edge& e) const {
        return cost == e.cost ? (from == e.from ? to < e.to : from < e.from) : cost < e.cost;
    }
};

class Kruskal {
private:
    int n;
    vector<edge> edges;
    UnionFind uf;
public:
    Kruskal(int _n) : n(_n), uf(UnionFind(n)) {
        rep(i, n) {
            rep(j, n) {
                int c;
                cin >> c;
                if (c == -1) c = 1e9;
                edges.emplace_back(i, j, c);
            }
        }
        sort(all(edges));
    }
    int calc() {
        int res = 0;
        for (auto &e : edges) {
            if (!uf.same(e.from, e.to)) {
                uf.unite(e.from, e.to);
                res += e.cost;
            }
        }
        return res;
    }
};

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n;
    cin >> n;
    Kruskal kr(n);
    cout << kr.calc() << endl;
}

Measured memory_bytes: 3320
/*i-=-1*/
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define in(n) for(int i=0;i<n;i++)
#define inj(n) for(int j=0;j<n;j++)
#define itn int
#define ll long long 
#define ull unsigned ll
#define int ll int
#define S second 
#define F first 
#define mod 1000000007
#define globalbool 2000000
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
using namespace std;
using namespace std::chrono;
int solve(int n)
{
	if(n==1)
		return 1;
	int ans=1;
	ans+=(2*solve(n/2));
	return ans;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	auto start = high_resolution_clock::now();
	int n;
	cin>>n;
	int ans=solve(n);
	cout<<ans;
	auto stop = high_resolution_clock::now();
    //auto duration = duration_cast<microseconds>(stop - start); 
  
    //cout << "Time taken by function: "
    //<< duration.count() << " microseconds" << endl;
}

Measured memory_bytes: 256
///in the name of Allah the most beneficent the most merciful.
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
#define base 139
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE   freopen("input.txt", "r", stdin);  freopen("out.txt", "w", stdout);
#define out(x) cout << #x << " -> " << x << endl;
using namespace std;
const ll N = 300010, M = 2000005;
ll a[N], n, res;
bool vis[M], freq[M];
int solve()
{
	in1(n);
	for (int i = 0; i < n; i++)
	{
		in1(a[i]);
		if (freq[a[i]] > 0) vis[a[i]] = 1;
		freq[a[i]] = 1;
		if (vis[a[i]] == 0)
		{
			for (int j = 2 * a[i]; j <= 1000000; j += a[i])
			{
				vis[j] = 1;
			}

		}
	}
	for (int i = 0; i < n; i++)
		if (vis[a[i]] == 0) res++;
	printf("%lld\n", res);
	return 0;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int ret = solve();
	return 0;
}
/*

*/


Measured memory_bytes: 7188
n = int(input())
pList = list(map(int,input().split()))
c = 0
for i in range(1,n-1):
    tList = [pList[i-1],pList[i],pList[i+1]]
    tList.sort()
    if pList[i] == tList[1]:
        c+=1
print(c)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define ms(n, t) memset(n, t, sizeof(n))
#define U 10050
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#define sp
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a = next<int>();
	cout<<a+a*a+a*a*a<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

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

inline void init() {
#ifdef __LOCAL__
  freopen("in", "r", stdin);
#endif
}

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



int main() {
  init();

  ll a, b; cin >> a >> b;
  a *= b;
  if (a & 1) cout << "Odd" << endl;
  else cout << "Even" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;


int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    map<int,int> mp;
    cin >> n;
    int a;
    FOR(i,2,n+1) {//ここをREP,REP1いろいろ試して全部うまく行かなかった
        cin >> a;
       // cout << a << endl;
        mp[a]++;
    }
    //cout << "Hello" << endl;
    /*for(auto p:mp){
        cout << p.second << endl;
        
    }*/
    REP1(i,n){
        cout << mp[i] << endl;
    }

}
 

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

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

    map<char, int> mp;
    for (char ch = 'a'; ch <= 'z'; ch++) {
        mp[ch] = 1000;
    }

    for (int i = 0; i < n; i++) {
        map<char, int> m;
        string s;
        cin >> s;

        for (char ch : s) {
            m[ch]++;
        }

        for (char ch = 'a'; ch <= 'z'; ch++) {
            mp[ch] = min(mp[ch], m[ch]);
        }
    }

    for (char ch = 'a'; ch <= 'z'; ch++) {
        for (int i = 0; i < mp[ch]; i++) {
            cout << ch;
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
sorted_ab = sorted(ab)

ab_price = [0] * n
num = [0] * (n+1)

for i in range(n):
    num[i+1] = num[i] + sorted_ab[i][1]
    ab_price[i] = sorted_ab[i][0] * sorted_ab[i][1]
    if num[i+1] >= m:
        to_here = i + 1
        break

max_price = sorted_ab[to_here-1][0]
minus_num = num[to_here] - m
ans = sum(ab_price[:to_here]) - max_price * minus_num

print(ans)

Measured memory_bytes: 33708
/***
*  author  :_shamim
*  created : 07.05.2020
*
***/

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <list>
#include <set>
#include <queue>
#include <iterator>
#include <bitset>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll             long long
#define _              ios_base::sync_with_stdio(0);cin.tie(0);
#define loop           for(i=0;i<n;i++)
#define pb             push_back
#define tc()           int t;cin>>t;while(t--) 
#define pi             acos(-1)         

using namespace std;

ll i,j,temp;

int main()
{_
    int a,b;
			cin>>a>>b;
			cout<<a*b<<endl;


return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>

int main(void) {
	char a[100][100];
	int i,j,r,c,cnt1,flag,cnt2,flag2,cntt;
	scanf("%d%d",&r,&c);
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf(" %c",&a[i][j]);
			
		}
	}
	for(i=0;i<r;i++){
		cnt1=0;
		for(j=0;j<c;j++){
			if(a[i][j]=='.')cnt1++;
			
		}
		if(cnt1==c){
			for(j=0;j<c;j++){
			a[i][j]='\0';
			}
		}
		
	}
	for(j=0;j<c;j++){
		cnt2=0;
		for(i=0;i<r;i++){
			if(a[i][j]=='.'||a[i][j]=='\0')cnt2++;
			
		}
		if(cnt2==r){
			for(i=0;i<r;i++){
			a[i][j]='\0';
			}
		}
		
	}
	for(i=0;i<r;i++){
		flag=0;
		cntt=0;
		for(j=0;j<c;j++){
			if(a[i][j]=='\0')cntt++;
		}	
		
		for(j=0;j<c;j++){
			if(a[i][j]!='\0'){
				//flag=1;
				printf("%c",a[i][j]);
			}
		}	 
		if(cntt<c)printf("\n");
		
			

			
			
		
		//if(flag==1)printf("\n");
	}
	return 0;
}


Measured memory_bytes: 128
# include<iostream>
# include <cstdio>
# include <algorithm>

using namespace std;

long long A[200050];

int main(void)
{
    int N,K;
    scanf("%d%d",&N,&K);
    long long sum = 0;
    for (int i=1;i<=N;i++){
        scanf("%lld",&A[i]);
    }
    sort(A+1,A+N+1);
    for (int i=1;i<=N-K;i++) sum+=A[i];
    cout<<sum<<endl;
    return 0;
}

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


int main(){
  long K,A,B;
  cin >>K>>A>>B;
  if(B-A<2){
    cout << K+1;
  }
  else{
    long init = 0;
    long cukky = 1;
    K = K-(A-1);
    cukky = A;
    if(K%2==0){
        for(long i=0;i<K/2;i++){
          cukky = cukky-A+B;
        }
    }
    else{
      for(long i=0;i<(K-1)/2;i++){
          cukky = cukky-A+B;
        }
      cukky++;
    }
    cout  << cukky;
  }
  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

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

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

	int N;
	cin >> N;

	vector<ll> T(N);
	rep(i, N) cin >> T[i];

	ll ans = 1LL;
	rep(i, N) ans = lcm(ans, T[i]);

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define what_is(x) cerr << #x <<" is " << x << endl;
typedef long long ll;
const ll MOD = 1000000007;
const double PI = 3.14159265358979;
const ll INF =  1e15 + 7;
const ll nax = 200005;

ll n;
vector<ll> a(nax);
vector<ll> adj[nax];
vector<ll> pos(nax, INF);
vector<ll> ans(nax, 1);


void dfs(ll i, ll p, ll maxx) {
	for (ll j : adj[i]) {
		if (j == p)
			continue;
		ll lo = 0, hi = n, position = 0;
		while (lo <= hi) {
			ll mid = (lo + hi) / 2;
			if (pos[mid] < a[j]) {
				position = mid;
				lo = mid + 1;
			}
			else hi = mid - 1;
		}
		position++;
		ll tmp_pos = pos[position];
		ll tmp_maxx = maxx;

		pos[position] = a[j];
		maxx = max(maxx, position);
		ans[j] = maxx;

		dfs(j, i, maxx);

		pos[position] = tmp_pos;
		maxx = tmp_maxx;
	}
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll tc = 1;
	// cin >> tc;
	while (tc--) {
		cin >> n;
		for (ll i = 1; i <= n; i++) {
			cin >> a[i];
		}
		for (ll i = 1; i < n; i++) {
			ll x, y;
			cin >> x >> y;
			adj[x].emplace_back(y);
			adj[y].emplace_back(x);
		}
		pos[0] = 0;
		pos[1] = a[1];
		ans[1] = 1;
		dfs(1, -1, 1);
		for (ll i = 1; i <= n; i++) {
			cout << ans[i] << endl;
		}
	}
	return 0;
}




















Measured memory_bytes: 33204
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

H, W, K = map(int, input().split())
cells = []
for i in range(H):
    s = input()
    cells.append(s)


ans = 0
for i in range(2 ** H):
    row = []
    for j in range(H):
        if ((i >> j) & 1):
            row.append(j)
    for k in range(2 ** W):
        column = []
        for l in range(W):
            if ((k >> l) & 1):
                column.append(l)
        cnt = 0
        for r in row:
            for c in column:
                if cells[r][c] == '#':
                    cnt += 1
        if cnt == K:
            ans += 1

print(ans)


Measured memory_bytes: 73372
#include<iostream>
#include<string>
#include<vector>
#include<boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int infinit;
using namespace std;
#define END return 0
int input(void)
{
	int i = 0;
	cin >> i;
	return i;
}
int main()
{

	int n,ans=0;
	vector<int> list;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		list.push_back(input());
	}

	for (int i = 0; i < list.size(); i++)
	{
		for (int w = i+1; w < list.size(); w++)
		{
			ans += list[i] * list[w];
		}
	}

	cout << ans << endl;

	END;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,i,j,k,n,q,x,y,l,r,m,c,z;
    string s;
	cin>>s;
	cin>>q;
	c = 0;
	while(q--){
		cin>>x;
		if(x == 1){
		  c = c^1;	
		}else{
		  string chr;	
		  cin>>y;
		  cin>>chr;
		  if(y == 1){
		  	if(c){
		  		s += chr;
			}else{
				s.insert(0,chr);
			}
		  }else{
		  	if(c){
		  		s.insert(0,chr);
			}else{
			    s+= chr;
			}
		  }	
		}
	}
	if(!c) cout<<s;
	else{
		reverse(s.begin(),s.end());
		cout<<s;
	}
}

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

template <class T>
inline void read(T &res)
{
	char ch; bool flag = false; res = 0;
	while (ch = getchar(), !isdigit(ch) && ch != '-');
	ch == '-' ? flag = true : res = ch ^ 48;
	while (ch = getchar(), isdigit(ch))
		res = res * 10 + ch - 48;
	flag ? res = -res : 0;
}

template <class T>
inline void put(T x)
{
	if (x > 9)
		put(x / 10);
	putchar(x % 10 + 48);
}

template <class T>
inline void CkMax(T &x, T y) {x < y ? x = y : 0;}
template <class T>
inline void CkMin(T &x, T y) {x > y ? x = y : 0;}
template <class T>
inline T Max(T x, T y) {return x > y ? x : y;}
template <class T>
inline T Min(T x, T y) {return x < y ? x : y;}

typedef long long ll;
ll n, a, b;

int main()
{
	std::cin >> n >> a >> b;
	if (a > b)
		std::swap(a, b);
	if (!(b - a & 1))
		std::cout << (b - a >> 1) << std::endl;
	else 
		std::cout << Min((a - 1 + b - 1 + 1 >> 1), (n - a + n - b + 1 >> 1)) << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int n; long long a[91];
int main() {
	cin >> n;
	a[0] = 2; a[1] = 1;
	for (int i = 2; i <= n; i++) a[i] = a[i - 1] + a[i - 2];
	cout << a[n] << endl;
	return 0;
}

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

const int INF = 1001001001;
const int mod = 1000000007;

ll pow(ll base, ll order) {
	ll ans = 1;
	rep(i,order - 1) ans *= base;
	return ans;
}

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

int cnt = 0;

string judge(string s) {
	//cnt++;
	//cout << "cnt" << " " << cnt << " " << s.substr(0, s.size()/2) << " " << s.substr(s.size()/2) << endl;
	if (s.size() == 1) return s;
	if (s.substr(0, s.size()/2) == s.substr(s.size()/2)) return s;

	return judge(s.substr(0, s.size() - 2));
}

int main() {
	string s;
	cin >> s;
	//cout << s << " " << s.size() << endl;
	if (s.size() % 2 == 0) s = s.substr(0, s.size() - 2);
	else s = s.substr(0, s.size() - 1);
	//cout << s << endl;
	cout << judge(s).size() << endl;
} 

Measured memory_bytes: 256
import math
def kock(n,p1,p2):
    if n==0:
        return
    s=[(2*p1[0]+p2[0])/3,(2*p1[1]+p2[1])/3]
    t=[(p1[0]+2*p2[0])/3,(p1[1]+2*p2[1])/3]
    kock(n-1,p1,s)
    print(*s)
    u=[(t[0]-s[0])*math.cos(math.radians(60))-(t[1]-s[1])*math.sin(math.radians(60))+s[0],(t[0]-s[0])*math.sin(math.radians(60))+(t[1]-s[1])*math.cos(math.radians(60))+s[1]]
    kock(n-1,s,u)
    print(*u)
    kock(n-1,u,t)
    print(*t)
    kock(n-1,t,p2)

n=int(input())
p1=[0,0]
p2=[100,0]
print(*p1)
kock(n,p1,p2)
print(*p2)


Measured memory_bytes: 5792
def cin; gets.split.map(&:to_i) end
def cout(*x); puts x.join(" ") end

exit if $0 != __FILE__

n = gets.to_i
h = Hash.new(0)
gets.chop.chars.each {|c| h[c] += 1}
(n-1).times do
  a = Hash.new(0)
  gets.chop.chars.each {|c| a[c] += 1}
  h.keys.each {|k| h[k] = [h[k], a[k]].min}
end

puts h.to_a.sort{|a,b|a[0]<=>b[0]}
        .inject("") {|str, kv| str += kv[0]*kv[1]}

Measured memory_bytes: 1788
n = int(input())
A = list(map(int, input().split()))
d2 = 0
d4 = 0
for a in A:
  if a % 4 == 0: d4 += 1
  elif a % 2 == 0: d2 += 1
if d4 * 2 + d2 >= n:
  print('Yes')
elif d4 * 2 >= n-1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=100010,M=1000010,P=1e9+7;
const int inf=0x3f3f3f3f;
const int INF=0xcfcfcfcf;
const db eps=1e-9,pi=asin(1)*2;
inline ll read();
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
inline int ADD(int a,int b) { return a+b>=P?a+b-P:a+b; }
inline int MINUS(int a,int b) { return a-b<0?a-b+P:a-b; }
#define plus(a,b) a=ADD(a,b)
#define minus(a,b) a=MINUS(a,b)
#define mul(a,b) a=(1ll*a*(b))%P
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)

int head[N],ver[M],nxt[M],du[N];
int n,m,tot=1;
char s[N];
int w[N];
bool visit[N];
inline void add(int x,int y)
{
	ver[++tot]=y,nxt[tot]=head[x],head[x]=tot,du[y]++;
}

queue<int> q;
int d[N],rt=0;
inline void dfs(int x,int fa)
{
	d[x]=d[fa]+w[x];
	if(d[x]>d[rt]) rt=x;
	for(int i=head[x];i;i=nxt[i])
	{
		int y=ver[i];
		if(y==fa) continue;
		dfs(y,x);
	}
}

#ifdef FILE
const int RS=1<<20;
char buf[RS],*p1=buf,*p2=buf;
#define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,RS,stdin),p1==p2)?EOF:*p1++
#endif
inline ll read()
{
	ll s=0;
	bool flag=false;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') flag=true;
	for(;'0'<=ch&&ch<='9';ch=getchar()) s=(s<<3)+(s<<1)+(ch^'0');
	if(flag) return -s;
	return s;
}

int main()
{
#ifdef FILE
	freopen(FILE ".in","r",stdin);
	freopen(FILE ".out","w",stdout);
#endif
	n=read();
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		add(x,y),add(y,x);
	}
	scanf("%s",s+1);
	
	while(q.size()) q.pop();
	for(int i=1;i<=n;i++) if(s[i]=='B'&&du[i]==1) q.push(i),visit[i]=true;
	while(q.size())
	{
		int x=q.front();q.pop();
		for(int i=head[x];i;i=nxt[i])
		{
			int y=ver[i];
			if(!visit[y])
			{
				du[y]--;
				if(du[y]==1&&s[y]=='B') q.push(y),visit[y]=true;
			}
		}
	}
	int ans=0;
	for(int x=1;x<=n;x++)
	{
		if(visit[x]) continue;
		for(int i=head[x];i;i=nxt[i])
		{
			int y=ver[i];
			if(visit[y]) continue;
			ans++;
		}
	}
	if(!ans)
	{
		for(int i=1;i<=n;i++)
		{
			if(s[i]=='W')
			{
				printf("1\n");
				return 0;
			}
		}
		printf("0\n");
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		if(visit[i]) continue;
		rt=i;
		if(s[i]=='W') w[i]^=1;
		if(du[i]&1) w[i]^=1;
		ans+=w[i];
	}
	d[0]=0;
	dfs(rt,0);
	dfs(rt,0);
	printf("%d\n",ans-2*d[rt]);
	return 0;
}
/*
5
1 2
1 3
1 4
1 5
*/

Measured memory_bytes: 8960
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a == b+c || b == a+c || c == a+b)
			System.out.println("Yes");
		else System.out.println("No");
	}
}


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

int main(){
    string s, t;
    cin >> s >> t;
    char ss[s.length()+1], tt[t.length()+1];
    for(int i=0;i<s.length();i++) ss[i] = s[i];
    ss[s.length()] = 0;
    for(int i=0;i<t.length();i++) tt[i] = t[i];
    tt[t.length()] = 0;
    sort(ss, ss+s.length());
    sort(tt, tt+t.length());
    char ttt[t.length()+1];
    for(int i=0;i<t.length();i++) ttt[i] = tt[t.length()-1-i];
    ttt[t.length()]=0;
    string s1 = ss;
    string t1 = ttt;
    //cout << "best s " << s1 << "\n" <<"best t "<<endl;
    if(s1<t1) cout << "Yes"<<endl;
    else cout <<"No"<<endl;
}

Measured memory_bytes: 256
// たぴたべてやる

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 998244353;

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

  vector< int > memo[2001];
  {
    vector< int > dp(N + 1);
    dp[N] = 1;
    memo[0] = dp;
    for(int j = 0; j < 2000; j++) { // 何個目のペアか
      vector< int > dp2(dp);
      int add = 0;
      for(int k = N; k >= 0; k--) {
        (dp2[k] += add) %= mod;
        (add += dp[k] * 2LL % mod) %= mod;
      }
      dp.swap(dp2);
      memo[j + 1] = dp;
    }
  }

  vector< int > beet[2001];

  {
    vector< int > dp(N + 1);
    dp[0] = 1;
    beet[0] = dp;
    for(int k = 0; k < 2000; k++) {
      vector< int > dp2(dp);
      int add = 0;
      for(int l = 0; l <= N; l++) {
        (dp2[l] += add) %= mod;
        (add += dp[l]) %= mod;
      }
      dp.swap(dp2);
      beet[k + 1] = dp;
    }
  }

  for(int i = 2; i <= 2 * K; i++) {

    int unused = K;
    int matched = 0;
    bool same = false;

    for(int j = 1; j <= K; j++) {
      int rest = i - j;
      if(j <= rest && rest <= K) {
        if(rest == j) {
          unused--;
          same = true;
        } else {
          matched++;
          unused -= 2;
        }
      }
    }

    vector< int > dp = memo[matched];

    if(same) {
      vector< int > dp2(dp);
      for(int k = 0; k < N; k++) (dp2[k] += dp[k + 1]) %= mod;
      dp.swap(dp2);
    }


    int all = 0;
    for(int j = 0; j <= N; j++) {
      all += 1LL * dp[j] * beet[unused][j] % mod;
      all %= mod;
    }

    cout << all << endl;

  }
}





Measured memory_bytes: 31744
#include <cmath>
#include <iostream>

using namespace std;

int main() {
    long long N, K;

    cin >> N >> K;

    long long ans;
    if (K % 2 == 0) {
        long long a = N / K;
        long long b = (N + K / 2) / K;
        ans = a * a * a + b * b * b;
    } else {
        long long a = N / K;
        ans = a * a * a;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
A = int(input())
B = int(input())

"""
if A == 1 and B == 2 or A == 2 and B == 1:
    print(3)
elif A == 1 and B == 3 or A == 3 and B == 1:
    print(2)
elif A == 2 and B == 3 or A == 3 and B == 2:
    print(1)
"""

if A > B:
    A, B = B, A

if A == 1 and B == 2:
    print(3)
if A == 2 and B == 3:
    print(1)
if A == 1 and B == 3:
    print(2)


Measured memory_bytes: 3060
while True:
    (m, mn, mx) = tuple(map(int, input().split()))
    if m == 0:
        break
    arr = [0 for i in range(m)]
    for i in range(m):
        arr[i] = int(input())
    arr.sort(reverse=True)
    res = []
    ap = res.append
    for i in range(mn, mx + 1):
        ap([arr[i - 1] - arr[i], i])
    res.sort(key=lambda x: x[0], reverse=True)
    reres = []
    rreap = reres.append
    maxa = res[0][0]
    for e in res:
        if e[0] < maxa:
            break
        rreap(e[1])
    reres.sort(reverse=True)
    print(reres[0])



Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define sec second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define FF fflush(stdout)
#define debug printf("Hello\n")
//why is my rating plummeting
int n, m, k, x, y, sum, cnt;
char s[2][100];
ll ans=1;
int main () {
	scanf("%d %s %s", &n, s[0], s[1]);
	int l=-1;
	for (int i=0; i<n; i++) {
		if (s[0][i]==s[1][i]) {
			if (l==-1) ans=(ans*3)%mod;
			else if (l==1) ans=(ans*2)%mod;
			l=1;
		} else {
			if (l==-1)ans=(ans*6)%mod;
			else if (l==2) ans=(ans*3)%mod;
			else ans=(ans*2)%mod;
			l=2;
			i++;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256