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

const int MOD = 1000000007;

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

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

  vector<modint<MOD>> A(N, 0);
  rep(i, N) cin >> A[i].a;

  modint<MOD> sum = 0;
  for (int i = 1; i < N; i++) {
    sum += A[i];
  }

  modint<MOD> ans = 0;
  for (int i = 0; i < N - 1; i++) {
    ans += A[i] * sum;
    sum -= A[i + 1];
  }

  cout << ans.a;
}

Measured memory_bytes: 4836
// ConsoleApplication10.cpp : アプリケーションのエントリ ポイントを定義します。
//


// ConsoleApplication10.cpp : アプリケーションのエントリ ポイントを定義します。
//
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;


int main()
{
	int N, M, x, y, j, c,ans, i, k, ptr,l, m, sum;
	cin >> N;
	vector<int> A(N);
	for (i = 0; i < N; i++) {
		cin >> A[i];
	}
	sum = 0;
	m = 0;
	ptr = 0;
	sort(A.begin(), A.end());
	while(ptr<N){
		int un;
		un = A[ptr];
		while (ptr < N&&A[ptr] == un) {
			ptr++;
			m++;
		}
		sum += m % 2;
      m=0;
	}

	cout << sum << endl;







	return 0;
}





Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int i = 0;
  ll ans = 0;
  int sz = S.size();
  // aがabcの前になんこつづいているか
  int ac = 0;
  while(1) {
    if(i >= sz - 2) { break; }
    // S[i]がAだったらacをふやす、ちがったらacをリセットする
    if(S[i] == 'A') {
      ac++;
      // ABCをみつけたらacの数だけansをふやしてiをi+2まですすめる
      if(S[i + 1] == 'B' && S[i + 2] == 'C') {
        S[i + 2] = 'A';
        ans += ac;
        ac--;
        i += 2;
      } else {
        i++;
      }
    } else {
      ac = 0;
      i++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 720
#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 2e9
#define ll long long
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ALL(v) v.begin(), v.end()

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string s; cin >> s;
    int nr = 0, nb = 0;
    REP(i, N) {
        if (s.at(i) == 'R') nr++;
        else if (s.at(i) == 'B') nb++;
    }
    if (nr > nb) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
using lint=long long;
using namespace std;

lint dx[]={0,1,0,-1};
lint dy[]={1,0,-1,0};

lint H,W;
string str;
char map[410][410];
lint umap[410][410];
lint ans;

int main()
{	
	cin >> H >> W;
	for(lint i=1;i<=H;i++)
	{
		cin >> str;
		for(lint j=1;j<=W;j++)
		{
			map[i][j]=str[j-1];
		}
	}
	
	for(lint i=1;i<=H;i++)
	{
		for(lint j=1;j<=W;j++)
		{
			lint w=0,b=0;
			lint x,y;
			queue<pair<lint,lint>> q;
			q.push({i,j});
			while(!q.empty())
			{
				pair<lint,lint> p=q.front();
				q.pop();
				
				if(umap[p.first][p.second]==1)continue;
				if(p.first<=0 || H<p.first || p.second<=0 || W<p.second)continue;
				
				umap[p.first][p.second]=1;
				if(map[p.first][p.second]=='#')b++;
				else w++;
				for(lint k=0;k<4;k++)
				{
					y=p.first+dy[k];
					x=p.second+dx[k];
					if(y<=0 || H<y || x<=0 || W<x)continue;
					if(map[y][x]!=map[p.first][p.second])q.push({y,x});
				}
			}
			
			ans+=w*b;
			//cout << w << " " << b << endl;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m = 0;
	cin >> n >> m;
	vector<int>duck;
	for (int i = 0; i < m; i++)
	{
		int a = 0;
		cin >> a;
		duck.push_back(a);
	}
	for (int i = 0; i < m; i++)
	{
		n -= duck[i];
	}
	if (n < 0)n = -1;
	cout << n;
    return 0;
}



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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<set<int> > vs(26);
    rep (i, s.size()) vs[s[i] - 'a'].insert(i);
    rep (i, 26) vs[i].insert(Inf);
    rep (i, q) {
        int t;
        cin >> t;
        if (t == 1) {
            int p;
            char c;
            cin >> p >> c;
            vs[s[p - 1] - 'a'].erase(p - 1);
            s[p - 1] = c;
            vs[c - 'a'].insert(p - 1);
        } else {
            int cnt = 0;
            int l, r;
            cin >> l >> r;
            l--, r--;
            rep (j, 26) {
                auto p = vs[j].lower_bound(l);
                if (*p <= r) cnt++;
            }
            cout << cnt << endl;
        }
    }
    
    return 0;
}

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

using namespace std;

const int MAXN = 1000005;

int n;

char s[MAXN];

bool ok(int lim)
{
	bool flag[2] = {1,1};
	for (int par = 0;par <= 1;par++)
	{
		int l = par,r = ((lim & 1) == par ? lim : lim - 1);
		if (l > r)
			flag[par] = 0;
		for (int i = 1;i <= n;i++)
		{
			if (s[i] == '?')
			{
				l--;
				r++;
			}
			else
			{
				l += (s[i] == '0' ? -1 : 1);
				r += (s[i] == '0' ? -1 : 1);
			}
			if (l < 0)
				l += 2;
			if (r > lim)
				r -= 2;
			if (l > r)
				flag[par] = 0;
		}
	}
	return flag[0] || flag[1];
}

int main()
{
	scanf("%s",s + 1);
	n = strlen(s + 1);
	int low = 1,high = n;
	while (low < high)
	{
		int mid = low + high >> 1;
		if (ok(mid))
			high = mid;
		else
			low = mid + 1;
	}
	printf("%d\n",low);
	return 0;
}

Measured memory_bytes: 4764
N = int(input())
A = list(map(int, input().split()))

MOD = 10**9 + 7
sum_A = 0
for i in range(N):
    sum_A = (sum_A + A[i]) % MOD

sum = 0
for i in range(N):
    sum_A = (sum_A - A[i]) % MOD
    sum = (sum + sum_A*A[i]) % MOD 


print(sum)

Measured memory_bytes: 31452
object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
    for (r@Array(m, nmin, nmax) <- in if r.forall(_ != 0)) {
        println(in.take(m).flatten.zipWithIndex.slice(nmin - 1, nmax + 1).foldLeft((0, 0, 0)){
            case ((gap, p0, res), (p1, i)) => if (p0 - p1 >= gap) (p0 - p1, p1, i) else (gap, p1, res)
        }._3)
    }
}

Measured memory_bytes: 82488
#include<bits/stdc++.h>
#include<ext/rope>
#define ll long long
#define ld long double
#define ull unsigned long long
#define sc(x) scanf("%d",&x)
using namespace std;
using namespace __gnu_cxx;
const int N = 1e7 + 5;
const int mod = 998244353;
const ld pi = acos(-1.0);
int t,n,m,l,r,x,Case;
void run(){
    cin>>n>>x>>t;
    cout<<((n+x-1)/x)*t;
}
int main(){
#ifdef haosao
freopen("main.h", "r", stdin);
//freopen("out.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
//    while()
        run();
    return 0;
}


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

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

ans = 1
inc = None
for i in range(N-1):
    if inc is None:
        if A[i] != A[i+1]:
            inc = A[i] < A[i+1]
            continue

    if inc:
        if A[i] > A[i+1]:
            ans += 1
            inc = None
    else:
        if A[i] < A[i+1]:
            ans += 1
            inc = None

print(ans)


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

using namespace std;

// #define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define rep(i,a,b) for (int i = a; i <= (int)b; ++i)
#define f first
#define s second

#define single_test



constexpr int mod = 1e9 + 7;

struct M {
    unsigned v;
    M(long long a = 0) : v((a %= mod) < 0 ? a + mod : a) {}
    M& operator+=(M r) { if ((v += r.v) >= mod) v -= mod; return *this; }
    M& operator-=(M r) { if ((v += mod - r.v) >= mod) v -= mod; return *this; }
    M& operator*=(M r) { v = (uint64_t)v * r.v % mod; return *this; }
};

uint32_t add(M a, M b) { return (a += b).v; }
uint32_t mul(M a, M b) { return (a *= b).v; }
uint32_t sub(M a, M b) { return (a -= b).v; }

uint32_t po(M x, int n) {
    M res(1);
    while (n > 0) {
        res *= (n & 1 ? x : 1);
        x *= x; n /= 2;
    }
    return res.v;
}

const int maxn = 1e5 + 3;

int dp[101][maxn];

int get(int l, int r, int id) {
     if (l <= 0) return dp[id][r];
    return sub(dp[id][r], dp[id][l - 1]);
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    // base cases are important and should be carefully managed
    for (int i = 0; i <= a[1]; ++i) {
        dp[1][i] = 1;
    }

    for (int i = 2; i <= n; ++i) {
        dp[i][0] = 1;
        int val = a[i];
        for (int j = 1; j < maxn; ++j) {
            dp[i][j] = get(j - val, j, i - 1);
        }
        for (int j = 1; j < maxn; ++j) {
            dp[i][j] = add(dp[i][j], dp[i][j - 1]);
        }
    }
    // rep(i,1,n) rep(j,0,k) cout << dp[i][j] << " \n"[j == k];
    cout << dp[n][k] << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Data
{
    ll P;
    ll Y;
    ll i;
};
Data D[100005];
pll A[100005];

int main()
{
    ll N, M;
    cin >> N >> M;
    REP(i, M)
    {
        cin >> D[i].P >> D[i].Y;
        D[i].i = i;
    }
    sort(D, D + M, [](Data a, Data b) { return a.P == b.P ? a.Y < b.Y : a.P < b.P; });
    int num = 1;
    REP(i, M)
    {
        if (i == 0 || D[i].P != D[i - 1].P)
            num = 1;
        A[D[i].i].first = D[i].P;
        A[D[i].i].second = num++;
    }

    REP(i, M)
    {
        cout << std::setfill('0') << std::right << std::setw(6) << A[i].first;
        cout << std::setfill('0') << std::right << std::setw(6) << A[i].second;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    cin >> n >> m >> k;
    vi v(n);
    REP(i, n) {
        cin >> v[i];
    }
    sort(ALL(v));
    ll now = 0;

    while (1) {
        if (now >= n) {
            break;
        }
        bool f = false;
        ll np = v[now] + k;
        FOR(i, now + 1, now + m) {
            if (i >= v.size()) {
                break;
            }
            if (np >= v[i]) {
                continue;
            } else {
                now = i;
                f = true;
                break;
            }
        }
        if (!f) {
            now += m;
        }
        ans++;
    }
    cout << ans << Endl;
}

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

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  int tot = 1, ans = 0;
  while (tot < b) {
    tot += a - 1;
    ans++;
  }
  cout << ans << '\n';
  return 0;
}



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

int main(){
	int n; 
	long m, a[10000], b[10000];
	
	scanf(" %d %ld", &n, &m);
	for(int i=0; i<n; ++i) scanf(" %ld %ld", &a[i], &b[i]);

	long ans=m;

	for(int i=0; i<n; ++i){
		m+=a[i]-b[i];
		if(ans < m) ans=m;
		else if(m<0) {
			ans=0;
			break;
		}
	}		

	printf("%ld\n", ans);
	return 0;
}

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

int main()
{
	int n;cin>>n;
	string s;cin>>s;
	string o[100];
	for(int i=0;i<n;i++)cin>>o[i];
	int c=0;
	bool flag;
	for(int i=0;i<n;i++)
	{
		flag=false;
		for(int j=1;j*(s.length()-1)<o[i].length();j++)
		{
			for(int k=0;k+j*(s.length()-1)<o[i].length();k++)
			{
				string now="";
				for(int l=0;l<s.length();l++)
				{
					now+=o[i][j*l+k];
				}
				if(now==s)
				{
					c++;
					flag=true;
					break;
				}
			}
			if(flag)break;
		}
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3172
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int i;
        long a,min =1000000, max =-1000000, sum = 0;
        for (i = 0; i < n; i++) {
            a = sc.nextLong();
            if (a < min) {
                min = a;
            }
            if (a > max) {
                max = a;
            }
            {sum += a;}
            }
        System.out.println(min + " " + max + " " + sum);
        sc.close();
    }
}


Measured memory_bytes: 42424
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()
def factorization(n):
  res = []
  if n%2==0:
    res.append(2)
  for i in range(3,math.floor(n//2)+1,2):
    if n%i==0:
      c = 0
      for j in res:
        if i%j==0:
          c=1
      if c==0:
        res.append(i)
  if len(res)==0:
    res = [n]
  return res
def fact2(n):
  p = factorization(n)
  res = []
  for i in p:
    c=0
    z=n
    while 1:
      if z%i==0:
        c+=1
        z/=i
      else:
        break
    res.append([i,c])
  return res
def fact(n):#階乗
  ans = 1
  m=n
  for _i in range(n-1):
    ans*=m
    m-=1
  return ans
def comb(n,r):#コンビネーション
  if n<r:
    return 0
  l = min(r,n-r)
  m=n
  u=1
  for _i in range(l):
    u*=m
    m-=1
  return u//fact(l)
def combmod(n,r,mod):
  return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
  r=copyQueue(q)
  ans=[0]*r.qsize()
  for i in range(r.qsize()-1,-1,-1):
    ans[i] = r.get()
  print(ans)
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1]*n

  def find(self, x): # root
    if self.parents[x]<0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self,x,y):
    x = self.find(x)
    y = self.find(y)

    if x==y:
      return

    if self.parents[x]>self.parents[y]:
      x,y = y,x

    self.parents[x]+=self.parents[y]
    self.parents[y]=x

  def size(self,x):
    return -1*self.parents[self.find(x)]

  def same(self,x,y):
    return self.find(x)==self.find(y)

  def members(self,x): # much time
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i)==root]

  def roots(self):
    return [i for i,x in enumerate(self.parents) if x<0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
  x = 1
  zero = "0"*n
  ans = []
  ans.append([0]*n)
  for i in range(2**n-1):
    ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
    x+=1
  return ans;
def arrsSum(a1,a2):
  for i in range(len(a1)):
    a1[i]+=a2[i]
  return a1
def maxValue(a,b,v):
  v2 = v
  for i in range(v2,-1,-1):
    for j in range(v2//a+1): #j:aの個数
      k = i-a*j
      if k%b==0:
        return i
  return -1
def copyQueue(q):
  nq = queue.Queue()
  n = q.qsize()
  for i in range(n):
    x = q.get()
    q.put(x)
    nq.put(x)
  return nq
def get_sieve_of_eratosthenes(n):
  data = [2]
  #data = [0,0,0]
  for i in range(3,n+1,2):
    data.append(i)
    data.append(0)
  for i in range(len(data)):
    interval = data[i]
    if interval!=0:
      for j in range(i+interval,n-1,interval):
        data[j] = 0
  ans = [x for x in data if x!=0]
  #ans = data[:]
  return ans


a,b = readInts()

#print(a+b)
print(a*b)

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define LL long long
#define pii pair<int,int>
#define SZ(x)  (int)x.size()
#define all(x) x.begin(),x.end()

using namespace std;

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;}
LL powmod(LL a, LL b, LL MOD) {LL ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
const int N = 5e5 + 3;
const LL mod = 1e9 + 7;
int n,m,a[N];
int main() {
	ios::sync_with_stdio(false);
    cin>>n>>m;
    priority_queue<int>q;
    for(int i=1;i<=n;i++)cin>>a[i],q.push(a[i]);
    while(!q.empty()){
        if(q.top()==0)return cout<<0,0;
        int x=q.top();
        q.pop();
        q.push(x/2);
        if(--m==0)break;
    }
    LL ans=0;
    while(!q.empty()){
        ans+=q.top();
        q.pop();
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define _GLIBCXX_DEBUG
#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++)
#define chmin(x, y) x = min(x, y)
typedef long long ll;
const int INF = 1001001001;
const int mod = 1000000007;

void dfs(int x, int y) {}

int main() {
    vector<string> v(3);
    cin >> v[0] >> v[1] >> v[2];
    cout << v[0][0] << v[1][0] << v[2][0] << endl;
}

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

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

const double PI = 3.14159265358979323846;
const int mod = 1e9+7;
// int 1e9+7 double 1e-12 long long 1e18

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main()
{
  string S;
  ll w;
  cin >> S >> w;
  ll i = 0;
  while (i < S.length()) {
    cout << S[i];
    i += w;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

n = int(input())

t = 0
for i in range(1, n // 2 + 1):
    add = n // i
    if n % i == 0:
        add -= 1
    t += add
t += (n - i - 1)
print(t)


Measured memory_bytes: 9156
//abc116_c.cpp
//Sat Feb  2 17:17:35 2019

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int ans = 0;
	while (1){
		int start = -1;
		int end = -1;
		int flag = 0;
		for (int i=0;i<n;i++){
			if (a[i] > 0){
				start = i;
				flag = 1;
				break;
			}
		}

		if (start == n-1){
			end = n;
		}else {
			for (int i=start+1;i<n;i++){
				if (a[i] == 0){
					end = i;
					break;
				}else if (i==n-1){
					end = n;
				}
			}
		}

		if (start == -1 || end == -1){
			break;
		}

//		cout << start << " " << end << endl;

		for (int i=start;i<end;i++){
			a[i]--;
		}
		ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	map<int, int> d;
	for (int i = 0; i < N; ++i) {
		int x;
		cin >> x;
		++d[x];
	}
	int ans = 0;
	for (pair<int, int> i : d) {
		if (i.second >= i.first) ans += i.second - i.first;
		else ans += i.second;
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

// n(>=0)以下のxで割り切れるものの個数
ll f(ll n, ll x) {
    if (n < 0) return 0;
    return n / x + 1;
}

int main() {
    ll a, b, x;
    cin >> a >> b >> x;

    ll ans = f(b, x) - f(a - 1, x);
    cout << ans << endl;
}


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

using namespace std;

int main(){
	int n;
	while(true){
		cin >> n;
		if(n==0){
			break;
		}

		set<int> s[100];
		
		for(int i=0;i<n;i++){
			int buf;
			cin >> buf;
			for(int j=0;j<buf;j++){
				int buf2;
				cin >> buf2;
				s[i].insert(buf2);
			}
		}

		int k;
		cin >> k;
		int kk[100];
		for(int i=0;i<k;i++){
			int buf;
			cin >> kk[i];
		}

		int ans = -1, cnt = 0;
		
		for(int i=0;i<n;i++){
			bool ansflag = true;
			for(int j=0;j<k;j++){
				ansflag &= s[i].count(kk[j]); 
			}
			if(ansflag) {
				ans = i+1;
				cnt++;
			}
		}
		if(cnt == 1 && ans != -1){
			cout << ans << endl;
		}else{
			cout << -1 << endl;
		}
		
	}
}

Measured memory_bytes: 1108
#include <iostream>


int main(void){

	char mass[2][3];

	for(int i = 0; i < 2; i++){
		for(int j = 0; j < 3; j++){
			std::cin >> mass[i][j];
		}
	}

	bool flag = true;
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < 3; j++){
			if(mass[i][j] != mass[1 - i][2 - j]){
				flag = false;
				break;
			}
		}
	}

	std::cout << ((flag) ? "YES" : "NO") << std::endl;

	return 0;
}

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

int main() {
	long long A,B,K;
    cin >> A >> B >> K;
    if(A >= K){
      cout << A-K <<" "<< B << endl;
    }
    else if(A+B >= K){
      cout << 0 <<" "<<A+B-K<<endl;
    }
    else {
      cout <<0<<" "<<0<<endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif
const int N = 2e3 + 5;
vector<int>adj[N];
int dis[N];
map<int,int>m;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,u,v;
    cin>>n>>u>>v;
    for(int i=1;i<=n-1;i++){
        adj[i].push_back(i+1);
        adj[i+1].push_back(i);
    }
    adj[u].push_back(v);
    adj[v].push_back(u);
    for(int id=1;id<=n;id++){
        for(int i=0;i<=n;i++){
            dis[i] = 1e18;
        }
        dis[id] = 0;
        queue<int>q;
        q.push(id);
        while(!q.empty()){
            auto it = q.front();
            q.pop();
            for(auto x:adj[it]){
                if(dis[x] == 1e18){
                    dis[x] = 1 + dis[it];
                    q.push(x);
                }
            }
        }
        for(int i=1;i<=n;i++){
            m[dis[i]]++;
        }
        // break;
    }
    for(int i=1;i<=n-1;i++){
        cout<<m[i] / 2<<endl;
    }
    
    return 0;
    
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

  cout << min(b / a, c) << endl;

  return 0;
}


Measured memory_bytes: 764
module DoublyLinkedList = struct
  type t = {
    mutable data : int;
    mutable next : t;
    mutable prev : t;
  }

  let make () =
    let rec head = { data = 0; next = head; prev = head } in
    head

  let insert data head =
    let x = { data = data; next = head.next; prev = head } in
    head.next.prev <- x;
    head.next <- x

  let delete x =
    x.next.prev <- x.prev;
    x.prev.next <- x.next

  let delete_first head = delete head.next

  let delete_last head = delete head.prev

  let delete_node data head =
    let rec doit ite =
      if ite == head then None
      else if ite.data = data then Some ite
      else doit ite.next
    in
    match doit head.next with
    | None -> ()
    | Some ite -> delete ite

  let iteri head ~f =
    let rec doit i ite =
      if ite != head then (f i ite.data; doit (i + 1) ite.next)
    in
    doit 0 head.next
end

module L = DoublyLinkedList

let split str delim =
  let rec doit s acc =
    match
      try Some (String.rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s1 (s2 :: acc)
  in
  doit str []

let () =
  let n = read_int () in
  let head = L.make () in
  let rec read i =
    if i < n then begin
      match split (read_line ()) ' ' with
      | ["insert"; n] -> (L.insert (int_of_string n) head; read (i + 1))
      | ["delete"; n] -> (L.delete_node (int_of_string n) head; read (i + 1))
      | ["deleteFirst"] -> (L.delete_first head; read (i + 1))
      | ["deleteLast"] -> (L.delete_last head; read (i + 1))
      | _ -> exit 1
    end
  in
  read 0;
  L.iteri head ~f:(fun i n -> if i <> 0 then print_string " "; print_int n);
  print_newline ()

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

int main(){
	int m,n;
	cin>>m>>n;
	string s[m];
	for(int i=0;i<m;i++){
		cin>>s[i];
	}
	for(int i=0;i<=n+1;i++)
		cout<<"#";
	cout<<endl;
	for(int i=0;i<m;i++){
		cout<<"#";
		cout<<s[i];
		cout<<"#\n";
	}
	for(int i=0;i<=n+1;i++)
		cout<<"#";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

Measured memory_bytes: 768
#include <stdio.h>
#include <limits.h>

int main(){
	int line=0;
	scanf("%d", &line);
	long num[line];

	for(int i=0; i<line; i++){
		scanf("%ld",&num[i]);
	}

	long max = LONG_MIN;
	int min = num[0];
	for(int i=1;i <line;i++){
		if(num[i]-min>max){
			max = num[i]-min;
		}
		if(num[i] < min){
			min = num[i];
		}
	}
	printf("%ld\n", max);
	return 0;
}


Measured memory_bytes: 3280
n = int(input())
a_list = list(map(int, input().split()))
mountain_rain = [0] * n

first_mountain = 0
for index in range(len(a_list)):
    if index % 2 == 0:
        first_mountain += a_list[index]
    else:
        first_mountain -= a_list[index]

mountain_rain[0] = first_mountain
for index in range(1, n):
    mountain_rain[index] = (a_list[index-1] - mountain_rain[index-1] // 2) * 2

ret = " ".join(map(str, mountain_rain))
print(ret)

Measured memory_bytes: 19096
n = gets.to_i
bi = []
4.times do
  bi << Array.new(3).map{Array.new(10,0)}
end
n.times do
  b,f,r,v = gets.split(" ").map(&:to_i)
  bi[b-1][f-1][r-1] += v
end
4.times do |i|
  3.times do |j|
    print " "
    puts bi[i][j].join(" ")
    puts "#"*20 if (j == 2)&&(i < 3)
  end
end

Measured memory_bytes: 8744
N = int(input())
A = list(map(int, input().split()))

def Sum (A):
    sum = 0
    for i in range(len(A)):
        sum += A[i]
    return sum


def Comper (A , sum):
    xx = 0
    aa = -1
    flag = 0
    for i in range(len(A)):
        xx +=A[i]
        if 0 < sum -2*xx:
            aa = sum - 2*xx
        elif flag == 0:
            if 0<i:
                ans1 = aa
            else:
                ans1 = -1
            ans2 = 2*xx - sum
            if ans1 > ans2 or ans1 == -1:
                return ans2
            else:
                return ans1
            flag = 1

ans = Comper (A , Sum(A))

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n;
  cin>>n;
  if(n%2==1){
    COUT(0);
  }
  else{
    n/=2;
    ll ans=0;
    while(n){
      ans+=n/5;
      n/=5;
    }
    COUT(ans);
  }
}

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

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final String[] line = in.nextLine().split(" ");
        final int n = Integer.parseInt(line[0]);
        final int k = Integer.parseInt(line[1]);
        final int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        in.nextLine();
        int low = 1, high = (int) 1e9;
        while (low < high) {
            final int mid = low + high >>> 1;
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                cnt += (arr[i] - 1) / mid;
            }
            if (k < cnt) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        System.out.println(low);
    }
}


Measured memory_bytes: 59820
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    if(n==1||n==2||n==3||n==5||n==6||n==9||n==10||n==13||n==17)
      System.out.println("No");
    else
      System.out.println("Yes");
  }
}

Measured memory_bytes: 23252
import java.io.BufferedReader;
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		if(N%500 <= A) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21716
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

const int N = 1e5 + 5;

int n, m, bin[N], tot1, tot2;
struct Data {
	int val, cnt;
} a[N], b[N];

void solve(std::vector<int> v, Data *a, int &tot) {
	memset(bin, 0, sizeof(bin));
	for (int x: v) bin[x]++;
	for (int i = 1; i <= 100000; i++) {
		a[++tot] = Data{i, bin[i]};
	}
}
int main() {
	scanf("%d", &n);
	m = n >> 1;
	std::vector<int> v1, v2;
	for (int i = 1; i <= n; i++) {
		int x;
		scanf("%d", &x);
		if (i & 1) v1.emplace_back(x);
		else v2.emplace_back(x);
	}
	solve(v1, a, tot1);
	solve(v2, b, tot2);
	std::sort(b + 1, b + tot2 + 1, [](Data a, Data b) {
		return a.cnt > b.cnt;
	});
	int ans = n;
	for (int i = 1; i <= tot1; i++) {
		int val1 = a[i].val, del1 = m - a[i].cnt, del2 = 0;
		if (b[1].val == val1) del2 = m - b[2].cnt;
		else del2 = m - b[1].cnt;
		ans = std::min(ans, del1 + del2);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2812
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#include <time.h> 

//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define c1 __builtin_popcount
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPER
vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
int n;
cin>>n;
vector<int> v(n);
int arr[60] = {};
int mod = 1e9+7;
FOR(i,0,n) cin>>v[i];
bitset<60> a;
FOR(i,0,n) {
    a = v[i];
    FOR(j,0,60) if(a[j]) arr[j]++;
}
int ans = 0;
 clock_t t; 
    t = clock(); 
FOR(i,0,n-1) {
    a= v[i];
    FOR(j,0,60) if(a[j]) arr[j]--;
    // FOR(j,0,60) cout<<arr[j]<<" ";
    // cout<<endl;
    int base = 1;
    FOR(j,0,60){
        if(a[j]) ans = (ans +  ((n-i-1-arr[j])*base)%mod);
        else ans= (ans+(arr[j]*base))%mod;
        if(ans >= mod) ans-=mod;
        base*=2;
        base%=mod;
    }
}
   t = clock() - t; 
    double time_taken = ((double)t)/CLOCKS_PER_SEC; // in seconds 
  
    // cout<<endl<<fixed<<setprecision(10)<<time_taken<<endl;

cout<<ans;
// bitset<20> a = 4;
// FOR(i,0,20) cout<<a[i];
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 2560
import numpy as np
N = int(input())
L = [list(map(int, input().split())) for i in range(N)]
dp = np.zeros((N, 3), dtype=int)

for i in range(N):
    dp[i][0] = L[0][0] if i == 0 else max(dp[i-1][1]+L[i][0], dp[i-1][2]+L[i][0])
    dp[i][1] = L[0][1] if i == 0 else max(dp[i-1][0]+L[i][1], dp[i-1][2]+L[i][1])
    dp[i][2] = L[0][2] if i == 0 else max(dp[i-1][0]+L[i][2], dp[i-1][1]+L[i][2])

print(max(dp[-1]))

Measured memory_bytes: 43728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 0;

    rep(i, N - 2)
    {
        if (S[i] == 'A')
        {
            if (S[i + 1] == 'B')
            {
                if (S[i + 2] == 'C')
                {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp

stack = []
s.chars.each do |ch|
  if ch == "("
    stack << "("
  elsif ch == ")"
    if stack[-1] == "("
      stack.pop
    else
      stack << ch
    end
  end
end

ns = stack.join
lb = ns.count("(")
rb = ns.count(")")
puts "(" * rb + s + ")" * lb


Measured memory_bytes: 3836
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ExplodingFreeze
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
const int MOD=1e9+7;
using pii=std::pair<int,int>;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

using namespace std;

int n,t,tp,x,xp,y,yp;
class CTraveling {
public:
	void solve(std::istream& in, std::ostream& out) {
		in >> n;
		tp=xp=yp=0;
		f(i,1,n+1)
		{
			in >> t >> x >> y;
			int diff=(t-tp)-(abs(x-xp)+abs(y-yp));
			if(diff<0||diff&1)
			{
				out << "No\n";
				return;
			}
			tp=t;
			xp=x;
			yp=y;
		}
		out << "Yes\n";

	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	CTraveling solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import math
from decimal import Decimal
A,B,X = map(Decimal, input().split())
s = X / A

if s == A*B:
    print(0)
    exit()
if s > A * B / 2:
    Bu = 2 * s / A - B
    s -= A*Bu
    B -= Bu

A2 = 2 * s / B
print(math.degrees(math.atan(B/(A2))))


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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}


int main(int argc, char const* argv[])
{
    int n;
    cin >> n;

    LL x2=0, x1=1, x0=2;
    if (n == 0) {
        cout << 2 << endl;
    }else if (n == 1){
        cout << 1 << endl;
    }else{
        for (int i = 0; i < n-1; i++) {
            x2 = x1 + x0;
            x0 = x1;
            x1 = x2;
        }
        cout << x2 << endl;
    }


    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


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

using namespace std;

int power(int x, int n) {
  int res = 1;
  while (n > 0) {
    if (n & 1) res *= x;
    x *= x;
    n >>= 1;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;

  double res = 0;
  for (int i = 1; i < N + 1; i++) {
    int x = i, cnt = 0;
    while (x < K) {
      x *= 2;
      cnt++;
    }
    res += 1.0 / power(2, cnt);
  }

  cout << fixed << setprecision(10) << res / N << '\n';
  return 0;
}


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

#define mem(arr, i) fill(arr, arr + sizeof(arr), i)
#define MEM(arr, i) memset(arr, i, sizeof(arr))
#define Push push_back
#define Pair make_pair
#define ALL(x) x.begin(), x.end()
#define X first
#define Y second
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv(maxN+5, 1);
vcL fac(maxN+5, 1);

void ADD(lli &x, lli y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = (x % mod + mod) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if (e & 1) MUL(ans, b);
		MUL(b, b);
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow(n, mod - 2);
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[i - 1] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if (a < b) return 0;

	MUL(ans, inv[fac[a - b]]);
	MUL(ans, inv[fac[b]]);
	MUL(ans, fac[a]);

	return ans;
}

lli Lucas(lli n, lli m) {
	if (m == 0) return 1;
	return cm(n % mod, m % mod) * Lucas(n / mod, m / mod) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas(n, m);
}

/// coding area ///

const lli maxn = 1E5;

void precal() {

	return;
}

void solve() {
	lli n;
	cin >> n;
	
	vcL a(n + 1), b(n);
	for (auto &x : a) cin >> x;
	for (auto &x : b) cin >> x;
	
	lli beat = 0;
	for (int i = 0; i < n; ++i) {
		if (a[i] > b[i]) {
			a[i] -= b[i];
			beat += b[i];
			b[i] = 0;
		}
		else {
			b[i] -= a[i];
			beat += a[i];
			a[i] = 0;
			if (a[i + 1] > b[i]) {
				a[i + 1] -= b[i];
				beat += b[i];
				b[i] = 0;
			}
			else {
				b[i] -= a[i + 1];
				beat += a[i + 1];
				a[i + 1] = 0;
			}
		}
	}
	
	cout << beat << '\n';
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}



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

int main(){
	int i,k,l,n,m;
	int a[100][100];
	int j[100];
	cin >> n;
	for(m=0;m<100;m++){
		for(l=0;l<100;l++){
			a[m][l]=0;//初期化
		}
	}

	for( m=0 ; m<n ; m++ ){
		cin >> i >> k ;
		for(l=0;l<k;l++){
			cin >>j[l];
			a[i-1][j[l]-1] = 1;//情報読み込みaij→a(i-1)(j-1)
		}
	}
	for( m=0 ; m<n ; m++ ){
		for(l=0;l<n-1;l++){
			cout<<a[m][l]<<" ";
		}
			cout<<a[m][n-1]<<endl;
	}
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;

int main(){
	int a,b; cin>>a>>b;
	if(a+b==15) co("+");
	else if(a*b==15) co("*");
	else co("x");
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	res := map[string]int{}
	for i := 0; i < n; i++ {
		var a string
		fmt.Scan(&a)
		res[a]++
	}
	fmt.Printf("AC x %v\n", res["AC"])
	fmt.Printf("WA x %v\n", res["WA"])
	fmt.Printf("TLE x %v\n", res["TLE"])
	fmt.Printf("RE x %v\n", res["RE"])
}

Measured memory_bytes: 6336
let th li n = List.nth li n
let () =
  let sl = Str.split (Str.regexp " ") (read_line ()) in
  let il = List.map int_of_string sl in
  let (w, h, x, y, r) = (th il 0), (th il 1), (th il 2), (th il 3), (th il 4) in
  let xres = (0 <= x+r && x+r <= w) && (0 <= x-r && x-r <= w) in
  let yres = (0 <= y+r && y+r <= h) && (0 <= y-r && y-r <= h) in
  Printf.printf "%s\n" (if xres && yres then "Yes" else "No")

Measured memory_bytes: 2212
import sys
for e in sys.stdin:
 e=list(map(float,e.split(',')))
 print(['YES','NO'][sum((e[i]-e[(2+i)%8])*(e[(5+i)%8]-e[(3+i)%8])-(e[1+i]-e[(3+i)%8])*(e[(4+i)%8]-e[(2+i)%8])>0 for i in range(0,8,2))%4>0])


Measured memory_bytes: 5588
#$N=<>;$-=$-=$-$i- --$N-($i+=/W/)for<>=~/./g;print$-$i
($N,$_)=<>;$-=$-=$-(/E/?--$N:$N++)for/./g;print$-y/W//
#$N=-<>;$-=$-=++$N+$-$i-($i+=/W/)for<>=~/./g;print$-$i


Measured memory_bytes: 26620
<?php
/*
# 整数の入力
fscanf(STDIN, "%d", $a);
# スペース区切りの整数の入力
fscanf(STDIN, "%d %d", $b, $c);
# 文字列の入力
fscanf(STDIN, "%s", $s);
*/
fscanf(STDIN, "%d", $a);
fscanf(STDIN, "%d", $b);
fscanf(STDIN, "%d", $c);
fscanf(STDIN, "%d", $d);
fscanf(STDIN, "%d", $e);
fscanf(STDIN, "%d", $k);

$arr = [$a, $b, $c, $d, $e];

for ($i = 0; $i <= 3; $i++) {
    for ($j = $i + 1; $j <= 4; $j++) {
        if ($arr[$j] - $arr[$i] > $k) {
            echo ":(";
            exit;
        }
    }
}
echo "Yay!";

?>


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

 using namespace std;

 int main() {
   int H, W, N;
   cin >> H >> W >> N;

   if (N % max(H, W) == 0) cout << N / max(H, W) << endl;
   else cout << N / max(H, W) + 1 << endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define yes(i) cout<<(i?"yes":"no")<<endl
using namespace std;
int gcd(int a,int b){
	if(b==0){
		return a;
	}else{
		return gcd(b,a%b);
	}
}
int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	int ans=0;
	vector<int> p,q;
	for(int i=1;i*i<=a[0];i++){
		if(a[0]%i==0){
			p.push_back(i);
			p.push_back(a[0]/i);
		}
	}
	for(int i=1;i*i<=a[1];i++){
		if(a[1]%i==0){
			q.push_back(i);
			q.push_back(a[1]/i);
		}
	}
	for(int i=0;i<p.size();i++){
		int cnt=0;
		for(int j=0;j<n;j++){
			if(a[j]%p[i]!=0){
				cnt++;
			}
		}
		if(cnt<=1){
			ans=max(ans,p[i]);
		}
	}
	for(int i=0;i<q.size();i++){
		int cnt=0;
		for(int j=0;j<n;j++){
			if(a[j]%q[i]!=0){
				cnt++;
			}
		}
		if(cnt<=1){
			ans=max(ans,q[i]);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640