akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,a[N],i,x,cnt[N],pp,p[N];
set<int>s,ss[N];
inline void bf(){
	int p[9],xb=0;
	p[0]=::p[pp];for(int x:s)p[++xb]=x;
	do{
		for(i=0;i<xb;++i)if(a[p[i]]==p[i+1])break;if(i==xb)break;
	}while(next_permutation(p+1,p+xb+1));
	for(i=1;i<=xb;++i)::p[++pp]=p[i];
}
int main(){
	scanf("%d",&n);for(i=1;i<=n;++i)scanf("%d",a+i),++cnt[a[i]],s.insert(i);
	if(n==2){puts("-1");return 0;}
	for(i=1;i<=n;++i)ss[cnt[i]].insert(i);
	for(;;){
		if(n-pp<=5)
			{bf();break;}
		if(!ss[n-pp-1].empty())x=*ss[n-pp-1].begin();
			else x=*s.begin()==a[p[pp]]?*++s.begin():*s.begin();
		p[++pp]=x;s.erase(x);ss[cnt[x]].erase(x);
		if(s.count(a[x]))ss[cnt[a[x]]].erase(a[x]),ss[--cnt[a[x]]].insert(a[x]);
	}
	for(i=1;i<=n;++i)printf("%d%c",p[i],i==n?'\n':' ');
}

Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <iomanip>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#pragma GCC optimize("Ofast")
#pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native" )
#define endl "\n"
#define int unsigned long long
#define debug(x) cout << #x << " is " << x << endl;
using namespace std;
int fastpow(int a, int b) {
	if (!b) return 1ll;
	if (b % 2 == 1) return fastpow(a, b - 1) * a;
	int t = fastpow(a, b / 2);
	return t * t;
}
void solve() {
	int n, cursum = 0; cin >> n;
	vector <int> a(n);
	map <int, int> counter;
	for (auto& x : a) {
		cin >> x;
		cursum += x;
		counter[x]++;
	}
	int q, u, v; cin >> q;
	for (int oper = 0; oper < q; oper++) {
		cin >> u >> v;
		counter[v] += counter[u];
		cursum -= counter[u] * u;
		cursum += counter[u] * v;
		counter[u] = 0;
		cout << cursum << endl;
	}
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(15);
	int t; t = 1;
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 10040
import java.util.Scanner

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val h = sc.nextInt()
    val w = sc.nextInt()

    val hNum = sc.nextInt()
    val wNum = sc.nextInt()
    val count = h * w

    val row = hNum * w
    val column = wNum * h
    val dup = hNum * wNum
    val result = count - ((row + column) - dup)
    println(result)
}

Measured memory_bytes: 31384
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
map<int,int>M;
int n,m;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		int k1; scanf("%d",&k1); M[k1]++;
	}
	scanf("%d",&m);
	for (int i=1;i<=m;i++){
		int k1; scanf("%d",&k1); M[k1]--;
		if (M[k1]<0){
			printf("NO\n"); return 0;
		}
	}
	printf("YES\n");
}

Measured memory_bytes: 9600
# 2020/04/26
# AtCoder Beginner Contest 088 - C

# Input
cr = list()
for i in range(3):
    cw = list(map(int,input().split()))
    cr.append(cw)

a = list()
b = list()

a.append(0)
b.append(cr[0][0] - a[0])
a.append(cr[1][0] - b[0])
b.append(cr[0][1] - a[0])
a.append(cr[2][0] - b[0])
b.append(cr[0][2] - a[0])

wkans = list()

for i in range(3):
    wkrow = list()
    for j in range(3):
        wkrow.append(cr[i][j] - (a[i] + b[j]))
    wkans.append(wkrow)

# print(a)
# print(b)
# print(wkans)

if min(wkans) == max(wkans):
    ans = 'Yes'
else:
    ans = 'No'

# Output
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=2e18;
const int MOD=1e9+7;
const int MAX=200001;
int fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

int 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]%MOD)%MOD;
}

int powMOD(int n,int r){
    if(r<=0)return 1;
    if(r%2==0)return powMOD(n,r/2)*powMOD(n,r/2)%MOD;
    if(r%2==1)return powMOD(n,r-1)*n%MOD;
}

signed main(){
    int N;cin>>N;
    pair<int,int> X[N];
  	REP(i,N)X[i]={INF,INF};
    map<pair<int,int>,int>memo;
    int cc=0;
    REP(i,N){
        int a,b;cin>>a>>b;
      	if((a==0)||(b==0)){
          	if(a==0&&b==0){
                cc++;
              	continue;
            }
          	if(a==0){
                memo[{0,1}]++;
                continue;
            }
          	if(b==0){
                memo[{1,0}]++;
                continue;
            }
        }
        int x=__gcd(a,b);
        a/=x;
        b/=x;
        if(a*b>0) memo[{abs(a),abs(b)}]++;
        if(a*b<0) memo[{-abs(a),abs(b)}]++;
    }
    int ans=1;
    for(auto v:memo){
        if(v.second==0)continue;
        int a=v.first.first;
        int b=v.first.second;
        int c,d;
        if(a*b>0&&a>0){
            c=-b;
            d=a;
        }
        else{
            c=b;
            d=-a;
        }
        int z=-1;
        z=(z+powMOD(2,v.second))%MOD;
        z=(z+powMOD(2,memo[{c,d}]))%MOD;
        ans=ans*z%MOD;
        v.second=0;
        memo[{c,d}]=0;
    }
    ans+=cc-1;
    ans%=MOD;
    while(ans<0)ans+=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 31496
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Remoting.Messaging;
using System.Security.Cryptography;
using System.Text;

namespace Contest
{
    class Program
    {

        public void Solve()
        {
            var sc = new Scanner();
            int A = sc.NextInt();
            int B = sc.NextInt();
            int C = sc.NextInt();
            Console.WriteLine(A == B && B == C ? "Yes" : "No");

        }


        static void Main(string[] args) => new Program().Solve();
    }

    class Scanner
    {
        private char _separator = ' ';
        private StreamReader _stream = new StreamReader(Console.OpenStandardInput());
        private int _pos = 0;
        private string[] _line = new string[0];
        public string Next()
        {
            if (_pos >= _line.Length)
            {
                _line = _stream.ReadLine().Split(_separator);
                _pos = 0;
            }
            return _line[_pos++];
        }
        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public string[] Array()
        {
            if (_pos >= _line.Length)
                _line = _stream.ReadLine().Split(_separator);
            _pos = _line.Length;
            return _line;
        }
        public int[] IntArray()
        {
            var arr = Array();
            var res = new int[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = int.Parse(arr[i]);
            }
            return res;
        }
        public long[] LongArray()
        {
            var arr = Array();
            var res = new long[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = long.Parse(arr[i]);
            }
            return res;
        }
        public double[] DoubleArray()
        {
            var arr = Array();
            var res = new double[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = double.Parse(arr[i]);
            }
            return res;
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define each(i, c) for (auto& (i) : (c))

using namespace std;
typedef long long int lli;
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }

int main() {
    int n;
    cin >> n;
    int fs[n];
    rep(i,n) {
        int b = 0;
        rep(j,10) {
            int f;
            cin >> f;
            b |= (f << j);
        }
        fs[i] = b;
    }

    int ps[n][11];
    rep(i,n)rep(j,11) cin >> ps[i][j];

    int m = -1e9-1;
    for (int i = 1; i < (1 << 10); i++) {
        int sum = 0;
        rep(j,n) {
            int cnt = 0;
            int mul = i & fs[j];
            rep(k,10) {
                cnt += (mul >> k) & 1;
            }
            sum += ps[j][cnt];
        }
        m = max(m, sum);
    }

    cout << m << endl;

    return 0;
}

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int N = int.Parse(strs[0]);
            int K = int.Parse(strs[1]);
            line = Console.ReadLine();
            strs = line.Split(' ');
            int[] p = new int[N];
            for(int i = 0; i < N; i++)
            {
                p[i]= int.Parse(strs[i]);
            }
            var list = p.ToList();
            list.Sort();
            int min = 0;
            for(int i = 0; i < K; i++)
            {
                min += list[i];
            }

            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 27976
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;
    
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           int k;
           cin >> k;
           
           int a = 7 % k;
           
           for(int i = 1 ; i <= k; i++)
           {
                if(a % k == 0)
                {
                    cout << i << endl;
                    return 0;
                }
                a *= 10 ;
                a += 7;
                a %= k;
           }
           cout << -1 << endl;
        }
    }



Measured memory_bytes: 3616
import java.util.*;
public class Main{
  static public void main(String ... args){
    final Scanner sc = new Scanner(System.in);
    final int N = sc.nextInt();
    final int A = sc.nextInt();
    final int B = sc.nextInt();
    if(N * A < B ){
      System.out.println(N*A);
    }else{
      System.out.println(B);
    }
    sc.close();
  }
}

Measured memory_bytes: 21588
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;


int n;
vector<PII> G[200000];
int d[200000];
void dfs(int u, int s) {
	if (s == 0)d[u] = 1;
	else d[u] = 2;
	rep(i, G[u].size()) {
		PII p = G[u][i];
		if (d[p.fi] != 0)continue;
		dfs(p.fi, (s + p.se) % 2);
	}
	return;
}


int main() {

	cin >> n;
	rep(i, n - 1) {
		int u, v, w;
		cin >> u >> v >> w;
		G[u].pb(dmp(v, w));
		G[v].pb(dmp(u, w));
	}

	dfs(1, 0);
	rrep(i, n)cout << d[i] - 1 << endl;

	return 0;
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n);; ++i)
using namespace std;
using ll = long long;
using p = pair<int, int>;
int x, a;
int main() {
    cin >> x >> a;
    if (x <= a) {
        cout << "unsafe";
    }
    else {
        cout << "safe";
    }
        return 0;
}

Measured memory_bytes: 3632
use proconio::input;

fn sieve(n: usize) -> (Vec<usize>, Vec<bool>) {
  let mut primes = Vec::new();
  let mut is_prime = vec![true; n];
  is_prime[0] = false;
  is_prime[1] = false;
  for i in 2..n { 
    if is_prime[i] {
      primes.push(i);
    }
    for &p in &primes {
      if i * p >= n {
        break;
      }
      is_prime[i * p] = false;
      if i % p == 0 {
        break;
      }
    }
  }
  (primes, is_prime)
}

fn main() {
  input! { 
    x: usize,
  }
  let (_, is_prime) = sieve(2*x);
  for p in x..2*x {
    if is_prime[p] {
      println!("{}", p);
      break;
    }
  }
}


Measured memory_bytes: 2472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/
const int MAX_N = 10000000;

int n;
string s;
bitset<26> dat[MAX_N];

void update(int k, char a);
void init(int n_)
{
    n = 1;
    while (n < n_)
        n *= 2;

    rep(i, n_)
    {
        update(i, s[i]);
    }
}

//k番目の値をaに変更
void update(int k, char a)
{
    k += n - 1;

    dat[k] = 1 << (a - 'a');

    while (k > 0) {
        k = (k - 1) / 2;
        dat[k] = (dat[k * 2 + 1] | dat[k * 2 + 2]);
    }
}

//[a,b)の最小値を求める

bitset<26> query(int a, int b, int k, int l, int r)
{
    if (r <= a || b <= l)
        return bitset<26>(0);
    if (a <= l && b >= r)
        return dat[k];

    bitset<26> vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    bitset<26> vr = query(a, b, 2 * k + 2, (l + r) / 2, r);

    return (vl | vr);
}

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    int Q;
    cin >> N >> s >> Q;

    init(N);


    rep(_, Q)
    {
        int q;
        cin >> q;
        --q;
        if (!q) {
            int i;
            char c;
            cin >> i >> c;
            --i;
            update(i, c);
        } else {
            int l, r;
            cin >> l >> r;
            --l;
            auto ans = query(l, r, 0, 0, n);
            cout << ans.count() << endl;
        }
    }
}


Measured memory_bytes: 8988
N = int(input())
a = list(map(int, input().split()))

c = [0,0,0,0]
for x in a:
    c[x % 4] += 1

# if (c[1]==0) and (c[3]==0):
#     print('Yes')

if c[1] + c[3] < c[0] + 1:
    print('Yes')
elif (c[1] + c[3] == c[0] + 1)and(c[2] == 0):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 15020
#include <algorithm>
#include <iostream>
#include <queue>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int64_t r[100'000];
int64_t l[100'000];

int main()
{
    int n;
    cin >> n;
    priority_queue<int64_t, vector<int64_t>, greater<int64_t>> rq1, rq2;
    priority_queue<int64_t, vector<int64_t>, less<int64_t>> lq1, lq2;

    rep(i, n)
    {
        cin >> l[i] >> r[i];

        rq1.push(r[i]);
        lq1.push(l[i]);
    }
    rq2 = rq1;
    lq2 = lq1;

    int64_t score1 = 0;
    int64_t cr = 0, cl = 0;
    while (true) {
        if (lq1.empty() || lq1.top() < cr) {
            score1 += abs(cr);
            break;
        }
        cl = lq1.top();
        lq1.pop();
        score1 += cl - cr;

        if (rq1.empty() || rq1.top() > cl) {
            score1 += abs(cl);
            break;
        }
        cr = rq1.top();
        rq1.pop();
        score1 += cl - cr;
    }

    int64_t score2 = 0;
    cl = cr = 0;
    while (true) {
        if (rq2.empty() || rq2.top() > cl) {
            score2 += abs(cl);
            break;
        }
        cr = rq2.top();
        rq2.pop();
        score2 += cl - cr;

        if (lq2.empty() || lq2.top() < cr) {
            score2 += abs(cr);
            break;
        }
        cl = lq2.top();
        lq2.pop();
        score2 += cl - cr;
    }
    cout << max(score1, score2) << endl;
    return 0;
}

Measured memory_bytes: 5100
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; 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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;

  cout << (e-a<=k ? "Yay!" : ":(") << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  rep(i, n) {
    cin >> a;
    ans += a - 1;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var Pos = new List<int[]>();
            for(int i = 0; i < N; i++)
            {
                var tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                Pos.Add(tmp);
            }
            var enumrable = Enumerable.Range(0, N);
            var jyunretu = Permutation<int>.All(enumrable);
            var sum = 0d;
            foreach(int[] x in jyunretu)
            {
                for(int i = 0; i < x.Length - 1; i++)
                {
                    
                    sum+=Math.Sqrt(Math.Pow((Pos[x[i]][0] - Pos[x[i+1]][0]), 2) + Math.Pow((Pos[x[i]][1] - Pos[x[i+1]][1]), 2));
                }
            }
            Console.WriteLine(sum / jyunretu.Count());


        }
    }

    static class Permutation<T>
    {
        private static void Search(List<T[]> perms, Stack<T> stack, T[] a)
        {
            int N = a.Length;
            if (N == 0)
            {
                perms.Add(stack.Reverse().ToArray());
            }
            else
            {
                var b = new T[N - 1];
                Array.Copy(a, 1, b, 0, N - 1);
                for (int i = 0; i < a.Length; ++i)
                {
                    stack.Push(a[i]);
                    Search(perms, stack, b);
                    if (i < b.Length) { b[i] = a[i]; }
                    stack.Pop();
                }
            }
        }
        public static IEnumerable<T[]> All(IEnumerable<T> src)
        {
            var perms = new List<T[]>();
            Search(perms, new Stack<T>(), src.ToArray());
            return perms;
        }
    }
}

Measured memory_bytes: 20564
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    int K;cin >> K;
    string S;cin >> S;
    if(S.size() <= K){
        cout << S << endl;
        return 0;
    }
    for(int i = 0;i<K;i++){
        cout << S.at(i);
    }
    cout << "..." << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>


void BubbleSort(int a[], int N) {
	int buf;
	for (int i = 0; i < N - 1; i++) {
		for (int j = 0; j < N - 1 - i; j++) {
			if (a[j] < a[j + 1]) {
				buf = a[j];
				a[j] = a[j + 1];
				a[j + 1] = buf;
			}
		}
	}
}

int main() {
	int inp[5];

	for (int i = 0; i < 5; i++) {
		scanf("%d", &inp[i]);
	}
	BubbleSort(inp, 5);

	printf("%d %d %d %d %d\n", inp[0], inp[1], inp[2], inp[3], inp[4]);

	return 0;
}


Measured memory_bytes: 2104
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

int main() {
  int N;
  cin >> N;
  long H[N];
  for (int i = 0; i < N; i++) cin >> H[i];

  int current = 0;
  bool flag = true;
  for (int i = 0; i < N; i++) {
    if (!flag) break;
    if (H[i] > current) {
      current = H[i] - 1;
    } else if (H[i] == current) {
      current = H[i];
    } else {
      flag = false;
    }
  }

  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200005;
int n,a[N],b[N];
int bin(int v){
	int l=1,r=n;
	for(;l<r;){
		int mid=(l+r)/2;
		if(v>b[mid])l=mid+1;else r=mid;
	}
	return l;
}
int main(){
	//freopen("aa.in","r",stdin);
	int i,j;
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",a+i),b[i]=a[i];
	sort(b+1,b+1+n);
	for(i=1;i<=n;++i){
		int k=bin(a[i]);
		if(k<=n/2)printf("%d\n",b[n/2+1]);
		else printf("%d\n",b[n/2]);
	}
	return 0;
}

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

using namespace std;

int find_min_index(vector <int> a, int N) {
    int index = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] > 0) {index = i; break;}
        else continue;
    }   
    return index;
}

int main() {
    int N; cin >> N;
    int min_index = 0;
    vector <int> a(N, 0); 
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }   
    sort(a.begin(), a.end());
    while (min_index < N - 1) {
        int min = a[min_index];
        for (int i = N - 1; i > min_index; i--) {
            a[i] = a[i] % min;
        }   
        sort(a.begin(), a.end());
        min_index = find_min_index(a, N); 
    }   
    cout << a[N - 1] << endl;
}


Measured memory_bytes: 1024
a,b = map(int,input(). split ())
if not b % 2 == 0:
    print('No')
elif a > 100:
    print('No')
elif b > 100:
    print('No')
elif a < 1:
    print('No')
elif b < 1:
    print('No')
elif not isinstance(a, int):
    print('No')
elif not isinstance(b, int):
    print('No')
elif 2 * a <= b <= 4 * a:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9220
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int n;
  cin >> n;
  cout << n*n << endl;

	return 0;
}

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

int main()
{
    int a,b,d,r;
    double f;

    std::cin >> a >> b;
    
    d = a/b;
    r = a%b;
    f = (double)a/(double)b;
    
    std::cout << d << " " << r << " " ;
    std::cout << std::fixed << std::setprecision(6) << f << std::endl;
    
    return 0;
}


Measured memory_bytes: 3292
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
struct NODE{
	int a; int b;
} num[200005];

bool cmp(NODE x, NODE y)
{
	if(x.a < y.a) return true;
	else return x.a < y.a;
}
int p[200005], flag[200005];
int n, m;
int main()
{
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; i++)
	{
		scanf("%d %d", &num[i].a, &num[i].b);
	}
	sort(num + 1, num + 1 + m, cmp);
	for(int i = 1; i <= m; i++)
	{
		if(num[i].a == 1) flag[num[i].b]++;
	}
	for(int i = 1; i <= m; i++)
	{
		if(num[i].b == n) flag[num[i].a]++;
	}
	int t = 0;
	for(int i = 1; i <= n; i++)
	{
		if(flag[i] == 2) t = 1;
	}
	if(t == 1) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 2560
N, *AB = map(int, open(0).read().split())
A, B = AB[:N], AB[N:]

ans = 0
while True:
    cnt = 0
    for i in range(N):
        b = B[(i - 1) % N] + B[(i + 1) % N]
        if 0 < b < B[i] and A[i] < B[i]:
            tmp = (B[i] - A[i]) // b
            cnt += tmp
            B[i] -= tmp * b
    if cnt == 0:
        break
    ans += cnt

if A == B:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 127208
N,A,B = map(int,input().split())

if A >B:
  ans = 0
elif N==1:
  if A ==B:
    ans = 1
  else:
    ans =0
else:
  X = A*(N-1)+B
  Y = A+(N-1)*B
  ans =Y - X + 1
print(ans)

Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,g,cnt=0,k=0,MIN=1e9,tmp=0;
  cin >> n;
  if(n<1200){
    cout << "ABC" << endl;
  }else if(1200<=n and n<2800){
    cout << "ARC" << endl;
  }else{
    cout <<"AGC" << endl;
  }
  // long long a[n],b[n];
  // pair<long long,long long> p[n];
  // for(int i=0;i<n;i++){
  //   cin >> a[i] >> b[i];
  //   tmp=100*(i+1)*a[i];
  //   if(tmp+b[i]>=g){
  //     if(tmp>g){
  //       MIN=min(MIN,(g+100*(i+1)+1)/(100*(i+1)));
  //     }else{
  //       MIN=min(MIN,a[i]);
  //     }
  //   }
  //   p[i]=make_pair((100*(i+1)*a[i]+b[i])/a[i],i);
  // }
  // sort(p,p+n);
  // reverse(p,p+n);
  // while(1){
  //   g-=(p[k].second+1)*100;
  //   a[p[k].second]--;
  //   if(a[p[k].second]==0){
  //     g-=b[p[k].second];
  //     k++;
  //   }
  //   cnt++;
  //   if(g<=0){
  //     break;
  //   }
  // }
  // cout << min(cnt,MIN) << endl;
  return 0;
}



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

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

int main() {
	int n;
    cin >> n;
    vector<int> a(n);
    ll all;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if(i == 0) all = a[i];
        else all = gcd(all, a[i]);
    }
    
    unordered_set<int> seen;
    bool pc = true;
    for (int i = 0; i < n; ++i) {
        int tmp = a[i];
        for (int j = 2; j * j <= tmp; ++j) {
            if(tmp > 1 && tmp % j == 0 && seen.count(j)) {
                pc = false;
                break;
            }
            while(tmp > 1 && tmp % j == 0) {
                seen.insert(j);
                tmp /= j;
            }
        }
        if(tmp > 1 && seen.count(tmp)) pc = false;
        else if(tmp > 1) seen.insert(tmp);
        if(!pc) break;
    }

    if(pc) puts("pairwise coprime");
    else if(all == 1ll) puts("setwise coprime");
    else puts("not coprime");
}


Measured memory_bytes: 7192
N, K = map(int, input().split())

MOD = 10**9 + 7

# パスカルの三角形
# comb[i][j] = iCj(i,jは1以上。iまたはjが0のときは一応入っているがコンビネーションの計算では不要)
comb = [[0]*(N+1) for _ in range(N+1)]
comb[0][0] = 1
for i in range(N):
    for j in range(i+1):
        comb[i+1][j] += comb[i][j]
        comb[i+1][j+1] += comb[i][j]

for i in range(1, K+1):
    a = comb[N-K+1][i] # redの隙間または端にi個に分割したbrueを入れる総数
    b = comb[K-1][i-1] # brueをi個に分割する総数
    ans = (a * b) % MOD
    print(ans)


Measured memory_bytes: 356536
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int N,M;
  cin >> N >> M;
  vector<int> S(N),T(M);
  cin >> S >> T;
  auto dp = make_v<int>(N+1,M+1);
  fill_v(dp,0);
  dp[0][0] = 1;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= M; j++) {
      if (i+1 <= N && j+1 <= M && S[i] != T[j]) (dp[i+1][j+1] += MOD - dp[i][j]) %= MOD;
      if (i+1 <= N) (dp[i+1][j] += dp[i][j]) %= MOD;
      if (j+1 <= M) (dp[i][j+1] += dp[i][j]) %= MOD;
    }
  }
  cout << dp[N][M] << endl;

  return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<ll> a(n);rep(i,n){cin>>a[i];}
#define in(a) ll a;cin>>a;
#define out(a) cout<<a<<endl;

int main()
{
    in(n);
    repin(v,n);
    sort(v.begin(),v.end());
    double a = v[0];
    rep(i,n-1){
        a = (a + v[i+1])/2; 
    }
     printf("%.10f", a);
}

Measured memory_bytes: 256
#include<stdio.h>
	int isprime(int n){
		for(int i=2;i*i<=n;i++){
			if(n%i==0)return 0;
		}
		return 1;
	}
	int main(){
		int v,k;
		while(1){
			scanf("%d",&v);
			if(v==0)break;
			for(k=v;k>=0;k--){
				if(isprime(k)==1 && isprime(k-2)==1){
					printf("%d %d\n",k-2,k);
					break;
				}
			}
		}
		return 0;
	}

Measured memory_bytes: 2628
#include<iostream>
#include<math.h> 
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long int lli;
lli mod=1000000007;
vector < lli> primes;

void Sieve(lli n) 
{ 
    bool prime[n+1];
	for(lli i=0;i<n+1;++i)
		prime[i]=true;
    for (lli p=2;p*p<=n;++p) 
    {
        if (prime[p] == true) 
        {  
            for (lli i=2*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
    for(lli p=2; p<=n; p++) 
       if (prime[p]) 
		primes.push_back(p);  
}
lli gcd(lli a,lli b)  
 {
    if(b>a)
        swap(a,b);
    if (a%b==0)  
        return b;  
    else 
        return gcd(a%b,b);  
 }
lli lcm(lli a,lli b)
{
    return (a*b)/gcd(a,b);    
}
lli power(lli x,lli y,lli m)   
{ 
    lli res = 1; 
    x=x%m;   
    while (y > 0) 
    {  
        if (y%2==1) 
            res =(res*x)%m;  
        y=y/2; 
        x=(x*x)%m; 
    } 
    return res; 
}
bool sortcol( const vector<lli>& v1, const vector<lli>& v2 ) { 
    return v1[1] < v2[1]; 
}
bool sortcol1( const vector<lli>& v1, const vector<lli>& v2 ) { 
    return v1[0] < v2[0]; 
}
int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	lli n,cnt=0;
	cin>>n;
	lli k[n];
	for(lli i=0;i<n;++i)
		cin>>k[i];
	sort(k,k+n);
	lli ans=k[n/2]-k[(n/2)-1];
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#a = int(input())
#b = list(input())
#c = list(map(int,input().split()))

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

for i in range(M):
    N -= A[i]

if N>-1:
    print(N)
else:
    print("-1")

Measured memory_bytes: 68052
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] idxes = new int[n + 1];
        TreeSet<Integer> allIdx = new TreeSet<>();
        allIdx.add(-1);
        allIdx.add(n);
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            idxes[x] = i;
            allIdx.add(i);
        }
        long total = 0;
        for (int i = n; i > 0; i--) {
            long left = allIdx.lower(idxes[i]);
            long right = allIdx.higher(idxes[i]);
            total += i * (idxes[i] - left) * (right - idxes[i]);
            allIdx.remove(idxes[i]);
        }
        System.out.println(total);
    }
}


Measured memory_bytes: 101984
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	string S;
	cin >> S;
	string ans = "Yes";
	int N = S.length();
	if(N%2==1)
		ans = "No";
	else {
		rep(i, N / 2) {
			if (S[i * 2] != 'h' || S[i * 2 + 1] != 'i')
				ans = "No";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N, L = [int(i) for i in input().split()]

ts = [L + i for i in range(N)]
target = abs(ts[0])
target_i = 0
for i, t in enumerate(ts):
    if target > abs(t):
        target = abs(t)
        target_i = i

ts.pop(target_i)
print(sum(ts))



Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5010;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

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

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

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

char c[2010][2010];
bool flag[2010][2010];
ll cnt[2010][2010];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	vector<ll>state;
	ll now = 1;
	ll cnt = 0;
	rep(i, n) {
		if (s[i] == (char)('0' + now))cnt++;
		else {
			state.push_back(cnt);
			now = 1 - now;
			cnt = 1;
		}
	}
	if (cnt != 0)state.push_back(cnt);
	if (state.size() % 2 == 0)state.push_back(0);
	vector<ll>sum(state.size() + 1);
	rep(i, state.size()) {
		sum[i + 1] = sum[i] + state[i];
	}
	ll add = 2 * k + 1;
	ll ans = 0;
	ll n2 = state.size();
	for (ll i = 0;i < n2;i += 2) {
		ll left = i;
		ll right = min(i + add, n2);
		ll tmp = sum[right] - sum[left];
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 2164
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, a, N) for(int i = a; i < N; i++)

int main() {
    int N;
    cin >> N;
    int ans = 0;
    rep(i, 0, N) {
        int a;
        cin >> a;
        int cnt = 0;
        while (a % 2 == 0) {
            cnt++;
            a /= 2;
        }
        ans += cnt;
    }
    cout << ans << endl;
}

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

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

    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i].first;
        a[i].second = i + 1;
    }

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

    for (auto i: a)
        cout << i.second << " ";
    cout << '\n';

    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

ll get(ll n, ll i) {
    return (n >> (i * 10)) & ((1LL << 10) - 1);
}

int main() {
    ll l[3];
    for (auto &e: l) cin >> e;
    ll k;
    cin >> k;
    vector<ll> a[3];
    for (ll i = 0; i < 3; ++i) a[i].resize(l[i]);
    for (auto &v: a) for (auto &e: v) cin >> e;
    for (auto &v: a) sort(v.begin(), v.end(), greater<ll>());

    using Node = pair<ll, ll>;
    set<Node, greater<Node>> s;
    set<ll> used;
    ll c = 0;
    for (auto &v: a) c += v[0];
    s.insert(make_pair(c, 0LL));
    used.insert(0);
    ll cnt = 0;
    while (cnt < k) {
        auto fr = *s.begin(); s.erase(s.begin());
        cout << fr.first << endl;
        ++cnt;
        for (ll i = 0; i < 3; ++i) {
            ll idx = fr.second;
            idx += 1LL << (i * 10);
            if (get(idx, i) >= l[i]) continue;
            if (used.count(idx) > 0) continue;
            ll cost = fr.first;
            cost -= a[i][get(idx, i) - 1];
            cost += a[i][get(idx, i)];
            s.insert(make_pair(cost, idx));
            used.insert(idx);
        }
    }

    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll long long int 
#define fori(i,n) for(i=0; i<n; i++)
#define ford(i,n) for(i=n-1; i>=0; i--)
#define vi vector<int> 
#define vs vector<string>
#define vll vector<ll>
#define di deque<int>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define pqi priority_queue<int>
#define pqll priority_queue<ll>
#define mod1 1000000007
#define mod2 998244353
#define pb push_back
#define fi first
#define se second
using namespace std;


int main(int argc, char const *argv[]){
	ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    ll n,i,j;
    cin>>n;
    cout<<(n*(n-1))/2<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N, L;
    cin >> N >> L;
    vector<int> taste(N);
    int total = 0;
    rep(i, 0, N)
    {
        taste.at(i) = L + i;
        total += taste.at(i);
    }
    if (L >= 0)
    {
        total -= taste.at(0);
    }
    else if (L + N - 1 < 0)
    {
        total -= taste.at(N - 1);
    }
    cout << total << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2e5+10;

int n,a[N];
ll f[N],s[N];

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		s[i]=(i>1?s[i-2]:0)+a[i];
	}
	for(int i=2;i<=n;i++)
		if(i&1) f[i]=max(f[i-1],f[i-2]+a[i]);
		else f[i]=max(s[i-1],f[i-2]+a[i]);
	printf("%lld\n",f[n]);return 0;
}


Measured memory_bytes: 5612
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial,hypot
#import sys
#from fractions import gcd
setrecursionlimit(10**6)
input=stdin.readline

h=int(input().rstrip())
cnt,ans=1,0
while h>1:
    h//=2
    ans+=cnt
    cnt*=2
    #print(h,cnt,ans)
print(ans+cnt)

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

using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vb = vector<bool>;
using vs = vector<string>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const ld eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i, a, b) for (ll i=(a); i<(b);i++)
#define FORD(i, a, b) for (ll i=ll(b)-1; i>=(a); i--)
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll longestPath[100005] = {0};

map<ll, set<ll>> paths = {};

ll longest(ll knoten) {
	if (longestPath[knoten] != -1) {
		return longestPath[knoten];
	}
	ll max = 0;
	for (auto i : paths[knoten]) {
		if (longest(i) + 1 > max)
			max = longest(i) + 1;
	}
	longestPath[knoten] = max;
	return max;
}

int main() {

	std::fill(std::begin(longestPath), std::begin(longestPath) + sizeof(longestPath) / sizeof(longestPath[0]), -1);
	cin.sync_with_stdio(0);

	ll n, m;
	cin >> n >> m;

	FOR(i, 0, m) {
		ll x, y;
		cin >> x >> y;
		paths[x].insert(y);
	}

	ll max = 0;

	FOR(i, 1, n + 1) {
		ll tmp = longest(i);
		if (tmp > max) max = tmp;
	}

	cout << max;
}

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

using namespace std;

int main() {
	string str;
	cin >> str;
	if (str.at(2) == str.at(3) && str.at(4) == str.at(5)) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256