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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ll long long
using namespace std;


int main() {
  char a;
  cin >> a;
  char moji;

  for(moji = 'A'; moji <= 'Z'; ++moji) {
    if (moji == a) {
      cout << 'A' << endl;
      return 0;
    }
  }
  cout << 'a' << endl;

}



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


template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) { }
	ModInt(signed sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }

	ModInt inverse() const {
		signed a = x, b = MOD, u = 1, v = 0;
		while (b) {
			signed t = a / b;
			a -= t * b; std::swap(a, b);
			u -= t * v; std::swap(u, v);
		}
		if (u < 0) u += Mod;
		ModInt res; res.x = (unsigned)u;
		return res;
	}

	bool operator==(ModInt that) const { return x == that.x; }
	bool operator!=(ModInt that) const { return x != that.x; }
	ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
	ModInt<MOD> r = 1;
	while (k) {
		if (k & 1) r *= a;
		a *= a;
		k >>= 1;
	}
	return r;
}
typedef ModInt<1000000007> mint;

vector<mint> fact, factinv;
void nCr_computeFactinv(int N) {
	N = min(N, mint::Mod - 1);
	fact.resize(N + 1); factinv.resize(N + 1);
	fact[0] = 1;
	for (int i = 1; i <= N; ++ i)
		fact[i] = fact[i - 1] * i;
	factinv[N] = fact[N].inverse();
	for (int i = N; i >= 1; i --) factinv[i - 1] = factinv[i] * i;
}
mint nCr(int n, int r) {
	if (n >= mint::Mod)
		return nCr(n % mint::Mod, r % mint::Mod) * nCr(n / mint::Mod, r / mint::Mod);
	return r > n ? 0 : fact[n] * factinv[n - r] * factinv[r];
}

int main() {
	int N;
	while (~scanf("%d", &N)) {
		if (N == 2) {
			puts("1");
			continue;
		}
		nCr_computeFactinv(N);
		mint ans = fact[N - 1] * (N - 1);
		for (int i = 1; i <= N - 3; ++ i) {
			ans -= nCr(N - 3 - i + 1, i) * fact[i] * fact[N - 1 - i];
		}
		printf("%d\n", ans.get());
	}
}


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

int main() {
    char a, b;
    cin >> a >> b;
    if(a == 'H' && b == 'H'){
        cout << "H" << "\n";
    } else if(a == 'H' && b == 'D') {
        cout << "D" << "\n";
    } else if(a == 'D' && b == 'D'){
        cout << "H" << "\n";
    } else if(a == 'D' && b == 'H'){
        cout << "D" << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace MyProgram{
    class AtCoder{
        static void Main(string[] args){
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            int N = input[0];
            int K = input[1];
            long[] h = new long[N];
            for(var i=0;i<N;i++){
                h[i] = long.Parse(Console.ReadLine());
            }
            Array.Sort(h);
            long temp=100000000000000;
            for(var i=0;i<=N-K;i++){
                temp = h[K+i-1] - h[i]<temp?h[K+i-1] -h[i]:temp;
            }
            Console.WriteLine(temp);
        }
    } 
}

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

int main()
{
    ll n,m,i,k;
    cin>>k>>n;
    ll arr[n];
    for(i=0;i<n;i++) cin>>arr[i];
    ll ans=arr[n-1]-arr[0];
    for(i=1;i<n;i++) ans=min(ans,arr[i-1]+k-arr[i]);
    cout<<ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
signed main() {
  int N; cin>>N;
  // not good
  for (int i = 0; i < N; i++) {
    int x, y, b, p;
    cin >> x >> y >> b >> p;
    int price = x*b+y*p;
    if (b < 5 && p >= 2) {
      price = min((int)((x*5+y*p)*0.8), price);
    } else if (b >= 5 && p < 2) {
      price = min((int)((x*b+y*2)*0.8), price);
    } else {
      price = (b >= 5 && p >= 2) ? price*0.8 : price;
    }
    cout << price << endl;
  }
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define dbV(arr) cout << #arr << "=[ "; \
for(auto i:arr) cout << i << " "; cout << "]\n";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repF(i,a,n) for(int i = (a); i <= (n); ++i)
#define repB(i,a,n) for(int i = (a); i >= (n); --i)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define umii unordered_map<int,int>
#define umll unordered_map<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define seti set<int>
#define setl set<ll>
#define pb push_back
#define F first
#define S second
#define MOD 1000000007
#define all(z) z.begin(),z.end()
using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m; cin >> n >> m;
	vi gr[n + 1];
	rep(i, m) {
		int u, v; cin >> u >> v;
		gr[u].pb(v);
	}
	int dp[n + 1]; memset(dp, -1, sizeof(dp));
	function<int(int)> solve = [&](int src) {
		if (dp[src] != -1) return dp[src];
		if (gr[src].size() == 0) return dp[src] = 0;
		int ans = 0;
		for (auto v : gr[src]) {
			ans = max(ans, 1 + solve(v));
		}
		return dp[src] = ans;
	};
	int ans = 0;
	repF(i, 1, n) {
		ans = max(ans, solve(i));
	}
	cout << ans << endl;
	return 0;
}

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


int main() {
  vector<int> v(3);

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

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

  cout << (v[0] * v[1]) / 2 << endl;
}


Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

const int MAX_HW = 90000;
const int LOG_HW = 20;
int bx[MAX_HW + 10], by[MAX_HW + 10];
int nxt[MAX_HW + 10][LOG_HW];

signed main() {
    int H, W, D; cin >> H >> W >> D;
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            int val; scanf("%lld", &val);
            bx[val] = i, by[val] = j;
        }
    }

    memset(nxt, -1, sizeof(nxt));
    for(int val=1; val<=H*W; val++) {
        int to = val + D;
        if(to > H*W) continue;
        int x_diff = abs(bx[val] - bx[to]);
        int y_diff = abs(by[val] - by[to]);
        nxt[val][0] = x_diff + y_diff;
        // printf("nxt[%lld][%lld] = %lld\n", val, 0LL, nxt[val][0]);
    }

    for(int k=1; k<LOG_HW; k++) {
        for(int i=1; i<=H*W; i++) {
            if(i + D * (1 << k) > H*W) continue;
            nxt[i][k] = nxt[i][k-1] + nxt[i + D * (1 << (k-1))][k-1];
            // printf("nxt[%lld][%lld] = %lld\n", i, k, nxt[i][k]);
        }
    }

    int Q; scanf("%lld", &Q);
    while(Q--) {
        int L, R; scanf("%lld%lld", &L, &R);
        int step = (R - L) / D;

        int ans = 0, idx = L;
        for(int i=0; i<LOG_HW; i++) {
            if(step >> i & 1) {
                ans += nxt[idx][i];
                idx += D * (1 << i);
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  string s, t; cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<int>());
  //cout << "s " << s << endl;
  //cout << "t " << t << endl;
  if (s < t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int N,T;
int A[123456];

int main(){

cin>>N>>T; 

for(int i=0; i<N; i++) scanf("%d",&A[i]);

int Max=0; int r=A[0],cnt=0;
for(int i=0; i<N; i++){
    if(A[i]>r){
        if(A[i]-r>Max){
            Max=A[i]-r;
            cnt=0;
        }
        if(A[i]-r==Max) cnt++;
    }
    if(A[i]<r) r=A[i];
}

cout<<cnt<<endl;

return 0;
 
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string ch;
    cin>>ch;
    if(ch[0]=='7' || ch[1]=='7' || ch[2]=='7')
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ld s;
	cin >> s;
	s = s/3;
	s = s*s*s;
	cout << setprecision(20) << s << "\n";
	return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)

ans = 0

for bit in range(1 << (n - 1)):
    # 各場合で式 f を生成する
    f = s[0]

    for i in range(n - 1):
        if bit & (1 << i):
            # フラグが立っているならば "+" を式の末尾に追加する
            f += "+"
        f += s[i + 1]

    ans += eval(f)

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#define fi        first
#define se        second
#define pb        push_back
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
typedef pair<ll,int>  PLI;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+7;
inline void solve()
{
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c; 

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




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int r = int.Parse(ReadLine());

            WriteLine(3 * Pow(r,2));

            
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
struct __test {} test;
using namespace std;
template <typename T>const __test &operator<<(const __test& d,
const T& v) {return cerr << "\033[31m" << v << "\033[0m",d;}
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

const int N = 1e5+5;
int n,m,ct[N];
bool here[N]={};

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	fill(ct,ct+n+1,1);
	here[1] = 1;
	while(m--) {
		int x,y;
		cin >> x >> y;
		if(here[x]) {
			if(ct[x] == 1)
				here[x] = false;
			here[y] = true;
		}
		--ct[x];
		++ct[y];
	}
	int ans=0;
	for(int i = 1; i <= n; ++i)
		ans += here[i];
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> sw(n);
    for(int i=0;i<n;i++) cin>>sw.at(i);
    int bot=1;
    int cnt=0;
    
    while(bot!=2){
        cnt++;
        bot=sw.at(bot-1);
        
        if(cnt>n){
            cnt=-1;
            break;
        }
    }
    
    cout<<cnt<<endl;
    
    return 0;
}

Measured memory_bytes: 768
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

"""
N日間のうちK日選んで働く
働いたらそれからC日間は働かない
Sにxがついていたら働かない

oの付いてる日のみ働く
全ての通りを求めてみよう

N, K, C = 11, 3, 2
S = ooxxxoxxxoo の時
働けるのは[1, 2, 6, 10, 11]日目
ここから3つ以上間が空く条件で3つ選ぶと条件を満たす
全ての通りでi日目に働く必要がある

A = [1, 2, 5, 7, 11, 13, 16]
M = 4
C = 3

for bit in range(1 << len(A)):
    cnt = []
    for i in range(len(A)):
        if bit & (1 << i):
            cnt.append(A[i])
    if len(cnt) == 4:
        for i in range(1, len(cnt)):
            if cnt[i] - cnt[i - 1] <= C:
                break
        else:
            print(cnt)

# python index.py
[1, 5, 11, 16]
[1, 7, 11, 16]
[2, 7, 11, 16]

A = [1, 2, 5, 10, 24]
M = 3
C = 2
[1, 5, 10]
[2, 5, 10]
[1, 5, 24]
[2, 5, 24]
[1, 10, 24]
[2, 10, 24]
[5, 10, 24]
[1, 5, 10, 24] M + 1回以上ジャンプできる場合には答えが[]になる
A[0]から頑張ってもM回しかジャンプできない

間がC + 1以上離れたM個の集合はどのように求める？
必ず働く日の特性は？
動かすと？
場所は固定？
"""
# N, K, C = getNM()
# S = getN()

N, K, C = getNM()
S = input()

# i回目に選べる要素の上限と下限を比べる
place = []
for i in range(N):
    if S[i] == 'o':
        place.append(i)

# 下限 出来るだけ前の仕事を選べるように
fore = [place[0]]
for i in place[1:]:
    if i - fore[-1] > C:
        fore.append(i)

# 上限 出来るだけ後ろの仕事を選ぶように
back = deque([])
back.append(place[-1])
for i in place[::-1]:
    if back[0] - i > C:
        back.appendleft(i)
back = list(back)

if len(fore) != K:
    print()
    exit()

ans = []
for a, b in zip(fore, back):
    if a == b:
        ans.append(a + 1)

for i in ans:
    print(i)


"""
fore = [0] * N
if S[0] == 'o':
    fore[0] = 1

for i in range(1, N):
    fore[i] = fore[i - 1]
    if S[i] == 'o' and i - C - 1 >= 0:
        fore[i] = max(fore[i], fore[i - C - 1] + 1)

back = [float('inf')] * N
ma = max(fore)
if S[N - 1] == 'o':
    back[N - 1] = ma

for i in range(N - 2, -1, -1):
    back[i] = min(ma, back[i + 1])
    if S[i] == 'o' and i + C + 1 < N:
        back[i] = min(back[i], back[i + C + 1] - 1)
print(back)
"""

Measured memory_bytes: 120860
//https://atcoder.jp/contests/dwacon5th-prelims/tasks/dwacon5th_prelims_e
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};

// aとbの最大公約数
// O(log (a+b) )
LL gcd(LL a,LL b){
    return (b==0)?a:gcd(b,a%b);
}
constexpr int mod = 998244353;
LL a[112345];
int main(){
    int N;
    cin>>N;
    for(int i:range(N))cin>>a[i];
    sort(a,a+N);
    LL ret=1;
    for(int i:range(N)){
        ret=ret*gcd(a[i],i)%mod;
    }
    cout<<ret<<endl;
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int K;
  cin >> K;
  queue<int64_t> que;
  for (int i = 1; i < 10; i++) {
    que.push(i);
  }
  while (K > 1) {
    auto x = que.front();
    que.pop();
    K--;
    for (int i = 0; i < 10; i++) {
      if (abs((x % 10) - i) <= 1) {
        que.push(x * 10 + i);
      }
    }
  }
  cout << que.front() << '\n';
  return 0;
}


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

namespace ABC133D
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long[] X = new long[N];
            long[] A = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

            long S = A.Sum();
            long subs = 0;
            for (int i = 1; i < N-1; i+=2)
            {
                subs += A[i];
            }
            X[0] = S - 2 * subs;
            Console.WriteLine(X[0]);
            for (int i = 1; i < N; i++)
            {
                X[i] = 2 * A[i - 1] - X[i - 1];
                Console.WriteLine(X[i]);
            }
        }
    }
}


Measured memory_bytes: 32092
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

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

	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	int sum=0,ma=0;
	rep(i,n){
		sum+=in[i];
		cmax(ma,in[i]);
	}
	sum-=ma;
	if(ma<sum)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(auto i=(a);i<(b);i++)
#define per(i,a,b) for(auto i=(a);i>=(b);i--)
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define int_inf 0x3f3f3f3f
#define int_max 2147483647
#define ll_max 9223372036854775807
#define ull_max 18446744073709551615
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lowbit(x) (x)&(-x)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eps 1e-8
#define all(v) (v.begin(),v.end())
#define db double
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const double pi=acos(-1.0);
const double inf = 1e100;
template<class T>
inline T read()
{
	T x=0,f=1;char s=getchar();
	while(s<'0'||s>'9') {if(s=='-')f=-1;s=getchar();};
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();};
	return x*f;
}
template<typename T>
inline void wri(T x)
{
	if(x<0){x=-x;putchar('-');};
	if(x/10) wri(x/10);
	putchar(x%10+48);
}
template<typename T>
inline void print(T x,char s)
{
	wri(x);
	putchar(s);
}
template<typename T>
T gcd(T a,T b)
{
	return b==0?a:gcd(b,a%b);
}
//关闭流同步就不能手写读入优化啦
ll n;
ll cnt=26ll,m;
vector<ll>r;
ll k;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>n;
    while(n>=cnt){
    	n-=cnt;
    	m++;
    	cnt*=26;
	}
	if(n==0){
		rep(i,1,m+1) cout<<'z';
	}
	else{
		n--;
		while(n){
	    	r.pb(n%26);
	    	n/=26;
		}
		int len=r.size();
		int delta=m+1-len;
		rep(i,1,delta+1) cout<<'a';
		for(int i=r.size()-1;i>=0;i--){
			cout<<char(r[i]+'a');
		}
	}
   
    return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; for(auto v : V) os << v << " "; return os << "]"; }
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; for(auto s:S) os<<s<<" ";return os<<"}"; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) { return os << "(" << P.first << "," << P.second << ")";}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) { os << "{ "; for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") "; return os<<"}"; }
#ifdef LMAO
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | "; __f(comma+1, args...); }
#else
    #define trace(...) 42
#endif
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
#define all(x) x.begin(), x.end()
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;    
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)   
/*****************start************/
// int binpow(int a, int b, int mod)
// {
//     int res=1;
//     while(b>0)
//     {
//         if(b&1)
//         {
//             res = (res*1ll*a)%mod;
//         }
//         a = (a*1ll*a)%mod;
//         b>>=1;
//     }
//     return res;
// }
// int modinv(int a, int mod)
// {
//     return binpow()
// }
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed<<setprecision(25);cerr<<fixed<<setprecision(10);
    int k;
    cin>>k;
    int start=7%k; 
    for(int i=1;i<=k;i++)
    {
        if(start==0)
        {
            cout<<i<<endl;
            return 0;
        }
        start=(start*10ll)%k;
        start=(start%k+7)%k;
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
#include <math.h>
double log10(double x);
int main() {
  int n;
  cin >> n;
  int64_t a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  int64_t ans = 1LL;
 /* for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }*/
  for (int i = 0; i < n; i++) {
    //if (log10(a[i]) + log10(ans) > 18) {
    if (a[i] > 1000000000000000000LL / ans) {
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
  }
  
  if (ans > 1000000000000000000LL || ans < 0LL) {
    cout << -1 << endl;
  }
  else {
    cout << ans << endl;
  } 
  
} 
  



Measured memory_bytes: 4400
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

vector<int> A(500010);
int H;

int left(int i){
    return 2 * i;
} 
int right(int i){
    return 2 * i + 1;
} 
int parent(int i){
    return i / 2;
} 

void maxHeapify(int i){
    int l = left(i), r = right(i);
    int largest = i;
    if(l <= H && A[l] > A[largest]) largest = l;
    if(r <= H && A[r] > A[largest]) largest = r;

    if(largest != i){
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

void buildMaxHeap(){
    for(int i = H / 2 ; i > 0; i--) maxHeapify(i);
}

int main(){
    cin >> H;
    for(int i = 1; i <= H; i++) cin >> A[i];
    buildMaxHeap();
    for(int i = 1; i <= H; i++) cout << " " << A[i];
    cout << endl;
}


Measured memory_bytes: 4512
#include<bits/stdc++.h>
using namespace std;
int a[100000][3];
int f[100000][3];
int main()
{
    int n;
    cin>>n;
    for (int i=0;i<n;i++)
    {
        for (int j = 0;j<3;j++)
        cin>>a[i][j];
    }
    f[0][0]=a[0][0];
    f[0][1]=a[0][1];
    f[0][2]=a[0][2];
    for (int i=1;i<n;i++)
    {
        f[i][0]=a[i][0]+max(f[i-1][1],f[i-1][2]);
        f[i][1]=a[i][1]+max(f[i-1][2],f[i-1][0]);
        f[i][2]=a[i][2]+max(f[i-1][1],f[i-1][0]);
    }   
    cout<<max(f[n-1][0],max(f[n-1][1],f[n-1][2]));

    return 0;
}

Measured memory_bytes: 5856
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<=(n);i++)
using namespace std;
typedef long long ll;
 
int main(){
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  int ans=0;
  rep(i,a){
    rep(j,b){
      rep(k,c){
        if(i*500+j*100+k*50==x){
          ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3552
//#include <ext/pb_ds/assoc_container.hpp> 
 //#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a,ll md) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
  
  
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
const int ce=1e9+7;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}
int fre[100001];
int co[11];
int n,k;
int f[100001];
int maxi;
int dp[501][5001];
int solve(int i,int rem)
{
	if(rem==0)
		return 0;
	if(i==maxi)
		return 0;
	int &res=dp[i][rem];
	if(res!=-1)
		return res;
	res=0;
	for(int j=1;j<=min(rem,k);j++)
	{
		res=max(res,co[j]+solve(i+1,rem-j));
	}
	return res;
}
int32_t main()
{
    IOS
   
    
    char ch;
    cin>>ch;
    if(ch-'A'>=0 and ch-'A'<=26)
    {
    	cout<<"A";
    }
    else
    {
    	cout<<"a";
    }


}       

Measured memory_bytes: 3648
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int H = in.nextInt();
            int n = in.nextInt();
            int nums[] = CPUtils.readIntArray(n, in);
            int attacks = 0;
            for (int val : nums)
            {
                attacks += val;
            }
            if (attacks >= H)
            {
                out.print("Yes");
            } else
            {
                out.print("No");
            }
        }

    }

    static class CPUtils
    {
        public static int[] readIntArray(int size, Scanner in)
        {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = in.nextInt();
            }
            return array;
        }

    }
}



Measured memory_bytes: 50280
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int p[] = new int[n];
		for(int i=0;i<n;i++){
			p[i]=sc.nextInt();
		}
		int count = 0;
		for(int i=1;i<n-1;i++){
			int tmp[] = new int[3];
			tmp[0] = p[i-1];
			tmp[1] = p[i];
			tmp[2] = p[i+1];
			for(int j=0;j<tmp.length-1;j++){
				for(int k=1;k<tmp.length;k++){
					if(tmp[k-1]>tmp[k]){
						int t = tmp[k-1];
						tmp[k-1] = tmp[k];
						tmp[k] = t;
					}
				}

			}

			if(tmp[1]==p[i]){
				count++;
			}

		}
		System.out.println(count);

	}
}


Measured memory_bytes: 21844
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N = int(input())
    S = input()

    r = S.count("R")
    b = S.count("B")
    if r > b:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    int ans=0;
    string s;
    cin>>s;
    for(int i=0;i<4;i++){
        if(s[i]=='+'){
            ans++;
        }else{
            ans--;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    string s;
    cin >> s;

    int sl = s.length();
    string ans = "";
    rep(i, sl) {
        if (s[i] == '0') ans += '0';
        if (s[i] == '1') ans += '1';
        if (s[i] == 'B' && ans != "") ans.erase(ans.length()-1);
    }

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

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, a, b, c = LI()
ans = []
D = {'A':a, 'B':b, 'C':c}
sx = SR(n)
for i in range(n):
    s = sx[i]
    s1 = s[0]
    s2 = s[1]
    if D[s1] == D[s2] == 0:
        print('No')
        exit()
    elif D[s[0]] == D[s[1]] == 1 and i + 1 < n:
        if s1 in sx[i + 1]:
            D[s1] += 1
            D[s2] -= 1
            ans += [s1]
        else:
            D[s2] += 1
            D[s1] -= 1
            ans += [s2]
    elif D[s1] == 0:
        ans += [s1]
        D[s1] += 1
        D[s2] -= 1
    elif D[s2] == 0:
        ans += [s2]
        D[s1] -= 1
        D[s2] += 1
    else:
        if D[s1] > D[s2]:
            ans += [s2]
            D[s1] -= 1
            D[s2] += 1
        else:
            ans += [s1]
            D[s1] += 1
            D[s2] -= 1

print('Yes')
print(*ans, sep='\n')

Measured memory_bytes: 94864
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int n,i,j,k,x[103],y[103],c[103],bx,by,bc,sc;
  
  cin >> n;
  for (i=0;i<n;i++) cin >> x[i] >> y[i] >> c[i];
  
  i=0;
  while (c[i]==0) i++;
  bx=x[i];
  by=y[i];
  bc=c[i];
  
  for (i=0;i<=100;i++){
    for (j=0;j<=100;j++){
      sc=bc+abs(i-bx)+abs(j-by);
      for (k=0;k<n;k++){
        if (max(0,sc-abs(i-x[k])-abs(j-y[k])) != c[k]) break;
      }
      if (k==n) break;
    }
    if (j<=100) break;
  }
  
  cout << i << ' ' << j << ' ' << sc << endl;
  
  return 0;
}

Measured memory_bytes: 256
stack = [i for i in input().split(" ")]
cnt1 = 0
cnt2 = 0

for i in stack:
    if "5" == i:
        cnt1 = cnt1 + 1
    if "7" == i:
        cnt2 = cnt2 + 1

if cnt1 == 2 and cnt2 == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
from functools import reduce

def gcd(x, y):
    if x >= y:
        while y != 0:
            x, y = y, x % y
        return x
    else:
        while x != 0:
            y, x = x, y % x
        return y
        

def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
l = []

for i in range(n):
    a = int(input())
    l.append(a)

print(lcm(*l))

Measured memory_bytes: 3572
N,x=gets.chomp.split(' ').map{|n| n.to_i}
A=gets.chomp.split(' ').map{|n| n.to_i}
cnt = 0
if(A[0] > x)
	dif = A[0]-x
	A[0] -= dif
	cnt += dif
end
for i in 1..(N-1)
	sum = A[i-1]+A[i]
	if(sum > x)
		dif = sum-x
		A[i] -= dif
		cnt += dif
	end
end
puts cnt


Measured memory_bytes: 9612
nk = gets.chomp

nkarr = nk.split(" ")

n = nkarr[0].to_i
k = nkarr[1].to_i

d = []
d_n = []
count = 0
while count < k do
    temp_k = gets.chomp.to_i
    temp_n = gets.chomp
    temp_n = temp_n.split(" ")
    temp_n = temp_n.map { |n|
        n.to_i
    }    
    d << temp_k
    d_n << temp_n
    count += 1
end

dn_uniq = d_n.flatten!.uniq

ans = 0
for i in 1..n do
    if dn_uniq.include? i
       ans += 1
    end
end

if ans == 0
    puts(0)
    exit
end

ans = n - ans 
puts(ans)

Measured memory_bytes: 14452
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {

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

        switch(N%10){
            case 2:
            case 4:
            case 5:
            case 7:
            case 9:
              System.out.println("hon");
              break;
            case 0:
            case 1:
            case 6:
            case 8:
              System.out.println("pon");
              break;
            case 3:
              System.out.println("bon");
              break;
        }
    }
}


Measured memory_bytes: 35560
s = input()
k = int(input())
l = []
cur = s[0]
c = 1
for i in s[1:]:
  if i != cur:
    l.append([cur,c])
    cur = i
    c = 1
  else:
    c += 1
l.append([cur,c])
c = 0
if len(l) == 1:
  print((l[0][1]*k)//2)
  exit()
elif len(l) == 2:
  print((l[0][1]//2+l[1][1]//2)*k)
  exit()

for i,j in l[1:-1]:
  c += j//2
if l[0][0] != l[-1][0]:
  c += l[0][1]//2 + l[-1][1] //2
  print(c*k)
else:
  re = c*k
  le = l[0][1] // 2
  r = l[-1][1] // 2
  ir = (l[0][1] + l[-1][1]) // 2
  print(re + le + r + ir * (k-1))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


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

  string str;
  cin >> str;

  string ans;
  for (int i = 0; i < str.size(); ++i) {
      if (str[i] == 'A') ans += 'T';
      if (str[i] == 'T') ans += 'A';
      if (str[i] == 'G') ans += 'C';
      if (str[i] == 'C') ans += 'G';
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long double ld;
#define int long long
typedef pair<int,int> pii;
#define RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(i=0; i <n; i++)
#define repv(i,k,n) for(int i=k; i<=n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define endl '\n'
#define deb(x) cout<<#x<<" = "<<x<<endl
#define gcd __gcd
#define inf LLONG_MAX
#define minf LLONG_MIN 
#define sp(n) fixed<<setprecision(n)
const int mod = (int)(1e9+7);
int power(int x,int n)
{   if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;return (y*y)%mod;}
    if(n&1)     {   int y = power(x,n-1);return (x%mod * y%mod)%mod;}
    return 0;
}
void db()
{   RAGE;
    #ifndef  ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
void timeit()
{  
    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}
bool is_power_2(int n)  { return log2(n)==floor(log2(n));}
bool is_prime(int n){for(int i=2; i*i<=n; i++)if(n%i==0)return 0; return 1;}

int dx[]    =  { -1 ,  0,  1,  0,  -1, -1, 1,  1};
int dy[]    =  { 0 ,  1,   0, -1,  -1,  1, 1, -1};
char dir[]  =  {'U', 'R', 'D','L' };
/* ------------------------------------------------------- */
const int maxn = 20005;
void solve()
{
    int n,i,j,k,m,q;
    cin>>n;
    int ar[n+1];
    m=0;
    repv(i,1,n)
    {
        cin>>ar[i];
        if(i&1 && ar[i]&1)
            m++;
    }
    cout<<m;
}
signed main()
{
    //db();    
    int t=1;
    //  cin>>t;
    while(t--)
    {
        solve();
    }
    //timeit();
    return 0;
}

Measured memory_bytes: 3584
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static final long mod = 1_000_000_007;

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

        long NUM = (long) Math.sqrt(1_000_000_001);
        List<Long> primes = sieveOfEratosthenes(NUM);

        Map<Long, Integer> primeNums = new HashMap<>();
        for (long p : primes) {
            int cnt = 0;
            while (M % p == 0) {
                cnt++;
                M /= p;
            }

            if (cnt != 0) {
                primeNums.put(p, cnt);
            }
        }

        // NUMより大きい素数がある可能性あり
        if (M > 1) {
            primeNums.put(M, 1);
        }

        long ans = 1;
        for (Map.Entry primeNum : primeNums.entrySet()) {
            int cnt = (int) primeNum.getValue();
            ans *= combinationMod(cnt + (N - 1), cnt, mod);
            ans %= mod;
        }

        out.println(ans);
    }

    public static long combinationMod(int n, int k, long prime) {
        // 事前計算
        long fac[] = new long[n + 1];
        long finv[] = new long[n + 1];
        long inv[] = new long[n + 1];
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i <= n; i++) {
            fac[i] = fac[i - 1] * i % prime;
            inv[i] = prime - inv[(int) (prime % Long.valueOf(i))] * (prime / i) % prime;
            finv[i] = finv[i - 1] * inv[i] % prime;
        }

        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;

        return fac[n] * (finv[k] * finv[n - k] % prime) % prime;
    }

    public static List<Long> sieveOfEratosthenes(long max) {
        List<Long> primes = new ArrayList<>();

        long prime;
        long max_check = (long) Math.floor(Math.sqrt(max));   //ふるい落としのチェックに利用する値
        List<Long> nums = new ArrayList<Long>();     //素数候補
        for (long i = 2; i <= max; i++) {
            nums.add(i);
        }


        while (true) {
            // ふるい落とした先頭は素数
            if (nums.size() < 2) {
                break;
            }
            prime = nums.get(0);

            // ふるい落としのチェックに利用する値は最大値の平方根未満の最大値
            if (prime >= max_check) {
                break;
            }

            primes.add(prime);

            // primeでふるい落とし
            List<Long> rest_nums = new ArrayList<>();
            for (long n : nums) {
                if (n % prime != 0) {
                    rest_nums.add(n);
                }
            }

            // ふるい落とした候補に更新
            nums = rest_nums;
        }

        //残っている候補は素数
        for (long n : nums) {
            primes.add(n);
        }

        return primes;
    }
}


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

mod = 10 ** 9 + 7

sum_a=0
for i in A:
    sum_a+=i
    sum_a%=mod

total=0
for i in range(N - 1):
    sum_a -= A[i]
    total+=A[i]*(sum_a)
    total%=mod
print(total)


Measured memory_bytes: 31364
x, y=map(int, input().split())

##xは二匹の合計，yは足の数
##cが鶴，tが亀

c = 0
t = 0

for t in range(x+1):
  c = x - t
  if 4*x - 2*c == 2*c + 4*t == y:
    print("Yes")
    break
  elif t < x:
    continue
  else:
    print("No")


Measured memory_bytes: 9172