akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

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

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long int ll;
const ll MOD = 1e9 + 7;

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

    vector<vector<ll>> dp(64, vector<ll>(3));
    dp[63][0] = 1;
    dp[63][1] = 0;
    dp[63][2] = 0;
    for (ll i = 62; i >= 0; i--) {
        if(n & (1L << i)){
            dp[i][0] = 1 * dp[i+1][0] + 0 * dp[i+1][1] + 0 * dp[i+1][2];
            dp[i][1] = 1 * dp[i+1][0] + 1 * dp[i+1][1] + 0 * dp[i+1][2];
            dp[i][2] = 0 * dp[i+1][0] + 2 * dp[i+1][1] + 3 * dp[i+1][2];
        }else{
            dp[i][0] = 1 * dp[i+1][0] + 1 * dp[i+1][1] + 0 * dp[i+1][2];
            dp[i][1] = 0 * dp[i+1][0] + 1 * dp[i+1][1] + 0 * dp[i+1][2];
            dp[i][2] = 0 * dp[i+1][0] + 1 * dp[i+1][1] + 3 * dp[i+1][2];
        }
        dp[i][0] %= MOD;
        dp[i][1] %= MOD;
        dp[i][2] %= MOD;
    }

    ll ans = (dp[0][0] + dp[0][1] + dp[0][2]) % MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func read() string {
    sc.Scan()
    return sc.Text()
}

func main() {
  read()
  
  Astr := read()
  Astrs := strings.Split(Astr, " ")
  As := []int{}
  for _, str := range Astrs {
    n, _ := strconv.Atoi(str)
    As = append(As, n)
  }
  
  Bstr := read()
  Bstrs := strings.Split(Bstr, " ")
  Bmap := map[int]int{}
  for i, str := range Bstrs {
    n, _ := strconv.Atoi(str)
    Bmap[i+1] = n
  }
  
  Cstr := read()
  Cstrs := strings.Split(Cstr, " ")
  Cmap := map[int]int{}
  for i, str := range Cstrs {
    n, _ := strconv.Atoi(str)
    Cmap[i+1] = n
  }
  
  var point int
  before := 999999999
  for _, A := range As {
    B := Bmap[A]
    point += B
    
    if before+1 == A {
      C := Cmap[A-1]
      point += C
    }
   	
    before = A
  }
  
  fmt.Println(point)
}

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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<int,P>;
using PP = pair<P ,P>;
constexpr ll MOD = ll(1e9+7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

ll N, K, n, m;
vector<ll> mn, pl;
ll zr = 0;

ll count(ll x){
    ll res = 0;
    if(x >= 0){
        res += n*m;
    }else{
        for(int i=0;i<n;i++){
            ll y = abs(x)/abs(mn[i]);
            res += pl.end() - upper_bound(pl.begin(),pl.end(),y);
        }
    }
    if(x > 0){
        res += zr*(n+m) + zr*(zr-1)/2;
        for(int i=0;i<n-1;i++){
            ll y = -((x-1)/abs(mn[i])+1);
            res += mn.end() - upper_bound(mn.begin()+i+1,mn.end(),y);
        }
        for(int i=0;i<m-1;i++){
            ll y = (x-1)/pl[i]+1;
            res += lower_bound(pl.begin()+i+1,pl.end(),y)-(pl.begin()+i+1);
        }
    }
    return res;
}

bool solve(){
    cin >> N >> K;
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        if(a < 0) mn.emplace_back(a);
        else if(a > 0) pl.emplace_back(a);
        else zr++;
    }
    n = mn.size();
    m = pl.size();
    sort(mn.begin(),mn.end());
    sort(pl.begin(),pl.end());
    ll ok = -(1e18), ng = (1e18)+1;  // ok: 未満の個数がK個未満となる最大値
    while(abs(ok-ng)>1){
        ll mid = (ok+ng)/2;
        if(count(mid) < K){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;
    return true;
}

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

Measured memory_bytes: 2420
#include<iostream>
#include<string>

using namespace std;
int main()
{
	// 整数の入力
	int a, b, x;
	cin >> a >> b >> x;
	if ((a <= x) & (a + b >= x))
	{
		cout << "YES" << endl;
	}
	else
		cout << "NO" << endl;
	return 0;

}

Measured memory_bytes: 256
words = lambda t : list(map(t, input().split()))

MOD = 10**9 + 7

l = list(input())

dp1 = [0]*(len(l)) #equal
dp2 = [0]*(len(l)) #less than

dp1[0] = 2
dp2[0] = 1
for i in range(1,len(l)):
    if l[i] == '1':
        dp1[i] = (dp1[i-1] * 2) % MOD
        dp2[i] = (dp2[i-1] * 3 + dp1[i-1]) % MOD
    else:
        dp1[i] = dp1[i-1]
        dp2[i] = (dp2[i-1] * 3) % MOD

#print(dp1,dp2)

print((dp1[-1] + dp2[-1])%MOD)


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

typedef vector<int> vi;
typedef pair<int, int> pii;
#define endl "\n"
#define sd(val) scanf("%d", &val)
#define ss(val) scanf("%s", &val)
#define sl(val) scanf("%lld", &val)
#define debug(val) printf("check%d\n", val)
#define all(v) v.begin(), v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val, 0, sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ                            \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int main()
{
    int n;

    cin >> n;
    bool f = 0;
    int total = 0;

    for (ll i = 1; i <= 1e7; i++)
    {
        total = ((total * 10) + 7) % n;

        if (total == 0)
        {
            cout << i << endl;
            f = 1;
            break;
        }
    }

    if (!f)
    {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var WHc = Reads();
            var W = int.Parse(WHc[0].ToString());
            var H = int.Parse(WHc[1].ToString());

            WriteLine("+" + new string('-', W - 2) + "+");
            for (int i = 0; i < H - 2; i++)
            {
                if ((H / 2) - 1 == i)
                {
                    WriteLine("|" + new string('.', W / 2 - 1) + WHc[2] + new string('.', W / 2 - 1) + "|");
                }
                else
                {
                    WriteLine("|" + new string('.', W - 2) + "|");

                }
            }
            WriteLine("+" + new string('-', W - 2) + "+");
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 17956
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
const int INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1000*1000*1000+7;
lli bpow(lli a, lli b) {
	if(b == 0) return 1;
	if(b == 1) return a % MOD;
	lli r = bpow(a, b >> 1);
	r = (r * r) % MOD;
	return (r * (((b&1)?a:1) % MOD)) % MOD;
}
lli multInverse(lli a) {
	return bpow(a, MOD - 2);
}
lli modMult(lli a, lli b) {
	return (a * b) % MOD;
}
lli modSub(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli modAdd(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	string s;
	cin >> s;
	int n = s.length();
	string ans = "";
	for(int i = 1; i <= n; i++) ans.push_back('x');
	cout << ans << "\n";
	return 0;
}

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

int main() {
    int N, M;
    std::cin >> N >> M;

    std::vector<std::vector<int>> g(N);
    std::vector<int> A(M), B(M);
    for (int i = 0; i < M; i++) {
        std::cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
        g[A[i]].push_back(B[i]);
    }

    std::vector<int> ans(N + 1);
    for (int i = 0; i < N; i++) {
        std::vector<int> dist(N, -1), prev(N);
        std::queue<int> que;
        dist[i] = 0;
        que.push(i);
        while (!que.empty()) {
            int u = que.front();
            que.pop();
            for (int v : g[u]) {
                if (dist[v] < 0) {
                    dist[v] = dist[u] + 1;
                    prev[v] = u;
                    que.push(v);
                }
            }
        }

        for (int j = 0; j < N; j++) {
            if (dist[j] < 0) continue;
            for (int u : g[j]) {
                if (u != i) continue;
                std::vector<int> res = {i};
                int v = j;
                while (v != u) {
                    res.push_back(v);
                    v = prev[v];
                }
                if (res.size() < ans.size()) {
                    ans = res;
                }
            }
        }
    }

    if (ans.size() == N + 1) {
        std::cout << "-1\n";
    } else {
        std::cout << ans.size() << "\n";
        for (int v : ans) {
            std::cout << v + 1 << "\n";
        }
    }
}

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

int main(){
  int p[3];
  cin  >> p[0] >> p[1] >> p[2];
  if(p[0] == p[1] && p[1] == p[2]) cout << 1 << endl;
  else if(p[0] == p[1] || p[0] == p[2] || p[1] == p[2]) cout << 2 << endl;
  else cout << 3 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    while(cin >> s)
    {
        int a = 0, b = 0;
        for(int i = 0; i < s.size(); i++)
        {
            string t = s.substr(i, 3);
            if(t == "JOI") a++;
            if(t == "IOI") b++;
        }
        cout << a << endl;
        cout << b << endl;
    }
    return 0;
}




Measured memory_bytes: 3216
from fractions import gcd
#from math import gcd
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
a,b=map(int,input().split())
m=gcd(a,b)
P=prime_factorize(m)
print(1+len(list(set(P))))

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	ll N,K; cin >> N >> K;
	V<ll> A(N),B(N);
	REP(i,N) cin >> A[i] >> B[i];
	ll ans = 0;
	for(int i = 0; i < N; ++i) if((K|A[i])==K) ans += B[i];

	for(int i = 0; i <= 29; ++i){
		if(!(K & (1<<i))) continue;
		ll L = K;
		L ^= (1<<i);
		ll cnt = 0;
		for(int j = 0; j < i; ++j) if(!(L & (1<<j))) L ^= (1<<j); 
		for(int j = 0; j < N; ++j) if((L|A[j])==L) cnt += B[j];
		chmax(ans,cnt);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
using namespace std;

int main() {
	string S; cin >> S;
	string  t;
	t += S[5]; t += S[6]; t += S[8]; t += S[9];
	int u = stoi(t);
	if (u <= 430)cout << "Heisei" << endl;
	else cout << "TBD" << endl;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
mod = int(1e9) + 7
temp = pow(2, n, mod) - 1
fa, fb = 1, 1
tempa, tempb = 1, 1
for i in range(1, a+1):
    fa *= i
    fa %= mod

    tempa *= (n - i + 1)
    tempa %= mod
for i in range(1, b+1):
    fb *= i
    fb %= mod
    tempb *= (n - i + 1)
    tempb %= mod

a_t = tempa * pow(fa, mod-2, mod) % mod
b_t = tempb * pow(fb, mod-2, mod) % mod
ans = (temp - a_t - b_t) % mod
print(ans)

Measured memory_bytes: 9136
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  ll n, m; cin >> n >> m;
  string s, t; cin >> s >> t;
  int g = __gcd(n,m);
  bool check = true;
  rep(i,g){
    if (s[i*n/g]!=t[i*m/g]) check = false;
  }
  cout << (check? n*m/g : -1) << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 3720
#include <iostream>

using namespace std;

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

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

	int checker[N] = {0};
	int count = 0;
	int btn_num = 0;
	while(1){
		count++;
		checker[btn_num]++;
		if(a[btn_num] != 2){
			if(checker[btn_num] >= 2){
				cout << -1 << endl;
				break;
			}else{
				btn_num = a[btn_num] - 1;
							continue;
			}
		}else{
			cout << count << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 1024
#include <cstring>
#include <cstdio>
typedef long long ll; 
int n, k, nxt[200005]; 
ll ans[35]; 
char str[200005]; 
void work(ll r)
{
	if (r <= n)
	{
		for (int i = 0; i < r; i++)
			ans[str[i] - 'a']++; 
		return; 
	}
	ll cnt_s = 1, cnt_t = 0, lst_s = 0, lst_t = 1; 
	while (cnt_s * n + cnt_t * k < r)
	{
		cnt_s += lst_s; 
		cnt_t += lst_t; 
		lst_s = cnt_s - lst_s; 
		lst_t = cnt_t - lst_t; 
	}
	work(r - lst_s * n - lst_t * k); 
	for (int i = 0; i < n; i++)
		ans[str[i] - 'a'] += lst_s; 
	for (int i = 0; i < k; i++)
		ans[str[i] - 'a'] += lst_t; 
}
int main()
{
	// freopen("ARC077-F.in", "r", stdin); 
	scanf("%s", str); 
	n = strlen(str) / 2; 
	nxt[0] = -1; 
	for (int i = 1, j = -1; i < n; i++)
	{
		while (~j && str[i] != str[j + 1])
			j = nxt[j]; 
		j += str[i] == str[j + 1]; 
		nxt[i] = j; 
	}
	k = n - nxt[n - 1] - 1; 
	ll l, r; 
	scanf("%lld%lld", &l, &r); 
	work(l - 1); 
	for (int i = 0; i < 26; i++)
		ans[i] *= -1; 
	work(r); 
	for (int i = 0; i < 26; i++)
		printf("%lld%c", ans[i], " \n"[i == 25]);
	return 0; 
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define MP make_pair
typedef long long ll;
int main(){
int n,k;
cin >> n >> k;
vector<ll>V(n);
for(int i=0;i<n;i++)
    cin >> V[i];
long long ans=0;
for(int i=0;i+1<n;i++){
    if(V[i]+V[i+1]>k){
        long long tmp=min(V[i+1],V[i]+V[i+1]-k);
        ans+=(tmp);
        V[i+1]-=tmp;
        if(V[i]+V[i+1]>k){
            tmp=V[i]+V[i+1]-k;
            V[i]-=tmp;
            ans+=tmp;
        }
    }
}

cout << ans << endl;

return 0;}


Measured memory_bytes: 1152
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int x = sc.nextInt();
    
    if (x >= 400 && 599 >= x)
      System.out.print("8");
    if (x >= 600 && 799 >= x)
      System.out.print("7");
    if (x >= 800 && 999 >= x)
      System.out.print("6");
    if (x >= 1000 && 1199 >= x)
      System.out.print("5");
    if (x >= 1200 && 1399 >= x)
      System.out.print("4");
    if (x >= 1400 && 1599 >= x)
      System.out.print("3");
    if (x >= 1600 && 1799 >= x)
      System.out.print("2");
    if (x >= 1800 && 1999 >= x)
      System.out.print("1");
  }
}

Measured memory_bytes: 27064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int H, N;
    cin >> H >> N;
    int A[N];
    for(int i = 0; i < N; i++) cin >> A[i];
    int sum = 0;
    for(int i = 0; i < N; i++) sum += A[i];
    
    if(sum >= H) cout << "Yes";
    else cout << "No";
    return 0;
}


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

int main(){
  double N;
  cin >> N;
  double count=0;
  for(int i=1 ; i<=N ;i++){
     if(i%2 !=0){
       count+=1;
     }
  }
  cout << count/N << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int a_xor = a[0];
  for (int i = 1; i < n; i++) {
    a_xor ^= a[i];
  }
  for (int i = 0; i < n; i++) {
    int out = a_xor ^ a[i];
    cout << out;
    if (i < n - 1) {
      cout << ' ';
    } else {
      cout << endl;
    }
  }

  return 0;
}


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

int main() {
  int n,sum;
  cin>>n;
  int a[n+1],b[n+1],c[n];
  
  for(int i = 1; i <= n; i++) cin>>a[i];
  for(int i = 1; i <= n; i++) cin>>b[i];
  for(int i = 1; i <= n-1; i++) cin>>c[i];
  sum = b[a[1]];
  for(int i = 2; i <= n; i++) {
      sum += b[a[i]];
      if(a[i] == a[i-1] + 1) sum += c[a[i-1]];
  }
  cout<<sum<<"\n";
  
  
  return 0;
}
 

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

int main()
{ 
   int n;
   cin>>n;
   int a[n+2];
   a[0]=a[n+1]=0;
   for(int i=1;i<=n;i++){
       cin>>a[i];
   }
   long long sum=0;
   for(int i=1;i<=n+1;i++){
       sum+=abs(a[i]-a[i-1]);
   }
   int diff=0;
   for(int i=1;i<=n;i++){
       diff=abs(a[i]-a[i-1])+abs(a[i+1]-a[i])-abs(a[i+1]-a[i-1]);
       cout<<sum-diff<<endl;
   }

}

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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; ll t;
	read(n, t);

	ll a = 0, b = 0;
	rep(i, 0, n) {
		ll h; read(h);
		chmax(b, h);
		ll p = (t - a) / b;
		ll q = (t - a) % b;
		write(max(0ll, p + (q >= h)) + 1);
		a += h;
	}
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define int long long

using namespace std;
using ll = long long;

const int N = (int)1e6 + 5;

int s[N], c[N];

main() {
  ios :: sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> s[i] >> c[i];
  }
  for (int i = 0; i <= 999; ++i) {
    vector <int> v;
    if (!i) {
      v.push_back(0);
    }
    else {
      int x = i;
      while (x) {
        v.push_back(x % 10);
        x /= 10;
      }
      reverse(v.begin(), v.end());
    }
    if (v.size() != n) {
      continue; 
    }
    bool ok = 1;
    for (int i = 1; i <= m; ++i) {
      if (s[i] > n) continue;
      ok &= (v[s[i] - 1] == c[i]); 
    }
    if (ok) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
  return 0;
}

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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
    string s;
    cin >> s;
    string upper = "";
    upper.push_back(s[0]);
    upper.push_back(s[1]);
    ll num_upper = stoi(upper);

    string lower = "";
    lower.push_back(s[2]);
    lower.push_back(s[3]);
    ll lower_upper = stoi(lower);

    if (num_upper < 1 or 12 < num_upper) {
      if (0 < lower_upper and lower_upper < 13) {
        COUT("YYMM");
      }
      else {
        COUT("NA");
      }
    }
    else {
      if (0 < lower_upper and lower_upper < 13) {
        COUT("AMBIGUOUS");
      }
      else {
        COUT("MMYY");
      }
    }
}



int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*
YYMM, MMYY, AMBIGUOUS, NA
*/


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll h, n, a[10010], b[10010];
ll dp[20010];


int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> h >> n;
  REP(i, n) cin >> a[i] >> b[i];
  REP(j, 20010) dp[j] = INF;
  dp[0] = 0;
  REP(i, n) REP(j, h + 1) {
    dp[j + a[i]] = min(dp[j + a[i]], dp[j] + b[i]);
  }
  ll ans = INF;
  for(int i = h; i < 20010; ++i) ans = min(ans, dp[i]);
  cout << ans;
  return 0;
}


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

int main(){
  int x=0;
  int N;
  cin>>N;
  for (int i=0;i<N;i++){
    string y;
    cin>>y;
    if(y=="Y"){
      x=1;
      break;
    }
  }
  if (x==1){
    cout<<"Four"<<endl;
  }
  else{
    cout<<"Three"<<endl;
  }
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

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

typedef long long ll;

void solve(long long N, long long M, std::vector<long long> A) {
    ll tot = 0;
    for (auto i : A) {
        tot += i;
    }
    ll ans = max(-1LL, N - tot);
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> A(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


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

#define all(x) x.begin(),x.end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long MOD=1e9+7;
const long long LINF=1e18;
const int INF=0x3f3f3f3f;
const int MAXN=200050;

int a[MAXN][2];
void solve(int T){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d %d",&a[i][0],&a[i][1]);
	}
	for(int i=1;i<=n-2;i++){
		if(a[i][0]==a[i][1]&&a[i+1][0]==a[i+1][1]&&a[i+2][0]==a[i+2][1]){
			puts("Yes"); 
			return;
		}
	}
	puts("No");
}
signed main(){
	int t=1;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	//scanf("%d",&t); 
	for(int i=1;i<=t;i++){
		solve(i);
	}
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int a[15];
vector<int>ans;
bool f() {
	int a1[15];
	for1(x, 9) {
		for1(i, 9)a1[i] = a[i];
		if (a1[x] < 2)continue;
		a1[x] -= 2;
		for1(i, 9) {
			if (a1[i] < 0)goto hell;
			a1[i] %= 3;
			if (a1[i] > 0 && i >= 8)goto hell;
			else {
				a1[i + 1] -= a1[i];
				a1[i + 2] -= a1[i];
				a1[i] = 0;
			}
		}
		return 1;
	hell:;
	}
	return 0;
}
signed main() {
	string s;
	while (cin >> s) {
		for1(i, 9)a[i] = 0;
		ans.clear();
		for (char c : s)a[c - '0']++;
		for1(i, 9) {
			if (a[i] > 4) {
				cout << "0\n";
				goto heaven;
			}
			a[i]++;
			if (a[i] <= 4)if (f())ans.push_back(i);
			a[i]--;
		}
		if (ans.size() == 0) {
			cout << "0\n";
			goto heaven;
		}
		for0(i, ans.size()) {
			if (i)cout << ' '; cout << ans[i];
		}cout << endl;
	heaven:;
	}
}


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

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	int l = a + b;
	int r = c + d;

	if (l > r) {
		cout << "Left" << endl;
	}
	else if (l < r) {
		cout << "Right" << endl;
	}
	else {
		cout << "Balanced" << endl;
 	}
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, Q;
    cin >> N >> Q;
    fenwick_tree<ll> fw(N);
    ll ai;
    for(int i=0;i<N;i++){
        cin >> ai;
        fw.add(i, ai);
    }
    ll q0, q1, q2;
    vector<ll> res;
    for(int i=0;i<Q;i++){
        cin >> q0 >> q1 >> q2;
        if(q0 == 0){
            fw.add(q1, q2);
        }else if(q0 == 1){
            res.push_back(fw.sum(q1, q2));
        }else{
            abort();
        }
    }
    for(auto v : res) cout << v << endl;

    return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct edge {
  int to, cost;
  edge(int to, int cost):to(to), cost(cost){}
};

using Graph = vector<vector<edge> >;

int N, Q, K;
Graph graph;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N;
  graph.resize(N);
  rep(i, N-1) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    graph[a].emplace_back(b, c);
    graph[b].emplace_back(a, c);
  }
  cin >> Q >> K;
  --K;
  vint dist(N, inf);
  queue<int> que;
  que.emplace(K);
  dist[K] = 0;
  while(!que.empty()) {
    int v = que.front(); que.pop();
    for(auto e : graph[v]) {
      if(dist[v]+e.cost < dist[e.to]) {
	que.emplace(e.to);
	dist[e.to] = dist[v]+e.cost;
      }
    }
  }
  rep(i, Q) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    cout << dist[x]+dist[y] << endl;
  }

  return 0;
}


Measured memory_bytes: 11520
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  ll X;
  cin >> X;
  
  ll ure = 0;
  while(X) {
    if(X >= 500) {
      ure += 1000;
      X -= 500;
    } else if(X >= 5) {
      ure += 5;
      X -= 5;
    } else {
      X --;
    }
  }
  
  fin(ure);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	
	int x,y;
	cin>>x>>y;
	if(x==2)cout<<"No"<<endl;
	if(x==1 || x==3 || x==5 || x==7 || x==8 || x==10){
		if(y==3 || y==5 || y==7 || y==8 || y==10 || y==12) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	if(x==4 || x==6 || x==9 || x==11){
		if(y==4 || y==6 || y==9 || y==11) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class T>inline bool chmax(T& a, T b){if(a>b){a =b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL <<60;
int N;
long long h[100010];
long long dp[1000010];
int main(){
  int N;cin>>N;
  for(int i=0;i<N;i++)cin>>h[i];
  for(int i=0;i<1000010;i++)dp[i]=INF;
  dp[0]=0;
  for(int i=1;i<N;++i){
    chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
    if(i>1)chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[N-1]<<endl;
  
}


Measured memory_bytes: 8832
#include <iostream>
using namespace std;
  
long gcd(long a, long b) {
    if (a < b) return gcd(b, a);
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}
  
int main() {
    long a, b;
    while (cin >> a >> b) {
        cout << gcd(a, b) << " " << a / gcd(a, b) * b << endl;      
    }
}

Measured memory_bytes: 2980
#include<cstdio>

int main(){
    char value[1000];
    
    while(1){
        scanf("%s",value);
        if((value[0]-'0')==0) {
            break;
        } else {
            int sum=0;

            for(int i=0; i<1000; i+=1){
                if(value[i]=='\0') break;
                sum += value[i] - '0';
            }
            printf("%d\n",sum);
        }
    }
    return 0;
}


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

namespace Coloring_Colorfully
{
    class Program
    {
        static void Main(string[] args)
        {
            string inp = Console.ReadLine();
            int otpt1 = 0;
            int otpt2 = 0;

            // Testcase 1
            for (int i = 1;i<=inp.Length;i++)
            {
                if (inp.Substring(i-1,1) == "0" & i%2==0)
                {
                    otpt1++;
                }
                if (inp.Substring(i - 1, 1) == "1" & i % 2 == 1)
                {
                    otpt1++;
                }
            }

            // Testcase 2
            for (int i = 1; i <= inp.Length; i++)
            {
                if (inp.Substring(i - 1, 1) == "0" & i % 2 == 1)
                {
                    otpt2++;
                }
                if (inp.Substring(i - 1, 1) == "1" & i % 2 == 0)
                {
                    otpt2++;
                }
            }

            if (otpt1<otpt2)
            {
                Console.WriteLine(otpt1);
            }
            else
            {
                Console.WriteLine(otpt2);
            }
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 17236
#include<bits/stdc++.h>
using namespace std;
long long n,w,c[105],v[105],dp[100005];
int main()
{
	cin >> n >> w;
	for(int i=1; i<=n; i++) cin >> c[i] >> v[i];
	for(int i=1; i<=n; i++) 
	{
		for(int j=w; j>=c[i]; j--) dp[j]=max(dp[j],dp[j-c[i]]+v[i]);
	}
	cout << dp[w];
	return 0;
}

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

int N,n;string A;int* B;
unsigned long long b1=100000007LL;unsigned long long* base;unsigned long long b2=1000000007LL;

void init(unsigned long long b) {
  base[0]=1LL;
  for (int i=0;i<n;i++) {
    base[i+1]=base[i]*b;
  }
}

int rollinghash(int a,int b,int b1) {
  unsigned long long start=0LL;
  for (int i=0;i<b;i++) {
    start+=base[b-1-i]*B[i+a];
  }
  unsigned long long x=start;int r=0;
  for (int i=0;i<N-a-b;i++) {
    x=x*b1-base[b-1]*b1*B[i+a]+B[i+a+b];
    if (i>=b-1 && x==start) {
      r=b;
      break;
    }
  }
  return r;
}

int main() {
  cin >> N >> A;B=new int[N];n=N/2;base=new unsigned long long[n+1];
  for (int i=0;i<N;i++) {
    B[i]=A.at(i)-'a';
  }
  init(b1);
  int right=n;int left=0;int mid;
  while (right!=left) {
    mid=(right+left+1)/2;
    bool x=false;
    for (int i=0;i<N-mid+1;i++) {
      if (rollinghash(i,mid,b1)>0) {
        x=true;
        break;
      }
    }
    if (x) left=mid;
    else right=mid-1;
  }
  init(b2);
  int right2=n;int left2=0;int mid2;
  while (right2!=left2) {
    mid2=(right2+left2+1)/2;
    bool x2=false;
    for (int i=0;i<N-mid2+1;i++) {
      if (rollinghash(i,mid2,b2)>0) {
        x2=true;
        break;
      }
    }
    if (x2) left2=mid2;
    else right2=mid2-1;
  }
  cout << max(left,left2) << endl;
}

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

int main(){
  string S;
  cin >> S;
  int n = S.length();
  int s[n];
  long long int dp[n+1][13];
  for (int i=0;i<=n;i++){
    for (int j=0;j<13;j++){
      dp[i][j]=0;
    }
  }
  dp[0][0]=1;
  long long int ans;
  for(int i=0;i<n;i++){
    if(S[i]=='?')s[i]=-1;
    else s[i]=S[i]-'0';
    for(int j=0;j<10;j++){
      if(s[i]!=-1 && s[i]!=j) continue;
      for(int ki=0;ki<13;ki++){
        dp[i+1][(ki*10+j)%13]+=dp[i][ki];
        dp[i+1][(ki*10+j)%13]%=MOD;
      }
    }
  }
  cout << dp[n][5] << endl;
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
#define INF 1000000000
#define EPS 0.0000000001
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<int> p(n);
    rep(i,n){
        cin>>p[i];
    }
    sort(all(p));
    ll ans=0;
    rep(i,n-1){
        ans+=p[i];
    }
    cout<<ans+(p[n-1]/2)<<endl;
}

Measured memory_bytes: 256
n = int(input())
c,s,f = [],[],[]
for _ in range(n-1):
  x,y,z = map(int,input().split())
  c.append(x)
  s.append(y)
  f.append(z)

for i in range(n-1):
  t = s[i] + c[i]
  for j in range(i+1,n-1):
    if t<s[j]:
      t = s[j]
    if t%f[j]==0:
      t+=c[j]
    else:
      t+=c[j]+f[j]-t%f[j]
  print(t)
print(0)
    

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

int main() {
    const int MAX = 10000;
    int n; cin >> n;
    vector<int> a(n);
    for (int &ai: a) cin >> ai;
    vector<int> dp(MAX + 1, 0);
    dp[0] = 1;
    for (int ai: a) {
        for (int i = MAX - ai; i >= 0; i--) dp[i + ai] |= dp[i];
    }
    for (int i = MAX; i >= 0; i--) if (dp[i] && (i % 10)) {
        cout << i << endl;
        return 0;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        Scanner sc = new Scanner(System.in);
        // 最初の文字の固まりを整数値と想定して読み込む
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            // 二重ループ(forの中にfor)を書いて、H x W個の # を表示しよう！
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 37540
#include <stdio.h>
#include <stdlib.h>

int main(void){
	int n;
	int *a, *b;
	int count = 0;
	scanf("%d", &n);
	a = malloc(sizeof(int) * n);
	b = malloc(sizeof(int) * n);
	for(int i = 0; i < n; i++)
		scanf("%d", a + i);
	for(int i = n; i > 0; i--){
		int bit = 0;
		for(int j = i * 2; j <= n; j += i)
			bit ^= b[j - 1];
		if(b[i - 1] = a[i - 1] ^ bit)count++;
	}
	printf("%d\n", count);
	for(int i = 0; count; i++){
		if(b[i]){
			count--;
			printf("%d ", i + 1);
		}
	}
	return 0;
}


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

int main() {
  int r, g, b;
  cin >> r >> g >> b;

  if ((r * 100 + g * 10 + b) % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

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

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

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
Scanner sc=new Scanner(System.in);
    char a=sc.next().charAt(0);
   int c=a;
    if(c>=65&&c<=90){
    
System.out.println("A");
    }else if(c>=97&&c<=122){
System.out.println("a");
    }
  }
}

Measured memory_bytes: 35728
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define f first
#define s second
#define mp make_pair
#define sz size()
#define ll long long
int h, w;
ll dp[1010][1010];
char a[1010][1010];
const int MOD = 1e9 + 7;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> h >> w;
	for(int i = 1; i <= h; ++i)
		for(int j = 1; j <= w; ++j) cin >> a[i][j];
	dp[1][1] = 1;
	for(int i = 1; i <= h; ++i) {
		for(int j = 1; j <= w; ++j) {
			if(i == j && i == 1) continue;
			if(a[i][j - 1] != '#') dp[i][j] = 1ll * (dp[i][j] + dp[i][j - 1]) % MOD;
			if(a[i - 1][j] != '#') dp[i][j] = 1ll * (dp[i][j] + dp[i - 1][j]) % MOD;
		}
	}
	/*for(int i = 1; i <= h; ++i) {
		for(int j = 1; j <= w; ++j) cout << "'" << a[i][j] << "'; coords: " << i << ' ' << j << "; dp[i][j] = " << dp[i][j] << '\n';
		cout << "\n\n";
	}*/
	cout << dp[h][w];
	return 0;
}

Measured memory_bytes: 9088
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<cstdio>
#include<ctime>
#include<utility>
#include<cstdlib>
#include<iterator>
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;
typedef unsigned int uint;
#define int long long

namespace G {
}
int N, A, B;

signed main() {
	cin >> N >> A >> B;
	if ((B*(N - 1) + A) - (A*(N - 1) + B) < 0) {
		cout << "0" << endl;
	}
	else {
		cout << (B*(N - 1) + A) - (A*(N - 1) + B) + 1 << endl;
	}
return 0;
}

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

int main() {
  int N, count = 0, now = 1;
  vector<int> a(100000);
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  for(int i = 0; i < N; i++) {
    now = a.at(now - 1);
    count++;
    if(now == 2) break;
  }
  if(now == 2) cout << count << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 768
import java.util.*;
import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        int ren = 0;
        for(int i=0; i<n; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();

            if(a == b) ren++;
            else ren = 0;

            if(ren == 3){
                out.println("Yes");
                break;
            }
        }
        if(ren != 3) out.println("No");
    }
}


Measured memory_bytes: 35988
lst = ["dream", "dreamer", "erase", "eraser"]
S = str(input())

while len(S) != 0:
    if S[len(S)-5:] == lst[0]:
        S = S[:len(S)-5]
    elif S[len(S)-7:] == lst[1]:
        S = S[:len(S)-7]
    elif S[len(S)-5:] == lst[2]:
        S = S[:len(S)-5]
    elif S[len(S)-6:] == lst[3]:
        S = S[:len(S)-6]
    else:
        break

if len(S) == 0:
    print("YES")
else:
    print("NO")

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

struct UnionFind {
    vector<int> d;
    UnionFind(int n = 0) : d(n,-1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> fri(n);
    vector<int> block(n);
    UnionFind uf(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        uf.unite(a, b);
        fri[a]++;
        fri[b]++;
    }
    for (int j = 0; j < k; ++j) {
        int c, d;
        cin >> c >> d;
        --c; --d;
        if (!uf.same(c, d)) continue;
        block[c]++;
        block[d]++;
    }
    for (int l = 0; l < n; ++l) {
        cout << uf.size(l) - 1 - fri[l] - block[l] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 2048
#include <iostream>
//#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>

using std::vector;
using std::swap;
using namespace std;


int solution(vector<int>& V){
	int result = 0;

	int n = V.size();
	int K;
	
	//randomized_quick_sort(V, 0, n - 1);
	sort(V.begin(), V.end());

	result = V[n/2] - V[n/2 - 1];
	
	return result;	
}

int main(){
  vector<int> V;
  int N;
  
  cin >> N;
  int a1;
  for(int i = 0; i < N; i++){
	  cin >> a1;
	  V.push_back(a1);	  
  }

  cout << solution(V) << endl; 
  
  return 0; 
}


Measured memory_bytes: 892
x,y,a,b,c = list(map(int,input().split()))
p = list(map(int,input().split()))
p = sorted(p,reverse=True)
q = list(map(int,input().split()))
q = sorted(q,reverse=True)
r = list(map(int,input().split()))
r = sorted(r)
c_ori = c
while c >= 1 and ((x >= 1 and p[x-1] < r[c-1]) or (y >= 1 and q[y-1] < r[c-1])):
    if x >= 1 and y >= 1 and p[x-1] < q[y-1]:
        x = x-1
        c = c-1
    elif x >= 1 and y >= 1 and p[x-1] >= q[y-1]:
        y = y-1
        c = c-1
    elif y == 0:
        x = x-1
        c = c-1
    else:
        y = y-1
        c = c-1
               
sum = 0
if x >= 1:
    for i in range(x):
        sum += p[i]
#print(sum)
if y >= 1:
    for i in range(y):
        sum += q[i]
#print(sum)
if c_ori > c:
    for i in range(c,c_ori):
        sum += r[i]
print(sum)

Measured memory_bytes: 23232
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#include<typeinfo>
#define R(i, n) for(int i = 0;i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", &a[i])
#define SAL(i, n, a) R(i, n) scanf("%lld", &a[i])
#define SC(a) scanf("%c", &a)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
#define PY printf("YES")
#define PN printf("NO")
#define Py printf("Yes")
#define Pn printf("No")
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;
const double PI = acos(-1);

int a, b;

int main(){
	S2(a, b);
	P(a * b);
} 

Measured memory_bytes: 3824