akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>

const int MN = 105;

int N, M, px, py, A[MN][MN], B[MN][MN], C[MN][MN];
char s[MN][MN];

int f[MN][MN][MN];

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= N; ++i) {
		scanf("%s", s[i] + 1);
		for (int j = 1; j <= M; ++j) {
			A[i][j] = s[i][j] == 'o';
			B[i][j] = B[i][j - 1] + A[i][j];
			C[i][j] = C[i - 1][j] + A[i][j];
			if (s[i][j] == 'E') px = i, py = j;
		}
	}
	for (int u = 0; u <= px - 1; ++u) {
		for (int d = 0; d <= N - px; ++d) {
			for (int l = 0; l <= py - 1; ++l) {
				for (int r = 0; r <= M - py; ++r) {
					int tu = std::max(px - u, 1 + d);
					int td = std::min(px + d, N - u);
					int tl = std::max(py - l, 1 + r);
					int tr = std::min(py + r, M - l);
					if (u && px - u == tu && tl <= tr) f[d][l][r] += B[px - u][tr] - B[px - u][tl - 1];
					if (d) f[d][l][r] = std::max(f[d][l][r], f[d - 1][l][r] + (px + d == td && tl <= tr ? B[px + d][tr] - B[px + d][tl - 1] : 0));
					if (l) f[d][l][r] = std::max(f[d][l][r], f[d][l - 1][r] + (py - l == tl && tu <= td ? C[td][py - l] - C[tu - 1][py - l] : 0));
					if (r) f[d][l][r] = std::max(f[d][l][r], f[d][l][r - 1] + (py + r == tr && tu <= td ? C[td][py + r] - C[tu - 1][py + r] : 0));
				}
			}
		}
	}
	printf("%d\n", f[N - px][py - 1][M - py]);
	return 0;
}

Measured memory_bytes: 4608
n = gets.to_i
x = []

n.times do
  x << gets.chomp.to_s
end
x = x.sort
x = x.group_by(&:itself).map{ |key, value| [key, value.count]}.to_h
max = x.values.max
x.each do |key, value|
  if (value == max) then
    puts "#{key}"
  end
end


Measured memory_bytes: 78056
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
int s[10];

int che(int n){
	while(n>0){
		if(s[n%10]){
			return 1;
		}
		n/=10;
	}
	return 0;
}

int main (){
  int N,K;
  cin >> N >> K;
  int t;
  for(int i=0;i<K;i++){
    cin  >> t;
    s[t]++;
  }
  while(che(N)){
    N++;
  }
  cout << N;
}

Measured memory_bytes: 256
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

mod = 1000000007

"""
# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    R = int(sys.stdin.readline())
    if 0 <= R < 1200:
        print("ABC")
    elif 1200 <= R < 2800:
        print("ARC")
    else:
        print("AGC")



Measured memory_bytes: 5456
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 2e5+7;

int main()
{
    int n;
    scf(n);
    
    n=n%10;
    
    if(n==2||n==5||n==4||n==7||n==9)
    cout<<"hon";
    
    else if(n==1||n==0||n==6||n==8)
    cout<<"pon";
    
    else
    cout<<"bon";
}

Measured memory_bytes: 3760
n = int(raw_input())
W = []
for _ in range(n):
    W.append(raw_input().strip())

if len(set(W)) != len(W):
    print 'No'
else:
    isyes = True
    for i in range(1, n):
        if W[i][0] != W[i-1][-1]:
            isyes = False
            break
    if isyes:
        print 'Yes'
    else:
        print 'No'

Measured memory_bytes: 2568
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

struct edge {
    int from, to, cost;
};
bool asc(const edge& l, const edge& r) {
    return l.cost < r.cost;
}

int main() {
    int n;
    cin >> n;
    vector<edge> E;
    int a;
    for (int i=0; i<n; ++i) {
        for (int j=0; j<n; ++j) {
            cin >> a;
            if (a < 0) continue;
            E.push_back((edge){i, j, a});
        }
    }
    sort(E.begin(), E.end(), asc);

    vector<int> V(1, 0);
    int res = 0;
    while (1) {
        bool update = false;
        for (int i=0; i<(int)E.size(); ++i) {
            bool exist_from = find(V.begin(), V.end(), E[i].from) != V.end();
            bool exist_to = find(V.begin(), V.end(), E[i].to) != V.end();
            if (exist_from && ! exist_to) {
                res += E[i].cost;
                V.push_back(E[i].to);
                update = true;
                break;
            }
        }
        if ( ! update) break;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr << #x << ":" << (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, n, m);
	vector< int > ans(n, 0);
	REP(i, m) {
		VAR(int, a, b);
		ans[a - 1]++;
		ans[b - 1]++;
	}

	REP(i, n) {
		OUT(ans[i])BR;
	}
  return 0;
}


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

from collections import deque

n = int(input())
a = list(map(int, input().split()))

b = deque()
for i, ele in enumerate(a):
    if i % 2:
        b.appendleft(ele)
    else:
        b.append(ele)

if n % 2:
    b.reverse()

print(*b)


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong X;
  cin >> X;

  if (X < 600) {
    cout << 8 << endl;
  }
  else if (X < 800) {
    cout << 7 << endl;
  }
  else if (X < 1000) {
    cout << 6 << endl;
  }
  else if (X < 1200) {
    cout << 5 << endl;
  }
  else if (X < 1400) {
    cout << 4 << endl;
  }
  else if (X < 1600) {
    cout << 3 << endl;
  }
  else if (X < 1800) {
    cout << 2 << endl;
  }
  else {
    cout << 1 << endl;
  }

  return 0;
}

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


def my_round(val):
    if val % 10 == 0:
        return val
    else:
        return val + (10 - val % 10)


def main():
    alpha = [int(input()) for _ in range(5)]
    ans = [0 for _ in range(5)]

    for i in range(5):
        for j, a in enumerate(alpha):
            if i == j:
                ans[i] += a
            else:
                ans[i] += my_round(a)

    print(min(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define INF 1e9
#define eps 1e-6
#define MOD 1000000007
typedef long long ll;
using namespace std;

ll n, k, ans, t1, t2;

int main(){

	cin >> n >> k;
	for(ll i = k; i <= n + 1; i++){
		t1 = i * (i - 1) / 2 - 1;
		t1 %= MOD;
		t2 = (n - i + 1 + n) * i / 2;
		t2 %= MOD;
		ans = (ans + t2 - t1 + MOD) % MOD;
	}
	cout << ans << "\n";	

	return 0;
}


Measured memory_bytes: 3636
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let mut s: String = iter.next().unwrap().parse::<String>().unwrap();
    s.push('_');
    let mut max = 0;
    let mut cnt = 0;
    for c in s.chars() {
        match c {
            'A' | 'C' | 'G' | 'T' => cnt += 1,
            _ => {
                max = std::cmp::max(max, cnt);
                cnt = 0;
            }
        }
    }
    println!("{}", max);
}

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

typedef long long int llint;

int main()
{
  int a= 0, b = 0;
  int n;
  int num[101];
  cin>> n;
  for(int i = 0; i < n; i++) cin>> num[i];

  sort(num, num + n, greater<int>());

  for(int i = 0; i < n; i++) {
    if(i % 2 == 0) a += num[i];
    else           b += num[i];
  }

  cout<< a - b <<endl;

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

n=int(input())
s,t = list(map(str, input().split()))

for i in range(2,n+2):
    print(s[i],end="")
    print(t[i],end="")


Measured memory_bytes: 3060
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 
 using namespace std;
 
 /*
 int stringToint(const string S)
 {  
    int result=0;
    if(S[0]=='-')
    {
      for(int i=1;i<S.length();i++)
      {
        result=10*result+(S[i]-'0');        
      }             
      result=-result;
    }
    else
    {
      for(int i=0;i<S.length();i++)
      { 
        result=10*result+(S[i]-'0');      
      }
    }  
    return result;  
 }  
 */
 
 int main()
 {
   string s;
   string word;
   stack<double> mm;
   while(cin>>word)
   {
     if(word=="+"||word=="-"||word=="*"||word=="/")
       {
         double a=mm.top();
         mm.pop();
         double b=mm.top();
         mm.pop();
         double result;
         if(word=="+") result=b+a;
         else if(word=="-") result=b-a;
         else if(word=="*") result=b*a;
         else result=b/a;
         mm.push(result);     
       }
       else  
       {
         //double kk=1.0*(stringToint(word));
         mm.push(atoi(word.c_str()));
         //mm.push(kk);                                                          
       }        
     if(getchar()=='\n')
     {    
       double final_result=mm.top();
       printf("%.10lf\n",final_result);
       mm.pop();
     }           
   }  
   //while(1);
   return 0;
 }

 
  

 

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int ans = 0, count = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'A' || s[i] == 'C'  || s[i] == 'G'  || s[i] == 'T'){
      count++;
    }else{
      ans = max(ans, count);
      count = 0;
    }
  }
  ans = max(ans, count);
  cout << ans << endl;;
  return 0;
}



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


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

  int a,b;
  cin >> a >> b;
  int fac=10;
  if(b>=10) fac=100;
  if(b>=100) fac=1000;
  int c = a*fac+b;
  rep(i,100000){
   	if(i*i==c) {
    	cout << "Yes"   << endl;
	      return 0;
    }
  }	
  cout << "No" << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#define BIT(nr) (1ULL << (nr))
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }


using namespace std;


signed main() {

    string s;
    cin >> s;

    int len = (int)s.length();

    int ans = 0;

    rep(i, 1 << (len - 1)) {
        int cal = i;
        int num = 0;
        int add = 0;
        
        rep(i, len) {
            num *= 10;
            num += s[i] - '0';
            if (cal & 1LL) {
                add += num;
                num = 0;
            }
            cal >>= 1;
            if (i == len - 1) {
                add += num;
                num = 0;
            }
        }
        ans += add;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1e9;

int n;//??????????????????????????°
int m;//??????????????????????????????????????°
vector<int> G[5010];
bool flag[5010];
list <int> out;
void dfs(int u){
	flag[u] = true;
	for(auto v : G[u]){
		if(!flag[v]) dfs(v);
	}
	//???????????????????????????????????????????????????????????§????????????????????????????????????
	out.push_front(u);
}

int main(void){
	cin >> n;//??????????????????????????°
	cin >> m;//??????????????????????????????????????°
	rep(i, m){
		int a, b; cin >> a >> b;//a??????b???
		a--; b--;//
		G[b].push_back(a);// b -> a
	}

	rep(i, n){
		if(!flag[i]) dfs(i);
	}

	//??????
	vector<int> memo;
    for(auto itr = out.begin(); itr != out.end(); ++itr){
    	memo.push_back(*itr);
    }
    for (int i = memo.size() - 1; i >= 0; --i){
    	cout << memo[i] + 1 << endl;//1origin?????????????????????
    }

    for(int i; i < memo.size() - 1; i++){
    	int a = memo[i], b = memo[i + 1];
    	bool flag1 = false, flag2 = false;
    	//???????????????????????????????????¨??????????????????????????????????????¨????????????????????????
    	for(auto tmp : G[a]){
    		if(tmp == b){//a -> b??????????????¨
    			flag1 = true; break;
    		}
    	}
    	if(flag1) continue;
    	for(auto tmp : G[b]){
    		if(tmp == a){//b -> a??????????????¨
    			flag2 = true; break;
    		}
    	}

    	if(!flag1 == !flag2){
    		printf("1\n"); return 0;
    	}
    }
    printf("0\n");
    return 0;
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
} edge;
typedef struct {
	bool a;
	bool b;
} P;
int main( void ){
	int N; cin >> N;
	map<ll, bool> mp;
	rep(i,0,N){
		int input; cin >> input;
		mp[input] = !mp[input];
	}
	int sum = 0;
	for(auto m:mp){
		sum += m.second;
	}
	cout << sum << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
char a[10001];
int i;
bool flag=false;
int main(){
	while(cin>>a[i]){
		if(a[i]=='C'){
			flag=true;
		}
		if(flag&&a[i]=='F'){
			cout<<"Yes";
			return 0;
		}
	}	
	cout<<"No";
	return 0;
}

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

using namespace std;

int main() {
  
  vector<string> s = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string q;
  cin >> q;
  for (int i = 0; i < 7; i++) {
    if (q == s[i]) {
      cout << 7 - i << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	int n;
	cin>>n;
	n=n%10;
	if(n==2 || n==4 || n==5 || n==7 || n==9){
		cout<<"hon"<<endl;
	}else if(n==0 || n==1 || n==6 || n==8){
		cout<<"pon"<<endl;
	}else{
		cout<<"bon"<<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <climits>
#include <iostream>

using namespace std;

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

    int max_l = INT_MIN, min_r = INT_MAX;
    int l, r;
    for (int i = 0; i < m; ++i) {
        cin >> l >> r;
        max_l = max(max_l, l);
        min_r = min(min_r, r);
    }
    cout << max(min_r - max_l + 1, 0) << '\n';
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100001

ll dp[MAXN][3];
ll n;
ll a[MAXN][3];
ll maxv = -1;


int main() {

    cin >> n;
    for(ll i=0; i<n; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }

    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];

    for(ll i=1; i<n; i++) {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + a[i][1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + a[i][2];
    }

    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));


}


Measured memory_bytes: 4992
#include "bits/stdc++.h"

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

int n;
vector<int> a, b, poss;
map<int, int> mn, mx;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    poss.assign(n + 1, 0);
    a.assign(n, 0); b.assign(n, 0);
    for(int i = 0; i < n; ++i) cin >> a[i];
    for(int i = 0; i < n; ++i) cin >> b[i];
    for(int i = 0; i < n; ++i){
        if(!mn.count(a[i])) mn[a[i]] = i;
        mx[a[i]] = i;
    }
    for(int i = 0; i < n; ++i){
        if(mn.count(b[i])){
            int l = (((mn[b[i]] - i)%n) + n)%n, r = (((mx[b[i]] - i)%n) + n)%n;
            // cout << b[i] << " " << mx[b[i]] << " " << mn[b[i]] << " " << l << " " << r << "\n";
            if(r < l){
                poss[l]++; poss[n]--;
                poss[0]++; poss[r + 1]--;
            }
            else{
                poss[l]++; poss[r + 1]--;
            }
        }
    }
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        cnt += poss[i];
        poss[i] = cnt;
    }
    // for(auto i : poss) cout << i << ' ';
    // cout << "\n";
    bool wks = false;
    for(int i = 0; i < n; ++i){
        if(!poss[i]){
            wks = true;
            // cout << i << " ";
            std::rotate(b.rbegin(), b.rbegin() + i, b.rend());
            // rotate(b.begin(), b.begin() + i, b.end());
            break;
        }
    }
    if(wks){
        cout << "Yes\n";
        for(auto i : b) cout << i << " ";
    }
    else cout << "No";
    return 0;
}

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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

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

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

inline void proc_status ()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) << endl;
}

const int Maxn = 600 + 10;
const int Mod = 1e9 + 7;

int N, K;
int A[Maxn];
int Dp[Maxn][Maxn], g[Maxn];
int Cnt[Maxn][Maxn];

inline void Add (int &a, int b) { if ((a += b) >= Mod) a -= Mod; }

inline void Init ()
{
	g[0] = 1;
	for (int i = 2; i <= N; i += 2) g[i] = (LL) g[i - 2] * (i - 1) % Mod;

	for (int i = 1; i <= N; ++i)
		for (int j = i; j <= N; ++j)
			Cnt[i][j] = Cnt[i][j - 1] + (A[j] ? 0 : 1);
}

inline void Solve ()
{
	Init ();

	int ans = 0;
	for (int i = 1; i <= N; ++i)
	{
		for (int j = i; j <= N; ++j)
		{
			if ((j - i + 1) & 1) continue ;
			for (int k = i; k <= j; ++k)
				if (A[k] && (A[k] < i || A[k] > j)) goto END;

//			cout << i << ' ' << j << ' ' << Cnt[i][j] << endl;
			Dp[i][j] = g[Cnt[i][j]];
			for (int k = i; k < j; ++k)
				Add (Dp[i][j], Mod - (LL) Dp[i][k] * g[Cnt[k + 1][j]] % Mod);
			Add (ans, (LL) Dp[i][j] * g[Cnt[1][i - 1] + Cnt[j + 1][N]] % Mod);
END:;
		}
	}

	cout << ans << endl;
}

inline void Input ()
{
	N = read<int>() * 2, K = read<int>();
	for (int i = 1; i <= K; ++i)
	{
		int x = read<int>(), y = read<int>();
		A[x] = y, A[y] = x;
	}
}

int main()
{

#ifdef hk_cnyali
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
#endif

	Input ();
	Solve ();

	return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll fib[100005]{};
ll  fibonacii(int n,int height[],int k)
 {    fib[0]=0;
      fib[1]=0;
       fib[2]=abs(height[2]-height[1]);
    for(int i=3;i<=n;i++)
  {  ll min_value=1000000009;
   for(int j=1;j<=k;j++)
   {
       if(i-j<=0)
       break;
       min_value=min(fib[i-j]+abs(height[i]-height[i-j]),min_value);
   }
      fib[i]=min_value;
  }
 
  return fib[n];
 }
int main()
{
  int n,k;
  cin>>n>>k;
  int height[n+1];
  for(int i=1;i<=n;i++)
  {
    cin>>height[i];
  }
  cout<<fibonacii(n,height,k);
  
  return 0;
}
//10 4
//40 10 20 70 80 10 20 70 80 60

Measured memory_bytes: 4808
N = int(input())
worddict = {}
for i in range(N):
  s = input()
  if s in worddict:
    worddict[s] += 1
  else:
    worddict[s] = 1
    
M = int(input())
for i in range(M):
  t = input()
  if t in worddict:
    worddict[t] -= 1
    
maxyen = 0
for i in worddict:
  maxyen = max(maxyen, worddict[i])
print(maxyen)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};
ll ma[200002];
ll r[200002];

int main() {

	ll n;
	cin>>n;

	rep(i,n)cin>>r[i];
	for(int i=n; i>=0; i--)ma[i]-=i197;

	rrep(i,n)ma[i]=max(ma[i+1],r[i]);

	ll ans=-i197;
	rep(i,n)ans=max(ans,ma[i+1]-r[i]);

	cout<<ans<<endl;

	return 0;
}



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

int main(){
  long long a,b;
  cin >> a >> b;
  long long n=__gcd(a,b);
  //long long m=n;
  int x=1;
  for(int i=2;i<=sqrt(n);i++){
    int k=0;
    while(n%i == 0){
      n = n/i;
      k=1;
    }
    x+=k;
  }
  if (n>1) x++;
  cout << x;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        String ans = "";

        int f = Integer.parseInt(s.substring(0, 2));
        int l = Integer.parseInt(s.substring(2, 4));

        //System.out.println(f);
        //System.out.println(l);


        if (f < 1 || 12 < f) {
            if (l < 1 || 12 < l) {
                ans = "NA";
            } else {
                ans = "YYMM";
            }
        } else {
            if (l < 1 || 12 < l) {
                ans = "MMYY";
            } else {
                ans = "AMBIGUOUS";
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21204
import sys
import math

def resolve():
    D, G = list(map(int, input().split(" ")))
    P = []
    C = []
    for i in range(D):
        p, c = list(map(int, input().split(" ")))
        P.append(p)
        C.append(c)

    mincnt = float("Inf")
    for bits in range(1<<D):
        score = 0
        cnt = 0
        # bitが立っている桁は全問題解く
        for odr in range(D):
            if (bits & (1<<odr)):
                score += (P[odr] * 100 * (odr+1) + C[odr])
                cnt += P[odr]
        if score >= G:
            mincnt = min(mincnt, cnt)
        else:
            for odr in range(D-1, -1, -1):
                if (bits & (1<<odr)):
                    continue
                for j in range(P[odr]):
                    if score >= G:
                        break
                    score += (odr+1) * 100
                    cnt += 1
            mincnt = min(mincnt, cnt)
    print(mincnt)

if '__main__' == __name__:
    resolve()

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

int main() {
	// your code goes here a=97
	long atoz[26]={0};
	long H,W;
	cin >>H>>W;
	
	for(long i=0; i<H*W; i++){
		char a;
		cin >>a ;
		long b=a-97;
		atoz[b]++;
	}			//文字数カウンタ
	
	int flag=1;
	//行・列数ともに偶数のとき
	if(H%2==0 && W%2==0){
		for(int i=0; i<26; i++){
			if(atoz[i]%4!=0){
				flag=0;
				break;
			}
		}
	}
	
	else if(H%2==0 && W%2==1){
		long yonbai=0;
		for(int i=0; i<26; i++){
			if(atoz[i]%2==1){
				flag=0;
				break;
			}
			yonbai+=atoz[i]/4;
		}
		if(yonbai < (W-1)*H/4)flag=0;
	}
	else if(H%2==1 && W%2==0){
		long yonbai=0;
		for(int i=0; i<26; i++){
			if(atoz[i]%2==1){
				flag=0;
				break;
			}
			yonbai+=atoz[i]/4;
		}
		if(yonbai < (H-1)*W/4)flag=0;
	}
	else{
		long kisu=0;
		long yonbai=0;
		for(int i=0; i<26; i++){
			if(atoz[i]%2==1)kisu++;
			yonbai+=atoz[i]/4;
		}
		if(kisu>=2 || kisu==0)flag=0;
		if(yonbai<(H-1)*(W-1)/4)flag=0;
	}
	
	
	if(flag==0)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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やllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------
int main(){
  int N;
  cin >> N;
  int ans = 0;
  for(int i=1; i<=N; i++){
    if(i%2 == 0) continue;
    int cnt = 0;
    for(int j=1; j<=i; j++){
      if(i%j == 0) cnt++;
    }
    if(cnt == 8){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll N;
    cin >> N;
    set<ll> ss;
    vector<ll> A(N);

    for(ll i = 0;i < N;i++){
        cin >> A.at(i);
        ss.insert(A.at(i));
    }

    if(N == ss.size())
        cout << "YES" << endl;
    else
    {
        cout << "NO" << endl;
    }
    
}

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

int search(int n,int a[],int key) {
    int mid,right=n,left=0;
    while(left<right) {
        mid=(right+left)/2;
        if(a[mid]==key) return 1;
        else if(a[mid]>key) right=mid;
        else if(a[mid]<key) left=mid+1;
    }
    return 0;
}

int main() {
    int n;cin>>n;
    int a[100001];
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    int q,ans=0;
    cin>>q;
    for(int j=0;j<q;j++) {
        int x;cin>>x;
        if(search(n,a,x)) {
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef struct list{
    int gcd_l, gcd_r; 
} *listp;

int gcd(int a, int b) {
    int tmp;
    if(a < b) { tmp = a; a = b; b = tmp; }
    while(b != 0) {
        a %= b;
        tmp = a; a = b; b = tmp;
    }
    return a;
}

void list_init(listp *p, int *a, int n) {
    int i;
    p[0]->gcd_l = 0; p[1]->gcd_l = a[0];
    p[n-1]->gcd_r = 0; p[n-2]->gcd_r = a[n-1];
    for(i = 2; i < n; ++i) {
        p[i]->gcd_l = gcd(a[i-1], p[i-1]->gcd_l);
    }
    for(i = n-3; i >=0; --i) {
        p[i]->gcd_r = gcd(a[i+1], p[i+1]->gcd_r);
    }
    int gcdlist[n], max = 0;
    for(i = 0; i < n; ++i) {
            gcdlist[i] = gcd(p[i]->gcd_l, p[i]->gcd_r);
        if(max < gcdlist[i]) { max = gcdlist[i]; }
    }
    printf("%d\n", max);
}

void solve(int *a, int n){
    int i;
    listp *p = (listp*)malloc((n+7)*sizeof(struct list));
    for(i = 0; i < n; ++i) {
        p[i] = (listp)malloc(sizeof(struct list));
    }
    list_init(p, a, n);
}

int main(void)
{
    int n;
    scanf("%d", &n);
    int *a = (int*)malloc((n+7)*sizeof(int));
    int i;
    for(i = 0; i < n; ++i) { scanf("%d", &a[i]); }
    solve(a, n);
    return 0;
}

Measured memory_bytes: 4864
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] points = new int[5];
    for(int i = 0; i < points.length; i++){
      points[i] = sc.nextInt();
    }
    int d = sc.nextInt();
    boolean check = true;
    for(int j = 0; j < points.length; j++){
      for(int k = 0; k < points.length; k++){
    	  if(j > k) {
    		  if((points[j] - points[k]) > d){
    			  check = false;
    		  }
    	  }else {
    		  if((points[k] - points[j]) > d){
    			  check = false;
    		  } 
    	  }
      }
    }
    if(check){
      System.out.println("Yay!");
    }else {
      System.out.println(":(");
    }
  }
}

Measured memory_bytes: 23124
#include<iostream>

using namespace std;

#define rep(i,n) for(i=0;i<(n);i++)
#define For(i,a,b) for(i=(a);i<(b);i++)

int main(){
  int i,j,k;
  int a,b,c;
  cin >> a >> b >> c;
  if(a<b && b<c) cout << "Yes";
  else cout << "No";
  cout << endl;
  
  return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;
    Scd(n);

    printf ("%d\n", n*800 - n/15*200);
    return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MAX = 1e3+10;

int N;
vi child[MAX*MAX];
int parent[MAX*MAX];

int val(int a, int b) {
    return max(a, b) * N + min(a, b);
}

int solve() {
    set<int> zeros, next;
    REP (i, N) REP (j, i) {
        int v = val(i, j);
        if (parent[v] == 0) zeros.insert(v);
    }
    int ans = 0;
    int count = 0;
    while (zeros.size() != 0) {
        ans++;
        for (auto it = zeros.begin(); it != zeros.end(); it++) {
            int v = *it;
            FORE (c, child[v]) {
                parent[c]--;
                if (parent[c] == 0) next.insert(c);
            }
            count++;
        }
        zeros = next;
        next = set<int>();
    }
    return (count == N * (N-1) / 2) ? ans : -1;
}

int main() {
    cin >> N;
    REP (a, N) {
        int x, y;
        cin >> x; x = val(a, x-1);
        REP (q, N-2) {
            cin >> y; y = val(a, y-1);
            parent[y]++;
            child[x].PB(y);
            x = y;
        }
    }
    cout << solve() << endl;
}

Measured memory_bytes: 43776
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let n: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };

    let mut a = vec![vec![0; 10]; 10];
    for i in 1..10 {
        for j in 1..10 {
            a[i][j] = calc(i, j, n);
        }
    }

    // for v in a.iter() {
    //     debugln!("{:?}", v);
    // }

    let mut ans = 0;
    for i in 1..10 {
        for j in 1..10 {
            ans += a[i][j] * a[j][i];
        }
    }
    println!("{}", ans);
}

fn calc(a: usize, b: usize, n: usize) -> usize {
    let str_n = n.to_string();
    let len = str_n.len();
    let chars_n: Vec<char> = str_n.chars().collect();

    if len == 1 {
        if a == b && a <= n {
            return 1;
        } else {
            return 0;
        }
    }

    let mut ret = 0;
    for i in 1..len {
        if i == 1 {
            if a == b {
                ret += 1;
            }
        } else {
            ret += 10usize.pow(i as u32 - 2);
        }
    }
    // debugln!("ret1: {}", ret);

    let d = n / 10usize.pow(len as u32 - 1);
    let rest = n - d * 10usize.pow(len as u32 - 1);
    if a < d {
        if len == 1 {
            ret += 9;
        } else {
            ret += 10usize.pow(len as u32 - 2);
        }
        // debugln!("ret2: {}", ret);
    } else if a == d {
        ret += count_1_a(b, rest);
        // debugln!("ret3: {}", ret);
    }

    ret
}

// 末尾がa
fn count_1_a(a: usize, n: usize) -> usize {
    let str_n = n.to_string();
    let len = str_n.len();

    // debugln!("a: {}, n: {}", a, n);

    if len == 1 {
        if a <= n {
            return 1;
        } else {
            return 0;
        }
    }

    let d = n / 10usize.pow(len as u32 - 1);
    let rest = n - d * 10usize.pow(len as u32 - 1);

    let mut ret = 0;
    ret += d * 10usize.pow(len as u32 - 2);
    ret += count_1_a(a, rest);

    ret
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_count_1_a() {
        assert_eq!(1, count_1_a(1, 10));
        assert_eq!(1, count_1_a(2, 10));
        assert_eq!(2, count_1_a(1, 20));
        assert_eq!(10, count_1_a(1, 100));
    }

    #[test]
    fn test_calc() {
        assert_eq!(1, calc(1, 1, 9));
        assert_eq!(0, calc(1, 2, 9));
        assert_eq!(2, calc(1, 1, 99));
        assert_eq!(1, calc(1, 2, 99));
        assert_eq!(2, calc(1, 1, 20));
        assert_eq!(1, calc(1, 1, 10));
        assert_eq!(1, calc(1, 2, 12));
        assert_eq!(0, calc(1, 2, 11));
        assert_eq!(0, calc(3, 1, 25));
    }

    // #[test]
    fn test_calc2() {
        assert_eq!(0, calc(3, 1, 25));
    }
}


Measured memory_bytes: 4352
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        s: chars
    }

    let mut ret = vec![];
    for c in s {
        if c == 'B' {
            ret.pop();
        } else {
            ret.push(c);
        }
    }
    println!("{}", ret .iter().cloned().collect::<String>());
}

Measured memory_bytes: 4352
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]

ab=sorted(ab, key=lambda x: x[1])
a_sum=0
ans='Yes'
for i in range(n):
    a_sum+=ab[i][0]
    if a_sum>ab[i][1]:
        ans='No'
        break
print(ans)


Measured memory_bytes: 55264
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>


#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int n = 0;
int dat[10000000];

void init(int _n){
  n = 1;
  while(n < _n) n *= 2; 
  for(int i = 0; i < 2 * n - 1; i++) dat[i] = INT_MAX;
}

void update(int idx, int value){
  idx += n - 1;
  dat[idx] = value;
  while(0 < idx){
    idx = (idx - 1) / 2;
    dat[idx] = min(dat[idx * 2 + 1], dat[idx * 2 + 2]);
  }
}


int find(int a, int b, int idx = 0, int left = 0, int right = -1){
  if(right < 0) right = n;
  if(right <= a || b <= left) return INT_MAX;
  if(a <= left && right <= b) return dat[idx];
  int vl = find(a, b, 2 * idx + 1, left, (left + right) / 2);
  int vr = find(a, b, 2 * idx + 2, (left + right) / 2, right);
  return min(vl, vr);
}

int main(){
  int n, q, com, x, y;
  cin >> n >> q;
  init(n);
  for(int i = 0; i < q; i++){
    cin >> com >> x >> y;
    if(com) cout << find(x, y + 1) << endl;
    else update(x, y);
  }
  return 0;
}


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

int main() {
  string n;
  cin >> n;
  if (n.at(0) == n.at(1) && n.at(1) == n.at(2) && n.at(2) == n.at(0)){
    cout << "Yes" << endl;
  }
  else if (n.at(1) == n.at(2) && n.at(2) == n.at(3) && n.at(3) == n.at(1)) {
    cout << "Yes" << endl;
  }
  else if (n.at(0) == n.at(1) && n.at(1) == n.at(2) && n.at(2) == n.at(3) && n.at(3) == n.at(0)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;
#define endl '\n'
typedef pair<int,int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

const int maxn=200005;
const int INF=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-9;

namespace Reader{
    const int L=1<<20;
    char buf[L],*s,*t;
    inline char nc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,L,stdin);
            if(s==t)return EOF;
        }
        return *s++;
    }
    template<class T>inline bool readInt(T&x){
        int c,ng=1;
        for(c=nc();~c&&c<33;c=nc());
        if(c==-1)return 0;
        if(c=='-')ng=-1,c=nc();
        for(x=0;c>32;x=(x+(x<<2)<<1)+(c^'0'),c=nc());
        x*=ng;return 1;
    }
    inline int readString(char *dest){
        int len=0;char c;
        for(c=nc();isalpha(c);dest[len++]=c,c=nc());
        dest[len]='\0';return len;
    }
}
using namespace Reader;
vector<int> v;
int main () {
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int n;
    for(int i=1;i<=100000;++i){
        if(i*i>1000000000)
            break;
        v.push_back(i*i);
    }
    cin>>n;
    int ind=upper_bound(v.begin(),v.end(),n)-v.begin();
    cout<<v[ind-1]<<"\n";
    return 0;
}

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

#define pb push_back
#define all(a) (a).begin(), (a).end()

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

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int x, y, a, b, c; 
    cin >> x >> y >> a >> b >> c;
    vector<pii> f;
    for (int i = 0; i < a; ++i) {
        int pi; cin >> pi;
        f.pb(make_pair(pi, 0));
    }

    for (int i = 0; i < b; ++i) {
        int qi; cin >> qi;
        f.pb(make_pair(qi, 1));
    }

    for (int i = 0; i < c; ++i) {
        int ri; cin >> ri;
        f.pb(make_pair(ri, 2));
    }

    sort(f.rbegin(), f.rend());
    ll ans = 0;
    priority_queue<int> pq;
    int n = a + b + c;
    for (int i = 0; i < n; ++i) {
        int d = f[i].first;
        int t = f[i].second;
        if (t == 0) {
            if (x > 0) {
                if (!pq.empty() && pq.top() > 0) {
                    ans += pq.top();
                    pq.pop();
                    pq.push(d);
                }
                else 
                    ans += d;
                --x;
            }
        }
        else if (t == 1) {
            if (y > 0) {
                if (!pq.empty() && pq.top() > d) {
                    ans += pq.top();
                    pq.pop();
                    pq.push(d);
                }
                else 
                    ans += d;
                --y;
            }
        }
        else {
            pq.push(d);
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 6532
N, A, B, C = map(int, input().split())
ABC = [A, B, C]
l = []
for _ in range(N):
    l.append(int(input()))

m = 10 ** 6
for choice in range(1, 4 ** (N + 1)):
    bucket = [[] for _ in range(4)]
    #print(choice)
    for j in range(N):
        temp = (choice // 4 ** j) % 4
        bucket[temp].append(l[j])
        #print(temp)
    #print(bucket)
    if bucket[0] and bucket[1] and bucket[2]:
        pass
    else:
        continue
    cost = 0
    for i in range(4):
        if i <= 2 and bucket[i]:
            if len(bucket[i]) >= 2:
                total = sum(bucket[i])
                cost += 10 * (len(bucket[i]) - 1)
            else:
                total = bucket[i][0]
            cost += abs(total - ABC[i])
    m = min(m, cost)
print(m)




Measured memory_bytes: 47836
import java.util.*;
public class Main{
	public static void main(String[] args){
		
      	Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
      	
      	ArrayList<Integer> L = new ArrayList<>();
		int l = 0;
      	for(int i = 0; i < N; i++){
          	l = sc.nextInt();     
// 	        if(!L.contains(l)){
        		L.add(l);
//          }
        }
        Collections.sort(L);
      
      	int cnt = 0;
      	int li,lj,lk;
               
      	for(int i = 0; i < L.size() - 2; i++){
        	for(int j = i + 1; j < L.size() - 1; j++){
              	for(int k = j + 1; k < L.size(); k++){
                  	
            		li = L.get(i);
              		lj = L.get(j);
              		lk = L.get(k);
              		
					if(li != lj && lj != lk && li + lj > lk){ 
               			cnt++;	
              		}
                }
            }
        }
      	System.out.println(cnt);
	}
}

Measured memory_bytes: 36764
(h, w, k) = [int(x) for x in input().split(" ")]

def m_fun(x):
    if x == '.':
        return 0
    return 1

def subsets(s):
    if len(s) == 0:
        return [[]]
    if len(s) == 1:
        return [[], s]
    prev_subsets = subsets(s[1:])
    return prev_subsets + [[s[0]] + l for l in prev_subsets]
    

A = [None] * h
for i in range(h):
    A[i] =  [m_fun(x) for x in list(input())]

count = 0

for ri in subsets(list(range(h))):
    for ci in subsets(list(range(w))):
        subcount = 0
        for i in ri:
            for j in ci:
                if A[i][j] == 1:
                    subcount += 1
        if subcount == k:
            count += 1
            
print(count)

Measured memory_bytes: 9128