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

int main() {

    char a , b;
    cin >> a >> b;

    if ((a == 'H' && b == 'H') || (a == 'D' && b == 'D')) 
        cout << "H" << endl;
    else
        cout << "D" << endl;

}

Measured memory_bytes: 256
# Contest: AtCoder Beginner Contest 142 (https://atcoder.jp/contests/abc142)
# Problem: B: Roller Coaster (https://atcoder.jp/contests/abc142/tasks/abc142_b)

def rint():
    return int(input())


def rints():
    return list(map(int, input().split()))


n, k = rints()
c = 0
for hi in rints():
    c += hi >= k
print(c)


Measured memory_bytes: 51440
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;



int MOD=1000000007;
int main(){
	int H,N,A,ans=0;
	cin >> H >> N;
	for(int i=0; i<N; i++){
		cin >> A;
		ans+=A;
	}
	if(H>ans) cout << "No" << endl;
	else cout << "Yes" << endl; 
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a,b,c,d,i,f[128]={0},r=0;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    for(i=a;i<b;i++){f[i]++;}
    for(i=c;i<d;i++){f[i]++;}
    for(i=0;i<=99;i++){if(f[i]==2){r++;}}
    printf("%d\n",r);
    return 0;
}

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

int main(int argc,char** argv)
{

	int A,B,C;
	scanf("%d%d%d",&A,&B,&C);
	if( A == B ){
		printf("%d\n", C);
	}
	else if ( A == C ){
		printf("%d\n", B);
	}
	else{
		printf("%d\n", A);
	}
	return(0);

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int a[200000] = {}, res[200000] = {};

int main(){
    int n, tem, i, j, m = 0;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> a[i];
    }
    for(i=n; i>0; i--){
        j = 2;
        tem = 0;
        while(j*i <= n){
            tem += res[j*i-1];
            tem %= 2;
            j++;
        }
        res[i-1] = tem ^ a[i-1];
        m += res[i-1];
    }
    cout << m << "\n";
    for(i=0; i<n; i++){
        if(res[i]){
            cout << i+1 << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 2432
use std::io::*;
use std::str::FromStr;
use std::cmp;


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 read<T: FromStr>() -> 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().expect("failed to parse token")
}


fn main() {
    input!{
        N: u64,
        A: u64,
        B: u64,
    }
    let mut ans = 0;
    
    for p in  0..N+1{
    	let mut s = 0;
        let mut q = p;
    	while q>0{
        	s += q % 10;
        	q /=10;
        }
        if (s>=A) & (s<=B){
        	ans+=p;
        }
    }
    
    
    println!("{}",ans);
}


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

using namespace std;

int main(void)
{
	int n,m;

	cin>>n>>m;
	int k[n],a[n][m],ans=0;
	int cnt[m+1]={0};

	for(int i=0;i<n;i++){
		cin>>k[i];
		for(int j=0;j<k[i];j++){
			cin>>a[i][j];
			cnt[a[i][j]]++;
		}
	}

	for(int i=1;i<=m;i++){
		if(cnt[i]==n) ans++;
	}

	cout<<ans<<endl;

	return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int n;cin>>n;
  vector<int> l(2*n);
  rep(i, 2*n)cin>>l[i];
  sort(l.begin(), l.end());
  int sum=0;
  rep(i, n)sum+=l[2*i];

  cout<<sum;

  return 0;
}

Measured memory_bytes: 256
import sys

def f(d):
    num = 3
    p = [2]
    c = 0
    while num <= 10**5:
        m = int(num**0.5)
        while m > 1 and num % m != 0:
            m -= 1
        if m == 1:
            p.append(num)
            if (num+1)//2 in p:
                c += 1
        d[num] = c
        num += 2
    return d


def main():
    input = sys.stdin.readline
    Q = int(input())
    d = {1: 0, 2: 0}
    d = f(d)
    for _ in range(Q):
        l, r = map(int, input().split())
        l = max(l - 2, 1)
        print(d[r] - d[l])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9268
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
int n,l,q,x[maxn],fa[maxn][18],sum[maxn],summ;
inline void pre()
{
	register int i,j=2;
	for(i=1;i<=n;++i)
	{
		while(summ+sum[j]-sum[j-1]<=l&&j<=n) summ+=sum[j]-sum[j-1],++j;
		fa[i][0]=j-1;
		summ-=sum[i+1]-sum[i];
	}
	for(i=1;i<=17;++i)
		for(j=1;j<=n;++j)
			fa[j][i]=fa[fa[j][i-1]][i-1];
}
inline void solve(int a,int b)
{
	if(a>b) swap(a,b);
	int ans=0;
	for(register int i=17;i>=0;--i)
		if(fa[a][i]<b) a=fa[a][i],ans+=(1<<i);
	printf("%d\n",++ans);
}
int main()
{
	scanf("%d",&n);
	register int i;
	for(i=1;i<=n;++i)
		scanf("%d",&x[i]),sum[i]=sum[i-1]+x[i]-x[i-1];
	scanf("%d%d",&l,&q);
	pre();
	int a,b;
	for(i=1;i<=q;++i)
		scanf("%d%d",&a,&b),solve(a,b);
	return 0;
}

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

constexpr long double fou = 20 - 5 * 3.1415926535897932384626433832, ff = 10 * 3.1415926535897932384626433832 - 20;
long long int x[4], N, a, b, my, My, dp[364364], n, d;
vector<pair<long long, long long>> fs;
vector<long long> v;

int main(){
    scanf("%lld%lld%lld%lld%lld", x, x + 1, x + 2, x + 3, &N);
    if(*x > x[2]){swap(*x, x[2]); swap(x[1], x[3]);}
    my = min(x[1], x[3]);
    My = x[1] + x[3] - my;
    d = 1 - 2 * (x[1] > x[3]);
    for(int i = 0; i < N; ++i){
        scanf("%lld%lld", &a, &b);
        if(*x <= a && a <= x[2] && my <= b && b <= My){
            fs.push_back({a, b * d});
        }
    }
    if(*x != x[2] && x[1] != x[3]){
        sort(fs.begin(), fs.end());
        fill(dp, dp + 364364, 114514893);
        for(auto p : fs){
            *lower_bound(dp, dp + N, p.second) = p.second;
        }
        n = lower_bound(dp, dp + N, 114514893) - dp;
        if(n == min(x[2] - *x, My - my) + 1)printf("%.15Lf", (x[2] - *x + My - my) * 100 - fou * (n - 1) + ff);
        else printf("%.15Lf", (x[2] - *x + My - my) * 100 - fou * n);
    }else{
        printf("%.15Lf", (x[2] - *x + My - my) * 100 + (ff * fs.size()));
    }
    return 0;
}


Measured memory_bytes: 7148
n = int(input())
a = [0] * (n+1)
for i in range(1,n+1):
    b = a[i-1] + 1
    c = 1
    d = 1
    while c <= i / 6:
        c *= 6
        b =  min(a[i-c]+1,b)
    while d <= i / 9:
        d *= 9
        b =  min(a[i-d]+1,b)
    a[i] = b
print(a[n])

Measured memory_bytes: 3828
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int ans = 17;
int a,b,c;
int main()
{
    cin>>a>>b>>c;
    if( (a+b+c) % ans == 0)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
from collections import deque
from collections import defaultdict

def main():
    n, k = list(map(int,sys.stdin.readline().split()))
    h = list(map(int,sys.stdin.readline().split()))
    h.sort(reverse=True)
    if k > len(h):
        print("0")
        return 0
    else: print(sum(h[k:]))
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 26124
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(ll N) : par(N+1) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N+1; i++) par[i] = i;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }

    ll COUNT(ll N){
        vector<ll> count(N+1);
        ll ans=0;
        rep(i,N+1){
            if(count.at(root(i))==0){
                ans++;
                count.at(root(i))++;
            }
        }
        return ans;
    }
};

int main()
{
    ll N,M;
    cin>>N>>M;
    UnionFind tree(N);
    rep(i,M){
        ll A,B;
        cin>>A>>B;
        tree.unite(A,B);
    }
    cout<<tree.COUNT(N)-2<<endl;
}

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

int main(){
 int X,Y;
  cin>>X>>Y;
  if(Y<2*X||Y>4*X){
    cout<<"No"<<endl;
  }else if(Y%2!=0){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 3588
program Balance
    implicit none
    integer(4):: n, mi, i
    integer(4),allocatable:: w(:)

    read*, n
    allocate(w(n))
    read*, w(:)

    mi = 100000

    do i=1,n-1
        mi = min(mi, abs(sum(w(1:i))-sum(w(i+1:n))))
    end do

    print*, mi
    
end program Balance

Measured memory_bytes: 256
n=int(input())
a= list(map(int,input().split()))

s= sum(a)

s_1 = sum([a[i] for i in range(n) if i%2==1])

x_1 = s-2*s_1

ans = [x_1]

for i in range(n-1):
    x = 2*a[i] - ans[-1]
    ans .append(x)

print(*ans)

Measured memory_bytes: 14032
#include<iostream>
main(){
  std::string s,t;
  std::cin>>s>>t;
  std::string ans;
  size_t i=0,j=0;
  size_t n=s.size();
  size_t m=t.size();
  while(i<n||j<m){
    if(i==j)ans+=s[i++];
    else ans+=t[j++];
  }
  std::cout<<ans<<std::endl;
}


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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    int N, X, T;  cin >> N >> X >> T;
    cout << T * (ll)ceil((double)N/(double)X) << endl;
	return 0;
}

Measured memory_bytes: 3720
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n;
	cin >> n;
	vector<double> v;
	for (int i = 0; i < n; i++) {
		double d;
		cin >> d;
		v.push_back(d);
	}
	sort(v.begin(), v.end(),greater<double>());

	double ans = 0;

	for (int i = 0; i < n; i ++) {
		if (i != (n - 1)) {
			ans += v[i] / (double)pow(2, i + 1);
		}
		else {
			ans += v[i] / (double)pow(2, i);
		}
	}

	cout << ans << endl;


	return 0;
}

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

int arr[101010];

const int MOD = 1e9+7;

int p(int a, int n){
  if( n == 0 ){ return 1LL;}
  else if( n == 1 ){ return a;}
  else{
    if( n % 2 == 0 ){ return (p(a,n/2)*p(a,n/2))%MOD;}
    else{ return (((p(a,(n-1)/2)*p(a,(n-1)/2))%MOD)*a)%MOD; }
  }
}

signed main(void){ 
  
  int N,K; cin >> N >> K;
  int ans = 0;
  
  for(int i = K; i >= 1; i--){ 
    int ad = 0; int kind = 0; int res = 0;
    for(int j = i; j <= K; j+=i){
      ad += arr[j]; kind++;
    }
    
    res = (p(kind,N)-ad+MOD*MOD)%MOD;
    
    arr[i] = (arr[i]+res)%MOD;
    
    ans = (ans+res*i)%MOD;
    
  }
  
  cout << ans << endl;
  
  return 0;
} 
  

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

def assignColor():
    for i in range(n):
        if C[i] == -1:
            #BFS(i)
            DFS(i)
            
#@profile
def BFS(start):
    global C
    Q = [start]
    C[start] = start

    while len(Q) != 0:
        u = Q.pop(0)
        v = [i for i in G[u] if C[i] == -1] # v := ??£??\???????????????????????¢?´¢??????????????????
        
        for i in v:
            Q.append(i)
            C[i] = C[start]

#@profile
def DFS(start):
    S = [start]
    C[start] = start
    while len(S) != 0:
        u = S.pop(0)
        for i in G[u]:
            if C[i] == -1:
                C[i] = start
                S.append(i)

if __name__ == "__main__":
    n, m = list(map(int, input().split()))
    G = [[] for i in range(n)]
    C = [-1]*n
    
    for i in range(m):
        s, t = list(map(int, input().split()))
        G[s].append(t)
        G[t].append(s)
    assignColor()
    q = int(input())
    for i in range(q):
        s, t = list(map(int, input().split()))
        if C[s] == C[t]:
            print("yes")
        else:
            print("no")
            

Measured memory_bytes: 32904
def pcmod(n):
    if n==0:
        return 1
    return 1+pcmod(n%bin(n).count('1'))

def main():
    n = int(input())
    x = list(map(int,list(input())))

    m_1 = x.count(1)-1
    m_0 = x.count(1)+1 
    baser_1 = 0
    baser_0 = 0
    if m_1!=0:
        for i in range(n):
            baser_1 += x[i] * pow(2,(n-1-i),m_1)
            baser_1 %= m_1
        
    for i in range(n):
        baser_0 += x[i] * pow(2,(n-1-i),m_0)
        baser_0 %= m_0

    ans = [0]*n

    for i in range(n):
        a = 0
        if x[i]==1:
            if m_1==0:
                ans[i] = 0
                continue
            t = (baser_1 - pow(2,(n-1-i),m_1))%m_1
            a = pcmod(t)

        if x[i]==0:
            t = (baser_0 + pow(2,(n-1-i),m_0))%m_0
            a = pcmod(t)
        ans[i] = a

    for a in ans:
        print(a)
if __name__ == "__main__":
    main()

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

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i, n)  FOR(i,0,(n))
typedef pair<int, int> P;


class BTimeLimitExceeded {
public:
    void solve(std::istream &in, std::ostream &out) {
      int n, t;
      in >> n >> t;
      vector<P> ct(n);
      REP(i, n) {
        int x, y;
        in >> x >> y;
        ct[i] = P(x, y);
      }
      sort(ct.begin(), ct.end(), [](P a, P b) {
          return a.first < b.first;
      });
      REP(i, n) {
        if (ct[i].second <= t) {
          out << ct[i].first << endl;
          return;
        }
      }
      out << "TLE" << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  BTimeLimitExceeded solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
# frozen_string_literal: true

n = gets.to_i
l = gets.split.map(&:to_i)
c = 0
l.combination(3).each do |e|
  l1 = e[0]
  l2 = e[1]
  l3 = e[2]
  next if [l1, l2, l3].uniq.size != 3
  c += 1 if l1 + l2 > l3 && l2 + l3 > l1 && l3 + l1 > l2
end
puts c


Measured memory_bytes: 14384
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/dynamic_bitset.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;
using namespace std;

void Main()
{
   int H, W;
   cin >> H >> W;
   char a;
   // boost::dynamic_bitset<> A(H * W);
   std::bitset<1000000> A;
   int i, j;
   std::bitset<1000000> Al;
   std::bitset<1000000> Ar;
   std::bitset<1000000> Au;
   std::bitset<1000000> Ad;
   A.set();
   Al.set();
   Ar.set();
   Au.set();
   Ad.set();
   for (i = 0; i < H; i++)
   {
      Ar.flip(W * i);
      Al.flip(W * i + W - 1);
   }
   for (j = 0; j < W; j++)
   {
      Au.flip(W * (H - 1) + j);
      Ad.flip(j);
   }

   for (i = 0; i < H; i++)
   {
      for (j = 0; j < W; j++)
      {
         cin >> a;
         if (a == '.')
            A.flip(W * i + j);
      }
   }
   int N = 0;
   while (1)
   {
      if (A.count() == A.size())
      {
         cout << N << endl;
         return;
      }
      A |= ((A << 1) & Ar) | ((A >> 1) & Al) | ((A >> W) & Au) | ((A << W) & Ad);
      N++;
   }

   return;
}

int main()
{
   std::cin.tie(nullptr);
   std::ios_base::sync_with_stdio(false);
   std::cout << std::fixed << std::setprecision(15);
   Main();
   return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>
#include<iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    
    int count_a = 0;
    int count_b = 0;
    for (int i = 0; i < n; i++) {
        string a, b;
        cin >> a >> b;
        
        if (a == b) {
            count_a += 1;
            count_b += 1;
        } else if (a > b) {
            count_a += 3;
        } else if (a < b) {
            count_b += 3;
        }
    }
    
    cout << count_a << " " << count_b << endl;
    
    return 0;
}


Measured memory_bytes: 3168
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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;}
#define DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t; cin >> t;
    while (t-->0) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        if (b>a) cout << "No\n";
        else if (d<b) cout << "No\n";
        else if (c>=b) cout << "Yes\n";
        else {
            ll bd = gcd(b, d);
            if (b-bd+(a%bd) > c) cout << "No\n";
            else cout << "Yes\n";
        }
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned x){
  int s=0;
  char f[10];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned long long x){
  int s=0;
  char f[21];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(double x){
  printf("%.15f",x);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
inline void wt_L(string &x){
  int i=0;
  for(i=0;x[i]!='\0';i++){
    putchar_unlocked(x[i]);
  }
}
template<class T> int runLength(int N, T *arr, T *val, int *len){
  int i;
  int rN;
  if(N==0){
    return 0;
  }
  rN = 1;
  val[0] = arr[0];
  len[0] = 1;
  for(i=(1);i<(N);i++){
    if(val[rN-1] == arr[i]){
      len[rN-1]++;
    }
    else{
      val[rN] = arr[i];
      len[rN] = 1;
      rN++;
    }
  }
  return rN;
}
int N;
char S[100001];
int sz;
int len[100000];
char num[100000];
int main(){
  rd(N);
  rd(S);
  wt_L(runLength(N,S,num,len));
  wt_L('\n');
  return 0;
}
// cLay varsion 20191012-1

// --- original code ---
// int N; char S[100001];
// int sz, len[1d5]; char num[1d5];
// {
//   rd(N,S);
//   wt(runLength(N,S,num,len));
// }

Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcorder_BeginnerContest_119
{
    class Program
    {
        public const double RATE = 380000.0;

        static void Main(string[] args)
        {
            int cnt = int.Parse(Console.ReadLine());

            double ret = 0;
            for(int i = 0; i < cnt; i++)
            {
                string[] line = Console.ReadLine().Split(' ');
                if("BTC" == line[1])
                {
                    ret += double.Parse(line[0]) * RATE;
                }
                else
                {
                    ret += double.Parse(line[0]);
                }
            }

            Console.WriteLine(ret);

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m, ans = 0; cin >> n >> m;
	ll k; cin >> k;
	vector<ll> prea(n + 1);
	vector<ll> preb(m + 1);
	for(int i = 0; i < n; i++)
	{
		ll a; cin >> a;
		prea[i + 1] = prea[i] + a;
	}
	for(int i = 0; i < m; i++)
	{
		ll b; cin >> b;
		preb[i + 1] = preb[i] + b;
	}
	for(int i = 0, j = m; i < n + 1; i++)
	{
		if(prea[i] > k) break;
		while(j > -1 && prea[i] + preb[j] > k) j--;
		ans = max(ans, i + j);
	}
	cout << ans;

	return 0;
}

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

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

int main(){
    ll n ;
    cin >> n;
    double od;
    if(n%2==1){
        od=n/2+1;
    }else{
        od= n/2;
    }
    double res = od/(double)n;
    printf("%.10lf",res);

    return 0;
}

Measured memory_bytes: 256
program abc133c
  use,intrinsic :: iso_fortran_env
  implicit none
  integer(int64) :: l, r, i, j, ans
  read *, l, r
  if (r - l + 1 >= 2019) then
     print *, 0
  else
     ans = 2019
     do j = l+1,r
        do i = l,j-1
           ans = min(ans,mod(i*j,2019))
           if (ans == 0) exit
        end do
     end do
     print *, ans
  end if
end program abc133c


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring>
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));

signed main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> v,w;
    rep(i,n){
        ll x,y; cin >> x >> y;
        v.pb(x+y);
        w.pb(x-y);
    }
    sort(ALL(v));
    sort(ALL(w));
    ll ans=0;
    chmax(ans,labs(v[n-1]-v[0]));
    chmax(ans,labs(w[n-1]-w[0]));
    cout << ans << endl;
}




Measured memory_bytes: 6692
using System;

class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int a = int.Parse(input[0]);
    int b = int.Parse(input[1]);
    int c = int.Parse(input[2]);
    int d = int.Parse(input[3]);
    
    if(a + b > c + d) Console.WriteLine("Left");
    else if(a + b == c + d) Console.WriteLine("Balanced");
    else Console.WriteLine("Right");
  }
}

Measured memory_bytes: 13140
N, K, *X = map(int, open(0).read().split())

y = [float(x * (x + 1) / 2 / x) for x in X]
ans = sum(y[:K])
res = ans
for i in range(K, N):
    res = res - y[i - K] + y[i]
    ans = max(ans, res)
print(ans)


Measured memory_bytes: 106000
import java.util.Locale;
import java.util.Scanner;

public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in).useLocale(Locale.US);
        int n = sc.nextInt();
        int result = 0;

        for(int i = 1; i <= n; ++i){
            int a = sc.nextInt();
            if(a % 2 == 1 && i % 2 == 1) ++result;
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 35748
/*
发现有解的充要条件是有一个形为AABBAABBAABB的环
此时每一个点至少与两个不同颜色的点相连
对于初始不合法的点直接删掉，判断删掉后与其相连的点是否变为不合法
类似拓扑排序 
*/
#include<bits/stdc++.h> 
#define gc getchar()
#define pc putchar 
inline int read() { 
	int x = 0,f = 1; 
	char c = gc; 
	while(c < '0' || c > '9') {if(c == '-')f = -1; c = gc;} 
	while(c <= '9' && c >= '0') x = x * 10 + c - '0',c = gc; 
	return x * f; 
} 
void print(long long  x) { 
	if(x < 0) { 
		pc('-'); 
		x = -x; 
	} 
	if(x >= 10) print(x / 10); 
	pc(x % 10 + '0'); 
} 
const int maxn = 1000007; 
int val[maxn]; 
int n,m; 
struct node {	
	int v,next; 
} edge[maxn]; 
int head[maxn],num = 0; 
inline void add_edge(int u,int v) { 
	edge[++ num].v = v; edge[num].next = head[u];head[u] = num; 
} 
int d[maxn][2]; 
std::queue<int>q; 
char s[maxn]; 
bool vis[maxn];  
int main() { 
	n = read(),m = read();
	scanf("%s",s + 1); 
	for(int i = 1;i <= n;++ i) {
		char c = s[i]; 
		if(c == 'A') val[i] = 0; 
		else val[i] = 1; 
	} 
	for(int u,v,i = 1;i <= m;++ i) { 
		u = read(),v = read(); 
		add_edge(u,v); add_edge(v,u); 
		d[u][val[v]] ++,d[v][val[u]]++;  
	} 
	int count = 0; 
	for(int i = 1;i <= n;++ i)  
		if(!d[i][1] || !d[i][0]) 
			q.push(i),count ++ ,vis[i] = 1;   
	while(!q.empty()) { 
		int u = q.front(); q.pop(); 
		for(int i = head[u];i;i = edge[i].next) { 
			int v = edge[i].v; 
			d[v][val[u]] --; 
		 	if((!d[v][1] || !d[v][0] )&& !vis[v]) {
		 		q.push(v); count++; vis[v] = 1; 
			 } 
		} 
	} 
	puts(count == n ? "No" : "Yes"); 
	return 0; 
} 

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

int main()
{
    long n, k, tmp,sum1=0, sum2=0;
    cin >> n >> k;
    vector<long> a(n);
    for (long i = 0; i < n;i++){
        cin >> a.at(i);
        if(a.at(i)==1){
            tmp = i;
        }
    }

    for (int i = 0; i < n;i++){
        if ((n - (k + (k - 1) * (i - 1)))>0){
            sum1 = i+1;
        }
    }
    cout << sum1 << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;
int main(){
	int n;
	std::cin >> n;
	std::deque<int> a;
	rep(i,n){
		int d;
		std::cin >> d;
		if(i%2==0)a.pf(d);
		else	a.pb(d);
	}
	if(n%2==1){
		rep(i,n){
			std::cout <<  a[i]<<" ";
		}
		std::cout  << std::endl;
	}else{
		rep(i,n){
			std::cout <<  a[n-i-1]<<" ";
		}
		std::cout  << std::endl;
	} 
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)



int main(){
    int a,p;
    cin>>a>>p;
    int ans=a*3+p;
    ans/=2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
#define PI 3.1415926535
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 25e7;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}
signed main()
{
    Start();
    int s, w;
    cin >> s >> w;
    if (w >= s)
        cout << "unsafe";
    else
        cout << "safe";
    return 0;
}



Measured memory_bytes: 3548
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int W,H,x,y,r;

    cin >> W >> H >> x >> y >> r;

    if (x - r >= 0 &&
        x + r <= W &&
        y - r >= 0 &&
        y + r <= H)
    {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
L = LIST()

tmp = max(L)
L.remove(tmp)
if tmp < sum(L):
	print("Yes")
else:
	print("No")


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

signed main(){
    int N;
    cin >> N;
    vector<int> A;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        A.push_back(a);
    }
    
    bool next_is_cheaper[N+1];
    next_is_cheaper[N-1] = true;
    next_is_cheaper[N] = true;
    for(int i=N-2; i>=0; i--){
        if(A[i] > A[i+1]){
            next_is_cheaper[i] = true;
        }
        else if(A[i] < A[i+1]){
            next_is_cheaper[i] = false;
        }
        else{
            next_is_cheaper[i] = next_is_cheaper[i+1];
        }
    }

    for(int i=1; i<=N-2; i++){
        if(!next_is_cheaper[i-1] && !next_is_cheaper[i] && !next_is_cheaper[i+1]){
            // ここで t 買い にするのとどっちがいいか
            int money = 1000, kabu = 0;
            for(int i=0; i<N; i++){
                if(!next_is_cheaper[i]){
                    // 買い
                    kabu += money / A[i];
                    money = money % A[i];
                }
                else{
                    // 売り
                    money += kabu * A[i];
                    kabu = 0;
                }
            }
            int now_m = money;
            money = 1000, kabu = 0;
            next_is_cheaper[i] = true;
            for(int i=0; i<N; i++){
                if(!next_is_cheaper[i]){
                    // 買い
                    kabu += money / A[i];
                    money = money % A[i];
                }
                else{
                    // 売り
                    money += kabu * A[i];
                    kabu = 0;
                }
            }
            if(now_m > money){
                next_is_cheaper[i] = false;
            }
        }
    }

    int money = 1000, kabu = 0;
    for(int i=0; i<N; i++){
        if(!next_is_cheaper[i]){
            // 買い
            kabu += money / A[i];
            money = money % A[i];
        }
        else{
            // 売り
            money += kabu * A[i];
            kabu = 0;
        }
    }
    cout << money << endl;

    return 0;
}

Measured memory_bytes: 3632
v[2]['~e'],l,n,m,a,c,*i,*s;D(x){c=0;for(i=v+a;c<x;i+=2)c+=i[1];memmove(i+2,i,(v[a]+l-i)*4);l+=2;*i=i[-2]+(i[-1]-=i[1]=c-x);return i;}C(d,s,e){c=memcpy(d,s,e-s)+e-s;}main(p,q,r,x,y){for(;scanf("%d%d%d%d%d",&n,&m,&p,&q,&r)*n;printf("%d\n",c)){v[a=**v=0][1]=n;for(l=2;m--;a^=1)scanf("%d%d",&x,&y),C(C(C(v[a^1],y,v[a]+l),x,y=D(y)),v[a],x=D(x));s=D(p-1);i=D(q);for(c=0;s-i;s+=2)c+=*s+s[1]>r?*s<r?r-*s:0:s[1];}}

Measured memory_bytes: 572
#include<stdio.h>
#include <iostream>
#include<string>
#include<algorithm>
#include<sstream>
#include<math.h>
using namespace std;
int main() {
	int a[5];
	int ans=0;
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
		if (a[i] < 40)a[i] = 40;
		ans += a[i] / 5;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3088
#include<stdio.h>

int main(void)
{
  int n,l,i,j,k,x,in1[26],in2[26];
  char str[100][101],sort1[26][100][101],sort2[26][100][101];
  scanf("%d %d",&n,&l);
  //inを初期化
  for(i=0;i<26;i++)
    {
      in1[i] = 0;
      in2[i] = 0;
    }
  //右から1文字目をバケットに入れる
  for(i=0;i<n;i++)
    {
      scanf("%s",str[i]);
      if(l%2 != 0)
	{
	  for(j=0;j<l;j++)
	    {
	      sort1[(int)str[i][l-1]-97][in1[(int)str[i][l-1]-97]][j] = str[i][j];
	    }
	  in1[(int)str[i][l-1]-97]++;
	}
      else
	{
	  for(j=0;j<l;j++)
	    {
	       sort2[(int)str[i][l-1]-97][in2[(int)str[i][l-1]-97]][j] = str[i][j];
	    }
	  in2[(int)str[i][l-1]-97]++;
	}
    }

  //2文字目以降についてバケットに入れる
  for(i=l-2;i>=0;i--)
    {
      //バケットの内容を初期化
      if(i%2 != 0)
	{
	  for(j=0;j<26;j++)
	    {
	      in2[j] = 0;
	    }
	}
      else
	{
	  for(j=0;j<26;j++)
	    {
	      in1[j] = 0;
	    }
	}

      if(i%2 != 0) //どっちのバケットを使うか
	{
	  for(j=0;j<26;j++)
	    {
	      for(k=0;k<in1[j];k++)
		{
		  //printf("1 %d %d %s\n",((int)sort1[j][k][i]-97),in1[j],sort1[j][k]);/////////////////////////////////////////
		  for(x=0;x<l;x++)
		    {
		      sort2[(int)sort1[j][k][i]-97][in2[(int)sort1[j][k][i]-97]][x] = sort1[j][k][x];
		    }
		  in2[(int)sort1[j][k][i]-97]++;
		}
	    }
	}
      else
	{
	  for(j=0;j<26;j++)
	    {
	      for(k=0;k<in2[j];k++)
		{
		  //printf("2 %d %d %s\n",((int)sort2[j][k][i]-97),in2[j],sort2[j][k]); //////////////////////////////////////////
		  for(x=0;x<l;x++)
		    {
		      sort1[(int)sort2[j][k][i]-97][in1[(int)sort2[j][k][i]-97]][x] = sort2[j][k][x];
		    }
		  in1[(int)sort2[j][k][i]-97]++;
		}
	    }
	}
    }
  
  for(i=0;i<26;i++)
    {
      for(j=0;j<in1[i];j++)
	{
	  printf("%s",sort1[i][j]);
	}
    }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static int LCS(String s1, String s2) {
        int[][] matrix = new int[s1.length() + 1][s2.length() + 1];
        for (int i = 0; i < matrix.length; i++) {
            matrix[i][0] = 0;
        }

        for (int i = 0; i < matrix[0].length; i++) {
            matrix[0][i] = 0;
        }

        for (int i = 1; i < matrix.length; i++) {
            for (int j = 1; j < matrix[0].length; j++) {
                matrix[i][j] = s1.charAt(i - 1) == s2.charAt(j - 1) ? 1 + matrix[i - 1][j - 1] : Math.max(matrix[i - 1][j], matrix[i][j - 1]);
            }
        }
        return matrix[s1.length()][s2.length()];
    }
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int queries = input.nextInt();
        input.nextLine();

        for (int i = 0; i < queries; i++) {
            System.out.println(LCS(input.nextLine(), input.nextLine()));
        }

        input.close();
    }
}


Measured memory_bytes: 63832
import java.util.*;
import java.util.TreeMap;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    long W = sc.nextLong();
    long A = H * W;
    if (H == 1 || W == 1) {
      System.out.println(1);
    } else {
      System.out.println((A + 1) / 2);
    }
  }
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

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

    int64_t min;
    cin >> min;
    for (int i = 1; i < 5; ++i)
    {
        int64_t t;
        cin >> t;
        if (t < min)
            min = t;
    }

    int64_t result = (n / min) + (n % min != 0 ? 1 : 0) + 4;
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long base(long long b, long long n) {
    long long a = 0;
    while (n != 0)
    {
        a += n % b;
        n /= b;
    }
    return a;
}
int main() {
    long long n, s, k = 0;
    cin >> n >> s;
    if (s == n) cout << n + 1;
    else if (s > n) cout << -1;
    else
    {
        for (long long b = 2; b < sqrt(n) + 1; b++) 
        {
            if (base(b, n) == s)
            {
                k++;
                cout << b;
                break;
            }
        }
        if (k == 0)
        {
            for (long long p = floor(sqrt(n)) + 1; p >= 1; p--)
            {
                if ((n - s) % p == 0)
                {
                    long long b = (n - s) / p + 1;
                    if (base(b, n) == s)
                    {
                        k++;
                        cout << b;
                        break;
                    }
                }
            }
        }
        if (k == 0) cout << -1;
    }
}

Measured memory_bytes: 3708
using System;
class Program{
	static void Main(){
		long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		long[] a=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		long[,] h=new long[s[0],s[0]];
		long ans=long.MaxValue;
		for(int i=0;i<s[0];i++){
			h[i,0]=a[i];
			long q=a[i],k=1;
			for(long j=s[0]+i-1;j!=i;j--,k++){
				h[i,k]=Math.Min(a[j%s[0]],h[i,k-1]);
			}
		}
		for(int i=0;i<s[0];i++){
			long q=i*s[1];
			for(int j=0;j<s[0];j++){q+=h[j,i];}
			ans=Math.Min(ans,q);
		}
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 44384
var input: string = require('fs').readFileSync('/dev/stdin', 'utf8');
var inputLines: string[] = input.trim().split("\n");
var parts = inputLines[0].split(" ");

var A = parts[0];
var T = A == "H" ? parts[1] : parts[1] == "H" ? "D" : "H";

console.log(T);

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

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

	if ((b - a) > k or (c - a) > k or (d - a) > k or (e - a) > k){
		cout << ":(";
	}
	else{
		cout << "Yay!";
	}

	return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%s %s',$S, $T);
fscanf(STDIN, '%d %d',$A, $B);
fscanf(STDIN, '%s', $U);
if ($S === $U) {
    $A--;
} else {
    $B--;
}
printf('%d %d', $A, $B);


Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll x,k,d,s;
    cin >> x >> k >> d;
    s = (x == 0 ? 1 : x/abs(x));
    ll div = abs(x)/d;
    div = min(div,k);
    k -= div;
    if(k&1) div++;
    cout << abs(abs(x) - div*d) << endl;
}


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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC   
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

const ll MOD = (ll)1e9+7; //change it for other mods

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve(ll testnum)
{
    ll n,d;
    cin >> n >> d;
    ll cnt = 0;
    for(ll i=0;i<n;i++) {
    	ll x,y;
    	cin >> x >> y;
    	if(x*x + y*y <= d*d) {
    		cnt++;
    	}
    }
    cout << cnt << "\n";
}

int main()
{
    FAST_IO;
    #ifdef STIO 
      freopen("input.txt" , "r", stdin);
      freopen("output.txt" , "w", stdout);
    #endif
    ll t = 1;
    // cin >> t;
    for (ll i = 1; i <= t; i++) {
        solve(i);
    }
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  bool beautiful = true;
  for(int i = 0; i < s.size(); i++){
    int cnt = 0;
    for(int j = 0; j < s.size(); j++){
      if(s.at(i) == s.at(j)) cnt++;
    }
    if(cnt % 2 == 1){
      beautiful = false;
      break;
    }
  }
  if(beautiful) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

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

    ll ans = 0;
    for (int b = k + 1; b <= n; b++) {
        int q = (n - k) / b;
        int r = min(n - q * b, b - 1);

        ans += (ll)(b - k) * q;
        ans += r - k + 1;
    }

    if (k == 0) ans -= n;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256