akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
signed main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int s = 0;
    rep(i, n)
    {
        cin >> a.at(i);
        s = (s ^ a.at(i));
    }
    rep(i, n)
    {
        if (i == n - 1)
            cout << (a.at(i) ^ s) << endl;
        else
            cout << (a.at(i) ^ s) << " ";
    }

    return 0;
}

Measured memory_bytes: 4824
//package atcoder;
 
import java.util.*;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		//System.out.println(s.charAt(3));
//		char S[] = new char[6];
//		for(int i=0;i<6;i++) {
//			S[i] = s.toCharArray();
//		}
		
		if(s.charAt(2)==s.charAt(3)&&s.charAt(4)==s.charAt(5)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	ll n, k;
	cin >> n >> k;
	vl a(n);
	rep(i, n) {
		cin >> a[i];
		if(a[i] == k) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	sort(all(a));
	if(a.back() < k || n == 1) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	ll g = __gcd(a[0], a[1]);
	rep(i, n) g = __gcd(a[i], g);
	if(k % g == 0) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
}


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

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	vector<ll> b(n + 1), c(n + 1);
	for(int i = 0; i < n; ++i){ b[i + 1] = b[i] + a[i]; }
	for(int i = 0; i < n; ++i){ c[i + 1] = c[i] + max(0ll, a[i]); }
	ll answer = 0;
	for(int i = 0; i + k <= n; ++i){
		answer = max(answer, c[i] + max(0ll, b[i + k] - b[i]) + (c[n] - c[i + k]));
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Mon Jun  8 00:49:17 JST 2020
 **/

template <class T> bool chmin(T& a, const T& b) { return a > b ? a = b, true : false; }
template <class T> bool chmax(T& a, const T& b) { return a < b ? a = b, true : false; }

void solve() {
    Int n;
    std::cin >> n;
    std::vector<Int> a(n);
    REP(i, n) std::cin >> a[i];
    std::string s;
    std::cin >> s;
    std::vector<Int> bases;
    for (Int i = n - 1; i >= 0; i--) {
        for (Int base : bases) {
            chmin(a[i], a[i] ^ base);
        }
        if (a[i]) {
            if (s[i] == '0') {
                bases.push_back(a[i]);
            } else {
                std::cout << 1 << std::endl;
                return;
            }
        }
    }
    std::cout << 0 << std::endl;
}
signed main() {
    Int T;
    std::cin >> T;
    while (T--) solve();
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A), t(B);
    rep(i, A) { cin >> s[i]; }
    rep(i, B) { cin >> t[i]; }
    s.push_back(INF);
    s.push_back(-INF);
    sort(s.begin(), s.end());
    t.push_back(INF);
    t.push_back(-INF);
    sort(t.begin(), t.end());

    for (int i = 0; i < Q; ++i) {
        ll x;
        cin >> x;
        ll res = INF;
        ll s_itr = upper_bound(s.begin(), s.end(), x) - s.begin(); // xより大きいsの場所
        ll t_itr = upper_bound(t.begin(), t.end(), x) - t.begin(); // xより大きいtの場所
        rep(j, 2)
        {
            rep(k, 2)
            {
                ll s_pos = max(0ll, s_itr - j);
                ll t_pos = max(0ll, t_itr - k);

                ll tmp_a = abs(s[s_pos] - x) + abs(t[t_pos] - s[s_pos]);
                ll tmp_b = abs(t[t_pos] - x) + abs(s[s_pos] - t[t_pos]);
                res = min(res, tmp_a);
                res = min(res, tmp_b);
            }
        }
        cout << res << endl;
    }
    return 0;
}

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

int main() {
  
  string S,T;
  cin >> S>>T;
  
  int counter=0;
  
  for(int i=0;i<3;i++){

      if(S.at(i)==T.at(i)){
        counter++;
      }
  }
  cout << counter<<endl;
  
  
}


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

#define int long long
#define xxx int32_t
#define fuck_u return 0;

xxx main() {
    xxx n, w;
    scanf("%d%d", &n, &w);
    int dp[w+1] = {0};
    for(xxx item=0; item<n; ++item) {
		xxx weight, value;
		scanf("%d%d", &weight, &value);
		for (xxx w1=w-weight; w1>=0; --w1) {
			dp[w1+weight] = max(dp[w1+weight], dp[w1]+value);
		}
	}
	int maximum = 0;
	for(int i=0; i<w+1; ++i)
		maximum = max(maximum, dp[i]);
    printf("%lld", maximum);
	fuck_u
}


Measured memory_bytes: 1024
use proconio::input;

fn main() {
    input! {
        mut n: u64,
    }
    if n == 1 {
        println!("a");
        return;
    }
    let mut sum = 0;
    let mut base = 1;
    let v = (0..26).map(|x| (x + b'a') as char).collect::<Vec<_>>();
    for i in 1..30 {
        // i 文字
        if sum + base * 26 < n {
            sum += base * 26;
            base *= 26;
            continue;
        }
        let mut index = n - sum - 1;
        let mut ans = vec!['a'; i];
        for j in 0..i {
            ans[j] = v[index as usize % 26];
            index /= 26;
        }
        ans.reverse();
        for c in ans {
            print!("{}", c);
        }
        println!();
        break;
    }
}


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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    size_t N, M;
    cin >> N >> M;
    auto modpow = [&MOD](auto n){
        unsigned long ret = 1, p = 2;
        while(n){
            if(n & 1)(ret *= p) %= MOD;
            (p *= p) %= MOD;
            n >>= 1;
        }
        return ret;
    };
    vector<unsigned long> S(N), T(M);
    copy_n(istream_iterator<unsigned long>(cin), N, S.begin());
    copy_n(istream_iterator<unsigned long>(cin), M, T.begin());
    vector<vector<unsigned long>> dp(N + 1, vector<unsigned long>(M + 1));
    for(size_t i = 0; i != N; ++i)for(size_t j = 0; j != M; ++j)(dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j] + (S[i] != T[j] ? dp[i][j] * (MOD - 1) : 1)) %= MOD;
    cout << dp.back().back() + 1 << endl;
    return 0;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  rep(i,N){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int sum=0;
  rep(i,N){
    if(i%2==0){
      sum+=vec[i];
    }
    if(i%2==1){
      sum-=vec[i];
    }
  }
  cout << sum << endl;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int r = scan.nextInt();
		int g = scan.nextInt();
		int b = scan.nextInt();
		int x = 10*g + b;
		if (x%4 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 21972
n = int(input())
s = input()

count_max = 0
for i in range(n-1):
    mae = s[:i+1]
    ato = s[i+1:]
    count = 0
    for i in range(ord("a"), ord("z") + 1):
        if chr(i) in mae and chr(i) in ato:
            count += 1
    if count > count_max:
        count_max = count    

print(count_max)

Measured memory_bytes: 3060
#!/usr/bin/env python3
from math import gcd

k = int(input())
ans = 1
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for k in range(1, k + 1):
            t = 0
            t = gcd(t, i)
            t = gcd(t, j)
            t = gcd(t, k)
            ans += t
print(ans - 1)


Measured memory_bytes: 67776
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int w, a, b; cin >> w >> a >> b;
	if ((a <= b&&b <= a+w)||(a<=b+w&&b+w<=a+w)) {
		cout << 0 << endl;
	}
	else {
		cout << min(abs(b+w-a), abs(a + w - b)) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N=int(input())
alist=list(map(int,input().split()))

def isAsc(lst):
  for i in range(1,len(lst)):
    if lst[i-1]>lst[i]:
      return False
  else:
    return True

min_a=min(alist)
max_a=max(alist)

answer_list=[]
if max_a>0 and max_a>-min_a:
  while(not isAsc(alist)):
    desc_index=-1
    
    for i in range(1,N):
      if alist[i-1]>alist[i]:
        desc_index=i
        break
  
    max_a=-10**9
    max_index=-1
    for i in range(N):
      if alist[i]>max_a:
        max_a=alist[i]
        max_index=i    
      
    while(alist[desc_index-1]>alist[desc_index]):
      alist[desc_index]+=max_a
      answer_list.append((max_index+1,desc_index+1))
else:
  while(not isAsc(alist)):
    desc_index=-1
    
    for i in reversed(range(1,N)):
      if alist[i-1]>alist[i]:
        desc_index=i-1
        break
  
    min_a=10**9
    min_index=-1
    for i in range(N):
      if alist[i]<min_a:
        min_a=alist[i]
        min_index=i    
      
    while(alist[desc_index]>alist[desc_index+1]):
      alist[desc_index]+=min_a
      answer_list.append((min_index+1,desc_index+1))

#print(answer_list)
print(len(answer_list))
for x,y in answer_list:
  print(x,y)

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll A,B,H,M;
    string S;
    cin >> A>>B>>H>>M;

    double A_kakudo = (H +M / 60.0) * 2.0 * M_PI / 12.0;
    double B_kakudo = M * M_PI / 30.0;

    //cout << A_kakudo << " " << B_kakudo << endl;

    double kakudo = min(abs(A_kakudo - B_kakudo), 2.0* M_PI - abs(A_kakudo - B_kakudo));

    //cout << cos(kakudo) << endl;

    double c = sqrt(A * A + B * B - 2.0 * A * B * cos(kakudo));

    if(kakudo<0.0000001){
        cout << setprecision(15) << abs(A - B) << endl;
    }
    else if(cos(kakudo)>0.99999999){
        cout << setprecision(15) << abs(A + B) << endl;
    }
    else{
        cout << setprecision(15) << c << endl;
    }
    
}


Measured memory_bytes: 4204
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	LL n;
	cin >> n;
	
	LL ans = 0;
	if(n % 2 == 0) {
		n /= 2;
		until(n == 0) {
			ans += n / 5;
			n /= 5;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<map>
#include<set>
#include<vector>
using namespace std;
typedef long long ll;
int main()
{
    ll r;
    while(cin>>r)
    {
        cout<<r*r;
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

/**
 * ABC111B
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();
        
        long sum = N*L + N*(N-1)/2;
        
        long min = 100000000000L;
        
        long ans =0;
        
        for(int i=1;i<=N;i++) {
        	long sum_tmp = sum - (L+i-1);
        	if(Math.abs(sum_tmp-sum)<Math.abs(ans-sum)) {
        		ans = sum_tmp;
        	}
        }
        
//        System.out.println(sum);
        
        System.out.println(ans);


        sc.close();
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less_equal<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

int main() 
{
    FAST;
    ll n;
    cin>>n;
    ll x=ceil(n/(ld)1000);
    cout<<(1000*x)-n;
    subt;
    return 0;
}

Measured memory_bytes: 3764
N,T,A,*hs=$<.read.split.map(&:to_i)

n = 0
d = 10**9
hs.each.with_index do |h,i|
    t = T-h*0.006
    t = (A-t).abs
    if t < d
        n = i
        d = t
    end
end

puts n+1


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

int main(){
    long long int n,a,b,c1,c2,x,y,ans;
    cin>>a>>b>>n;
    if(b<a) swap(a,b);
    ans=(b/n)-(a/n);
    if(a%n==0) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
S=input()

pre=S[0]

ans='Yes'

if len(S)%2==1:
    print('No')
else:
    for i in range(len(S)):
        if i%2==0:
            if S[i]!='h':
                ans='No'
        else:
            if S[i]!='i':
                ans='No'
    print(ans)

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

int main() {
	int n;
	cin>>n;
	double a=0,b;
	double arr[n];
	for(int i=0;i<n;i++)
	{
	cin>>arr[i];
	a=a+1/arr[i];
	}
	b=1/a;
	cout<<b;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/ruby
class TLLI
	def initialize
		@trianies=[nil,[0,0,0]]
	end
	def root_triany
		1
	end
	def allocate_triany
		siz=@trianies.size
		@trianies[siz]=[0,0,0]
		return siz
	end
	def set_a(id,value)
		return if !@trianies[id]
		@trianies[id][0]=value
	end
	def set_b(id,value)
		return if !@trianies[id]
		@trianies[id][1]=value
	end
	def set_c(id,value)
		return if !@trianies[id]
		@trianies[id][2]=value
	end
	def get_a(id)
		return if !@trianies[id]
		@trianies[id][0]
	end
	def get_b(id)
		return if !@trianies[id]
		@trianies[id][1]
	end
	def get_c(id)
		return if !@trianies[id]
		@trianies[id][2]
	end
end

class SETI <TLLI # a=>key, b=>left, c=>right
	def set_entry(key)
		x=root_triany
		y=0
		while x!=0&&!(x==root_triany&&get_a(x)==0) #fixme
			y=x
			if key<get_a(x)
				x=get_b(x)
			else
				x=get_c(x)
			end
		end
		if y==0
			set_a(root_triany,key)
		else
			leaf=allocate_triany
			set_a(leaf,key)
			if key<get_a(y)
				set_b(y,leaf)
			else
				set_c(y,leaf)
			end
		end
	end
	def find_entry(key)
		t=root_triany
		loop{
			return true if key==get_a(t)
			if key<get_a(t)
				t=get_b(t)
				return false if t==0
			else
				t=get_c(t)
				return false if t==0
			end
		}
	end
	def delete_entry(key)
		left=false
		prev=nil
		t=root_triany
		loop{
			break if key==get_a(t)
			prev=t
			if key<get_a(t)
				t=get_b(t)
				left=true
				return false if t==0
			else
				t=get_c(t)
				left=false
				return false if t==0
			end
		}
		if get_b(t)>0&&get_c(t)>0
			children=inorder_internal(get_c(t))+[t]
			set_a(t,get_a(children[0]))
 
			prev=children[1]
			#left of parent of t
			if prev!=t
				set_b(prev,0)
				left=true
			else
				left=false
			end
			t=children[0]
		end
		if get_b(t)+get_c(t)>0
			n=get_b(t)+get_c(t)
			if left
				set_b(prev,n)
			else
				set_c(prev,n)
			end
		else
			if left
				set_b(prev,0)
			else
				set_c(prev,0)
			end
		end
	end
	def inorder_internal(t)
		t==0 ? [] : inorder_internal(get_b(t))+[t]
	end
	def print_preorder(t)
		return if t==0
		Kernel.print " #{get_a(t)}"
		print_preorder(get_b(t))
		print_preorder(get_c(t))
	end
	def print_inorder(t)
		return if t==0
		print_inorder(get_b(t))
		Kernel.print " #{get_a(t)}"
		print_inorder(get_c(t))
	end
	def print_postorder(t)
		return if t==0
		print_postorder(get_b(t))
		print_postorder(get_c(t))
		Kernel.print " #{get_a(t)}"
	end
	def print
		print_inorder(root_triany);puts
		print_preorder(root_triany);puts
	end
end
 
seti=SETI.new
$<.drop(1).each{|l|
	a=l.split
	if a[0]=='insert'
		seti.set_entry(a[1].to_i)
	elsif a[0]=='find'
		puts seti.find_entry(a[1].to_i) ? :yes : :no
	elsif a[0]=='delete'
		seti.delete_entry(a[1].to_i)
	elsif a[0]=='print'
		seti.print
	end
}

Measured memory_bytes: 90040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  string s, t;cin>>s>>t;
  vector<char> a(s.size()), b(t.size());
  for(int i=0;i<s.size();i++){
    a[i]=s[i];
  }
  for(int i=0;i<t.size();i++){
    b[i]=t[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end(), greater<char>());
  cout << (a<b?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#define Bobyama
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000, MAX_M = 100000;
int N, M;
int L[MAX_M], R[MAX_M];

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

  cin >> N >> M;
  rep(i, M) cin >> L[i] >> R[i];

  int ma = 0, mi = INFINT;
  rep(i, M) {
      ma = max(ma, L[i]);
      mi = min(mi, R[i]);
  }

  cout << max(0, mi - ma + 1) << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod=1e9+7;
ll add(ll a, ll b)
{
    return ((a%mod)+(b%mod))%mod;
}
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   ll n;
   cin>>n;
   set<string>s;
   for(int i=0;i<n;i++)
   {
       string str;
       cin>>str;
       s.insert(str);
   }
   cout<<s.size();
}



Measured memory_bytes: 19284
#include <vector>
#include <iostream>
using namespace std;
const int mod = 100000;
int N, M, S;
int main() {
	while (cin >> N >> M >> S, N) {
		N *= N;
		M -= N;
		S -= N * (N + 1) / 2;
		vector<vector<int> > dp(M + 1, vector<int>(S + 1, 0));
		dp[0][0] = 1;
		for (int i = 0; i < N; i++) {
			vector<vector<int> > dp2(M + 1, vector<int>(S + 1, 0));
			dp2[0][0] = 1;
			for (int j = 1; j <= M; j++) {
				for (int k = j; k <= S; k++) {
					dp2[j][k] = dp[j][k - j];
					if (j >= 1) {
						dp2[j][k] += dp2[j - 1][k - 1];
						if (dp2[j][k] >= mod) dp2[j][k] -= mod;
					}
				}
			}
			dp = dp2;
		}
		int ret = 0;
		for (int i = 0; i <= M; i++) {
			ret += dp[i][S];
			if (ret >= mod) ret -= mod;
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 30180
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
*/

string s;
ll n,a[10010]={};

int main(void){
	cin>>n>>s;
	rep(i,n){
		a[s[i]]++;
	}
	cout<<(a['R']>a['B']?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            long ans = 1900 * m + 100 * (n - m);
            for (int i = 0; i < m; i++) {
                ans *= 2;
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int find(int n,int mod)
{
    int ans=0;
    while(n>0)
    {
        ans+=1;
        int x=setbits(n);
        n%=x;
    }
    return ans;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
string str;
cin>>str;
reverse(str.begin(),str.end());
int cnt=0;
for(int i=0;i<n;i++)
{
    if(str[i]=='1')
        cnt++;
}
///corner case if cnt==0.

int l=cnt-1, r=cnt+1;

int suml=0,sumr=0;
int resl=1,resr=1;
for(int i=0;i<n;i++)
{if(str[i]=='1')
   {
    suml+=resl;
    sumr+=resr;
   }
   if(l!=0)
    suml%=l;
sumr%=r;
resl*=2;
resr*=2;
if(l!=0)
resl%=l;
resr%=r;
}
resl=1;
resr=1;
vector<int> a;
for(int i=0;i<n;i++)
{int ans=0;
    if(str[i]=='1')
    {int x=suml;
    x-=resl;
if(l!=0)
    x%=l;
    if(x<0)
        x+=l;
        if(l!=0)
        ans+=1+find(x,l);
    }
    else
    {
        int x=sumr;
        x+=resr;
        x%=r;
        ans+=1+find(x,r);
    }
    resl*=2;
    resr*=2;
    if(l!=0)
    resl%=l;
    resr%=r;
    a.pb(ans);
}
reverse(a.begin(),a.end());
for(int i=0;i<a.size();i++)
    cout<<a[i]<<endl;







    return 0;
}


Measured memory_bytes: 5516
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)


int n;
vector<int> x, y;

int main()
{
  cin >> n;
  REP(i, n) {
    int w;
    cin >> w;
    x.push_back(w);
    y.push_back(w);
  }
  sort(y.begin(), y.end());
  REP(i, n) {
    if (x[i] < y[n / 2]) {
      cout << y[n / 2] << endl;
    } else {
      cout << y[n / 2 - 1] << endl;
    }
  }
}


Measured memory_bytes: 3948
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int my=in.nextInt(),debt=in.nextInt(),book=in.nextInt();
		int cred=my-book;
		if(cred<0) {
			if(debt+cred>=0)out.println(Math.abs(cred));
			else out.println("NA");
		}
		else out.println(0);
		out.flush();
	}

}



Measured memory_bytes: 26364
from bisect import bisect_right

def cal(X):
    output = []
    for i in range(len(X)):
        if len(output) > 0:
            if output[len(output)-1] == "S" and X[i] == "T":
                output.pop()
            else:
                output.append(X[i])
        else:
            output.append(X[i])

    return len(output)

def main():
    X = input()
    print(cal(X))

if __name__ == "__main__":
    main()


Measured memory_bytes: 5096
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=5005,M=1e9+7;
int ne[N*2],tot,fi[N],zz[N*2],size[N],f[N],dp[N][N],x,y,n,fac[N];
void jb(int x,int y){
	ne[++tot]=fi[x];
	fi[x]=tot;
	zz[tot]=y;
}
void dfs(int x,int y){
	size[x]=1;dp[x][1]=1;
	for (int i=fi[x];i;i=ne[i])
		if (zz[i]!=y){
			dfs(zz[i],x);
			for (int j=0;j<=size[x];j++)
				for (int k=0;k<=size[zz[i]];k++)
					(f[j+k]+=dp[x][j]*dp[zz[i]][k])%=M,
					(f[j]+=M-dp[x][j]*dp[zz[i]][k]%M*fac[k]%M)%=M;
			size[x]+=size[zz[i]];
			for (int j=0;j<=size[x];j++)dp[x][j]=f[j],f[j]=0;
		}
}
signed main(){
	scanf("%lld",&n);
	for (int i=1;i<n;i++){
		scanf("%lld%lld",&x,&y);
		jb(x,y);jb(y,x);
	}
	fac[0]=1;
	for (int i=2;i<=n;i++)fac[i]=fac[i-2]*(i-1)%M;
	dfs(1,0);
	int ans=0;
	for (int i=0;i<=n;i++)(ans+=fac[i]*dp[1][i])%=M;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 194944
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

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

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

bool prime[MAX_N];
void sieve(){
	for(int i =1;i <MAX_N;i++){
		prime[i]=true;
	}
	prime[0]=false,prime[1]=false;
	for(int i =2;i*i<MAX_N;i++){
		if(prime[i])
		for(int j =i+i;j<MAX_N;j+=i){
			prime[j]=false;
		}
	}
}

int main(){
	sieve();
	int n;
	while(cin>>n,n){
		for(int i = n;i >=2;i--){
			if(prime[i]&&prime[i-2]){
				cout <<i-2<<" "<<i<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1172
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    B=[0]*n
    for i in range(n-1,-1,-1):
        x=2*(i+1)
        other=0
        while x<=n:
            other+=B[x-1]
            x+=i+1
        if other%2==A[i]:
            B[i]=0
        else:
            B[i]=1
    print(sum(B))
    print(*[int(i+1) for i,x in enumerate(B) if x==1])

if __name__=='__main__':
    main()

Measured memory_bytes: 13112
#include <algorithm>
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define endl "\n"
#define sz(u) (int)(u.size())
#define L(x)(2*x)
#define R(x)(2*x+1)
#define M(x,y)((x+y)/2)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int n,m;
bool check(int r,int c){
	return (r>=1 && r<=n && c>=1 && c<=m);
}
const int mod=1e9+7;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	cin>>n>>m;
	char t[n+1][m+1];
	ll dp[n+1][m+1];
	memset(dp,0,sizeof(dp));
	dp[1][1]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>t[i][j];

	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(check(i-1,j)){
				if(t[i-1][j]!='#')
					dp[i][j]+=dp[i-1][j];
				dp[i][j]%=mod;
			}
			if(check(i,j-1)){
				if(t[i][j-1]!='#')
					dp[i][j]+=dp[i][j-1];
				dp[i][j]%=mod;
			}
		}
	}
	cout<<dp[n][m];			
}


Measured memory_bytes: 12356
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s; cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s[i] == '1') cout << 9;
    if (s[i] == '9') cout << 1;
  }
  cout << endl;
}

Measured memory_bytes: 256
fun main(args:Array<String>) {
    val (h,w) = readLine()!!.split(" ").map { it.toInt() }
    var map = (1..h).map { readLine()!!.toMutableList() }.toMutableList()
    for(i in (0 until w).reversed()) {
        if(map.map { it[i] }.all { it == '.' }) {
            map.forEach { it.removeAt(i) }
        }
    }
    map.filter { it.contains('#') }.forEach { println(it.joinToString("")) }
}

Measured memory_bytes: 38692
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ETree {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        string s;
        cin >> s;
        if (s.front() == '0' || s.back() == '1') {
            cout << -1 << endl;
            return;
        }

        int n = s.size();

        int l = 0;
        int r = n - 2;
        bool ok = true;
        while (l <= r) {
            if (s[l] != s[r]) {
                ok = false;
                break;
            }
            l++;
            r--;
        }

        if (!ok) {
            cout << -1 << endl;
            return;
        }

        vector<int> par(n);
        int last = n - 1;
        REV(i, n - 1, 0) {
            par[i] = last;
            if (s[i] == '1') {
                last = i;
            }
        }

        REP(i, n - 1) {
            cout << i + 1 << " " << par[i] + 1 << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ETree solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 2384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long A,B,C,k,q,w;
	cin>>A>>B>>C>>k;
	int  a=A,b=0,c=C*-1;
	if(A>=k)  cout<<k;
	else if(A+B+C==k) cout<<a+c;
	else{
		q=k-A;
		if(B>=q) cout<<a;          
		else 
		{
			w=q-B;
			w=w*-1;
			cout<<a+w;
		}
	} 
}

Measured memory_bytes: 3588
#include <stdio.h>

void p2(unsigned int n){
	for(int i=31;i>=0;i--)printf("%u",(n>>i)&1);
	puts("");
}
int main(){
	unsigned int n;
	scanf("%u",&n);
	p2(n);
	p2(~n);
	p2(n<<1);
	p2(n>>1);
}


Measured memory_bytes: 2112
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Twinkle Twinkle Little Star
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BOddString solver = new BOddString();
        solver.solve(1, in, out);
        out.close();
    }

    static class BOddString {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            String concate = "";
            for (int i = 0; i < s.length(); i++) {
                if (i % 2 == 0)
                    out.print(s.charAt(i));
            }
            out.println();
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  for (int i = 0; i < S.length(); i++) {
    char ch = S.at(i);
    ch += N;
    if (ch > 90) ch = 64 + (ch - 90);
    cout << ch;
    if (i == S.length()) cout << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pq priority_queue
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define elif else if

using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using pll=pair<ll,ll>;
using pss=pair<string,string>;
using pdd=pair<ld,ld>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-9;

template<class T> void chmin(T &a, T b){a=min(a, b);}
template<class T> void chmax(T &a, T b){a=max(a, b);}

ll abs1(ll a){if(a>=0)return a;else return -a;}
ll pow1(ll a,ll b,ll p=LLONG_MAX){ll ret=1;while(b!=0){if((b&1)==1)ret*=a;a*=a;if(a>=p)a%=p;if(ret>=p)ret%=p;b=b>>1;}return ret;}
int digit(ll a,ll b=10){int i=0;while(a!=0){a/=b;i++;}return i;}
ll gcd1(ll a,ll b){if(a==0 || b==0)return 0;ll n;while(a%b!=0){n=a%b;a=b;b=n;}return b;}
ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;ll a[100],b[100];a[0]=n;b[0]=m;int i=1;
  while(b[i-1]!=0){a[i]=b[i-1];b[i]=a[i-1]%b[i-1];i++;}n=i;if(c%a[n-1]!=0)return 0;ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){ll cnt=x;x=y;y=cnt-(a[n-i-1]/b[n-i-1])*y;}return x;
}
ll modInv(ll a,ll p=MOD){a%=p;ll n=solveLinear(a,p,1);n%=p;if(n<0)return n+p;return n;}
ll fact(ll n,ll p=MOD){if(n<0)return 0;ll ret=1;for(int i=1;i<=n;i++){ret=ret*i;if(ret>=p)ret%=p;}return ret;}
ll perm(ll n,ll k,ll p=MOD){if(n<0 || k<0 || n<k)return 0;ll ret=1;rep(i,k){ret=ret*(n-i);if(ret>=p)ret%=p;}return ret;}
ll binom(ll n,ll k,ll p=MOD){return (perm(n,k,p)*modInv(fact(k)))%p;}

int main(){
  ll i,j,k,cnt=0;
  ll h,w,n;
  cin>>h>>w>>n;
  ll m=max(h,w);
  cout<<(n+m-1)/m<<endl;
}


Measured memory_bytes: 256
import copy
n,k = map(int,input().split())
ai = [int(i) for i in input().split()]

old_ai = ai
cnt = 0

while 1 == 1:
    old_ai = copy.deepcopy(ai)
    li = [0]*(n+1)
    for i in range(n):
        li[max(0,i-ai[i])] += 1
        li[min(n,i+1+ai[i])] -= 1
        #print(li)
    #print(li)
    tmp = 0
    for i in range(n):
        if i == 0:
            ai[i] = li[i]
            tmp += ai[i]
        else:
            ai[i] = li[i] + ai[i-1]
            tmp += ai[i]
    #print(rui)
    if ai == old_ai:
        print(*ai)
        exit()
        break
    cnt += 1
    if cnt == k:
        print(*ai)
        exit()
    old_ai = ai

Measured memory_bytes: 179240
def calc(x, S):
    res = set(S)
    cnt = 0
    while (len(res) != 1):
        cnt += 1
        t = ""
        N = len(S)
        for y in range(N - 1):
            if (S[y] == x):
                t += x
            elif (y + 1 < len(S) and S[y + 1] == x):
                t += x
            else:
                t += S[y]
        S = t
        res = set(S)
    return cnt


if __name__ == "__main__":
    S = input()
    res = set(S)
    result = 2 ** 50
    for x in res:
        result = min(result, calc(x, S))
    print (result)


Measured memory_bytes: 3064
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long[] a = new long[n];
		for(int i = 0;i < n; ++i)a[i] = scan.nextInt();

		long ans = 0;
		for(int i = 1; i < n; ++i){
			if(a[i-1] > a[i]){
				ans += a[i-1] - a[i];
				a[i] += a[i-1] - a[i];
			}
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 61280
use std::io::stdin;

#[derive(Default)]
struct Scanner {
	buffer: Vec<String>
}

impl Scanner {
	fn next<T: std::str::FromStr> (&mut self) -> T {
		loop {
			if let Some(token) = self.buffer.pop() {
				return token.parse().ok().expect("Failed parse");
			}
			let mut input = String::new();
			stdin().read_line(&mut input).expect("Failed read");
			self.buffer = input.split_whitespace().rev().map(String::from).collect();
		}
	}
}

fn main() {
	let mut scan = Scanner::default();
	let mut x: u128 = scan.next();
	let mut ans: Vec<char> = vec![];
	while x > 0 {
		let mut c = ('a' as u8 + (x%26) as u8 - 1) as char;
		if c == '`' {
			c = 'z';
			x = x / 26 - 1;
		} else {
			x /= 26;
		}
		ans.push(c);
	}
	for i in (0..ans.len()).rev() {
		print!("{}", ans[i]);
	}
	println!("");
}


Measured memory_bytes: 2172
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
sosuu = [2]
A = 5555
for L in range(3, A, 2): # 2 以外の素数は奇数なので
    for L2 in sosuu:
        if L % L2 == 0:
            break # 素数でないことがわかったらそれ以上ループする必要はない
    else: # break で抜けることがなかったら L は素数（Python 特有の制御構文）
        sosuu.append(L)
ans=[]
count=0
for i in sosuu:
    if i%5==1:
        count+=1
        ans.append(i)
    if count==n:
        print(*ans)
        exit()

Measured memory_bytes: 5068
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;

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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, K, x, ans = 0;
    cin >> N >> K;
    REP(i, N) {
        cin >> x;
        ans += 2 * min(x, (K - x));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#import<atcoder/all>
#define f(i)std::cout<<i<<' ';
int n,f;int main(){auto&c=std::cin>>n>>f;atcoder::scc_graph g(n);for(;c>>n>>f;)g.add_edge(n,f);f(size(g.scc()))for(auto i:g.scc()){f(size(i))for(int j:i)f(j)}}

Measured memory_bytes: 40076
n=int(input())
s=input()

w=s.count("R")*s.count("G")*s.count("B")
cnt=0

for i in range(n):
    for j in range(i+1,n):
        k=j+j-i
        if k>=n:
            break        
        if s[i]!=s[j] and s[k]!=s[j] and s[i]!=s[k]:
            cnt+=1
            

answer=w-cnt
print(answer)


Measured memory_bytes: 9200
n=int(input())
A=list(map(int,input().split()))
Q=[a for a in A if a%4==0]
W=[a for a in A if a%4==2]
if len(Q)>=n//2:
  print("Yes")
else:
  if len(W)>=n-len(Q)*2:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 14252
#include<iostream>
#include<cstring>

using namespace std;

const int MAX = 31;
const int INF = (1<<25);
int T[MAX][MAX];
int w,h;
bool edge[MAX][MAX][MAX][MAX];
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

void print(){
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++) cout << T[i][j] << " ";
    cout << endl;
  }
  cout << endl;
}
void init(){
  for(int i = 0; i < MAX; i++)
    for(int j = 0; j < MAX; j++)
      T[i][j] = INF;

  memset(edge,true,sizeof(edge));
}


bool inside(int x, int y){
  return 0<=x&&x<w&&0<=y&&y<h;
}
void dfs(int x, int y, int t){
  
  if(t >= T[y][x]) return;

  T[y][x] = t;

  for(int i = 0; i < 4; i++){
    int nx = x+dx[i];
    int ny = y+dy[i];
    if(inside(nx,ny) && !edge[y][x][ny][nx]) dfs(nx,ny,t+1);
  }
}

int main(){
  while(cin >> w >> h && w+h){
    init();

    for(int i = 0; i < 2*h-1; i++)
      for(int j = 0; j < w-1+(i%2); j++){
	bool n;
	cin >> n;
	if(i%2) edge[i/2][j][i/2+1][j] = edge[i/2+1][j][i/2][j] = n;
	else edge[i/2][j][i/2][j+1] = edge[i/2][j+1][i/2][j] = n;
      }

    dfs(0,0,0);

    if(T[h-1][w-1] == INF) cout << "0" << endl;
    else cout << T[h-1][w-1]+1 << endl;

    //   print();
  }
  return 0;
}

Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define c(a,n) for(int i = 0; i < n; i++) cin >> a[i];
#define ffor(n) for(int i = 0; i < n; i++)
#define float long double
typedef vector<int> vi;
typedef vector<float> vf;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef unordered_map<string,int> umsi;
 
 
int32_t main()
{
    fast_io;
    
       long double d,t,s;
       cin>>d>>t>>s;
       long double tn=d/s;
       if(tn<=t)cout<<"Yes";
       else cout<<"No";

    return 0;
}

Measured memory_bytes: 3740
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#define ll long long
#define FOR(i,n) for(int i=0;i<(n);i++)
using namespace std;
const int INF = (int)1e9,mxN = (int)1e5;

void solve()
{
	double d,t,s;
	cin >> d >> t >> s;
	double k = d/s;
	cout << (k<=t?"Yes":"No");
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
}



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

int main(){
    double n;cin>>n;
    double original = n / 1.08;

    bool judge = false;
    int val;
    for (int i=-10;i<11;i++){
        if ((int)(((int)original + i) * 1.08) == n){
            val = (int)original + i;
            judge = true;
            break;
        }
    }
    if (judge){
        cout << val <<endl;
    } else {
        cout << ":(" <<endl;
    }
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int M = 1000000000 + 7;
int n, a;

int main() {
	if (0) freopen("a.in", "r", stdin);
	scanf("%d", &n);
	ll ans = 1, cur = 1, cnt = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a);
		if (a >= cur)
			cur += 2, ++cnt;
		else {
			ans = (ans*(cnt + 1)) % M;
		}
	}
	while (cnt > 0)
		ans = (ans*cnt--) % M;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256