akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int takahashi, aoki;
    if (c%b == 0){
        takahashi = c/b;
    }
    else{
        takahashi = c/b +1;
    }
    
    if (a%d ==0){
        aoki = a/d;
    }
    else {
        aoki = a/d +1;
    }

    if (takahashi <= aoki){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    if(N % 2){
        Out(0);
    }else{
        int n = N / 2;
        int d = 5;
        int ans = 0;
        while(true){
            int tmp = n / d;
            if(tmp){
                ans += tmp;
                d *= 5;
            }else break;
        }
        Out(ans);
    }
    

    return 0;
}


Measured memory_bytes: 256
// Remember...

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn=2e5+10,mod=998244353;
const ll inf=1e18;

int a[maxn], b[maxn], n;
queue<int> q;

int Sum(int i){
    return b[(i+n-1)%n] + b[(i+1)%n];
}
void Do(int i){
    int num=Sum(i);
    if(b[i]>num && b[i]-num>=a[i]) q.push(i);
}

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

    cin>>n;

    for(int i=0;i<n;i++)
	cin>>a[i];
    for(int i=0;i<n;i++)
	cin>>b[i];
    for(int i=0;i<n;i++)
	if(b[i]<a[i]) return cout<<-1<<endl,0;
    for(int i=0;i<n;i++)
	Do(i);
    
    ll ans=0;

    while(sz(q)){
	int i=q.front();
	q.pop();
	int x=(b[i]-a[i])/Sum(i);
	ans+=x, b[i]-=x*Sum(i);
	Do((i+n-1)%n), Do((i+1)%n);
    }
    for(int i=0;i<n;i++)
	if(a[i]!=b[i]) return cout<<-1<<endl,0;
    return cout<<ans<<endl,0;
}
// Deathly mistakes:
//  * Read the problem carefully.
//  * Check maxn.
//  * Overflows.


// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

import sys
input = sys.stdin.readline

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	n,x = map(int, io().split())
	ll= list(map(int, io().split()))
	pos=0
	if n > x:
		return 0
		
	cc=1
	for l in ll:
		pos += l
		if pos > x:
			break
		cc+=1
			
	return cc

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))
	

Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt(); //500
    int B = sc.nextInt(); //100
    int C = sc.nextInt();  //50
    int target = sc.nextInt(); //合計
    int pattern = 0;
    
    for(int i =0 ; i < A+1 ; i++){
      for(int j = 0 ; j < B+1 ; j++){
        for(int k = 0 ; k < C+1 ; k++){
          if((500 * i) + (100 * j) + (50 * k) == target){
            pattern++;
          }
        }
      }
    }
    System.out.println(pattern); 
  }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int INF = 1e9 + 5;
int main()
{
    int n;
    scanf("%d",&n);
    vi v(n);
    for(int &a : v) scanf("%d",&a);
    vi dp(n + 4, INF);
    dp[0] = 0;
    for(int i = 0; i < n; i++)
    {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(v[i + 1] - v[i]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(v[i + 2] - v[i]));
    }
    cout << dp[n - 1];
}


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

int main(){
  int n,x,l;
  cin >>n >>x;
  int d=0;
  int c=1;
  int i=0;
  while(i<n){
    cin >> l;
   	d+=l;
    if(d<=x)
      c++;
    else
      break;
    i++;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))
ln = min(x)
rn = max(x)
ans = (rn-ln)**2*n
for i in range(ln, rn+1):
    ttl = 0
    for j in x:
        ttl+=(i-j)**2
    ans = min(ans, ttl)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main() {
	int a, b, count;
	char k[55][55];
	cin >> a >> b;
	for (int i = 0; i < a; ++i) {
		for (int j = 0; j < b; ++j) {
			cin >> k[i][j];
		}
	}
	for (int i = 0; i < a; ++i) {
		for (int j = 0; j < b; ++j) {
			if (k[i][j] == '#') {
				cout << "#";
				if (j == b - 1) cout << endl;
			}
			else {
				count = 0;
				if (k[i + 1][j] == '#') ++count;
				if (k[i][j + 1] == '#') ++count;
				if (k[i - 1][j] == '#') ++count;
				if (k[i][j - 1] == '#') ++count;
				if (k[i + 1][j + 1] == '#') ++count;
				if (k[i - 1][j - 1] == '#') ++count;
				if (k[i + 1][j - 1] == '#') ++count;
				if (k[i - 1][j + 1] == '#') ++count;
				cout << count;
				if (j == b - 1) cout << endl;
			}
		}
	}
}


Measured memory_bytes: 256
N=int(input())
A=[int(x) for x in input().split()]
A.sort()
ma=0
mi=0
cnt=A[N-1]
for i in range(N-1):
  if ma<=A[i]*(cnt-A[i]):
    ma=A[i]*(cnt-A[i])
    mi=A[i]
  else:
    break
print(cnt,mi)

Measured memory_bytes: 14060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  map<int,int> m;
  rep(i,0,n){
    int a;
    cin>>a;
    m[a]++;
  }
  int cur=0;
  for(auto p:m){
    cur+=p.second-1;
  }
  if(cur%2==0){
    cout<<m.size()<<endl;
  }
  else{
    cout<<m.size()-1<<endl;
  }
}

Measured memory_bytes: 4992
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn = 300005;

inline int read()
{
	int ret, f=1;
	char c;
	while((c=getchar())&&(c<'0'||c>'9'))if(c=='-')f=-1;
	ret=c-'0';
	while((c=getchar())&&(c>='0'&&c<='9'))ret=(ret<<3)+(ret<<1)+c-'0';
	return ret*f;
}

int n, a[maxn];

int s[maxn];

int lowbit(int x)
{
	return x & -x;
}

void modify(int x, int w)
{
	while(x <= n)
	{
		s[x] += w;
		x += lowbit(x);
	}
}

int query(int x)
{
	int ret = 0;
	while(x)
	{
		ret += s[x];
		x -= lowbit(x);
	}
	return ret;
}

int main()
{
	n = read();
	for(int i = 1; i <= n; ++i)
		a[i] = read();
	int s1 = 0, s2 = 0, s3 = 0, res = 0;
	for(int i = 1; i <= n; i += 2)
	{
		s1 += res - query(a[i]);
		modify(a[i], 1);
		++ res;
	}
	for(int i = 1; i <= n; i += 2)
		modify(a[i], -1);
	res = 0;
	for(int i = 2; i <= n; i += 2)
	{
		s2 += res - query(a[i]);
		modify(a[i], 1);
		++ res;
	}
	for(int i = 2; i <= n; i += 2)
		modify(a[i], -1);
	for(int i = 1; i <= n; ++i)
	{
		s3 += i - 1 - query(a[i]);
		modify(a[i], 1);
	}
	printf("%s", (s1 + s2) * 3 == s3? "Yes": "No");
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int N, M;
	cin >> N >> M;

	int L = 0;
	int R = N;
	for( int i = 0; i < M; ++i ) {
		int a, b;
		cin >> a >> b;

		L = max( L, a );
		R = min( R, b );
	}

	cout << max( R-L + 1, 0 ) << endl;

	return 0;
}


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

/*
   AtCoder contest code
   coder : yoichidon
 */

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long W = sc.nextInt();
        long[] weight = new long[N];
        int[] value = new int[N];
        int V = 0;
        for(int n=0; n<N; n++){
            weight[n] = sc.nextInt();
            value[n]= sc.nextInt();
            V += value[n];
        }

        long[][] dp = new long[N+1][V+1];
        //dp[n][v] : choose items from first 'n' items, and the total value is v
        //this arrays have the minimum weight

        Arrays.fill(dp[0], 5000000000000000L); dp[0][0] = 0;
        for(int n=1; n<=N; n++) for(int v=0; v<=V; v++){
            dp[n][v] = dp[n-1][v];
            if(value[n-1] <= v){
                dp[n][v] = Math.min(dp[n][v], dp[n-1][v-value[n-1]]+weight[n-1]);
            }
        }

        //for(int n=0; n<=N; n++) System.err.println(Arrays.toString(dp[n]));


        int ans = 0;
        for(int v=0; v<=V; v++){
            if(dp[N][v] <= W) ans=v;
        }
        System.out.println(ans);

    }
}


Measured memory_bytes: 124880
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

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

int n;
int dp[1001][1001];

int main() {
  cin >> n;
  rep(i, n) {
    string x, y;
    cin >> x >> y;
    dp[0][0] = 0;
    rep(i, y.size()) {
      dp[0][i+1] = 0;
    }
    rep(i, y.size()) {
      dp[i+1][0] = 0;
    }
    rep(i, x.size()) {
      rep(j, y.size()) {
        dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
        if(x[i] == y[j]) {
          dp[i+1][j+1] = dp[i][j] + 1;
        }
      }
    }
    cout << dp[x.size()][y.size()] << endl;
  }


  return 0;
}


Measured memory_bytes: 7128
n = int(input())

ans = 0

for i in range(1,n//2+1):
    x = n//i
    #print(x)
    ans += i*(x*(x+1)*0.5)
    #print(ans)

allsum = n*(n+1)*0.5
partsum = (n//2)*(n//2+1)*0.5

#print("all",allsum)
#print("part",partsum)

ans = ans + (allsum - partsum)

print(int(ans))

Measured memory_bytes: 67420
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define reps(i,s,n) for (int i = s; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
#define per(i,n) for (int i = n - 1; i >= 0; --i)
#define per1(i,n) for (int i = n; i >= 1; --i)
#define all(c) begin(c),end(c)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
// if(nextY >= 0 && nextY < H && nextX >= 0 && nextX < W)
static const long double pi = acos(-1.0);
typedef complex<ld> cd;

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

    int N; cin >> N;
    vector<ll> T(N), A(N);

    bool ng = 0;
    cin >> T[0];
    rep1(i, N-1) {
        cin >> T[i];
        if(T[i] < T[i - 1]) {
            ng = 1;
        }
    }

    cin >> A[0];
    rep1(i, N-1) {
        cin >> A[i];
        if(A[i] > A[i - 1]) {
            ng = 1;
        }
    }

    if(T.back() != A.front()) {
        ng = 1;
    }

    if(ng) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    rep1(i, N-2) {
        if(T[i] != T[i-1] && A[i] != A[i+1] && A[i] != T[i]) {
            cout << 0 << endl;
            return 0;
        }
        if(T[i] != T[i-1] && T[i] > A[i]) {
            cout << 0 << endl;
            return 0;
        }
        if(A[i] != A[i+1] && A[i] > T[i]) {
            cout << 0 << endl;
            return 0;
        }

        if(T[i] != T[i-1] || A[i] != A[i+1]) continue;
        ans *= min(T[i], A[i]);
        ans %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
int cnt[3];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,p;
	cin>>n>>p;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		a[i]%=2;
		cnt[a[i]]++;
	}
	if(p==0)
	{
		long long ans=(1ll<<cnt[0]);
		if(cnt[1])
		{
			ans=ans*(1ll<<(cnt[1]-1));
		}
		cout<<ans<<"\n";
	}
	else
	{
		if(cnt[1])
		{
			long long ans=(1ll<<(cnt[1]-1));
			ans=ans*(1ll<<(cnt[0]));
			cout<<ans<<"\n";
		}
		else
		{
			cout<<"0\n";
		}
	}
}

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

if all(a<b for a,b in zip(P,P[1:])):
    print('YES')
    exit()

for i in range(N-1):
    for j in range(i+1, N):
        P[i],P[j] = P[j],P[i]
        if all(a<b for a,b in zip(P,P[1:])):
            print('YES')
            exit()
        P[i],P[j] = P[j],P[i]
print('NO')

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
long long n,ans=0,ans1=0;
char a;
int main(){
    scanf("%lld",&n);
    for(int i=0;i<n;i++){
        cin>>a;
        if(a=='I'){
            ans1++;
        }else if(a=='D'){
            ans1--;
        }
        ans=max(ans,ans1);
    }
    printf("%lld\n",ans);
    return 0;
}

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

int main(){
    int a,h;
    cin >> h >> a;
    if(h%a==0){
        cout << h/a << endl;
    }
    else{
        cout << h/a +1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import itertools
N = int(input())
A = [int(x) for x in input().split()]
max_A = max(A)
counter = [[] for _ in range(max_A + 1)]
for i, a in enumerate(A):
    counter[a].append(i)
if any(len(counter[i]) > 3 for i in range(max_A + 1)):
    print(0)
    quit()
if any(len(counter[i]) < len(counter[i+1]) for i in range(max_A)):
    print(0)
    quit()

ans = [3, 6, 6][len(counter[0])-1]
mod = 10 ** 9 + 7
for i in range(max_A):
    cnt = 0
    for li in itertools.permutations(counter[i], len(counter[i+1])):
        cnt += all(v1 < v2 for v1, v2 in zip(li, counter[i+1]))
    ans = (ans * cnt) % mod
print(ans)


Measured memory_bytes: 21924
import scala.io.StdIn._

/**
 * Created by sonetsuyoshi on 2015/12/16.
 */

object Main extends App {
  val MOD = 1000000007

  val N = readInt

  def primesUnder(n: Int): List[Int] = {
    def rec(i: Int, primes: List[Int]): List[Int] = {
      if (i > n) primes
      else if (prime(i, primes)) rec(i + 1, i :: primes)
      else rec(i + 1, primes)
    }

    rec(2, List()).reverse
  }

  def prime(num: Int, factors: List[Int]): Boolean = factors.forall(num % _ != 0)

  val primes = primesUnder(N)

  val expos = primes.map(x => {
    1.to(N).foldLeft(0.toLong)((s, n) => {
      var m = n
      var count = 0
      while(m % x == 0) {
        m /= x
        count += 1
      }
      (s + count).toLong
    })
  })
  println(expos.foldLeft(1.toLong)((s, n) => s * (n + 1) % MOD))
}


Measured memory_bytes: 24512
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int D = scan.nextInt();
		int N = scan.nextInt();
		scan.close();
		if(D == 0) {
			if(N == 100) {
				System.out.println(N + 1);
			}else {
				System.out.println(N);
			}
		}else if(D == 1){
			if(N == 100) {
				System.out.println(N * 101);
			}else {
				System.out.println(N * 100);
			}
		}else {
			if(N == 100) {
				System.out.println(N * 10100);
			}else {
				System.out.println(N * 10000);
			}
		}
	}
}


Measured memory_bytes: 23252
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int a[n];
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }for(int i=n-1;i>=0;i--){
    if(i==0){
        printf("%d",a[i]);
        break;
    }printf("%d ",a[i]);
  }printf("\n");
  return 0;
}


Measured memory_bytes: 2700
#include<bits/stdc++.h>
using namespace std;
const int nmax=100005;
int par[nmax];
bool c[nmax];
void init(int x){
  for(int i=0;i<x;i++){
    par[i]=i;
    c[i]=true;
  }
}
int root(int x){
  if(par[x]==x){
    return x;
  }
  else{
    return par[x]=root(par[x]);
  }
}
void unite(int x,int y){
  x=root(x);
  y=root(y);
  if(x==y){
    return;
  }
  else{
    par[x]=y;
    c[x]=false;
  }
}
int main(){
  int n,m;
  cin >> n >> m;
  init(n);
  for(int i=0;i<m;i++){
    int x,y,z;
    cin >> x >> y >> z;
    x--,y--;
    unite(x,y);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(c[i]){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 768
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;
struct Node {int key; Node *l, *p, *r;};
Node *root, *NIL;

void Inorder(Node *u)
{
  if(u == NIL) return ;
  Inorder(u->l);
  printf(" %d", u->key);
  Inorder(u->r);
}

void Preorder(Node *u)
{
  if(u == NIL) return ;
  printf(" %d", u->key);
  Preorder(u->l);
  Preorder(u->r);
}

void Insert(int k)
{
  Node *x, *y, *z;
  z = (Node*)malloc(sizeof(Node));
  z->l = z->r = NIL;  z->key = k;
  y = NIL; x = root;
  while(x != NIL)
  {
    y = x;
    if(z->key < x->key) x = x->l;
    else  x = x->r;
  }
  z->p = y;
  if(y == NIL)  root = z;
  else
  {
    if(z->key < y->key) y->l = z;
    else y->r = z;
  }
}

Node* findkey(int k)
{
  Node *x;  x = root;
  while(x!=NIL && x->key!=k)
  {
    if(k < x->key)  x=x->l;
    else  x = x->r;
  }
  return x;
}

Node* getMin(Node* x)
{
  while(x->l != NIL)
    x = x->l;
  return x;
}
/*
Node* getNext(Node* x)
{
  if(x->r != NIL) return getMin(x->r);
}*/

void delNode(Node* x)
{
  Node *y, *z;
  //if(x == NIL) return;
  if(x->l == NIL || x->r == NIL)  z = x;
  else  z = getMin(x->r);
  if(z->l != NIL) y=z->l; //y is the son of z; z is the one that will be deleted.
  else y = z->r;
  if(y != NIL)  y->p = z->p;
  if(z->p == NIL) root = y;
  else
  {
    if(z == z->p->l)  z->p->l = y;
    else z->p->r = y;
  }
  if(x != z)  x->key = z->key;
  free(z);
}
int main()
{
  int m, k;
  string s;
  Node *x=NIL;
  scanf("%d", &m);
  for(int i=0; i<m; i++)
  {
    cin >> s;
    if(s == "insert") {scanf("%d", &k); Insert(k);}
    else if(s == "find")
    {
      scanf("%d", &k); x = findkey(k);
      if(x == NIL) printf("no\n");
      else printf("yes\n");
    }
    else if(s == "delete")
    {
      scanf("%d", &k); delNode(findkey(k));
    }
    else
    {
      Inorder(root); printf("\n");
      Preorder(root); printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 21944
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
pair<vl,vb> eratosthenes_sieve(ll n){
  vb is_prime(n+1,true);
  vl prime;
  is_prime[0] = false;
  is_prime[1] = false;
  FOR(i,2,sqrt(n)+1){
    if(!is_prime[i]) continue;
    for(ll j=2*i;j<=n;j+=i) is_prime[j] = false;
    prime.eb(i);
  }
  FOR(i,sqrt(n)+1,n+1){
    if(is_prime[i])prime.eb(i);
  }
  return {prime,is_prime};
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  auto ppp = eratosthenes_sieve(1e7+1);
  auto pt = ppp.second;
  vl dp(1e7+1,0);
  FOR(i,2,1e7-6){
    if(pt[i]&&pt[i+2]&&pt[i+6]&&pt[i+8]) dp[i+8] = i+8;
    else dp[i+8] = dp[i+7];
  }
  while(cin >> n,n){
    cout << dp[n] << endl;
  }
}



Measured memory_bytes: 88400
#include<bits/stdc++.h>
using namespace std;
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pi 3.141592653589793238

int main( )
{
     float r,ans;

     scanf("%f",&r);
     ans = 2*pi*r;
     printf("%.20f\n",ans);

    return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=((int)(n)-1);v>=0;v--)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define DUMP(x) cerr<<#x<<":="<<(x)<<endl
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9; const long long INFLL=1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<" "<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":"\n");return os;}
//------------------------------------------------------------------------------

signed main() {
    set<int> s;
    REP(i,3) {
        int a;
        cin>>a;
        s.insert(a);
    }
    cout<<SZ(s)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static int[][] pond;
	
	public static void main(String[] args) {
		int d, w, count;
		Scanner sc = new Scanner(System.in);
		while (true) {
			w = sc.nextInt();
			if (w == 0) {
				break;
			}
			d = sc.nextInt();
			count = 0;
			
			pond = new int[w][d];
			
			for(int i=0;i<w;i++) {
				for(int j=0;j<d;j++) {
					pond[i][j] = sc.nextInt();
				}
			}
			
			for(int iw=0;iw<w-2;iw++) {
				for(int id=0;id<d-2;id++) {
					for(int jw=iw+2;jw<w;jw++) {
						for(int jd=id+2;jd<d;jd++) {
							count = Math.max(count, calc(iw,id,jw,jd));
						}
					}
				}
			}
			
			System.out.println(count);
			
		}//while
		sc.close();
	}
	
	public static int calc(int iw,int id,int jw, int jd) {
		int height=10;
		for(int w=iw;w<=jw;w++) {
			height = Math.min(pond[w][id], height);
			height = Math.min(pond[w][jd], height);
		}
		for(int d=id+1;d<jd;d++) {
			height = Math.min(pond[iw][d], height);
			height = Math.min(pond[jw][d], height);
		}
		
		int depth=0;
		for(int w=iw+1;w<jw;w++) {
			for(int d=id+1;d<jd;d++) {
				if(height <= pond[w][d]) {
					return 0;
				}
				depth += height - pond[w][d];
			}
		}
		
		
		return depth;
	}

}


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

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1,i,j;
    //cin>>t;
    while(t--)
    {
        int n,m,count=0,sum=0,maxi=0,mini=1e18;
        long double a,b;
        cin>>a>>b;
        long double ans=a*b;
       	cout<<(int)(ans);
    }
}

Measured memory_bytes: 3744
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int main(){
	string s;
	cin>>s;
	bool h=true;
	if(s[0]!='A')h=false;
	if(s[1]=='C')h=false;
	int co=0;
	int n=s.size();
	loop(i,2,n-1)if(s[i]=='C')co++;
	if(co-1)h=false;
	rep(i,n)if(s[i]=='C'||s[i]=='A');
	else if(isupper(s[i]))h=false;
	if(h)cout<<"AC"<<endl;
	else cout<<"WA"<<endl;
}







Measured memory_bytes: 256
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n,i,j,k,x,y,ans,temp,curr,m;
    int tc;
    string s;
    cin >> s;
    ans = 0;
    for(i=0;i<3;i++) if(s[i] == 'A') ans++;
    if(ans == 0 || ans == 3) cout << "No\n";
    else cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
from collections import deque  
d = deque(input())
Q = int(input())
Query = [input() for i in range(Q)]

# 先頭から読むか，末尾から読むかを判定する
# 偶数 -> 先頭から，奇数 -> 末尾から
isReadOrientation = 0

for i in range(Q):
    if len(Query[i]) == 1:
        isReadOrientation += 1
    else:
        #先頭に追加
        if Query[i][2] == "1":
            #先頭に追加
            if isReadOrientation % 2 == 0:
                d.appendleft(Query[i][4])
            #末尾に追加
            else:
                d.append(Query[i][4])
        #末尾に追加
        else:
            #末尾に追加
            if isReadOrientation % 2 == 0:
                d.append(Query[i][4])
            #先頭に追加
            else:
                d.appendleft(Query[i][4])

#先頭から文字列に記録
if isReadOrientation % 2 != 0:
    d.reverse()
print("".join(d))

Measured memory_bytes: 21244
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,d,x;
    cin >> n >> d >> x;
    int a[n];
    int answer = 0;
    REP(i,n){
        cin >> a[i];
        answer += (d-1)/a[i];
    }
    cout << answer + n + x << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;
ll dp[101][101010];

int main(){
    int k,n;
    cin>>k>>n;
    vector<int> a;
    FOR(i,1,100000){
        if(i*i>k)break;
        a.push_back(i);
        a.push_back(k/i);
    }
    a.push_back(0);
    sort(a.begin(),a.end());
    int m = a.size();
    dp[0][0]=1;
    F0R(i,n){
        F0R(j,m)(dp[i][j+1]+=dp[i][j])%=MOD;
        F0R(j,m-1){
            int idx = m-j-2;
            dp[i+1][j]=dp[i][idx]*(a[j+1]-a[j])%MOD;
        }
    }
    ll ans = 0;
 
    F0R(i,m)ans += dp[n][i];
    cout<<ans%MOD<<endl;
    return 0;
}

Measured memory_bytes: 78844
# coding: utf-8
import numpy as np


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    A = np.array(sorted(map(int, args[1].split())))
    N = A[A < 0]
    P = A[0 < A]

    count = 0
    left, right = -10**18, 10**18
    while left+1 < right:
        x = (left+right)//2
        count = (n-np.searchsorted(A, -(-x//N), side='left')).sum()
        count += n * (A == 0).sum() if 0 <= x else 0
        count += np.searchsorted(A, x//P, side='right').sum()
        count -= (A*A <= x).sum()
        count //= 2

        if count < k:
            left = x
        else:
            right = x

    return str(right)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 34188
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  int x,y;
  cin>>x>>y;
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      if(i+j==x && 2*i+4*j==y){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}


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

int main() {
  int x, y;
  cin >> x;
  cin >> y;

  if (x%500 < y) 
      {
        cout << "Yes" << endl;
      }

   else if (x%500 > y)
         {
          cout << "No" << endl;
        }
   else 
   {
    cout << "Yes" << endl;
   }
   return 0;
    //else
        //{
         // cout << "No" << endl;
       // }
  

  //cout << "終了" << endl;
}



Measured memory_bytes: 256
#include<algorithm> 
#include<iostream>
#include<cstdio>
#define MN 100000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
long long ans;
int n,m,a[MN+5],s[MN+5],q[MN+5],top,num;
inline int getfa(int x){return s[x]?s[x]=getfa(s[x]):x;}
int main()
{
	n=read();m=read();
	if((n-m-1)*2>n) return 0*puts("Impossible");
	for(int i=1;i<=n;++i) a[i]=read();
	for(int i=1;i<=m;++i)
	{
		int x=read()+1,y=read()+1;
		if(a[getfa(x)]<a[getfa(y)]) s[getfa(y)]=getfa(x);
		else s[getfa(x)]=getfa(y);
	}
	for(int i=1;i<=n;++i) if(getfa(i)==i) ans+=a[i],++num; else q[++top]=a[i];
	if(num==1) return 0*puts("0");
	sort(q+1,q+top+1);
	for(int i=1;i<=num-2;++i) ans+=q[i];
	printf("%lld",ans);
	return 0;
}



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

const int SENTINEL = 1000000001;
int Cnt;

void Merge(int A[500000], int left, int mid, int right)
{
	int n1 = mid-left;
	int n2 = right-mid;

	int L[250001], R[250001];
	for(int i=0; i<n1; i++){
		L[i] = A[left+i];
	}
	for(int i=0; i<n2; i++){
		R[i] = A[mid+i];
	}
	L[n1] = SENTINEL;
	R[n2] = SENTINEL;

	for(int i=0, j=0, k=left; k<right; k++){
		if(Cnt++, L[i]<=R[j]){
			A[k] = L[i];
			i++;
		}
		else{
			A[k] = R[j];
			j++;
		}
	}
}

void Merge_Sort(int A[500000], int left, int right)
{
	if(left+1>=right)
		return;

	int mid = (left+right)/2;
	Merge_Sort(A, left, mid);
	Merge_Sort(A, mid, right);
	Merge(A, left, mid, right);
}

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

	int S[500000];
	for(int i=0; i<n; i++){
		cin >> S[i];
	}

	Cnt = 0;
	Merge_Sort(S, 0, n);

	for(int i=0; i<n; i++){
		cout << S[i];
		if(i<n-1){
			cout << ' ';
		}
		else{
			cout << endl;
		}
	}
	cout << Cnt << endl;

	return 0;
}

Measured memory_bytes: 5064
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	HashSet<String> set = new HashSet<String>();
	String[] a = new String[n];
	for(int i = 0; i<n; i++) {
	    String str = sc.next();
	    set.add(str);
	    a[i] = str;
	    if(i!=0) {
		if(a[i].charAt(0) != a[i-1].charAt(a[i-1].length()-1)) {
			System.out.println("No");
			return;
		    }
		}
	}
	if(set.size()!=n) {
	    System.out.println("No");
	    return;
	}
	System.out.println("Yes");

    }
}

Measured memory_bytes: 22996
n = int(input())
a = list(map(int, input().split()))
ans = 1
b = True
if 0 in a:
	print(0)
	exit()
for i in a:
	ans*=i
	if (ans>1000000000000000000):
		b = False
		break
if (b):
	print(ans)
else:
	print(-1)

Measured memory_bytes: 84584
#include<stdio.h>
int main(void)
{
	int a,b,n,m;
	scanf("%d %d",&a,&b);
	if(a<0){
		m=a*-1;
		n=b-m;
	}
	else{
		n=b-a;
	}
	if(n==0){
		if(a>=0){
			printf("1\n");
		}
		else{
			printf("0\n");
		}
	}
	else{
		if(a>=0){
			printf("1\n");
		}
		else{
			printf("-1\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2120
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var hi = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var count = 0;
            var max = 0;
            for (var i = 0; i < hi.Length - 1; i++)
            {
                if (hi[i] >= hi[i + 1])
                {
                    count++;
                }
                else
                {
                    max = Math.Max(max, count);
                    count = 0;
                }
            }
            max = Math.Max(max, count);
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 26204
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;

int main()
{
  string s;
  int n;
  cin >> n;
  cin >> s;
  string a, b;
  int ans = 0, x, y, p;
  for(int i = 1; i < n - 2; i++) {
    a = s.substr(0, i);
    b = s.substr(i);
    p = 0;
    for(char c = 'a'; c <= 'z'; c++) {
      x = 0;
   	  y = 0;
      rep(j, i) if(a[j] == c) x++;
      rep(j, n - i) if(b[j] == c) y++;
      if(x && y) p++;
    }
    ans = max(ans, p);
  }
  cout << ans << endl;
      
    
  return 0;
}

Measured memory_bytes: 3616
#include<iostream>


using namespace std;


int main(){
	int a,b;
	
	
	cin>>a>>b;
	
	if(a<b){
	for(int c=1;c<=b;c++){
	
	cout<<a;
}	
		
	}
	if(b<a)
	{
			for(int c=1;c<=a;c++){
	
	cout<<b;
}	
		
	}
	if(a==b){
		for(int c=1;c<=b;c++){
	cout<<a;
		}
	}

	
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    string s,t;cin>>s>>t;
    int ss=s.size();
    if(s==t.substr(0,ss))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

public class Main {
    private static Scanner sc;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int a = sc.nextInt();
            int b = sc.nextInt();

            if (a > 12) System.out.println(b);
            else if (6 <=a && a <= 12) System.out.println(b/2);
            else System.out.println(0);


        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

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

#define Omar45 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define pb push_back
#define endl '\n'
#define MOD 1000000007
#define maxN 1e5

ll n, ans = 0, arr[20][20];

int getDigit(int x, int ret = 0)
{
    while (x > 0) {
        ret = x % 10;
        x /= 10;
    }
    return ret;
}


int main() {
	Omar45
	cin >> n;
	for (ll i = 1; i <= n; i++)
        arr[getDigit(i)][i % 10]++;
    for (ll i = 0; i < 10; i++) {
        for (ll j = 0; j < 10; j++) {
            ans += (1LL * arr[i][j] * arr[j][i]);
        }
     }
     cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    string N;
    cin >> N;
    int ans = 0;

    for(int i=0;i<4;i++){
        if(N[i] == '2')
        	ans++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
  int dx=tx-sx;
  int dy=ty-sy;
  REP(i,dx){
    cout<<"R";
  }
  REP(i,dy+1){
    cout<<"U";
  }
  REP(i,dx+1){
    cout<<"L";
  }
  REP(i,dy+1){
    cout<<"D";
  }
  cout<<"R";
  cout<<"D";
  REP(i,dx+1){
    cout<<"R";
  }
  REP(i,dy+1){
    cout<<"U";
  }
  REP(i,dx+1){
    cout<<"L";
  }
  REP(i,dy){
    cout<<"D";
  }
  return 0;
}


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

N = int(input())

T,A = map(int, input().split())

for i in range(N-1):
    t,a = map(int, input().split())
    # 多く増やす必要のある方に合わせて、同じ比で両方増やす
    tmp = max(-(-T // t), -(-A // a))
    T = t * tmp
    A = a * tmp

print(T + A)

Measured memory_bytes: 3060
import math
n = int(raw_input())
while True:
    try:
        x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())
        a = math.sqrt((x1-x2)**2+(y1-y2)**2)
        b = math.sqrt((x1-x3)**2+(y1-y3)**2)
        c = math.sqrt((x2-x3)**2+(y2-y3)**2)
        s = (a+b+c)/2
        ss = math.sqrt(s*(s-a)*(s-b)*(s-c))
        sina = 2*ss/b/c
        sinb = 2*ss/a/c
        sinc = 2*ss/a/b
     
        r = a/sina/2
    
        a = a*a
        b = b*b
        c = c*c
        px = (a*(b+c-a)*x3 + b*(a+c-b)*x2+c*(a+b-c)*x1)/16/ss**2
        py =(a*(b+c-a)*y3 + b*(a+c-b)*y2+c*(a+b-c)*y1)/16/ss**2
    
        print "%.3f %.3f %.3f" % (px, py, r)
    except:
        break

Measured memory_bytes: 4444
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();

		double a = Math.pow(r,2) * Math.PI;
		double l = 2 * r * Math.PI;

		System.out.printf("%f %f",a ,l );
		sc.close();

	}

}


Measured memory_bytes: 28408
from functools import reduce


def exclusve_sum(x, y):
    return x^y

def calc_exclusive(a, b):
    """aは偶数であるとする"""
    if b - a <= 4:
        return reduce(exclusve_sum, [x for x in range(a, b + 1)])

    q, r = divmod(b - a, 4)
    rest = [a + 4 * q + r1 for r1 in range(0, r + 1)]
    ans = reduce(exclusve_sum, rest)
    return ans


if __name__ == "__main__":
    a, b = list(map(int, input().split(" ")))
    calc_exclusive(a, b)

    if a % 2 == 0:
        ans = calc_exclusive(a, b)
        print(ans)
    else:
        ans = a ^ calc_exclusive(a + 1, b)
        print(ans)


Measured memory_bytes: 3572
import java.util.*;

public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		while(true) {
			C = C - B;
			if(C <= 0) {
				System.out.println("Yes");
				break;
			}
			A = A - D;
			if(A <= 0) {
				System.out.println("No");
				break;
			}
			
		}
	}
}

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

//ABC158B
int main(void) {
  int n, k, i, cou=0, tmp;
  char s[200];
  scanf("%s", s);
  for(cou=0; s[cou]!='\0'; ++cou)
    ; //文字数

  for(i=0; i*4<cou; i++){
    if(s[i]!=s[cou/2-1-i]||s[i]!=s[cou/2+1+i]||s[i]!=s[cou-1-i]){
      printf("No");
      return 0;
    }
  }
  printf("Yes");
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
using ll = long long;
constexpr int MOD = 1e9 + 7;
inline int quick_pow(int a, int n)
{
	int res = 1;
	while (n)
	{
		if (n & 1)
			res = (ll)res * a % MOD;
		a = (ll)a * a % MOD;
		n >>= 1;
	}
	return res;
}
int a[1005], b[1005], fact[1000005], inv[1000005];
inline int C(int n, int m) { return n < m ? 0 : (ll)fact[n] * inv[m] % MOD * inv[n - m] % MOD; }
int main()
{
	// freopen("keyence2019-D.in", "r", stdin);
	int n, m;
	scanf("%d%d", &n, &m);
	fact[0] = 1;
	for (int i = 1; i <= n * m; i++)
		fact[i] = (ll)fact[i - 1] * i % MOD;
	inv[n * m] = quick_pow(fact[n * m], MOD - 2);
	for (int i = n * m; i; i--)
		inv[i - 1] = (ll)inv[i] * i % MOD;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", a + i);
		a[i]--;
	}
	for (int i = 0; i < m; i++)
	{
		scanf("%d", b + i);
		b[i]--;
	}
	std::sort(a, a + n, std::greater<int>());
	std::sort(b, b + m, std::greater<int>());
	for (int i = 1; i < n; i++)
	{
		if (a[i] == a[i - 1])
		{
			puts("0");
			return 0;
		}
	}
	for (int i = 1; i < m; i++)
	{
		if (b[i] == b[i - 1])
		{
			puts("0");
			return 0;
		}
	}
	int rem = 0, ans = 1, lst = n * m, x = 0, y = 0;
	while (true)
	{
		int cur = std::max(a[x], b[y]), cnt = lst - cur - 1;
		ans = (ll)ans * C(rem, cnt) % MOD * fact[cnt] % MOD;
		rem -= cnt;
		lst = cur;
		if (x >= n && y >= m)
			break;
		if (a[x] == b[y])
			rem += x + y;
		else if (a[x] > b[y])
		{
			ans = (ll)ans * y % MOD;
			rem += y - 1;
		}
		else
		{
			ans = (ll)ans * x % MOD;
			rem += x - 1;
		}
		x += a[x] == cur;
		y += b[y] == cur;
	}
	printf("%d\n", ans);
	return 0;
}


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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

bool
f(vector<int>&ln, int idx, int x, int y) {
  if (idx == 10) return true;
  int z = ln[idx];
  return (x < z && f(ln, idx + 1, z, y)) || (y < z && f(ln, idx + 1, x, z));
}

int main() {

  int n; cin >> n;
  for (;n--;) {
    vector<int> ln(10);
    rep (i, 10) cin >> ln[i];
    bool bl = f(ln, 0, 0, 0);
    cout << (bl ? "YES" : "NO" ) <<endl;
  }

  return 0;
}

Measured memory_bytes: 1184
package main

import (
	"fmt"
)

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

	if a == b {
		fmt.Println("Draw")
	} else if (b != 1 && a > b) || a == 1 {
		fmt.Println("Alice")
	} else {
		fmt.Println("Bob")
	}
}


Measured memory_bytes: 1836