akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) int x; cin>>(x);
#define SIN(x) string x; cin>>(x);
#define INN(x, y) int x, y; cin>>(x)>>(y);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x,v) lower_bound((x).begin(),(x).end(),(v))-(x).begin();
#define uboundv(x,v) upper_bound((x).begin(),(x).end(),(v))-(x).begin();
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1
#define mp make_pair

typedef long long ll;
typedef long double LD;

using namespace std;

#define N 100005

int main() {
	ios::sync_with_stdio(0);
    INN(d, n);
    ll ans = 0;
    F(n) ans++;
    if(n==100) ans++;
    F(d) ans *= 100;
    cout<<ans<<endl;
	return 0;
}


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

int main() {
    int n,k;
    cin>>n>>k;
    double ans=0,res;
    vector<double> p(n),b(n+1,0);
    rep(i,n) {
        cin>>p[i];
        p[i]++;
    }
    for (int i=0; i<n; i++) {
        b[i+1]=b[i]+p[i];
    }

    for (int i=0; i<=n-k; i++) {
        res=b[i+k]-b[i];
        ans=max(ans,res);
    }
    printf("%.12f\n",ans/2.0);
}

Measured memory_bytes: 3328
using System;

class BaseballSimulator {
    public int Point { get; private set; }
    bool first;
    bool second;
    bool third;
    int outCount = 0;

    public void Hit() {
        if (third)
            this.Point++;
        else {
            third = second;
            second = first;
            first = true;
        }
    }

    public void HomeRun() {
        this.Point += third ? 4 : second ? 3 : first ? 2 : 1;
        first = second = third = false;
    }

    public int Out() {
        return ++outCount;
    }

    static void Main() {
        var n = int.Parse(Console.ReadLine());
        for (var i = 0; i < n; i++) {
            Inning();
        }
    }

    static void Inning() {
        var sim = new BaseballSimulator();
        while (true) {
            var ev = Console.ReadLine();
            switch (ev) {
                case "HIT":
                    sim.Hit();
                    break;
                case "HOMERUN":
                    sim.HomeRun();
                    break;
                case "OUT":
                    if (sim.Out() == 3) {
                        Console.WriteLine(sim.Point);
                        return;
                    }
                    break;
            }
        }
    }
}

Measured memory_bytes: 9208
package main

import "fmt"

func isOdd(n int) bool { return n%2 != 0 }

func swap(a *int, b *int) { *a, *b = *b, *a }

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a > b {
		swap(&a, &b)
	}
	if d := b - a; isOdd(d) {
		fmt.Printf("IMPOSSIBLE\n")
	} else {
		fmt.Printf("%v\n", d/2+a)
	}
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int[] nums = sc.IntArray();
        nums = nums.OrderBy(n => n).ToArray();

        int answer = nums[0] + nums[1] + nums[2] * 10;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define P std::pair<int,int> 
#define INF LLONG_MAX/3
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n,a[200010];
signed main() {
	cin>>n;
	rep(i,n)cin>>a[i];
	for(int i=1;i<n;i++)a[i]+=a[i-1];
	int b=0,c=0,ans=INF;
	for(int i=1;i<n-2;i++){
		c=max(i+1,c);
		while(b<i){
			if(abs((a[i]-a[b])-a[b])<abs((a[i]-a[b+1])-a[b+1]))break;
			b++;
		}
		while(c<n-1){
			if(abs((a[c]-a[i])-(a[n-1]-a[c]))<abs((a[c+1]-a[i])-(a[n-1]-a[c+1])))break;
			c++;
		}
		ans=min(ans,max({a[b],a[i]-a[b],a[c]-a[i],a[n-1]-a[c]})-min({a[b],a[i]-a[b],a[c]-a[i],a[n-1]-a[c]}));
	}
	cout<<ans<<endl;
	return 0;
}

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

#define fastio()   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll     long long int

int main()
{
    string s1;
    cin>>s1;
    string s2;
    cin>>s2;
    ll cnt=0;
    for(ll i=0;i<s1.size();i++)
    {
        if(s1[i]!=s2[i])
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3900
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <cmath>
#include <cstring>
#include <cstdio>

using namespace std;

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

int N;
ll A[100001];
ll B[100001];
ll X[100001][2];

int main() {
    scanf("%d", &N);
    rep(i, N + 1) scanf("%lld", &A[i]);
    rep(i, N) scanf("%lld", &B[i]);
    rep(i, N) {
        ll a = i > 0 ? A[i] - X[i - 1][1] : A[i];
        X[i][0] = min(a, B[i]);
        X[i][1] = min(B[i] - X[i][0], A[i+1]);
    }
    ll ans = 0;
    rep(i, N) ans += X[i][0] + X[i][1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
int main(){
  int n,m,i,p,ans1=0,ans2=0,a[100010],b[100010];
  string s;
  scanf("%d %d\n",&n,&m);
  for(i=0;i<=n;i++){
    a[i]=0,b[i]=0;
  }
  for(i=0;i<m;i++){
    cin >> p >> s;
    if(s=="WA" && a[p]==0){
      b[p]++;
    }
    if(s=="AC" && a[p]==0){
      ans1++;
      ans2=ans2+b[p];
      a[p]=1;
    }
  }
  printf("%d %d\n",ans1,ans2);
  return 0;
}

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

int main(){

  int n;
  int a,b;
  int z[1000][1000] = {0};

  cin >> n;

  for(int i=0;i<n;i++){
    cin >> a >> b;
    z[b][a] = 1;
  }

  for(int i=100;i>=0;i--){
    for(int j=1;j<=20;j++){
      if(z[i][j] == 1){
	cout << j << " " << i << endl;
	return 0;
      }
    }
  }

}

Measured memory_bytes: 5076
#![allow(unused_imports)]

use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        s: usize,
    }

    let m = 10usize.pow(9) + 7;

    let mut list = vec![0; s + 6];
    list[3] = 1;
    list[4] = 1;
    list[5] = 1;

    for i in 6..(s + 1) {
        let mut j = i as isize - 3;
        while j >= 0 {
            list[i] += list[j as usize] % m;
            j -= 1;
        }
        list[i] += 1;
        list[i] = list[i] % m;
    }
    println!("{}", list[s]);
}


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

const int N = 100;
int M[N][N];
int n;
int t;
int color[N];
int d[N], f[N];

void init(){
  for(int i=0;i<n;i++){
    color[i] = 0;
  }
}

void dfs(int x){
  color[x] = 1;
  d[x] = ++t;
  for(int i=0;i<n;i++){
    if(M[x][i] == 1 && color[i] == 0){
      dfs(i);
    }
  }
  color[x] = 2;
  f[x] = ++t;
}

int main(){
  cin >> n;
  int u, k, v;
  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int j=0;j<k;j++){
      cin >> v;
      M[u-1][v-1] = 1;
    }
  }
  init();
  for(int i=0;i<n;i++)
    if(color[i] == 0) dfs(i);
  for(int i=0;i<n;i++){
    cout << i+1 << " " << d[i] << " " << f[i] << endl;
  }
  return 0;
}



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

int main () {
  vector<string> vec{"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string in;
  cin >> in;
  
  for(int i = 0 ; i < 7 ; i++) {
    if(in == vec.at(i) && i != 6) {
	  cout << 7 - i << endl;
      break;
    }
    else if(i == 6) cout << 1 << endl;
  }
}

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

using namespace std;
using namespace __gnu_cxx;

random_device rd;
mt19937 rnd(rd());
#define pt pair<int, int>
#define x first
#define y second
#define what_is(x) cerr << #x << " is " << x << endl;
#define ok cerr << "ok" << endl;
#define endl '\n'
#define int long long
#define ld long double

int ans = 0, n, m, q;
int all[51][4];

void solve(vector<int> &a)
{
	if (a.size() == n)
	{
		int cur = 0;
		for (int i = 0; i < q; ++i)
		{
			int x = all[i][1] - 1, y = all[i][0] - 1;
			if (a[x] - a[y] == all[i][2]) cur += all[i][3];
		}

		ans = max(ans, cur);

		return;
	}

	for (int i = 1; i <= m; ++i)
	{
		if (a.size() == 0 || a.back() <= i)
		{
			a.push_back(i);
			solve(a);
			a.pop_back();
		}
	}
}

signed main()
{
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);

	cin >> n >> m >> q;
	for (int i = 0; i < q; ++i)
		for (int j = 0; j < 4; ++j)
			cin >> all[i][j];
	vector<int> a;
	solve(a);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3648
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        txy: [(i64, i64, i64); n],
    }
    let mut t0 = 0i64;
    let mut x0 = 0i64;
    let mut y0 = 0i64;
    for (t, x, y) in txy {
        let d = (x - x0).abs() + (y - y0).abs();
        if t - t0 - d < 0 || (t - t0 - d) % 2 == 1 {
            println!("No");
            return;
        }
        t0 = t;
        x0 = x;
        y0 = y;
    }
    println!("Yes");
}


Measured memory_bytes: 8444
#include <cstdio>
#include <cstdlib>

int main(int argc, char const* argv[])
{
	int al[26];
	int c;
	for(int i = 0; i < 26; i++){
			al[i] = 0;
	}
	int i = 0;
	while((c = getchar()) != EOF){
			if(c - 'a' >= 0 && c - 'a' <= 25)al[c - 'a'] += 1;
			else if(c - 'A' >= 0 && c - 'A' <= 25)al[c - 'A'] += 1;
			i++;
	}
	for(int i = 0; i < 26; i++){
			printf("%c : %d\n", 'a' + i, al[i]);
	}
	return 0;
}



Measured memory_bytes: 2680
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

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

using namespace std;

typedef long long ll;



int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    repeat(i, 3){
        s[i][0] += -'a'+'A';
    }
    cout << s[0][0] << s[1][0] << s[2][0] << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc054a()
}

fun abc054a() {
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        .map { if (it == 1) it + 13 else it }

    val answer = if (a > b) "Alice" else if (a < b) "Bob" else "Draw"

    println(answer)
}


Measured memory_bytes: 37948
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vint r(a), g(b), n(c);
    rep(i, a) cin >> r[i];
    rep(i, b) cin >> g[i];
    rep(i, c) cin >> n[i];

    sort(r.rbegin(), r.rend());
    sort(g.rbegin(), g.rend());
    sort(n.rbegin(), n.rbegin());

    vint all;
    rep(i, x) { all.emplace_back(r[i]); }
    rep(i, y) all.emplace_back(g[i]);
    rep(i, c) all.emplace_back(n[i]);

    sort(all.rbegin(), all.rend());

    ll ans = 0;
    rep(i, x + y)
    {
        ans += all[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<complex>
#include<random>
using namespace std;

typedef unsigned long long ull;

int main(){
    int N;
    ull V, x;
    cin >> N >> V;
    ull a[N], b[N], c[N], d[N];
    for (int i=0;i<N;i++) {cin >> a[i];}
    for (int i=0;i<N;i++) {cin >> b[i];}
    for (int i=0;i<N;i++) {cin >> c[i];}
    for (int i=0;i<N;i++) {cin >> d[i];}

    vector<ull> abList;
    vector<ull> cdList;
    for (int i=0;i<N;i++){
        for (int j=0;j<N;j++){
            abList.push_back(a[i]+b[j]);
        }
    }
    for (int i=0;i<N;i++){
        for (int j=0;j<N;j++){
            cdList.push_back(c[i]+d[j]);
        }
    }
    sort(cdList.begin(), cdList.end());

    ull S = 0;
    pair<vector<ull>::iterator, vector<ull>::iterator> p;
    for (int i=0;i<N*N;i++){
        p = equal_range(cdList.begin(), cdList.end(), V-abList[i]);
        S += (p.second -p.first);
    }

    cout << S << endl;
    return 0;
}

Measured memory_bytes: 23100
N = int(input())
S = input()

def check(k,s):
    j = 0
    for i in range(len(s)):
        if k[j] == s[i]:
            j += 1
            if j == 3:
                return True
    return False

ans = 0
for k in range(1000):
    if check(str(k).zfill(3),S):
        ans += 1
print(ans)


Measured memory_bytes: 39408
x_1,y_1,x_2,y_2=map(int,input().split())
x_3=x_2-y_2+y_1
y_3=y_2+x_2-x_1
x_4=x_1-y_2+y_1
y_4=y_1+x_2-x_1
print(x_3,y_3,x_4,y_4)

Measured memory_bytes: 2940
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	string  S; cin >> S;
	S[3] = '8';
	cout << S << endl;
}

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

int main() {
  double N,M;
  cin >> N >>M;
  
  vector<double> a(N);
  rep(i,N){
    cin >> a.at(i);
  }
  
  double sum=0;
  rep(i,N){
    sum+=a.at(i);
  }
  
  int cnt=0;
  rep(i,N){
    if(!(a.at(i)<sum/(4*M))){
      cnt++;
    }
  }
  
  if(cnt>=M) cout << "Yes" <<endl;
  else cout << "No" <<endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;


int main() {


	int a, b, c;

	cin >> a >> b >> c;

	int sum = 0;
	int m = -1;
	sum += abs(a - b);
	m = max(abs(a-b), m);
	sum += abs(b - c);
	m = max(abs(b - c), m);
	sum += abs(c - a);
	m = max(abs(c - a), m);

	sum -= m;

	cout << sum << endl;

}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
typedef long long ll;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;


string x, y;
ll c[1005][1005];

ll lcs(ll m, ll n) {
	ll maxv = 0;
	for (int i = 0; i <m; ++i) {
		for (int j = 0; j <n; ++j) {
			if (x[i] == y[j])c[i+1][j+1] = c[i][j] + 1;
			else c[i+1][j+1] = max(c[i][j+1], c[i+1][j]);
			maxv = max(maxv, c[i+1][j+1]);
		}
	}
	return maxv;
}

int main() {
	int q;
	cin >> q;
	vector<ll>ans(q);
	repp(i, 0, q) {
		cin >> x >> y;
		ll m = x.size(), n = y.size();
		memset(c, 0, sizeof(c));
		ans[i] = lcs(m, n);
	}
	for (int i = 0; i < q;++i)cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 11104
import math

a, b = map(int, input().split())

saitei = math.ceil(a/0.08)

for i in range(10000):
    if int((saitei+i)*0.1) == b and int((saitei+i)*0.08) == a:
        print(saitei+i)
        exit()

print(-1)

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const ll INF = 1000000000;
//const ll MOD = 1000000007;
const ld PI = (acos(-1));
using Graph = vector<vector<int>>;
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;}
typedef pair<int, int> pair;
double rad(double a) {return a * 180 / PI;}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//dpTable
int dp[100050];

vector<ll> rsk(100050);

int main(){
    int N;
    cin >> N;
    vector<ll> a(200050);
    for (int i = 1; i <= N; i++) {
        cin >> a.at(i);
    }
    if (N % 2 == 0) {
        for (int i = N; i >= 2; i -= 2) {
            cout << a.at(i) << ' ';
        }
        for (int i = 1; i < N; i += 2) {
            cout << a.at(i) << ' ';
        }
    }
    else {
        for (int i = N; i >= 1; i -= 2) {
            cout << a.at(i) << ' ';
        }
        for (int i = 2; i <= N - 1; i += 2) {
            cout << a.at(i) << ' ';
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5632
MOD = 10**9+7
r1,c1,r2,c2 = map(int,input().split())

size = 1010000*2
f_list = [1]*(size)
for i in range(1,size):
    f_list[i] = (f_list[i-1]*i)%MOD

def func(r,c):
    return (f_list[r+c]*pow(f_list[r],MOD-2,MOD)*pow(f_list[c],MOD-2,MOD))

ans = func(r2+1,c2+1)-1
ans += func(r1,c1)-1
ans -= func(r2+1,c1)-1
ans -= func(r1,c2+1)-1
print(ans%MOD)



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

using namespace std;

int findSCM(int a[],int n)
{

    int rez = a[1];
    for (int i = 2; i <= n; i++)
        rez = rez*a[i]/__gcd(a[i],rez);


        return rez;

}



int main()
{
    int n , a[101] , SCM , k=1;


    cin>>n;

    cin>>a[1];

    for(int i=2;i<=n;i++)
    {
        cin>>a[i];

        if(a[i]==a[i-1]) k++;

    }


        float s;

        SCM=findSCM(a,n);

        for(int i=1;i<=n;i++)  s+=1*(SCM/a[i]);

        s=SCM/s;

        cout<<s;




        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
using ll = long long;
void printString(ll n) 
{ 
    char str[50]; // To store result (Excel column name) 
    ll i = 0; // To store current index in str which is result 
  
    while (n > 0) { 
        // Find remainder 
        ll rem = n % 26; 
  
        // If remainder is 0, then a 'Z' must be there in output 
        if (rem == 0) { 
            str[i++] = 'z'; 
            n = (n / 26) - 1; 
        } 
        else // If remainder is non-zero 
        { 
            str[i++] = (rem - 1) + 'a'; 
            n = n / 26; 
        } 
    } 
    str[i] = '\0'; 
  
    // Reverse the string and print result 
    reverse(str, str + strlen(str)); 
    cout << str << endl; 
  
    return; 
}
int main()
{
	ll n;
    cin >> n;
    printString(n);
	return 0;
}

Measured memory_bytes: 3624
//VS2015エラー回避用
#define _CRT_SECURE_NO_WARNINGS 0 
//include
#include<stdio.h>
//関数プロトタイプ宣言
void probremA(void);
void probremB(void);
void probremC(void);
void probremD(void);

//メイン関数
int main(void) {
	//A問題
	//probremA();
	
	//B問題
	//probremB();

	//C問題
	probremC();

	//D問題
	//probremD();

	//getchar();
	//getchar();
	//終了
	return 0;
}
//A問題
void probremA(void) {
	int i;			//入力数値:人数
	int n=0;		//計算結果:個数
	//入力処理
	scanf("%d", &i);

	//個数の計算
	for (int j = 0; j <= i; j++) {
		n += j;
	}
	//出力処理
	printf("%d\n", n);

	return;
}
//B問題
void probremB(void) {
	char s[11];		//入力文字列
	char o[11];		//出力文字列
	int count_s = 0;//インデックス
	int	count_o = 0;//インデックス
	
	//入力処理
	scanf("%s", &s);

	//出力文字列の計算
	while(s[count_s]!='\0'){
		if (s[count_s] == '0') {
			o[count_o] = '0';
			count_o++;
		}else if(s[count_s] == '1') {
			o[count_o] = '1';
			count_o++;
		}else if (s[count_s] == 'B') {
			count_o = count_o == 0 ? 0 : count_o - 1;
		}
		//次の文字を判別
		count_s++;
	}
	//出力処理
	for (int i = 0; i < count_o; i++) {
		printf("%c", o[i]);
	}

	return;
}
//C問題
void probremC(void) {
	int n = 0;			//入力N
	int a[100] = { 0 };	//入力数列
	int sum = 0;
	int var = 0;
	int var2 = 0;
	//入力処理
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
	}
	
	//平均値がコスト最小になると仮定
	//割り切れないとき
	if (sum%n != 0) {
		for (int i = 0; i < n; i++) {
			var += (sum / n - a[i])*(sum / n - a[i]);
			var2 += (sum / n + 1 - a[i])*(sum / n + 1 - a[i]);
		}
		var = var < var2 ? var : var2;
	}
	//割り切れるとき
	else {
		for (int i = 0; i < n; i++) {
			var += (sum / n - a[i])*(sum / n - a[i]);
		}
	}
	//出力結果
	printf("%d\n", var);

	return;
}
//D問題
void probremD(void) {
	char s[1000001];	//入力文字列
	int c[26] = { 0 };	//アルファベットカウンタ
	int count = 0;		//ループカウンタ
	int s_length = 0;	//入力文字列の長さ
	//入力処理
	scanf("%s", &s);

	//出力文字列の長さを知る
	while (s[count] != '\0') {
		count++;
	}
	s_length = count;	//長さであることに注意
	//printf("s_length:%d\n", s_length);

	//
	for (int i = 2; i <= s_length; i++) {
		for (int j = 0; j <= s_length - i; j++) {
			for (int k = 0; k < i; k++) {
				//初期化_アルファベットカウンタ
				for (int l = 0; l < 26; l++) {
					c[l] = 0;
				}
				//アルファベットをカウントする
				for (int l = j; l < j + i; l++) {
					int alphabet = s[l] - 'a';
					c[alphabet]++;
				}
				//数えたアルファベットの最大値を調べる
				int max = 0;
				for (int i = 0; i < 26; i++) {
					max = c[i] > max ? c[i] : max;
				}
				//もし最大値がi/2より大きいならアンバランスである
				if (max>i/2) {
					//インデックスが0-originであることに注意
					printf("%d %d\n",j+1,j+i);
					return;
				}
			}
		}
	}

	//もしここまで来たら、アンバランスな部分文字列は存在しない
	//インデックスが0-originであることに注意
	printf("%d %d\n", -1, -1);
	return;
}

Measured memory_bytes: 128
#include <iostream>
//#include <windows.h>
//#include <iomanip>
//#include <math.h>
//#define pi 3.14159
 
using namespace std;
 
int main() {
	//cout << fixed << setprecision(2);
	
	int a;
	
	cin >> a;
	
	cout << a*a*a << endl;
	
   	return 0;
}

Measured memory_bytes: 1160
x, n = map(int, input().split())
P = list(map(int, input().split()))
a = 0
b = 0

i = x
for i in reversed(range(x)):
    if i in P:
        i = i-1
    else:
        break
a = x -i

j = x
for j in range(j,101):
    if j in P:
        j = j + 1
    else:
        break
b = j - x

if a <= b:
    print(i)
else:
    print(j)


Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e3;
int k,n,mat[maxn][maxn];
inline long long read(){
	long long x=0,f=1;
	char c;
	do{c=getchar();if(c=='-') f*=-1;}while(!isdigit(c));
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
	return x*f;
}
int main(){
	k=read();
	if(k==1) printf("1\n1\n");
	else{
		n=(k+3)/4*2;
		printf("%d\n",n);
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				mat[i][j]=(i&1)?1+n+(i+j)%n:1+(i+j)%n;
				if(mat[i][j]>k) mat[i][j]-=n;
				printf("%d ",mat[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

class UnionFind {
    std::vector<int> p;

public:
    UnionFind(int n) : p(n, -1) {}

    int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }

    bool same(int x, int y) { return root(x) == root(y); }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (p[y] < p[x]) std::swap(x, y);
        p[x] += p[y];
        p[y] = x;
        return true;
    }

    int size(int x) {
        return -p[root(x)];
    }
};

void solve(std::string S) {
    UnionFind uf(S.size());

    for (int i = 0; i + 1 < S.size(); i++) {
        if (S[i] == S[i + 1]) {
            uf.unite(i, i + 1);
        }
    }
    for (int i = 0; i + 1 < S.size(); i++) {
        if (S[i] == 'R' && S[i + 1] == 'L') {
            uf.unite(i, i + 1);
        }
    }
    int cnt[100010][2] = {};
    for (int i = 0; i < S.size(); i++)
        cnt[uf.root(i)][i%2]++;

    vector<int> v(S.size());
    for (int i = 0; i + 1 < S.size(); i++) {
        if (S[i] == 'R' && S[i + 1] == 'L') {
            v[i] = cnt[uf.root(i)][i%2];
            v[i+1] = cnt[uf.root(i)][(i+1)%2];
        }
    }
    for(int i = 0 ; i < S.size() ; i++) cout << v[i] << " ";
    cout << endl;
};

int main() {
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 2176
// https://atcoder.jp/contests/abc122/tasks/abc122_d

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <regex>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-7)
#define INF (1e9)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }
static regex re(".*(A.?GC|AG.?C|GAC|ACG)");
map<string, ll> mp;
// 文字列長、今までの文字列
ll rec(int n, string s) {
    bool result = regex_match(s, re);
    if (result) {
        return 0;
    }
    if (n == 0) {
        // cout << s << endl;
        return 1;
    }
    ll ret = 0;
    //末尾から3桁の文字列 + ":" + 残り文字数
    int pos = max(0, (int)s.length() - 3);
    string ends = s.substr(pos) + ":" + to_string(n);
    if (mp.count(ends) == 0) {
        ret = rec(n - 1, s + "A") + rec(n - 1, s + "G") + rec(n - 1, s + "C") +
              rec(n - 1, s + "T");
        mp[ends] = ret;
    } else {
        ret = mp[ends];
    }
    return ret % MOD;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;

    cout << rec(n, "") << endl;

    return 0;
}


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

int main(){
    string S;
    cin >> S;
    int l=S.length();
    int count=0;

        for (int i=0;i<(l/2);i++){
            if(S[i]!=S[l-i-1]) count++;
          //cout << S[i] << S[l-i-1] << endl;
        }

        cout << count << endl;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
L = list(map(int, list(input())[: -1]))
L.reverse()
mod = 10 ** 9 + 7
res = 1
for i in range(len(L)):
  if L[i]: res = (2 * res + pow(3, i, mod)) % mod
print(res)

Measured memory_bytes: 49776
#include <bits/stdc++.h>
#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 all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

const int mod = 1e9+7;
struct mint {
    ll x;
    mint (ll x = 0) : x((x%mod+mod)%mod) {}
    mint operator -() const {return mint(-x);}
    mint& operator +=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator -=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator *=(const mint a) {(x *= a.x) %= mod; return *this;}
    mint operator +(const mint a) const {return mint(*this) += a;}
    mint operator -(const mint a) const {return mint(*this) -= a;}
    mint operator *(const mint a) const {return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {return pow(mod-2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {return mint(*this) /= a;}
};
istream& operator >>(istream &is, const mint &a) {return is >> a.x;}
ostream& operator <<(ostream &os, const mint &a) {return os << a.x;}

int main() {
    int n; cin >> n;
    vll a(n);
    rep(i,n) cin >> a[i];
    mint ans = 0;
    rep(i,60) {
        int x = 0;
        rep(j,n) x += a[j]>>i&1;
        ans += mint(2).pow(i)*x*(n-x);
    }
    cout << ans << endl;
}

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


int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int sum = 0;
	sum = a + b + c;



	int largest = max(a, max(b, c));

	for (int i = 0; i < k; ++i) {
		if (a == largest) {
			a = a * 2;
			largest = max(a, max(b, c));
		}
		else if (b == largest) {
			b = b * 2;
			largest = max(a, max(b, c));
		}
		else {
			c = c * 2;
			largest = max(a, max(b, c));
		}
	}

	sum = a + b + c;

	cout << sum << endl;

}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	string s;
	cin >> s;
	if(s[0]==s[1] || s[2]==s[1] || s[2]==s[3]){
		cout << "Bad" << endl;
	}else{
		cout << "Good" << endl;
	}
	
//////////////////////////////////////////////
}


Measured memory_bytes: 256
def listToString(_list, split=""):
    maped_list = map(str, _list)  # mapで要素すべてを文字列に
    mojiretu = split.join(maped_list)
    return mojiretu


n = int(input())
a = [int(i) for i in str(n)]
count = 0
for i in range(len(str(n))):
    # 下i桁目までで各位の和が最大になるものを算出
    now = a[-i-1:n]
    nowSum = 0
    for j in range(len(now)):
        nowSum += now[j]
    # abcdの時、4桁での最大値はa+(bcdのmax)かa-1 + 9 + 9 + 9
    if a[-i-1] > 0:
        if nowSum < now[0] + 9 * (len(now)-1):
            a[-i-1] -= 1
            for k in range(1, len(now)):
                a[-i-1 + k] = 9
    # print("i:{} a:{} now:{} nowSum:{}".format(i, listToString(a), listToString(now), nowSum))
nowSum = 0
for i in range(len(a)):
    nowSum += a[i]
print(nowSum)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
struct color {
	int r,
		g,
		b;
	char c[8];
};
//int c16toi10(char*);
int hex(char*);
int main() {
	struct color a[8]={
		{0x00,0x00,0x00,"black"},
		{0x00,0x00,0xff,"blue" },
		{0x00,0xff,0x00,"lime" },
		{0x00,0xff,0xff,"aqua"},
		{0xff,0x00,0x00,"red"},
		{0xff,0x00,0xff,"fuchsia"},
		{0xff,0xff,0x00,"yellow"},
		{0xff,0xff,0xff,"white"}
	};
	int i,t;
	double r, g, b, d, n;
	char str[16];
	while (~fscanf(stdin, "%s", str), str[0] != '0') {
		r = hex(str + 1) * 16 + hex(str + 2);
		g = hex(str + 3) * 16 + hex(str + 4);
		b = hex(str + 5) * 16 + hex(str + 6);
		n = 1e8;
		for (i = 0; i < 8; i++) {
			d = sqrt(pow(r - a[i].r, 2) + pow(g - a[i].g, 2) + pow(b - a[i].b, 2));
			if (n > d)
				n = d, t = i;
		}
		P(s, a[t].c);
	}
	return 0;
}

//int c16toi10(char *n){
//	int ans=0;
//	int i, base = 1;
//	for (i = strlen(n)-1; i >= 0; --i) {
//		if (hex(n + i) == -1) return -1;
//		ans += hex(n+i)*base;
//		base *= 16;
//	}
//	return ans;
//}

int hex(char *s){
	if ('0' <= *s&&*s <= '9') return *s - '0';
	else if ('A' <= *s&&*s <= 'Z') return *s - 'A' + 10;
	else if ('a' <= *s&&*s <= 'z') return *s - 'a' + 10;
	return -1;
}

Measured memory_bytes: 536
n = int(input())
As = list(map(int, input().split()))
kabu = 0
money = 1000
buy = True
prev = 1 << 50
for i, a in enumerate(As):
    if buy: #買いtrend
        if prev < a:
            #買う
            # print("buy",i, prev)
            kabu += money // prev
            money -= kabu * prev
            buy = False
    else:
        if prev > a:
            #売る
            # print("sell",i,prev)
            buy = True
            money += kabu * prev
            kabu = 0
    prev = a

print(money+kabu*a)


Measured memory_bytes: 9184
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include<cstring>

using namespace std;

typedef long long ll;
ll a;
ll sum;
int main()
{
    long long int b,c;
    cin>>a>>b>>c;
    long long int x=a/(b+c);
    long long int t=a%(b+c);
    if(t>=b)
    {
        sum=x*b+b;
    }
    else
    {
        sum=x*b+t;
    }
    cout<<sum;
    return 0;
}



Measured memory_bytes: 256
c = int(input())
d = {}
e = {}
for i in range(c):
    k, v = input().split()
    d.setdefault(k, []).append(int(v))
for k,v in d.items():
    for i in range(1,14):
        if not i in v:
            e.setdefault(k, []).append(int(i))
if e:
    for k in ['S','H','C','D']:
        for i in e[k]:
            print("{} {}".format(k, i))



Measured memory_bytes: 5600
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int aSum = 0, bSum = 0;
			for(int i = 0; i < 4; ++i)
			{
				int a = stdIn.nextInt();
				aSum += a;
			}
			for(int i = 0; i < 4; ++i)
			{
				int b = stdIn.nextInt();
				bSum += b;
			}
			if(aSum >= bSum)
			{
				System.out.println(aSum);
			}
			else
			{
				System.out.println(bSum);
			}
		}
	}
}

Measured memory_bytes: 12000
import itertools, bisect
def inpl(): return [int(i) for i in input().split()]

N = int(input())
a = inpl()
sa = sorted(a)
acsa = list(itertools.accumulate(sa)) + [0]
acans = 0
ma = 0
ans = [0]*N
for i in range(N):
    if ma >= a[i]:
        continue
    ma = a[i]
    x = bisect.bisect_left(sa, a[i]) - 1
    ans[i] = a[i]*(N-1-x) + acsa[x] - acans
    acans += ans[i]
    
for i in ans:
    print(i)

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

import bisect

alist = [0]
blist = [0]

for i in range(n):
  alist.append(alist[i]+a[i])  
for i in range(m):
  blist.append(blist[i]+b[i])

res = 0
ans = 0
for i in range(n+1):
  border = k - alist[i]
  if border < 0:
    continue
  ans = i
  ans += bisect.bisect_right(blist, border)-1
  res = max(res, ans)
  
print(res)

Measured memory_bytes: 47372
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import time
import math
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
N,K=map(int,input().split())
mod=10**9+7
"""
fac=[1,1]
for i in range(2,2*(N+1)):
    fac.append(fac[-1]*i%mod)
ifac=[pow(i,mod-2,mod) for i in fac]
def comb(a,b):
    if a<b:return(0)
    return(fac[a]*ifac[a-b]*ifac[b]%mod)
"""
c=0
for k in range(K,N+2):
    X=(N)*k - (k-1)*k//2 - (k-1)*k//2  +1
    c+=X
    #print(X,k)
    c%=mod
print(c)


Measured memory_bytes: 72984
#include <bits/stdc++.h>
#define int long long
#define INF 2e+12
using namespace std;

signed main(){
	int n,m,a,b,p,q,mi;
	vector<int> vec,num;
	cin >> n >> m >> a >> b >> p >> q;
	mi = m;
	if(a == 1 && b == 1){
		if(p + q >= (m + n - 1) / n) cout << min(m % (p + q),p + q - m % (p + q)) << endl;
		else cout << m - (p + q) * n << endl;
		return 0;
	}
	int ta = p,tb = q;
	for(int i = 0;i < n;i++){
		if(ta + tb > INF) break;
		vec.push_back(ta + tb);
		if(ta > (INF + a - 1) / a || tb > (INF + b - 1) / b) break;
		ta *= a;
		tb *= b;
	}
	n = vec.size();
	for(int i = 0;i < (1 << (n / 2));i++){
		int sum = 0;
		for(int j = 0;j < n / 2;j++){
			if((i >> j) & 1) sum += vec[j];
		}
		num.push_back(sum);
	}
	sort(num.begin(),num.end());
	for(int i = 0;i < (1 << ((n + 1) / 2));i++){
		int sum = 0;
		for(int j = 0;j < (n + 1) / 2;j++){
			if((i >> j) & 1) sum += vec[j + n / 2];
		}
		int ind = upper_bound(num.begin(),num.end(),m - sum) - num.begin() - 1;
		if(ind >= 0) mi = min(mi,m - sum - num[ind]);
		if(ind + 1 < n) mi = min(mi,-(m - sum - num[ind + 1]));
	}
	cout << mi << endl;
	return 0;
}


Measured memory_bytes: 11244
#include <stdio.h>

int main (){

  int i,n,F[50];

  scanf("%d",&n);

  F[0]=F[1]=1;

  for(i=2;i<=n;i++)
    {
      F[i]=F[i-2]+F[i-1];

    }

  printf("%d\n",F[n]);

  return 0;
}

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

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗する

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) の絶対値

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//配列の受け取り

main(){
  int n=in(),h=in(),w=in();
  cout << (n-h+1)*(n-w+1) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 41
 
typedef struct node{
  int l, r;
}node;
 
node c[N];
int a[N], b[N];
int cnt=0;
 
void postorder(int root,int n){
 
        if(c[root].l != -1) postorder(c[root].l, n);
        if(c[root].r != -1) postorder(c[root].r, n);
        if(cnt < n - 1) printf("%d ", root);
        else printf("%d\n", root);
 
        cnt++;
 
        return;
 
}
 
int reconst(int start,int last,int n){
  int i, j;
 
  if(start == last) return b[start];
  else if(start > last) return -1;
 
  else {
    for(i = 1 ; i <= n ; i++){
      for(j = start ; j <= last ; j++){
        if(a[i] == b[j]){
          c[a[i]].l = reconst(start, j - 1, n);
          c[a[i]].r = reconst(j + 1, last, n);
          return a[i];
        }
      }
    }
  }
}
 
 
int main(){
  int n,i, root;
 
  scanf("%d",&n);
 
  for(i = 1 ; i <= n ; i++) scanf("%d",&a[i]);
  for(i = 1 ; i <= n ; i++) scanf("%d",&b[i]);
  for(i = 1 ; i <= n ; i++){
    c[i].l = -1;
    c[i].r = -1;
  }
 
  root = reconst(1,n,n);
 
  postorder(root,n);
 
  return 0;
 
}



Measured memory_bytes: 2032
using System;

namespace CA {
	class Prg {
		static void Main() {
			string[] s = Console.ReadLine().Split(' ');
			ushort[] n = new ushort[3];
			n[0] = ushort.Parse(s[0]);
			n[1] = ushort.Parse(s[1]);
			n[2] = ushort.Parse(s[2]);
			if (n[0] == n[2]) {
				if (n[0] > n[1]) Console.WriteLine(n[1] + " " + n[0] + " " + n[2]);
				else Console.WriteLine(n[0] + " " + n[2] + " " + n[1]);
			} else {
				if (n[0] < n[1] && n[1] < n[2] && n[0] < n[2]) Console.WriteLine(n[0] + " " + n[1] + " " + n[2]);
				else if (n[0] < n[2] && n[2] < n[1] && n[0] < n[1]) Console.WriteLine(n[0] + " " + n[2] + " " + n[1]);
				else if (n[1] < n[0] && n[0] < n[2] && n[1] < n[2]) Console.WriteLine(n[1] + " " + n[0] + " " + n[2]);
				else if (n[1] < n[2] && n[2] < n[0] && n[1] < n[0]) Console.WriteLine(n[1] + " " + n[2] + " " + n[0]);
				else if (n[2] < n[0] && n[0] < n[1] && n[2] < n[1]) Console.WriteLine(n[2] + " " + n[0] + " " + n[1]);
				else Console.WriteLine(n[2] + " " + n[1] + " " + n[0]);
			}
		}
	}
}

Measured memory_bytes: 9644
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	ArrayList<Integer>[] g;

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextLong();
		}
		long ans = 0;
		for (int i = 0; i < N; ++i) {
			if ((i == 0 && A[0] != 0) || (i > 0 && A[i] - A[i - 1] > 1)) {
				System.out.println(-1);
				return;
			}
		}
		for (int i = 1; i < N; ++i) {
			if (i == N - 1 || A[i + 1] != A[i] + 1) {
				ans += A[i];
			}
		}
		System.out.println(ans);
	}

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

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 89156
import sys
input = sys.stdin.readline
N = int(input())
css = [0] * N
mns = [0] * N
t = [x for x in range(N)]
for x in range(N):
  S = list(input())[: -1]
  for i in range(len(S)):
    if S[i] == "(": css[x] += 1
    if S[i] == ")":
      css[x] -= 1
      mns[x] = min(mns[x], css[x])
if sum(css):
  print("No")
  exit(0)
t.sort(key = lambda x: -10 ** 7 if mns[x] == 0 else -10 ** 7 - mns[x] if css[x] >= 0 else mns[x] - css[x])
l = 0
for i in t:
  if l + mns[i] < 0:
    print("No")
    exit(0)
  l += css[i]
print("Yes")

Measured memory_bytes: 159988
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    char c;
    cin >> c;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cout << "vowel";
    else cout << "consonant";
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b;
	char op;
	
	
	while (!(op=='?')){
		scanf("%d %c %d",&a,&op,&b);
		if (op=='+'){
			printf("%d\n",a+b);
		}else if (op=='-'){
			printf("%d\n",a-b);
		}else if (op=='*'){
			printf("%d\n",a*b);
		}else if (op=='/'){
			printf("%d\n",a/b);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl



int main() {
	int n, a;
	cin >> n >> a;
	wrln(n*n - a);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>	// 入出力
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列


using namespace std;


int main()
{
	int n;

	cin >> n;

	int max = 0, min = 1000;

	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;

		if (a > max) {
			max = a;
		}
		if (a < min) {
			min = a;
		}
	}

	cout << max - min << endl;


	return 0;
}

Measured memory_bytes: 256