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

#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define for1(i, n) for(int i = 1; i <= (int)(n); ++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)
#define ford1(i, n) for(int i = (int)(n); i>=1; --i)
#define fored(i, a, b) for(int i = (int)(b); i >= (int)(a); --i)
#define sz(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()
#define clr(v) memset(v, 0, sizeof(v))
#define clr1(v) memset(v, 0xFF, sizeof(v))
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long i64;
typedef unsigned long long u64;
typedef long double ld;
typedef vector<ld> vld;

typedef vector<i64> vi64;

template<class T> bool uax(T&a, const T& b) { if( a < b ) { a = b; return true; } return false; }
template<class T> bool uin(T&a, const T& b) { if( a > b ) { a = b; return true; } return false; }

void solve() {
  int n;
  cin >> n;
  vi a(n);
  forn(i, n) cin >> a[i];
  vi b0((n+1)/2), b1(n/2);
  forn(i, n) if(i&1) b1[i/2] = a[i]; else b0[i/2] = a[i];
  sort(all(b0));
  sort(all(b1));
  sort(all(a));
  int r = 0;
  for (int x: b1) {
    int j = lower_bound(all(a), x) - a.begin();
    if (j % 2 == 0)
      r += 1;
  }
  cout << r << '\n';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed; cout.precision(15);
  cerr << fixed; cerr.precision(15);
#ifdef HOME
  freopen("input.txt", "r", stdin);
#endif
  solve();
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	int x, y;
	cin >> x >> y;
	for (int i = 0; i <= x; i++) {
		if (i * 2 + (x - i) * 4 == y) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define D 0
using namespace std;
string s[55];
int n;
int t[55];
string str;
int pos=0,sum=0;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i]>>t[i];
		if(D)cout<<s[i]<<" "<<t[i]<<endl;
	}
	cin>>str;
	if(D)cout<<str<<endl;
	if(D)cout<<"s[i]	str		i	pos"<<endl;
	for(int i=0;i<n;i++){
		if(str==s[i]){
			if(D)cout<<s[i]<<" "<<str<<" "<<i;
			if(D)getchar();
			pos=i;
			if(D)cout<<pos<<endl;
			break;
		}
	}
	if(D)getchar();
	if(D)cout<<"sum	t[i]"<<endl;
	for(int i=pos+1;i<n;i++){
		if(D)cout<<sum<<" "<<t[i]<<endl;
		sum+=t[i];
	}
	cout<<sum<<endl;
	return 0;
}

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

int main() {
    int n, a, b;
    cin >> n;
    cin >> a >> b;
    int p[n];

    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int r  = 0;
    int cc = 0;
    int l  = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] <= a) {
            r++;
        }
        if (a < p[i] && p[i] <= b) {
            cc++;
        }
        if (p[i] > b) {
            l++;
        }
    }
    int count = min(r, min(cc, l));

    cout << count << endl;
    return 0;
}

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

using namespace std;
#define rep(i,n) for(double i=1;i<n+1;i++)
#define ll long long int
int log2(int n){
  return log(n)/log(2)+1;
}
int main(){
  double N,K;
  cin>>N>>K;
  double count=0;

  rep(i,N){
    double I=i,tem=(double)1/N;
     while(I<K){
       I*=2;
       tem/=2;
    }
     count+=tem;
  }
  cout<<fixed<<setprecision(12)<<count<<endl;
  return 0;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n;
	cin >> n;
	vector<int> v(n), p(n), q(n);
	rep(i, n) cin >> p[i];
	rep(i, n) cin >> q[i];
	rep(i, n) v[i] = i + 1;
	int i = 1;
	int a, b;
	do {
		if (p == v)
			a = i;
		if (q == v)
			b = i;
		i++;
	} while (next_permutation(all(v)));
	cout << abs(a - b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define INF (1<<29)
using namespace std;
typedef long long ll;
int main(){
      int n,k;
      while(cin>>n>>k&&n&&k){
            bool f[100001];
            int a,ans=-1;
            bool white=false;
            memset(f,false,sizeof(f));
            REP(i,k){
                  cin>>a;
                  if(a==0)white=true;
                  else f[--a]=true;
            }
            int cur=0,next;
            while(cur<n){
                  if(!f[cur]){
                        cur++;
                        continue;
                  }
                  next=cur;
                  while(f[next])next++;
                  ans=max(ans,next-cur);
                  if(white&&next<=n&&f[++next]){
                        while(f[next])next++;
                        ans=max(ans,next-cur);
                  }
                  cur++;
            }
            cout<<ans<<endl;
      }
}

Measured memory_bytes: 1264
import java.io.*;
import java.util.*;
import java.lang.Math;
import java.util.Arrays;

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

        Scanner sc = new Scanner(System.in);
        
        int w = sc.nextInt();
        int ar[] = new int[w];
        int n = sc.nextInt();
        for (int i = 0; i < w; i++)
            ar[i] = i + 1;
        for (int i = 0; i < n; i++) {
            String buf = sc.next();
            String buf2[] = buf.split(",");
            int a = Integer.parseInt(buf2[0]) - 1, 
                b = Integer.parseInt(buf2[1]) - 1;
            int tmp = ar[a];
            ar[a] = ar[b];
            ar[b] = tmp;
        }
        
        for (int i = 0; i < w; i++) {
            System.out.printf("%d\n", ar[i]);
        }
    }
  
}


Measured memory_bytes: 26368
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int ans[100010];

int main() {
	int N, K, S;
	cin >> N >> K >> S;
	for(int i=0; i<N; ++i){
		if(i<K) ans[i]=S;
		else{
			if(S==1e9) ans[i]=2;
			else ans[i]=S+1;
		}
	}
	cout << ans[0];
	for(int i=1; i<N; ++i) cout << ' ' << ans[i];
	cout << endl;
	return 0;
}


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

static const ll MOD = 1e9 + 7;

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

    ll fac[100001];
    fac[1] = 1;
    for(int i = 2; i <= max(N,M) ;i++){
        fac[i] = fac[i-1] * i % MOD;
    }

    if(abs(N - M) >= 2) cout << 0 << endl;
    else{
        ll ans = 1;
        if(N == M) ans *= 2;

        ans = ans * fac[N] % MOD * fac[M] % MOD;
        cout << ans << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    int N; cin >> N;
    map<int,int> mp;
    rep(i,N){
        int a;
        cin >> a;
        mp[a]++;
    }

    int ct = 0;

    for(auto i:mp){
        i.second = (i.second%2?1:2);
        //cout << i.first << ' ' << i.second << endl;
        if(i.second%2 == 0) ct++;
    }

    if(ct%2){
        cout << sz(mp) - 1 << endl;
    }else{
        cout << sz(mp) << endl;
    }



}

Measured memory_bytes: 4992
#include <stdio.h>
#include <string.h>
int main(void)
{
    char cards[201],str[500]={},shuffled[201];
    int m,h,i,j;
    
    while(1)
    {
       scanf("%s",cards);
       if(cards[0]=='-') break;
       else
       {
           scanf("%d",&m);
           for(i=0;i<m;i++)
           {
               scanf("%d",&h);
               strcpy(str,cards); strcat(str,cards);
               for(j=0;j<strlen(cards);j++)
               {
                   shuffled[j]=str[j+h];
               }
               shuffled[strlen(cards)]='\0';
               strcpy(cards,shuffled);
           } 
           
       }
       printf("%s\n",shuffled);
    }
    return 0;
}


Measured memory_bytes: 2104
def main():
    N, P = map(int,input().split())

    if N == 1:
        print(P)
        exit()

    ans = 1
    d = 2
    while d * d <= P:
        cnt = 0
        while P % d == 0:
            P //= d
            cnt += 1
        ans *= pow(d, cnt//N)
        d += 1

    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
//
// Created by Pulak on 18-11-2019.
//
#include <bits/stdc++.h>
#include <iostream>
using namespace std;

int main(){
    string a, b;
    cin>>a>>b;
    int s1 = a.size();
    int s2 = b.size();
    vector <vector<int>> dp(5000, vector<int>(5000));
    for (int i = 0; i <= s1; ++i) {
        for (int j = 0; j <=s2; ++j) {
            if(i == 0 || j == 0)  dp[i][j] = 0;
            else if(a[i - 1] == b[j - 1]){
                dp[i][j] = 1 + dp[i-1][j-1];
            } else {
                dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
            }
        }
    }
    string ans;
    int k = s1, j = s2;
    while(k > 0 && j > 0){
        if(a[k -1] == b[j - 1]){
            ans += a[k-1];
            k--;
            j--;
        }
        else{
            if(dp[k-1][j] > dp[k][j-1])
                k--;
            else j--;
        }
    }
    
    reverse(ans.begin(),ans.end());
    cout<<ans;



}


Measured memory_bytes: 98176
#include<stdio.h>
int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a == 1 && b == 1) printf("Draw\n");
	else if (a == 1 && b != 1) printf("Alice\n");
	else if (a != 1 && b == 1) printf("Bob\n");
	else if (a<b) printf("Bob\n");
	else if (b<a) printf("Alice\n");
	else if (a == b) printf("Draw\n");
	return 0;
}

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

static const int INF = (1<<30)-1;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int min_num=INF;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  while(1){
    for(int i=1;i<a.size();i++){
      a[i] %= a[0];
      if(a[i]==0){
        a.erase(a.begin()+i);
      }
    }
    if(a.size()==1) break;
    sort(a.begin(),a.end());
  }
  cout << a[0] << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int n = stdIn.nextInt();
			int m = stdIn.nextInt();
			if(n == 0 && m == 0)
			{
				break;
			}
			Queue<Boolean> deq = new ArrayDeque<Boolean>();
			boolean[] flag = new boolean[n];
			for(int i = 0; i < n; ++i)
			{
				flag[i] = true;
			}
			int remain = n;
			int pos = 0;
			int count = 0;
			while(remain != 1)
			{
				if(pos >= n)
				{
					pos = 0;
				}
				if(flag[pos])
				{
					++count;
				}
				if(count == m)
				{
					flag[pos] = false;
					count = 0;
					--remain;
				}
				++pos;
			}
			for(int i = 0; i < n; ++i)
			{
				if(flag[i])
				{
					System.out.println(i + 1);
					break;
				}
			}
		}
	}
}

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

int main()
{
    int N, countN = 0;
    cin >> N;
    for (int i = 1; i <= N; i++)
    {
        int num = i, count = 0;
        while (num != 0)
        {
            num /= 10;
            count++;
        }
        if (count % 2 == 1)
        {
            countN++;
        }
    }
    cout << countN << endl;
}

Measured memory_bytes: 256
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    ll K; cin >> K;
    veci A(N);
    vector<bool> seen(N,false);
    int next;
    REP(i,N) {
        int a; cin >> a;
        a--;
        A[i] = a;
    }
    int ans;
    int cur = 0;
    if(N >= K) {
        REP(i,K) {
            ans = A[cur];
            cur = A[cur];
        }
    } else {
        int v;

        REP(i,N) {
            v = A[cur];
            cur = A[cur];
        }

        seen[v] = true;
        int cnt = 0;

        while(1) {
            v = A[v];
            cnt++;
            if(seen[v]) break;
            else seen[v] = true;
        }
        cur = v;
        REP(i,(K-N)%cnt) {
            ans = A[cur];
            cur = A[cur];
        }
    }
    cout << ans+1 << endl;

}

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

typedef unsigned long long ULL;

typedef struct{
    ULL time;
    ULL deadline;
}WORK;
void margsort(WORK *work, int start,int end);
bool sort_check(WORK a, WORK b){
    return a.deadline < b.deadline;
}
int main(){
    int N;
    int i;
    WORK *work;
    ULL time;
    cin >> N;
    work = new WORK[N];
    for(i=0;i<N;i++){
        cin >> work[i].time >> work[i].deadline;
    }
    
    //margsort(work,0,N-1);
    sort(work,work+N,sort_check);
    time = 0;

    for(i=0;i<N;i++){
        time += work[i].time;
        if( time > work[i].deadline){
            break;
        }
    }
    if( i == N){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}
void margsort(WORK *work, int start,int end){
    int mid = ( start + end ) / 2;
    WORK temp;
    WORK *temps;
    int left,right,num,i;
    
    if( start >= end)
        return;
    margsort(work,start,mid);
    margsort(work,mid+1,end);
  //  cout << "start:" << start << " mid:"<<  mid << " end:" << end << endl;
    temps = new WORK[end - start + 1];
    num = 0;
    left = start;
    right = mid+1;
    while(left <= mid || right <= end){
        if( left <= mid && right <= end){
            if( work[left].deadline < work[right].deadline ){
                temps[num++] = work[left++];
            }else{
                temps[num++] = work[right++];
            }
        }else if( left <= mid){
            temps[num++] = work[left++];
        }else{
            temps[num++] = work[right++];
        }
    }
    for(i=0;i<num;i++){
        work[start + i] = temps[i];
    }
    delete [] temps;
}


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

using namespace std;

int main()
{  long long a , b , c , d  , sol1 , sol2;
    cin>>a>>b>>c>>d ;
    if(a*c > a*d) {
        sol1 = a * c ;
        }
        else
          {  sol1 = a * d ; }
    if(b*c > b*d)
         {sol2  = b*c ; }
       else
          {sol2  = b*d ;}
    if(sol1 > sol2)
        cout<<sol1 << endl ;
    else
        cout<<sol2<<endl ;


   
    return 0;
}


Measured memory_bytes: 3604
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int an = sc.nextInt();
		int bn = sc.nextInt();
		int mn = sc.nextInt();

		int[] a = new int[an];
		int[] b = new int[bn];

		int amin = 9999999;
		int bmin = 9999999;
		for ( int i=0; i<an; i++ ) {
			a[i] = sc.nextInt();
			amin = Math.min(amin, a[i]);
		}
		for ( int i=0; i<bn; i++ ) {
			b[i] = sc.nextInt();
			bmin = Math.min(bmin, b[i]);
		}

		int tmin = amin + bmin;

		for ( int i=0; i<mn; i++ ) {
			int x = sc.nextInt()-1;
			int y = sc.nextInt()-1;
			int c = sc.nextInt();
			tmin = Math.min(tmin, a[x]+b[y]-c) ;
		}

		System.out.println(tmin);
	}
}

Measured memory_bytes: 131572
N = gets.to_i
As = gets.split.map(&:to_i)

def calc(sign)
  As.inject([0, 0]) do |(cost, sum), a|
    sum += a
    unless sign * sum > 0
      cost += sum.abs + 1
      sum = sign
    end
    sign *= -1
    [cost, sum]
  end.first
end

puts [calc(1), calc(-1)].min

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

#define ll long long

ll patti(ll l)
{
    ll n = 1;
    for(ll i = 0;i < l;i++) {
        n = 2*n + 1;
    }
    return n;
}
ll vans(ll l)
{
    ll n = 0;
    for(ll i = 0;i < l;i++) {
        n = 2*n + 2;
    }
    return n;
}

ll eat(ll x, ll n)
{
    ll re = 0;
    if(x == 0) {
        return 0;
    }
    if(n == 0) {
        return 1;
    }

    // 一番下のバンズを食べる
    if(0 < x) {
        x--;
    }

    // レベルn-1バーガーのサイズ
    ll v = vans(n - 1);
    ll p = patti(n - 1);

    // レベルn-1バーガーを食べる
    if(v + p <= x) {
        re += p;
        x -= v + p;
    }else{
        re += eat(x, n - 1);
        x = 0;
    }

    // 真ん中のパティを食べる
    if(0 < x) {
        x--;
        re++;
    }

    // レベルn-1バーガーを食べる
    if(v + p <= x) {
        re += p;
        x -= v + p;
    }else{
        re += eat(x, n - 1);
        x = 0;
    }

    // 一番上のバンズを食べる
    if(0 < x) {
        x--;
    }
    return re;
}

int main()
{
    ll N;
    ll X;
    scanf("%lld %lld", &N, &X);
    printf("%lld\n", eat(X, N));
    return 0;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
red = [0] * N
red[0] = 1
boal = [1] * N

for i in range(M):
    x, y = map(int,input().split())
    x -= 1
    y -= 1
    if red[x] == 1 and boal[x] == 1:
        red[x] = 0
        boal[x] -= 1
        red[y] = 1
        boal[y] += 1
    elif red[x] == 1 and boal[x] > 1:
        boal[x] -= 1
        red[y] = 1
        boal[y] += 1
    else:
        boal[x] -= 1
        boal[y] += 1
print(sum(red))

Measured memory_bytes: 47116
S = input()
l = len(S) - 1

total = 0
for bit in range(2 ** l):
    n_list = []
    index = 0
    for i in range(l):
        if bit & (1 << i):
            total += int(S[index:i+1])
            index = i+1
    total += int(S[index:])
print(total)


Measured memory_bytes: 39152
n=int(input())
a=list(map(int,input().split()))
nu={}
for i in range(len(a)):
  nu[a[i]+1]=i+1
nu=sorted(nu.items())
b=[]
for i in nu:
  b.append(str(i[1]))
mojiretu = ' '.join(b)
print(mojiretu)

Measured memory_bytes: 34460
# -*- coding: utf-8 -*-

#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))

#整数値龍力　複数の入力(配列で1つずつ渡される)
def input_multiple_number_as_list_sep(N):
    ins = []
    for i in range(N):
        ins.append(input())
    return ins

#2次元配列入力
def input_map():
    return [list(map(int,list(input()))) for i in range(h)]

#リスト出力
def print_list(list):
    print(*list)
    return

#2次元配列出力
def print_map(maplist):
    for i in maplist:print(*i, sep='')
    return

#素数生成
def generate_primenums():
    n = 100
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5+1)):
        primes.difference_update(range(i*2, n+1, i))
    primes=list(primes)
    return primes

def memo():
    a=[0]*5
    b=a  #良くない配列のコピー
    b2=a[:]  #1次元のときはコピーはこれで良い
    a[1]=3
    print('b:{}, b2:{}'.format(b,b2))  #b:[0, 3, 0, 0, 0], b2:[0, 0, 0, 0, 0]
    
    import copy
    a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
    b=copy.deepcopy(a)  #2次元配列はこうコピーする
    
    #内包表記奇数のみ
    odd=[i for i in range(100) if i%2==1] #[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]

    #二部探索
    import bisect
    a = [1, 2, 3, 5, 6, 7, 8, 9]
    b=bisect.bisect_left(a, 8)

    #combinations、組み合わせ、順列
    from itertools import permutations, combinations,combinations_with_replacement,product
    a=['a','b','C']
    print(list(permutations(a)))
    print(list(combinations(a,2)))
    print(list(combinations_with_replacement(a,3)))


#階乗
def kaijo(n):
    import math
    return math.factorial(n)

#選び方（コンビネーション nCr）
def num_combination(n,r):
    import math
    return math.factorial(n) // math.factorial(n - r)


#最大公約数、最小公倍数
def calc_gcd(a,b):
    import fractions
    GCD=fractions.gcd(a,b)
    lcm=a*b//gcd
    return gcd,lcm

#複数の最大公約数
def calc_gcd_list(l):
    gcd = l[0]
    for i in range(1, N):
        gcd = fractions.gcd(gcd, l[i])
    return gcd

#各桁の和
def sum_digit(n):
    sum = 0
    while n > 0:
        sum += n%10
        n //= 10
    return sum

H,A = input_multiple_number()

n = H//A
if H%A != 0:
    n+=1
print(n)


Measured memory_bytes: 3192
/*
 Abu Jafor Mohammad Saleh
 ios_base :: sync_with_stdio(false);
 cin.tie(NULL);
 
 */

#include<cstdio>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<limits>
#include <algorithm>
#include <unordered_map>
#include<fstream>
#define f first
#define s second
#define MOD 1000003

#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define BOUNDARY(i, j) ((i >= 0 && i < rows) && (j >= 0 && j < coloums))

//#include<bits/stdc++.h>
#define ll long long
const int maxn = 1000001;
using namespace std;
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
int rows,coloums;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

void solve(int n)
{
    cout<<n<<endl;
    
}

int main()
{
    fast;
    int n;
    cin>>n;
    int a[n+1];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    
    int c = 0;
    int mn = 10e8;
    for(int i=0;i<n;i++)
    {
        if(a[i]<=mn)
        {
            mn = a[i];
            c++;
        }
    }
    cout<<c<<endl;
}


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

using namespace std;

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

  int n, T, t, c;
  cin >> n >> T;
  int res = 1111;
  while (n--) {
    cin >> c >> t;
    if (t <= T && c < res) res = c;
  }
  if (res == 1111) 
    cout << "TLE" << endl;
  else cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
#define MOD (ll)(998244353)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	vector<int> a(n);
	for(auto &i:a) cin>>i;
	set<int> st;
	for(int i=n;i>=1;i--){
		int cnt=0;
		for(int j=i*2;j<=n;j+=i)
			if(st.count(j)) cnt++;
		if(cnt%2!=a[i-1]){
			st.emplace(i);
		}
	}
	cout<<sz(st)<<"\n";
	bool f=true;
	for(auto &i:st){
		if(f) f=false;
		else cout<<" ";
		cout<<i;
	}
	cout<<"\n";
	return 0;
}

















Measured memory_bytes: 8576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int c[] = new int[n];
	
		for (int i=0;i<n;i++) {
			c[i] = sc.nextInt();
			
		}
		
		int min = Integer.MAX_VALUE;
		
		for (int i=0;i<n;i++) {
			if (i>=k-1) min = Math.min(min, Math.abs(c[i]-c[i-k+1])+Math.abs(c[i]));
			if (i<n-k+1) min = Math.min(min, Math.abs(c[i]-c[i+k-1])+Math.abs(c[i]));
		}
		System.out.println(min);

	}

}


Measured memory_bytes: 52360
#include <stdio.h>

void func(int a[], int num, int* sum, int* min){
    int m = 1000;
    for(int i = 0; i < num; i++){
        if(m > a[i]) m = a[i];
        *sum += a[i];
    }
    *min = m;
}

int main(void){
    int N, X;
    scanf("%d %d", &N, &X);
    int m[N];
    for(int i = 0; i < N; i++){
        scanf("%d", &m[i]);
    }
    int sum = 0;
    int min;
    func(m, N, &sum, &min);
    int ans = N + (X - sum) / min;
    printf("%d\n", ans);
    
    return 0; 
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx
x4 = x3 - dx
y4 = y3 - dy

print(x3, y3, x4, y4)

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

int main(){
    int N, H, i;

    cin >> N;
    vector<int> high(N);
    for(i = 0; i < N; i++){
        cin >> H;
        high[i] = H;
    }
    high[0]--;
    for(i = 0; i < N - 1; i++){
        if(high[i] < high[i+1]){
            high[i+1]--;
        }
        if(high[i] > high[i+1])break;
    }
    if(i == N - 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
    // 最大を覗いたやつ
    int P, Q, R;
    cin >> P >> Q >> R;

    int max = 0;
    if(max < P) max = P;
    if(max < Q) max = Q;
    if(max < R) max = R;

    cout << P + Q + R - max << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s; cin >> s;
  int ans = 0;
  for (int i = 0; i < s.length() / 2; i++)
    if (s[i] != s[s.length() - i - 1]) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 * @author yoshkur
 */
public class Main {

	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String line = br.readLine().trim();
			Double a = Double.parseDouble(line);
			Double anser = Math.pow(a, 3d);
			System.out.println(anser.intValue());

		} catch (IOException | NumberFormatException e) {
			System.err.println(e.getLocalizedMessage());
		}
	}
}

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

#define MOD 1000000007
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795

const int INF = ~(1<<31);
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int32 A,B;
	cin>>A>>B;
	if(A == B or (A+B)%2==0){
		cout<<(A+B)/2;
	}
	else{
		cout<<"IMPOSSIBLE\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll ksm(ll a, ll b, ll m) 
{
    a %= m;
    ll res = 1;
    while (b > 0) 
    {
        if (b & 1) res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll fact[100005];
ll C(ll n, ll k, ll m)
{
    if (n < k) return 0;
    ll ret = (fact[n] * ksm((fact[k] * fact[n - k]) % m, m - (ll)2, m)) % m;
    //printf("C(%lld, %lld) = %lld", n, k, ret);
    return ret;
}
void init(ll n)
{
    fact[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        fact[i] = (fact[i - 1] * i) % mod;
    }
}
int n, k;
ll arr[100005], summ[100005], sumM[100005];
int main()
{
    ios::sync_with_stdio(0);
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    init(n);
    sort(arr, arr + n);
    for (int i = 0; i < n; i++)
    {
        sumM[i] += C(i, k - 1, mod);
    }
    for (int i = 0; i < n; i++)
    {
        summ[i] = sumM[n - i - 1];
    }
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        ll tmp = sumM[i] * arr[i] % mod - summ[i] * arr[i] % mod; 
        tmp %= mod;
        ans += tmp;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int64_t N;
    cin >> N;
    vector<int64_t>vec(N);
    for (int64_t i=0; i<N; i++) {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());
    int64_t min_ = INT64_MAX;
    int64_t min_index = 0;
    for (int i=1; i<N; i++) {
        vec[i] = vec[i] % vec[0];
        if (vec[i] > 0 && min_ > vec[i]) {
            min_ = vec[i];
            min_index = i;
        }
    }

    bool ikeru = true;
    while (ikeru) {
        ikeru = false;
        int64_t new_min = INT64_MAX;
        int64_t new_min_index = INT64_MAX;
        for (int64_t i=0; i<N; i++) {
            if (i != min_index) {
                vec[i] = vec[i] % min_;
                if (vec[i] != 0 && new_min > vec[i]) {
                    new_min = vec[i];
                    new_min_index = i;
                }
            }
        }

        if (min_ > new_min) {
            ikeru = true;
            min_ = new_min;
            min_index = new_min_index;
        }
    }

    int64_t ans = INT64_MAX;
    for (int64_t i=0; i<N; i++) {
        if (vec[i] > 0) {
            ans = min(ans, vec[i]);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

int dp_solve(const int n, const string& s){
    //x : s.size()
    //y : use cnt
    //z ; lucky number
    bool dp[n+1][4][1000] = { };
    // vector<vector<vector<bool>>> dp(n + 1, vector<vector<bool>>(4, vector<bool>(1000, false)));
    dp[0][0][0] = true;
    for (auto i = 0; i < n; i++) {
        for (auto j = 0; j <= 3; j++) {
            for (auto k = 0; k <= 999; k++) {
                int index = k * 10 + (s[i] - '0');
//                cout << i << " " << j << " " << k << " " << index << endl;
//                cout << dp[i][j][k] << " -> " << dp[i + 1][j][k] << endl;
                dp[i + 1][j][k] = dp[i][j][k] or dp[i + 1][j][k];
                if(index <= 999 and j < 3) {
//                    cout << dp[i][j][k] << " -> " << dp[i + 1][j + 1][index] << endl;
                    dp[i + 1][j + 1][index] = dp[i][j][k] or dp[i + 1][j + 1][index];
                }
            }
        }
    }

//    for (auto i = 0; i <= n; i++) {
//        for (auto j = 0; j <= 3; j++) {
//            for (auto k = 0; k <= 30; k++) {
//                cout << dp[i][j][k] << " ";
//            }
//            cout << endl;
//        }
//        cout << endl;
//    }

    int cnt = 0;
    for (auto i = 0; i <= 999; i++) if(dp[n][3][i]) cnt++;

    return cnt;
}

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

//    int ans = 0;
//    for (auto i = 0; i <= 999; i++) {
//        vector<int> number(3);
//        int tmp = i;
//        for (auto j = 0; j < 3; j++) {
//            number[j] = tmp % 10;
//            tmp /= 10;
//        }
//        int cnt = 0;
//        for (auto k = 0; k < (int)s.size(); k++) {
//            if(s[k] - '0' == number[cnt]) cnt++;
//            if(cnt == 3) {
//                ans++;
//                break;
//            }
//        }
//    }
//
//    cout << ans << endl;

    cout << dp_solve(n, s) << endl;
    return 0;
}

Measured memory_bytes: 117504
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)

using namespace std;
int prime[10001];
int main(){
  prime[0] = prime[1] = 1;
  FOR(i, 2, 5001){
    for(int j = 2 * i; j < 10001; j += i) prime[j] = 1;
  }
  int n, dec[10001]; 
  while(~scanf("%d", &n)){
    for(int i = 1; i <= n; ++i) dec[i] = n-i+1; 
    int c = 0;
    //    FOR(i, 1, n+1) printf("%d ", i); puts("");
    //    FOR(i, 1, n+1) printf("%d ", dec[i]); puts("");
    FOR(i, 1, n+1) if(prime[i] == 0 && prime[dec[i]] == 0) c++;

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

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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    ll n, m; cin >> n >> m;
    vector<pair<ll, ll> > v;
    rep(i, n){
        ll a, b; cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    sort(all(v));

    ll ans = 0, sum = 0;
    for(int i = 0; i < n; i++){
        if(sum + v[i].second < m){
            ans += v[i].first * v[i].second;
            sum += v[i].second;
        }else{
           ll t = m - sum;
           ans += v[i].first * t;
           break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main()
{
  int k;
  cin >> k;
  while(k--) {
    cout << "ACL";
  }
  cout << endl;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main() {
    int n;
    cin >> n;
    if (n & 1)
        OUT((n / 2 + 1) / double(n));
    else
        OUT(0.5);
}


Measured memory_bytes: 256
N = 4


def main():
    deg = [0] * N
    for _ in range(N - 1):
        a, b = (int(z) - 1 for z in input().split())
        deg[a] += 1
        deg[b] += 1
    num_even = sum(d % 2 == 0 for d in deg)
    num_odd = N - num_even
    if num_odd == 0 or num_odd == 2 and num_even == N - 2:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define N 100550
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define pp pop_back
#define mapiter map<int, int>::iterator
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n)  for(int i = n - 1; i >= 0; --i)
#define forr1(i, n) for(int i = n; i >= 1; --i)
#define form(l, r, i)   for(int i = l; i <= r; ++i)
#define forv(r, l, i)   for(int i = r; i >= l; --i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
#define elif else if
  
const int inf = 1e9 + 7;
const lld EPS = 0.00000001;
const ll modw = 1e9 + 9;
  
using namespace std;



int main()
{
    barnarnar
    ll x;
    cin >> x;
    ll ans = (x / 500 * 500) * 2;
    x -= (x / 500 * 500);
	ans += (x / 5 * 5);
	cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	//freopen("input.txt", "r", stdin); // redirects standard input
	//freopen("output.txt", "w", stdout); // redirects standard output

	int n, k, i, j, d, x, ans;
	cin >> n >> k;
	vector<bool> used(n + 1, false);
	for (i = 0; i < k; i++) {
		cin >> d;
		while (d--) {
			cin >> x;
			used[x] = true;
		}
	}

	ans = 0;
	for (i = 1; i <= n; i++) {
		if (!used[i]) ans++;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3184
#include <iostream>
#include <cstdio>

using namespace std;

int main(void) {
	int w, n, a, b;
	int i;
	int out[31], tmp;

	cin >> w;
	cin >> n;

	for(i=0;i<w;i++) {
		out[i] = i+1;
	}

	for(i=0;i<n;i++) {
		scanf("%d,%d", &a, &b);
		tmp = out[a-1];
		out[a-1] = out[b-1];
		out[b-1] = tmp;
	}

	for(i=0;i<w;i++) {
		cout << out[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 0
# coding: utf-8
# Your code here!
#import collections
# c = collections.Counter()
#import itertools as it
#import math
#import numpy as np
#import sys 
#sys.exit()
 
s = input()
t = str(s)
#k = int(input())
#a, b  = map(int, input().split())
'''
#  = list(map(int, input().split()))
'''
'''
n = input()
a = [int(input()) for i in range(n)]
'''
'''
n,m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
'''
 
#-------------------------------#
#len(t)==len(s)+1
#print(t[0:-1])
if t[-1]==str(2) or t[-1]==str(4) or t[-1]==str(5) or t[-1]==str(7) or t[-1]==str(9):
	print('hon')
elif t[-1]==str(0) or t[-1]==str(1) or t[-1]==str(6) or t[-1]==str(8):
    print('pon')
else:
  	print('bon')

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define TASKNAME somethinghere

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

	//freopen("input.txt", "r", stdin);
	//freopen(TASKNAME".inp", "r", stdin);
	//freopen(TASKNAME".out", "w", stdout);

    string s;
    cin >> s;
    for(ll i = 0; i < s.size(); i++) {
		if(i & 1) {
			if(s[i] == 'R') {
				cout << "No";
				return 0;
			}
		}
		else {
			if(s[i] == 'L') {
				cout << "No";
				return 0;
			}
		}
    }
    cout << "Yes";
}

/* stuff you should look for
	* array bounds
	* special cases (n=1?), set tle
	* do sth instead of nothing and stay organized
	* check for variables with close names
*/


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  string s;
  cin >> s;
  string ans;
  int cnt = 0;
  rirep(i, s) {
    if (*i == 'B')
      ++cnt;
    else if (cnt != 0)
      --cnt;
    else
      ans.push_back(*i);
  }
  rv(ans);
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3584
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n-2):
  lst=[p[i],p[i+1],p[i+2]]
  m=min(lst)
  P=p[i+1]
  del lst[lst.index(m)]
  if min(lst)==P:
    cnt+=1
print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ull unsigned long long
#define mp make_pair
#define F first
#define S second
#define mod 1000000007

int main()
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    ll ans = -1*INT64_MAX;
    ans = max(ans, a*c);
    ans = max(ans, b*d);
    ans = max(ans, c*b);
    ans = max(ans, a*d);
    

    cout << ans << endl;


}

Measured memory_bytes: 3632
#include <assert.h>
#include <ctype.h>
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

#include <algorithm>
#include <complex>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define SZ(a) (int)(a).size()
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define REP(i,n) for (int i=0; i<(n); ++i)
#define ALL(c) c.begin(), c.end()
#define CLR(c,n) memset(c, n, sizeof(c))
#define TR(it, c) for(typeof(c.begin()) it = c.begin();it != c.end(); ++it)
#define CONTAIN(it, c) (c.find(it) != c.end())
typedef vector<int> VI;
typedef pair<int, int> PII;
template <class T> void checkmin(T &a, T b) { if (b<a) a=b; }
template <class T> void checkmax(T &a, T b) { if (b>a) a=b; }
const int INF=0x3F3F3F3F;

const int N=1<<20;
int p[N];
int main(int argc, char *argv[]) {
  p[0] = p[1] = 0;
  fill(p + 2, p+N, 1);
  for (int i = 2; i * i < N; ++i) {
    if (p[i]) {
      for (int j = i * i; j < N; j += i) {
        p[j] = 0;
      }
    }
  }
  FOR(i, 3, N-1) p[i] += p[i-1];
  int n;
  while (scanf("%d", &n) == 1) printf("%d\n", p[n]);
}

Measured memory_bytes: 5284
#include <bits/stdc++.h>     
using namespace std;
typedef long long int ll;
int main()
{
    string s,t;cin>>s>>t;
    int m = s.length() , n = t.length();
    int dp[m+1][n+1];
   for(int i = 0;i <= m; i++) dp[i][0] = 0;  
    for(int j = 0;j <= n; j++) dp[0][j] = 0;
    for(int i = 1;i < m+1; i++)
    {
        for(int j = 1; j < n+1 ; j++) 
        {
            if(s[i-1] == t[j-1])
               {
                  dp[i][j] = 1 + dp[i-1][j-1];
               } 
            else
                {
                    dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);    //not included
                }
        }  
    }
  
	int i = m,j = n;
    vector<char> res;
    while(i > 0 && j > 0)        
    {
        if(s[i-1] == t[j-1])
        {
          res.push_back(s[i-1]);
          i--;
          j--;
        }
        else if(dp[i-1][j] > dp[i][j-1])
            i--;
        else
            j--;
    }
    reverse(res.begin(), res.end());
    for(char c : res)
    cout<<c;
    return 0;
}




Measured memory_bytes: 35456
import bisect

n = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))

cnt = 0


for j in range(n) :
    a = bisect.bisect_left(A,B[j])
    c = bisect.bisect_right(C,B[j])
    cnt += a * (n-c)
    
print(cnt)

Measured memory_bytes: 22720
#include<bits/stdc++.h>
#define  ll   long long int
#define  sz   200010

using namespace std;


int main()
{


    ll k,s=0,d,i,j,n,p;

      cin>>n;

      for(i=1;i<=n;i++)
      {
          for(j=1;j<=n;j++)
          {
              p=__gcd(i,j);

              for(k=1;k<=n;k++)
              {
                  s+=__gcd(p,k);
              }
          }
      }

      cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 3624
import itertools

N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))

x=list(range(N+1))
del x[0]
li=list(itertools.permutations(x))

a=li.index(P)+1
b=li.index(Q)+1

print(abs(a-b))
#print(type(li[1]))

Measured memory_bytes: 8052
from collections import Counter
def resolve():
    MOD = 10 ** 9 + 7
    N = int(input())
    S = input()

    CNT = Counter(S)
    ans = 1
    for v in CNT.values():
        ans *= v + 1
        ans %= MOD

    print(ans - 1)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9580
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define TRUE 1
#define FALSE 0

int selectionsort(int N, int *num) {
	int itmp, sw, change = 0;
	for (int i = 0; i < N; i++) {
		sw = FALSE;
		int minj = i;
		for (int j = i; j < N; j++) {
			if (num[j] < num[minj]) {
				minj = j;
				sw = TRUE;
			}
		}
		itmp = num[i];
		num[i] = num[minj];
		num[minj] = itmp;
		if (sw) {
			change++;
		}
	}
	return change;
}

int main(void) {
	int N, changed;
	int num[100];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", num + i);
	}
	changed = selectionsort(N, num);
	for (int i = 0; i < N; i++) {
		if (i) {
			printf(" ");
		}
		printf("%d", num[i]);
	}
	printf("\n%d\n", changed);
	return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int a[2019];

int main() {
	int N;
	cin >> N;
	for(int i=0; i<N; ++i) cin >> a[i];
	sort(a, a+N);
	a[N]=1e9;
	int ans=0, now=0;
	for(int i=0; i+2<N; ++i){
	    int now=i+1;
	    for(int j=i+1; j+1<N; ++j){
	        while(a[i]>a[now+1]-a[j]) ++now;
	        ans += now-j;
	    }
	}
	cout << ans << endl;
	return 0;
}


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

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

int main(){
  int n;
  cin >> n;
  string siritori[n];
  bool flag = false;
  
  rep(i,n) cin >> siritori[i];
  
  rep(i,n){
    if(i > 0){
      if(siritori[i-1][siritori[i-1].size()-1] != siritori[i][0]){
        flag = true;
      }
    }
  }
  
  rep(i,n){
    rep(j,i){
      if(siritori[i] == siritori[j]){
        flag = true;
      }
    } 
  }
  
  if(flag){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
typedef vector<pii> vpii;
#define reps(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define all(g) (g).begin(),(g).end()
#define pb push_back
const int mod = 1e9 + 7;
#define INF 1<<25
/*
input case
output case
*/

int N;
int *L;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    L = new int [N];
    int sum = 0;

    rep(i,N * 2){
        cin >> L[i];
    }

    sort(L, L+(N * 2));

    // rep(i,N * 2){
    //     if (i) cout << " ";
    //     cout << L[i];
    // }cout << endl;

    for(int i = 0;i < (N * 2);i+=2){
        sum += L[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 256