akhauriyash/Code-Regression huggingface dataset:
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
struct circle { double x, y, r; };
int n; circle x[100009];
bool operator<(const circle& c1, const circle& c2) {
	return c1.x - c1.r < c2.x - c2.r;
}
int main() {
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			scanf("%lf%lf%lf", &x[i].r, &x[i].x, &x[i].y);
			double ex = x[i].x * 0.28 - x[i].y * 0.96;
			double ey = x[i].x * 0.96 + x[i].y * 0.28;
			x[i].x = ex, x[i].y = ey;
		}
		sort(x, x + n);
		double ret = 1.0e+9;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (x[i].x + x[i].r + ret < x[j].x - x[j].r) break;
				double dist = hypot(x[i].x - x[j].x, x[i].y - x[j].y) - x[i].r - x[j].r;
				ret = min(ret, dist);
			}
		}
		printf("%.15lf\n", ret);
	}
	return 0;
}

Measured memory_bytes: 5628
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
       
        Scanner scan = new Scanner(System.in);
        
        String N = scan.next();
        String A = scan.next();
        //String  = scan.next();
        
        //int  = Integer.parseInt(r) * 100 + Integer.parseInt(g) * 10 + Integer.parseInt(b);
        // N円500で割ったとき、あまりーA円＞0以下ならおｋ
        if((Integer.parseInt(N) % 500) - Integer.parseInt(A) <= 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35488
program main
implicit none
character(100) ::S
integer :: count = 0
integer :: n

read *,S
n = len_trim(S)

if(S(1:1)=="k")      count = count + 1
if(S(1:2)=="ke")     count = count + 1
if(S(1:3)=="key")    count = count + 1
if(S(1:4)=="keye")   count = count + 1
if(S(1:5)=="keyen")  count = count + 1
if(S(1:6)=="keyenc") count = count + 1
if(S(1:7)=="keyence")count = count + 1

if(S(n-0:n)==      "e")count = count + 1
if(S(n-1:n)==     "ce")count = count + 1
if(S(n-2:n)==    "nce")count = count + 1
if(S(n-3:n)==   "ence")count = count + 1
if(S(n-4:n)==  "yence")count = count + 1
if(S(n-5:n)== "eyence")count = count + 1
if(S(n-6:n)=="keyence")count = count + 1

if ( count > 6 ) then
print *, "YES"
else
print *, "NO"
end if

end program main

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long k,a,b;
    cin >> k >> a >> b;
    if(a>=b||k+1<=a) cout << k+1 << endl;
    else
    {
        k-=(a-1);
        long long c=(k/2)*(b-a)+a;
        if(k&1) c++;
        cout << max(c,k+a) << endl;
    }
    return 0;
}


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

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < t.length(); i++) {
		s += s[0];
		s = s.substr(1);
		if (s == t) break;
	}
	cout << (s == t ? "Yes" : "No") << endl;
	return 0;
}


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

void defining_lists(vector<char> &lists, int N){
    for (int i = 0; i < N; i++){
        char element;
        cin >> element;
        lists.push_back(element);
    }
}

int main(){
    int N;
    vector <char> A, B, C;
    vector <char> &rA = A;
    vector <char> &rB = B;
    vector <char> &rC = C;
    cin >> N;
    defining_lists(rA, N);
    defining_lists(rB, N);
    defining_lists(rC, N);
    int count = 0;
    for (int i = 0; i < N; i++){
        vector<char> vec;
        vec.push_back(A[i]);
        vec.push_back(B[i]);
        vec.push_back(C[i]);
        sort(vec.begin(), vec.end());
        vec.erase( unique(vec.begin(), vec.end()), vec.end() );
        int size = vec.size();
        if (size == 3){
            count += 2;
        }else if (size == 2){
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}

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

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

    long long int ans = 0;
    /*
    for (int i = 0; i < n; ++i) {
        const int c = min(a[i], b[i]);
        b[i] -= c;
        ans += c;
        const int d = min(a[i+1], b[i]);
        a[i+1] -= d;
        ans += d;
    }
    /*/
    for (int i = n-1; i >= 0; --i) {
        const int c = max(0, b[i] - a[i+1]);
        ans += b[i] - c;
        ans += min(a[i], c);
        a[i] = max(0, a[i] - c);
    }
    //*/
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <atcoder/dsu>
#define mp make_pair
#define fi first
#define se second
#define INF 10000000000000000LL
#define ll  long long 
const long long  inf =1e18+44;
const int MAX=3e5+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=1e6+9;
const int MAX_A=71;
const int LN=20;
const double eps=1e-1;
using namespace std;
using namespace atcoder;
int dp[2000][2000];
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int q , n;
    cin>>q>>n;
    auto t = dsu(q+9);
    while(n--){
        int type , a, b;
        cin>>type>>a>>b;
        if ( type==0)
            t.merge(a, b);
        else
        {
            if(t.same(a,b))
                cout<<1<<endl;
            else
                cout<<0<<endl;
        }
    }

}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void uniq(vector<int> &vec){sort(vec.begin(), vec.end());vec.erase(unique(vec.begin(), vec.end()), vec.end());}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}


signed main(){start();
    int x,a;
    cin>>x>>a;
    if(x<a) cout<<0<<endl;
    else cout<<10<<endl;
    return 0;
}


Measured memory_bytes: 256
local mfl, mce = math.floor, math.ceil
local mmi, mma = math.min, math.max
local bls, brs = bit.lshift, bit.rshift
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    local cnt = bls(1, i - 1)
    for j = 1, cnt do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, n, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.stage = {{}}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.stage[stagenum] = {}
  end
  self.stagenum = stagenum
  self.left_stage = {}
  for i = 1, n do
    local sp, sz = 1, bls(1, stagenum - 1)
    while(i - 1) % sz ~= 0 do
      sp, sz = sp + 1, brs(sz, 1)
    end
    self.left_stage[i] = sp
  end
  self.sz_stage = {}
  local tmp, sp = 1, stagenum
  for i = 1, n do
    if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end
    self.sz_stage[i] = sp
  end
  for i = 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local stagenum = self.stagenum
  local ret = self.emptyvalue
  while left <= right do
    local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])
    local sz = bls(1, stagenum - stage)
    ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])
    left = left + sz
  end
  return ret
end
SegTree.incValue = function(self, idx)
  self.stage[self.stagenum][idx] = self.stage[self.stagenum][idx] + 1
  for i = self.stagenum - 1, 1, -1 do
    local dst = brs(idx + 1, 1)
    local rem = dst * 4 - 1 - idx
    self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
    idx = dst
  end
end
SegTree.new = function(n, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n, func, emptyvalue)
  return obj
end

local n, k = io.read("*n", "*n")
local t = {}
local sum = {}
local cur = 0
sum[cur] = true
for i = 1, n do
  t[i] = io.read("*n") - k
  cur = cur + t[i]
  sum[cur] = true
end
local uniq = {}
for k, v in pairs(sum) do
  table.insert(uniq, k)
end
table.sort(uniq)
local uniqinv = {}
for i = 1, #uniq do
  uniqinv[uniq[i]] = i
end

local st = SegTree.new(#uniq, function(a, b) return a + b end, 0)
st:incValue(uniqinv[0])
cur = 0
local ret = 0
for i = 1, n do
  cur = cur + t[i]
  local pos = uniqinv[cur]
  ret = ret + st:getRange(1, pos)
  st:incValue(pos)
end
print(ret)


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

int n, k, h[200005], dp[200005];

int fn(int i) {
    if (i <= 0) return 0;
    if (i == 1) return abs(h[1] - h[0]);
    if (~dp[i]) return dp[i];
    dp[i] = fn(i - 1) + abs(h[i] - h[i - 1]);
    for (int t = 2; t <= k; ++t) {
        if (i - t >= 0) 
        dp[i] = min(dp[i], fn(i - t) + abs(h[i] - h[i - t]));
    }
    return dp[i]; 
}

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &h[i]);
    }
    memset(dp, -1, sizeof dp);
    printf("%d\n", fn(n - 1));
    return 0;
}

Measured memory_bytes: 4608
A, B, C, X = [int(input()) for x in range(4)]
cnt = 0

for a in range(A+1):
    x = X - 500*a
    if x < 0:
        break
    for b in range(B+1):
        y = x - 100*b
        if y < 0:
            break
        else:
            if y/50 <= C:
                cnt += 1
print(cnt)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<bool> vb;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sq(x) ((x)*(x))
#define fo(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<n;i++)
#define Fo(i,n) for(int i=1;i<=n;i++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<"\n"
#define fi first
#define se second
const double pi = 3.14159265358979323846;
#define uni(c) (c).resize(unique(all(c))-(c).begin())
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
//pair <int, int> w[4] = {mp(-1, 0), mp(0, -1), mp(1, 0), mp(0, 1)};   // for matrix movement:
void cp()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
const int mod = 1e9 + 7;
void solve()
{
    ll n; cin >> n;
    ll a[n];
    fo(i, n)cin >> a[i];
    ll cur = 0;
    ll ans = 0;
    for (int i = n - 2; i >= 0; i--)
    {
        cur += a[i + 1];
        cur %= mod;
        ans += (a[i] * cur) % mod;
        ans %= mod;
    }
    cout << ans;
}
int main()
{
    fast;
    //cp();
    ll t = 1;
    //cin >> t;
    while (t--)
        solve();


    return 0;
}

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

int main() {
    long long N;
    cin >> N;
    string  S;
    cin >> S;
    char A = 'A';
    char B = 'B';
    char C = 'C';
    long long sum = 0;
    for (long long i = 0; i + 2 < N; ++i) {
        if (S[i] == A) {
            if (S[i + 1] == B) {
                if (S[i + 2] == C) {
                    sum += 1;
                }
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
from operator import itemgetter
N = int(input())
S = []
P = []
Num = []
for _ in range(N):
    S1, P1 = [_ for _ in input().split()]
    Num.append(_)
    S.append(S1)
    P.append(P1)
P = [int(_) for _ in P]

c = zip(Num, S, P)
c = sorted(c, key=itemgetter(2), reverse=True)
c = sorted(c, key=itemgetter(1))
Num, S2, P2 = zip(*c)
for i in Num:
    print(i+1)


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

using ll = int_fast64_t;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define repr(i,n) for(int i{n};i-->0;)
template<int64_t MOD>
struct mod_int{
  int64_t val;
  constexpr mod_int():val(0){}constexpr mod_int(int64_t x)noexcept:val(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD){}
  constexpr int64_t value()const noexcept{return val;}constexpr int64_t get_MOD()const noexcept{return MOD;}
  constexpr mod_int operator+(mod_int const& rhs){return mod_int(*this)+=rhs;}
  constexpr mod_int operator-(mod_int const& rhs){return mod_int(*this)-=rhs;}
  constexpr mod_int operator*(mod_int const& rhs){return mod_int(*this)*=rhs;}
  constexpr mod_int operator/(mod_int const& rhs){return mod_int(*this)/=rhs;}
  constexpr mod_int &operator++(int _){val += 1;if(val>MOD)val-=MOD;return *this;}
  constexpr mod_int &operator++(){val += 1;if(val>MOD)val-=MOD;return *this;}
  constexpr mod_int &operator--(int _){val -= 1;if(val<0)val+=MOD;return *this;}
  constexpr mod_int &operator--(){val -= 1;if(val<0)val+=MOD;return *this;}
  constexpr mod_int &operator+=(mod_int const& rhs)noexcept{val += rhs.val;if(val>=MOD)val-=MOD;return *this;}
  constexpr mod_int &operator-=(mod_int const& rhs)noexcept{if(val<rhs.val)val+=MOD;val-=rhs.val;return *this;}
  constexpr mod_int &operator*=(mod_int const& rhs)noexcept{(val*=rhs.val)%=MOD;return *this;}
  constexpr mod_int &operator/=(mod_int rhs)noexcept{*this*=rhs.inverse();return *this;}
  constexpr friend std::ostream &operator<<(std::ostream& os, mod_int const& mi){return os<<mi.val;}
  constexpr friend std::istream &operator>>(std::istream& is, mod_int & mi){int64_t t=0;is>>t;mi = mod_int<MOD>(t);return is;}
  constexpr mod_int inverse(){int64_t a=val,b=MOD,u=1,v=0,t=0;while(b>0){t=a/b;std::swap(a-=t*b,b);std::swap(u-=t*v,v);}return mod_int(u);}
  constexpr mod_int mpow(int64_t n)const{mod_int res(1),e(*this);while(n){if(n&1)res*=e;e*=e;n>>=1;}return res;}
};
using mint = mod_int<1000000007>;

signed main(){

  int n,m;
  cin>>n>>m;
  vector<int> s(n),t(m);
  rep(i,n)cin>>s[i];
  rep(j,m)cin>>t[j];

  vector<vector<mint>> dp(n+1,vector<mint>(m+1));
  vector<vector<mint>> sum(n+1,vector<mint>(m+1));
  dp[0][0] = 1;
  rep(i,n)rep(j,m){
    if(s[i]==t[j]){
      dp[i+1][j+1] = sum[i][j] + 1;
    }
    sum[i+1][j+1] = sum[i+1][j]+sum[i][j+1]-sum[i][j];
    sum[i+1][j+1] += dp[i+1][j+1];
  }
  
  mint ans = 0;
  for(auto vec:dp)
    for(auto val:vec)
      ans += val;
  cout<<(ans)<<endl;

}

Measured memory_bytes: 66012
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
#define LL long long
#define LD long double
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pii pair<int,int>
#define pli pair<LL,int>
#define pil pair<int,LL>
#define pll pair<LL,LL>
#define ff first
#define ss second
#define pb push_back
#define BTW(x,a,b) ((a) <= (x) && (x) <= (b))
#define _eq(a,b) (fabs((a)-(b)) < EPS)
#define _lt(a,b) (fabs((a)-(b)) > EPS && a < b)
#define _gt(a,b) (fabs((a)-(b)) > EPS && a > b)
#define _lte(a,b) !_gt(a,b)
#define _gte(a,b) !_lt(a,b)
const vector<pii> XY = {pii(0,-1),pii(0,1),pii(-1,0),pii(1,0)};
const LD EPS = 1e-8;
const LD PI = acos(-1.0L);
const LL INFLL =  4e18;
const int INF  =  2e9;
const int MOD  =  1e9 + 7;
//#define int long long

// read / write
template<typename T> void read(T& t) { cin >> t; }
template<typename T, typename ... U> void read(T& t, U& ... u) { read(t); read(u ...); }
template<typename T> void write(T t) { cout << t; }
template<typename T, typename ... U> void write(T t, U ... u) { write(t); write(u ...); }



// ------------------------------------------------- Vs
const int LOGN    =  16              + 1;
const int MAXN1   =  3e5            + 3;
const int MAXN2   =  8            + 3;
// ------------------------------------------------- Fs
int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); write(fixed, setprecision(12));
    int n; read(n);
    int n1=0,n2=0,n3=0;
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        string s; read(s);
        for(int j = 0; j + 1 < sz(s); ++j) ans += s[j]=='A'&&s[j+1]=='B';
        bool b1 = s.back()=='A';
        bool b2 = s.front()=='B';
        if(b1&&b2) ++n1;
        else if(b1) ++n2;
        else if(b2) ++n3;
    }
    
    if(n1 == 0) ans += min(n2,n3);
    else{
        ans += n1 - 1;
        if(n2) ++ans,--n2;
        if(n3) ++ans,--n3;
        ans += min(n2,n3);
    }

    write(ans, "\n");
    return 0;
}

Measured memory_bytes: 256
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N = int(readline())
    judge_dic = {"AC":0,"WA":0, "TLE":0, "RE":0}
    for _ in range(N):
        S = input()
        for k in judge_dic.keys():
            if k == S:
                judge_dic[k] += 1
    print("AC x {0}".format(judge_dic["AC"]))
    print("WA x {0}".format(judge_dic["WA"]))
    print("TLE x {0}".format(judge_dic["TLE"]))
    print("RE x {0}".format(judge_dic["RE"]))


if __name__ == '__main__':
    solve()

Measured memory_bytes: 10544
import sys
input = sys.stdin.readline

def main():
    N, K = list(map(int, input().split()))

    ans = 0
    for i in range(1, N+1):
        t = 0
        while i < K:
            i *= 2
            t += 1

        ans += 0.5 ** t

    print(ans * (1 / N))


if __name__ == '__main__':
    main()

Measured memory_bytes: 39024
let s = read_line ()
let n, fs, i = Array.(String.length s, make 26 false, ref 0)
let f s n = Printf.printf "%s%c\n" s (Char.chr (n + 97)); exit 0
let _ = String.(Char.(iter (fun c -> fs.(code c - 97) <- true) s; if n < 26 then (while fs.(!i) do incr i done; f s !i);
  for j = n - 1 downto 0 do i := code s.[j] - 96; while !i < 26 && fs.(!i) do incr i done; if !i < 26 then f (sub s 0 j) !i; fs.(code s.[j] - 97) <- false done; print_endline "-1"))

Measured memory_bytes: 384
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
        for j in range(W):
            if i == 0 or i == H-1 or j == 0 or  j == W-1:
                print("#",end="")
            else:
                print(".",end="")
        print()
        
    print()


Measured memory_bytes: 7000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			while (true)
			{
				int x = int.Parse(Console.ReadLine());
				int h = int.Parse(Console.ReadLine());
				if (x == 0 && h == 0) break;
				double s = x * Math.Sqrt(4 * h * h + x * x) + x * x;
				Console.WriteLine(s);
			}
		}
	}
}

Measured memory_bytes: 5628
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int man = 2e5+10;
#define IOS ios::sync_with_stdio(0)
#define ull unsigned ll
#define uint unsigned
#define pai pair<int,int>
#define pal pair<ll,ll>
#define IT iterator
#define pb push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);++i)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);--i)
#define endl '\n'
#define ll long long
const ll mod = 1e9+7;

signed main() {
    #ifndef ONLINE_JUDGE
        //freopen("in.txt", "r", stdin);
        //freopen("out.txt","w",stdout);
    #endif
    int n;
    cin >>n;
    int tp = 0;
    for(int i = 1;i <= 2e6;++i){
        tp = tp*10 + 7;
        tp %= n;
        if(!tp){
            return cout<<i<<endl,0;
        }
    }cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3592
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1001001001;
const ll LONGINF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<int> B(N-1);
    for(int i=0; i+1<N; i++) cin >> B[i];

    int ans = B.front() + B.back();
    for(int i=1; i+1<N; i++) {
        int vl = B[i-1];
        int vr = B[i  ];
        ans += min(vl, vr);
    }
    cout << ans << endl;
    return 0;
}


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

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

int main(){
  string s;
  int ans = 0;
  cin >> s;
  rep(i,3){
    if(s[i]=='1')ans++;
  }
  cout << ans << endl;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    
    int h[N];
    rep(i,N) cin >> h[i];
    
    int count=0;
    
    rep(i,N){
        if(h[i] >= K){
            count++;
        }
        
    }
    
    cout << count << endl;
    
    return 0;
}
    

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>

using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)

int main()
{
    char c;
    cin>>c;
    cout<<(char)(c+1)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int,int>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
#define YesNo(a) cout<<((a)?"Yes":"No")<<endl
#define YESNO(a) cout<<((a)?"YES":"NO")<<endl

int main(){
	int ans = 100000,N;
	cin >> N;
	FOR(i,0,N){
		int A,cnt=0;
		cin >> A;
		while(A%2==0){
			A /= 2;
			cnt++;
		}
		ans = min(ans,cnt);
	}
	cout << ans << endl;
}


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

int main() {
    int X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
    int p[A + 1], q[B + 1], r[C + 1];
    for (int i = 0; i < A; i++) cin >> p[i];
    for (int i = 0; i < B; i++) cin >> q[i];
    for (int i = 0; i < C; i++) cin >> r[i];
    sort(p, p + A), sort(q, q + B);

    vector<int> v;
    for (int i = 0; i < X; i++) v.push_back(p[A - i - 1]);
    for (int i = 0; i < Y; i++) v.push_back(q[B - i - 1]);
    for (int i = 0; i < C; i++) v.push_back(r[i]);
    sort(v.begin(), v.end());

    long long ans = 0;
    for (int i = 0; i < X + Y; i++) ans += v[v.size() - i - 1];
    cout << ans << endl;
}


Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();

		StringBuffer sb = new StringBuffer();
		for(int i = S.length(); i > 0; i--) {
			sb.append(S.charAt(i - 1));
		}
		String R = sb.toString();

		int len = S.length();

		String start = S.substring(0, (len - 1) / 2);
		StringBuffer str = new StringBuffer();
		for(int i = start.length(); i > 0; i--) {
			str.append(start.charAt(i - 1));
		}
		String checkStart = str.toString();

		String end = S.substring((len + 3) / 2 - 1, len);
		StringBuffer en = new StringBuffer();
		for(int i = end.length(); i > 0; i--) {
			en.append(end.charAt(i - 1));
		}
		String checkEnd = en.toString();


		if(len > 5) {
			if(S.equals(R) && start.equals(checkStart) && end.equals(checkEnd)) {
				System.out.println("Yes");
				return;
			}else {
				System.out.println("No");
				return;
			}
		}else if(len == 5) {
			if(S.equals(R) && S.charAt(0) == S.charAt(1) && S.charAt(3) == S.charAt(4)) {
				System.out.println("Yes");
				return;
			}else {
				System.out.println("No");
				return;
			}
		}else {
				System.out.println("Yes");
				return;
		}
	}

}

Measured memory_bytes: 21844
#include<iostream>
#include<sstream>
#include<iomanip>
#include<stdlib.h>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<utility>
#include<algorithm>
#include<complex>
using namespace std;
#define loop(i,l,r) for(int (i)=(int)(l);(i)<(int)(r);(i)++)
#define rloop(i,l,r) for(int (i)=(int)(l);(i)>(int)(r);(i)--)
#define rep(i,n) loop(i,0,n)
#define rrep(i,n) rloop(i,n-1,-1)
#define INF 0x3f3f3f3f
#define mod 1000000007LL
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef complex<double> C;

int main(){
		int N,M,d,dd;
		cin>>N>>M;
		vector<int> a(N+1,1),b(N+1,0);
		b[1]=1;
		rep(i,M){
				cin>>d>>dd;
				a[d]--;
				a[dd]++;
				if(b[d])b[dd]=1;
				if(a[d]==0)b[d]=0;
		}
		int res=0;
		loop(i,1,N+1){
				if(b[i])res++;
		}
		cout<<res<<endl;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
// using mP = pair<modint, modint>;

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


int H, W;
vector<vec> v;
void dfs(int h, int w){
	if(v[h][w] == 0) return;
	v[h][w] = 0;

	Rep1(i, -1, 1){
		Rep1(j, -1, 1){
			if(h+i < 0 || h+i > H-1 || w+j < 0 || w+j > W-1) continue;
			dfs(h+i, w+j);
		}
	}
}

void solve() {
    while(true){
        cin >> W >> H;
        if(H == 0 && W == 0)break;

		vector<vec> tmp(H, vec(W));
		rep(i, H){
			rep(j, W){
				int a; cin >> a;
				tmp[i][j] = a;
			}
		}
		v = tmp;

		int res = 0;
		rep(i, H){
			rep(j, W){
				if(v[i][j] == 1){
					dfs(i, j);
					res++;
				}
			}
		}
		cout << res << endl;
	}
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}



Measured memory_bytes: 7420
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; string S; cin >> N >> S;
  vector<int> R(N, 0);
  vector<int> G(N, 0);
  vector<int> B(N, 0);
  REP(i, N){
    if(S[i] == 'R'){
      if(i != 0){
        R[i] = R[i-1] + 1;
        G[i] = G[i-1];
        B[i] = B[i-1];
      }else{
        R[i]++;
      }
    }
    if(S[i] == 'G'){
      if(i != 0){
        G[i] = G[i-1] + 1;
        R[i] = R[i-1];
        B[i] = B[i-1];
      }else{
        G[i]++;
      }
    }
    if(S[i] == 'B'){
      if(i != 0){
        B[i] = B[i-1] + 1;
        G[i] = G[i-1];
        R[i] = R[i-1];
      }else{
        B[i]++;
      }      
    }
  }
  ll ans = 0;
  REP(i, N-2){
    for(int j = i+1; j < N-1; j++){
      if(S[i] == 'R'){
        if(S[j] == 'G'){
          ans += B[N-1] - B[j]; // RGB
          if(2*j-i <= N-1 && S[2*j-i] == 'B') ans--;
        }else if(S[j] == 'B'){
          ans += G[N-1] - G[j]; // RBG
          if(2*j-i <= N-1 && S[2*j-i] == 'G') ans--;
        }
      }else if(S[i] == 'G'){
        if(S[j] == 'R'){
          ans += B[N-1] - B[j]; // GRB
          if(2*j-i <= N-1 && S[2*j-i] == 'B') ans--;
        }else if(S[j] == 'B'){
          ans += R[N-1] - R[j]; // GBR
          if(2*j-i <= N-1 && S[2*j-i] == 'R') ans--;
        }
      }else if(S[i] == 'B'){
        if(S[j] == 'R'){
          ans += G[N-1] - G[j]; // BRG
          if(2*j-i <= N-1 && S[2*j-i] == 'G') ans--;
        }else if(S[j] == 'G'){
          ans += R[N-1] - R[j]; // BGR
          if(2*j-i <= N-1 && S[2*j-i] == 'R') ans--;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3672
#include <stdio.h>

int main(void) 
{
	int n, m, a[100][100], b[100], i, j, c;


	scanf("%d %d", &n, &m);

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}


	for (i = 0; i < m; i++)
	{
		scanf("%d", &b[i]);
	}


	for (i = 0; i < n; i++)
	{
		c = 0;

		for (j = 0; j < m; j++)
		{
			c = a[i][j] * b[j] + c;
		}

		printf("%d\n", c);
	}
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main() {
	int x;
	cin >> x;
	int res = 1;
	int a;
	int c = 0;
	int d = 0;
	//int c = pow(a, b);
	for (int i = 2; i < 32; ++i) {
		for (int j = 2; j < 10 ; ++j) {
			a = pow(i, j);
			//cout << a << endl;
			if (a <= x) {
				if (res < a) {
					res = a;
				}
			}else {
				d++;
				break;
			}
			c++;

		}
	}
	//cout << "c" << c << endl;
	//cout << "d" << d << endl;
	cout << res << endl;

	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    ll a[52];
    ll ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] > (n - 1) * n){
            ans += ((a[i] - (n - 1) * n - 1) / (n + 1)) * (n + 1);
            a[i] -= ((a[i] - (n - 1) * n - 1) / (n + 1)) * (n + 1);
        }
    }
    while(true){
        bool yet = false;
        for(int i = 0; i < n; i++){
            if(a[i] >= n){
                for(int j = 0; j < n; j++) a[j]++;
                a[i] -= n + 1;
                ans++;
                yet = true;
            }
        }
        if(!yet) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
		cout << fixed << setprecision( 10 );
	}

	void solve() {
		int X, Y, Z;
		cin >> X >> Y >> Z;
		cout << Z << ' ' << X << ' ' << Y << endl;
	}
};

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


Measured memory_bytes: 256
N = input()

Nl = len(N)
tmp = N[0] + '9'*(Nl-1)

if int(N) >= int(tmp):
    answer = int(N[0]) + 9*(Nl-1)
else:
    answer = int(N[0])-1 + 9*(Nl-1)
    
print(answer)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int f[200005];
int main() {
	int n;
	cin>>n;
	for(int i=1;i<n;i++){
		int k;
		cin>>k;
		f[k]++;
	}
	for(int i=1;i<=n;i++){
		cout<<f[i]<<endl;
	}

	return 0;
}


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

int main(){
    int n;cin>>n;
    map<int, int> friends;
    for (int i=0;i<n;i++){
        int target;cin>>target;
        friends[i+1] = target;
    }

    int acc = 0;
    for (auto like: friends){
        if (like.first == friends[like.second]){
            acc++;
        }
    }
    cout << acc / 2 << endl;
    return 0;
}

Measured memory_bytes: 4992
# include <stdio.h>

int main(void){
    int n,k,i,j,l,m;
    int sum = 0;

    scanf("%d", &n);
    scanf("%d", &k);

    int p[n];

    for(i=0; i<n; i++){
        scanf("%d", &p[i]);
    }

    for(j=0; j<n; j++){
        for(l=j+1; l<n; l++){
            if(p[j]>p[l]){
                int sort = p[j];
                p[j] = p[l];
                p[l] = sort;
            }
        }
    }
    for(m=0; m<k; m++){
        sum = sum + p[m];
    }
    printf("%d",sum);
}


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

int solve(vector<int>& heights, vector<int>& dp, int k, int idx) {
    if(idx >= int(heights.size()) - 1)
        return 0;

    if(dp[idx] == INT_MAX)
    {
        for(int j=1; idx+j<heights.size() && j<=k; ++j)
            dp[idx] = min(dp[idx], solve(heights, dp, k, idx+j)+abs(heights[idx]-heights[idx+j]));
    }
    
    return dp[idx];
}

int main() {
    int n, k;
    cin >> n >> k;

    vector<int> heights(n, 0);
    for(int i=0; i<n; ++i) cin >> heights[i];

    vector<int> dp(n, INT_MAX);
    cout << solve(heights, dp, k, 0);
    
    return 0;
}

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

int main(){
  ll N;cin>>N;
  map<ll,int> m;
  rep(i,N){
    ll k;cin>>k;
    if(m[k]==1) m[k]--;
    else m[k]=1;
  }
  ll ans=0;
  for(auto& x:m){
    ans += x.second;
  }
  cout<<ans<<endl;
}

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

using namespace std;

int main()
{
    const string unit[] = {"", "Man", "Oku", "Cho", "Kei", "Gai",
                           "Jo", "Jou", "Ko", "Kan", "Sei", "Sai", "Gok",
                           "Ggs", "Asg", "Nyt", "Fks", "Mts"};

    int M, N;
    while (cin >> M >> N, M) {
        int v[18] = {};
        v[0] = 1;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 18; j++) {
                v[j] *= M;
            }
            for (int j = 0; j < 18; j++) {
                int carry = v[j] / 10000;
                if (carry > 0) {
                    v[j+1] += carry;
                    v[j] -= 10000 * carry;
                }
            }
        }
        for (int i = 17; i >= 0; i--) {
            if (v[i] > 0) {
                cout << v[i] << unit[i];
            }
        }
        cout << endl;
    }       
    return 0;
}

Measured memory_bytes: 3228
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
#include<regex>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)); //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl; }
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;

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

	if (3200 <= a) cout << s << endl;
	else cout << "red" << endl;

	return 0;
}

Measured memory_bytes: 256
//ABC 126 E
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;
int n,m,cnt;
int f[MAXN];
int find(int x){
	if(x==f[x])
	return x;
	else
	return f[x]=find(f[x]);
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;++i)
	f[i]=i;
	while(m--){
		int x,y,z;
		cin>>x>>y>>z;
		int fx=find(x);
		int fy=find(y);
		if(fx!=fy){
			f[fx]=fy;
			cnt++;
		}
	}
	cout<<n-cnt;
	return 0;
}

Measured memory_bytes: 640
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,b) for(ll i=(b)-1; i>=a; --i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scanv(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#define square(x) x*x
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
ll r,g,b,n;
void input(){
    cin>>r>>g>>b>>n;
}
void src(){
    int ans=0;
    rep(i,n/r+1){
        ll n2 = n-r*i;
        rep(j,n2/g+1){
            double bb = (double)(n2-g*j)/(double)b;
            if(floor(bb)==bb){ans++;}
        }
    }
    cout<<ans;
}    
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int width = 100;

int print(char c1, char c2, int count) {
  for (int i = 0; i < width / 2; ++i) {
    for (int j = 0; j < width; ++j) {
      if (count != 0 && i % 2 && j % 2) {
        printf("%c", c1);
        count--;
      } else {
        printf("%c", c2);
      }
    }
    printf("\n");
  }
  return 0;
}

int main() {
  int a, b;
  scanf("%d%d", &a, &b);

  a--;
  b--;

  printf("100 100\n");
  print('.', '#', a);
  print('#', '.', b);

  return 0;
}


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

int n;
vector<long long> a, k;

long long gru(long long a, long long k)
{
    if (k == 1)
    {
        return a;
    }
    if (a < k)
    {
        return 0;
    }
    if (a % k == 0)
    {
        return a / k;
    }
    return gru(a - (1 + a / k) * max((a - a / k * k)/(1+a/k), 1LL), k);
}

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

    long long nim = 0;

    for (int i = 0; i < n; i++)
    {
        nim ^= gru(a[i], k[i]);
    }
    if (nim)
    {
        cout << "Takahashi" << endl;
    }
    else
    {
        cout << "Aoki" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
<?php
//$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
list($R,$G,$B) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));
$K = (int)trim(fgets(STDIN));

//G>R B>G

for($i=0;$i<$K;$i++) {
  if ($G<=$R) {
    $G*=2;
    continue;
  }
  if ($B<=$G) {
    $B*=2;
    continue;
  }
  break;
}
if ($G>$R && $B>$G) {
  printf("Yes\n");
}
else {
  printf("No\n");
}


Measured memory_bytes: 16232
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

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

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : std::numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

void solve();

int main() {
  std::locale loc(std::locale(), new yes_no);
  std::cout << std::boolalpha << std::setprecision(12) << std::fixed;
  std::cout.imbue(loc);
  solve();
  return 0;
}

using namespace std;

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

void solve() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> vec(M);
  REP(i,N) {
    int X; cin >> X;
    vec[X % M].push_back(X);
  }
  REP(i,M) sort(ALL(vec[i]));
  vector<int> one(M), two(M);
  REP(i,M) {
    const int n = vec[i].size();
    REP(j,n) {
      if (j < n - 1 && vec[i][j] == vec[i][j+1]) {
        ++j;
        ++two[i];
      }
      else ++one[i];
    }
  }
  int res = 0;
  REP(i,(M+2)/2) {
    if (i * 2 == M) {
      res += two[i] + one[i] / 2;
    }
    else if (i == 0) {
      res += two[i] + one[i] / 2;
    }
    else {
      const int a = min(one[i], one[M-i]);
      one[i] -= a; one[M-i] -= a; res += a;
      const int b = min(one[i], two[M-i] * 2);
      one[i] -= b; two[M-i] -= (b+1)/2; res += b;
      const int c = min(two[i] * 2, one[M-i]);
      two[i] -= (c+1)/2; one[M-i] -= c; res += c;
      res += two[i] + two[M-i];
    }
    // cout << res << endl;
  }
  cout << res << endl;
  return;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using i64 = long long;

constexpr i64 inf = 1000000000000000;

struct Edge {
    int to;
    i64 cap;
    int rev;
    Edge(int t, i64 c, int r) : to(t), cap(c), rev(r) {}
};

std::vector<std::deque<Edge>> g;
std::vector<int> level, iter;

void add_edge(int from, int to, i64 cap) {
    g[from].emplace_back(to, cap, g[to].size());
    g[to].emplace_back(from, 0, g[from].size() - 1);
}

void bfs(int s) {
    for (auto &el : level) el = -1;
    level[s] = 0;

    std::deque<int> q { s };

    while (!q.empty()) {
        auto curr = q.front();
        q.pop_front();
        for (auto &e : g[curr]) {
            if (e.cap > 0 && level[e.to] < 0) {
                level[e.to] = level[curr] + 1;
                q.push_back(e.to);
            }
        }
    }
}

i64 dfs(int v, int t, i64 f) {
    if (v == t) return f;

    for (int i = iter[v]; i < (int)g[v].size(); i++) {
        iter[v] = i;
        auto &e = g[v][i];

        if (e.cap > 0 && level[v] < level[e.to]) {
            i64 d = dfs(e.to, t, std::min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                g[e.to][e.rev].cap += d;
                return d;
            }
        }
    }

    return 0;
}

i64 max_flow(int s, int t) {
    i64 flow = 0;
    while (true) {
        bfs(s);
        if (level[t] < 0) return flow;

        for (auto &el : iter) el = 0;

        i64 f = dfs(s, t, inf);
        while (f > 0) {
            flow += f;
            f = dfs(s, t, inf);
        }
    }
}

int main() {
    int h, w;
    std::cin >> h >> w;
    std::string in;
    g.resize(h + w + 2);
    level.resize(h + w + 2);
    iter.resize(h + w + 2);

    for (int i = 0; i < h; i++) {
        std::cin >> in;
        for (int j = 0; j < w; j++) {
            char c = in[j];
            if (c == 'o') {
                add_edge(i, h + j, 1);
                add_edge(h + j, i, 1);
            } else if (c == 'S') {
                add_edge(h + w, i, inf);
                add_edge(h + w, h + j, inf);
            } else if (c == 'T') {
                add_edge(i, h + w + 1, inf);
                add_edge(h + j, h + w + 1, inf);
            }
        }
    }

    auto ret = max_flow(h + w, h + w + 1);
    if (ret > h * w) ret = -1;
    std::cout << ret << std::endl;

    return 0;
}

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

int main(){
  string s;
  cin>>s;
  vector<bool> flag(2,false);
  string head=s.substr(0,2),last=s.substr(2,2);
  if(head>"00"&&head<"13"){
    flag[1]=true;
  }if(last>"00"&&last<"13"){
    flag[0]=true;
  }
  if(flag[0]&&flag[1]) cout<<"AMBIGUOUS";
  else if(flag[0]) cout<<"YYMM";
  else if(flag[1]) cout<<"MMYY";
  else cout<<"NA";
  cout<<endl;
}

Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline().strip())
A = [list(map(int, sys.stdin.readline().strip().split())) for _ in range(N)]
need = [[True]*N for _ in range(N)]

for i in range(N):
    for j in range(N):
        for k in range(N):
            if i==j or j==k or k==i:
                continue

            if A[i][j]+A[j][k]<A[i][k]:
                print(-1)
                exit()

            if A[i][j]+A[j][k]==A[i][k]:
                need[i][k] = False

ans = 0
for i in range(N):
    for j in range(N):
        if need[i][j]:
            ans += A[i][j]
 
print(ans // 2)

Measured memory_bytes: 45828
fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut v = vec![];
    for c in s {
        match c {
            'B' => {
                if v.len() > 0 {
                    v.pop();
                }
            }
            _ => v.push(c),
        }
    }
    let ans = v.into_iter().collect::<String>();
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <cstdio>

int main()
{
  int a, b;
  char s[12];
  scanf("%d %d %s", &a, &b, s);
  for (int i = 0; i < a; ++i)
  {
    if (s[i] == '-')
    {
      puts("No");
      return 0;
    }
  }
  if (s[a] != '-')
  {
    puts("No");
    return 0;
  }
  for (char *p = s + a + 1; *p; ++p)
  {
    if (*p == '-')
    {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 128