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

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

const int N = 405;
char bs[N][N];
int H, W;

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

void dfs(int x, int y, char c, int& nb, int& nw, vector<vector<bool>>& vis) {
	vis[x][y] = 1;
	char nc = c == '#' ? '.' : '#';
	REPU(i, 0, 4) {
		int nx = x + dx[i], ny = y + dy[i];
		if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
		if (bs[nx][ny] == nc && !vis[nx][ny]) {
			if (nc == '#') nb++;
			else nw++;
			dfs(nx, ny, nc, nb, nw, vis);
		}
	}
}

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	cin >> H >> W;
	REPU(i, 0, H) cin >> bs[i];
	vector<vector<bool>> vis(H, vector<bool>(W, false));

	int nb, nw;
	ll ans = 0;
	REPU(i, 0, H) REPU(j, 0, W) if (!vis[i][j] && bs[i][j] == '#') {
		nb = 1, nw = 0;
		dfs(i, j, '#', nb, nw, vis);
		ans += 1LL * nb * nw;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 15488
def merge(S, left, mid, right):
    INF = 10**9
    global cnt
    L = S[left: mid] + [INF]
    R = S[mid: right] + [INF]
    i = 0
    j = 0
    
    for k in range(left, right):
        cnt += 1
        if L[i] <= R[j]:
            S[k] = L[i]
            i += 1
        else:
            S[k] = R[j]
            j += 1

def mergeSort(S, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        mergeSort(S, left, mid)
        mergeSort(S, mid, right)
        merge(S, left, mid, right)
        
n = int(input())
S = list(map(int, input().split()))

cnt = 0
mergeSort(S, 0, n)

print(" ".join(map(str, S)))
print(cnt)


Measured memory_bytes: 66720
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

long long gcd(long long a, long long b) {
	while (a != 0) {
		if (a < b)swap(a, b);
		a = a % b;
	}
	return b;
}
long long x(long long a, long long b) {
	if (a < b)swap(a, b);
	return a / gcd(a, b)*b;
}

int main() {
	int N,b=0,c=0; cin >> N;
	vector<long long> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	for (int i = 0; i < N; i++) {
		if (a[i] % 4 == 0) {
			b++; continue;
		}
		if (a[i] % 2 == 0)c++;
	}
	if(c==0&&N-b-1<=b)cout << "Yes" << endl;
	else if ((N - c + 1) / 2 <= b&&c!=0)cout << "Yes" << endl;
	else cout << "No" << endl;
}



Measured memory_bytes: 1024
#include<iostream>
#include<string>
 
using namespace std;
 
int check(string str)
{
  if(str[0] != '>'){ return -1; }
  if(str[1] != '\'' && str[1] != '^'){ return -1; }
  if(str[2] == '='){
    if(str[str.size()-1] != '~' || str[str.size()-2] != '='){ return -1; }
    int i=3,cnt1=1,cnt2=0;
    while(str[i] != '#'){
      if(i >= str.size()){ return -1; }
      if(str[i] != '=')  { return -1; }
      i++;
      cnt1++;
    }
    i++;
    while(str[i] == '='){
      if(i >= str.size()){ return -1; }
      i++;
      cnt2++;
    }
    if(cnt1 == cnt2){ return 0; }
    else{ return -1; }
  }
  else if(str[2] == 'Q'){
    if(str[str.size()-1] != '~' ||
       str[str.size()-2] != '~' ||
       str[str.size()-3] != '='){ return -1; }
    int i = 3;
    while(1){
      if(i >= str.size()-2){ return 1; }
      if(i&1){
        if(str[i] != '='){ return -1; }
      }
      else{
        if(str[i] != 'Q'){ return -1; }
      }
      i++;
    }
    return 1;
  }
  else{ return -1; }
  
}
 
int main(void)
{
 
  int n;
  string str;
 
  cin >> n;
 
  while(n-->0){
    cin >> str;
    int ans = check(str);
    if(ans <  0){ cout << "NA" << endl; }
    if(ans == 0){ cout << "A"  << endl; }
    if(ans == 1){ cout << "B"  << endl; }
  }
 
  return 0;
}

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

int main() {
  char c;
  cin >> c;
  if (c == 'a'){
    cout << "vowel" << endl;
  }
 else if (c == 'e'){
    cout << "vowel" << endl;
  }
 else if (c == 'i'){
    cout << "vowel" << endl;
  }
  else if (c == 'o'){
    cout << "vowel" << endl;
  }
 else if (c == 'u'){
    cout << "vowel" << endl;
  }
  else cout << "consonant" << endl;
}


Measured memory_bytes: 256
import itertools
N = int(input())
s = [0] * N
not10 = []
answer = 0
for i in range(N):
    s[i] = int(input())

SUM = sum(s)
if SUM % 10 != 0:
    print(SUM)
    exit()
else:
    for i in range(N):
        if s[i] % 10 != 0:
            not10.append(s[i])
    not10.sort()
    if len(not10) == 0:
        print(0)
    else:
        print(SUM - not10[0])
    exit()
            
# print(not10)

# for i in range(1, N+1):  # 何問正解するか、0からN問まで
#     for v in itertools.combinations(s, i):
#         if sum(v) % 10 != 0 and answer <= sum(v):
#             answer = sum(v)
#         print(v, sum(v))

# print(answer)
        

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

int main()
{
    int a, b, c;
    std::cin >> a >> b >> c;
    int array[] = {a, b, c};
    std::size_t size = sizeof(array) / sizeof(array[0]);
    std::sort(array, array + size);
    std::cout << array[0] << ' ' << array[1] << ' ' << array[2] << std::endl;
}

Measured memory_bytes: 3148
fun main(args: Array<String>) {
    var numList: List<Int> = getInputIntList()

    var a = numList.get(0)
    var b = numList.get(1)

    var num = 0
    if(a < b) {
        num += b
        b -= 1
    } else {
        num += a
        a -= 1
    }

    if(a < b) {
        num += b
        b -= 1
    } else {
        num += a
        a -= 1   
    }
    println(num)
}

fun getInputIntList() : List<Int> {
    val str = readLine()!!.toString()
    return str.split(Regex("\\s+")).map{b -> Integer.parseInt(b)}
}

Measured memory_bytes: 35816
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>

using namespace std;

int main(){

    int n, k;
    int cnt = 0;
    vector<int> v;

    cin >> n >> k;

    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        v.emplace_back(tmp);
    }

    while(n > 1){
        n = n - k + 1;
        cnt++;
    }

    cout << cnt << endl;





    return 0;
}


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

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

int main() {
    int K, A, B;
    cin >> K >> A >> B;

    if (A % K == 0 || B % K == 0) {
        cout << "OK" << endl;
        return 0;
    }

    if (A / K < B / K) {
        cout << "OK" << endl;
        return 0;
    }

    cout << "NG" << endl;
}


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


int main() {
    int a, b;
    string s;
    cin >> a >> b >> s;
    if (s.size() != a + b + 1) return !printf("No");
    if (s[a] != '-') return !printf("No");
    for (int i = 0; i < s.size(); i++) {
        if (i == a) continue;
        if (s[i] == '-') return !printf("No");
    }
    puts("Yes");
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;cin>>N;
    vint P(N);rep(i,N)cin>>P[i];
    int ans=0;
    int pre=1;
    rep(i,N){
        if(P[i]==pre||pre==1){
            ans+=P[i]/pre-1;
            pre++;
        }
        else{
            int t=P[i]/pre;
            if(P[i]%pre==0)t--;
            ans+=t;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  int n; cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) {
    cin >> a[i] >> b[i];
  }

  ll ans = 0;
  for(int i = n - 1; i >= 0; --i) {
    ll diff = (ans + a[i]) % b[i];
    if(diff) {
      ans += b[i] - diff;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
def solve(h, n, AB):
    size = h + max(a for a, _ in AB) # 残りHP:1の時に最大火力を出すときまで考える
    dp = [-1] * size
    dp[0] = 0
    for i in range(1, size):
        # if 1撃で倒せる then b消費 else (HPがi-aのときの最小魔力+b)消費
        dp[i] = min(b if a >= i else dp[i - a] + b for a, b in AB)
    return min(dp[h:])

_h, _n = map(int, input().split())
_AB = [list(map(int, input().split())) for _ in range(_n)]
print(solve(_h, _n, _AB))


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

int Ordinary(int n){
    int P[n]={};
    for(int i=0;i<n;i++){
        cin >> P[i];
    }
    int cnt=0;
    for(int i=1;i<n-1;i++){
        if(P[i-1]<P[i]&&P[i]<P[i+1]){
            cnt++;
        }
        else if(P[i-1]>P[i]&&P[i]>P[i+1]){
            cnt++;
        }
    }
    return cnt;
}

int main(){
    int n; cin >> n;
    cout << Ordinary(n) << endl;
    return 0;
}

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

int main() {
long long X;
  cin >> X;
  long double A = 100;
  long long b;
  for(int a = 1;a >= 0;a++){
    A *= 1.01;
    b = A;
    A = b;
    if(A >= X){
     cout << a << endl;
      break;
    }
  }
}

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

int main() {
	int n;
	cin >> n;
	vector<double> v(n);
	rep(i,n) cin >> v[i];
	sort(v.begin(), v.end());
	double ans = v[0];
	for(int i=1;i<n;++i) {
		ans = (ans + v[i]) / 2;
	}
	printf("%.10f\n", ans);
	return 0;
}


Measured memory_bytes: 256
//even flip - face up odd 
//1st row -even last row - even
//2nd row - odd
//2nd row - even anser will be the border
//.....
//.....
//w+w+h-2+h-2
#include<bits/stdc++.h>
using namespace std;
long long mini(long long a,long long b){
    if(a<=b)return a;
    else return b;
}
int main(){
	long long n,m;cin>>n>>m;
	
	long long tot;
	if(n==1 && m==1){cout<<1;return 0;}
	if(n==1 || m==1){cout<<max(n,m)-2;return 0;}
	else{tot = 2*m+2*n-4;}
  cout<<n*m-tot;
}

Measured memory_bytes: 3532
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
const int INF = 1e9;
const ll LINF = 1e18;
// clang-format on

void solve(long long N) {
  ll ans = 0;
  rep1(i, N) {
    if (to_string(i).length() % 2 == 1)
      ans += 1;
  }
  ANS(ans);
}

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ans = 1000;
  for (int i = 0; i <= s.size() - 3; i++) {
    int ss = stoi(s.substr(i, 3));
    if (abs(ss - 753) < ans) ans = abs(ss - 753);
  }
  cout << ans << endl;
}

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

ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}
ll min(ll a, ll b){ 
	if(a <= b) return a;
	else if(a > b) return b;
}
ll gcd(ll a, ll b){
	if(b == 0) return a;
	return gcd(b, a%b);
}
ll fact(ll n){
	ll res = 1;
	rep(i, n){
		res *= i + 1;
		res =  res%((ll)(1e9 + 7));
	}
	return res;
}
ll digit(const ll n){
	ll res = 0;
	ll i = 1;
	while(n % i != n){
		res += 1;
		i *= 10;
	}
	return res;
}

int main(){
	ll x;
	cin >> x;
	x -= 1;
	ll ans = 2*(x/11);
	ll mod = x%11;
	if(mod <= 5)ans += 1;
	else if(mod >= 6) ans += 2;
	cout << ans << endl;
}
	

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

const ll MOD = 1e9+7;

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  int sum = 0;
  rep(i, n) {
    int x;
    cin >> x;
    int t = min(abs(x-k), abs(x-0));
    sum += (t*2);
  }
  cout << sum << endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(abs(a[i] -a[j]) % (n-1) == 0){
                cout << a[i] << " " << a[j] << endl;
                i = n;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <cstdlib>
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[100010];
int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];
    for (int i = 0; i < 100010; ++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: 1792
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <string>
#include <sstream>
int fix()
{
    //example to format floating point numbers.
    double pi = 3.141592653589793;
    double r = 3.141592653589793 * 128;
    std::ios_base::fmtflags f(std::cout.flags()); //[1]
    std::cout << "default:\n  " << pi << " " << r << "\n";
    std::cout << std::setprecision(4) << "setprecision(4):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout << std::setiosflags(std::ios::fixed) << "setiosflags(std::ios::fixed):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout << std::setprecision(5) << "setprecision(5):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout.flags(f);
    std::cout << "reset:\n  " << pi << " " << r << "\n";
    //[1] https://stackoverflow.com/questions/2273330/restore-the-state-of-stdcout-after-manipulating-it
    //[2] https://stackoverflow.com/questions/4217510/how-to-cout-the-correct-number-of-decimal-places-of-a-double-value
    return 0;
}
void multipleLines()
{
    //example to parse multiple lines input.
    std::istringstream isin("1 2 3\n3 2 4\n0 0 0");

    for (std::string str; std::getline(isin, str);)
    {
        std::istringstream tisin(str);
        int a, b, c;
        tisin >> a >> b >> c;
        std::cout << a << " " << b << " " << c << "\n";
    }
    //[1]  https://stackoverflow.com/questions/19767644/c-parsing-input-string-to-variables
}
int main()
{
    std::istream &istr = std::cin;
    //std::istringstream istr("8 8\n0 0");
    while (true)
    {
        int64_t a, b;
        istr >> a >> b;
        if (a * a + b * b == 0)
        {
            return 0;
        }
        for (int64_t i = 1; i <= a; i++)
        {
            char t[2] = {'.', '#'};

            for (int64_t j = 1; j <= b; j++)
            {
                std::cout << t[i == 1 || i == a || j == 1 || j == b];
            }
            std::cout << "\n";
        }
        std::cout << "\n";
    }
    return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int n, k;
vector<int> a;
int dp[3001][3001][2];

int solve(int first_index, int last_index, int turn)
{
	if (first_index > last_index)
		return 0;

	if (dp[first_index][last_index][turn] != -1)
		return dp[first_index][last_index][turn];


	if (turn == 1)
	{
		return dp[first_index][last_index][turn] = max(a[first_index] + solve(first_index + 1, last_index, 0), a[last_index] + solve(first_index, last_index - 1, 0));
	}
	else
	{
		return dp[first_index][last_index][turn] = min(solve(first_index + 1, last_index, 1), solve(first_index, last_index - 1, 1));
	}
}

int32_t main()
{
	FIO();
	cin >> n;
	int tot_sum = 0;

	a.resize(n);

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

	memset(dp, -1, sizeof(dp));

	int taro = solve(0, n - 1, 1);
	int jiro = tot_sum - taro;

	cout << taro - jiro << '\n';

	return 0;
}

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

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<std::pair<int64_t, int64_t>> xy(N);
	for (auto& e: xy) scanf("%lld%lld", &e.first, &e.second);
	int64_t max[2]{-(1ll << 60), -(1ll << 60)}, min[2]{1ll << 60, 1ll << 60};
	for (auto& e: xy)
	{
		int64_t sum{e.first + e.second}, sub{e.first - e.second};
		if (sum > max[0])
			max[0] = sum;
		if (sum < min[0])
			min[0] = sum;
		if (sub > max[1])
			max[1] = sub;
		if (sub < min[1])
			min[1] = sub;
	}
	printf("%lld\n", std::max(max[0] - min[0], max[1] - min[1]));

	return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  int ans = 0;
  int outlet = 1;
  while (outlet < b) {
    --outlet;
    outlet += a;
    ++ans;
  }
  cout << ans << endl;
}

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

int main(){

    int a, b, c;
    cin >> a >> b >> c;

    bool poor = false;

    if(a == b){
        if(a != c){
            poor = true;
        }
    }
    else{
        if(b == c){
            poor = true;
        }else if(a == c){
            poor = true;
        }
    }

    if(poor){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

//A Milk Shop
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[] a = new int[n];
			for(int i=0;i<n;i++)a[i]=sc.nextInt();
			Arrays.sort(a);
			long s = 0;
			long t = 0;
			for(int i=0;i<n;i++){
				s += t;
				t += a[i];
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 13000
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import fractions


def lcm(a, b):
    return a * b // fractions.gcd(a, b)


def lcms(ns):
    l = len(ns)
    assert l > 1
    if l == 2:
        return lcm(*ns)
    else:
        a = ns.pop()
        return lcm(a, lcms(ns))


if __name__ == "__main__":
    _ = int(input())
    print(lcms(list(map(int, input().split()))))

Measured memory_bytes: 10264
S=io.read()

for s,l,m,r in S:gmatch"(()R+()L+())"do
for i=l,m-2 do
	print(0)
end
ln=m-l
rn=r-m
print(math.ceil(ln*.5)+math.floor(rn*.5))
print(math.floor(ln*.5)+math.ceil(rn*.5))
for i=m+1,r-1 do
	print(0)
end
end

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

int main(){
  int A, B;
  cin>>A>>B;
  int sum=0;
  for(int i=A;i<=B;i++){
    if((i%10==i/10000)&&((i%100)/10==(i/1000)%10)){
      sum+=1;
    }
  }
  cout<<sum<<endl;
}

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

int main() {
    int X, Y, Z, tmp;
    cin >> X >> Y >> Z;
    // swap AB
    tmp = X;
    X = Y;
    Y = tmp;
    // swap AC
    tmp = X;
    X = Z;
    Z = tmp;
    cout << X << " " << Y << " " << Z << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back

char ban[3][3];


main(){
  while(cin>>ban[0]){
    if(ban[0][0]=='0')break;
    cin>>ban[1];
    cin>>ban[2];


    int br=0,bl=0,wr=0,wl=0;
    rep(i,3){
      int bh=0,wh=0,bv=0,wv=0;
      rep(j,3){
        if(ban[i][j]=='b')++bh;
        if(ban[i][j]=='w')++wh;
        if(ban[j][i]=='b')++bv;
        if(ban[j][i]=='w')++wv;
      }
      if(bv==3 || bh==3){
        cout<<'b'<<endl;
        goto END;
      }
      if(wv==3 || wh==3){
        cout<<'w'<<endl;
        goto END;
      }
      if(ban[i][i]=='b')++br;
      if(ban[i][i]=='w')++wr;
      if(ban[i][2-i]=='b')++bl;
      if(ban[i][2-i]=='w')++wl;
    }

    if(br==3 || bl==3){
      cout<<'b'<<endl;
      goto END;
    }
    if(wr==3 || wl==3){
      cout<<'w'<<endl;
      goto END;
    }
    puts("NA");
END:;
  }
}

Measured memory_bytes: 0
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;
template <class T> T gcd(T n, T m){return m ? gcd(m, n%m):n;}

int main(){
    ll a, b;
    cin >> a >> b;
    ll c = gcd(a,b);
    ll ans = 1;
    for (ll i=2;i*i<=c;i++){
        if(c%i==0){
            ans++;
            while(c%i==0){c/=i;}
        }
    }
    if(c!=1){ans++;}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
class event{
public:
  int a,b,c;  
};
int32_t main(){
    int n;
    cin>>n;
    event arr[n+1];
    for(int i=1;i<=n;i++){
        cin>>arr[i].a;
        cin>>arr[i].b;
        cin>>arr[i].c;
    }
    int dp[n+1][3];
    dp[1][0]=arr[1].a;
    dp[1][1]=arr[1].b;
    dp[1][2]=arr[1].c;
    for(int i=2;i<=n;i++){
        dp[i][0]=arr[i].a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=arr[i].b+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=arr[i].c+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
	return 0;
}

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

int main(){
    int A = 0, tmp = 0;

    cin >> tmp;
    A += tmp;

    cin >> tmp;
    A += tmp;

    cin >> tmp;
    A += tmp;

    if (A >= 22){
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt(), B = scanner.nextInt();

        if (A <= 8 && B <= 8) {
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }
    }
}


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

int main(){
    int x[5];
    for(int i=0; i<5; i++){
        cin >> x[i];
        if(x[i] == 0){
            cout << i+1 << endl;
            return 0;
        }
    }
    
    return 0;
}
  

Measured memory_bytes: 3520
n = int(input())

def fib(n):
    dp = [0] * (n+1)
    dp[0] = 1
    dp[1] = 1

    def fib_sub(n):
        if dp[n] != 0:
            return dp[n]

        fibn1 = fib_sub(n-1)
        fibn2 = fib_sub(n-2)
        dp[n-1] = fibn1
        dp[n-2] = fibn2
        return fibn1 + fibn2

    return fib_sub(n)
print(fib(n))



Measured memory_bytes: 5608
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
string match(string& s, string& t, int offset) {
    bool can = true;
    for(int i = 0; i < t.size() and can; i++) {
        can &= s[i + offset] == '?' or s[i + offset] == t[i];
    }
    if(can) {
        string m = s;
        for(int i = 0; i < t.size(); i++) {
            m[i + offset] = t[i];
        }
        for(int i = 0; i < m.size(); i++) {
            if(m[i] == '?') {
                m[i] = 'a';
            }
        }
        return m;
    } else {
        return "{";
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin >> s >> t;
    string ans = "{";
    if(t.size() <= s.size()) {
        for(int offset = 0; offset <= s.size() - t.size(); offset++) {
            if(ans > match(s, t, offset)) {
                ans = match(s, t, offset);
            }
        }
    }
    cout << (ans == "{" ? "UNRESTORABLE" : ans) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

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

    int l, r;
    int cnt = 0;
    REP(0, i, N) {
        cin >> l >> r;
        cnt += r - l + 1;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define elif else if
#define ll long long
#define pr printf
#define sc scanf

int main()
{
      ll int a, b, c, t;
      while(sc("%lld",&t)==1) {
                  while(t--) {
            sc("%lld %lld %lld",&a,&b,&c);
            ll int p=a*a,q=b*b,r=c*c;
            if((p+q==r) ||(p+r==q) ||(q+r==p)) pr("YES\n");
            else pr("NO\n");
      }
      }
      return 0;
}

Measured memory_bytes: 580
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (mut a, mut b) = input_tuple();
    let mut sum = 0;
    if a > b {
        sum += a;
        a -= 1;
    } else {
        sum += b;
        b -= 1;
    }

    if a > b {
        sum += a;
    } else {
        sum += b;
    }

    println!("{}", sum);
} 



Measured memory_bytes: 4352
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	parseProblem()
}

type graph struct {
	size  int
	edges [][]int
	nodes []int
}

func newGraph(n int) *graph {
	return &graph{
		size:  n,
		edges: make([][]int, n),
		nodes: make([]int, n),
	}
}

func parseProblem() {
	n, q := scanInt(sc), scanInt(sc)
	g := newGraph(n)
	for i := 0; i < n-1; i++ {
		a, b := scanInt(sc)-1, scanInt(sc)-1
		g.edges[a] = append(g.edges[a], b)
		g.edges[b] = append(g.edges[b], a)
	}
	for _ = range loop0(q) {
		p, x := scanInt(sc)-1, scanInt(sc)
		g.nodes[p] += x
	}
	nums := make([]int, n)
	visited := make([]bool, n)
	_dfs(nums, visited, g, 0, 0)
	b := strings.Builder{}
	for i := range nums {
		b.WriteString(fmt.Sprint(nums[i]))
		b.WriteString(" ")
	}
	fmt.Println(b.String())
	return
}

func _dfs(nums []int, visited []bool, g *graph, idx, cur int) {
	cur += g.nodes[idx]
	visited[idx] = true
	nums[idx] = cur
	for _, next := range g.edges[idx] {
		if visited[next] {
			continue
		}
		_dfs(nums, visited, g, next, cur)
	}
}

func loop0(n int) chan int {
	return loop(0, n-1, 1)
}

func loop1(n int) chan int {
	return loop(1, n, 1)
}

func loop(s, e, d int) chan int {
	ch := make(chan int)
	go func() {
		for i := s; i <= e; i += d {
			ch <- i
		}
		close(ch)
	}()
	return ch
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 74780
//A,Elebereth Gilthoniel mantae!
//For Temeria!
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>
#include<cstring> 
using namespace std;
int o[101][101];
char c[2]={'.','#'};
int check(int x,int y)
{
	if(x<0 or x>99 or y<0 or y>99) return 0;
	if(o[x][y]!=o[x][y+1])
	if(o[x][y]!=o[x][y-1])
	if(o[x][y]!=o[x+1][y])
	if(o[x][y]!=o[x-1][y])
	return 1;
	return 0;
}
int main()
{
 	//freopen("","r",stdin);
	//freopen("","w",stdout);
	 int m,n;cin>>m>>n;swap(m,n);
	 for(int i=0;i<100;i++) o[0][i]=o[i][99]=o[99][i]=o[i][0]=1;
	 if(m<n) swap(m,n),swap(c[0],c[1]);m--;n--;
	 for(int i=1;i<99;i+=2)
	 {
	 	for(int j=1;j<99;j+=2)
	 	{
	 		if(m==0) continue;
	 		if(m>0 and n==0)
	 		{
	 			
	 			o[i][j]=1;if(check(i,j)==0)
	 			{
	 				o[i][j]=0;
	 				continue;
	 			}
	 			if(check(i,j-1) or check(i,j+1) or check(i+1,j) or check(i-1,j)) 
	 			{
	 				o[i][j]=0;continue;
	 			}m--;continue;
	 		}
	 		if(m>0 and n>0)
	 		{
	 			o[i][j]=1;
	 			if(check(i,j)==0)
	 			{
	 				o[i][j]=0;continue;
	 			}
	 			int t=check(i,j-1)+check(i,j+1)+check(i+1,j)+check(i-1,j);
	 			if(t<=n) 
	 			{
	 				n-=t,m--;;continue;
	 			}
	 			else
	 			{
	 				o[i][j]=0;continue;
	 			}
	 		}
	 	}
	 }
	 if(n>0)
	 {
	 	for(int i=98;i>0;i--)
	 	{
	 		for(int j=98;j>0;j--)
	 		{
	 			if(n>0)
	 			{
	 				if(check(i,j) or o[i][j]==1) continue;
	 				o[i-1][j]=o[i+1][j]=o[i][j+1]=o[i][j-1]=o[i+1][j+1]=o[i-1][j-1]=o[i+1][j-1]=o[i-1][j+1]=1;n--;
	 			}
	 		}
	 	}
	 }
	 cout<<100<<" "<<100<<"\n";
	 for(int i=0;i<100;i++)
	 {
	 	for(int j=0;j<100;j++) {
	 		cout<<c[o[i][j]];
	 	}cout<<"\n";
	 }
	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  map<int, int> a;
  bool valid = true;
  if (n % 2 == 0) {
	for (int i = 1; i < n; i += 2) {
	  a.emplace(i, 0);
	}
  }
  else {
	for (int i = 0; i < n; i += 2) {
	  a.emplace(i, 0);
	}
  }
  for (int i = 0; i < n; i++) {
	int t;
	cin >> t;
	if (a.find(t) == a.end()) {
	  valid = false;
	}
	else {
	  a[t]++;
	}
  }
  for (auto i = a.begin(); i != a.end(); i++) {
	if (i->first == 0 && i->second != 1) {
	  valid = false;
	}
	if (i->first != 0 && i->second != 2) {
	  valid = false;
	}
  }
  if (!valid) {
	cout << 0 << endl;
	return 0;
  }
  else {
	const int mod = 1e9 + 7;
	long long ans = 1;
	for (int i = 0; i < n / 2; i++) {
	  ans = ans * 2 % mod;
	}
	cout << ans << endl;
	return 0;
  }
  return 0;
}



Measured memory_bytes: 2560
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
typedef unsigned long long ull ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define rrep(i , n) for ( int i = n-1; i >=0 ; i--)

#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	ull size_; 
	std::vector<ull> par, rank, count;

public:
	UnionFind() : size_(0), par(std::vector<ull>()), rank(std::vector<ull>()), count(std::vector<ull>()) {};
	UnionFind(ull size__) : size_(size__) {
		par.resize(size_); rank.resize(size_); count.resize(size__);
		for (ull i = 0; i < size_; i++) par[i] = i, rank[i] = 0, count[i] = 1;
	}
	ull size() { return size_; }
	// ull root(ull x) { return par[x] == x ? x : par[x] = root(par[x]); }
	
	ull root(ull x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	
	bool same(ull x, ull y) { return root(x) == root(y); }

	void unite(ull x, ull y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y, count[y]+=count[x], count[x]=0;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++, count[x]+=count[y], count[y]=0;
		else par[y] = x, count[x] += count[y], count[y] = 0;
	}

	ull size__(ull x)
	{
		return count[root(x)];
	}

	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};
/*
maybe sth wrong 
got wa in one problem
*/
ll modpow(ll a, ll b)
{
	if (b == 0)
	{
		return 1;
	}

	if (b % 2)
	{
		return a * modpow(a, b-1) % MOD;
	}
	else
	{
		ll halfB = b / 2;
		ll half = modpow(a, halfB);
		return half * half % MOD;
	}
}

ll calcComb(ll n, ll m)
{
	if (m > n-m)
	{
		return calcComb(n, n-m);
	}

	ll ansMul = 1;
	ll ansDiv = 1;

	rep(i, m)
	{
		ansMul *= (n-i);
		ansDiv *= (i+1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}

	return ansMul * modpow(ansDiv, MOD - 2) % MOD;
}

__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}


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

	string s;

	cin >> s;

	int gr = 1;
	char pre = s[0];

	for (int i = 1; i < N; i++)
	{
		if (s[i] != pre)
		{
			gr++;
			pre = s[i];
		}
	}
	
	rep(i, K)
	{
		if (gr >= 3)
		{
			gr -= 2;
		}
		else
		{
			gr = 1;
		}
		
	}

	cout << N - gr << endl;
	return 0;
}


Measured memory_bytes: 512
import Control.Applicative
import Control.Monad
main = do
  [h, w] <- map (read :: String -> Int) . words <$> getLine
  if h == 0 && w == 0
    then return [()]
    else do
      putStrLn $ replicate w '#'
      replicateM (h - 2) . putStrLn $ "#" ++ (replicate (w - 2) '.') ++ "#"
      putStrLn $ replicate w '#'
      putStrLn ""
      main

Measured memory_bytes: 4116
#include<stdio.h>

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

    scanf("%d",&n);

    if(1<=9&&n<=9){
        printf("%d\n",n);
    }else if(10<=n&&n<=99){
        printf("9\n");
    }else if(100<=n&&n<=999){
        printf("%d\n",10+n-100);
    }else if(1000<=n&&n<=9999){
        printf("909\n");
    }else if(10000<=n&&n<=99999){
        printf("%d\n",910+n-10000);
    }else{
        printf("90909\n");
    }




    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int t[100];
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  int m;
  cin >> m;
  int p[100], x[100];
  for (int i = 0; i < m; i++) {
    cin >> p[i] >> x[i];
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += t[i];
  }
  for (int i = 0; i < m; i++) {
    cout << sum - t[p[i] - 1] + x[i] << endl;
  }
}

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

int main() {
  long long N,O;
  cin >> N;
  O = 0;
  for(int i = 1;i <= N;i++){
    if(i%3 != 0 && i%5 != 0){
      O += i;
    }
  }
  cout << O <<endl;
}

Measured memory_bytes: 3464
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	int N, i, j,  sum, min=1000000001;
	int x[100];
	
	scanf("%d", &N);
	lop(i, N){
		scanf("%d", &x[i]);
		}
	
	int L=x[0], R=x[0];
	
	for(i=1; i<N; i++){
		if(L>x[i])L=x[i];
		if(R<x[i])R=x[i];
	}
	
	for(i=L; i<=R; i++){
		sum=0;
		lop(j, N){
			sum+=pow(x[j]-i, 2);
		}
		if(min>sum)min=sum;
	}
	
	printf("%d", min);
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
  int n,m;
  int min;
  int i,j,k;
  int ans_h,tmp_h;
  int xxx=0,flag=0;
  int x[100],y[100],h[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d",&x[i],&y[i],&h[i]);
  }
  for(i=0;i<101;i++){
    for(j=0;j<101;j++){
      flag=0;
      for(k=0;k<n;k++){
	if(h[k]!=0){
	  if(flag==0){
	    tmp_h=h[k]+abs(x[k]-i)+abs(y[k]-j);
	    flag=1;
	  }else{
	    if(tmp_h!=h[k]+abs(x[k]-i)+abs(y[k]-j)){
	      flag=2;
	      break;
	    }
	  }
	}
      }
      for(k=0;k<n;k++){
	if(h[k]==0){
	  if(h[k]<tmp_h-abs(x[k]-i)-abs(y[k]-j)){
	    flag=2;
	  }
	}
      }
      if(flag==1){
	printf("%d %d %d\n",i,j,tmp_h);
	return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 128
use std::io::stdin;
fn get_string() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

macro_rules! input {
    ($single:ty) => ( get_string().parse::<$single>().unwrap() );
    ($plural:ty,) => ({
        let line = get_string();
        line.split_whitespace().map(|v| v.parse::<$plural>().unwrap()).collect::<Vec<$plural>>()
    });
    ($($plural:ty),+) => ({
        let line = get_string();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$plural>().unwrap()),+)
    });
    ($single:ty; $times:expr) => ( (0..$times).map(|_| input!($single)).collect::<Vec<$single>>() );
    ($($plural:ty),+; $times:expr) => ( (0..$times).map(|_| input!($($plural),+)).collect::<Vec<($($plural),+)>>() );
}

#[allow(dead_code)]
fn get_value<T: std::str::FromStr>() -> T {
    get_string().parse().ok().unwrap()
}
#[allow(dead_code)]
fn get_values_for<T: std::str::FromStr>(times: u64) -> Vec<T> {
    (0..times).map(|_| get_value()).collect()
}
#[allow(dead_code)]
fn get_vector<T: std::str::FromStr>() -> Vec<T> {
    get_string()
        .split_whitespace()
        .map(|v| v.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn get_vectors_for<T: std::str::FromStr>(times: u64) -> Vec<Vec<T>> {
    (0..times).map(|_| get_vector()).collect()
}

fn main() {
    let _n = input!(u64);
    let a = input!(u64,);

    let ans = a.into_iter().fold(0, |sum, x| sum + x - 1);
    println!("{}", ans);
}


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

struct node{
	struct node *right;
	struct node *left;
	struct node *parent;
	int key;
};
typedef struct node *Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
	while (x->left != NIL) x = x->left;
	return x;
}

Node treeSearch(Node u, int k){
	while (u != NIL && k != u->key){
		if (k < u->key) u = u->left;
		else u = u->right;
	}
	return u;
}

Node treeSuccessor(Node x){
	if (x->right != NIL) return treeMinimum(x->right);
	Node y = x->parent;
	while ( y != NIL && x == y ->right ) {
		x = y;
		y = y->parent;
	}
	return y;
}

void treeDelete(Node z){
	Node y; // node to be deleted
	Node x; // child of y

	if ( z->left == NIL || z->right == NIL ) y = z;
	else y = treeSuccessor(z);
	if (y->left != NIL) {
		x = y->left;
	} else {
		x = y->right;
	}

	if ( x != NIL ) {
		x->parent =  y ->parent;
	}

	if ( y->parent == NIL ) {
		root = x;
	} else {
		if (y == y->parent->left) {
			y->parent->left = x;
		} else {
			y->parent->right = x;
		}
	}

	if ( y != z ) {
		z->key = y->key;
	}

	free(y);
}

void insert(int k){
	Node y = NIL;
	Node x = root;
	Node z;

	z = malloc(sizeof(struct node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL){
		y = x;
		if (z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}

	z->parent = y;
	if (y == NIL) {
		root = z;
	} else {
		if (z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}

}

void inorder(Node u){
	if (u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node u){
	if (u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

int main(){
	int n, i, x;
	char com[20];
	scanf("%d", &n);

	for ( i = 0; i < n; i++ ){
		scanf("%s", com);
	if ( com[0] == 'f' ){
		scanf("%d", &x);
		Node t = treeSearch(root, x);
			if ( t != NIL ) printf("yes\n");
			else printf("no\n");
		} else if ( com[0] == 'i' ){
			scanf("%d", &x);
			insert(x);
		} else if ( com[0] == 'p' ){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		} else if ( com[0] == 'd' ){
			scanf("%d", &x);
			treeDelete(treeSearch(root, x));
		}
	}

return 0;
}


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

using namespace std;

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

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

    int n, a, b;
    cin >> n >> a >> b;
    cout << (n * a < b ? n * a : b) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MAX_DIST 99999999999999LL

class Dijkstra{
public:
    struct edge{
        ll to;
        ll cost;
    };
    int vertex;
    vector<vector<edge>> graph;
    vector<ll> dist;

    Dijkstra(ll n){
        vertex = n;
        graph = vector<vector<edge>>(n);
        dist = vector<ll>(n);
    };

    void dijkstra(int s){
        priority_queue<pll, vector<pll>, greater<pll>> que;
        fill(dist.begin(), dist.end(), MAX_DIST);
        dist[s] = 0;
        que.push(pll(0, s));

        while (!que.empty()){
            pll p = que.top();  //cost/to
            que.pop();
            int v = p.second;
            if (dist[v] < p.first) continue;
            for (int i = 0; i < graph[v].size(); i++) {
                edge e = graph[v][i];
                if (dist[e.to] > dist[v] + e.cost && !(dist[e.to] == MAX_DIST && dist[v] == MAX_DIST)){
                    dist[e.to] = dist[v] + e.cost;
                    que.push(pll(dist[e.to], e.to));
                }
            }
        }

    }

    void addEdge(ll from, ll to, ll cost) {
        edge e;
        e.to = to;
        e.cost = cost;
        graph[from].push_back(e);
    }
};

int main() {
    ll e, v, s, t;
    cin >> v >> e >> s >> t;
    s--; t--;
    Dijkstra si(v);
    Dijkstra ti(v);
    for(int i = 0; i < e; i++){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        si.addEdge(a,b,c);
        si.addEdge(b,a,c);
        ti.addEdge(a,b,d);
        ti.addEdge(b,a,d);
    }

    si.dijkstra(s);
    ti.dijkstra(t);
    vector<ll> st(v);
    vector<ll> ans(v);
    for(int i = 0; i < v; i++){
        st[i] = si.dist[i] + ti.dist[i];
    }
    ans[v-1] = st[v-1];
    for(int i = v-2; i >= 0; i--){
        ans[i] = min(st[i],ans[i+1]);
    }

    for(int i = 0; i < v; i++){
        printf("%.0f\n",1e15-ans[i]);
    }

    return 0;
}


Measured memory_bytes: 19780
md = 10 ** 9 + 7
s = input()
n = len(s)
dp = [[1, 0] for _ in range(n + 1)]
for i, c in enumerate(s):
    dpi = dp[i]
    if c == "0":
        dp[i + 1] = [dpi[0], dpi[1] * 3 % md]
    else:
        dp[i + 1] = [dpi[0] * 2 % md, (dpi[1] * 3 + dpi[0]) % md]
print(sum(dp[-1]) % md)


Measured memory_bytes: 19700
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool HN(ll n)
{
    ll sum = 0;
    ll num = n;
    while(num){
        ll rem = num % 10;
    sum = sum + rem;
    num = num / 10;
    }
   // printf("%lld\n",sum);
   // printf("%lld\n",n);
    if(n % sum == 0)
        return true;

    return false;
}
int main()
{
    ll n;
    scanf("%lld",&n);

    ll res = HN(n);

    if(res == 1){
        printf("Yes\n");
    }
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=200000+100,bas=100001;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int n,l[N],r[N];
vi ql[N],qr[N];
bool vis[N];

ll solve(int op)
{
    rep(i,1,bas*2) {ql[i].clear();qr[i].clear();}
    rep(i,1,n)
    {
        vis[i]=0;
        ql[l[i]].pb(i);
        qr[r[i]].pb(i);
    }
    int pl=bas*2,pr=0,pos=bas;ll ans=0;
    while (1)
    {
        if (op)
        {
            while ((pl>pos) && ((ql[pl].empty()) || (vis[ql[pl].back()])))
            {
                if (ql[pl].empty()) pl--;
                else if (vis[ql[pl].back()]) ql[pl].pop_back();
            }
            if (pl<=pos) break;
            ans+=(pl-pos);vis[ql[pl].back()]=1;pos=pl;
        }
        else
        {
            while ((pr<pos) && ((qr[pr].empty()) || (vis[qr[pr].back()])))
            {
                if (qr[pr].empty()) pr++;
                else if (vis[qr[pr].back()]) qr[pr].pop_back();
            }
            if (pr>=pos) break;
            ans+=(pos-pr);vis[qr[pr].back()]=1;pos=pr;
        }
        op^=1;
    }
    ans+=abs(pos-bas);
    return ans;
}       

int main()
{
    n=read();
    rep(i,1,n) {l[i]=read()+bas;r[i]=read()+bas;}
    printf("%lld\n",max(solve(0),solve(1)));
    return 0;
}

Measured memory_bytes: 15360