akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
  string s;cin >>s;
  int q;cin >>q;
  int cnt_r = 0;
  string head_s = "";
  string tail_s = "";
  for(int i=0;i<q;++i){
    int t,f;
    string c;
    cin >>t;
    if(t==1) {
      ++cnt_r;

    } else {
      cin >> f>>c;
      if(f==1){
        if(cnt_r%2==0){
          head_s = c+head_s;
        } else {
          tail_s = tail_s+c;
        }
      } else {
        if(cnt_r%2==1){
          head_s = c+head_s;
        } else {
          tail_s = tail_s+c;
        }
      }
    }
  }
  string out;
  if(cnt_r%2==1){
    reverse(all(s));
    reverse(all(tail_s));
    reverse(all(head_s));
    swap(head_s,tail_s);
  }
  cout << head_s+s+tail_s << endl;
  return 0;
}


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

typedef long long ll;

int main(){
    vector<ll> A;
    ll n,x;
    cin >> n >> x;
    A.resize(n+2);

    for(int i=0;i<n;i++)    cin >> A[i+1];
    
    ll mn=0;

    for(int i=1;i<=n;i++){
        if(A[i]+A[i-1]>x){
            mn+=A[i]+A[i-1]-x;
            A[i]=x-A[i-1];
        }
    }

    cout << mn << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

void out(bool a)
{
	if (a) cout << "YES" << endl;
	else cout << "NO" << endl;
	exit(EXIT_SUCCESS);
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ll n; cin >> n;
	vi a(n + 1);
	ll sum = 0;
	for (auto &i : a)
	{
		cin >> i;
		sum += i;
	}
	ll m = (1 + n) * n / 2;
	if (sum % m != 0) out(false);
	ll t = sum / m;
	ll cnt = 0;
	a[n] = a[0];
	REP(i, n)
	{
		ll d = a[i + 1] - a[i];
		if ((t - d) % n != 0) out(false);
		ll y = (t - d) / n;
		if (y < 0) out(false);
		cnt += y;
	}
	out(cnt == t);
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;

namespace ABC133
{
    class D
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long[] A = Console.ReadLine().Split().Select(long.Parse).ToArray();

            long sum = 0;
            for (int i = 0; i < N; i++)
            {
                sum += A[i];
            }

            long[] X = new long[N];

            long sumA = 0;
            for (int i = 1; i < N - 1; i += 2)
            {
                sumA += A[i];
            }

            X[0] = sum - 2 * sumA;

            for (int i = 1; i < N; i++)
            {
                X[i] = 2 * A[i - 1] - X[i - 1];
            }

            Console.WriteLine(string.Join(" ", X));
        }
    }
}


Measured memory_bytes: 31068
#include <iostream>

using namespace std;

int main() {
    int n,b,k=0;
    cin>>n>>b;
    if(n==0) {
        cout<<1;
        return 0;
    }
    while(n!=0){
        n=n/b;
        k++;
    }
    cout<<k;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N, P; cin >> N >> P;
    vector<Int> W(N), B(N);
    for (int i = 0; i < N; i++) cin >> W[i] >> B[i];
    Int val = 0;
    vector<Int> A(N);
    for (int i = 0; i < N; i++) {
        A[i] = (100-P)*W[i] + P*B[i];
        val -= P*B[i];
    }
    sort(rbegin(A), rend(A));
    for (int i = 0; i < N; i++) {
        val += A[i];
        if (val >= 0) {
            cout << i+1 << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 2560
# 参考解答: http://abc073.contest.atcoder.jp/submissions/1583714

N, M, R = gets.split.map(&:to_i)
r = gets.split.map(&:to_i)
d = Array.new(201) { Array.new(201, Float::INFINITY) }

M.times do
  a, b, c = gets.split.map(&:to_i)
  d[a][b], d[b][a] = [c] * 2
end

1.upto(N) do |k|
  1.upto(N) do |i|
    1.upto(N) do |j|
      distance = d[i][k] + d[k][j]
      d[i][j] = distance if d[i][j] > distance
    end
  end
end

min_distance = Float::INFINITY
r.permutation(R) do |route|
  distance = 0
  (1...route.size).each do |i|
    distance += d.dig(route[i - 1], route[i])
  end

  min_distance = distance if distance < min_distance
end

puts min_distance

Measured memory_bytes: 2300
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

primes = foldl' (\l p -> [x | x <- l, x == p || mod x p /= 0]) [2..104743] [2..323]
sumOfPrimes = scanl (+) 0 primes

main = map (sumOfPrimes!!) . takeWhile (/=0) . map read . lines <$> getContents >>= mapM_ print

Measured memory_bytes: 5540
#include <stdio.h>

int main(void){

  int n;
  scanf("%d", &n);
  int a[n];
  int x[n][n-1],y[n][n-1];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    for (int j = 0; j < a[i]; j++) {
      scanf("%d %d", &x[i][j], &y[i][j]);
    }
  }
  int truth[n];
  for (int i = 0; i < n; i++) {
    truth[i] = 0;
  }
  int flag;
  int honest;
  int max = 0;
  while (1) {
    flag = 1;
    for (int i = 0; i < n; i++) {
      if (truth[i] == 1) {
        for (int j = 0; j < a[i]; j++) {
          if (truth[x[i][j]-1] != y[i][j]) {
            flag = 0;
            break;
          }
        }
        if (flag == 0) {
          break;
        }
      }
    }
    honest = 0;
    for (int i = 0; i < n; i++) {
      honest += truth[i];
    }
    if (flag == 1) {
      if (honest > max) {
        max = honest;
      }
    }
    if (honest == n) {
      break;
    }
    truth[0]++;
    for (int i = 1; i < n; i++) {
      truth[i] += truth[i-1]/2;
      truth[i-1] %= 2;
    }
  }
  printf("%d\n", max);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
bool t[999999] = {false};
int main()
{
	int n, c, i, j;
	t[0] = true;
	for (i = 2; i * i <= 999999; i++)
	{
		if (!t[i-1])
		{
			for (j = i+i; j <= 999999; j+=i)
				t[j-1] = true;
		}
	}
	while (cin >> n)
	{
		if (cin.eof()) break;
		for (i = c = 0; i < n; i++)
			if (!t[i]) c++;
		cout << c << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;


int main(){
    int N,K,S;
    int MAX = 1000000000;
    cin >> N >> K >> S;
    if(S == MAX){
        for(int i=0;i<K;i++){
            cout << S << " ";
        }
        for(int i=0;i<(N-K);i++){
            cout << 1 << " ";
        }
    }else{
        for(int i=0;i<K;i++){
            cout << S << " ";
        }
        for(int i=0;i<(N-K);i++){
            cout << S+1 << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 1280
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double

struct datas{
  ll sumd;
  set<int> ts;
};
ll max(ll a,ll b){
  if(a<b){
    return b;
    
  }else{
    return a;
  }
}
int main(void){
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  int cnt=0;
  rep(i,n){
    if(a[i]==cnt+1){
      cnt++;
    }
  }
  if(cnt==0){
    cout<<-1<<endl;
    return 0;
  }
  cout<<n-cnt;
  return 0;
}


Measured memory_bytes: 1024
n,k = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]
a.sort(key=lambda x:x[0])
ans,i = 0,0
t = 0
while(ans < k):
	ans += a[i][1]
	t = a[i][0]
	i += 1
print(t)

Measured memory_bytes: 28448
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl
  
signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, str = 0;
    cin >> n;
    bool ans = false;
    for(int i = 0; i < n; i ++) {
    	int a, b;
    	cin >> a >> b;
    	if(a == b) {
    		str ++;
    	} else {
    		str = 0;
    	}
    	if(str >= 3) {
    		ans = true;
    	}
    }
    if(ans) {
    	cout << "Yes" << endl;
    } else {
    	cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
import sys
from itertools import permutations

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


def main():
    N = INT()
    P = tuple(LIST())
    Q = tuple(LIST())

    for i, tup in enumerate(list(permutations(range(1, N+1)))):
        if P == tup: a = i
        if Q == tup: b = i

    print(abs(a - b))


if __name__ == '__main__':
    main()

Measured memory_bytes: 44784
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#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;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){
	return b?gcd(b,a%b):a;
}

template<typename T,typename Y> inline T mpow(T a, Y n) {
	T res = 1;
	for(;n;n>>=1) {
		if (n & 1) res = res * a;
		a = a * a;
	}
	return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
	 return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
	 os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
	for(auto const& x:{args...}){
		cerr<<x<<' ';
	}
	cerr<<ENDL;
}

long long modpow(long long a, long long n, long long MOD) {//a^n(MOD)を求める
    long long res = 1%MOD;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;//次の準備
        n >>= 1;
    }
    return res;
}

signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	ll n;cin>>n;
	V<ll> a(0),b(0);

	ll x,y,z=0;
	rep(i,0,n){
		cin>>x>>y;
		if(!x && !y)z++;
		else a.pb(x),b.pb(y);
	}

	n-=z;

	map<PL,PL> ma;

	ll ans=1;
	rep(i,0,n){
		x=abs(a[i]),y=abs(b[i]);
		ll g;
		if(x==0)g=y;
		else if(y==0)g=x;
		else g=gcd(x,y);
		

		if(b[i]<0){
			a[i]*=-1;
			b[i]*=-1;
		}else if(b[i]==0 && a[i]<0)a[i]*=-1;
		
		
		if(a[i]>0){
			ma[mp(abs(a[i])/g,abs(b[i])/g)].fs++;
		}else{
			ma[mp(abs(b[i])/g,abs(a[i])/g)].sc++;
		}
	}

	for(auto&& i:ma){
		ans*=(modpow(2ll,i.sc.fs,mod)+modpow(2ll,i.sc.sc,mod)+mod-1)%mod;
		ans%=mod;
	}
	ans+=mod+z-1;
	ans%=mod;


	cout<<ans<<ENDL;
	
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 21880
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

const int inf = 1e9;
struct edge { int to, cap, rev; edge(int t, int c, int r) : to(t), cap(c), rev(r) {} };

template<class T> T ford_fulkerson(int s, int t, VV<edge>& g) {
  int n = g.size();
  V<bool> vis(n);

  function<T(int, int, T)> dfs = [&](int v, int t, T f) {
    if (v == t) return f;
    vis[v] = true;
    for (auto&& e : g[v]) {
      if (vis[e.to] or e.cap <= 0) continue;
      T d = dfs(e.to, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        g[e.to][e.rev].cap += d;
        return d;
      }
    }
    return 0;
  };

  T res = 0;
  while (true) {
    vis.assign(n, false);
    T f = dfs(s, t, inf);
    if (f == 0) return res;
    res += f;
  }
}

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n1, n2, m; cin >> n1 >> n2 >> m;
  VV<edge> g(n1 + n2 + 2);
  for (int i = 0; i < m; i++) {
    int a, b; cin >> a >> b, b += n1;
    g[a].emplace_back(b, 1, g[b].size());
    g[b].emplace_back(a, 0, g[a].size() - 1);
  }
  int s = n1 + n2;
  for (int i = 0; i < n1; i++) {
    g[s].emplace_back(i, 1, g[i].size());
    g[i].emplace_back(s, 0, g[s].size() - 1);
  }
  int t = n1 + n2 + 1;
  for (int i = n1; i < n1 + n2; i++) {
    g[t].emplace_back(i, 0, g[i].size());
    g[i].emplace_back(t, 1, g[t].size() - 1);
  }
  cout << ford_fulkerson<int>(s, t, g) << '\n';
}


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

using namespace std;

void solve()
{
  long long int n;
  cin >> n;
  long long int ans = 0;
  for (long long int i = 1; i <= n; i++)
  {
    if (i % 3 == 0 || i % 5 == 0)
    {
      continue;
    }
    ans += i;
  }
  cout << ans << "\n";
}

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


Measured memory_bytes: 3608
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t H,W,K;
char map[1000][1000];
bool ok[1000][1000];
void func(int h, int w, int k)
{
	if (h < 0 || H <= h || w < 0 || W <= w) { return; }
	if (k < 0) { return; }
	if (ok[h][w]) { return; }
	if (map[h][w] == '#') { return; }
	ok[h][w] = true;
	func(h - 1, w, k - 1);
	func(h + 1, w, k - 1);
	func(h, w - 1, k - 1);
	func(h, w + 1, k - 1);
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> H>>W>>K;
	for (size_t i = 0; i < H; i++)
	{
		in >> map[i];
	}
	int sx=0, sy = 0;
	for (size_t i = 0; i < H; i++)
	{
		for (size_t w = 0; w < W; w++)
		{
			if (map[i][w] == 'S') {
				sx = w; sy = i; map[i][w] = '.';
			}
		}
	}

	{
		std::vector<std::pair<int, int>> que;
		std::vector<std::pair<int, int>> quenext;
		ok[sy][sx] = true;
		quenext.emplace_back(sx, sy);
		for (int count = 0; count < K; count++)
		{
			std::swap(quenext, que);
			for (auto& i : que) {
				auto w = i.first,h=i.second;
				const int diff[5] = { +1,0,-1,0,+1 };
				for (int j = 0; j < 4; j++)
				{
					h += diff[j]; w += diff[j + 1];
					if (h < 0 || H <= h || w < 0 || W <= w) {  }
					else if (ok[h][w]) {  }
					else if (map[h][w] == '#') {  }
					else {
						ok[h][w] = true;
						quenext.emplace_back(w, h);
					}
					h -= diff[j]; w -= diff[j + 1];
				}
			}
			que.clear();
		}
	}

	int res = H*W;
	for (int i = 0; i < H; i++)
	{
		for (int w = 0; w < W; w++)
		{
			if (ok[i][w]) {
				res = std::min(res, 1 + (std::min({ i,H - i - 1,w,W - w - 1 })+K-1)/K);
			}
		}
	}
	std::cout << res << std::endl;

	return 0;
}
#endif

Measured memory_bytes: 1920
n = gets.chomp.to_i
points = readlines.map(&:chomp).map{|row| row.split(' ').map(&:to_i)}

max = 0
current_route = 0
0.upto(n-1) do |j|
    0.upto(j) do |j0|
        current_route += points[0][j0]
    end
    j.upto(n-1) do |j1|
        current_route += points[1][j1]
    end
    max = current_route if max < current_route
    current_route = 0
end

puts(max)
        

Measured memory_bytes: 1788
fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    val ans = IntArray(N)
    repeat(M) {
        val (a, b) = readLine()!!.split(" ").map(String::toInt).map(Int::dec)
        ans[a]++
        ans[b]++
    }
    ans.forEach(::println)
}


Measured memory_bytes: 37860
N=int(input())
H=list(map(int,input().split()))
h=min(H)
count=min(H)
flag=False
while max(H)>=h:
    for i in range(N):
        if flag and H[i]<=h:
            flag=False
            count+=1
        elif flag==False and H[i]>h:
            flag=True
        if i==N-1 and flag:
            count+=1
            flag=False
    h+=1
print(count)


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
#define guard(x) if( not ( x ) ) continue;
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename T>
struct Maybe {
   T x;
   bool valid;
   Maybe() : valid(false) {}
   Maybe(T x_) : x(x_), valid(true) {}
   operator T() const {
      assert( valid );
      return x;
   }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int n; scan(n);
      Int xs[128];
      xs[0] = 2;
      xs[1] = 1;
      for(Int i = 2; i <= n; ++i) {
         xs[i] = xs[i-1] + xs[i-2];
      }
      printf("%ld\n", xs[n]);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;

/**
 * 不安なら ll を使う.
 * 小数は double を忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 * pair<型, 型> 変数名
 * map<型, 型> 変数名  // 連想配列
 * priority_queue<型> 変数名  // 最大値から出てくるヒープ
 * 比較するときは型まで注意
 * 区間の計算は累積和
*/

/* ===== コーナーケースに気をつけろ ===== */

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    int sum = 0;
    REP(i, N) {
        cin >> A.at(i);
        sum += A.at(i);
    }
    int cnt = 0;

    REP(i, N) {
        if (A.at(i) >= (double)sum / (4*M)) {
            ++cnt;
        }
    }
    cout << (cnt >= M ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()




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

	long long a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;

	auto d = abs(a - b);

	if (d <= (v-w) * t) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}


	return 0;
}


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

#define for(i, a, b) for(ll (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)
#define sz(x)        ((ll)(x).size())

const ll inf = 1 << 25;
const ll mod = 1e9 + 7;

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

int digit(ll num) {
    return to_string(num).length();
}

int main() {
    ll N;
    cin >> N;
    
    int ans = inf;
    for(i, 1, sqrt(N)+1) {
        if (N % i == 0) {
            ll j = N / i;
            ans = min(ans, max(digit(i), digit(j)));
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
// Gracias, Rodolfo
// Gracias, MarcosK
// Gracias, Graphter
// Obrigado, Dilson
//#pragma GCC optimize ("Ofast,unroll-loops")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for (Long i = a; i < b; i++)
#define roF(i,a,b) for (Long i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) (v).begin(),(v).end()

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef long long Long;
typedef long double Double;
typedef unsigned long long ULong;
typedef pair<Long, Long> Pair;
typedef vector<Long> Vector;
typedef vector<Pair> PairVector;

const int N = 1e6;
const Long INF = 1e18;
const Double EPS = 10e-9;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
Long random(Long a, Long b) { return uniform_int_distribution<Long> (a, b) (rng); }

void solve() {
	Long n;
	cin >> n;
	Long a[n], b[n];
	For(i, 0, n) {
		cin >> a[i];
		b[i] = a[i];
	}
	Long cnt = 0;
	sort(b, b + n);
	For(i, 0, n) {
		if (a[i] != b[i]) cnt++;
	}
	if (cnt > 2) cout << "NO" << endl;
	else cout << "YES" << endl;
}

int main() {
	fastio;
	int t = 1;
	//cin >> t;
	while (t--) solve();
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	int q;
	cin >> q;
	vector<ll> b(q), c(q);
	rep(i, q) cin >> b[i] >> c[i];
	ll sum = 0;
	rep(i, n) sum += a[i];
	map<ll, ll> mp;
	rep(i, n) {
		mp[a[i]]++;
	}
	rep(Q, q) {
		ll k = mp[b[Q]];
		mp[b[Q]] = 0;
		mp[c[Q]] += k;
		sum += c[Q] * k;
		sum -= b[Q] * k;
		cout << sum << endl;
		
	}
	return 0;
}

Measured memory_bytes: 11392
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

constexpr int G = 0;
constexpr int X = 1;
constexpr int P = 2;

int f(int a) {
    if (a == G) return P;
    if (a == X) return G;
    if (a == P) return X;
    return -1;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(int, N, K);
    vector<i64> score(3);
    read(score);

    vector<int> s(N);
    rep(i, 0, N) {
        var(char, ch);
        if (ch == 'r') s[i] = G;
        if (ch == 's') s[i] = X;
        if (ch == 'p') s[i] = P;
    }

    vector<int> me(N);
    i64 sum = 0;
    rep(i, 0, N) {
        if (i - K >= 0) {
            if (f(s[i]) == me[i - K]) {
                me[i] = -1;
            } else {
                me[i] = f(s[i]);
                sum += score[me[i]];
            }
        } else {
            me[i] = f(s[i]);
            sum += score[me[i]];
        }
    }

    print(sum);

    return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i=0;i<N;i++){
    cin >> h[i];
  }
  vector<int> dp(N,1000000000);
  dp[0]=0;
  for (int i=1;i<N;i++){
    for (int j=1;j<K+1;j++){
      if (i-j>=0){
        dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
      }
    }
  }
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__);
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__);


#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair


int main(){
    SCIN(n);
    string t=n;
    reverse(ALL(t));
    Yes(t==n);
    return 0;


}


Measured memory_bytes: 256
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
ans = 0
# print(ab)
for i in range(m):
    temp = [[] for i in range(n+1)]
    v = [0]*(n+1)
    for j in range(m):
        if j==i:
            continue
        else:
            temp[ab[j][0]] += [ab[j][1]]
            temp[ab[j][1]] += [ab[j][0]]
    q = [1]
    # print(temp)
    while q:
        a = q.pop()
        for j in temp[a]:
            if v[j] == 0:
                v[j] = 1
                q.append(j)
    if v.count(1) != n:
        ans += 1
    # print(v)
print(ans)

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

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

    int cse[n + 10];  // CumSumE
    cse[0] = 0;
    int countE = 0;
    for (int i = 1; i <= n; i++) {
        if (s[i - 1] == 'E') countE++;
        cse[i] = countE;
    }

    int minCost = n;
    for (int i = 1; i <= n; i++) {
        int cost = 0, leftW = 0, rightE = 0;
        leftW = (i - 1) - cse[i - 1];
        rightE = cse[n] - cse[i];
        cost = leftW + rightE;

        if (cost < minCost) {
            minCost = cost;
        }
    }

    cout << minCost << endl;
    return 0;
}

Measured memory_bytes: 1796
#B
n,d = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]

def dist(a,b):
    d = 0
    for i in range(len(a)):
        d += (a[i] - b[i])**2
        
    return d**0.5

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

cnt = 0
for i in range(n):
    for j in range(i,n):
        if i != j and is_integer_num(dist(x[i],x[j])):
            cnt += 1
            
print(cnt)

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    var n = 1
    val arr = IntArray(N) {1}
    arr[0] = 0
    while(n <= N-1) {
        var t = n + n
        val max = N - 1
        while (t <= max) {
            arr[t] += 1
            t += n
        }
        n++
    }
    println(arr.sum())
}


Measured memory_bytes: 42548
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
import std.bigint, std.functional;

void main() {
  auto I = readln.split.to!(BigInt[]);
  auto N = BigInt(I[0]);
  auto A = BigInt(I[1]);
  auto B = BigInt(I[2]);

  BigInt solve() {
    auto loopSize = A + B;
    auto looped = N / loopSize;
    auto mod = N % loopSize;

    return looped * A + (mod <= A ? mod : A);
  }

  solve().writeln();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 200000 + 5;
int a[N];

bool cmp(int a,int b){
	return a > b;
}

int main(){
	int n,k;
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> a[i];	
	double ans = 0.00;
	for(int i = 0; i < k; i++)
		ans += a[i];
	double t = ans;
	for(int i = k; i < n; i++){
		t = t - a[i-k] + a[i];
		ans = max(ans,t);
	}
	printf("%.6lf\n",(ans+k)/2);
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#define N 200001
using namespace std;int n,a[N],dfn[N],siz[N],c[N],clk,qa[N],qb[N],ssz;vector<int> v[N];bool cmp(int a,int b){return dfn[a]>dfn[b];}
struct edge{int v,next;edge(){}edge(int _v,int _next){v=_v;next=_next;}}e[N<<1];int head[N],sz;
void init(){memset(head,-1,sizeof(head));sz=0;}void insert(int u,int v){e[++sz]=edge(v,head[u]);head[u]=sz;}
void dfs(int u,int f){dfn[u]=++clk;++siz[u];for(int i=head[u];~i;i=e[i].next)if(e[i].v!=f)dfs(e[i].v,u),siz[u]+=siz[e[i].v];}
int query(int x){int ans=0;for(;x;x-=x&-x)ans+=c[x];return ans;}void add(int x,int p){for(;x<=n;x+=x&-x)c[x]+=p;}
int main()
{
	init();scanf("%d",&n);for(int i=1;i<=n;++i)scanf("%d",a+i),v[a[i]].push_back(i);
	for(int i=1,u,v;i<n;++i)scanf("%d%d",&u,&v),insert(u,v),insert(v,u);dfs(1,0);for(int i=1;i<=n;++i)
	{long long ans=1ll*n*(n+1)/2;sort(v[i].begin(),v[i].end(),cmp);
		for(int j=0;j<v[i].size();++j)
		{
			int u=v[i][j],x=1;for(int k=head[u];~k;k=e[k].next)if(siz[e[k].v]<siz[u])
			{
				int tmp=siz[e[k].v]-query(dfn[e[k].v]+siz[e[k].v]-1)+query(dfn[e[k].v]-1);
				ans-=1ll*tmp*(tmp+1)/2;x+=tmp;
			}
			add(dfn[u],x);qa[++ssz]=dfn[u],qb[ssz]=x;
		}
		int tmp=n-query(n);ans-=1ll*tmp*(tmp+1)/2;
		for(int j=1;j<=ssz;++j)add(qa[j],-qb[j]);ssz=0;printf("%lld\n",ans);
	}
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    string s;
    cin >>n;
    cin >> s;
    int count =1;
    for(int i=0;i<n-1;i++)
    {
        if(s[i]!=s[i+1])count++;
    }
    cout << count << endl;
    return 0;
}



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

#define sc second
#define fr first
#define mk make_pair
#define pb push_back
#define int long long

using namespace std;

const int N = (1e6 + 5);
const int inf = (1e9 + 7);

int a,b;
int u[N];

main () {
    for (int i = 1; i <= 3; i ++) {
        cin >> a >> b;
        u[a] ++,u[b] ++;
    }
    for (int i = 1; i <= 4; i ++) {
        if (u[i] > 2) {
            puts("NO");
            return 0;
        }
    }
    puts("YES");

}


Measured memory_bytes: 256
import math

a, b, h, m = map(int,input().split())

time = h * 60 + m

ta = time * 2 * math.pi / (12 * 60)
tb = time * 2 * math.pi / 60

xa = a * math.sin(ta)
ya = a * math.cos(ta)
xb = b * math.sin(tb)
yb = b * math.cos(tb)

ans = math.sqrt((xa-xb)**2 + (ya-yb)**2)
print(ans)

Measured memory_bytes: 9444
#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>;
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 (b<a) {a=b; return 1;} return 0;}

int main(){
    int n;
    cin >> n;
    vector<P> ba(n), cd(n);
    // 赤い点 左下
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        ba[i] = P(b, a);
    }
    // 青い点 右上
    rep(i, n) {
        int c, d;
        cin >> c >> d;
        cd[i] = P(c, d);
    }
    // 青い点はx座標が小さい順(同じならy座標が小さい順)
    sort(cd.begin(), cd.end());
    // 赤い点はy座標が大きい順(同じならx座標が大きい順)
    sort(ba.rbegin(), ba.rend());

    int ans = 0;
    vector<bool> used(n, false);
    rep(i, n) {
        int blue_x = cd[i].first;
        int blue_y = cd[i].second;
        rep(j, n) {
            int red_x = ba[j].second;
            int red_y = ba[j].first;
            if (red_x < blue_x && red_y < blue_y && !used[j]) {
                ans++;
                used[j] = true;
                break;
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

const int N = 1e5 + 5;

int a[N], b[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    scanf("%d", b+i);
  for (int i = 0; i < n; ++i)
    scanf("%d", a+i);
  long long bisa = 0, need = 0;
  for (int i = 0; i < n; ++i) {
    if (b[i] > a[i])
      need += b[i]-a[i];
    else
      bisa += (a[i] - b[i])/2;
  }
  puts((need <= bisa) ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 384
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define printx(x) printf("%lld\n",x);
#define printxy(x,y) cout << x << y <<endl;
#define printxyz(x,y,z) cout << x << y << z <<endl;
#define deba(a) cout << #a << a << endl;
#define debab(a,b) cout << #a << a << #b << b << endl;
int main()
{
	fast;
	string s;
	cin >> s;
	string ans = "";
	rep(i, 0, s.length())
	{
		if (s[i] == 'B' and ans.length() > 0)
			ans.pop_back();
		else if (s[i] != 'B')
			ans += s[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3632
#include <string>

int N, Q;
int T[100001];


int main(void){
    scanf("%d %d", &N, &Q);

    char S[N];
    // Your code here!

    scanf("%s", S);
    int l, r;

    for(int i = 0; i < N; i++){
        int add = 0;
        if(S[i] == 'A' && S[i+1] == 'C'){
            add = 1;
        }
        T[i+1] = T[i] +  add;
    }
    
    for(int i = 0; i < Q; i++){
        scanf("%d %d", &l, &r);

        printf("%d\n", T[r-1] - T[l-1]);
    }
}



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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {
	ll n;
	cin >> n;
	fix;
	ll product = 1;
	ll cnt = 0;
	while(n != 1) {
		product *= 2;
		n /= 2;
		cnt++;
	}
	cnt = (ll)pow(2, cnt) - 1 + product;
	cout << cnt  << "\n";
	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	solve();

	return 0;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long ans=0,i,n,k,j,kk=0;
    scanf("%lld %lld",&n,&k);
    n-=2;
    for (i=1;i<=5;i++)
        for (j=1;j<=(13-2);j++)
            if((63*j+9*i+9)%11==k)
                kk++;
    if(n>=11)
    {
        ans+=n/11*kk;
        n%=11;
    }
    for (i=1;i<=5;i++)
        for (j=1;j<=n;j++)
            if((63*j+9*i+9)%11==k)
                ans++;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#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/2

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<Pii> VPii;
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;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;

    int now=0,ans=0;
    while(now<c){
        now+=a;
        if(ans%7==6) now+=b;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3216
#include <math.h>
#include <stdio.h>
int n, sqrtN;
long long ans, d;
char buf[8],out[20];
char k;
s;
size_t i;
int main() {
    s = read(0, buf, 8);
    for(;;) {
        k = buf[i++];
        if(k < '0') break;
        n = n * 10 + k - '0';
    }
    if(n == 1) {
        putchar(49);
    } else {
        const int sqrtN = sqrt(n);
        ans = -(long long)(sqrtN) * (sqrtN + 1) * (2 * sqrtN + 1) / 6;
        for(int i = 1; i <= sqrtN; ++i) {
            const int a = n / i;
            ans += ((long long)i * (i + a) * (a + 1 - i));
        }
        i = 20;
        do{
            out[--i]=ans%10+'0';
            ans/=10;
        }while(ans);
        write(1,out+i,20-i);
    }
}


Measured memory_bytes: 1808
import math
a, b, h ,m = map(int, input().split())
t = h * 60 + m
ht = 2*math.pi/(12.0*60.0) * t
mt = 2*math.pi/(60.0) * m
x = a**2 + b**2 - 2*a*b*math.cos(abs(mt-ht))
x = math.sqrt(x)
print(x)


Measured memory_bytes: 9504
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{
  int N,A,B;
  cin>>N>>A>>B;
  int R =N/(A+B);
  int ANS = R*A;
  int X = N%(A+B);
  // DEBUG(X);
  ANS += min(X,A);
  cout<<ANS<<endl;
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n;
    cin >> n;
    if (n % 1000==0)
        cout << 0 << endl;
    else
        cout << 1000 - n % 1000 << endl;
    return 0;
}

Measured memory_bytes: 3632
def main():
    s = input()

    c0, c1 = 0, 0
    for i, c in enumerate(s):
        if i % 2 == 0:
            if c == '0':
                c1 += 1

            else:
                c0 += 1

        else:
            if c == '0':
                c0 += 1

            else:
                c1 += 1

    print(min(c0, c1))

if __name__ == "__main__":
    main()


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

int N;
vector<char> S, T;

int main() {
    scanf("%d\n", &N);
    S.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%c", &S[i]);
    }
    for(int i = 0; i < 4; i++) {
        T.clear();
        T.resize(N);
        T[N - 1] = i & 1;
        T[0] = (i>>1) & 1;
        for(int j = 1; j < N - 1; j++) {
            T[j] = T[ (j + N - 2) % N ] ^ T[ (j + N - 1) % N ] ^ (S[j - 1] == 'o');
        }
        if(T[N - 3] ^ T[N - 2] ^ T[N - 1] ^ (S[N - 2] == 'o')) continue;
        if(T[N - 2] ^ T[N - 1] ^ T[0] ^ (S[N - 1] == 'o')) continue;
        for(int j = 0; j < N; j++) {
            if(T[j]) printf("S");
            else printf("W");
        }
        return 0;
    }
    printf("-1");
}


Measured memory_bytes: 512
def F(N):
    if N == 0:
        return ''
    if N % 2 == 0:
        return F(N//-2) + '0'
    return F((N-1)//-2) + '1'

N = int(input())
answer = F(N)
if N == 0:
    answer = 0
print(answer)


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

class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.nextLine());
        Integer[] d = new Integer[n];

        for (int i = 0; i < n; i++) {
            d[i] = Integer.parseInt(scan.nextLine());
        }
        Arrays.sort(d);

        int count = 0;
        for (int i = 0; i < n; i++) {
            if (i == 0 || d[i] > d[i - 1]) {
                count++;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main {
    public void solve() {
        Scanner scan = new Scanner(System.in);
    int[]X = new int[5];
    for(int i=0;i<=4;i++){X[i]=scan.nextInt();
    if(X[i]==0)System.out.println(i+1);}

    }
    public static void main(String[] args) {
        new Main().solve();
    }
    }

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string a;
  cin >> a;
  string b = a;
  reverse(all(a));
  if (a == b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3580