akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v){
    if(!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}

//---------

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int a = 0, b = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'C') a = 1;
        if(s[i] == 'F'&& a == 1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;
bool sr(ll a, ll b)
{
	return a > b;
}
bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(ll n)
{
	int count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
template <class T>
void print(const T &value)
{
	std::cout << value << std::endl;
}

int main()
{
	string s;
	cin>>s;
	
	vector<string>aki={"AKIHABARA","AKIHBARA","AKIHBRA","AKIHBR","AKIHABRA","AKIHABR","AKIHABAR","AKIHBAR",
	"KIHABARA","KIHBARA","KIHBRA","KIHBR","KIHABAR","KIHBAR","KIHBARA","KIHBRA","KIHABR"};
	bool ans=false;
	rep(i,17){
		if(s==aki[i]){
			ans=true;
		}
	}
	if(ans){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}

}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll a; double b; cin>>a>>b;
  ll c=b*100+0.1;
  ll ans=a*c/100;
  cout<<ans<<endl;
  
}

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


int main()
{
    int A,B;
    cin >> A >> B;
    vector<int> h(A);
    for(int i=0; i<A; i++)
    {
        cin >> h.at(i);
    }
    sort(h.begin(),h.end());
    int min=h.at(A-1);
    for(int i=0; i<A-B+1; i++)
    {
        if(min>h.at(B-1+i)-h.at(i))
        {
            min=h.at(B-1+i)-h.at(i);
        }
    }
    cout << min << endl;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long int A,B,K; cin>>A>>B>>K;
    A=A-K;
    if(A<0){
        B=B+A;
        A=0;
        if(B>=0) {
            cout << A << ' ' << B;
        }
        else{
            cout<<A<<' '<<0;
        }
    }
    else{
        cout<<A<<' '<<B;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
    int n,k,i=1;
    double ans=0.0;
    scanf("%d%d", &n, &k);
    if(n>=k) ans+=(n-k+1.0)/(n+0.0);

    while(1)
    {
        if(k==(k+(k%2))/2) break;
        else
        {
            if((k+(k%2))/2 > n);
            else if(k-1<=n)
            {
                ans+=((k-(k+(k%2))/2)+0.0)/n*pow(0.5, i+0.0);

            }
            else
            {
                ans+=((n+1-(k+(k%2))/2)+0.0)/n*pow(0.5, i+0.0);
            }
            
            k=(k+(k%2))/2;
            i++;
        }
    }
    printf("%14.12f", ans);

    return 0;
}

Measured memory_bytes: 128
import itertools
import math

N, D = map(int, raw_input().split())
X = [map(int, raw_input().split()) for _ in range(N)]

def calc_dist(Y, Z):
    return math.sqrt(sum((y - z) ** 2 for y, z in zip(Y, Z)))

print sum([calc_dist(Y, Z).is_integer() for Y, Z in itertools.combinations(X, 2)])


Measured memory_bytes: 2692
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
constexpr ll R=2e5+69, INF=2e9+6969;

ll l,r,n,k,a[R],ans;

int main()
{
	scanf("%lld%lld", &n, &k);
	for(int i=0;i<n;++i) scanf("%lld", &a[i]);
	ans = INF;
	l = 1;
	r = INF;
	//  #warning change here :)
	while(l<r)
	{
		ll s = (l+r)/2;
		//  printf("%lld\n", s);
		ll licz = 0;
		for(int i=0;i<n;++i) licz += ((s-1 + a[i])/s - 1);
		if(k>=licz)
		{
			ans = s;
			r = s;
		}
		else l = s + 1;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 5256
def findProductSum(A, n): 
    array_sum = sum(A)
    array_sum_square = array_sum ** 2
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 
    return (array_sum_square -
            individual_square_sum) // 2

n = input()
arr = list(map(int, input().split()))
res = findProductSum(arr, len(arr)) % (10**9 + 7)
print(res)




Measured memory_bytes: 94348
#include<stdio.h>

int main(void){
  int i,j;
  int a[4];
  int b[4];
  int hit,blow;

  while(1){
    if(scanf("%d ",&a[0])==EOF)break;
    for(i=1;i<4;i++)scanf("%d ",&a[i]);
    for(i=0;i<4;i++)scanf("%d ",&b[i]);

    hit = 0;
    blow = 0;

    for(i=0;i<4;i++){
      for(j=0;j<4;j++){
	if(a[i] == b[j]){
	  if(i == j)hit++;
	  else blow++;
	}
      }
    }

    printf("%d %d\n",hit,blow);

  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
     string c,c1={"..."};
     int l;
     cin>>l;
     cin>>c;
     int k=c.size();
      if(k<=l)cout<<c<<endl;
      else{
        cout<<c.substr(0,l)+c1<<endl;
      }
}


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

int main(int argc, char const *argv[])
{
	int k;
	cin >> k;
	if(k % 7 == 0)
		k /= 7;
	if(__gcd(10, k) != 1)
	{
		cout << -1;
		return 0;
	}

	ll x = 1 % k;
	ll len = 1;

	while(x != 0)
	{
		x = (x*10+1)%k;
		len++;
	}
	
	cout << len;

	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>

using namespace std;
using ll = long long int;

int main()
{
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e - a <= k){
    if(e - b <= k && b - a <= k)
    {
      if(e - c <= k && a - c <= k)
      {
        if(e - d <= k && a - d <= k)
        {
          cout << "Yay!" << endl;
          return 0;
        }
      }
    }
  }
  cout << ":(" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
LL f(int x){
  return x*x*x;
}
int main(void){
  int z;
  while(cin>>z){
    LL ans = 1e8;
    if(z==0) break;
    FOR(x,1,z){
      FOR(y,1,z){
        if(f(z)<f(x)+f(y)) continue;
        ans = min(ans, f(z)-f(x)-f(y));
      }
    }
    cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 868
#define _CRT_SECURE_NO_WARNINGS

#define N (1<<17)
#define MODULO (1000000007)
#define HA1 (2420609)
#define HA2 (19260817)
#define MMAX (10000000000001000LL)

#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <deque>
#include <vector>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
using namespace std;

inline int GetRand()
{
	int Res = rand()*rand()*rand();
	Res -= rand()*rand();
	Res += rand();
	return Res;
}

long long k;
long long a[N];

int main()
{
	scanf("%lld", &k);
	printf("50\n");
	long long xx = k / 50LL;
	int yy = (int)(k % 50LL);
	for (int i = 0;i < 50;i++)
	{
		a[i] = (long long)i + xx;
	}
	for (int i = 0;i < yy;i++)
	{
		a[i] += 51LL;
		for (int j = 0;j < 50;j++)
		{
			a[j]--;
		}
	}
	for (int i = 0;i < 50;i++)
	{
		printf("%lld ", a[i]);
	}
	printf("\n");
	//system("pause");
	return 0;
}



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

int main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s<t)
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
}

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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }

    /* ユークリッドの互除法 */
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    return res;
}

void solve(long long H, long long N, vpi M, int a_max) {
    sort(M.begin(), M.end());

    int ans = 1e9;
    vi dp(H + 1 + a_max, 1e9);
    dp[0] = 0;

    for (int i = M[0].first; i <= H + a_max; i++) {
        for (int j = 0; j < N; j++) {
            if (i - M[j].first >= 0 && dp[i - M[j].first] + M[j].second <= dp[i]) {
                dp[i] = dp[i - M[j].first] + M[j].second;
            }
        }
    }

    for (ll i = H; i < dp.size(); i++) {
        ans = min(dp[i], ans);
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
    long long H;
    std::cin >> H;
    long long N;
    std::cin >> N;
    vpi M(N);
    int a_max = 0;
    for (int i = 0; i < N; i++) {
        std::cin >> M[i].first;
        std::cin >> M[i].second;
        a_max = max(a_max, M[i].first);
    }
    solve(H, N, std::move(M), a_max);
    return 0;
}


Measured memory_bytes: 384
def approve(A: list) -> bool:
    is_even = lambda number: number % 2 is 0
    is_odd = lambda number: not is_even(number)
    is_dividable_by_3 = lambda number: number % 3 is 0
    is_dividable_by_5 = lambda number: number % 5 is 0
    is_dividable_by_3_or_5 = lambda number: is_dividable_by_3(number) or is_dividable_by_5(number)
    is_approved = lambda number: (
        is_odd(number) or
        (is_even(number) and is_dividable_by_3_or_5(number)))

    approved = all([is_approved(Ai) for Ai in A])

    return approved


N = input()
A = list(map(int, input().split()))

answer = 'APPROVED' if approve(A) else 'DENIED'

print(answer)


Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    int A1,A2,A3;

    cin >> A1 >> A2 >> A3;

    if(A1 + A2 + A3 <= 21)cout << "win" << endl;
    else cout << "bust" << endl;
    
    return 0;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll power(ll x, ll y){//繰り返し2乗法
  if(y < 0){
    return 0;
  }else if(y == 0){
    return 1LL;
  }else if(y%2 == 0){//偶数
    return power(x,y/2)*power(x,y/2);
  }else{//奇数
    return power(x,y-1)*x;
  }
}

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N; cin >> N;
  string s, t; cin >> s >> t;
  
  //main
  string ans = "";
  for(int i=0; i<N; i++){
    ans += s[i];
    ans += t[i];
  }
  
  // output
  cout << ans << endl;
  
  return 0;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    int mins='z',mint='z';
    int maxs='a',maxt='a';
    for(int i=0;i<s.size();i++){
        mins=min(mins,(int)s[i]);
        maxs=max(maxs,(int)s[i]);
    }
    for(int i=0;i<t.size();i++){
        mint=min(mint,(int)t[i]);
        maxt=max(maxt,(int)t[i]);
    }
    if(mins<maxt)cout<<"Yes"<<endl;
    else if(mins==maxs&&mint==maxt&&s.size()<t.size())cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

signed main() {
  int K, T;
  cin >> K >> T;
  
  vector<int> A(T);
  for( int i = 0; i < T; i++ ){
    cin >> A.at(i);
  }
  
  vector<int> zyun(K);
  int big = 0;
  int basyo;
  int big2 = 0;
  int basyo2;
  
  for( int i = 0; i < K; i++ ){
    big = 0;
    big2 = 0;
    for( int j = 0; j < T; j++ ){
      if( A.at(j) > big ){
        big2 = big;
        basyo2 = basyo;
        big = A.at(j);
        basyo = j;
      }else if( A.at(j) > big2 ){
        big2 = A.at(j);
        basyo2 = j;
      }
    }
    if( i == 0 ){
        zyun.at(i) = basyo;
        A.at(basyo)--;
    }else{
      if( zyun.at(i-1) == basyo ){
        zyun.at(i) = basyo2;
        A.at(basyo2)--;
      }else{
        zyun.at(i) = basyo;
        A.at(basyo)--;
      }
    }
  }
  
  int ans = 0;
  for( int i = 1; i < K; i++ ){
    if( zyun.at(i-1) == zyun.at(i) ) ans++;
  }
  cout << ans << endl;
  
    
}


Measured memory_bytes: 384
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let mut bingo: Vec<Vec<usize>> = vec![];
    bingo.push(vec![read(), read(), read()]);
    bingo.push(vec![read(), read(), read()]);
    bingo.push(vec![read(), read(), read()]);
    let mut bingo_result: Vec<Vec<bool>> = vec![vec![false; 3]; 3];
    let N: usize = read();
    for _ in 0..N {
        let v: usize = read();
        for i in 0..3 {
            for j in 0..3 {
                if bingo[i][j] == v {
                    bingo_result[i][j] = true;
                }
            }
        }
    }
    if bingo_result[0].iter().all(|&x| x)
        || bingo_result[1].iter().all(|&x| x)
        || bingo_result[2].iter().all(|&x| x)
    {
        println!("Yes");
        return;
    }
    if column(0, &bingo_result).iter().all(|&x| x)
        || column(1, &bingo_result).iter().all(|&x| x)
        || column(2, &bingo_result).iter().all(|&x| x)
    {
        println!("Yes");
        return;
    }
    if diagonal1(&bingo_result).iter().all(|&x| x) || diagonal2(&bingo_result).iter().all(|&x| x) {
        println!("Yes");
        return;
    }
    println!("No");
}

fn column(column_num: usize, bingo_result: &Vec<Vec<bool>>) -> Vec<bool> {
    vec![
        bingo_result[0][column_num],
        bingo_result[1][column_num],
        bingo_result[2][column_num],
    ]
}

fn diagonal1(bingo_result: &Vec<Vec<bool>>) -> Vec<bool> {
    vec![bingo_result[0][0], bingo_result[1][1], bingo_result[2][2]]
}

fn diagonal2(bingo_result: &Vec<Vec<bool>>) -> Vec<bool> {
    vec![bingo_result[0][2], bingo_result[1][1], bingo_result[2][0]]
}


Measured memory_bytes: 4352
N = int(input())
XL = [list(map(int, input().split())) for i in range(N)]

paths = []
for x, l in XL:
    paths.append((x-l, x+l))
paths = sorted(paths, key=lambda x: x[1])

ans = 0
cur = None
for (l, r) in paths:
    if cur is None or cur <= l:
        ans += 1
        cur = r

print(ans)

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

typedef struct node *link;
struct node{
  int key;
  link le,ri,pa;
};
link head;

void insert(int a);
void inorder(link h);
void preorder(link h);
int find(int a);

int main(){
  int m,k;
  char op[10];
  int i;

  head=NULL;
  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%s",op);
    if(strcmp(op,"insert")==0){
      scanf("%d",&k);
      insert(k);
    }else if(strcmp(op,"print")==0){
      inorder(head);
      printf("\n");
      preorder(head);
      printf("\n");
    }else if(strcmp(op,"find")==0){
      scanf("%d",&k);
      if(find(k)==1)  printf("yes\n");
      else  printf("no\n");
    }
  }

  return 0;
}

void insert(int a){
  link x,y,z;
  z=malloc(sizeof(struct node));
  z->key=a; z->le=NULL; z->ri=NULL;
  y=NULL;  x=head;
  while(x!=NULL){
    y=x;
    if(z->key<x->key)   x=x->le;
    else                x=x->ri;
  }
  z->pa=y;

  if(y==NULL)             head=z;
  else if(z->key<y->key)  y->le=z;
  else                    y->ri=z;
}

void inorder(link h){
  if(h==NULL) return;
  inorder(h->le);
  printf(" %d",h->key);
  inorder(h->ri);
}

void preorder(link h){
  if(h==NULL) return;
  printf(" %d",h->key);
  preorder(h->le);
  preorder(h->ri);
}

int find(int a){
  link x;
  int ans;
  x=head;
  while(1){
    if(x==NULL){
      ans=0;  break;
    }else{
      if(x->key==a){
        ans=1;  break;
      }else if(x->key>a){
        x=x->le;
      }else{
        x=x->ri;
      }
    }
  }
  return ans;
}



Measured memory_bytes: 20452
def get_parent x
    @parent[x] = get_parent(@parent[x]) if @parent[x] != x
    @parent[x]
end

while true
    h, w = gets.chomp.split.map(&:to_i)
    break if [h, w] == [0, 0]

    map = []
    h.times{map << gets.chomp}
    @parent = (0...(h * w)).to_a
    for y in 0...h
        for x in 0...w
            [[y - 1, x], [y, x - 1]].each{|y2, x2|
                next if y2 < 0 || x2 < 0
                next if map[y2][x2] != map[y][x]
                p1 = get_parent(y * w + x)
                p2 = get_parent(y2 * w + x2)
                min, max = [p1, p2].minmax
                @parent[max] = min
            }
        end
    end
    count = 0
    @parent.each_with_index{|x, i| count += 1 if x == i}
    puts count
end



Measured memory_bytes: 7048
import math

S = input()
K = int(input())


before = ""
count = 0
if len(S) == 1:
    out = K // 2
else:
    for s in S:
        if before == s:
            count += 1
            before = ""
        else:
            before = s
    ### If before is empty at the end of the loop, the last character should be replaced ->
    ### Can aboid to be same as the first character of the string
    if before == S[0]:
        first_same_num = 1
        before2 = S[0]
        for s in S[1:]:
            if before2 == s:
                first_same_num += 1
            else:
                break
        if first_same_num % 2 == 0:
            first_last_replace = 0      # Even -> the first one could be replaced anyway
        else:
            if first_same_num != len(S):
                first_last_replace = K - 1
            else:
                first_last_replace = math.ceil((K - 1) / 2)
    else:
        first_last_replace = 0

    out = count * K + first_last_replace

print(out)


Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split()))

cnt = 0
prev = A[0]
ans = 0
for i in range(1,N):
    if prev >= A[i]:
        cnt += 1
    else:
        ans = max(ans,cnt)
        cnt = 0
    prev = A[i]

ans = max(ans,cnt)
print(ans)


Measured memory_bytes: 20372
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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(std::io::BufReader::new(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)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        l: i64,
        r: i64,
    }
    let mut m = vec![];

    for i in l..min(l + 2020, r+1) {
        m.push(i % 2019);
    }
    let mut ans = 3000;
    for i in 0..m.len() {
        for j in 0..m.len() {
            if i == j {
                continue;
            }
            let acc = (m[i] * m[j]) % 2019;
            if acc < ans {
                ans = acc;
            }
        }
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef	long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define PI(n) ((double)acos(n))
#define clr0(n) (memset(n,0,sizeof n))
#define clr1(n) (memset(n,-1,sizeof n))
int dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	// online submission
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
}
int main()
{
	
	string x;
	cin >> x;
	string y;
	y = x;
	reverse(all(y));
	if (x == y)
		cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
def remaining_balls_number(dict_sum_of_each_balls, remove_balls_color):
    if dict_sum_of_each_balls[remove_balls_color]:
        now_number = dict_sum_of_each_balls[remove_balls_color]
        dict_sum_of_each_balls[remove_balls_color] = now_number - 1
    return dict_sum_of_each_balls


if __name__ == '__main__':
    a_color, b_color = input().split()
    a_number, b_number = map(int, input().split())
    remove_color_ball = input()
    answer = remaining_balls_number(
        {a_color: a_number, b_color: b_number}, remove_color_ball)
    print(answer[a_color], answer[b_color])


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

using namespace std;

#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  nl "\n";
#define FIO ios_base::sync_with_stdio(false);cout.setf(ios::fixed);cout.precision(10);cout.tie(nullptr);cin.tie(nullptr);

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

template < class T> inline T biton(T n, T pos) { return n | ((T)1 << pos); }
template < class T> inline T bitoff(T n, T pos) { return n & ~((T)1 << pos); }
template < class T> inline T ison(T n, T pos) { return (bool)(n & ((T)1 << pos)); }
template < class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); }return a; }

template <class T> inline T bigmod(T p, T e, T m) {
	T ret = 1;
	for (; e > 0; e >>= 1) {
		if (e & 1) ret = (ret * p) % m; p = (p * p) % m;
	} return (T)ret;
}

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " is " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define debug(...)
#endif



void solve()
{
	long long n, m, k;
	cin >> n >> m >> k;

	vector<long long> items(n + 1), items2(m + 1);

	for (int i = 1; i <= n; i++) {
		cin >> items[i];
	}

	vector<long long> com(m + 1);

	for (int i = 1; i <= m; i++) {
		cin >> items2[i];
		com[i] = items2[i];
		com[i] += com[i - 1];
	}

	long long mx = 0;
	long long taken = 0;

	for (int i = 0; i <= n; i++) {
		
		if (taken + items[i] > k) {
			break;
		}

		taken += items[i];
	    
		long long rem = k - taken;

		long long ub = upper_bound(com.begin(), com.end(), rem) - com.begin();
		ub--;

		long long res = ub + i;
		mx = max(res, mx);
	}

	cout << mx << nl;

}

int main()
{
	FIO;

	int t = 1;

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

	return 0;
}

Measured memory_bytes: 7948
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

struct Edge {
    ll to, time, money;
    Edge(){}
    Edge(ll to, ll time, ll money):to(to), time(time), money(money){}
};

struct Info {
    ll time, node, money;
    Info(){}
    Info(ll time, ll node, ll money):time(time), node(node), money(money){}

    bool operator<(const Info& another) const {
        return time > another.time;
    }
};


int main(int argc, char const *argv[]) {
    ll n,m,s; cin>>n>>m>>s;
    vector<vector<Edge>> g(n);
    rep(i,m) {
        int u,v; cin>>u>>v; --u,--v;
        ll a,b; cin>>a>>b;
        g[u].emplace_back(v,b,a);
        g[v].emplace_back(u,b,a);
    }

    vector<ll> c(n),d(n);
    rep(i,n) cin>>c[i]>>d[i];

    chmin(s, 2550ll);
    priority_queue<Info> pq;
    pq.emplace(0, 0, s);
    vector<vector<ll>> dp(n, vector<ll>(3000, LINF));
    dp[0][s] = 0;

    while (!pq.empty()) {
        Info cur = pq.top(); pq.pop();
        int v = cur.node; int mon = cur.money;

        // 頂点間の遷移
        for (auto &&e: g[v]) {
            int to_money = mon-e.money;
            if (to_money < 0) continue;
            if (chmin(dp[e.to][to_money], dp[v][mon]+e.time)) {
                pq.emplace(dp[e.to][to_money], e.to, to_money);
            }
        }

        // 銀貨間の遷移
        if (mon+c[v] > 2800) continue;
        if (chmin(dp[v][mon+c[v]], dp[v][mon]+d[v])) {
            pq.emplace(dp[v][mon+c[v]], v, mon+c[v]);
        }
    }

    for (int i = 1; i < n; ++i) {
        ll ans = LINF;
        rep(j,3000) {
            chmin(ans, dp[i][j]);
        }
        cout << ans << '\n';
    }
    return 0;
}

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

/*
時計の針の距離を求める問題。
三角関数かな〜。
*/

double calcHourDeg(int minute) {
    double deg = minute * 0.5;
    while (deg > 360) {
        deg -= 360;
    }
    return deg;
}

double caclMinuteDeg(int minute) {
    double deg =  minute * 6.0;
    while (deg > 360) {
        deg -= 360;
    }
    return deg;
}

double degToRad(double deg) {
    return deg / 180 * M_PI;
}

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    int passed_minute = H * 60 + M;

    double hourDeg = calcHourDeg(passed_minute);
    double minuteDeg = caclMinuteDeg(passed_minute);

    double hourRad = degToRad(hourDeg);
    double minuteRad = degToRad(minuteDeg);

    double theta = abs(hourRad - minuteRad);

    double dx = A * cos(theta) - B;
    double dy = A * sin(theta);

    double dist = sqrt(dx * dx + dy * dy);
    cout << fixed << setprecision(15) << dist << endl;
}

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

int digitNumber(ll x){
  int number=0;
  while(x>0){
    x/=10;
    number++;
  }
  return number;
}



int main() {
  ll N;
  cin >> N;
   
  vector<pair<ll,ll>> factor;
  for(ll a=1LL; a*a<=N;a++){
    if(N%a==0){
      ll b=(N/a);
      
      pair<ll,ll> p;     
      p=make_pair(a,b);
      
      factor.push_back(p);
    }
  }
  
  int answer=digitNumber(N);
  
  for(auto p: factor){
    int tmp=max(digitNumber(p.first),digitNumber(p.second));

    if(answer>tmp){
      answer=tmp;
    }
  }
  cout << answer << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
//#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

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

	int H, W;
	char C[100][100];

	cin >> H >> W;

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> C[i][j];
		}
	}

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cout << C[i][j];
		}
		cout << endl;
		for (int j = 0; j < W; j++)
		{
			cout << C[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
int main()
{
    int n;
    cin>>n;
    lli arr[n];
    lli sum=0;
    for(int i=0;i<n;i++) 
    { cin>>arr[i]; sum+=arr[i];}
    lli dp[n][n];
    for(int len=1;len<=n;len++)
    {
        int j;
        for(int i=0;i<=n-len;i++)
        {   j=i+len-1;
            if(len==1) dp[i][i]=arr[i];
            else if(len==2)
            {
                dp[i][i+1]=max(arr[i],arr[i+1]);
            }
            else 
            {
                dp[i][j]=max(arr[i]+min(dp[i+2][j],dp[i+1][j-1]),
                              arr[j]+min(dp[i][j-2],dp[i+1][j-1]));
            }
        }
    }
    cout<<2*dp[0][n-1]-sum<<endl;
    return 0;
}

Measured memory_bytes: 69888
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<long long> h(n);
  for (int i = 0; i < n; i++)
    cin >> h[i];
  long long dp[n + 2];
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < n; i++) {
    dp[i] = 100000000000;
    for (int j = max(i - k, 0); j < i; j++)
      dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
  }
  cout << dp[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 1792
class UnionFindTree:
    def __init__(self, n):
        self.nodes = [-1] * n #根にサイズを負の値で格納する。
    def find(self, i):
        if self.nodes[i] < 0: #値が負の場合は根
            return i
        else:
            self.nodes[i] = self.find(self.nodes[i]) #縮約
            return self.nodes[i]

    def union(self, i, j):
        i = self.find(i)
        j = self.find(j)
        if i == j:
            return
        if self.nodes[i] > self.nodes[j]: #サイズ比較してiの方がサイズが大きいようにする
            i, j = j, i
        self.nodes[i] += self.nodes[j] #大きい方に小さい方を統合しサイズを登録する。
        self.nodes[j] = i # jの親はi
    
    def size(self, i): # 所属する集合の大きさを返す
        i = self.find(i)
        return -self.nodes[i]

n = int(input())
uft = UnionFindTree(2 * n)
for _ in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    if w % 2 == 0:
        uft.union(u, v)
        uft.union(u + n, v + n)
    else:
        uft.union(u + n, v)
        uft.union(u, v + n)

x = uft.find(0)
for i in range(n):
    print(0 if uft.find(i) == x else 1)

Measured memory_bytes: 84564
unittest
{
	assert( [ "3", "1 1", "2 4", "3 2" ].solve == 4 );
	assert( [ "2", "1 1", "1 1" ].solve == 0 );
	
	assert( [ "4", "1 1", "100 1", "1 101", "100 100" ].solve == 199 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto xys = new long[ 2 ][ n ];
	foreach( ref xy; xys )
	{
		input.popFront;
		xy = input.front.split.to!( long[] );
	}
	
	// 45度回転という式変形を使う
	// d = abs( x[a]-x[b] ) + abs( y[a]-y[b] )
	// --> d = max( x[a]-x[b]+y[a]-y[b], x[b]-x[a]+y[b]-y[a], x[a]-x[b]+y[b]-y[a], x[b]-x[a]+y[a]-y[b] )
	// --> d = max( x[a]+y[a]-x[b]-y[b], x[b]+y[b]-x[a]-y[a], x[a]-y[a]-x[b]+y[b], x[b]-y[b]-x[a]+y[a] )
	// --> d = max( (x[a]+y[a])-(x[b]+y[b]), (x[b]+y[b])-(x[a]+y[a]), (x[a]-y[a])-(x[b]-y[b]), (x[b]-y[b])-(x[a]-y[a]) )
	// --> p[a] = x[a] + y[a]
	//     p[b] = x[b] + y[b]
	//     m[a] = x[a] - y[a]
	//     m[b] = x[b] - y[b]
	//     d = max( p[a]-p[b], p[b]-p[a], m[a]-m[b], m[b]-m[a] )
	// --> d = max( abs( p[a]-p[b] ), abs( m[a]-m[b] ) )
	auto pma = long.min;
	auto pmi = long.max;
	auto mma = long.min;
	auto mmi = long.max;
	foreach( xy; xys )
	{
		auto p = xy[ 0 ] + xy[ 1 ];
		auto m = xy[ 0 ] - xy[ 1 ];
		pma = max( pma, p );
		pmi = min( pmi, p );
		mma = max( mma, m );
		mmi = min( mmi, m );
	}
	return max( pma - pmi, mma - mmi );
}


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

int table[10][10];

int check(vector<int> x){
  int tmp = 0;
  for(int i=0;i<5;i++){
    tmp = table[tmp][x[i]];
  }
  return tmp;
}

int calc(vector<int> x){
  int tmp = 0;
  for(int i=0;i<4;i++){
    tmp = table[tmp][x[i]];
  }
  return tmp;
}

int main(){
  for(int i=0;i<10;i++)for(int j=0;j<10;j++){
    scanf("%d", &table[i][j]);
  }
  int ans = 0;
  vector<int> x(5, 0);
  for(int i1=0;i1<10;i1++){
    for(int i2=0;i2<10;i2++){
      for(int i3=0;i3<10;i3++){
        for(int i4=0;i4<10;i4++){
          x[0]=i1;
          x[1]=i2;
          x[2]=i3;
          x[3]=i4;
          x[4]=calc(x);

          bool flag = true;
          for(int j=0;j<5;j++){
            vector<int> one = x;
            for(int k=0;k<10;k++){
              if(x[j] != k){
                one[j] = k;
                if(check(one) == 0)flag = false;
              }
            }
          }

          for(int j = 0; j < 4; j++){
            vector<int> two = x;
            if(x[j] != x[j+1]){
              two[j] = x[j+1];
              two[j+1] = x[j];
              if(check(two) == 0)flag = false;
            }
          }

          if(!flag)ans++;

        }
      }
    }
  }

  printf("%d\n", ans);

  return 0;
}



Measured memory_bytes: 3280
shouhin_list = []

kaisu = int(input().rstrip())

for _ in range(kaisu):
    shouhin_price = int(input().rstrip())
    shouhin_list.append(shouhin_price)
    
sorted_shouhin_list = sorted(shouhin_list, reverse=True)
sorted_shouhin_list[0] = int(sorted_shouhin_list[0] // 2)

print(sum(sorted_shouhin_list))

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

int main() {
	char str[25];
	for (int i = 0;i < 25;i++) {
		str[i] = '\0';
	}
	cin >> str;
	for (int i = 24; i >= 0; i--) {
		if (str[i] == '\0') continue;
		cout << str[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1132
#include <iostream>
using namespace std;
int main(void){
    int a;
    cin >> a;
    int i;
    if(a % 2 == 0){
        i = 2;
    }else{
        i = 1;
    }
    for(;i < 10;i+=2){
        if(a % i != 0) continue;
        int b = a / i;
        if(b < 10){
            cout << "Yes" << endl;
            exit(0);
        }
        i+=2;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


int main() {
	init();

	int N, A, B; cin >> N >> A >> B;
	cout << min(A, B) << " ";
	if (A + B < N)cout << 0;
	else cout << A + B - N;
	cout << "\n";

	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n;
string le, ri;

int main(){
	cin >> n;
	cout << 0 << endl;
	cin >> le;
	cout << n-1 << endl;
	cin >> ri;
	
	int l = 0, r = n-1;
	while(abs(r - l) > 1){
		int mid = (l + r) / 2;
		cout << mid << endl;
		string pos; cin >> pos;
		
		if(((mid - l) + (pos == le))%2) l = mid, le = pos;
		else r = mid, ri = pos;
	} 
	return 0;
}


Measured memory_bytes: 852
n = int(input())
a = list(map(int,input().split()))
t = [0]
for i in range(n):
    t.append(t[i] + a[i])
t.pop(0)
p = t[-1] // 2
if p in t:
    print(0)
else:
    for i in range(n):
        if p < t[i]:
            print(min(abs(sum(a[0:i+1]) - sum(a[i+1:n])),abs(sum(a[0:i]) - sum(a[i:n]))))
            break

Measured memory_bytes: 31440
arr = []
3.times do
  s = gets.split.map &:to_i
  arr << s
end
n = gets.to_i
num = []
count = 0
n.times do
  b = gets.to_i
  (0...3).each do |i|
    if arr[i].include?(b)
      h = arr[i].index(b)
      arr[i][h] = 0
    end
  end
end
check = 0
(0...3).each do |i|
  (0...3).each do |j|
    count += 1 if arr[i][j].zero?
  end
  if count == 3
    check = 1
  end
  count = 0
end
count = 0
(0...3).each do |i|
  (0...3).each do |j|
    count += 1 if arr[j][i].zero?
  end
  if count == 3
    check = 1
  end
  count = 0
end
if arr[0][0].zero? && arr[1][1].zero? && arr[2][2].zero?
  check = 1
end
if arr[0][2].zero? && arr[1][1].zero? && arr[2][0].zero?
  check = 1
end
if check == 1
  puts :Yes
else
  puts :No
end

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

int n;

int sumOfDigits(int x){
  if (x==0) return 0;
  return x%10 + sumOfDigits(x/10);
}

int main(){
  cin>>n;
  cout << (n%sumOfDigits(n) == 0 ? "Yes" : "No") << endl;
}


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

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main() {
    string S;
    cin >> S;
    int n = S.size();
    reverse(S.begin(), S.end());
    int mod = 1000000007;
    vector<int> l = {1, 10, 9, 12, 3, 4};
    vector<int> x(13);
    if (S[0] == '?') for (int i = 0; i < 10; i++) x[i] = 1;
    else x[ctoi(S[0])] = 1;
    for (int i = 1; i < n; i++) {
        int s = S[i];
        vector<int> x_(13);
        int a = l[i%6];
        if (s == '?') {
            for (int j = 0; j < 10; j++) {
                int b = 13 - a * j % 13;
                for (int k = b; k < b + 13; k++) x_[k-b] = (x_[k-b] + x[k%13]) % mod;
            }
        }
        else {
            int b = 13 - a * ctoi(s) % 13;
            for (int j = b; j < b + 13; j++) x_[j-b] = x[j%13];
        }
        x = x_;
    }
    cout << x[5] << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>

using std::list;
using std::max;
using std::min;
using std::vector;

double myabs(double a)
{
  if(a < 0) {
    return -a;
  } else {
    return a;
  }
}

int main()
{
  int n, base, goal;
  scanf("%d%d%d", &n, &base, &goal);
  vector<double> v(n);
  for(int i = 0; i < n; i++) {
    int height;
    scanf("%d", &height);
    v[i] = 1.0 * base - 1.0 * height * 0.006;
    v[i] = myabs(v[i] - 1.0 * goal);
  }
  int ans = 0;
  for(int i = 1; i < n; i++) {
    if(v[i] < v[ans]) {
      ans = i;
    }
  }
  printf("%d\n", ans+1);
  return 0;
}


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

int main()
{
    for (int i = 1; i <= 9; i++)
    {
        for (int n = 1; n <= 9; n++)
        {
            cout << i << "x" << n << "=" << i*n << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3044
def main():
    H, W, K = map(int, input().split())
    S = []
    for _ in range(H):
        s = input()
        S.append(s)

    cnt = 0
    ans = [[0] * W for _ in range(H)]
    for h in range(H):
        flag = False
        for w in range(W):
            if flag:
                ans[h][w] = cnt
            if S[h][w] == '#':
                cnt += 1
                ans[h][w] = cnt
                flag = True

    for h in range(H):
        flag = False
        for w in range(W-1,-1,-1):
            if flag and ans[h][w] == 0:
                ans[h][w] = cnt
            if S[h][w] == '#':
                cnt = ans[h][w]
                flag = True


    for w in range(W):
        for h in range(H-1):
            if ans[h][w] == 0:
                for h2 in range(h,H):
                    if ans[h2][w] != 0:
                        ans[h][w] = ans[h2][w]
                        break

    for w in range(W):
        for h in range(H-1,0,-1):
            if ans[h][w] == 0:
                for h2 in range(h,-1,-1):
                    if ans[h2][w] != 0:
                        ans[h][w] = ans[h2][w]
                        break


                
    for i in range(H):
        print(*ans[i])

    



if __name__ == "__main__":
    main()

Measured memory_bytes: 49884
ls = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
n = int(input())
s = input()
ans = ""

for i in range(len(s)):
  ans += ls[(ls.index(s[i])+n)%26]
  
print(ans)

Measured memory_bytes: 3064