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

ll ans(int n, ll x){
  if(n == 0) return 1;
  ll len = (1LL << (n + 1)) - 3;
  ll num = (1LL << (n)) - 1;
  if(x == 1) return 0;
  //1つ分のバーガーの途中で終わっている場合
  else if(x <= len + 1) return ans(n -1, x -1);
  //ちょうど半分の位置にあるpのところまでの場合
  else if(x == len + 2) return num + 1;
  //一つ分のL-1バーガーを完全に含み、もう一つのL -1バーガーの途中まで含む場合。
  else if (x <= (len + 1) * 2) return num + 1 + ans(n-1, x-len-2);
  //全て含む
  else return num * 2 + 1;

}

int main() {
  int n;
  ll x;
  cin >> n >> x;
  ll ansa = ans(n, x);
  cout << ansa << endl;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int L = A + B;
  int R = C + D;
  
  if (L > R) {
    cout << "Left" << endl;
  } else if (L == R) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}


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

def inOdd(lst):
    flag = False
    for i in range(len(lst)):
        if lst[i]%2!=0:
            flag = True
            break
    return flag

count = 0
while True:
    if inOdd(A):
        break
    for i in range(len(A)):
        A[i] /= 2
    count += 1
print(count)

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

using namespace std;

bool is_prime(int n, int k = 2)
{
	if (n == 1) { return false; }
	
	if (n < k * k) { return true; }

	if (n % k == 0) { return false; }

	return is_prime(n, k + 1);
}

int main()
{
	vector<int> prime;

	for (int i = 2; i <= 100000; i++)
	{
		if (is_prime(i))
		{
			prime.push_back(i);
		}
	}

	int m, a, b;

	while (true)
	{
		cin >> m >> a >> b;

		if (m == 0 && a == 0 && b == 0) { break; }

		int max_ = 0, p = 0, q = 0;

		for (int i = 0; i < prime.size(); i++)
		{
			for (int j = i; j < prime.size() && (prime[i] * prime[j] <= m); j++)
			{
				if (a * prime[j] <= b * prime[i] && 1LL * prime[i] * prime[j] <= m)
				{
					if (max_ < prime[i] * prime[j])
					{
						max_ = prime[i] * prime[j];

						p = prime[i];
						q = prime[j];
					}
				}
			}
		}

		cout << p << ' ' << q << endl;
	}

	return 0;
}

Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

template<class... Args>
auto input(Args&&... args) {
    return InputType2(std::forward<Args>(args)...);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

auto gcd(size_t l, size_t r) {
    if (r == 0)
        return l;
    return gcd(r, l % r);
}

auto gcd(size_t a, size_t b, size_t c) {
    return gcd(gcd(gcd(a, b), gcd(a, c)), gcd(b, c));
}

int main() {
    size_t k = input();
    size_t d = 0;
    for (size_t a = 1; a <= k; ++a) {
        for (size_t b = 1; b <= k; ++b) {
            for (size_t c = 1; c <= k; ++c) {
                d += gcd(a, b, c);
            }
        }
    }
    cout << d << endl;
    return 0;
}


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

using namespace std;

int main(){
  int A, B;
  int x, y, z, Max;
  cin >> A >> B;
  x = A + B;
  y = A - B;
  z = A * B;
  Max = max(max(x, y), z);
  cout << Max << endl;
  return 0;
}

Measured memory_bytes: 256
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define endl "\n"
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int fast_pow(int x, int y, int p);
int BIT[1000000];
int size=1000000;


int get(int idx)
{
    int ans=0;
    while(idx>0)
    {
        ans+=BIT[idx];
        idx-=(idx&(-idx));
    }
    return ans;
}
void upd(int idx,int val)
{
    while(idx<size)
    {
        BIT[idx]+=val;
        idx+= (idx&(-idx));
    }
}
void solve() {
    int n,i,d,a;
    cin>>n>>d>>a;
    set<int> st;
    map<int,int> mp;
    vector<pair<int,int>> v(n);
    int cnt=1;
    for(i=0;i<n;i++)
    {
        cin>>v[i].F>>v[i].S;
        st.insert(v[i].F);
        st.insert(v[i].F + 2*d +1);
    }
    sort(ALL(v));
    for(auto x: st)
    {
        mp[x]=cnt++;
    }
    int ans=0;
    for(i=0;i<n;i++)
    {
        int dam=get(mp[v[i].F]);
        int val=v[i].S-dam;
        if(val>0)
        {
            double dd=val;
            int plus=ceil(dd/a);
            ans+=plus;
            upd(mp[v[i].F],plus*a);
            upd(mp[v[i].F+ 2*d + 1],-plus*a);
        }
    }
    cout<<ans<<endl;

}

int32_t main() {
    IOS;
    int test = 1;
    // cin >> test;
    while (test--) {
        solve();
    }
    return 0;
}
int fast_pow(int x, int y, int p) {
    int res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

Measured memory_bytes: 54016
#include<stdio.h>
#define N 10000

int main(){

  int S[N],T[N];
  int n,q,a,i,j,count=0;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  
  for(j=0;j<=q-1;j++){

    i=0;
    S[n]=T[j];

    while(S[i]!=T[j]){
      i++;
    }

    if(i!=n) count++;

  }

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

  return 0;

}



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

numAppeared = [0] * (N+1)

for i in A:
    numAppeared[i] += 1

numAppeared.sort( reverse=True )

# print( sum( numAppeared[i] for i in range(K,N) ) )
print( sum( numAppeared[K:N] ) )

Measured memory_bytes: 24996
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
//l={1,2,3,4}
//sort(l,l+N,greater<int>());	降順ソート
//sort(l,l+N);	昇順ソート
//string 変数　　変数.size()で数字化


int main(void)
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int an, bn;
	an = min(a, b);
	bn = min(c, d);
	cout << an + bn << endl;
}

Measured memory_bytes: 256
S = input()

a = 0
b = 0
c = 0

for i in S:
    if i == "a":
        a += 1
    elif i == "b":
        b += 1
    else:
        c += 1

if (max(a,b,c) - min(a,b,c)) <= 1:
    print ("YES")
else:
    print ("NO")


Measured memory_bytes: 40676
#include<string>
#include<math.h>
#include<iostream>

using namespace std;

int main()
{
	string S;
	int N;
	cin >> N >> S;
	for (int i = 0; i < S.size(); i++){
		if (S[i] + N != 'A' && S[i] + N != 'B' && S[i] + N != 'C' && 
			S[i] + N != 'D' && S[i] + N != 'E' && S[i] + N != 'F' &&
			S[i] + N != 'G' && S[i] + N != 'H' && S[i] + N != 'I' &&
			S[i] + N != 'J' && S[i] + N != 'K' && S[i] + N != 'L' && 
			S[i] + N != 'M' && S[i] + N != 'N' && S[i] + N != 'O' &&
			S[i] + N != 'P' && S[i] + N != 'Q' && S[i] + N != 'R' && 
			S[i] + N != 'S' && S[i] + N != 'T' && S[i] + N != 'U' &&
			S[i] + N != 'V' && S[i] + N != 'W' && S[i] + N != 'X' && 
			S[i] + N != 'Y' && S[i] + N != 'Z' )printf("%c", S[i] - 26 + N);
		else printf("%c", S[i] + N);
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n;
    int a[200010];
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    scanf("%d",&a[i]);

    int m=0;
    int b[200010]={};

    for(int i=n;i>=1;i--)
    {
        int sum=0;
        for(int j=1;i*j<=n;j++)
        {
            sum+=b[i*j];
        }
        if(sum%2!=a[i])
        {
            b[i]++;
            m++;
        }
    }

    printf("%d\n",m);
    bool s=true;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<b[i];j++){
            if(s) {
                printf("%d",i);
                s=false;
            }
            else printf(" %d",i);
        }
    }
    printf("\n");
}

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

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

std::vector<int> RollingHashMatches(const std::string& haystack,
                                    const std::string& needle) {
  if (haystack.size() < needle.size()) {
    return {};
  }
  auto roll = [](uint64_t& h, char c) { h = h * 100000007 + c; };
  uint64_t h = 0, n = 0, t = 1;
  for (std::size_t i = 0; i < needle.size(); ++i) {
    roll(h, haystack[i]);
    roll(n, needle[i]);
    roll(t, 0);
  }
  std::vector<int> matches;
  for (std::size_t i = 0;; ++i) {
    if (h == n) matches.push_back(i);
    std::size_t j = i + needle.size();
    if (j == haystack.size()) break;
    roll(h, haystack[j]);
    h -= t * haystack[i];
  }
  return matches;
}

using namespace std;

int main() {
  rd(int, n);
  vector<bitset<30>> a(n), b(n);
  rep(i, n) {
    rd(int, x);
    a[i] = x;
  }
  rep(i, n) {
    rd(int, x);
    b[i] = x;
  }

  vector matches(30, vector(2, vector(n, false)));
  rep(bit, 30) {
    string as, nas, bs;
    rep(i, n) {
      as += '0' + a[i][bit];
      nas += '1' - a[i][bit];
      bs += '0' + b[i][bit];
    }
    bs += bs;
    for (int m : RollingHashMatches(bs, as)) {
      matches[bit][0][m] = true;
    }
    for (int m : RollingHashMatches(bs, nas)) {
      matches[bit][1][m] = true;
    }
  }
  vector<pair<int, int>> ans;
  rep(i, n) {
    bool ok = true;
    rep(j, 30) if (!(matches[j][0][i] || matches[j][1][i])) ok = false;
    if (!ok) continue;
    int x = 0;
    rep(j, 30) x |= (matches[j][1][i]) << j;
    ans.push_back({(n - i) % n, x});
  }
  sort(all(ans));
  for (auto [a, b] : ans) wt(a, b);
}


Measured memory_bytes: 10860
#include<stdio.h>
int main()
{
    int a, b, c, x, y;
    scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
    if((a+b)/2<c)
        printf("%d\n", x*a+y*b);
    else if(x<y)
    {
        if(2*c<b) printf("%d\n", 2*y*c);
        else printf("%d\n", 2*x*c+(y-x)*b);
    }
    else
    {
        if(2*c<a) printf("%d\n", 2*x*c);
        else printf("%d\n", 2*y*c+(x-y)*a);
    }
}


Measured memory_bytes: 128
def myAnswer(a:int,b:int,c:int) -> str:
   A = ( a + b - c) ** 2
   B = 4 * a * b

   return "Yes" if( A - B > 0 and (c - a - b) > 0) else "No"

def modelAnswer():
   return
def main():
   a,b,c = map(int,input().split())
   print(myAnswer(a,b,c))

if __name__ == '__main__':
   main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long int
#define ld long double
#define pb push_back
#define pf push_front
#define ft first
#define sc second
#define all(v) v.begin(), v.end()
using namespace std;
const int maxn = 4101;
int suf[3][maxn];
signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int d = 0; d < s.size(); d++) {
        if (s[d] == 'R') {
            s[d] = '0';
        }
        if (s[d] == 'G') {
            s[d] = '1';
        }
        if (s[d] == 'B') {
            s[d] = '2';
        }
    }
    for (int d = s.size() - 1; d >= 0; d--) {
        suf[0][d] = suf[0][d + 1];
        suf[1][d] = suf[1][d + 1];
        suf[2][d] = suf[2][d + 1];
        suf[s[d] - '0'][d]++;
    }
    int ans = 0;
    for (int d = 0; d < s.size(); d++) {
        for (int i = d + 1; i < s.size(); i++) {
            if (s[d] != s[i]) {
                int cnt = n - i - 1 - suf[s[d] - '0'][i + 1] - suf[s[i] - '0'][i + 1];
                int dif = i - d;
                if (i + dif < n && s[i + dif] != s[d] && s[i + dif] != s[i]) {
                    cnt--;
                }
                ans += cnt;
            }
        }
    }
    cout << ans;
}


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

int main()
{
    string n;
    int a = 0;
    cin >> n;
    if (n[0] == '7')
    {
        a++;
    }
    if (n[1] == '7')
    {
        a++;
    }
    if (n[2] == '7')
    {
        a++;
    }

    if (a == 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3640
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int train = N * A;
		int taxi = B;
		System.out.println(Math.min(train, taxi));

	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a/b; a -= t*b; swap(a, b); u -= t*v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if (e%2 == 0) { p = (p*p)%mod; e /= 2; }
            else { a = (a*p)%mod; e--; }
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

const int MAX_N = 100100;
const int MAX_D = 110;
const int MOD = 1e9+7;

int main() {
    string S;
    int D;
    cin >> S >> D;
    int N = S.length();
    
    ModInt<MOD> dp[MAX_N][2][MAX_D];
    dp[0][0][0] = 1;
    for (int i = 0; i < N; i++) {
        const int c = S[i] - '0';
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 10; k++) {
                if (!j && c < k) continue;
                for (int d = 0; d < D; d++) {
                    dp[i+1][j || (k < c)][(d + k) % D] += dp[i][j][d];
                }
            }
        }
    }
    
    ModInt<MOD> ans = dp[N][0][0] + dp[N][1][0] - 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 86272
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
using namespace std;
 
int main(int argc, char const* argv[]) {
    int N, M;
    cin >> N >> M;
 
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
 
    auto threshold = 1.0 * accumulate(A.begin(), A.end(), 0U) / (4 * M);
 
    // cout << "threshold" << threshold << endl;
 
    int selected = 0;
 
    for (int i = 0; i < N; i++) {
        if (A[i] >= threshold) {
            selected++;
        }
    }
 
    if (selected >= M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const Q  = parseInt(arg[0]);
    const lr = arg.slice(1, Q + 1);
    
    let primeMap = [];
    
    // 100000までの素数表を作る
    for(let i=1; i<=100000; i++) {
        if(i === 1) {
            primeMap[i] = false;
            continue;
        }
        
        let flag = true;
        
        for(let j=2; j<i; j++) {
            if(i % j === 0) {
                flag = false;
                break;
            }
            
            if(j > Math.sqrt(i)) {
                break;
            }
        }
        
        if(flag) primeMap[i] = true;
    }
    
    let totalSum = [...Array(100000)].fill(0);
    
    // 奇数のうち2017-likeかどうかを判定する
    for(let i=1; i<=100000; i += 2) {
        // Nも(N+1 / 2)も素数かどうか
        if(primeMap[i] && primeMap[((parseInt(i) + 1) / 2)]) {
            totalSum[i]++;
        }
    }

    // 上書きして累積和にしていく
    for(let i=1; i<=100000; i ++) {
        totalSum[i] += totalSum[i - 1];
    }
    
    let answer = [];
    
    // 累積和からlrの範囲をとる
    for(let i in lr) {
        let l = parseInt(lr[i].split(" ")[0]);
        let r = parseInt(lr[i].split(" ")[1]);
        
        answer.push(totalSum[r] - totalSum[l - 1]);
    }
    
    console.log(answer.join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 55912
x = gets.chomp.to_f
max = 1

for i in 2..31
  v = Math.log(x) / Math.log(i.to_f)
  value = v.round(10)
  if value >= 2.0
    new_num = i ** value.floor
    if new_num > max
      max = new_num
    end
  end
end

puts max


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, K;
    string S;

    cin >> N >> K;
    cin >> S;

    char now = S[0];
    ll count = 0;
    vector<ll> C;
    if(S[0] == '0'){
        C.push_back(0);
    }
    REP(i, N){
        if(S[i] == now){
            count++;
        }
        else{
            C.push_back(count);
            count = 1;
        }
        now = S[i];
    }
    C.push_back(count);
    if(S[N-1] == '0'){
        C.push_back(0);
    }

    ll L = C.size();
    vector<ll> A(L+1);
    
    A[0] = 0;
    for(ll i=0; i<L; i++){
        A[i+1] = A[i] + C[i];
    }

    // REP(i, L){
    //     cout << T[i] << " " << C[i] << " " << A[i] << endl;
    // }

    ll ans = 0;
    for (ll left = 0; left < L+1; left += 2) {
        ll right = left + K*2+1;
        if (right >= L+1) right = L;
        ans = max(ans, A[right] - A[left]);
    }
    cout << ans << endl;
   
    return 0;
}

Measured memory_bytes: 2164
from sys import stdin
INF = float("inf")#無限大の設定1
IINF = 10 ** 18#無限大の設定2
MOD = 10 ** 9 + 7#まれに用いるmodを予め設定しておく
N = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
S,T = map(str, stdin.readline().rstrip().split())
#S = [list(stdin.buffer.readline().decode().rstrip()) for _ in range(h)]
ans = ""
for i in range(N):
    ans += S[i]
    ans += T[i]
print(ans)


Measured memory_bytes: 3060
n,m = gets.split.map(&:to_i)
roads = m.times.map{gets.split.map(&:to_i)}

ans = [0]*n
roads.each do |r|
  1.upto(n) do |i|
    ans[i-1] += 1 if r.include?(i)
  end
end

ans.each do |a|
  puts a
end

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int n;
ll m, v, p, a[125252];

bool is_ok(int mid){
  ll b[125252];
  REP(i, n){
    b[i]=a[i];
  }
  ll cnt=m*v;
  if(b[p-1]-b[mid]>m){
    return false;
  }
  cnt-=m*(p+n-mid-1);
  b[mid]+=m;
  FOR(i, p-1, mid){
    cnt-=min(b[mid]-b[i], (ll)m);
  }
  return cnt<=0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  cin>>n>>m>>v>>p;
  REP(i, n){
    cin>>a[i];
  }
  sort(a, a+n, greater<int>());
  int lb=p-1, ub=n;
  while(ub-lb>1){
    int mid=(lb+ub)/2;
    if(is_ok(mid)){
      lb=mid;
    }
    else{
      ub=mid;
    }
  }
  cout<<lb+1<<'\n';
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;

int d[N];
vector<int> child[N];
int par[N];
int n, k;
int ans = 0;

void dfs(int v)
{
	for (auto u : child[v])
	{
		dfs(u);
		if (v != 0 && d[u] >= k-1)
			ans++, d[u] = -1;
		d[v] = max(d[v], d[u] + 1);
	}	
}

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

	cin >> n >> k;
	cin >> par[0];
	if (par[0] != 1)
		ans++;
	for (int i=1; i<n; i++)
	{
		cin >> par[i];
		par[i]--;
		child[par[i]].push_back(i);
	}
	dfs(0);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define read cin >>
#define echo cout <<
#define fin << '\n'

struct Data {
    int id;
    bool isHonest;
};

vector<Data> dat[16];

signed main ( ) {

    int n;
    read n;
    vector<int> a(n);
    for ( int i = 0; i < n; i++ ) {
        read a[i];
        for ( int j = 0; j < a[i]; j++ ) {
            int x, y;
            read x >> y;
            dat[i].push_back({x-1, !!y});
        }
    }

    int ans = 0;
    for ( int i = 0; i < (1<<n); i++ ) {
        bool isCorrect = true;
        for ( int j = 0; j < n; j++ ) {
            if ( (1<<j) & i ) {
                for ( int k = 0; k < a[j]; k++ ) {
                    isCorrect &= !!((1<<dat[j][k].id)&i) == dat[j][k].isHonest;
                }
            }
        }

        if ( isCorrect ) {
            ans = max ( ans, __builtin_popcount(i) );
        }
    }

    echo ans fin;

    return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        m: usize,
        k: usize,
    }

    if k >= (1 << m){
        println!("-1");
        return;
    }

    if m == 0{
        if k == 0{
            println!("0 0");
        }else{
            println!("-1");
        }
        return;
    }

    if m==1{
        if k == 0{
            println!("0 0 1 1");
        }else{
            println!("-1");
        }
        return;
    }

    let a : Vec<usize> = (0..(1<<m)).collect();
    let mut b : Vec<usize> = (0..(1<<m)).collect();
    b.reverse();

    for e in &a{
        if *e != k {
            print!("{} ",e);
        }
    }
    print!("{} ",k);

    for e in &b{
        if *e != k {
            print!("{} ",e);
        }
    }
    println!("{}",k);

}


Measured memory_bytes: 4144
n,m = map(int,input().split())
ans = [ "" for i in range(m) ]
data = []
for i in range(m):
    a,b = map(int,input().split())
    data.append([b,a,i])
data = sorted(data)
cnt = [ 1 for i in range(n+1) ]
for i in data:
    a = "0"*(6-len(str(i[1]))) + str(i[1]) + "0" * (6-len(str(cnt[i[1]]))) + str(cnt[i[1]])
    ans[i[2]] = a
    cnt[i[1]] += 1

for i in ans:
    print(i)


Measured memory_bytes: 32116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
ll MOD = 1e9 + 7;
int main() {
    ll n, a, b, c, d, ans;
    cin >> n;
    a=b=c=d=1;
    rep(i, n) a = (a*10)%MOD;
    rep(i, n) b = (b*9)%MOD;
    rep(i, n) d = (d*8)%MOD;
    //cout << a <<',' << b <<','<<d <<endl;
    ans = a - 2*b + d;
    ans = ans%MOD;
    if (ans < 0) {
        ans += MOD;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3628
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, m;
  cin >> n >> m;
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
B = [4,6,9,11]
C = [1,3,5,7,8,10,12]
x,y = map(int,input().split())
if x==y and x==2:
  print("Yes")
elif B.count(x)==B.count(y) and B.count(y)==1:
  print("Yes")
elif C.count(x)==C.count(y) and C.count(y)==1:
  print("Yes")
else:
  print("No")

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<int>h(n);
rep(i,n)cin>>h[i];
const int INIT=300;
int min_val=INIT;
int ans=0;
int l;
do{
    l=0;
    rep(r,n+1){
       if(r==n || h[r]==0){
           reps(j,r,l){
               h[j]-=min_val;
           }
           if(min_val!=INIT)ans+=min_val;
           l=r+1;
           min_val=INIT;           
       }
       else{
           min_val=min(min_val,h[r]);
       }
   }
   
}while(accumulate(h.begin(),h.end(),0));
cout<<ans<<endl;
return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    vector<ll> X(5);
    REP(i, 5) cin >> X[i];

    ll L = 2*max(X[3], X[4]);

    ll res = (1ll<<60);
    for(int i=0;i<=L;i++){
    	ll tmp = 0;
    	tmp += X[0] * max(X[3] - i/2, 0ll);
    	tmp += X[1] * max(X[4] - i/2, 0ll);
    	tmp += X[2] * i;
    	chmin(res, tmp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
double N,K;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>K;
    double ans=0;
    rep(i,1,min(N+1,K)){
        ans+=pow(0.5, int(log2((K-1)/i))+1);
    }
    rep(i,min(N+1,K),N+1){
        ans+=1;
    }
    ans/=N;
    cout <<setprecision(15)<<ans<<"\n";
}

Measured memory_bytes: 512
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

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


def solve():
    S = input()
    if S == "ABC":
        print ("ARC")
    else:
        print ("ABC")






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()


Measured memory_bytes: 65140
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    cin >> s;
    int n = 0, ss = 0, e = 0, w = 0;
    for(auto &x : s){
        if(x == 'N') n = 1;
        if(x == 'S') ss = 1;
        if(x == 'E') e = 1;
        if(x == 'W') w = 1;
    }
    if((n ^ ss) || (e ^ w)){
        cout << "No";
    }else{
        cout << "Yes";
    }
    return 0;
}
/*
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

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

int main(void){
  int a[3];
  for(int i = 0; i < 3; i++) cin >> a[i];
  int ans = 0;
  while(a[0] != a[1] || a[1] != a[2]){
    sort(a, a + 3);
    if(a[1] == a[2]){
      a[0] += 2;
      ans++;
    }else{
      ans++;
      a[0]++;
      a[1]++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll A, B, N;
ll ans;

int main()
{
  std::cin >> A >> B >> N;

  ll q = N/B, r;

  if( q > 0 )
    r = B-1;
  else
    r = N%B;

  std::cout << A*r/B << std::endl;

  return 0;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
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; }

bool operater_by_second(pair<int,int> a, pair<int,int> b){
  if(a.second != b.second){
    return a.second < b.second;
  }else{
    return a.first < b.first;
  }
}

int main()
{
  //input
  inputInt(N);
  
  //main
  vector<pair<int,int>> vp(N);
  fN(i,N) cin >> vp[i].first >> vp[i].second;
  
  sort(vp.begin(),vp.end(),operater_by_second);
  
  string ans = "Yes";
  long task = 0;
  for(int i=0; i<N; i++) {
    task += vp[i].first;
    if(task > vp[i].second){
      ans = "No";
    } 
  }
  
  // output
  cout << ans << endl;
  
  //debug
  
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
vector<vector<int>> p;
vector<vector<int>> ans;
int main() {
  cin >> n;
  p.resize(n * n);
  ans.resize(n);
  for (int i = 0; i < n; i++)
    ans[i].resize(n);

  for (int i = 0; i < 2 * n * n - 2 * n; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    p[a].push_back(b);
    p[b].push_back(a);
  }
  int now = -1;
  int m = n * n;
  vector<bool> used(m);

  for (int i = 0; i < n; i++) {
    int nowlim = 2;
    bool ok = false;
    if (i == 0)
      ok = true;
    if (i == n - 1) {
      nowlim--;
    }
    for (int k = 0; k < m; k++) {
      int c = 0;
      bool contains = ok;
      if (used[k])
        continue;
      for (int &v : p[k]) {
        if (!used[v])
          c++;
        else {
          if (!contains) {
            if (v == ans[i - 1][0])
              contains = true;
          }
        }
      }

      if (c == nowlim && contains)
        now = k;
    }

    int lim = 2, ulim = 2;
    if (i == 0)
      ulim--;
    if (i == n - 1)
      lim--;

    for (int j = 0; j < n; j++) {
      ans[i][j] = now;
      used[now] = true;
      if (j == n - 1)
        break;
      if (j == n - 2)
        lim--;
      for (auto &v : p[now]) {
        if (used[v])
          continue;
        int c = 0, d = 0;
        for (auto &w : p[v])
          if (!used[w])
            c++;
          else
            d++;
        if (c == lim && d == ulim) {
          now = v;
          break;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i][0] + 1;
    for (int j = 1; j < n; j++)
      cout << " " << ans[i][j] + 1;
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3512
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using ll = long long;


int main() {
	int n, k;
	cin >> n >> k;
	int X[100005];
	rep(i, n) cin >> X[i];

	int res = 1000000000;
	for (int i=0; i<=n-k; i++) {
		int l_x = X[i];
		int r_x = X[i+k-1];
		int time = min(abs(l_x) + abs(l_x-r_x), abs(r_x) + abs(l_x - r_x));
		res = min(res, time);
	}
	cout << res << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, k, s);

  int ans = 0;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= k; ++y) {
      // x + y + z == s
      int z = s - x - y;
      ans += (0 <= z && z <= k);
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
	int n, m, x, i, j, k;
	int c[12], a[12][12];
	//入力
	scanf("%d %d %d", &n, &m, &x);
	for (i = 0; i < n; i++) {
		scanf("%d", &c[i]);
		for (j = 0; j < m; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	int minC = 1200000, flag1 = 0;
	for (i = 1; i <= pow(2, n) - 1; i++) {
		int sumC = 0, flag2 = 0;
		int sumA[12] = {};
		for (j = 0; j < n; j++) {
			int mask = pow(2, j);
			if (i & mask) {
				sumC += c[j];
				for (k = 0; k < m; k++) {
					sumA[k] += a[j][k];
				}
			}
		}
		for (j = 0; j < m; j++) {
			if (sumA[j] >= x) flag2++;
		}
		if (flag2 == m && minC >= sumC) {
			minC = sumC;
			flag1 = 1;
		}
	}
	if (flag1 == 0) printf("-1");
	else printf("%d", minC);

	return 0;
}

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

using namespace std;

set<int> s;

int main()
{
   int n,a,b;
   cin>>n;
   s.clear();
   int flag=0;
   for(int i=1;i<=n;i++){
    cin>>a;
    if(s.count(a)==1)
        flag=1;
    s.insert(a);
   }
   if(flag)
    cout<<"NO"<<endl;
   else
    cout<<"YES"<<endl;

    return 0;

}


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

#define LL long long

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n, cur = 0; cin >> n; string s; cin >> s;
    int a[n-1], cnt[3]={};
    for(int i = 0; i < n-1; i++) {
        a[i] = abs(s[i+1] - s[i]);
        cnt[a[i]]++;
    }

    int mul = 1, res = 0;
    if(cnt[1] == 0) {
        mul++;
        for(int &x : a) x >>= 1;
    }

    for(int i = 0; i < n-1; i++) if(((n-2) & i) == i) res ^= a[i];
    cout << (res & 1) * mul; 
}

Measured memory_bytes: 8204
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        String s = String.valueOf(n);
        String target = s.substring(s.length()-1);
        String result = "pon";
        switch (target) {
            case "2":
            case "4":
            case "5":
            case "7":
            case "9":
            result = "hon";
                break;
            case "3":
            result = "bon";
                break;
            default:
            result = "pon";
                break;
        }
        
        System.out.println(String.valueOf(result));

    }
}

Measured memory_bytes: 35708
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

vector<vector<int> > g(200001);
vector<int> vis(200001 , 0);

int dfs(int root)
{
	vis[root] = 1;
	int count = 1;
	
	for(int i = 0;i<g[root].size();i++)
	{
		int node = g[root][i];
		
		if(vis[node]) continue;
		
		count+=dfs(node);
	}
	
	return count;
}

int main()
{
	int n,m;
	cin>>n>>m;
	map<pair<int ,int> , bool>	ma;
	
	for(int i = 0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		if(!ma[mp(x,y)])
		{
			g[x].push_back(y);
			g[y].push_back(x);
			ma[mp(x,y)] = true;
			ma[mp(y,x)] = true;	
		}
	}
	
	int maxi = 0;
	
	for(int i = 1;i<=n;i++)
	{
		if(!vis[i])
		{
			int count = dfs(i);
			maxi = max(maxi , count);
		}	
	}
	
	
	cout<<maxi<<endl;
	
	return 0;
}

Measured memory_bytes: 49224
#include "bits/stdc++.h"
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int ans = a + b;
	if (ans < a - b) {
		ans = a - b;
	}
	if (ans < a * b) {
		ans = a * b;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
use strict;

my $s = get_array_from_stdin();

while($s) {
  if ($s eq "") {
    print "YES\n";
    exit;
  }

  if ($s =~ s/^eraser?//) {
    redo;
  }

  if ($s =~ /^dream/) {
    if ($s =~ /^dreamer/) {
      if ($s =~ s/^dreameraser?//) {
      } else {
        $s =~ s/^dreamer//;
      }
      redo;
    } else {
      $s =~ s/^dream//;
      redo;
    }
  }

  print "NO\n";
  exit;
}

### common sub routine ###

sub get_array_from_stdin {
  my $input = <STDIN>;
  chomp($input);
  if (wantarray) {
    return split /\s+/, $input;
  } else {
    return $input;
  }
}


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

using namespace std;

using ll = long long;
int main(int argc, const char *argv[]) {
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;

  // 逃げてる方が前にいる
  if (a > b) {
    ll dist = a - b;
    ll sp = (v - w) * t;
    cout << (sp >= dist ? "YES" : "NO") << '\n';
  } else {
    ll dist = b - a;
    ll sp = (v - w) * t;
    cout << (sp >= dist ? "YES" : "NO") << '\n';
  }

  return 0;
}

Measured memory_bytes: 3620