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


#define li          long long int
#define uli         unsigned long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li n,x,t;
    cin>>n>>x>>t;
    cout<<(n+x-1)/x*t<<endl;

    return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<iomanip>

using namespace std;
using ll=long long;

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

int main(){
  cin.tie(nullptr);                  // 標準入出力高速化
  ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  cout << fixed << setprecision(8);  // 小数を10進数表示
  int n;
  cin>>n;
  double x,j_sum=0,b_sum=0;
  string y;
  rep(i,0,n){
      cin>>x>>y;
      y=="JPY" ? j_sum+=x : b_sum+=x;
  }
  cout<<j_sum+b_sum*380000<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
unsigned GetDigit(unsigned num){
    return std::to_string(num).length();
}
int main() {
  int n;
  cin >> n;
  long long a[n];
  rep(i, n) {
    cin >> a[i];
  }
  long long ans = 1;
  bool zero = false;
  rep(i, n) {
    if(a[i] == 0) {
      zero = true;
      break;
    }
  }
  if(zero) { 
    cout << 0 << endl;
    return 0;
  }
  else {
    rep(i, n) {
      //cout << log10((double)ans)+log10((double)a[i]) << endl;
      if(log10((double)ans)+log10((double)a[i]) >= (double)18) {
        if(ans*a[i] == 1000000000000000000) {
          ans *= a[i];
        }
        else{
        ans = -1;
        break;
        }
      }
      else{
      ans *= a[i];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4748
#include<stdio.h>

int main(void)
{
    int x, y, n, i;

    for(i = 0; ; i++)
    {
        scanf("%d %d ", &x, &y);

        if(x == 0 && y == 0)
        {
            break;
        }
    
        if(x > y)
        {
            n = x;
            x = y;
            y = n;
        }

        printf("%d %d\n", x, y);
    }

    return 0;
}


Measured memory_bytes: 2032
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<string>
using namespace std;
int main() {
  string s;
  cin >> s;
  int N = s.size();
  int zan = 15-N;
  int cnt = 0;
  for (int i=0; i<N; i++) {
    if (s[i] == 'o') cnt++;
  }
  if (cnt + zan >= 8) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long LL;
typedef pair<LL, LL> pLL;

int main(void)
{
	LL temp;
	cin >> temp;
	if (temp >= 30) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
		
	return 0;

}

Measured memory_bytes: 3604
use proconio::input;

use std::cmp::*;
// use std::collections::*;
use proconio::marker::Chars;

fn main() {
    input! {
        a: u64,
        b: u64,
        x: u64,
    }
    // 0 なしで考える
    let v1 = if a == 0 { 0 } else { (a - 1) / x };
    let v2 = if b == 0 { 0 } else { b / x };
    let mut ans = v2 - v1;
    // 0 考慮
    if a == 0 {
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N;
  cin >> N;
 
  string hinaArare;
  bool hanteiP = false;
  bool hanteiW = false;
  bool hanteiG = false;
  bool hanteiY = false;
  
  rep(i, N) {
    cin >> hinaArare;
    
    // 計算結果を出力
    if (hinaArare == "P") {
      hanteiP = true;
      continue;
    } 
    else if (hinaArare == "W") { 
      hanteiW = true;
      continue;
    } 
    else if (hinaArare == "G") { 
      hanteiG = true;
      continue;
    }
    else if (hinaArare == "Y") {
      hanteiY = true;
      continue;
    }
  }
  
  if (hanteiP && hanteiW && hanteiG && hanteiY) {
    cout << "Four" << endl;
  } 
  else if (hanteiP && hanteiW && hanteiG) {
    cout << "Three" << endl;
  }  
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100'000
i64 A[MAX_N];

i64 gcd(i64 a, i64 b) {
    if (a < b) swap(a, b);

    i64 t;
    while(b > 0) {
        t = a % b;
        a = b;
        b = t;
    }

    return a;
}

int main() {
    i64 N; cin >> N;
    REP(i, N) cin >> A[i];

    i64 g = 0;
    REP(i, N) {
        g = gcd(A[i], g);
    }
    cout << g << endl;

    return 0;
}

Measured memory_bytes: 1024
main :: IO ()
main = do
  [a, b, c, d, e] <- fmap words getLine
  let rect = Rect {
    w = read a :: Int,
    h = read b :: Int
  }
  let circle = Circle {
    x = read c :: Int,
    y = read d :: Int,
    r = read e :: Int
  }

  putStrLn $ contains rect circle

data Circle = Circle {
  x :: Int,
  y :: Int,
  r :: Int
} 

data Rect = Rect {
  w :: Int,
  h :: Int
}

contains :: Rect -> Circle -> String
contains rect circle | x' - r' < 0 || x' + r' > w' || y' - r' < 0 || y' + r' > h' = "No" 
                     | otherwise = "Yes"
                     where 
                       x' = x circle :: Int
                       y' = y circle :: Int
                       r' = r circle :: Int
                       w' = w rect :: Int
                       h' = h rect :: Int
                     

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    int n;
    cin >> n;
    int l[n];
    rep(i, n){
        cin >> l[i];
    }
    if(n < 3){
        cout << 0 << endl;
        return 0;
    }
    sort(l, l + n);
    int ans = 0;
    for (int i = 0; i < n - 2; i++){
        for (int j = i + 1; j < n - 1; j++){
            for (int k = j + 1; k < n; k++){
                if (l[i] + l[j] > l[k] && l[i] != l[j] && l[j] != l[k]){
                    ans++;
                }
                
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        Map<Integer, Integer> scoreMap = new HashMap<Integer, Integer>();
        int[] occurrences = new int[31];
        while (true) {
            String[] values = reader.readLine().split(",");
            int number = Integer.parseInt(values[0]);
            int score = Integer.parseInt(values[1]);
            if (number == 0 && score == 0) {
                break;
            }
            scoreMap.put(number, score);
            occurrences[score] = 1;
        }
        while (true) {
            String line = reader.readLine();
            if (line == null || line.isEmpty()) {
                break;
            }
            int number = Integer.parseInt(line);
            int score = scoreMap.get(number);
            int rank = 0;
            for (int i = 30; i >= score; i--) {
                rank += occurrences[i];
            }
            out.println(rank);
        }
    }
}

Measured memory_bytes: 8964
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
#define fi first
#define se second
#define pb push_back
 
const int N = 10004;
char s[N];
 
int main() {
    int n;
    scanf("%d\n%s", &n, s);
    int m = strlen(s);
    for (int i = 0; i < m; i++) {
        int c = s[i] - 'A';
        c += n;
        c %= 26;
        s[i] = c + 'A';
    }
    printf("%s", s);
    return 0;
}

Measured memory_bytes: 3796
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	for i := 1; i <= 1000; i++ {
		if int(0.08*float64(i)) == a && int(0.1*float64(i)) == b {
			fmt.Println(i)
			return
		}
	}
	fmt.Println("-1")
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define PF printf
#define SF scanf
#define MAXN 100010
using namespace std;
int a[MAXN];
int n,cnt[MAXN],minv,maxv;
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%d",&a[i]);
	minv=a[1];
	maxv=a[1];
	for(int i=2;i<=n;i++){
		minv=min(minv,a[i]);
		maxv=max(maxv,a[i]);
	}
	if(minv!=(maxv+1)/2){
		PF("Impossible");
		return 0;
	}
	for(int i=1;i<=n;i++)
		cnt[a[i]]++;
	for(int i=maxv;i>minv;i--){
		if(cnt[i]<2){
			PF("Impossible");
			return 0;
		}
	}
	if(maxv%2==0&&cnt[minv]!=1){
		PF("Impossible");
		return 0;
	}
	if(maxv%2==1&&cnt[minv]!=2){
		PF("Impossible");
		return 0;	
	}
	PF("Possible");
		
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;

    if (a <= 0 && b >= 0)
    {
        cout << "Zero" << endl;
    }else if (a <= 0 && b <= 0)
    {
        if ((b - a + 1) % 2 == 0)
        {
            cout << "Positive" << endl;
        }else{
            cout << "Negative" << endl;
        }
        
    }else if (a > 0 && b > 0)
    {
        cout << "Positive" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
S=input()

T='0'+S+'0'
ans,cnt=0,0
for i,(a,b) in enumerate(zip(S,S[1:])):
  if a=='0' and b=='1':
    cnt+=1
  elif cnt==k and a=='1' and b=='0':
    ans=max(ans,i+1)
    break
else:
  print(n)
  exit()
  
S,cnt=S[::-1],0
for i,(a,b) in enumerate(zip(S,S[1:])):
  if a=='0' and b=='1':
    cnt+=1
  elif cnt==k and a=='1' and b=='0':
    ans=max(ans,i+1)
    break
else:
  print(n)
  exit()
  
x,y=[],[]
for i,(a,b) in enumerate(zip(T,T[1:])):
  if a==b: continue
  if a=='0':
    x.append(i)
  else:
    y.append(i)
for a,b in zip(x,y[k:]):
  ans=max(ans,b-a)
print(ans)

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

using namespace std;

const int max_n = 100111, inf = 1000111222;

int n, a[max_n];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        if (a[i] % 2) {
            puts("first");
            return 0;
        }
    }
    puts("second");
    return 0;
}


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

#define o(output) cout << output << endl

using namespace std;

string s,t,u;
int a,b,c,d;
char A,B;
priority_queue<int,vector<int>,greater<int> >small;

int main(){
  cin>>a>>b;
  o((a+b)%24);
}

Measured memory_bytes: 256
from collections import defaultdict
D=defaultdict(int)
N=int(input())
A=list(map(int,input().split()))

for x in A:
    D[x]+=1
Q=int(input())
ans=0
for value,key in D.items():
    ans+=value*key

for i in range(Q):
    b,c=map(int,input().split())
    ans-=D[b]*b
    ans+=D[b]*c
    D[c]+=D[b]
    D[b]=0
    print(ans)


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

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

int main() {
	ll n, k;
	cin >> n >> k;
	ll ans = n % k;
	float harf = k / 2;
	if (ans > harf) ans = abs(ans - k);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans*= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main(){
    int N;
    cin>>N;
    long long ans=1;
    rep(i,N){
        ans*=i+1;
        ans%=1000000007;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>


int main() {
	long long a, b;

	std::cin >> a >> b;

	std::vector<long long> v(a);

	for (long long i = 0; i < a; i++)
	{
		std::cin >> v[i];
	}

	std::cout << (a - 1 + b - 2) / (b - 1) << std::endl;

	return 0;
}


Measured memory_bytes: 1024
import java.util.*

fun main(args: Array<String>) {
    val stack = Stack<Char>()
    for (c in readLine()!!) {
        if (stack.empty() || stack.peek() == 'T' || c == 'S') {
            stack.push(c)
        } else {
            stack.pop()
        }
    }
    println(stack.size)
}

Measured memory_bytes: 37236
array = [int(i) for i in list(input())]
flag = False
fugou = ['+', '-']

for i in fugou:
	if i == '+':
		tmp = array[0] + array[1]
	else:
		tmp = array[0] - array[1]
	for j in fugou:
		if j == '+':
			tmp2 = tmp + array[2]
		else:
			tmp2 = tmp - array[2]
		for k in fugou:
			if k == '+':
				if tmp2 + array[3] == 7:
					print(str(array[0])
							+ i + str(array[1])
							+ j + str(array[2])
							+ k + str(array[3])
							+ '=7')
					flag = True
					break
			else:
				if tmp2 - array[3] == 7:
					print(str(array[0])
							+ i + str(array[1])
							+ j + str(array[2])
							+ k + str(array[3])
							+ '=7')
					flag = True
					break
		if flag: break
	if flag: break

Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1'000'000'007;
constexpr ll mod = 998244353;
const double PI = 3.14159265358;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin >> N;
	ll pre = 2;
	ll now = 1;
	for(int i=2; i<=N; i++){
		ll temp = now;
		now = now + pre;
		pre = temp;
	}
	cout << now << "\n";
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cctype>
using namespace std;

int main(void) {

  int i , num , x;

  int T[26] = {};

  string S;

  while (cin >> S) {

    x = S.size();

    for(i = 0; i < x; i++) {

      if(isupper(S[i])) {

	S[i] = tolower(S[i]);

      }

      num = S[i] - 'a';

      T[num]++;

    }

  }

    for(i = 0; i < 26; i++){ 

      printf("%c : %d\n",i + 97,T[i]);

    }

}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define INF (ll)1e18+9
#define N 2000006

using namespace std;

ll n, a[305][305], ans;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            cin >> a[i][j];
    int f = 0;
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++) {
            ll c = 0;
            for (int k = 1; k <= n; k++)
                if (i != k && j != k && a[i][j] == a[i][k] + a[k][j]) c = 1;
                else if (a[i][j] > a[i][k] + a[k][j]) f = 1;
            if (!c) ans += a[i][j];
        }
    if (f) ans = -1;
    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
MOD=10**9+7

def facinv(N):
    fac,finv,inv=[0]*(N+1),[0]*(N+1),[0]*(N+1)
    fac[0]=1;fac[1]=1;finv[0]=1;finv[1]=1;inv[1]=1
    for i in range(2,N+1):
        fac[i]=fac[i-1]*i%MOD
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        finv[i]=finv[i-1]*inv[i]%MOD
    return fac,finv,inv

#nCr
def COM(n,r):
    if n<r or r<0:
        return 0
    else:
        return ((fac[n]*finv[r])%MOD*finv[n-r])%MOD



S=int(input())
fac,finv,inv=facinv(S)
if S<3:
    print(0)
    exit()
ans=0
for i in range(1,S):
    ret=S-3*i
    C=COM(ret+i-1,ret)
    ans=(ans+C)%MOD
print(ans)


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

namespace ABC64_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var cls = new bool[8];
            var master = 0;
            foreach (var i in a)
            {
                if (i < 400) cls[0] = true;
                else if (i < 800) cls[1] = true;
                else if (i < 1200) cls[2] = true;
                else if (i < 1600) cls[3] = true;
                else if (i < 2000) cls[4] = true;
                else if (i < 2400) cls[5] = true;
                else if (i < 2800) cls[6] = true;
                else if (i < 3200) cls[7] = true;
                else master++;
            }

            var sum = 0;
            for (int i = 0; i < cls.Length; i++)
            {
                if (cls[i]) sum++;
            }

            var min = 0;
            if (sum == 0 && master > 0)
            {
                min = 1;
            }
            else
            {
                min = sum;
            }


            Console.WriteLine(min + " " + (sum + master));


        }
    }
}


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

using namespace std;

void debug_out() { cerr << endl; }
template <typename H, typename... T> void debug_out(H h, T... t) {  cerr << " " << (h);  debug_out(t...); }
void read() {}
template <typename H, typename... T> void read(H &h, T&... t) { cin >> h; read(t...) ;}

#ifndef LOCAL
#define endl '\n'
#define debug(...) //
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


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

void solve() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> b(h, vector<char> (w, -1));

  int black = 0;
  for (auto &it : b)
    for(auto &i : it) {
      cin >> i;
      if (i == '#') black++;
    }

  deque<pair<int, int>> q;
  q.emplace_back(0, 0);
  vector<vector<int>> d(h, vector<int> (w, 1000));

  d[0][0] = 1;
  while (!q.empty()) {
    auto cur = q.front(); q.pop_front();

    for (int k = 0; k < 4; k++) {
      int x = cur.first + dx[k];
      int y = cur.second + dy[k];
      if (x >= 0 && x < h && y >= 0 && y < w) {
        if (b[x][y] != '#' && d[cur.first][cur.second] + 1 < d[x][y]) {
          d[x][y] = d[cur.first][cur.second] + 1;
          q.emplace_back(x, y);
        }
      }
    }
  }
  if (d[h - 1][w - 1] < 1000) {
    cout << h * w - d[h - 1][w - 1] - black << endl;
  } else {
    cout << -1 << endl;
  }
}

int main() {
#ifndef LOCAL
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif
  //int tc; cin >> tc;
  //while (tc--)
  solve();
  return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()
    val p = sc.asSequence().take(n).map { it.toInt() }.toList()

    println(if (p.filterIndexed { idx, v -> idx + 1 != v }.count() <= 2) "YES" else "NO")
}


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

int main() {
  int N, K, L = 0;
  cin >> N >> K;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.rbegin(),vec.rend());
  
  for (int i = 0; i < K; i++) {
    L += vec.at(i);
  }
  
  cout << L << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll arr[n];
    ll ans=0;
    if(n==1)
    {
        cout<<1;
        return 0;
    }
    ll count=0,prev=0,flag=0;
    for(int i=0;i<n;i++)
    cin>>arr[i];
    sort(arr,arr+n);
    ll fre[1000005]={0};
    for(int i=0;i<n;i++)
    {
        fre[arr[i]]++;
        if(fre[arr[i]]>1)
        continue;
        for(int j=2*arr[i];j<1000005;j=j+arr[i])
        {
            fre[j]++;
        }
    }
    for(int i=0;i<n;i++)
    {
        if(fre[arr[i]]==1)
        ans++;
        
    }
    cout<<ans;
   
    


    
    return 0;
}

Measured memory_bytes: 12972
s = input()
if len(s) % 2 == 0:
  n = len(s)
  f = list(s[0:int(n/2)])
  l = list(s[int(n/2):n])
else:
  n = len(s)-1
  f = list(s[0:int(n/2)])
  l = list(s[int(n/2)+1:n+1])
ans = 0
for i in range(len(f)):
  if f[i] != l[len(f)-1-i]:
    ans += 1
print(ans)



Measured memory_bytes: 3064
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

static const int MAX = 1e5;
char S[MAX];
string s;
int cnt_0, cnt_1, ans;

int main() {
    scanf("%s", S);
    s = S;
    cnt_0 = 0;
    cnt_1 = 0;

    for ( int i = 0; i < (int)s.length(); i++ ) {
        if ( s[i] == '0' ) {
            cnt_0++;
        } else {
            cnt_1++;
        }
    }

    ans = 2 * min(cnt_0, cnt_1);
    printf("%d\n", ans);
    return 0;
}


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

#define ll long long
#define endl "\n"

ll a[1000005], n, dp[1000005], k;

ll solve(ll i){
	if(i==n-1)
		return 0;
	if(i>=n)
		return INT_MAX;
	if(dp[i]!=-1)	return dp[i];
	ll ans=INT_MAX;
	for(ll j=1;j<=k;j++){
		if(i+j<n)
			ans=min(ans,abs(a[i]-a[i+j])+solve(i+j));
	}
	return dp[i]=ans;
}

int main(){	
  	ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
	memset(dp,-1,sizeof dp);
	cin >> n >> k;
	for(ll i=0;i<n;i++)		cin >> a[i];
	cout << solve(0) << endl;
	return 0;
}

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

#define endl "\n"
#define ll long long int

void solve(ll caseNo)
{
    string s;
    cin >> s;
    int n = s.size();
    if (s[n - 1] != 's')
        s += "s";
    else
        s += "es";
    cout << s << endl;
    return;
}

int main()
{
    ll cases;
    cases = 1;
    for (ll i = 1; i <= cases; i++)
    {
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

LL N, X;
vector<LL> L, P;

LL dfs(LL i, LL n) {
  if (n <= 0) return  0LL;
  if (L[i] <= n) {
    return P[i];
  }

  --n;  // B

  LL cnt = dfs(i-1, n);
  n -= L[i-1];
  if (n <= 0) return cnt;

  --n; // P
  ++cnt;

  cnt += dfs(i-1, n);
  n -= L[i-1];
  if (n <= 0) return cnt;

  assert(false);
  // B
}

int main() {
  cin >> N >> X;
  L.resize(N + 1), P.resize(N + 1);
  L[0] = 1, P[0] = 1;

  for (int i = 0; i < N; ++i) {
    L[i + 1] = 2LL * L[i] + 3LL;
    P[i + 1] = 2LL * P[i] + 1LL;
  }

  cout << dfs(N, X) << endl;
}


Measured memory_bytes: 3596
n = int(input())
s = input().split()
xs = []

for ps in s:
  xs.append(int(ps))

max_x = max(xs)
min_x = min(xs)
for i in range(min_x, max_x + 1):
  dist = 0
  for x in xs:
    dist += abs((i - x) ** 2)
  
  try:
    if min_dist > dist:
      min_dist = dist
  except NameError:
    min_dist = dist

print(min_dist)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <climits>
#include <sstream>

using namespace std;

double EPS = 1e-12;

//誤差を考慮して足し算を行う
double add(double a, double b) {
	if( abs(a + b) < EPS * (abs(a) + abs(b))) {
		return 0;
	}

	return a + b;
}

//二次元ベクトル構造体
struct P {
	double x, y;

	P() {};
	P(double x, double y) : x(x), y(y) {
	}
	P operator + (P p) {
		return P(add(x, p.x), add(y, p.y));
	}
	P operator - (P p) {
		return P(add(x, -p.x), add(y, -p.y));
	}
	P operator * (double d) {
		return P(x * d, y * d);
	}
	double dot(P p) {	//　内積
		return add(x * p.x, y * p.y);
	}
	double det(P p) {	//　外積
		return add(x * p.y, -y * p.x);
	}
};

//　線分p1-p2上に点qがあるか判定
bool on_seg(P p1, P p2, P q) {
		return (p1 - q).det(p2 - q) == 0 && (p1 - q).dot(p2 - q) <= 0;
}

//　直線p1-p2と直線q1-q2の交点
P intersection(P p1, P p2, P q1, P q2) {
	return p1 + (p2 - p1) * ((q2 - q1).det(q1 - p1) / (q2 - q1).det(p2 - p1));
}

int ccw(P a, P b, P c) {
	a = b - a;
	b = b - c;

	if(a.det(b) < 0) {
		return -1;
	} else if(a.det(b) > 0) {
		return 1;
	}

	return 0;
}


int main() {

	string str;
    while (getline(cin, str)) {
        replace(str.begin(), str.end(), ',', ' ');
        stringstream buf(str);
        P p[4];
        for (int i = 0; i < 4; i++) {
            buf >> p[i].x >> p[i].y;
        }
 
        int cnt = 0, n = 0;
        for (int i = 0; i < 4; i++) {
            int c = ccw(p[i], p[(i+1)%4], p[(i+2)%4]);
            cnt += c;
            n += abs(c);
        }
 
        cout << (abs(cnt) == n ? "YES" : "NO") << endl;
    }
}

Measured memory_bytes: 1232
from itertools import chain, islice
 
R = lambda: map(int, input().split())
n, k = R()
v = list(R())
a = sorted((x, i) for i, x in enumerate(v) if x < 0)
ans = max(sum(chain(v[:i - j], v[n - j:])) -
          sum(islice((x for x, m in a if m < i - j or m >= n - j), k - i))
          for i in range(1, min(n, k) + 1) for j in range(i))
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    int p,q,r; cin>>p>>q>>r;
    cout<<p+q+r-max(p,max(q,r))<<endl;
}


Measured memory_bytes: 256
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( $ t : ty ;; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ;; ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let r = get!(usize);
    if r < 1200 {
        println!("ABC");
    } else if r < 2800 {
        println!("ARC");
    } else {
        println!("AGC");
    }
}


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

N, M = map(int,input().split())
bridges = []
for _ in range(M):
    a, b = map(int,input().split())
    bridges.append([a, b])

bridges.sort(key = lambda x: x[1])

p = 0
t = 0

while len(bridges) > 0:
    t = bridges[0][1]
    p += 1
    bridges = [i for i in bridges if i[0] >= t]

print(p)

Measured memory_bytes: 25368
//AtCoder 
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

ll lcm(ll num1,ll num2){
	//return num1 / calc_gcd(num1,num2) * num2;
    return num1 / __gcd(num1,num2) * num2; //gcc拡張
}

int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    auto cnt = [](ll v, ll c,ll d){
        ll b1=v/c;
        ll b2=v/d;
        ll b3=v/(lcm(c,d));
        return v-b1-b2+b3;
    };
    ll bb=cnt(B,C,D);
    ll aa=cnt(A-1,C,D);
    cout<<bb-aa<<endl;
    // ll b1=B/C;
    // ll b2=B/D;
    // ll b3=B/(C*D);
    // ll a1=(A-1)/C;
    // ll a2=(A-1)/D;
    // ll a3=(A-1)/(C*D);
    // ll ans=B-A+1-b1-b2+b3+a1+a2-a3;
    //cout<<ans<<endl;    
#if 0
    ll ans=0;
    for(ll i=A;i<=B;++i){
        ans+=(i%C!=0&&i%D!=0);
    }
#endif
    //cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <math.h>
#include <stdio.h>
#include <deque>

using namespace std;

#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define REV(v) for (auto itr = v.rbegin(); itr != v.rend(); itr++)
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,-1,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pi pair<int, int>
#define MP make_pair
#define PB push_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define Vl(v,n) vector<ll> v(n);
#define Read_vll(v,n) vector<ll> v(n);REP(i,0,n)cin>>v[i];
#define sumV(v,n) Vl(acm,n) REP(i,0,n) acm[i] = v[i] + ( i == 0 ? 0 : acm[i - 1]);
#define EPS (1e-10)
#define INF 1000000000000LL

void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}


template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		REP(i,0,n)for( auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};


int MOD=1000000007;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
//I ASCII code: '0' = 48; 'A' = 65; 'a' = 97


signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	LIN(n) LIN(m)
	Graph<ll> g(n);
	REP( i, 0, m ){
		LIN(a) LIN(b)
		g.add( a - 1, b - 1, 0 );
  }

	vector< bool >  used(n,false);
	deque<int> d;
	d.push_back(0);
	d.push_back(get<0>(g.edge[0][0]));



	used[0] = used[d.back()] = true;
	bool lp=true;
	while(lp){
		lp=false;
		for(auto x:g.edge[d.back()]){
			if( !lp && !used[get<0>(x)] ){
				used[ get<0>(x) ] = true;
				d.push_back(get<0>(x));
				lp = true;
			}
		}
	}
	lp = true;
	while( lp ){
		lp=false;
		for( auto x:g.edge[ d.front() ] ){
			if( !lp && !used[ get<0>( x ) ] ){
				used [get< 0 >( x ) ] = true;
				d.push_front( get< 0 >( x ) );
				lp = true;
			}
		}
	}
	cout << d.size() << endl << d.front()+1;
	d.pop_front();
	while( !d.empty() ){
		cout << " " << d.front()+1;
		d.pop_front();
	}
	return 0;
}


Measured memory_bytes: 8832
a=int(input())

n=55555
root_n = int(n ** (1/2)) + 1

# create a list of 2 ... n
primes = list(range(2, n))

# check each of numbers
i = j = 0
for p, q in enumerate(primes):
    if q >= root_n:
        break
    elif q:
        for r in range(p + q, n - 2, q):
            if primes[r]:
                primes[r] = 0

primes = list(filter(None, primes))

c=0
for i in range(n):
    if c == a:
        break
    if i in primes and i%5==1:
        print(i,end=' ')
        c=c+1






Measured memory_bytes: 5236
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
vector<int> A;

int main(){
  cin >> N;
  A.resize(N);
  for(auto & x : A) cin >> x;
  vector<int> cnt(101010,0);
  for(auto & x : A) cnt[x]++;
  int ga = 0;
  for(auto i : cnt){
    if(i > 0){
      ga += i - 1;
    }
  }
  cout << N - 2 * (ga / 2 + ga % 2) << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  bool p = false;
  for(int i = a; i<=b; i++) {
    if(i%k==0) p = true;
  }
  if(p) cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

typedef long long ll;
typedef pair<int,int> pii;

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 2e5 + 9, M = 1e6, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;




int main(){
    init();

    int a, b;
    char c;
    cin >> a >> c >> b;
    if(c == '+')
        cout << a + b;
    else
        cout << a - b;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

char s[11], res[11];
int main(void) {

    scanf("%s", s);

    char *sp = s, *rp = res;
    while (*sp) {
        if (*sp == 'B') {
            if (rp != res)
                --rp;
            ++sp;
        }
        else
            *rp++ = *sp++;
    }
    *rp = '\0';

    printf("%s\n", res);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <math.h>
#define ll long long
using namespace std;
int main(){
	ll n,ans=0;
	cin>>n;
	ans=n/500*1000+n%500/5*5;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
s = list(input())
k = int(input())

def cnt(s):
    v = s[0]
    ans = 0
    c = 0
    for ss in s:
        if ss == v:
            c += 1
        else:
            ans += c // 2
            c = 1
            v = ss
    ans += c // 2
    return ans

if s[0] != s[-1]:
    c = cnt(s) * k
    print(c)
else:
    if len(set(s)) == 1:
        c = (len(s) * k) //2
        print(c)
    else:
        i_nxt = 0
        for i in range(len(s)):
            if s[i] != s[0]:
                i_nxt = i
                break
        s_new = s[i_nxt:] + s[0:i_nxt]
        c = cnt(s_new) * (k-1) + cnt(s[0:i_nxt]) + cnt(s[i_nxt:])
        print(c)


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

int main(){
  int N,X;
  
  cin >> N;
  X = N%10 + N/10%10 + N/100%10 + N/1000%10 + N/10000%10 + N/100000%10 + N/1000000%10 + N/10000000%10 +N/100000000%10;
  
  if(N%X==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main(){
  
  int n;
  cin >>n;
  ll a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  
  ll ans=a[0];
  for(int i=1; i<n; i++){
  	ans=GCD(ans,a[i]);
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 1024
from bisect import *
a, b, q = map(int,input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
inf = 10 ** 18
s = [-inf] + s + [inf]
t = [-inf] + t + [inf]

for i in range(q):
    x = int(input())
    s_ind = bisect_left(s, x)
    t_ind = bisect_left(t, x)
    
    res = inf
    for cand_s in [s[s_ind - 1], s[s_ind]]:
        for cand_t in [t[t_ind - 1], t[t_ind]]:
            st = abs(cand_s - cand_t)
            dx = min(abs(cand_s - x), abs(cand_t - x))
            
            res = min(res, st + dx)
    
    print(res)

Measured memory_bytes: 18456
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	var H []int
	for range make([]int, N) {
		var h int
		fmt.Scan(&h)
		H = append(H, h)
	}

	if N <= K {
		fmt.Println(0)
		return
	}

	sort.Sort(sort.IntSlice(H))
	H = H[:N-K]

	sum := 0
	for _, h := range H {
		sum += h
	}
	fmt.Println(sum)
}


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

  int R,G,B,N ;
  cin >> R >> G >> B >> N;
  int count = 0 ;
  rep(i,3001){
    rep(j,3001){
      if( ( N - R*i - G*j )%B == 0  && ( N - R*i - G*j )/B >= 0 )count++ ;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int a[200005],b[200005];
void init(int n)
{
for(int i=1;i<=n;i++)
{
a[i]=i;
b[i]=1;
}
}
int root(int x)
{
int m=x;
while(a[m]!=m)
{
a[m]=a[a[m]];
m=a[m];
}
return m;
}
void u(int x,int y)
{
int m= root(x);
int v=root(y);
if(m==v)
return;
if(b[m]>b[v])
{
a[v]=m;
b[m]=b[m]+b[v];
b[v]=0;
}
else
{
a[m]=v;
b[v]=b[m]+b[v];
b[m]=0;
}
}
int main()
{
int n,m,i,j,x,y;
cin >> n >> m;
j=m;
init(n);
while(j--)
{
cin >> x >> y;
u(x,y);


}
sort(b+1,b+n+1);

printf("%d ",b[n]);

cout << "\n";
return 0;
}

Measured memory_bytes: 5264
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& , map< pair<int,int> , int >& , vector<int>& );

void solve()
{
    int n;
    cin>>n;

    vector< vector<int> > v(n+1);
    vector< pair<int,int> > p;
    rep(i,0,n-1)
    {
        int a,b;
        cin>>a>>b;
        p.pb(mp(a,b));
        v[a].pb(b);
        v[b].pb(a);
    }

    int m = 0;

    rep(i,1,n+1)
    {
        m = max(m,(int)v[i].size());
    }

    cout<<m<<endl;
    vector<int> vis(n+1,0);
    map< pair<int,int> , int > l;
    vector<int> cs(n+1,0);
    bfs(v,1,vis,l,cs);

    rep(i,0,p.size())
    {
        cout<<l[{p[i].ft,p[i].sd}]<<endl;
    }
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis , map< pair<int,int> , int > &l , vector<int> &cs )
{
    queue<int> q;
    q.push(x);
    vis[x] = 1;
    while( !q.empty() )
    {
        int p = q.front();
        q.pop();
        int curr = 1;
        rep(i,0,v[p].size())
        {
            
            if ( vis[v[p][i]] == 0 )
            {
                if ( curr == cs[p] )
                {
                    curr++;
                }
                cs[v[p][i]] = l[mp(p,v[p][i])] = l[mp(v[p][i],p)] = curr++;
                vis[v[p][i]] = 1;
                q.push(v[p][i]);     
            }
        }
    }
}

Measured memory_bytes: 22128