akhauriyash/Code-Regression huggingface dataset:
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.map!(to!int).array; }

int calc(int k, int[] xs) {
    int[int] d;
    foreach (x; xs) d[x]++;

    /*
    int ans = 0;
    auto values = d.values.sort();
    for (int i = 0; i < (cast(int)values.length - k); i++) {
        ans += values[i];
    }
    return ans;
    */

    return d.values.sort!"a > b"().drop(k).sum;
}

void main() {
    auto nk = readints;
    int k = nk[1];
    auto xs = readints;

    int ans = calc(k, xs);
    writeln(ans);
}


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

using namespace std;

int main() {

	long n;
	cin >> n;

	vector<double> p(n+1, 0);
	for (int i = 1; i <= n; i++) {
		cin >> p[i];
	}

	vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0));

	dp[1][0] = 1 - p[1];
	dp[1][1] = p[1];

	for (long i = 2; i <= n; i++) {
		dp[i][0] = dp[i - 1][0] * (1 - p[i]);
		for (long j = 1; j <= i; j++) {
			dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i];
		}
	}

	double res = 0;
	for (long i = (n / 2) + 1; i <= n; i++) {
		res += dp[n][i];
	}
	cout << setprecision(15) << res << endl;
}

Measured memory_bytes: 70784
n,m = map(int,input().split())
all_town = [[] for i in range(n)]
for i in range(m):
  p_y = list(map(int,input().split()))
  p_y.append(i)
  all_town[p_y[0]-1].append(p_y)

i_id = []
for town in all_town:
  town.sort(key=lambda x: x[1])
  for i in range(len(town)):
    left = "{:0=6}".format(town[i][0])
    right = "{:0=6}".format(i+1)
    i_id.append([town[i][2],left+right])
    
i_id.sort(key=lambda x: x[0])
for id in i_id:
  print(id[1])
    

Measured memory_bytes: 120792
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    string a,b;
    cin >> a >> b;
    if(a>b)cout << ">";
    if(a==b)cout << "=";
    if(a<b)cout << "<";
    return 0;
}


Measured memory_bytes: 256
# Author: cr4zjh0bp
# Created: Mon Mar  2 04:27:45 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

s = ns()
N = len(s)
K = ni()
dp = [[[0] * 4 for _ in range(2)] for _ in range(N + 1)]
dp[0][0][0] = 1

for i in range(N):
    for j in range(2):
        D = int(s[i])
        n = 9 if j == 1 else D
        for d in range(n + 1):
            for k in range(4):
                ni, nj, nk = i + 1, j, k
                if d != 0:
                    nk += 1
                if nk > K:
                    continue
                if d < D:
                    nj = 1
                dp[ni][nj][nk] += dp[i][j][k]

print(dp[N][0][K] + dp[N][1][K])

Measured memory_bytes: 3188
#include <iostream>
#include <string>
 
using namespace std;
 
int main()
{
    string str;
    int i;
    int count[26] = {};
    int num = 0;
 
    while (getline(cin, str)){
 
        for (i = 0; i < str.length(); i++)
        {
            if (islower(str[i])){
                num = str[i] - 'a';
                count[num]++;
            }
            else if (isupper(str[i])){
                str[i] = tolower(str[i]);
                num = str[i] - 'a';
                count[num]++;
            }
 
        }
    }
 
    for (i = 0; i < 26; i++)
    {
        cout << char(i + 'a') << " : " << count[i] << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main()
{	
	LL n, a, b;
	cin >> n >> a >> b;

	LL loop = n / (a + b);
	LL ans = a * loop, num = (a+b)*loop;

	if (num + a <= n) {
		ans += a;
	}
	else {
		while (num < n) {
			ans++;
			num++;
		}
	}

	col(ans);
	return 0;
}


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

struct UnionFind
{
	vector<int> uni;

	UnionFind(int n) : uni(n, -1){}
	int root(int a)
	{
		if (uni[a] < 0) return a;
		return uni[a] = root(uni[a]);
	}

	bool connect(int a, int b)
	{
		a = root(a);
		b = root(b);
		if (a == b) return false;
		if (uni[a] > uni[b])
		{
			a ^= b;
			b ^= a;
			a ^= b;
		}
		uni[a] = uni[a] + uni[b];
		uni[b] = a;
		return true;
	}
	bool isConnect(int a, int b)
	{
		return root(a) == root(b);
	}
	int size(int a)
	{
		return -uni[root(a)];
	}
};

signed main(void)
{
	int n, m, cnt;
	cin >> n >> m;
	P p[n];
	UnionFind uf(n);

	rep(i, n)
	{
		int a;
		cin >> a;
		a--;
		p[i] = P(i, a);
	}
	rep(i, m)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		if (!uf.isConnect(a, b)) uf.connect(a, b);
	}
	cnt = 0;
	rep(i, n)
	{
		if (uf.isConnect(i, p[i].second))
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;
import java.util.ArrayList;
import java.util.HashMap;
import java.lang.Integer;
import java.lang.StringBuilder;
import java.lang.Math;

public class Main {
  private static int N;
  private static int T;
  private static int[] a;

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    N = in.nextInt();
    T = in.nextInt();
    a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i]= in.nextInt();
    }

    int cnt = 0;

    int maxDiff = Integer.MIN_VALUE;
    int min = a[0];
    for(int i = 1; i < N; i++) {
      if (min > a[i - 1]) {
        min = a[i - 1];
      }
      int diff = a[i] - min;
      if (diff <= 0) {
        continue;
      }
      if (maxDiff < diff) {
        maxDiff = diff;
        cnt = 1;
      } else if (maxDiff == diff) {
        cnt++;
      }
    }

    System.out.println(cnt);
  }
}

Measured memory_bytes: 45956
/**
 *　　　　　　　　┏┓　　　┏┓+ +
 *　　　　　　　┏┛┻━━━┛┻┓ + +
 *　　　　　　　┃　　　　　　　┃
 *　　　　　　　┃　　　━　　　┃ ++ + + +
 *　　　　　　 ████━████ ┃+
 *　　　　　　　┃　　　　　　　┃ +
 *　　　　　　　┃　　　┻　　　┃
 *　　　　　　　┃　　　　　　　┃ + +
 *　　　　　　　┗━┓　　　┏━┛
 *　　　　　　　　　┃　　　┃
 *　　　　　　　　　┃　　　┃ + + + +
 *　　　　　　　　　┃　　　┃　　　　Code is far away from bug with the animal protecting
 *　　　　　　　　　┃　　　┃ + 　　　　神兽保佑,代码无bug
 *　　　　　　　　　┃　　　┃
 *　　　　　　　　　┃　　　┃　　+
 *　　　　　　　　　┃　 　　┗━━━┓ + +
 *　　　　　　　　　┃ 　　　　　　　┣┓
 *　　　　　　　　　┃ 　　　　　　　┏┛
 *　　　　　　　　　┗┓┓┏━┳┓┏┛ + + + +
 *　　　　　　　　　　┃┫┫　┃┫┫
 *　　　　　　　　　　┗┻┛　┗┻┛+ + + +
 */
/*--------- Hongjie ----------*/
// #include<bits/stdc++.h>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<deque>
#include<cmath>
#include<cstdio>
#include<bitset>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

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

const int INF  = 0x3f3f3f3f;
const int MAXN = 1e5+7;
int a[MAXN];

int main(){
        // freopen("../in.txt","r",stdin);
        // freopen("../out.txt","w",stdout);
        ios::sync_with_stdio(0);
        cin.tie(0);
        int n;
        while(cin>>n) {
                for(int i=0;i<n;++i)
                        cin>>a[i];
                int flag = 0;
                for(int i=n-2;i>=0;--i){
                        if(a[i]>a[i+1]) a[i]--;
                        if(a[i]>a[i+1]) {
                                flag = 1;
                                break;
                        }
                }
                if(flag)        cout<<"No"<<endl;
                else            cout<<"Yes"<<endl;
        }


        return 0;
}


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

int main() {
    int n;
    int x;

    cin >> n;

    for (int i = 1; i <= n; ++i) {
        if ((i % 3) == 0) {
            cout << " " << i;
            continue;
        }

        x = i;
        while (x > 0) {
            if ((x % 10) == 3) {
                cout << " " << i;
                break;
            }
            x = x / 10;
        }
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 3104
using System;
using System.Text;
class MainClass
{
    public static void Main(string[] args)
    {
        string str = Console.ReadLine();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < str.Length; i++)
        {
            if (str[i] == '0' || str[i] == '1') sb.Append(str[i]);
            else if(sb.ToString() != "")sb.Remove(sb.Length - 1, 1);
        }
        Console.WriteLine(sb.ToString());
    }
}


Measured memory_bytes: 2648
#include <bits/stdc++.h>
// #include <cmath>
// #include <numeric>
// #include <regex> //正規表現
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// グリッドグラフの移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


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

int A, B; cin >> A >> B;
 
  if (B == 1){
    cout << 0 << endl;
    return 0;
}

int cnt = 1, kuti = A;

while(kuti < B) {
    kuti += A-1;
    ++cnt;
}


cout << cnt << endl;
}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    left = 0
    right = N
    print(left,flush=True)
    ls = input()
    if ls == "Vacant":
        exit()
        
    while right-left > 1:
        mid = (right+left)//2
        print(mid,flush=True)
        nls = input()
        if nls == "Vacant":
            exit()
        if nls == ls:
            if (mid-left)%2 == 0:
                left = mid
            else:
                right = mid
        else:
            if (mid-left)%2 == 1:
                left = mid
                ls = nls
            else:
                right = mid

if __name__ == "__main__":
    main()


Measured memory_bytes: 3660
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, a, b = MAP()

def power(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x % mod
    elif y % 2 == 0:
        return power(x, int(y/2)) ** 2 % mod
    else:
        return power(x, int((y-1)/2)) ** 2 * x % mod

ans = power(2, n)-1

fact = [1]*(2*10**5+2)
for i in range(1, 2*10**5+1):
	fact[i] = (fact[i-1]*i)%mod

def C(n, a):
	tmp = 1
	for i in range(n, n-a, -1):
		tmp = (tmp*i)%mod
	return tmp*power(fact[a], mod-2)

print((ans-C(n, a)-C(n, b))%mod)


Measured memory_bytes: 13268
object Main extends App {
  val sc = new java.util.Scanner(System.in);
  val h, w = sc.nextInt();
  sc.nextLine(); // 行末スキップ
  val matrix = Array.fill(h)(sc.nextLine().map(ch => if(ch=='#') -1 else 0).toArray);

  def resetMatrix(): Unit = {
    (0 until h).foreach { y =>
      (0 until w).foreach { x =>
        if (matrix(y)(x) > 0) {
          matrix(y)(x) = 0;
        }
      }
    }
  }

  def maxDistance(x: Int, y: Int): Int = {
    @scala.annotation.tailrec
    def sub1(que: List[(Int, Int)], distance: Int): Int = {
      if (que.isEmpty) {
        distance - 2;
      } else {
        val que2 = sub2(que, Nil, distance);
        sub1(que2, distance + 1);
      }
    }
    @scala.annotation.tailrec
    def sub2(que1: List[(Int, Int)], que2: List[(Int, Int)], distance: Int): List[(Int, Int)] = {
      que1 match {
        case Nil => que2;
        case head :: q =>
          val x = head._1;
          val y = head._2;
          val que3 = List((x-1, y), (x, y-1), (x+1, y), (x, y+1)).filter { case (x, y) =>
            if (x >= 0 && x < w && y >= 0 && y < h) {
              if (matrix(y)(x) == 0) {
                matrix(y)(x) = distance + 1;
                true;
              } else {
                false;
              }
            } else {
              false;
            }
          } ::: que2;
          sub2(q, que3, distance);
      }
    }
    matrix(y)(x) = 1;
    sub1(List((x, y)), 1);
  }

  val answer = (0 until h).map { y =>
    (0 until w).map { x =>
      if (matrix(y)(x) >= 0) {
        resetMatrix();
        maxDistance(x, y);
      } else {
        -1;
      }
    }.max;
  }.max;
  
  println(answer);
}

Measured memory_bytes: 57296
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

int n;

void main() {
    while (true) {
        scan(n);

        if (n == 0) break;

        writeln(solve(n));
    }
}

int solve(int n) {
    int res;

    foreach (r ; 1 .. n) {
        int x = r * (r + 1) / 2;
        int y = x - n;

        if (y < 0) continue;

        int btm = -1, top = r, mid;

        while (top - btm > 1) {
            mid = btm + (top - btm) / 2;

            if (mid * (mid + 1) / 2 >= y) {
                top = mid;
            }
            else {
                btm = mid;
            }
        }

        if (top * (top + 1) / 2 == y) {
            debug {
                writeln(top, " ", r);
            }

            res++;
        }
    }

    return res;
}

void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 2300
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<iomanip>
#include<cstring>
#define R register
#define EN printf("\n")
#define LL long long
inline LL read(){
	LL x=0,y=1;
	char c=std::getchar();
	while(c<'0'||c>'9'){if(c=='-') y=-1;c=std::getchar();}
	while(c>='0'&&c<='9'){x=x*10+(c^48);c=std::getchar();}
	return x*y;
}
int n;
LL work(LL h){
	if(h==1) return 1ll;
	return (work(h/2)<<1)|1;
}
int main(){
	LL h=read();
	std::printf("%lld",work(h));
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int X[4];
int Y[4];
int main(){
  int i;
  rd(X[0]);
  rd(Y[0]);
  rd(X[1]);
  rd(Y[1]);
  for(i=2;i<4;i++){
    X[i] = X[i-1] - (Y[i-1] - Y[i-2]);
    Y[i] = Y[i-1] + (X[i-1] - X[i-2]);
  }
  wt_L(X[2]);
  wt_L(' ');
  wt_L(Y[2]);
  wt_L(' ');
  wt_L(X[3]);
  wt_L(' ');
  wt_L(Y[3]);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int X[4], Y[4];
// {
//   rd(X[0],Y[0],X[1],Y[1]);
// 
//   rep(i,2,4){
//     X[i] = X[i-1] - (Y[i-1] - Y[i-2]);
//     Y[i] = Y[i-1] + (X[i-1] - X[i-2]);
//   }
// 
//   wt(X[2],Y[2],X[3],Y[3]);
// }


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

const int INF = 1001001001;

int ck(int a)
{
    if (a == 1)
    {
        return 0;
    }
    for (int i = 2; i * i <= a; i++)
    {
        if (a % i == 0)
        {
            return 0;
        }
    }
    return 1;
}

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

    int MAX = 100100;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0;
    is_prime[1] = 0;
    for (int i = 2; i < MAX; i++)
    {
        if (is_prime[i] == 0)
            continue;
        for (int j = i * 2; j < MAX; j += i)
        {
            is_prime[j] = 0;
        }
    }

    vector<int> a(MAX, 0);
    for (int i = 0; i < MAX; ++i)
    {
        if (i % 2 == 0)
            continue;
        if (is_prime[i] && is_prime[(i + 1) / 2])
            a[i] = 1;
    }

    vector<int> cum(MAX + 1, 0);
    rep(i, MAX)
    {
        cum[i + 1] = cum[i] + a[i];
    }

    rep(i, q)
    {
        int l, r;
        cin >> l >> r;
        r++;
        cout << cum[r] - cum[l] << endl;
    }

    return 0;
}

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }

void Solve()
{
	string N;
	cin >> N;

	ll ans = 0;
	REP(i, N.size()) {
		ans += N[i] - '0';
	}

	string a = ans % 9 == 0 ? "Yes" : "No";
	cout << a << endl;

}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 3740
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=18;
typedef long long ll;

int n;
ll A[N+3];

ll DFS(int Pl,int Pr,ll Vl,ll Vr){
	int siz=Pr-Pl+1;
	if(siz==2) return 0;
	ll ans=(1ll<<62);
	for(int i=Pl+1;i<=Pr-1;i++)
		ans=min(ans,DFS(Pl,i,Vl,Vl+Vr)+DFS(i,Pr,Vl+Vr,Vr)+(Vl+Vr)*A[i]);
	return ans;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&A[i]);
	printf("%lld\n",DFS(1,n,1,1)+A[1]+A[n]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>

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

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
    int a,b;
    cin >> a >> b ;
    int sub = b - a;
    int tower = 0;
    for(int i= sub;i >=0; i--){
        tower += i;
    }
    cout << tower - b;


    return 0;
}

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

using namespace std;

const int MAX_FR = 3001;

int n, ans;
vector<int> a, fr(MAX_FR);

int main() {
	cin >> n;
	a.resize(n);
	
	for(int& e: a) cin >> e;
	
	sort(a.begin(), a.end());
	
	for(int i = 0; i < n; i++) {
		for(int j = a[i] + 1; j < MAX_FR; j++)
			// all sums more than a[i] element
			ans += fr[j];
		
		for(int j = 0; j < i; j++)
			fr[a[i] + a[j]]++;
		
	}
	
	cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int N;
  long A, B;
  cin >> N >> A >> B;
  long X[N];
  for (int i = 0; i < N; i++)
    cin >> X[i];
  long ans = 0;
  for (int i = 1; i < N; i++)
    ans += min(A * (X[i] - X[i - 1]), B);
  cout << ans << endl;
  return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}

int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}
void read_cr() {
    fgets(_buf, 256, stdin);
}

int solve(int N, int T, vi& a) {
    int h = T/2;
    priority_queue<int> pq;
    int min_so_far = a[0];
    for (int i=1; i<N; ++i) {
        if (a[i] >= min_so_far) {
            pq.push(a[i] - min_so_far);
        } else {
            min_so_far = a[i];
        }
    }
    int best = pq.top(); pq.pop();
    int cnt = 1;
    while (!pq.empty()) {
        if (pq.top() == best) ++cnt;
        else break;
        pq.pop();
    }
    return cnt;
}

int main() {
    int N,T; cin>>N>>T;
    read_cr();
    vi a(N);
    loadvec(a, N);
    cout << solve(N,T,a) << endl;
    return 0;
}


Measured memory_bytes: 2300
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll k,x,y;
vi a(100);

ll funck1(ll inp,ll nl){
  
  ll flag=0,ans=0;
  if (a[nl-2-inp]==0)return 0;
  
    for(ll i=inp;i<nl-1;i++){
      if (a[nl-2-i]!=0){
        flag=1;
        ans+=a[nl-2-i];
        ans+=9LL*(nl-2-i);
        break;
      }
    }
    return ans;
}


ll funck2(ll inp,ll nl){
  ll flag=0,ans=0;
  //if (a[nl-2-inp]==0)return 0;
  for(ll i=0;i<nl-1;i++){
      
      if (a[nl-2-i]!=0){
        flag++;
        if (flag==1){
          ans+=(a[nl-2-i]-1)*9LL*(nl-2-i);
          ans+=81LL*(nl-2-i)*(nl-2-i-1)/2LL;
        }

        if (flag==2){
          ans+=a[nl-2-i]+9LL*(nl-2-i);
          break;
        }
      }
    }

    if (flag>=1)return ans;
    return 0;
}

int main(){
  ll ans=0;
  string n;
  cin >> n >> k;
  ll nl=n.length();
  
  REP(i,nl){
    a[i]=n[nl-1-i]-48;
  }

  ll k9=1;
  REP(i,k){
    k9*=9;
  }

  REP(i,nl-1){
    if (i+1>=k){
      ll ii=i+1;
      ll k9a=k9;
      REP(i,k-1){
        k9a*=ii-1-i;
      }
      if (k==3)k9a/=2;
      ans+=k9a;
    }
  }


  if (k==1){
    ans+=a[nl-1];
  }


  if ((k==2)&(nl>=2)){
    ans+=(a[nl-1]-1)*9LL*(nl-1);
    ll flag=0;
    for(ll i=0;i<nl-1;i++){
      if (a[nl-2-i]!=0){
        //flag=1;
        ans+=a[nl-2-i];
        ans+=9LL*(nl-2-i);
        break;
      }
    }
    //REP(i,nl-1)
    //  ans+=funck1(i,nl);
  }


  if ((k==3)&(nl>=3)){
    ans+=(a[nl-1]-1LL)*81LL*(nl-1)*(nl-2)/2LL;
    ll flag=0;

    flag=0;
    
    ans+=funck2(0,nl);
  
  }
  
  if (nl<k)ans=0;




  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

const int N = 2020;
const int Mod = 1e9 + 7;

void add_self(int& x,int y){
    if((x += y) >= Mod) x -= Mod;
}
void sub_self(int& x,int y){
    if((x -= y) < 0)    x += Mod;
}

int n,m;
int a[N];
int b[N];
int Dp[N][N];

int Rec(int i = 0,int j = 0)
{
    if(i >  n || j >  m)    return 0;
    if(i == n && j == m)    return 1;

    if(Dp[i][j] + 1)    return Dp[i][j];

    int Res = 0;

    add_self(Res,Rec(i,j+1));
    add_self(Res,Rec(i+1,j));
    sub_self(Res,Rec(i+1,j+1));

    if(a[i] == b[j])    add_self(Res,Rec(i+1,j+1));

    return Dp[i][j] = Res;
}

int main()
{
    memset(Dp,-1,sizeof(Dp));

    cin>>n>>m;

    for(int i=0;i<n;i++)    scanf("%d",a+i);
    for(int i=0;i<m;i++)    scanf("%d",b+i);

    cout << Rec();
}


Measured memory_bytes: 16384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B);
  vector<int> x(M), y(M), c(M);
  rep(i, A)
  {
    cin >> a[i];
  }
  rep(i, B)
  {
    cin >> b[i];
  }
  int minA = *min_element(a.begin(), a.end());
  int minB = *min_element(b.begin(), b.end()); // 最小値のイテレータを返してくれる
  int ans = minA + minB;
  for (int i = 0; i < M; i++)
  {
    int x, y, c;
    cin >> x >> y >> c;
    x--;
    y--;
    ans = min(ans, a[x] + b[y] - c);
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
	int K; cin >> K;
	string s; cin >> s;
	if(s.size() <= K){ 
		cout << s << endl;
	} else{
		string ss = s.substr(0,K) + "...";
		cout << ss << endl;
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    for (ll i = k; i <= n + 1; i++)
    {
        ll cur1 = (i - 1) * i / 2;
        ll cur2 = (2 * n - i + 1) * i / 2;
        ll cnt = (cur2 - cur1 + 1) % mod;
        ans = (ans + cnt) % mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3648
#include <cmath>
#include <vector>
#include <stdio.h>
#include <iostream>
using namespace std;

//-----------------------------------------
float time_past(int T, int X){
    float t;
    t = (float)T / (float)X;
    return t;
}

int main() {
    // I/O format
    int T, X; cin >> T >> X;
    float out;

    out= time_past(T, X);
    cout << out << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

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

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#define rep(i,n) for(int i=0;i<int(n);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

void solve(){
	const int MAX_N = 2000+5;
	ll t[MAX_N] = {};
	priority_queue<ll, std::vector<ll>, std::greater<ll> > q;

	ll N, x, a[MAX_N]; cin >>N >>x; rep(i, N) cin >>a[i];

	rep(i,N){
		t[i] = a[i];
	}

	rep(i,N){
		rep(j,N){
			t[j] = min(t[j], a[(N + j - i) % N]);
		}
		//ARR(t, N);

		ll sum = 0;
		rep(j,N) sum += t[j];

		q.push(i * x + sum);
	}

	cout << q.top() << endl;
}

int main(){
	solve();
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

unsigned int compare_int(const void *a, const void *b){
    return *(unsigned int*)a - *(unsigned int*)b;
}

int main(){
    int n,i,k;

    scanf("%d%d",&n,&k);
    unsigned int h[n];
    unsigned int min=4294967295;

    for(i=0;i<n;i++){
        scanf("%u",&h[i]);
    }

    qsort(h,n,sizeof(unsigned int),compare_int);

    for(i=0;i+k-1<n;i++){
        if(h[i+k-1]-h[i]<min){
            min=h[i+k-1]-h[i];
        }
    }

    printf("%u",min);
  
    return 0;
}

Measured memory_bytes: 892
#include <stdio.h>

int cross(int x1,int y1,int x2,int y2,
	int x3,int y3,int x4,int y4) {
	double kaA,seA,kaB,seB,x,y,uex,uey,sitax,sitay;
	if(x1==x3 && y1==y3)return 1;
	if(x1==x4 && y1==y4)return 1;
	if(x2==x3 && y2==y3)return 1;
	if(x2==x4 && y2==y4)return 1;
	if(x1!=x2 && x3!=x4) {
		kaA=(double)(y2-y1)/(double)(x2-x1);
		seA=y1-x1*kaA;
		kaB=(double)(y4-y3)/(double)(x4-x3);
		seB=y3-x3*kaB;
		if(kaA==kaB) {
			if(seA==seB) {
				if(x1>x2){uex=x1;sitax=x2;} else {uex=x2;sitax=x1;}
				if((x3>=sitax && x3<=uex) || (x4>=sitax && x4<=uex))return 1;
				return 0;
			} else return 0;
		}
		x=(double)(seB-seA)/(double)(kaA-kaB);
		y=kaA*x+seA;
		if(x1>x2){uex=x1;sitax=x2;} else {uex=x2;sitax=x1;}
		if(y1>y2){uey=y1;sitay=y2;} else {uey=y2;sitay=y1;}
		if(y1!=y2) {
			if(x<sitax || x>uex || y<sitay || y>uey)return 0;
		} else {
			if(x<sitax || x>uex)return 0;
		}
		if(x3>x4){uex=x3;sitax=x4;} else {uex=x4;sitax=x3;}
		if(y3>y4){uey=y3;sitay=y4;} else {uey=y4;sitay=y3;}
		if(y3!=y4) {
			if(x<sitax || x>uex || y<sitay || y>uey)return 0;
		} else {
			if(x<sitax || x>uex)return 0;
		}
	}
	if(x1==x2 && x3!=x4) {
		kaB=(double)(y4-y3)/(double)(x4-x3);
		seB=y3-x3*kaB;
		y=kaB*x1+seB;
		if(y1>y2){uey=y1;sitay=y2;} else {uey=y2;sitay=y1;}
		if(x3>x4){uex=x3;sitax=x4;} else {uex=x4;sitax=x3;}
		if(y<sitay || y>uey || x1<sitax || x1>uex)return 0;
	}
	if(x1!=x2 && x3==x4) {
		kaA=(double)(y2-y1)/(double)(x2-x1);
		seA=y1-x1*kaA;
		y=kaA*x3+seA;
		if(y3>y4){uey=y3;sitay=y4;} else {uey=y4;sitay=y3;}
		if(x1>x2){uex=x1;sitax=x2;} else {uex=x2;sitax=x1;}
		if(y<sitay || y>uey || x3<sitax || x3>uex)return 0;
	}
	if(x1==x2 && x3==x4) {
		if(x1!=x3)return 0;
		if(y1>y2){uey=y1;sitay=y2;} else {uey=y2;sitay=y1;}
		if(y3>y4){uex=y3;sitax=y4;} else {uex=y4;sitax=y3;}
		if(sitax>uey)return 0;
		if(uex>sitay)return 0;
	}
	return 1;
}

int main(void) {
	int datanum,datamax;
	int crossnum;
	int x1,y1,x2,y2,x3,y3,xk,yk,xs,ys;
	scanf("%d",&datamax);
	for(datanum=0;datanum<datamax;datanum++) {
		scanf("%d %d %d %d %d %d %d %d %d %d",
			&x1,&y1,&x2,&y2,&x3,&y3,&xk,&yk,&xs,&ys);
		crossnum=0;
		if(cross(x1,y1,x2,y2,xk,yk,xs,ys))crossnum++;
		if(cross(x2,y2,x3,y3,xk,yk,xs,ys))crossnum++;
		if(cross(x3,y3,x1,y1,xk,yk,xs,ys))crossnum++;
		puts(crossnum==1?"OK":"NG");
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX_N 1000
ll N,V,ans=0;
ll a[MAX_N];
ll b[MAX_N];
ll c[MAX_N];
ll d[MAX_N];
map<ll,ll> t;
  
int main(){
  scanf("%lld %lld",&N,&V);
  for(int i=0;i<N;i++)scanf("%lld",&a[i]);
  for(int i=0;i<N;i++)scanf("%lld",&b[i]);
  for(int i=0;i<N;i++)scanf("%lld",&c[i]);
  for(int i=0;i<N;i++)scanf("%lld",&d[i]);
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      t[ a[i]+b[j] ]++;
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      ans+=t[V-c[i]-d[j]];
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 128188
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string s;
    cin >> s;

    map<char, int> mp;

    for(char c : s){
        mp[c]++;
    }

    string t = "abcdefghijklmnopqrstuvwxyz";
    for(char c : t){
        if(mp[c]==0){
            p(c);
            return 0;
        }
    }

    p("None");

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define N 1000000007

ll power(ll x, ll n) {
    ll ans = 1;
    while (n > 0) {
        if (n % 2 == 1) {
            ans *= x;
            ans %= N;
        }
        x *= x;
        x %= N;
        n >>= 1;
    }
    return ans;
}

ll comb(ll n, int a) {
    ll acc = 1;
    for (int i = 0; i < a; i++) {
        acc *= n - i;
        acc %= N;
    }
    ll div = 1;
    for (int i = 0; i < a; i++) {
        div *= i + 1;
        div %= N;
    }
    div = power(div, N - 2);
    return (acc * div) % N;
}

int main()
{
    ll n;
    int a, b;
    cin >> n >> a >> b;
    ll acc = power(2, n);
    acc += (N - comb(n, a));
    acc %= N;
    acc += (N - comb(n, b));
    acc %= N;
    cout << (acc - 1) % N << endl;
    return 0;
}

Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] A = new long[N];
        long sum = 0;
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextLong();
            sum += A[i];
        }
        StringJoiner sj = new StringJoiner(" ");
        long current = sum;
        for (int i = 1; i * 2 < N; i++) {
            current -= A[i * 2 - 1] * 2;
        }
        sj.add(Long.toString(current));
        for (int i = 1; i < N; i++) {
            current = 2 * A[i - 1] - current;
            sj.add(Long.toString(current));
        }
        System.out.println(sj.toString());
    }
}


Measured memory_bytes: 60732
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n,x;
    int ans = 1;
    cin >> n>>x;
    vector<int> L(n);
    for (int i=0;i<n;i++) cin >> L[i];
    int d=0;
    int i=0;
    for (int i=0;i<n;i++){
        d = d + L[i];
        if (d<=x) ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll B[110];
int main(){
    int n;cin>>n;
    for(int i=1;i<n;i++) cin>>B[i];
    ll ans=0;
    B[n]=B[0]=1e9;
    for(int i=0;i<n;i++) ans+=min(B[i],B[i+1]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
s=input()
if s[0]=="(":
    c=1
    d=1
else:
    c=-1
    d=-1
for i in range(1,n):
    if s[i]=="(":
        d+=1
    else:
        d-=1
        c=min(c,d)
if c<0:
    s="("*(-c)+s
print(s+")"*(s.count("(")-s.count(")")))


Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
 
using namespace std;
int main(){
    string s;std::cin >> s;
    int a,b,n;
    for(int i=0;i<3;i++){
        if(s.at(i)=='1')s.at(i)='9';
        else if(s.at(i)=='9')s.at(i)='1';
        
    }
    std::cout <<s << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
//ate
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
void yes() { cout << "Yay!\n"; }
void no() { cout << ":(\n"; }

int main() {
    init();

    int x, y;
    cin >> x >> y;
    int ans = 0;
    int k[4] = { 0,300000 ,200000,100000 };
    if (x < 4) ans += k[x];
    if (y < 4)ans += k[y];
    if (x == 1 && y == 1)ans += 400000;
    cout << ans << "\n";
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

mod = 10 ** 9 + 7

cnt = [0] * n
for v in a:
    cnt[v] += 1

res = 1

if n % 2 == 1:
    if cnt[0] != 1:
        print(0)
        exit()
    
    for i in range(1, n):
        if i % 2 == 1:
            if cnt[i] > 0:
                print(0)
                exit()
        else:
            if cnt[i] == 2:
                res = res * 2 % mod
            else:
                print(0)
                exit()
    
else:
    for i in range(1, n):
        if i % 2 == 0:
            if cnt[i] > 0:
                print(0)
                exit()
        else:
            if cnt[i] == 2:
                res = res * 2 % mod
            else:
                print(0)
                exit()

print(res)

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

int main() {
  int h,w;
  cin>>h>>w;
  vector<vector<int>> a(h,vector<int>(w));
  rep(i,h) {
    rep(j,w){
      cin >> a.at(i).at(j);
    }
  }
  
  vector<tuple<int,int,int,int>>ans;
  rep(i,h){
    if(i%2==0){
      rep(j,w-1){
        if(a[i][j]%2!=0){
          a[i][j+1]++;
          ans.push_back(make_tuple(i+1,j+1,i+1,j+2));
        }
      }
      if(i!=h-1&&a[i][w-1]%2!=0){
        a[i+1][w-1]++;
        ans.push_back(make_tuple(i+1,w,i+2,w));
      }
    }
    else{
      for(int j=w-1;j>0;j--){
        if(a[i][j]%2!=0){
          a[i][j-1]++;
          ans.push_back(make_tuple(i+1,j+1,i+1,j));
        }
      }
      if(i!=h-1&&a[i][0]%2!=0){
        a[i+1][0]++;
        ans.push_back(make_tuple(i+1,1,i+2,1));
      }
    }
  }
  cout<<ans.size()<<endl;
  rep(i,ans.size()){
    cout<<get<0>(ans[i])<<" "<<get<1>(ans[i])<<" "<<get<2>(ans[i])<<" "<<get<3>(ans[i])<<endl;
  }
}

Measured memory_bytes: 6304
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
const int INF = 1e9;
const long long LINF = 1e18;
const double EPS = 1e-8;
#define pb emplace_back
#define mk make_pair
#define fr first
#define sc second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define rreps(i,j,k) for(int i = (j); i >= (k); --i)
#define rrep(i,j) rreps(i,j,0)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef pair<int, ll> Pil;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main(){
	int N;
	cin >> N;
	cout << N*(N+1)/2 << endl;
	return 0;
}

Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())

ans = float('inf')
for i in range(0,2*max(x,y)+1,2):
    ab = i
    x_tmp = x - i//2
    y_tmp = y - i//2
    tmp = max(0,a*x_tmp) + max(0,b*y_tmp) + c*i
    if tmp < ans:
        ans = tmp
print (ans)


Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vii;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b;
  cin>>a>>b;
  if( a<=8 and b<=8 ){ cout<<"Yay!\n"; }
  else{ cout<<":(\n"; }
  return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			Integer a[] = new Integer[n];
			for (int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}

			int count = 0;
			for (int i = 0; i < n; i++) {
				while (a[i] % 2 == 0) {
					a[i] /= 2;
					count++;
				}
			}

			System.out.println(count);
		}

	}

}

Measured memory_bytes: 37228
d = input().split()
a = input().split()
p = [(-1, 2, 4, 1, 3, -1), (3, -1, 0, 5, -1, 2), (1, 5, -1, -1, 0, 4),
(4, 0, -1, -1, 5, 1), (2, -1, 5, 0, -1, 3), (-1, 3, 1, 4, 2, -1)]
ts = [i for i, x in enumerate(d) if x == a[0]]
fs = [i for i, x in enumerate(d) if x == a[1]]
b = 0
for t in ts:
  for f in fs:
    if t == f: continue
    r = p[t][f]
    if r == -1: continue
    l = [d[t], d[f], d[r], d[5-r], d[5-f], d[5-t]]
    if a == l: b += 1; break
print("Yes") if b > 0 else print("No")


Measured memory_bytes: 5580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;



int main(){
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.size() <= k){
        cout << s << endl;
    }
    else{
        string ans=s.substr(0,k)+"...";
        cout << ans << endl;
    }

   

}

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

int main(void){
    int a1, a2, m = 1;
    int c[1000001];
    scanf("%d", &a1);

    while (c[a1] != 1) {
        c[a1] = 1;
        if(a1 % 2 == 0){
            a2 = a1 / 2;
        }else{
            a2 = 3 * a1 + 1;
        }
        a1 = a2;
        m++;
    }

    printf("%d\n", m);

    return 0;
}


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

int maxsize = 300000;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n+1);
    vector<ll> plus(maxsize),minus(maxsize);
    REP(i,n){
        cin >> a[i];
        if(i+a[i]<maxsize)plus[i+a[i]]++;
        if(i-a[i]>=0) minus[i-a[i]]++;
    }
    ll ans = 0;
    REP(i,maxsize-1){
        ans+=plus[i]*minus[i];
    }
    cout << ans << endl;
}

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

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int main(){
    int n;
    cin >> n;
    int sum=0;

    for(int i=0;i<n;i++){
        int l,r;
        cin >> l >> r;
        sum+=r-l+1;
    }
    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 256
N = int(input())

word_list = []
f = 0
for i, n in enumerate(range(N)):
  s = input()
  if i == 0:
    pre = s[-1]
    word_list.append(s)
    continue
  if s in word_list:
    f = 1
    break
  if s[0] != pre:
    f = 1
    break
  pre = s[-1]
  word_list.append(s)
if f == 1:
  print("No")
else:
  print("Yes")


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

int main() {
  int a,b,c;
  cin >>a>>b>>c;
  int ichi,ni,san;
  ichi=min(a,min(b,c));
  san=max(a,max(b,c));
  ni=a+b+c-ichi-san;
  cout <<ichi<<" "<<ni<<" "<<san<<endl;
}


Measured memory_bytes: 3092