akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define rep(i,j) for(int i=0;i<j;i++)
using namespace std;

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }
int main(void)
{
	ll N,X;
	ll ans=0;
	cin>>N>>X;
	vector<ll> x(N);
	rep(i,N) cin>>x[i];
	rep(i,N)ans=gcd(ans,abs(x[i]-X));
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	string s;
	bool c = false, f = false;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'C')c = true;
		if (c&&s[i] == 'F')f = true;
	}
	cout << (f ? "Yes" : "No") << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, B;
    cin >> A >> B;
    if(A <= 5) cout << 0;
    else if(A <= 12) cout << B / 2;
    else cout << B;
    cout << endl;
    return 0;
}


Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;

namespace Test01
{
    struct AB
    {
        public int a;
        public int b;
        public AB(int a, int b)
        {
            this.a = a;
            this.b = b;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            //入力1(N, M)
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int N = input[0];
            int M = input[1];
            //入力2(ab)
            AB[] ab = new AB[M];
            for(int i = 0; i < M; i++)
            {
                input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();              
                ab[i] = new AB(input[0], input[1]);
            }

            int cnt = 0;  //切った数をカウント
            int cut_e = -1;  //直前に切った橋の番号
            foreach(var s in ab.OrderBy(x => x.b))
            {
                if (s.a > cut_e) { cut_e = s.b - 1; cnt++; }
            }

            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 19768
# B
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
past = -2
for index in a:
    ans += b[index-1]
    if past == index-1:
        ans += c[index-2]
    past = index
print(ans)

Measured memory_bytes: 38384
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    int N;cin>>N;
    if(N<105)cout<<0<<endl;
    else if(N<135)cout<<1<<endl;
    else if(N<165)cout<<2<<endl;
    else if(N<189)cout<<3<<endl;
    else if(N<195)cout<<4<<endl;
    else cout<<5<<endl;
    return 0;

}

Measured memory_bytes: 256
import sys

n = int(input())


for i in range(1, 3500):
    for j in range(1, 3500):
        # 分子
        rest = 4 * i * j - n * i - n * j
        if rest > 0:
            ans = n * i * j / rest
            if ans.is_integer():
                print(i, j, int(ans))
                sys.exit()

Measured memory_bytes: 40684
#include <iostream>
#include <map>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using namespace std;

int main(){
  ll n;
  cin >> n;
  map<int,int> A;
  ll a;
  rep(i,n){
    cin >> a;
    A[a]++;
    if(A[a] > 1){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 9600
import heapq

n,m = map(int,input().split())
a = list(map(lambda x: -int(x),input().split()))
heapq.heapify(a)
for _ in range(m):
    temp = -heapq.heappop(a)
    temp//=2
    heapq.heappush(a,-temp)
ans = 0
for _ in range(n):
    ans -= heapq.heappop(a)
print(ans)

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> data.at(i).at(j);
    }
  }

  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;

  for (int i = 0; i < H; i++) {
    cout << '#';
    for (int j = 0; j < W; j++) {
      cout << data[i][j];
    }
    cout << '#' << endl;
  }

  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 3652
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	var x, y, z, k int
	fmt.Scan(&x, &y, &z, &k)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, x)
	for i := range as {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(sort.Reverse(sort.IntSlice(as)))
	bs := make([]int, y)
	for i := range bs {
		sc.Scan()
		bs[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(sort.Reverse(sort.IntSlice(bs)))
	cs := make([]int, z)
	for i := range cs {
		sc.Scan()
		cs[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(sort.Reverse(sort.IntSlice(cs)))

	ans := make([]int, 0, x+y+z)
	for ia, a := range as {
		for ib, b := range bs {
			for ic, c := range cs {
				if (ia+1)*(ib+1)*(ic+1) > k {
					break
				}
				ans = append(ans, a+b+c)
			}
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(ans)))
	for _, v := range ans[:k] {
		fmt.Println(v)
	}
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll d,n;
    cin>>d>>n;
    ll x = pow(100,d);
    if(n==100)n++;
    ll ans= x*n;
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007; // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const ld PI = acos((ld)-1);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
  os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;
  ll now,ans=0;
  V<ll> v(n);
  rep(i,0,n)cin>>v[i];
  now=v[0];
  rep(i,1,n){
    ans+=max(0ll,now-v[i]);
    chmax(now,v[i]);
  }

  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 4776
N = int(input())
S = [int(input()) for _ in range(N)]
S.sort()
sum_s = sum(S)

if sum_s % 10 != 0:
    print(sum_s)
    exit()

for s in S:
    if (sum_s - s) % 10 != 0:
        print(sum_s - s)
        exit()

print(0)

Measured memory_bytes: 3060
from sys import stdin, stdout

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, m, x = rli()
	A = []
	for _ in range(n):
		A.append(list(rli()))
	mask = 0
	for i in range(n):
		mask |= (1 << i)

	opt = INF

	def process(s):
		nonlocal opt
		i = 0
		cost = 0
		algs = [0 for _ in range(m)]
		while s:
			s, bit = divmod(s, 2)
			if bit:
				cost += A[i][0]
				for j in range(1, m+1):
					algs[j-1] += A[i][j]
			i += 1
		if all(skill >= x for skill in algs):
			opt = min(opt, cost)

	process(mask)
	s = mask
	while s > 0:
		process(s)
		s = (s-1) & mask

	print(opt if opt < INF else -1)
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 69212
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

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

int main() {
    int k; cin >> k;
    ll sum=0;
    for(int a=1; a<=k; a++){
        for(int b=1; b<=k; b++){
            for(int c=1; c<=k; c++){
                sum += gcd(gcd(a,b),gcd(b,c));
            }
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3624
#include<cstdio>
using namespace std;
int main()
{
	int a,b,c,d,e,sum;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if(a<b&&a<c)	sum=a-50;
	else if(b<a&&b<c)	sum=b-50;
	else	sum=c-50;
	if(d<e) sum+=d;
	else	sum+=e;
	printf("%d\n",sum);
	return 0;
}



Measured memory_bytes: 2748
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
		int M = sc.nextInt();

		int[] a = new int[M];
		int[] b = new int[M];

		int[] ans = new int[N];
		for(int i=0; i<N; i++){
			ans[i] = 0;
		}

		for(int i=0; i<M; i++){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			ans[a[i]-1]++;
			ans[b[i]-1]++;
		}

		for(int i=0; i<N; i++){
    	System.out.println(ans[i]);
		}

	}

}


Measured memory_bytes: 23764
(let ((a (read))
    (b (read))
    (ans "Positive")
    (neg -1))
    (if (and (<= a 0) (>= b 0))
        (setq ans "Zero")
        (progn
            (if (< a 0)
                (setq neg (- b a))
            )
            (if (zerop (rem neg 2))
                (setq ans "Negative")
            )
        )
    )
    (format t "~A~%" ans)
)

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

int main(){

    string S;
    cin >> S;

    map<char,int>  mp;
    for(int i=0;i<S.length();i++){
        mp[S[i]]++;
    }

    for(auto t:mp){
        if(t.second!=2){
            cout << "No" <<endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
  const unsigned char g[] = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
  int a, b;
  scanf("%d %d", &a, &b);
  puts(g[a - 1] == g[b - 1] ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 128
N,D = map(int,input().split())
P = []
for i in range(N):
    X,Y = map(int,input().split())
    P.append([X,Y])
cnt = 0
for i in range(N):
    X,Y = P[i]
    dist2 = X*X + Y*Y
    if dist2 <= D*D:
        cnt += 1
print(cnt)

Measured memory_bytes: 38980
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii; 
int dp[100010];
bool bd[100010];
int n,m;
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a;
		cin>>a;
		bd[a]=1;
	}
	dp[1]=(bd[1]==1 ? 0 : 1);
	dp[0]=(bd[0]==1 ? 0 : 1);
	for(int i=2;i<=n;i++){
		dp[i]=(dp[i-1]+dp[i-2])%1000000007;
		if(bd[i])dp[i]=0;
	}
	cout<<dp[n]<<endl;
    return 0; 
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <memory.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long LL;
typedef double D;

const int N = 3e5 + 1;

LL arr[N], r[N], l[N];
priority_queue<LL> pq;

int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	for (int i = 0; i < n * 3; ++i)
		cin >> arr[i];
	
	LL sum = 0;
	
	for (int i = n * 3 - 1; i >= n * 2; --i)
	{
		sum += arr[i];
		pq.push(arr[i]);
	}
	
	r[n * 2] = sum;
	
	for (int i = n * 2 - 1; i >= n; --i)
	{
		sum += arr[i];
		pq.push(arr[i]);
		sum -= pq.top();
		pq.pop();
		r[i] = sum;
	}
	
	sum = 0;
	
	while(!pq.empty())
		pq.pop();
	
	for (int i = 0; i <= n - 1; ++i)
	{
		sum -= arr[i];
		pq.push(-arr[i]);
	}
	
	l[n - 1] = -sum;
	
	for (int i = n; i <= n * 2 - 1; ++i)
	{
		sum -= arr[i];
		pq.push(-arr[i]);
		sum -= pq.top();
		pq.pop();
		l[i] = -sum;
	}
	
	LL res = -1e18;
	
	for (int i = n; i <= 2 * n; ++i)
		res = max(res, l[i - 1] - r[i]);
	
	cout << res;
}

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

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

  int count = 0;
  for(int i = 1; i <= N; i++){
    if(i < 10){
      count++;
    }
    if(i >= 100 && i<= 999){
      count++;
    }
    if(i >= 10000 && i <= 99999){
      count++;
    }
  }

  cout << count <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

bool primeJudge( int a ) {
    int in_num = a;
    for ( int i = 2; i * i <= a; ++i ) {
        if ( a == 1 ) break;
        while(1) {
            if ( a % i != 0 ) break;
            a /= i;
        }
    }
    if ( a == in_num ) return true;
    else               return false;
}

int main(){
    int q;
    cin >> q;
    vector<bool> prime(1e5+1, false);
    for ( int i = 2; i <= 1e5; ++i ) {
        prime[i] = primeJudge(i);
    }
    vector<int> like2017;
    for ( int i = 3; i <= 1e5; i = i + 2 ) {
        if ( prime[i] && prime[(i+1)/2] ) {
            like2017.push_back(i);
        }
    }
//    rep(i, 1e5+1) {
//        if ( prime[i] ) cout << i << endl;
//    }
//    cout << like2017.size() << endl;
    vector<int> ans(q);
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        int ur_num = upper_bound(like2017.begin(), like2017.end(), r) - like2017.begin();
        int ul_num = lower_bound(like2017.begin(), like2017.end(), l) - like2017.begin();
        ans[i] = ur_num - ul_num;
    } 
    rep(i, q) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 1024
S = input() + 'E'
gx, gy = map(int, input().split())
X, Y = [], []
x, y, i, flag = 0, 0, 0, 1
while i <= len(S):
    f = 0
    while S[i] == 'F':
        f += 1
        i += 1
    if flag:
        X.append(f)
    else:
        Y.append(f)
    flag = (flag + 1) % 2
    if S[i] == 'E':
        break
    i += 1
gx -= X[0]
for x in sorted(X[1:], reverse = True):
    if gx > 0:
        gx -= x
    else:
        gx += x
for y in sorted(Y, reverse = True):
    if gy > 0:
        gy -= y
    else:
        gy += y
if gx == gy == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 41328
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i, n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i, a, b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i, a, b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a, b) a=min((a),(b))
#define CHMAX(a, b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a, b) (abs(a-b)<EPS)
typedef complex<Real> P;


int main() {
//    int N ,L; cin >> N >> L;

//    vector<string> vs(N);
//    REP(i, N) cin >> vs.at(i);

    string O, E; cin >> O >> E;

    REP(i, E.size()) {
        cout << O.at(i);
        cout << E.at(i);
    }

    if(O.size() != E.size()) cout << O.back();


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool p;
int main(){
	long long a,b,k;
	cin>>a>>b>>k;
	if(2*k>=(b-a+2))p=1;
	if(p){
		for(long long i=a;i<=b;++i)
			cout<<i<<endl;
		return 0;
	}
	for(long long i=a;i<=a+k-1;++i)
		cout<<i<<endl;
	for(long long i=b-k+1;i<=b;++i)
		cout<<i<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define N 100000
using namespace std;
int n;
int a1[N+5],a2[N+5];
long long s1,s2;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a1[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&a2[i]);
	for(int i=1;i<=n;i++)
	{
		if(a1[i]<a2[i])
		{
			int x=a2[i]-a1[i];
			s1+=x/2;
		}
		else
			s2+=a1[i]-a2[i];
	}
	if(s2<=s1)
		printf("Yes\n");
	else
		printf("No\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ll1 int
#define mod 1000000007


int main()
{
	string s;
	cin>>s;
	ll i,c=0,n=s.length()-1,k=n;
	// cout<<n<<" "<<(n+1)/2<<endl;
	for(i=0;i<(n+1)/2;i++)
	{
		// cout<<s[i]<<" ";
		if(s[i]!=s[k])
			c++;
		k--;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>

using namespace std;
int n;
long long k;

int main() {
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<int> p; // path
    vector<int> d(n + 1, -1); // discovered
    int cycle_len = 1, acyclic_len = 0;
    {
        int v = 1, t = 0;
        while (d[v] == -1) {
            // visit the vertex
            d[v] = t;
            t++;
            p.push_back(v);

            // move to the next vertex
            v = a[v - 1];
        }
        cycle_len = t - d[v];
        acyclic_len = d[v];
    }

    if (k <= acyclic_len) {
        cout << p[k] << endl;
    } else {
        k -= acyclic_len;
        k %= cycle_len;
        k += acyclic_len;
        cout << p[k] << endl;
    }
    return 0;
}

Measured memory_bytes: 5792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func init() {
	// 100MB
	bufsize := 100 * 1024 * 1024
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, bufio.MaxScanTokenSize), bufsize)
	sc.Split(bufio.ScanWords)
}
func readInt() int              { return readIntArray(1)[0] }
func readInt2() (int, int)      { a := readIntArray(2); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(3); return a[0], a[1], a[2] }
func readIntArray(n int) []int {
	s := readStringArray(n)
	a := make([]int, n)
	for i := range a {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}
func readString() string            { return readStringArray(1)[0] }
func readString2() (string, string) { a := readStringArray(2); return a[0], a[1] }
func readStringArray(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i] = sc.Text()
	}
	return a
}
func max(ns ...int) int {
	max := ns[0]
	for _, n := range ns {
		if n > max {
			max = n
		}
	}
	return max
}
func min(ns ...int) int {
	min := ns[0]
	for _, n := range ns {
		if n < min {
			min = n
		}
	}
	return min
}
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

type SC struct {
	s int
	c int
	N int
}

func (sc *SC) check(n int) bool {
	switch sc.N {
	case 1:
		return n == sc.c
	case 2:
		switch sc.s {
		case 1:
			return n/10 == sc.c
		case 2:
			return n%10 == sc.c
		}
	case 3:
		switch sc.s {
		case 1:
			return n/100 == sc.c
		case 2:
			return (n%100)/10 == sc.c
		case 3:
			return n%10 == sc.c
		}
	}
	return false
}

func main() {
	N, M := readInt2()
	var start, end int
	switch N {
	case 1:
		start = 0
		end = 9
	case 2:
		start = 10
		end = 99
	case 3:
		start = 100
		end = 999
	}

	sc := make([]SC, M)
	for i := 0; i < M; i++ {
		s, c := readInt2()
		sc[i] = SC{s: s, c: c, N: N}
	}

	for n := start; n <= end; n++ {
		isFulfill := true
		for i := 0; i < M; i++ {
			if !sc[i].check(n) {
				isFulfill = false
				break
			}
		}
		if isFulfill {
			fmt.Println(n)
			return
		}
	}
	fmt.Println(-1)

}

//func main() {
//	N, M := readInt2()
//
//	var str string
//	for i := 0; i < N; i++ {
//		str += "a"
//	}
//
//	for i := 0; i < M; i++ {
//		s, c := readInt2()
//		target := string(str[s-1])
//		if target == "a" || target == strconv.Itoa(c) {
//			str = str[:s-1] + strconv.Itoa(c) + str[s:]
//		} else {
//			fmt.Println(-1)
//			return
//		}
//	}
//
//	str = strings.Replace(str, "a", "0", -1)
//
//	if N != 1 && string(str[0]) == "0" {
//		fmt.Println(-1)
//		return
//	}
//	result, _ := strconv.Atoi(str)
//	fmt.Println(result)
//}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n,k;
  cin>>n>>k;
  vector<pair<ll,int>> dts(n);
  rep(i,n) {
    int t,d;
    cin>>t>>d;
    dts[i]=make_pair(d,t);
  }
  sort(dts.begin(),dts.end());
  reverse(dts.begin(),dts.end());
  set<int> kind;
  using P = pair<int,ll>;
  priority_queue<P,vector<P>, greater<P>> pq;
  ll sum=0;
  rep(i,k) {
    int t,d;
    tie(d,t)=dts[i];
    sum+=d;
    if(kind.find(t)==kind.end()) {
      pq.push(make_pair(1,d));
      kind.insert(t);
    } else {
      pq.push(make_pair(0,d));
    }
  }
  ll ans=sum+kind.size()*kind.size();
  repeat(i,k,n) {
    int t,d;
    tie(d,t)=dts[i];
    if(kind.find(t)==kind.end()) {
      if(pq.top().first==0) {
        sum-=pq.top().second;
        sum+=d;
        kind.insert(t);
        pq.push(make_pair(1,d));
        pq.pop();
        ll tmp=sum+kind.size()*kind.size();
        ans=max(ans,tmp);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6256
#include<stdio.h>
#include<string.h>
#define MAX 1001

int c[MAX][MAX];

int lcs(char *x,char *y){
    int n,m,i,j;
    n=strlen(x);
    m=strlen(y);
  
    for(j=0;j<=m;j++){
      for(i=0;i<=n;i++){
        if(i==0||j==0)c[i][j]=0;
         else if(x[i-1]==y[j-1])c[i][j]=c[i-1][j-1]+1;
         else if(c[i-1][j]>c[i][j-1])c[i][j]=c[i-1][j];
         else c[i][j]=c[i][j-1];
      }
    }
    return c[n][m];
}

int main(){
  int n,i;
  char x[MAX],y[MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s%s",x,y);
    printf("%d\n",lcs(x,y));
  }
  return 0;
}


Measured memory_bytes: 5620
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;

int main(){
	int price,num,cnt=0,sum=0,average=0;
	while(scanf("%d",&price)!=EOF){
		scanf(",%d",&num);
		sum+=price*num;
		cnt++;
		average+=num;
	}
	double ans=(double)average/cnt;
	int as=average/cnt;
	cout<<sum<<endl;
	if((ans-as)<0.5)cout<<as<<endl;
	else cout<<as+1<<endl;
	return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include<string>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;

int main()
{
  // 入力
  int n, k;
  cin >> n >> k;
  deque<int> d, tmp;
  
  for (int i = 1; i <= n; i++) {
    int v;
    cin >> v;
    d.push_back(v);
  }
  
  int max = 0;
  for (int l = 0; l <= k && l <= n; l++) {
    for (int r = 0; l+r <= k && r <= n; r++) {
      int total = 0;
      tmp = d;
      vector<int> hand;
      for (int i = 0; i < l && 0 < tmp.size(); i++) {
        int v = tmp.front();
        total += v;
        hand.push_back(v);
        tmp.pop_front();
      }
      for (int i = 0; i < r && 0 < tmp.size(); i++) {
        int v = tmp.back();
        total += v;
        hand.push_back(v);
        tmp.pop_back();
      }
      
      sort(hand.begin(), hand.end());

      for (int t = 0; t < hand.size() && l+r+t < k; t++) {
        if (hand.at(t) < 0)
          total -= hand.at(t);
        else
          break;
      }

      if (total > max)
        max = total;
    }
  }
  
  // 出力
  cout << max << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int>P;
int main(void){
	int n;
	P pp[11];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>pp[i].F;
	}
	for(int i=0;i<n;i++){
		cin>>pp[i].S;
	}
	int MIN0=INT_MAX;
	int MIN1=INT_MAX;
	bool flg=false;
	bool flg1=false;
	for(int i=0;i<n;i++){
		if(pp[i].F==1){
			MIN1=min(MIN1,pp[i].S);
			flg1=true;
		}
		if(pp[i].F==0){
			MIN0=min(MIN0,pp[i].S);
			flg=true;
		}
	}
	if(flg&&flg1){
		cout<<MIN1+MIN0<<endl;
	}
	else{
		cout<<0<<endl;
	}
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];

  int c0 = 0, c1 = 0, c2 = 0, c3 = 0;
  for (auto t : s) {
    rep(j, t.size() - 1) if (t.substr(j, 2) == "AB") c0++;
    if (t.front() == 'B' && t.back() == 'A') c1++;
    if (t.front() == 'B' && t.back() != 'A') c2++;
    if (t.front() != 'B' && t.back() == 'A') c3++;
  }
  int c;
  if (c1 == 0) {
    c = min(c2, c3);
  } else {
    if (c2 + c3 > 0) {
      c = c1 + min(c2, c3);
    } else {
      c = c1 - 1;
    }
  }
  cout << c0 + c << endl;
  return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
	string str,b;
	cin>>str;
	cin>>b;
	bool t = true;
	for(int i=0;i<str.length();i++)
	{
		if(str[i] != b[i])
		{
			t = false;
			break;
		}
	}
	if(t)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
} 

Measured memory_bytes: 3628
#pragma GCC optimize("trapv")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
const int maxn = 1<<18;
int n, pu[maxn], du[maxn], s, u, inf = 0, ans = -(1<<30);
vector<int> gs[maxn], gu[maxn];
void preu(int v) {
	for(auto i : gu[v]) if(pu[v] != i) du[i] = du[v] + 1, pu[i] = v, preu(i);
}
int d1(int u, int v) {
	return pu[u] == v || pu[v] == u;
}
int d2(int u, int v) {
	return pu[pu[u]] == v || pu[pu[v]] == u || pu[u] == pu[v];
}
int bad(int u, int v) {
	return d1(u, v) + d2(u, v);
}
void dfs(int v, int p = 0, int d = 0) {
	if(d >= du[v]) return;
	ans = max(ans, max(d, du[v])+du[v]);
	int bd = 1;
	for(auto i : gs[v]) bd &= bad(v, i);
	if(!bd) inf = 1;
	for(auto i : gs[v]) if(i != p) dfs(i, v, d+1);
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> s >> u;
	for(auto &g : {gs, gu})
	for(int f, t, i = 1; i < n; i++) {
		cin >> f >> t;
		g[f].push_back(t);
		g[t].push_back(f);
	}
	preu(u);
	dfs(s);
	cout << (inf ? -1 : ans);
}


Measured memory_bytes: 38524
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rrep(i,l,r)for(ll i=(l);i>r;i--)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}/*swap 交換*/
ll max2(ll a,ll b){return a>=b?a:b;}/*2つのうち大きい数を返す*/ 
ll min2(ll a,ll b){return a>=b?b:a;}/*2つのうち小さい数を返す*/ 
ll ABS(ll a){return a>=0?a:(-a);}/*絶対値*/ 
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

/*nをa進数にしたときの、i桁目の数*/
ll placenai(ll n, ll a, ll i){return i==1?n%a:placenai(n/a,a,i-1);}
/*n(2)の中にある１の数*/
ll standn21(ll n){return n==0?0:n%2+standn21(n/2);}


typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    ll n,ans=0;
    scanf("%lld",&n);
    ll a[n],x[15][15],y[15][15];
    // rep(i,0,15){
    //     rep(j,0,15){
    //         x[j][i]=2;
    //         y[j][i]=2;
    //     }
    // }
    rep(i,0,n){
        scanf("%lld",&a[i]);
        rep(j,0,a[i]){
            scanf("%lld%lld",&x[i][j],&y[i][j]);
        }
    }
    ll z=pow(2,n)-1;
    rrep(i,z,0){
        ll f2=0;
        if(ans>standn21(i)) continue;
        // printf("%lld\n",i);
        rep(j,0,n){
            ll f1=0;
            // printf("%lld\n",j);
            if(placenai(i,2,j+1)){
                rep(k,0,a[j]){
                    if(placenai(i,2,x[j][k])!=y[j][k]){
                        break;
                    }
                    f1++;
                }
                if(f1!=a[j]) break;
            }
            f2++;
        }
        if(f2==n){
            ans=standn21(i);
            // printf("%lld ",i);
        }
        // printf("\n");
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
A,B,C=map(int,input().split())
target=[A,B,C]
START=sorted([A,B,C])

def checkIfInfinite(tar):
  tar=sorted(tar)
  for i in range(len(tar)):
    if tar[i]!=START[i]:
      return False
  return True

def checkIfEnd(tar):
  for t in tar:
    if t%2==1:
      return True
    
ans=0
while True:
  if checkIfEnd(target):
    print(ans)
    exit(0)
  Ahalf=target[0]//2
  Bhalf=target[1]//2
  Chalf=target[2]//2
  target[0]=Bhalf+Chalf
  target[1]=Chalf+Ahalf
  target[2]=Ahalf+Bhalf
  ans+=1
  if checkIfInfinite(target):
    print(-1)
    exit(0)


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  pr(c / a * b);

  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>

using namespace std;

int main(){
	int n;
	cin >> n;
	int a = 1;
	while(a <= n){
		a *= 2;
	}
	cout << a / 2 << endl;
	
	return 0;
}

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

int main(){
	int a,b;
	while( cin >> a >> b , a||b ){
		int n,f[20][20] = {0};
		f[1][1] = 1;

		cin >> n;
		for(int i=0 ; i < n ; i++ ){
			int x,y;
			cin >> x >> y;
			f[y][x] = -1;
		}
		for(int y=1 ; y <= b ; y++ ){
			for(int x=1 ; x <= a ; x++ ){
				if( f[y][x] != -1 ){
					if( y != 1 && f[y-1][x] != -1 ){
						f[y][x] += f[y-1][x];
					}
					if( x != 1 && f[y][x-1] != -1 ){
						f[y][x] += f[y][x-1];
					}
				}
			}
		}
		cout << f[b][a] << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

void conb(int a, int b, int &ans)
{
    REP(i, b)
    {
        ans *= a - i;
     while(ans%(i+1)!=0)ans+=MOD;
        ans /= i + 1;
     ans%=MOD;
    }
}

signed main()
{
    int N, M;
    cin >> N >> M;

    vi a;

    bool flg = false;
    int tmp = 2;
    while (M > 1)
    {
        if (M % tmp == 0)
        {
            if (!flg)
            {
                a.push_back(1);
                flg = true;
            }
            else
                a[a.size() - 1]++;
            M /= tmp;
        }
        else
        {
            tmp++;
            flg = false;
        }
    }
    int ans = 1;
    REP(i, a.size())
    {
        conb(a[i] + N - 1, a[i], ans);
    }
    cout << ans << endl;

    // system("pause");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    long long N,M,A[100000]={},ans=0,max,l=0;
    cin >> N>>M;

    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    sort(A,A+N,greater<int>());
    max=0;

    for(int i=0;i<M;i++){
        for(int j=0;j<=l+1;j++){
            if(A[max]<A[j]){
                max=j;
            }
        }
        A[max]/=2;
        if(l<max){
            l=max;
        }

        if(i==M/2){
            sort(A,A+N,greater<int>());
            l=0;
        }

    }

    for(int i=0;i<N;i++){
        ans += A[i];
    }

    cout << ans <<endl;
    
    
    return 0;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int mo=998244353,N=405;
typedef vector<int>V;
int n,h[N],i,j,mi[N],ans,C[N][N];
inline V mul(V a,V b){
	V c(a.size()+b.size()-1);
	for(int i=0;i<a.size();++i)for(int j=0;j<b.size();++j)c[i+j]=(c[i+j]+1ll*a[i]*b[j])%mo;
	return c;
}
inline void add(V&a,V b){
	if(a.size()<b.size())a.resize(b.size());
	for(int i=0;i<b.size();++i)a[i]=(a[i]+b[i])%mo;
}
V f[N*N][2];int xb;
int solve(int l,int r,int z){
	int i,j,c=0,x,id=++xb;
	f[id][0]={1};
	auto upd=[&](V*v){
		V nv[2];
		for(int o1=0;o1<2;++o1)for(int o2=0;o2<2;++o2)add(nv[o1|o2],mul(f[id][o1],v[o2]));
		f[id][0]=nv[0];f[id][1]=nv[1];
	};
	for(i=l;i<=r;++i)if(h[i]==z)++c;else{
		for(j=i;j<=r && h[j]>z;++j);
		upd(f[solve(i,--j,z+1)]);i=j;
	}
	V v[2]={V(c+1),V(c+1)};v[0][0]=1;for(i=1;i<=c;++i)v[1][i]=C[c][i];upd(v);
	for(i=r-l+1;i>=0;--i)
		f[id][0][i]=(f[id][1][i]+1ll*mi[r-l+1-i]*f[id][0][i])%mo,
		f[id][1][i]=1ll*(mi[r-l+1-i]-1)*f[id][1][i]%mo;
	return id;
}
int main(){
	for(i=*mi=1;i<N;++i)mi[i]=2*mi[i-1]%mo;
	for(i=**C=1;i<N;++i)for(j=*C[i]=1;j<=i;++j)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	scanf("%d",&n);for(i=1;i<=n;++i)scanf("%d",h+i);
	solve(1,n,1);
	for(i=0;i<=n;++i)ans=(ans+(i&1?mo-f[1][0][i]:f[1][0][i]))%mo;
	printf("%d\n",ans);
}

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

int main() {
    int x;
    cin >> x;
    ll n = 0;
    for(int i = 1; i <= x; i++) {
        n = i * (i + 1) / 2;
        if(n >= x) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <regex>

using namespace std;
using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
	ll N;
	cin >> N;

	map<string, ll> mp;

	for (ll i = 0; i < N; i++)
	{
		string s;
		cin >> s;
		mp[s]++;
	}


	ll sum = 0;
	for (auto&& e : mp)
	{
		sum++;
	}
	cout << sum << endl;
}

Measured memory_bytes: 19228
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()
#define MP make_pair

int main() {
	ll a,b;
	cin >> a;
	if (a % 11 <= 6 && a % 11 != 0) cout << (a + 10) / 11 * 2 - 1 << endl;
	else cout << (a + 10) / 11 * 2 << endl;

}

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

const char NL = '\n';
const int MOD = 1e9 + 7;

// B - Frog 2
// https://atcoder.jp/contests/dp/tasks/dp_b

void solve()
{
    int n, k; cin >> n >> k;
    vector<int> v;
    for (int i = 0; i < n; ++i) {
        int h; cin >> h;
        v.push_back(h);
    }
    vector<int> dp(n, 0);
    for (int i = 1; i < n; ++i) {
        int minCost = INT_MAX;
        for (int j = max(0, i - k); j < i; ++j) {
            int cost = dp[j] + abs(v[i] - v[j]);
            minCost = min(minCost, cost);
        }
        dp[i] = minCost;
    }
    cout << dp[n - 1] << NL;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cerr<<#x<<" = "<<x<<endl

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li a,b,c,d;

    cin>>a>>b>>c>>d;

    li ans=a*c;

    ans=max(ans,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);

    cout<<ans;
}

int main()
{    
    //remove this in kickstart

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    f(i,1,t)
    {
        // cout<<"Case #"<<i<<": ";

        solve();
    }

    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int n;cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
    }
    else {
        int a,b;cin>>a>>b;
        cout<<a+b<<endl;
    }
}

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

using i64 = long long int;

int main(){
    int n, m, d;
    cin >> n >> m >> d;
    vector<string> v;
    for(int i=0;i<n;++i){
        string row;
        cin >> row;
        v.push_back(row);
    }

    int ans = 0;
    for(int i=0;i<n;++i){
        int acc = 0;
        for(int j=0;j<m;++j){
            if(v[i][j] == '#'){
                acc = 0;
            }else{
                acc++;
                if(acc >= d)ans++;
            }
        }
    }

    for(int j=0;j<m;++j){
        int acc = 0;
        for(int i=0;i<n;++i){
            if(v[i][j] == '#'){
                acc = 0;
            }else{
                acc++;
                if(acc >= d)ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3212
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var d, g int

	fmt.Sscan(getNextLine(scanner), &d, &g)
	g /= 100
	ppp := make([]int, d)
	ccc := make([]int, d)

	for i := 0; i < d; i++ {
		pc := getIntList(scanner)
		ppp[i] = pc[0]
		ccc[i] = pc[1] / 100
	}
	min := 1000
	for p := 0; p < 1<<uint(d); p++ {
		score := 0
		ans := 0
		masks := make([]int, d)
		for mask := 0; mask < d; mask++ {
			masks[mask] = p >> uint(mask) & 1
			if masks[mask] == 1 {
				ans += ppp[mask]
				score += ccc[mask] + ppp[mask]*(mask+1)
			}
		}
		for mask := d - 1; mask >= 0 && score < g; mask-- {
			if masks[mask] == 1 {
				continue
			}
			for ii := 0; ii < ppp[mask] && score < g; ii++ {
				ans++
				score += mask + 1
				if ii+1 == ppp[mask] {
					score += ccc[mask]
				}
			}
		}
		if min > ans {
			min = ans
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef set<int> SI;
typedef map<string, int> MSI;
typedef map<int, int> MII;
typedef pair<ll, ll> PLL;
typedef pair<ll, pair<ll, ll>> PLLL;

#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MP make_pair
#define PB push_back
#define FF first
#define SS second
#define MOD 1000000007
#define test ll t;cin>>t;while(t--)

void solve()
{
	ll n;
	cin >> n;
	vector<ll> v(n);
	for(int i=0;i<n;i++)
		cin >> v[i];
	ll res=0;
	for(int i=0;i<n-1;i++)
	{
		if(v[i+1]<v[i])
		{
			res+=(v[i]-v[i+1]);
			v[i+1]=v[i];
		}
	}
	cout << res << "\n";
	return;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	flash;

	// test
	// {
	// 	solve();
	// }
	solve();
#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed : " << 1000 * (double)clock() / (double)CLOCKS_PER_SEC
	     << " ms\n";
#endif
	return 0;
}


Measured memory_bytes: 4780
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try(Scanner sc = new Scanner(System.in);){
            System.out.println(new Main().run(sc));
        }
    }
    
    private String run(Scanner sc){
        int n = Integer.parseInt(sc.next());
        while(n > 0){
            n -= 1000;
        }
        return Integer.toString(Math.abs(n));
    }
    
}


Measured memory_bytes: 35264
#include <iostream>

using namespace std;

int main()
{
    int x,a,b,c,d;
    cin>>x;
    d=x%10;
    x=x/10;
    c=x%10;
    x=x/10;
    b=x%10;
    a=x/10;
    if(a+b+c+d==7)
        cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7";
    else if(a-b+c+d==7)
        cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7";
    else if(a+b-c+d==7)
        cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7";
    else if(a+b+c-d==7)
        cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7";
    else if(a-b-c+d==7)
        cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7";
    else if(a-b+c-d==7)
        cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7";
    else if(a+b-c-d==7)
        cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7";
    else if(a-b-c-d==7)
        cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7";

    return 0;
}


Measured memory_bytes: 256