akhauriyash/Code-Regression huggingface dataset:
/*
      Ashraful Islam Paran
      15-August-2020
      18:32:12
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i, x, n) for (int i = x; i < n; i++)
#define fb(i, x, n) for (int i = n - 1; i >= 0; i--)
#define w(t) int t; cin >> t; while (t--)



typedef unsigned long long ull;
typedef vector<long long> vi;
#define ull unsigned long long
#define msi map<string, long long>
#define mii map<long long, long long>
const int MX = 2e5 + 5;
const int INF = 1e18;
#define pb push_back
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define all(x) x.begin(), x.end()
#define ff first
#define ss second


int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    // online submission
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int a[100001],b,c=0,d=0,e,f,m,n,p,y,z,t,i,j,k;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0;i<n-2;i++)
    {
        for(j=i+1;j<n-1;j++)
        {
            for(k=j+1;k<n;k++)
            {
                if(a[i]+a[j]>a[k] && a[i]!=a[j] && a[j]!=a[k])
                    c++;
            }
        }
    }
    cout<<c<<endl;
    
    
    
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 3816
import math
d, n, b = map(int, input().split())
O = [list(map(int, input().split())) for i in range(n)]

def solve(b):
    l = d / (b+1)
    idx = 0
    vx2 = 10**9
    for i in range(b+1):
        while idx < n and O[idx][0]*(b+1) <= d*(i+1):
            p, h = O[idx]
            p -= l*i
            vx2 = min(vx2, p*(l-p)/(2*h))
            idx += 1
    if vx2 == 0:
        return 10**9
    return l if l <= vx2 * 2 else vx2 + l**2 / (4*vx2)
print(math.sqrt(min(map(solve, range(b+1)))))

Measured memory_bytes: 5684
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc  = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());

    int[] a = new int[n];
    for(int i=0; i<n; i++){
      a[i] = Integer.parseInt(sc.next());
    }

    Arrays.sort(a);
    int ans = a[n-1]-a[0];
    System.out.println(ans);
  }  
}

Measured memory_bytes: 23764
<?php
$count=trim(fgets(STDIN));
$valueArr=trim(fgets(STDIN));
$valueArr=explode(" ",$valueArr);
$costArr=trim(fgets(STDIN));
$costArr=explode(" ",$costArr);
$answer=0;
for($i=0;$i<count($costArr);$i++){
	if($costArr[$i]<$valueArr[$i]){
		$answer+=($valueArr[$i]-$costArr[$i]);    	
    } 
}
echo $answer;

Measured memory_bytes: 3828
In1 = input().split()
h = int(In1[0])
n = int(In1[1])
ith = input().split()[0:n]
count = 0
for x in ith:
    h -= int(x)
    if h <= 0:
        break
if h > 0:
    print("No")
else:
    print("Yes")

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

int main(){

    long long int h;
    cin >> h;

    long long int i = 1;
    long long int ans = 0;

    while(h > 0){
        ans += i;
        h /= 2;
        i *= 2;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    int h[n+1];
    for(int i=1;i<=n;i++)
    {
        cin >> h[i];
    }
    int dp[n+1];
    dp[0] = 0;
    dp[1] = 0;
    int i,j;
    for(i=2;i<=n;i++)
    {
        dp[i] = dp[i-1]+abs(h[i]-h[i-1]);
        //cout << "init dp[i]: " << dp[i] << "\n";
        //cout << "inner: ";
        for(j=i-1;j>=1&&j>=i-k;j--)
        {
            dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]));
            //cout << dp[i] << " ";
        }
        //cout << "\n";
    }
    cout << dp[n] << "\n";
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        // 入力
        int[] abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var a = abc[0];
        var b = abc[1];
        var c = abc[2];


        Array.Sort(abc);
        var tmp1 = abc[0];
        var tmp2 = abc[1];
        var max = abc[2];
        var ans = 0;

        bool flag = true;
        while (flag)
        {
            if (max - tmp1 == 0 && max - tmp2 == 0)
            {
                flag = false;
            }
            else if (max - tmp1 > 2)
            {
                tmp1 += 2;
                ans += 1;
            }
            else if (max - tmp2 > 2)
            {
                tmp2 += 2;
                ans += 1;
            }
            else if (max - tmp1 == 2 && max - tmp2 == 2)
            {
                tmp1 += 2;
                tmp2 += 2;
                ans += 2;
                flag = false;
            }
            else if (max - tmp1 == 1 && max - tmp2 == 1)
            {
                tmp1 += 1;
                tmp2 += 1;
                ans += 1;
                flag = false;
            }
            else if (max - tmp1 == 0 && max - tmp2 == 1)
            {
                ans += 2;
                flag = false;
            }
            else if (max - tmp1 == 1 && max - tmp2 == 0)
            {
                ans += 2;
                flag = false;
            }
            else if (max - tmp1 == 0 && max - tmp2 == 2)
            {
                ans += 1;
                flag = false;
            }
            else if (max - tmp1 == 2 && max - tmp2 == 0)
            {
                ans += 1;
                flag = false;
            }
            else
            {
                ans += 3;
                flag = false;
            }
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		int m, n_min, n_max; scanf("%d %d %d", &m, &n_min, &n_max);
		if (m == 0) break;
		vector<int> p(m); for (int i = 0; i < m; i++) scanf("%d", &p[i]);
		sort(p.rbegin(), p.rend());
		int g = -1;
		int res = 0;
		for (int i = n_max - 1; i >= n_min - 1; i--) {
			if (chmax(g, p[i] - p[i + 1])) {
				res = i + 1;
			}
		}
		printf("%d\n", res);
	}
	return 0;

}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  int A[N+1]; rep(i,N+1) cin >> A[i];
  int B[N]; rep(i,N) cin >> B[i];
  ll result = 0;
  rep(i,N) {
    result += min(A[i]+A[i+1], B[i]);
    if (A[i]>=B[i]) continue;
    A[i+1]= max(0, A[i]+A[i+1]-B[i]);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1024
n, k, q = map(int, input().split())
a = {}
for i in range(q):
    tmp = int(input())
    if tmp in a.keys():
        a[tmp] += 1
    else:
        a[tmp] = 1

for i in range(1, n+1):
    if not i in a.keys():
        a[i] = 0
    if k - (q - a[i]) <= 0:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 15856
#include <bits/stdc++.h>
#include <climits>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define ll long long int
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define loop(i, L, R) for (int i = L; i < R; ++i)
#define looprev(i, L, R) for (int i = L; i > R; --i)
#define MAX(x, y) (x > y ? x : y)
#define MIN(x, y) (x < y ? x : y)
#define wh(t) while (t--)
#define pii pair<int, int>
#define ppi pair<int, pii>
#define pll pair<ll, ll>
#define ppl pair<ll, pll>
#define vii vector<int>
#define vvi vector<vii>
#define vl vector<ll>
#define vvl vector<vl>
#define maxHi priority_queue<int>
#define maxHl priority_queue<ll>
#define minHi priority_queue < int, vector<int>, greater<int>>
#define minHl priority_queue < ll, vector<ll>, greater<ll>>
#define mod 1000000007
#define inf 1000000000000000001
#define PI 3.1415926535897932384626
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define mp(x, y) make_pair(x, y)
#define mem(a, val) memset(a, val, sizeof(a))
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false)
#define endl "\n"
using namespace std;

/*  AH SH*T,  HERE WE GO AGAIN.  */


void solve()
{
    ll i, j, n, m;

    sl(n);

    sl(m);

    std::vector<ll> v(n);

    loop(i, 0, n) sl(v[i]);

    sort(all(v));


    ll sum = 0;


    loop(i, 0, m)
    {


        sum += v[i];

    }

    cout << sum << endl;

}


int32_t main()
{

    IOS;
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int T = 1;



    wh(T)
    {

        solve();

    }
}

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

using namespace std;

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

	vector< pair<int, int> > r(N), b(N);
	for (int i = 0; i < N; i++)
	{
		cin >> r[i].first >> r[i].second;
	}
	for (int i = 0; i < N; i++)
	{
		cin >> b[i].first >> b[i].second;
	}
	sort(r.begin(), r.end(), [](pair<int, int> x, pair<int, int> y) {return x.first > y.first; });
	sort(b.begin(), b.end(), [](pair<int, int> x, pair<int, int> y) {return x.second < y.second; });

	int ans = 0;
	for (size_t i = 0; i < N; i++)
	{
		pair<int, int> sb = b[i];
		for (size_t j = 0; j < r.size(); j++)
		{
			pair<int, int> sr = r[j];
			if (sr.first < sb.first&&sr.second < sb.second)
			{
				ans++;
				r.erase(r.begin() + j);
				break;
			}
		}
	}

	std::cout << ans << endl;
	return 0;
}

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

int main(void) {

	while (1) {
		bool flag = true;
		int h, w;
		int now, maxi = 1000000;
		int ho, wo;

		cin >> h >> w;
		if (h == 0) {
			break;
		}
		now = h*h + w*w;

		for (int i = 1; i <= 150; i++) {
			for (int t =i+1; t <= 150; t++) {
				if (i*i + t*t > now&&i*i + t*t < maxi) {
					ho = i;
					wo = t;
					maxi = i*i + t*t;
					break;
				}
				else if (i*i + t*t == now&&i>h) {
					ho = i;
					wo = t;
					flag = false;
					break;
				}
			}
			if (!flag) {
				break;
			}
		}
		cout << ho << " " << wo << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i, sz(v)) { if (i) os << " "; os << v[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a - mod; }

void solve();

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

    int T;
    // cin >> T;
    T = 1;

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


string t;
int d;
int dfs(int st, int ed, string s, bool less) {
  if (sz(s) == d) {
    return 1;
  }
  int res = 0;
  int l = 0;
  int r = (less ? 10 : t[sz(s)] - '0' + 1);

  if (sz(s) == 0) l = st, r = st + 1;
  if (sz(s) == d - 1) l = ed, r = ed + 1;

  rep3(i, l, r) {
    if (!less && i > t[sz(s)] - '0') continue; // st, ed, 10通り全部試してる
    add(res, dfs(st, ed, s + (char)(i + '0'), less | i < t[sz(s)] - '0')); // debuged, t[sz(s) - 1] to t[sz(s)]
  }
  return res;
}

void solve() {
  int n;
  cin >> n;
  if (n < 10) { cout << n << endl; return; }

  t = to_string(n);
  d = sz(t);

  map<pii, int> mp;

  rep3(i, 1, 10) rep3(j, 1, 10) {
    int sum = 0;
    if (i == j) sum++; // 1桁の数
    // nより1桁以上少ない数はすべて
    // 3桁なら2桁の1つ
    rep(k, d - 2) {
      add(sum, modpow(10, k));
    }
    // nと同じ桁の数
    // 桁dpっぽいdfsやる
    add(sum, dfs(i, j, "", 0));
    mp[pii(i, j)] = sum;
  }

  int ans = 0;
  rep3(i, 1, 10) rep3(j, 1, 10) {
    add(ans, mp[pii(i, j)] * mp[pii(j, i)] % mod);
  }
  cout << ans << endl;
}


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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans = 2;
    for (int i = 1; 2*i < n; i++) {
        bool check = true;
        for (int j = 0; j < i; j++){
            if (s[j] != s[i+j]) {
                check = false;
                break;
            }
        }
        if (check) ans = 2 * i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int x[n][m];
    int y[m];
    for(int i=0;i<n;i++){
        for (int j=0; j<m; j++) {
            cin >> x[i][j];
        }
    }
    for(int k=0;k<m;k++){
        cin >> y[k];
    }
    
    for(int s=0; s<n; s++){
        int sum =0;
        for (int t=0; t<m; t++) {
            sum += x[s][t] * y[t];
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define FPEN2 freopen("out.txt", "w", stdout);
#else
#define FPEN
#define FPEN2
#endif
const int maxn = 200009;
const int MOD = 1e9 + 7;
int N;
int ans = 0;
int black[555][555], dist[555][555];
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
void dijk(int x, int y) {
  ans += dist[x][y];
  black[x][y] = 0;
  priority_queue<pair<int, int>> que;
  que.emplace(-dist[x][y], x * N + y);
  while (que.size()) {
    x = que.top().second / N, y = que.top().second % N;
    int Dist = -que.top().first + black[x][y];
    que.pop();
    for (int j = 0; j < 4; ++j) {
      int nx = x + dx[j], ny = y + dy[j];
      if (nx >= 0 && nx < N && ny >= 0 && ny < N && dist[nx][ny] > Dist) {
        dist[nx][ny] = Dist;
        que.emplace(-Dist, nx * N + ny);
      }
    }
  }
}
int main() {
  FPEN FPEN2;
  ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  cin >> N;
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < N; ++j) black[i][j] = 1, dist[i][j] = min(min(N - 1 - i, N - 1 - j), min(i, j));
  for (int i = 0; i < N * N; ++i) {
    int t;
    cin >> t;
    t--;
    dijk(t / N, t % N);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 5884
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <stack>
#include <utility>
#include <array>
#include <random>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;
typedef long long ll;
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template < typename T >
ostream& operator<<(ostream& os, vector< T >& v) {
    os << "{";
    for (int i = 0; i < (int)v.size(); i++) {
        os << v[i] << (i < v.size() - 1 ? ", " : "");
    }
    os << "}";
    return os;
}
// pair出力
template < typename T, typename U >
ostream& operator<<(ostream& os, pair< T, U >& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template < typename T, typename U >
ostream& operator<<(ostream& os, map< T, U >& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template < typename T >
ostream& operator<<(ostream& os, set< T >& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#pragma endregion

/////////////////////////////////////////

int main() {
    ll a,b,v,w;cin >> a >> v >> b >> w;
    ll t;cin >> t;
    if (a < b) {
        if (a + t * v >= b + t * w) {
            puts("YES");
        }
        else {
            puts("NO");
        }
    }
    else {
        if (a - t * v <= b - t * w) {
            puts("YES");
        }
        else {
            puts("NO");
        }
    }
    return 0;
}

/////////////////////////////////////////

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

using namespace std;
#define ll long long int
#define mod 998244353

unsigned long long fac[200000 + 1];
long long power(unsigned long long x,
                int y, int p)
{
    unsigned long long res = 1; // Initialize result

    x = x % p; // Update x if it is more than or
    // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x) % p;

        // y must be even now
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
long long modInverse(unsigned long long n, int p)
{
    return power(n, p - 2, p);
}

long long ncr(unsigned long long n,
              int r, int p)
{
    if (r == 0)
        return 1;

    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
}

int main()
{
    ll t;
    t = 1;
    //  cin t;
    while (t--)
    {
        ll n, m, k;
        cin >> n >> m >> k;
        ll ans = m;
        ll sum = 0;
        fac[0] = 1;
        for (int i = 1; i <= n; i++)
            fac[i] = (fac[i - 1] * i) % mod;
        for (int i = 0; i <= k; i++)
        {
            sum = sum % mod + (ncr(n - 1, i, mod) % mod * power(m - 1, n - i - 1, mod) % mod) % mod;
            sum %= mod;
        }
        ans = (ans % mod * sum % mod) % mod;
        cout << ans << endl;
    }
}


Measured memory_bytes: 5140
#include<stdio.h>
int main()
{
	int e, y;
	scanf("%d %d", &e, &y);
	if (e == 0) {
		if (1868 <= y&&y <= 1911) {
			printf("M%d\n", y - 1867);
		}
		if (1912 <= y&&y <= 1925) {
			printf("T%d\n", y - 1911);
		}
		if (1926 <= y&&y <= 1988) {
			printf("S%d\n", y - 1925);
		}
		if (1989 <= y&&y <= 2016) {
			printf("H%d\n", y - 1988);
		}
	}
	if (e == 1) {
		printf("%d\n", y + 1867);
	}
	if (e == 2) {
		printf("%d\n", y + 1911);
	}
	if (e == 3) {
		printf("%d\n", y + 1925);
	}
	if (e == 4) {
		printf("%d\n", y + 1988);
	}
	return 0;
}

Measured memory_bytes: 2760
import sys
readline = sys.stdin.buffer.readline

def S(k):
    return k * (k + 1) // 2

N = int(readline())
M = int((N+1)**.5)
ans = 0
# 蜑榊濠
for i in range(1, N // (M+1) + 1):
    ans += i * S(N // i)
# 蠕悟濠
for k in range(1, M+1):
    ans += S(k) * (S(N//k) - S(N//(k+1)))
print(ans)


Measured memory_bytes: 9448
#include<cstdio>
#include<string>
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;

int main(){
  int N,Q,li,ri;
  string S;
  int count=0;
  vector<int> score;
  
  scanf("%d %d",&N,&Q);
  cin >> S;
//  printf("%s\n",S.c_str());
  score.push_back(0);
  for(int i=1;i<N;i++){
    if(S[i-1]=='A' && S[i]=='C'){
      count++;
    }
    score.push_back(count);
  }
/*  for(auto num:score)
    printf("%d",num);
  printf("\n");
*/
  for(int i=0;i<Q;i++){
    scanf("%d %d",&li,&ri);
    printf("%d\n",score[ri-1]-score[li-1]);
  }
  return 0;
}


Measured memory_bytes: 1528
#include <iostream>
#include <queue>
#define ll long long
using namespace std;

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

    int count = 1;
    queue<ll> window;
    // 正なら単調非増加、負なら単調非減少
    ll diff = 0;
    for (ll i = 0; i < N; i++) {
        ll Ai;
        cin >> Ai;
        window.push(Ai);
        if (window.size() >= 3) {
            ll first = window.front();
            window.pop();
            ll second = window.front();
            if (second - first != 0) {
                diff = second - first;
            }
            ll third = window.back();
            if (diff > 0 && third - second < 0) {
                count++;
                diff = 0;
                window.pop();
            } else if (diff < 0 && third - second > 0) {
                count++;
                diff = 0;
                window.pop();
            }
        }
    }

    cout << count;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Boolean flag = true;
        String[] num = in.nextLine().split("");
        for(int i = 0; i <= 2; i++){
            if(num[i].equals("7")){
                System.out.print("Yes");
                flag = false;
                break;
            }
        }
        if(flag){
            System.out.print("No");
        }
    }

}

Measured memory_bytes: 35560
//package atcoder;
 
import java.util.*;
import java.math.BigDecimal;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Set<String> set = new HashSet<>();
		for(int i=0;i<N;i++) {
			set.add(sc.next());
		}
		if(set.size() == N) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 76160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
   int a,b,res=0;
   cin>>a>>b;
   int cnt=1;
   if(b==1)return cout<<0<<endl,0;
   for(int i=1;;i++)
   {
       cnt= cnt+a;
       cnt-=1;
       res++;
       if(cnt>=b)break;
   }
   cout<<res<<endl;

}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
    int n = scan!int, m = scan!int;

    int[] us = [];
    foreach(int x; 0 .. (1<<(max(n, m))) - 1){
        int t = x + 0;
        int cnt;
        while(t % 2) cnt += 1, t /= 2;
        us ~= cnt;
    }
    log("us:", us);

    foreach(int x; 0 .. (1<<n) - 1){
        foreach(int y; 0 .. (1<<m) - 1){
            if(us[x] == us[y]) write("1");
            else write("0");
        }
        writeln("");
    }
}



Measured memory_bytes: 1276
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
#define maxn 2505
using namespace std;
typedef long long  LL;
int main()
{
    string s;
    string t;
    cin>>s>>t;
    int flag=0;
    if(s.size()!=t.size())
        cout<<"No"<<endl;
    else if(s==t)
    {

            cout<<"Yes"<<endl;
    }
    else
    {
        for(int i=0; i<s.size(); i++)
        {
            int temp=s[s.size()-1];
            for(int j=s.size()-1;j>=0;j--)
            {
                s[j]=s[j-1];
            }
            s[0]=temp;
            //cout<<s<<endl;
            if(s==t)
            {
                flag=1;
                break;
            }
        }
        if(!flag)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;

    }

    return 0;
}


Measured memory_bytes: 256
n, q = map(int,input().split())
s = input()
l = [[int(i) for i in input().split()] for i in range(q)]
c = [0 for i in range(n)]
cc = 0
f = False
for i in range(n):
    if f:
        f = False
        if s[i] == "C":
            cc += 1
    if s[i] == "A":
        f = True
    c[i] = cc
for i in range(q):
    print(c[l[i][1]-1]-c[l[i][0]-1])

Measured memory_bytes: 24400
// 見せてやるぜ、奇跡ってやつをよぉ……
#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;

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

    ll n, m; cin >> n >> m;
    vvll edges(n);
    REP(i, m) {
        ll s, t; cin >> s >> t;
        edges[s-1].push_back(t-1);
    }

    double ans = (double)HIGHINF;
    REP(i, n) {
        V<double> dp(n, 0); dp[n-1]=0;
        double sump, maxu;
        for (ll j=n-2; j>=0; j--) {
            sump=0, maxu=0;
            for (ll u: edges[j]) {
                sump += dp[u];
                chmax(maxu, dp[u]);
            }
            if (i==j && edges[j].size()>1) dp[j] = (sump-maxu)/(edges[j].size()-1) + 1;
            else dp[j] = sump / edges[j].size() + 1;
        }
        chmin(ans, dp[0]);
    }
    cout << fixed << setprecision(12) << ans << '\n';

    return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    public static boolean debug = true;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();

        char[] sa = s.toCharArray();
        char[] ta = t.toCharArray();

        int count =0;
        for(int i=0;i<3;i++){
            if(sa[i] == ta[i]){
                count++;
            }
        }
        System.out.println(count);




    }
    public static void d(String message){
        if(debug){
            System.out.println(message);
        }
    }
}

Measured memory_bytes: 21716
array = input().split(' ')
W = int(array[0])
H = int(array[1])
x = int(array[2])
y = int(array[3])
r = int(array[4])

if x+r<=W and y+r<=H and x-r>=0 and y-r>=0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5596
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 1e6 + 6, mod = (int) 0;
int ss[N], ts[N];
int main() {
	ios_base::sync_with_stdio(0);
	string s, t;
	cin >> s >> t;
	for (int j = 0; j < (int) s.size(); ++j) {
		ss[j + 1] = ss[j] + (s[j] == 'A') + 1;
	}
	for (int j = 0; j < (int) t.size(); ++j) {
		ts[j + 1] = ts[j] + (t[j] == 'A') + 1;
	}
	int q;
	cin >> q;
	while (q--) {
		int sl, sr, tl, tr;
		cin >> sl >> sr >> tl >> tr;
		--sl, --tl;
		cout << ((((ss[sr] - ss[sl]) % 3) == ((ts[tr] - ts[tl]) % 3)) ? "YES\n": "NO\n");
	}

}



Measured memory_bytes: 5456
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define abu ios_base::sync_with_stdio(0)
#define said cin.tie(0)
using namespace std;

void yes(){
    cout<<"YES"<<endl;
}

void no(){
    cout<<"NO"<<endl;
}

int main(){
    abu;
    said;
    //cin>>t;
    string s;
    cin>>s;
    int q;
    cin>>q;
    int t;
    int f;
    char c;
    vector<char> h;
    vector<char> e;
    bool pw=true;
    for(int i=0;i<q;i++){
        cin>>t;
        if(t==1){
            pw=!pw;
        }else{
            
            cin>>f>>c;
            if((f==1 && pw) || (f==2 && !pw)){
                h.pb(c);
            }else{
                e.pb(c);
            }
        }
    }
    if(pw){
        for(int i=h.size()-1;i>=0;i--){
            cout<<h[i];
        }
        cout<<s;
        for(int i=0;i<e.size();i++){
            cout<<e[i];
        }
        cout<<endl;
    }else{
        for(int i=e.size()-1;i>=0;i--){
            cout<<e[i];
        }
        for(int i=s.size()-1;i>=0;i--){
            cout<<s[i];
        }
        for(int i=0;i<h.size();i++){
            cout<<h[i];
        }
        cout<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 976
/*  CREATED BY
    STREAM_CIPHER
    29-aug-2020
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define debug1(a) cout<<#a<<"="<<(a)<<"\n"
#define debug2(a,b) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<"\n"
#define debug3(a,b,c) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<","<<#c<<"="<<(c)<<"\n"
#define fix_precision(n) cout << fixed << setprecision(n)
#define all(a) a.begin(),a.end()
const double pi=acos(-1.0);
int inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int mx=5*1000000;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    #endif
        int n,x,t;
        cin>>n>>x>>t;
        int ans=(int)((ceil((double)n/(double)x)))*t;
        cout<<ans<<endl;
}

Measured memory_bytes: 3620
input_str = str(input()).split()
a, b, k = int(input_str[0]), int(input_str[1]), int(input_str[2])

# 初期化
self = a
partner = b

for i in range(k):
    # 自分が持っているクッキーの枚数が奇数なら、自分が持っているクッキーを
    # 1枚食べ、偶数なら何もしない。
    if self % 2 == 1:
        self += -1

    # その後、自分が持っているクッキーの半分を相手に渡す。
    partner += int(self / 2)
    self = int(self / 2)

    self, partner = partner, self
    i -= 1

if i % 2 == 1:
    a = partner
    b = self
else:
    b = partner
    a = self

print(a, b)


Measured memory_bytes: 3064
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input()) 
print(a[k-1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

int main() {
	int n;
	cin >> n;
	vector<int> num(15);
	vector<vector<P>> data(15, vector<P>(1));
	for(int i=0; i<n; i++){
		cin >> num.at(i);
		if(num.at(i)>0) cin >> data.at(i).at(0).first >> data.at(i).at(0).second;
		for(int j=1; j<num.at(i); j++){
			int x, y;
			cin >> x >> y;
			data.at(i).push_back(P(x, y));
		}
	}
	int max=0;
	for(int tmp=0; tmp<(1<<15); tmp++){
		bitset<15> s(tmp);
		bool clear = true;
		int num=0;
		for(int i=0; i<n; i++){
			if(s.test(i)){
				num++;
				for(int j=0; j<data.at(i).size(); j++){
					if(s[data.at(i).at(j).first-1] != data.at(i).at(j).second){
						clear = false;
						break;
					}
				}
			}
		}
		if(clear && num > max) max = num;
	}

	cout << max << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import bisect

MAX_VAL = 2e+10


def make(src, dst):
  points = [v[0] for v in dst]

  for i in range(len(src)):
    p = src[i][0]
    j = bisect.bisect(points, p)

    if j == 0:
      v = dst[j][0] - p
    elif j == len(dst):
      v = p - dst[j - 1][0]
    else:
      v = min(dst[j][0] - p, p - dst[j - 1][0])

    src[i] = (p, v)


def main():
  a, b, s = map(int, input().split())
  shrines = [(int(input()),) for _ in range(a)]
  temples = [(int(input()),) for _ in range(b)]
  starts = [int(input()) for _ in range(s)]

  make(shrines, temples)
  make(temples, shrines)

  s_index = 0
  t_index = 0
  places = []

  while len(places) < len(shrines) + len(temples):
    if s_index == len(shrines):
      places.append(temples[t_index])
      t_index += 1
    elif t_index == len(temples):
      places.append(shrines[s_index])
      s_index += 1
    elif temples[t_index][0] < shrines[s_index][0]:
      places.append(temples[t_index])
      t_index += 1
    else:
      places.append(shrines[s_index])
      s_index += 1

  points = [p for p, _ in places]

  for start in starts:
    idx = bisect.bisect(points, start)
    value = None

    if idx == 0:
      value = points[idx] - start + places[idx][1]
    elif idx == len(points):
      value = start - points[idx - 1] + places[idx - 1][1]
    else:
      value = min(points[idx] - start + places[idx][1], start - points[idx - 1] + places[idx - 1][1])

    print(value, flush=True)


if __name__ == '__main__':
  main()



Measured memory_bytes: 39048
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	ll x,x2,x1,x3,h=0;
	cin>>x;
	x1=x/500;
	h=h+(2*x1*500);
	x2=x%500;
	x3=x2/5;
	h=h+(x3*5);
	cout<<h;
	return 0;
}

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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    string s;
    map<int,int> m;
    cin >> s;
    rep(i,s.size()){
        m[s[i]]++; 
    }
    if(m['N']>0){
        if(m['S']==0){
            cout << "No"<<endl;
            return 0;
        }
    }
    if(m['S'] > 0) {
        if(m['N'] == 0) {
            cout << "No" << endl;
            return 0;
        }
    }

    if(m['E'] > 0) {
        if(m['W'] == 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    if(m['W'] > 0) {
        if(m['E'] == 0) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes"<<endl;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll modpow(ll a, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main()
{
    string s;
    cin >> s;
    ll n = s.size();
    ll ans = 0;
    ll now = 1;
    rep(i, n)
    {
        if (s[i] == '1')
        {
            ans += now * modpow(3, n - 1 - i, MOD);
            ans %= MOD;
            now = now * 2 % MOD;
        }
    }
    ans = (ans + now) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    ll n,k; cin>>n>>k;
    vector<ll> x(n);
    rep(i,n) cin>>x[i];
    ll res=0;
    rep(i,n){
        res+=min(x[i], k-x[i]);
    }
    cout<<res*2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int n, d;
    cin >> n >> d;
    d /= 1'000;

    irep(i, min(n, d / 10))
    {
        irep(j, min(n - i, (d - 10 * i) / 5))
        {
            int k = n - i - j;
            if (10 * i + 5 * j + k == d) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
 int n,m,i,j,b,A[100][100]={},Ab[100]={};
 scanf("%d %d", &n, &m);
 for(i=0; i<n; i++){
  for(j=0; j<m; j++){
   scanf(" %d", &A[i][j]);
  }
 }
 for(i=0; i<m; i++){
  scanf(" %d",&b);
  for(j=0; j<n; j++){
   Ab[j]= +Ab[j] + A[j][i]*b;
  }
 } 
 for(i=0; i<n; i++){
  printf("%d\n", Ab[i]);
 }
 
 return 0;
}
    
   
  

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

int main()
{
    long n, m, a, d, i;
    d = 0;
    scanf("%ld %ld", &n, &m);
    for(i = 0; i < m; i++) {
        scanf("%ld", &a);
        d += a;
    }
    n = n - d;
    if(0 <= n) printf("%ld", n);
    else printf("-1");
    return 0;
}

Measured memory_bytes: 1728
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define str string
#define ld long double
#define vec vector
#define vll vec<ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define kai "\n"
#define yuque priority_queue
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mie min_element
#define mae max_element
#define tos to_string
#define sep setprecision
#define lob lower_bound
#define upb upper_bound
#define nep next_permutation
#define MOD 1000000007ll
#define MIN (1e-10)
#define equal(a,b) (abs((a)-(b))<MIN)
#define v2 ten
#define chokusen senbun
#define tenten senbun
#define takaku vec<ten>
#define kosu(b,e,v) (upb(b,e,v)-lob(b,e,v))
#define aru(b,e,v) (find(b,e,v)!=e)
using namespace std;
void solve();
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed;
	solve();
}
struct pea{
	ll f,s;
	bool operator<(const pea &p)const{
		return f!=p.f?f<p.f:s<p.s;
	};
};
struct tri{
	ll f,s,t;
	bool operator<(const tri &p)const{
		if(f!=p.f)return f<p.f;
		if(s!=p.s)return s<p.s;
		return t<p.t;
	};
};
class ten{
public:
	ld x,y;
	ten operator+(ten p){return{x+p.x,y+p.y};}
	ten operator-(ten p){return{x-p.x,y-p.y};}
	ten operator*(ld k){return{k*x,k*y};}
	ten operator/(ld k){return{x/k,y/k};}
	ld abs(){return sqrt(abs2());}
	ld abs2(){return x*x+y*y;};
	bool operator<(const ten &p)const{return x!=p.x?x<p.x:y<p.y;};
	bool operator==(const ten &p)const{return (-MIN<x-p.x)&&(x-p.x<MIN)&&(-MIN<y-p.y)&&(y-p.y<MIN);};
	ld naiseki(v2 b){return x*b.x+y*b.y;}
	ld gaiseki(v2 b){return x*b.y-y*b.x;}
};
struct senbun{ten p1,p2;};
struct en{ten o;ld r;};

bool zt01(vll a,ll m){
	ll n=a.size(),j=1,k=0,l=0;
	vll dp(1<<n);dp[0]=0;
	rep(i,1,1<<n){
		k++;
		dp[i]=dp[i-j]+a[l];
		if(k==j){j*=2;k=0;l++;}
		if(dp[i]==m)return true;
	}
	return false;
}

void solve(){
	ll n,q,m;cin>>n;
	vll a(n);
	rep(i,0,n)cin>>a[i];
	cin>>q;
	rep(i,0,q){
		cin>>m;
		cout<<(zt01(a,m)?"yes":"no")<<kai;
	}
}


Measured memory_bytes: 11324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll x(n);
    rep(i, n){
        cin >> x[i];
    }
    vll y(x);
    sort(ALL(y));
    ll up = y[n/2];
    ll down = y[n/2-1];
    rep(i, n){
        if(x[i] >= up){
            cout << down << endl;
        }else{
            cout << up << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main()
{         
	string a,b;
	cin>>a>>b;
	reverse(b.begin(),b.end());
	if(b==a) cout<<"YES";
	else cout<<"NO";
	return 0; 
}

Measured memory_bytes: 256
# モンスターの数 必殺技の回数
# モンスターの体力

ATTACK_POINT = 1 # 攻撃力

monsters_count, waza_attempt = gets.split(" ").map(&:to_i)
monsters_powers = gets.split(" ").map(&:to_i).sort.reverse
monsters_powers.shift(waza_attempt)

if monsters_powers.count == 0
  puts 0
else
  puts monsters_powers.inject(:+)
end

Measured memory_bytes: 19344
n,m=map(int,input().split(" "))

l = list(map(int,input().split()))

s = sum(l)

nl=sorted(l,reverse=True)



r = s/(4*m)

count=0

for i in range(m) :
    if nl[i]>=r:
        pass
    else :
        count += 1

if count > 0:
    print("No")
else :
    print("Yes")

Measured memory_bytes: 9192
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main()
{
unsigned long long N;
char animalans[200000];
char animal[4][200002];
int A=0;
unsigned long long i;
unsigned long long j;

scanf("%llu",&N);
scanf("%s",animalans);
if(animalans[0]=='x')
{
 animal[0][N+1]='S';
 animal[0][0]='W';
 animal[0][1]='S';

 animal[1][N+1]='W';
 animal[1][0]='W';
 animal[1][1]='W';

 animal[2][N+1]='W';
 animal[2][0]='S';
 animal[2][1]='S';

 animal[3][N+1]='S';
 animal[3][0]='S';
 animal[3][1]='W';
}else{
 animal[0][N+1]='W';
 animal[0][0]='W';
 animal[0][1]='S';

 animal[1][N+1]='S';
 animal[1][0]='W';
 animal[1][1]='W';

 animal[2][N+1]='S';
 animal[2][0]='S';
 animal[2][1]='S';

 animal[3][N+1]='W';
 animal[3][0]='S';
 animal[3][1]='W';
}
for( i=1; i<N; i++)
{
 if(animalans[i]=='x')
 {
  for( j=0; j<4; j++)
  {
    if((animal[j][i-1]=='W')&(animal[j][i]=='S')) animal[j][i+1]='S';
    if((animal[j][i-1]=='W')&(animal[j][i]=='W')) animal[j][i+1]='W';
    if((animal[j][i-1]=='S')&(animal[j][i]=='S')) animal[j][i+1]='W';
    if((animal[j][i-1]=='S')&(animal[j][i]=='W')) animal[j][i+1]='S';
   }
 }else{
  for( j=0; j<4; j++)
  {
    if((animal[j][i-1]=='W')&(animal[j][i]=='S')) animal[j][i+1]='W';
    if((animal[j][i-1]=='W')&(animal[j][i]=='W')) animal[j][i+1]='S';
    if((animal[j][i-1]=='S')&(animal[j][i]=='S')) animal[j][i+1]='S';
    if((animal[j][i-1]=='S')&(animal[j][i]=='W')) animal[j][i+1]='W';
  }
 }
}
A=-1;
for(j=0; j<4; j++)
{
 if((animal[j][N+1]==animal[j][N-1])&(animal[j][N]==animal[j][0]))
 { 
        if((animalans[0]=='o')&(animal[j][0]=='S')&(animal[j][N-1]==animal[j][1])) A=j;
        if((animalans[0]=='o')&(animal[j][0]=='W')&(animal[j][N-1]!=animal[j][1])) A=j;
        if((animalans[0]=='x')&(animal[j][0]=='S')&(animal[j][N-1]!=animal[j][1])) A=j;
        if((animalans[0]=='x')&(animal[j][0]=='W')&(animal[j][N-1]==animal[j][1])) A=j;
 }
}

if(A==-1)
{
 printf("%d",A);
}else{
 for(i=0; i<N; i++) printf("%c",animal[A][i]);
}

return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main()
{
     int a,b,c,d,ans=0;
     cin>>a>>b>>c;
     for(int x=1;x<=a;x++)
     {
     	cin>>d;
     	if(d<b||d>=c)
     	ans++;
	 }
	 cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#define INF INT_MAX

using namespace std;

int main(){
    int n;
    cin >> n;
    int m[n+1][n+1], p[n+1];
    for(int i = 1; i <= n; i++) cin >> p[i-1] >> p[i];

    for(int i = 1; i <= n; i++) m[i][i] = 0;
    for(int l = 2; l <= n; l++){
        for(int i = 1; i <= n-l+1; i++){
            int j = i + l - 1;
            m[i][j] = INF;
            for(int k = i; k < j; k++){
                int q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
                m[i][j] = min(m[i][j], q);
            }
        }
    }

    cout << m[1][n] << endl;

    return 0;
}


Measured memory_bytes: 3100
s = input()
sa = s.replace('LR','L,R')
sb = sa.split(',')
ans = ''
for hoge in sb:
  poge = len(hoge)
  g = hoge.find('RL')
  if poge%2 == 0:
    r = poge//2
    l = poge//2
  else:
    if g%2 == 1:
      r = poge//2
      l = r + 1
    else:
      l = poge//2
      r = l + 1
  an = '0 '*(g)+str(r)+' '+str(l)+' 0'*(poge-g-2)+ ' '
  ans += an
print(ans)

Measured memory_bytes: 7028