akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <bitset>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define INF 1100000000
#define LLINF 1100000000000000000
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair

using namespace std;
typedef long long ll;

string S;

ll rec(int idx, ll num, ll sum)
{
  if (idx == S.size()) return num + sum;

  return rec(idx + 1, 10*num + (S[idx] - '0'), sum)
    + rec(idx + 1, (S[idx] - '0'), sum + num);
}

int main()
{
  cin >> S;
  cout << rec(1, S[0] - '0', 0) << endl;
  return 0;
}

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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define all(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COUT(x) cout << x << endl
//#define int long long

template<typename T> constexpr auto square(T x) { return (x) * (x); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const int MOD = 1000000007;
const int INF = INT_MAX;

signed main()
{
	int A,B;
	cin >> A >> B;

	int sum = A + B;

	if (sum % 2 == 1) {
		COUT("IMPOSSIBLE");
	}
	else {
		int K = sum / 2;
		COUT(K);
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
    
        int t[] = new int[10];
        t[0] =  scanner.nextInt();
        t[1] =  scanner.nextInt();
        t[2] =  scanner.nextInt();
        t[3] =  scanner.nextInt();
        t[4] =  scanner.nextInt();
        t[5] =  scanner.nextInt();
        t[6] =  scanner.nextInt();
        t[7] =  scanner.nextInt();
        t[8] =  scanner.nextInt();
        t[9] =  scanner.nextInt();
        
        
        for(int i=0; i<9; i++){
             for(int j=0; j<9-i; j++){
                 if( t[j] < t[j+1]) {
                    int temp = t[j];
                    t[j] = t[j+1];
                    t[j+1] = temp;   
                 }
             }
        }
        for(int i=0; i<3; i++){
            System.out.println(t[i]);
    }
    
        

    }
}




Measured memory_bytes: 26172
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N;
  cin >> N;

  cout << (N-1) * N / 2 << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int main(void){
    double x1,x2,y1,y2;
    
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    
    printf("%lf\n", sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));

    return 0;
}


Measured memory_bytes: 2100
//THINK FIRST CODE NEXT!!!!!!!!!!!!!!!!!
//It does not matter how slowly you go as long as you do not stop. - Confucius
#include<bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << ':' << x << endl;
#define loop3(i, k, n) for(i=k; i<n; i++)
#define ll  long long 
#define loop(i,n) for(int i=0;i<n;i++)
#define loop2(i,n) for(int i = 1;i<=n;i+=1)
#define pb push_back
#define mp make_pair
#define v1d vector<ll>
#define v2d vector<vector<ll>>
#define Sort(v) sort(v.begin(),v.end())
const int INF = 1e9 +5 ;
#define ll        long long
// #define mp      make_pair
#define eb         emplace_back
#define pb         push_back
#define ss         second
#define ff         first
#define IOS        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod        998244353
#define MOD        (1000*1000*1000+7)
#define MN         LLONG_MIN
#define MX         LLONG_MAX
#define v1d        vector<ll>
#define v2d        vector<vector<ll>>
#define vip        vector<pair<ll,ll> >
#define v1s        vector<string>
#define pa         pair<ll,ll>
#define mxpq(T)    priority_queue <T>
#define mnpq(T)    priority_queue<T,vector<T>,greater<T>>
#define print(v)   for(auto i:v)cout<<i<<" ";cout<<endl;
#define p2d(v)     for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)     for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)     for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define input(b,n) for(int i=0;i<n;i++)cin>>b[i];
#define Sort(v)    sort(v.begin(),v.end())
#define RSort(v)   sort(v.rbegin(),v.rend())
#define all(v)     v.begin(),v.end()
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//string s = bitset<64>(a).to_string();
void solve()
{
    string s,t;
    cin>>s>>t;
    ll cnt = 0;
    for(int i = 0; i<s.size() ;i++)
    {
        if(s[i] != t[i])
        {
            cnt++;
        }
    }
    cout<<cnt<<"\n";
}

int main()
{
    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
return 0;
}

Measured memory_bytes: 3852
#include <iostream>
using ll = long long;
using namespace std;

int main() {
    int n,m,l;
    cin >> n >> m >> l;
    if(max(n,max(m,l)) == l) cout << l-max(n,m)+abs(m-n);
    else if(max(n,max(m,l)) == m) cout << m-max(n,l)+abs(l-n);
    else if(max(n,max(m,l)) == n) cout << n-max(l,m)+abs(m-l);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC112.D
{
    class Program
    {
        static void Main()
        {
            var sc = new Scanner();
            var n = sc.Nextint();
            var m = sc.Nextint();

            var maxGcd = 0;
            for (int i = 1; i * i <= m; i++)
            {
                var quotient = m / i;
                var remainder = m % i;
                if (remainder == 0)
                {
                    if (i < n)
                    {
                        if (quotient >= n) quotient = i;
                        else continue;
                    }
                    maxGcd = Math.Max(maxGcd, quotient);
                }
            }
            Console.WriteLine(maxGcd);
        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int Nextint()
        {
            return int.Parse(Next());
        }
        public int[] Arrayint(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        public double[] ArrayDouble(long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }

        public decimal NextDecimal()
        {
            return decimal.Parse(Next());
        }

        public decimal[] ArrayDecimal(long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal();
            }
            return Array;
        }
    }
}


Measured memory_bytes: 13140
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int n, m, v, p;
vector<int> a;

bool judge(int i) {
	if (a[p - 1] > a[i] + m) return false;
	int _v = v;
	_v -= p - 1 + n - i;
	if (_v <= 0) return true;
	int b = a[i] + m;
	vector<int> cnt;
	for (int j = p - 1; j < i; ++j)
		cnt.push_back(b - a[j]);
	int sz = cnt.size();
	ll sum = accumulate(cnt.begin(), cnt.end(), 0LL);
	return (sum / _v) >= m;
}

signed main() {
	cin >> n >> m >> v >> p;
	a.resize(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	// にぶたん
	int ok = p - 1, ng = n;
	while (ok + 1 < n && a[ok + 1] == a[p - 1])
		++ok;
	if (ok == n) {
		cout << n << endl;
	}
	else {
		while (ng - ok > 1) {
			int mid = (ok + ng) / 2;
			if (judge(mid)) ok = mid;
			else ng = mid;
		}
		cout << (ok + 1) << endl;
	}
	return 0;
}


Measured memory_bytes: 1556
#include <iostream>
#include <queue>
#include <string>

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

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

using namespace std;
int H, W, N;
char map[1003][1003];
int dist[1003][1003];

int bfs(char s, char t) {
    queue<int> que_x, que_y;
    rep(y, 1003) rep(x, 1003) dist[y][x] = -1;
    rep(y, H) rep(x, W) {
        if (s == map[y][x]) {
            dist[y][x] = 0;
            que_y.push(y);
            que_x.push(x);
        }
    }

    int ret = 0;
    while (que_x.size()) {
        int x = que_x.front();
        int y = que_y.front();
        que_x.pop();
        que_y.pop();
        if (map[y][x] == t) {
            ret = dist[y][x];
            break;
        }
        rep(k, 4) {
            int ny = y + dy[k];
            int nx = x + dx[k];
            if (ny < 0 || H <= ny) continue;
            if (nx < 0 || W <= nx) continue;
            if (map[ny][nx] == 'X') continue;
            if (dist[ny][nx] != -1) continue;
            dist[ny][nx] = dist[y][x] + 1;
            que_x.push(nx);
            que_y.push(ny);
        }
    }
    return ret;
}

void solve() {
    int ans = 0;

    ans += bfs('S', '1');
    rep(i, N - 1) ans += bfs(i + '1', i + '2');
    cout << ans << endl;
}

int main() {
    cin >> H >> W >> N;
    rep(y, H) cin >> map[y];
    solve();
}

Measured memory_bytes: 8040
import sys
import heapq
import math

input = sys.stdin.readline
N, M = map(int, input().split())
uv = [list(map(int, input().split())) for _ in range(M)]
S, T = map(int, input().split())

g = [[] for _ in range(3*N)]
for a, b in uv:
    g[a-1].append(b-1+N)
    g[a-1+N].append(b-1+2*N)
    g[a - 1 + 2 * N].append(b - 1)

# bfsでよかった
hq = [(0, S-1)]
costs = [math.inf] * 3 * N
while len(hq) > 0:
    c, u = heapq.heappop(hq)
    if u == T - 1:
        print(c // 3)
        sys.exit()
    costs[u] = c
    for v in g[u]:
        if costs[v] > c+1:
            heapq.heappush(hq, (c + 1, v))
        costs[v] = min(costs[v], c+1)

print(-1)


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

using namespace std;
typedef long long ll;
ll n,W;
ll wt[100000+1],v[100000+1];
ll mo(ll x){
  if(x>0) return x;
  else return -x;
}
ll cal(){
  ll dp[n+1][W+1];
  for(int i=0; i<=n; i++){
    for(int w=0; w<=W; w++){
      if(i==0||w==0) dp[i][w]=0;
      else if (wt[i-1] <= w) dp[i][w] = max(v[i-1] + dp[i-1][w-wt[i-1]],  dp[i-1][w]); 
      else dp[i][w] = dp[i-1][w]; 
    }
  }
  return dp[n][W];
}
int main() {
  cin>>n>>W;
  for(int i=0; i<n; i++){
    cin>>wt[i]>>v[i];
  }
  ll ans = cal();
  cout<<ans<<endl;
}

Measured memory_bytes: 79104
N = int(input())
K = int(input())
X = list(map(int,input().split()))
ans = 0
for i in range(N):
  if abs(X[i]) <= abs(K - X[i]):
    ans += 2 * X[i]
  else:
    ans += 2 * (K - X[i])
print(ans)

Measured memory_bytes: 3060
import sys
from operator import itemgetter


def r(n, m, xl):
    if len(xl) == 1:
        return 0
    if n >= m:
        return 0
    xl.sort()
    min_x = abs(min(xl))
    xl = [x + min_x for x in xl]
    xm = [xl[i+1] - xl[i] for i in range(len(xl)-1)]
    xm.sort()
    xxb = xm[:m-n]
    return sum(xxb)


def main():
    input = sys.stdin.readline
    n, m = list(map(int, input().split()))
    xl = list(map(int, input().split()))

    print(r(n, m, xl))


if __name__ == '__main__':
    main()


Measured memory_bytes: 13308
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <unordered_map>
#include <queue>
// g++ -std=c++11 -o2 -Wall filename.cpp -o filename
#define hell 1000000009
#define bug1(x) cout<<"$ "<<x<<" $"<<endl
#define bug2(x) cout<<"% "<<x<<" %"<<endl
#define bug3(x) cout<<"# "<<x<<" #"<<endl
#define ll long long
#define pb push_back
#define mp make_pair
#define tr(z) for(auto it=z.begin(); it!=z.end(); it++)
#define rloop(i,a,b) for(long long i=a; i>=b;i--)
#define loop(i,a,b) for(long long i=a; i<b; i++)
#define vbool vector< bool >
#define vvbool  vector< vector<bool> >
#define vchar vector<char>
#define vi vector<int>
#define vvi vector< vector<int> >
#define pll pair<long long, long long>
#define vll vector<long long>
#define vvl vector< vector<long long> >
#define ninf numeric_limits<long long>::min()
#define pinf numeric_limits<long long>::max()
#define comp(a,b) (abs(a-b)<1e-9) // to compare doubles
using namespace std;

int N, C;
vll V(N), W(N);
vvl dp;

ll helper(ll i, ll cur_C) {
    if (cur_C <= 0) {
        return 0;
    }
    if (i < 0) return 0;

    if (dp[i][cur_C]) {
        return dp[i][cur_C];
    }
    if (cur_C - W[i] < 0) {
        return dp[i][cur_C] = helper(i - 1, cur_C);
    }
    return dp[i][cur_C] = max(helper(i - 1, cur_C), helper(i - 1, cur_C - W[i]) + V[i]);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N, C;
    cin >> N >> C;
    V.resize(N);
    W.resize(N);
    dp = vvl(N, vll(C + 1));
    loop(i, 0, N) {
        cin >> W[i] >> V[i];
    }

    cout << helper(N-1, C) << endl;


    //cout << dp[C] << "\n";
    return 0;
}


Measured memory_bytes: 79488
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <list>
using namespace std;

struct Edge {
	vector<int> in_n, out_n;
	void set_in(int a) { in_n.emplace_back(a); }
	void set_out(int a) { out_n.emplace_back(a); }
};

int main() {
	int V, E; cin >> V >> E;
	vector<Edge> edge(V+1);
	list<int> L;
	queue<int> S;

	//initialize
	for (int i = 0; i < E;i++) {
		int s, t; cin >> s >> t;
		edge[s].set_out(t);
		edge[t].set_in(s);
	}
	for (int i = 0; i < V;i++) {
		if (edge[i].in_n.size() == 0) { S.push(i); }
	}
	
	while (!S.empty()) {
		int n = S.front(); S.pop();
		L.push_back(n);

		int size = edge[n].out_n.size();
		for (int i = 0; i < size; i++) {
			int m = edge[n].out_n[0];

			edge[n].out_n.erase(edge[n].out_n.begin());

			for (int j = 0; j < edge[m].in_n.size();j++) {
				if (edge[m].in_n[j] == n) {
					edge[m].in_n.erase(edge[m].in_n.begin() + j);
					break;
				}
			}
			E--;

			if (edge[m].in_n.size() == 0) {
				S.push(m);
			}
		}
	}

	if (E == 0) { cout << 0; }
	else { cout << 1; }
	cout << endl;
	return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    string a, b;
    stringstream str;
    cin >> a >> b;
    str << a << b;
    string n = str.str();

    int num = stoi(n);
    for (int i = 0; i < 1000; i++)
    {
        if (i * i == num)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

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

  int N = 50;
  out(N);
  ll A[N];
  rep(i, N) {
    A[i] = i+K/N;
  }
  rep(i, (N+K)%N) {
    rep(j, N) {
      --A[j];
    }
    A[i] += N+1;
  }
  rep(i, N-1) cout << A[i] << " ";
  cout << A[N-1] << "\n";

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
const int inf = 0x3f3f3f3f;

int n, k, E;
int p[N], q[N];
int tr[N << 2], ans1[N], ans2[N];
int fir[N], deg[N], nex[N << 1], arr[N << 1];
priority_queue<int, vector<int>, greater<int> > Q;

inline void Add_Edge(int x, int y) {
//	cout << x << ' ' << y << endl;
	nex[++E] = fir[x];
	fir[x] = E; arr[E] = y; deg[y]++;
}

void Updata(int x, int l, int r, int pos, int v) {
	if (l == r) return (void) (tr[x] = v);
	int mid = (l + r) >> 1;
	if (mid >= pos)
		Updata(x << 1, l, mid, pos, v);
	if (mid < pos)
		Updata(x << 1 | 1, mid + 1, r, pos, v);
	tr[x] = min(tr[x << 1], tr[x << 1 | 1]);
}

int Query(int x, int l, int r, int ql, int qr) {
	if (ql <= l && r <= qr) return tr[x];
	int mid = (l + r) >> 1, ans = 0x3f3f3f3f;
	if (mid >= ql)
		ans = min(ans, Query(x << 1, l, mid, ql, qr));
	if (mid < qr)
		ans = min(ans, Query(x << 1 | 1, mid + 1, r, ql, qr));
	return ans;
}
	
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &p[i]);
		q[p[i]] = i;
	}
/*	for (int i = 1; i <= n; ++i)
		cout << q[i] << ' ';
		puts("");*/
	memset(tr, 0x3f, sizeof tr);
	for (int i = n; i >= 1; --i) {
		int x = Query(1, 1, n, min(n, q[i] + 1), min(n, q[i] + k - 1));
		int y = Query(1, 1, n, max(1, q[i] - k + 1), max(1, q[i] - 1));
//		cout << i << ' ' << x << ' ' << y << endl;
		if (x != inf) Add_Edge(q[i], q[x]);
		if (y != inf) Add_Edge(q[i], q[y]);
		Updata(1, 1, n, q[i], i);
	}
	for (int i = 1; i <= n; ++i)
		if (!deg[i]) Q.push(i);
	int cnt = 0;
	while (!Q.empty()) {
		int x = Q.top(); Q.pop();
		for (int i = fir[x]; i; i = nex[i]) {
			if (--deg[arr[i]] == 0) Q.push(arr[i]);
		}
		ans1[++cnt] = x;
	}
	for (int i = 1; i <= n; ++i)
		ans2[ans1[i]] = i;
/*	for (int i = 1; i <= n; ++i)
		cout << ans1[i] << ' ';
		puts("");*/
	for (int i = 1; i <= n; ++i)
		printf("%d\n", ans2[i]);
	return 0;
}


Measured memory_bytes: 31604
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

template <class Abel>
struct BIT {
  vector<Abel> dat[2];
  Abel UNITY_SUM = 0;  // to be set

  /* [1, n] */
  BIT(int n) { init(n); }
  void init(int n) {
    for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM);
  }

  /* a, b are 1-indexed, [a, b) */
  inline void sub_add(int p, int a, Abel x) {
    for (int i = a; i < (int)dat[p].size(); i += i & -i)
      dat[p][i] = dat[p][i] + x;
  }
  inline void add(int a, int b, Abel x) {
    sub_add(0, a, x * -(a - 1));
    sub_add(1, a, x);
    sub_add(0, b, x * (b - 1));
    sub_add(1, b, x * (-1));
  }

  /* a is 1-indexed, [a, b) */
  inline Abel sub_sum(int p, int a) {
    Abel res = UNITY_SUM;
    for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
    return res;
  }
  inline Abel sum(int a, int b) {
    return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) -
           sub_sum(1, a - 1) * (a - 1);
  }

  /* debug */
  void print() {
    for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
    cout << endl;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, Q;
  cin >> N >> Q;
  vector<int> colors(N);
  REP(i, N) cin >> colors[i];
  vector<int> lefts(Q), rights(Q), ids(Q);
  REP(i, Q) {
    cin >> lefts[i] >> rights[i];
    --lefts[i];
    ids[i] = i;
  }
  sort(ids.begin(), ids.end(),
       [&](int i, int j) { return rights[i] < rights[j]; });

  BIT<int> bit(N + 5);
  vector<int> prev(1100000, -1);
  vector<int> res(Q, 0);
  int r = 0;
  for (auto i : ids) {
    for (; r < rights[i]; ++r) {
      bit.add(prev[colors[r]] + 2, r + 2, 1);
      prev[colors[r]] = r;
    }
    int tmp = bit.sum(lefts[i] + 1, lefts[i] + 2);
    res[i] = max(res[i], tmp);
  }
  for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}


Measured memory_bytes: 21756
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=500000;
int n;//|a| 
char a[N+5];//字符串 
int kmp[N+1],kmp_r[N+1];//kmp数组 
void kmp_init(int kmp0[]){//对a跑KMP算法 
	for(int i=2;i<=n;i++){
		int now=kmp0[i-1];
		while(now&&a[now+1]!=a[i])now=kmp0[now];
		kmp0[i]=a[now+1]==a[i]?now+1:0;
	}
}
int main(){
	cin>>a+1;
	n=strlen(a+1);
	bool ok=true;
	for(int i=1;i<n;i++)ok&=a[i]==a[i+1];//a的最小循环节是否为1 
	if(ok)return cout<<n<<"\n1",0;//特判最小循环节为1 
	kmp_init(kmp);
	reverse(a+1,a+n+1);//令a=a^r以算kmp_r 
	kmp_init(kmp_r);
	if(!kmp[n]||n%(n-kmp[n]))return puts("1\n1"),0;//特判不循环 
	puts("2");//一定有分成2段的方式 
	int ans=0;
	for(int i=1;i<n;i++)ans+=(!kmp[i]||i%(i-kmp[i]))&&(!kmp_r[n-i]||(n-i)%(n-i-kmp_r[n-i]));//如果都不循环，答案+1
	cout<<ans;
	return 0;
}

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

int n,x;
int cnt[100005];

typedef long long ll;
const ll MOD = 1e9 + 7;

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

int main(){
    scanf("%d", &n);
    if(n % 2 == 0){
        for(int i = 1; i <= n; i++){
            scanf("%d", &x);
            cnt[x]++;
        }
        bool flag = true;
        for(int i = 1; i < n; i += 2){
            if(cnt[i] != 2){
                flag = false;
                break;
            }
        }
        if(flag) printf("%lld\n",Pow(2,n/2));
        else puts("0");
    }
    else{
        for(int i = 1; i <= n; i++){
            scanf("%d", &x);
            cnt[x]++;
        }
        bool flag = true;
        if(cnt[0] != 1) flag = false;
        for(int i = 2; i < n; i += 2){
            if(cnt[i] != 2){
                flag = false;
                break;
            }
        }
        if(flag) printf("%lld\n",Pow(2,n/2));
        else puts("0");
    }
    return 0;
}



Measured memory_bytes: 640
n = int(input())
a = []
for i in range(0,n):
    a.append(int(input()))

num = []
while(len(a) > 0):
    
    num.append(max(a))
    index = max(a)
    for i in range(0,n):
        if(len(a) > 0 and index in a):
            a.remove(index)
            
print(len(num))
    


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<pll> A;
    rep(i,N) {
        int a; cin >> a;
        A.emplace_back(a,i);
    }

    sort(all(A)); reverse(all(A));
    vector<vector<ll>> dp(N+1, vector<ll>(N+1));
    rep(i,N) {
        rep(j,i+1) {
            chmax(dp[j+1][i-j],dp[j][i-j]+A[i].first*abs(A[i].second-j));
            chmax(dp[j][i+1-j],dp[j][i-j]+A[i].first*abs(A[i].second-(N-1-i+j)));
        }
    }

    ll ans = 0;
    rep(i,N+1) chmax(ans,dp[i][N-i]);
    cout << ans <<ln;
}


Measured memory_bytes: 34600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
using namespace std;

int main()
{
    int ans = 0;
    int tmp = 9;
    bool flag = true;
    for (int i = 0; i < 5; i++)
    {
        int tmp2;
        cin >> tmp2;
        if (tmp2 % 10)
        {
            if ((tmp2 % 10) < tmp)
            {
                tmp = tmp2 % 10;
            }
            ans += ((tmp2 / 10) * 10 + 10);
            flag = false;
        }
        else
        {
            ans += tmp2;
        }
    }
    if (flag)
    {
        cout << ans << endl;
    }
    else
    {
        cout << ans + tmp - 10 << endl;
    }
    return 0;
}

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

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

  int temp = 1;
  rep(i, N) {
    if (temp * 2 < temp + K) { // exception
      temp *= 2; // operation A
    } else {
      temp += K; // operation B
    }
  }

  cout << temp << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int ans;
int a[105];

int main(void) {
    int n;
    cin >> n;
    rep(i, 1, n+1) cin >> a[i];

    rep(i, 1, n+1) {
        if (a[i]%2 && i%2) ans++;
    }

  
    cout << ans << "\n";
    return 0;
}



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

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class FSugoroku {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N, M;
        in >> N >> M;
        string S;
        in >> S;

        vector<int> minZeroIndex(N+1, N+1); // find min index whose grid is zero in range [i, N]
        int minIndex = N+1;
        RREP(i,0,N+1) {
            if (S[i] == '0') {
                minIndex = i;
            }
            minZeroIndex[i] = minIndex;
        }

        vector<int> answers;

        int currentIndex = N;
        while (currentIndex != 0) {
            int nextIndex = minZeroIndex[max(0, currentIndex - M)];
            if (nextIndex == currentIndex || minZeroIndex[nextIndex] == N+1) {
                out << -1 << "\n";
                return;
            }
            assert(nextIndex < currentIndex);
            answers.push_back(currentIndex - nextIndex);
            currentIndex = nextIndex;
        }
        RREP(i,0,answers.size()) {
            out << answers[i];
            if (i == 0) out << "\n";
            else out << " ";
        }
    }
};


int main() {
	FSugoroku solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1528
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ans = 0
    neg = 0
    pos = []
    for ai, bi in zip(a, b):
        if ai < bi:
            neg += bi - ai
            ans += 1
        else:
            pos.append(ai - bi)
    if neg > sum(pos):
        print(-1)
        return 0
    pos.sort()
    for pi in pos[::-1]:
        if neg <= 0:
            break
        neg -= pi
        ans += 1
    print(ans)


if __name__ == "__main__":
    resolve()


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

using namespace std;

int h,w;
int G[21][21];
int ans=0;
int d[21][21];
int inf=1<<21;
char s;
queue<pair<int,int>> q;
vector<int> vec = {0,1,-1,0};
vector<int> uvec = {-1,0,0,1};

int bfs(int i,int j){
    q.push(pair<int,int> (i,j));
    d[i][j] = 0;
    while(!(q.empty())){
        pair<int,int> u = q.front();q.pop();
        //cout << i << " " << j << endl;
        for(int i=0;i<vec.size();i++){
            //cout << vec[i] << " " << uvec[i] << endl;
            if(G[vec[i]+u.first][u.second + uvec[i]] == 2) continue;
            else if(G[u.first + vec[i]][u.second + uvec[i]] == 1 && d[vec[i] + u.first][u.second + uvec[i]] == -1 && u.second + uvec[i] >= 0 && u.first + vec[i] >= 0){
                d[u.first + vec[i]][u.second + uvec[i]] = d[u.first][u.second] + 1;
                q.push(pair<int,int>(u.first + vec[i],u.second + uvec[i]));
            }
        }
    }
    int maxcos = -1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            //cout << d[i][j] << endl;
            if(d[i][j] > maxcos){
                maxcos = d[i][j];
            }
        }
    }
    return maxcos;

}

int main(){
    cin >> h >> w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> s ;
            if(s == '.'){
                G[i][j] = 1;
            }
            if(s == '#'){
                G[i][j] = 2;
            }
            //cout << G[i][j] << endl;
            d[i][j] = -1;
        }
    }

    for(int i=0;i<=h;i++){
        for(int j=0;j<=w;j++){
            if(i==h || j == w) G[i][j] == 2;
        }
        //cout << endl;
    }

    for(int k=0;k<h;k++){
        for(int l=0;l<w;l++){
            //cout << k <<  " " << l << endl;
            if(G[k][l] == 1) ans = max(bfs(k,l),ans);
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    d[i][j] = -1;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
    }

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cassert>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

long gcd(long a, long b) {
    while (b > 0) {
        long c = a % b;
        a = b;
        b = c;
    }
    return a;
}

long lcm(long a, long b) {
    long d = gcd(a, b);
    return a / d * b;
}

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


    vector<bool> pm(100000, 1);
    vector<int> p;

    for (int i = 2; p.size() < 1005; i++) {
        if (pm[i]) {
            p.push_back(i);
//            cout << p.size() << " " << i << "\n";
            for (int j = 2 * i; j < pm.size(); j += i) {
                pm[j] = false;
            }
        }
    }

    int n;
    cin >> n;

    vector<long> d1(n);
    for (int i = 0; i < n; i++) {
        d1[i] = p[i];
    }
    vector<long> d2(n);
    for (int i = 0; i < n; i++) {
        d2[i] = p[n + i];
    }

    vector<vector<long>> a(n, vector<long>(n));

    set<long> used;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if ((i + j) % 2 == 0) {
                a[i][j] = d1[(i + j) / 2] * d2[(i - j) / 2 + n / 2];
//                cout << d1[(i + j) / 2] << "*" << d2[(i - j) / 2 + n / 2] << " ";
                used.insert(a[i][j]);
            }
        }
//        cout << "\n";
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if ((i + j) % 2 == 1) {
                a[i][j] = 1;
                if (i > 0) a[i][j] = lcm(a[i][j], a[i - 1][j]);
                if (j > 0) a[i][j] = lcm(a[i][j], a[i][j - 1]);
                if (i < n - 1) a[i][j] = lcm(a[i][j], a[i + 1][j]);
                if (j < n - 1) a[i][j] = lcm(a[i][j], a[i][j + 1]);
                int x = a[i][j];
                a[i][j]++;
                while (used.find(a[i][j]) != used.end()) {
                    a[i][j] += x;
                    assert(a[i][j] <= 1000000000000000L);
                }
                used.insert(a[i][j]);
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << a[i][j] << " ";
        }
        cout << "\n";
    }


    return 0;
}

Measured memory_bytes: 16896
#include <iostream>

typedef long long ll;

using namespace std;

int main() {
    ll a = 2, b = 1, c, n;
    cin >> n;
    if (n < 2) {
        cout << 2 - n << endl;
        return 0;
    }
    for (int i = 0; i < n - 1; ++i) {
        c = a + b;
        a = b;
        b = c;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES //円周率を使用
#include <math.h>
#include <iomanip> //小数点以下を表示
#include <iostream>
#include <cstring> //文字列操作
using namespace std;

//【関数の定義】

int main(void)
{
	int dice[6] = {0, 0, 0, 0, 0, 0}; //サイコロの各面（ex.1の面->dice[0]）
	int dummy = 0; //サイコロの面の数字のダミー
	int top = 0; //サイコロの上面の数字
	char len[101]; //方角
	int lencount = 0;
	int i; //カウンタ変数
	
	for (i = 0; i < 6; i++)
	{
		cin >> dice[i];
	}

	cin >> len;
	lencount = strlen(len);

	for (i = 0; i < lencount; i++)
	{
		dummy = 0; //ダミーの初期化

		if (len[i] == 'S')
		{
			dummy = dice[5];
			dice[5] = dice[1];
			dice[1] = dice[0];
			dice[0] = dice[4];
			dice[4] = dummy;
			top = dice[4];
		}

		else if(len[i] == 'E')
		{
			dummy = dice[5];
			dice[5] = dice[2];
			dice[2] = dice[0];
			dice[0] = dice[3];
			dice[3] = dummy;
			top = dice[3];
		}

		else if (len[i] == 'N')
		{
			dummy = dice[5];
			dice[5] = dice[4];
			dice[4] = dice[0];
			dice[0] = dice[1];
			dice[1] = dummy;
			top = dice[1];
		}

		else if (len[i] == 'W')
		{
			dummy = dice[5];
			dice[5] = dice[3];
			dice[3] = dice[0];
			dice[0] = dice[2];
			dice[2] = dummy;
			top = dice[2];
		}

	}

	cout << dice[0] << endl; //上面の数字を表示

	return 0;
}


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

int main(){
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	string s;
	cin>>s;
	if(s=="ABC")
		cout<<"ARC"<<endl;
	else
		cout<<"ABC"<<endl;

	return 0;
}

Measured memory_bytes: 3136
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String st;
		int a[];
		int sum;

		a = new int[100];
		while (sc.hasNext()) {
			sum = 0;
			st = sc.next();
			for (int i = 0; i < st.length(); i++) {
				if (st.charAt(i) == 'I') a[i] = 1;
				if (st.charAt(i) == 'V') a[i] = 5;
				if (st.charAt(i) == 'X') a[i] = 10;
				if (st.charAt(i) == 'L') a[i] = 50;
				if (st.charAt(i) == 'C') a[i] = 100;
				if (st.charAt(i) == 'D') a[i] = 500;
				if (st.charAt(i) == 'M') a[i] = 1000;
				if (i != 0 && a[i - 1] < a[i]) {
					a[i] -= a[i - 1];
					a[i - 1] = 0;
				}
			}
			for (int i = 0; i < st.length(); i++) {
				sum += a[i];
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int maxn = 2e5+10;
long long n;
int main(){
    cin>>n;
    long long ans = (n/11)*2;
    if(n% 11 == 0)   ans = ans;
    else if(n%11 <= 6 )   ans = ans+1;
    else   ans = ans+2;
    cout << ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define jizz ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) x&-x
#define F first 
#define S second 
#define pb push_back
#define MP make_pair
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9;
const int MAXN=1e6;
int n, ac, wa, tle, re;
string s;
int main()
{
	cin >> n;
	for (int i=0;i<n;i++){
		cin >> s;
		if (s[0]=='A'){
			ac++;
		}
		else if (s[0]=='W')
			wa++;
		else if (s[0]=='T')
			tle ++;
		else re++;
	}
	cout << "AC x " << ac << "\n";
	cout << "WA x " << wa << "\n";
	cout << "TLE x " << tle << "\n";
	cout << "RE x " << re << "\n";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int mod = 1e9+7;

int main(){
    string l;
    cin >> l;
    int n = l.size();
    VVL dp(n+1, VL(2));
    dp[0][0] = 1;
    rep(i,n){
        if (l[i] == '1'){
            dp[i+1][1] += dp[i][0];
            dp[i+1][1] += dp[i][1];

            dp[i+1][0] += dp[i][0] * 2;
            dp[i+1][0] %= mod;
            dp[i+1][1] += dp[i][1] * 2;
            dp[i+1][1] %= mod;
        }else{
            dp[i+1][0] += dp[i][0];
            dp[i+1][1] += dp[i][1];

            dp[i+1][1] += dp[i][1] * 2;
            dp[i+1][1] %= mod;
        }
    }
    ll ans = (dp[n][0] + dp[n][1]) % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8780
#include <bits/stdc++.h>
#define ll int
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
 



int main()
{
    fastio
    ll i,j;
    
    ll x,y;
    cin>>x>>y;
    
    ld d=(y*1.0)/x;
    
    if(y%2==0 && d<=4.0 && d>=2.0)
    cout<<"Yes";
    else
    cout<<"No";
    
    /*ll a=(4*x-y)/2;
    ll b=(y-2*x)/2;
    
    if(2*a+4*b==y)
    cout<<"Yes";
    else
    cout<<"No";*/
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
  int x,i,k,j=0;
  scanf("%d",&x);
  i=x;
  while(1){
    if(i==2){
      i=2;
      break;}
    j=0;
    for(k=2;k<x;k++){
      if(i%k==0){
        j=1;
        break;
      }
    }
    if(j==0) break;
    i++;
  }
  printf("%d",i);

  return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
int main()
{
   //#ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  //#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
   char c;
   cin>>c;
   if(c=='a')
   {
   	cout<<'b';
   }
   if(c=='b')
   {
   	cout<<'c';
   }
   if(c=='c')
   {
   	cout<<'d';
   }
   if(c=='d')
   {
   	cout<<'e';
   }
   if(c=='e')
   {
   	cout<<'f';
   }
   if(c=='f')
   {
   	cout<<'g';
   }
   if(c=='g')
   {
   	cout<<'h';
   }
  if(c=='h')
   {
   	cout<<'i';
   }

   if(c=='i')
   {
   	cout<<'j';
   }
   if(c=='j')
   {
   	cout<<'k';
   }
   if(c=='k')
   {
   	cout<<'l';
   }
   if(c=='l')
   {
   	cout<<'m';
   }
   if(c=='m')
   {
   	cout<<'n';
   }
   if(c=='n')
   {
   	cout<<'o';
   }
   if(c=='o')
   {
   	cout<<'p';
   }
   if(c=='p')
   {
   	cout<<'q';
   }
   if(c=='q')
   {
   	cout<<'r';
   }
   if(c=='r')
   {
   	cout<<'s';
   }
   if(c=='s')
   {
   	cout<<'t';
   }
   if(c=='t')
   {
   	cout<<'u';
   }
   if(c=='u')
   {
   	cout<<'v';
   }
   if(c=='v')
   {
   	cout<<'w';
   }
   if(c=='w')
   {
   	cout<<'x';
   }
   if(c=='x')
   {
   	cout<<'y';
   }
   if(c=='y')
   {
   	cout<<'z';
   }
}


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

int main(void){
    int n,d;
    cin >> n >> d;
    vector<vector<int>> pos(n,vector<int>(d));
    for(int i=0;i<n;i++) for(int j=0;j<d;j++) cin >> pos[i][j];

    int count = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            double dist = 0;
            for(int k=0;k<d;k++){
                dist += (pos[i][k]-pos[j][k])*(pos[i][k]-pos[j][k]);
            }
            dist = sqrt(dist);
            int intdist = (int)dist;
            if(dist == (double)intdist) count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
import sys
import os

N, K = map(int,input().split())
A = list(map(int,input().split()))
mod = 10**9 + 7

cnt1 = 0  #Aの中で自分より後ろにある自分より小さい値の個数
cnt2 = 0  #Aの中で自分より小さい値の個数
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            cnt2 += 1
            if i < j:
                cnt1 += 1

print((K*cnt1+K*(K-1)*cnt2//2)%mod)


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

using namespace std;

const long long inf = 0x7f7f7f7f7f7f7f7fll;

template <class T, class U = int>
struct RangeMinimumQuery {
	static const int maxh = 20;

	int n;
	vector<T> a;
	vector<array<U, maxh> > f;

	U select(const U & lhs, const U & rhs) const {
		return a[lhs] <= a[rhs] ? lhs : rhs;
	}

	RangeMinimumQuery() {
		clear();
	}

	void clear() {
		n = 0;
		a.clear();
		f.clear();
	}

	void resize(const int & n) {
		this->n = n;
		a.resize(n);
		f.resize(n);
	}

	void update(const int & i, const bool & rht = false) {
		f[i][0] = i;
		if (!rht) {
			for (int k = 1, b; (b = 1 << k) <= i + 1; k++)
				f[i + 1 - b][k] = select(f[i + 1 - b][k - 1], f[i + 1 - (b >> 1)][k - 1]);
		} else {
			for (int k = 1, b; (b = 1 << k) <= n - i; k++)
				f[i][k] = select(f[i][k - 1], f[i + (b >> 1)][k - 1]);
		}
	}

	void push_back(const T & x) {
		n++;
		a.push_back(x);
		f.emplace_back();
		update(n - 1, false);
	}

	void build() {
		for (int i = 0; i < n; i++)
			update(i, false);
	}

	U query(const int & l, const int & r) const {
		int k = 0;
		for (; 1 << k + 1 < r - l; k++);
		return select(f[l][k], f[r - (1 << k)][k]);
	}
};

const int maxN = 100000;

int N, M;
vector<pair<int, int> > vtr[maxN];
RangeMinimumQuery<long long, int> RMQ;
long long f[maxN];

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

	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int l, r, c;
		cin >> l >> r >> c;
		l--, r--;
		vtr[r].emplace_back(l, c);
	}

	f[0] = 0;
	for (int i = 1, k = 0; i < N; i++) {
		f[i] = inf;
		for (; k < i; k++)
			RMQ.push_back(f[k]);
		for (const auto & e : vtr[i]) {
			int l = e.first, r = i, c = e.second;
			f[i] = min(f[i], f[RMQ.query(l, r)] + c);
		}
	}

	if (f[N - 1] == inf)
		cout << "-1";
	else
		cout << f[N - 1];
	cout << '\n';

	return 0;
}


Measured memory_bytes: 19464
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return 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 (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n+1, 0), b(m+1, 0);
    rep(i, n) {
        ll c;
        cin >> c;
        a[i+1] = a[i] + c;
    }
    rep(i, m) {
        ll c;
        cin >> c;
        b[i+1] = b[i] + c;
    }
    ll ans = 0;
    repn(i, n) {
        ll now = a[i];
        if(k < now) break;
        ll t = upper_bound(all(b), k - now) - b.begin();
        chmax(ans, i + t - 1);
    }
    cout << ans << endl;
}

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

#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

class BResale {
public:
	void solve(std::istream& in, std::ostream& out) {
        int N;
        in >> N;
        int ans = 0;
        int v[N], c[N];
        REP(i, N) in >> v[i];
        REP(i, N) in >> c[i];
        REP(i, N) {
            if (v[i] - c[i] > 0) ans += v[i] - c[i];
        }
        out << ans << '\n';
	}
};


int main() {
	BResale solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


A, B, C = LI()

result = B // A
print(min(result, C))


Measured memory_bytes: 67308
/*
E - Sequential operations on Sequence
by.YXH_XianYu
   2018.6.15
 */
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LLI long long
#define MXN 100010

LLI q[MXN],
	a[MXN],
	t[MXN],
	ans[MXN],
	ch;
int n,m;

int Binary(int l, int r, LLI k){
	while(l<=r){
		int mid=(l+r)>>1;
		if(a[mid]<=k)
			l=mid+1;
		else
			r=mid-1;
	}
	return l-1;
}


int main(){
	//freopen("mothergoose.in","r",stdin);
	//freopen("mothergoose.out","w",stdout);

	scanf("%d%d",&n,&m);
	q[++q[0]]=n;
	for(int i=1;i<=m;i++){
		scanf("%lld",&ch);
		while(q[q[0]]>=ch)//q[0]=0 < ch
			q[0]--;
		q[++q[0]]=ch;
	}
	m=q[0];
	for(int i=1;i<=q[0];i++)
		a[i]=q[i];
	t[m]=1;
	for(int i=m;i>=1;i--){
		LLI k=a[i];
		int p=Binary(1,i-1,k);
		while(p){
			t[p]+=k/a[p]*t[i];
			k%=a[p];
			p=Binary(1,p-1,k);
		}
		ans[k]+=t[i];
	}
	for(int i=n;i>=1;i--)
		ans[i]+=ans[i+1];
	for(int i=1;i<=n;i++)
		printf("%lld\n",ans[i]);

	return 0;
}


Measured memory_bytes: 4864