akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto S = readln.chomp.to!(char[]);

    int r;
    foreach (i; 1..N-1) {
        int[char] CNT;
        foreach (c; S[0..i]) {
            CNT[c] = 1;
        }
        foreach (c; S[i..N]) {
            if (c in CNT) ++CNT[c];
        }
        int rr;
        foreach (_, v; CNT) if (v > 1) ++rr;
        r = max(r, rr);
    }
    writeln(r);
}

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

using namespace std;

template <typename type>
type BaseChange(type num, type base, type digit)
{
    for(type i=0;i<digit;i++){
        num/=base;        
    }
    return num%base;
}

int main()
{
    // 基本データ入力
    int n, m, x;
    cin >> n >> m >> x;
    
    // コストとデータ入力
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0;i<n;i++){
        cin >> c[i];
        for(int j=0;j<m;j++) cin >> a[i][j];
    }

    int ans=(1<<30);

    // ビット全探索
    for(int i=1;i<(1<<n);i++){
        int cost=0;
        vector<int> state(m,0);
        for(int j=0;j<n;j++){
            // 検索文字がhit
            // cout << BaseChange(i,2,j);
            if(BaseChange(i,2,j)==1){
                cost+=c[j];
                for(int k=0;k<m;k++){
                    state[k]+=a[j][k];
                }
            }
        }
        // cout << endl;
        // デバッグ用
        // cout << " " << cost << " ";
        // for(int j=0;j<m;j++) cout << state[j] << " ";
        // cout << endl;
        bool check=true;
        for(int j=0;j<m;j++){
            if(state[j]<x) check=false;
        }
        if(check) ans = min(ans, cost);
    }
    if(ans==(1<<30)) ans=-1;
    cout << ans << endl;
}

Measured memory_bytes: 3600
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();
                string[] change = input.Split(' ');
                int h = int.Parse(change[0]);
                int w = int.Parse(change[1]);

                if (h == 0 && w == 0)//????????????0?????£????????????
                    break;

                for (int row = 0; row < h; row++)
                {
                    for (int col = 0; col < w; col++)
                    {
                        if ((row + col) % 2 == 0)//#??????????????????????????¶
                        {
                            Console.Write("#");
                        }
                        else//????????\???????????????????????????
                        {
                            Console.Write(".");
                        }
                        
                    }
                    Console.WriteLine();//?????´???for??§1??????????????????????????§???????????\??????
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 8856
import itertools


def main():
    (n, _) = list(map(int, input().split()))
    x = [[int(n) for n in input().split()] for _ in range(n)]

    count = 0
    for (a, b) in itertools.combinations(x, 2):
        if (sum((pair[0] - pair[1]) ** 2 for pair in zip(a, b)) ** .5).is_integer():
            count += 1
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
N = int(input())
Q = [list(map(int, input().split())) for _ in range(N)]
Q.sort(key=lambda x: x[2])
a, b, H = Q[-1]


def height(x, y, H, a, b):
    return max(H-abs(x-a)-abs(y-b), 0)


for i in range(101):
    for j in range(101):
        A = H+abs(i-a)+abs(j-b)
        B = height(a, b, H, i, j)
        f, g = True, True
        if not A:
            f = False
        if not B:
            g = False
        for k in range(N):
            x, y, h = Q[k]
            if height(i, j, A, x, y) != h:
                f = False
            if height(i, j, B, x, y) != h:
                g = False
            if not (f or g):
                break
        else:
            if f:
                print(i, j, A)
                exit()
            else:
                print(i, j, B)
                exit()


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

// point : cum sum is monotonic increasing / decreasing

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    long a[55]; for(int i=0; i < n; ++i) cin >> a[i];

    int mx = 0, mn = 1e9, mxi = 0, mni = 0;
    for(int i=0; i < n; ++i) {
        if(mx < a[i]) {
            mx = a[i];
            mxi = i;
        }
        if(mn > a[i]) {
            mn = a[i];
            mni = i;
        }
    }

    vector<pair<int, int>> ans;
    if(abs(mx) >= abs(mn)) {
        for(int i=0; i < n; ++i) {
            a[i] += mx;
            ans.emplace_back(mxi + 1, i + 1);
        }

        for(int i=0; i < n-1; ++i) {
            a[i+1] += a[i];
            ans.emplace_back(i+1, i+2);
        }
    } else {
        for(int i=0; i < n; ++i) {
            a[i] += mn;
            ans.emplace_back(mni + 1, i + 1);
        }

        for(int i=n-1; i > 0; --i) {
            a[i-1] += a[i];
            ans.emplace_back(i+1, i);
        }
    }

    cout << ans.size() << '\n';
    for(auto p : ans) cout << p.first << " " << p.second << '\n';
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

N, X, Y = map(int, input().split())
X -= 1
Y -= 1
dist= [0] * N # dist[i] = (距離がiなる(i, j)の組の個数)
check = [[] for _ in range(N)]
for i in range(N - 1):
    for j in range(i + 1, N):
        if j <= X or Y <= i:
            dist[j - i] += 1
            check[j - i].append((i, j))
        elif i <= X and Y <= j:
            d = (X - i) + 1 + (j - Y)
            dist[d] += 1
            check[d].append((i, j))
        elif X <= i and j <= Y:
            d = min(j - i, (i - X) + 1 + (Y - j))
            dist[d] += 1
            check[d].append((i, j))
        elif i <= X and X <= j and j <= Y:
            d = min(j - i, (X - i) + 1 + (Y - j))
            dist[d] += 1
            check[d].append((i, j))
        elif X <= i and i <= Y and Y <= j:
            d = min(j - i, (i - X) + 1 + (j - Y))
            dist[d] += 1
            check[d].append((i, j))

#print(check)

for k in range(1, N):
    print(dist[k])




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

// #define multitest 1
// #define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

const int nax = 1e5 + 5;
vector<int> edges[nax];
int in_degree[nax], dist[nax];
bool visited[nax];

void dfs(int node)
{
	if (visited[node])
		return;
	visited[node] = true;
	for (auto child : edges[node])
	{
		dist[child] = max(dist[node] + 1, dist[child]);
		in_degree[child]--;
		if (in_degree[child] == 0)
			dfs(child);
	}
	db(node,dist[node]);
}

void solve()
{
	int n, m, u, v;
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		cin >> u >> v;
		edges[u].pb(v);
		in_degree[v]++;
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i)
		if (in_degree[i] == 0)
			dfs(i);
	for (int i = 1; i <= n; ++i)
		ans = max(ans, dist[i]);
	cout << ans;
}

int main()
{
#ifndef Debug
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 9728
/*---Bismillahir Rahmanir Rahim---*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define mod 998244353
#define int long long
#define ld long double
#define pb push_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define pii pair<int, int>
using namespace std; 

map <char,int> cnt;
inline void solve()
{
	string s; int ans=0;
	cin >> s;
	for (int i=0;i<sz(s);i++) 
		cnt[s[i]] ^= 1 ; 
	for (char  i='a';i<='z';i++)
		if (cnt[i]) ans++;
	cout << ((ans)?"No":"Yes") << endl;
}

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

/*
3 4
2 1 3
3 1 2 3
2 3 2

*/


Measured memory_bytes: 3616
H,W = map(int,input().split())

start = tuple(map(lambda x:x - 1, map(int,input().split())))
goal = tuple(map(lambda x:x - 1, map(int,input().split())))

S = [input() for i in range(H)]

from collections import deque
q = deque([])

# 頂点, コスト
q.append([start[0], start[1], 0])
INF = 10 ** 10
cost = [[INF] * W for i in range(H)]

while q:
  y,x,c = q.popleft()
  if S[y][x] == "#":
    continue
  if cost[y][x] <= c:
    continue
  cost[y][x] = c
  for i in range(-2,3):
    for j in range(-2,3):
      if i == 0 and j == 0:
        continue
      if 0 <= y + i < H and 0 <= x + j < W:
        if abs(i) + abs(j) == 1:
          q.appendleft([y + i, x + j, c])
        else:
          q.append([y + i, x + j, c + 1])

if cost[goal[0]][goal[1]] == INF:
  print(-1)
else:
  print(cost[goal[0]][goal[1]])


Measured memory_bytes: 248220
while(True):
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break

    cnt = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    cnt += 1
    print(cnt)

Measured memory_bytes: 7656
#include <bits/stdc++.h>  // ver2.1.4
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int, vector<int>, greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a.back()<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int mypow(int x, int n, int m){  //  高速累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int a,b;
  cin >> a >> a >> b;
  if((b-a)%2==1)cout<<"Borys"<<endl;
  else cout<<"Alice"<<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++)
typedef long long ll;
typedef pair<int,int>P;
#define INF 10000000
  	int N;
vector<int>h(101);
int sim(int x){
  	h[x]--;
	if(x>=2&&h[x]+1==h[x-1]){sim(x-1);}
	if(x<=99&&h[x]+1==h[x+1]){sim(x+1);}
}
int allo(){
 for(int i=1;i<=N;i++){
 	if(h[i]!=0){return true;}
 }
	return false;

}

int main() {

  	cin >>::N;
  	
  	for(int i=1;i<=N;i++){
      cin >>h[i];
    }
  	int memo,num,count;
  while(allo()){
    memo=0;
   	for(int i=1;i<=N;i++){
    	memo=max(memo,h[i]);
      	if(memo==h[i]){num=i;}
    }
   	sim(num);count++;
  }
   cout<<count<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;                      
                                               
 class Main {                                  
    public static void main(String[] args) {   
     Scanner scanner = new Scanner(System.in);      
   int n=scanner.nextInt();

   for ( int i = 1; i <= n; ++i ) {
	
	   int a = i;
	
	   if ( a % 3 == 0 ) {            //３の倍数の場合出力
	 System.out.print(" " + i);
	 }
	else 
    {
		a=a*10;
		while(a>10){                //aが2桁になるまで割り続け、10で割ったあまりが3の場合出力する、
			a=a/10;
	if ( a % 10 == 3 ) {
	   System.out.print(" " +i);
	   break;
	   }
	  }
    }
	}
	System.out.println();

	scanner.close();
}
 }
    


Measured memory_bytes: 28588
import java.util.*

val sc = Scanner(System.`in`)
val N = sc.nextInt()

fun main(args: Array<String>) {
    print(if (N % f(N) == 0) "Yes" else "No")
}

fun f(X: Int): Int {
    var x = X
    var result = 0
    repeat(x.toString().length) {
        result += x % 10
        x /= 10
    }
    return result
}


Measured memory_bytes: 31400
#if 1
  #include <bits/stdc++.h>
#else
  #include "../../../../bits/stdc++.h"
#endif

using namespace std;

#define int long long

using ll = long long;
using pii =  pair<int, int>;

const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)

#define rep(i,n) for_(i,0,n)
#define rrep(i,n) rfor_(i,0,n)

#define pb push_back
//#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))

#define endl '\n'

const int limit = 100007;

int N;
int a[limit];

int x, y;

signed main(){
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  
  cin>>N;
  rep(i, N)cin>>a[i];
  
  sort(a, a+N);
  
  
  rfor_(i, 1, N) {
    if(x<1) {
      if(a[i]==a[i-1]) {
        x = a[i];
        i--;
      }
    }else if(y<1) {
      if(a[i]==a[i-1]) {
        y = a[i];
        i--;
      }
    }else break;
  }
  
  cout<<x*y<<endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

template<int M>
class ModInt {
   public:
    ll value;
    constexpr ModInt(ll v = 0) { value = v % M; if (value < 0) value += M; }
    constexpr ModInt pow(ll n) const {
        ModInt<M> ret(1), x(value);
        while (n > 0) {
            if (n % 1) ret *= x;
            x *= x;
            n >>= 1;
        }
        return ret;
    }
    constexpr ModInt inv() const { return this->pow(M - 2); }
    constexpr ModInt operator + (const ModInt &rhs) const { return ModInt(*this) += rhs; };
    constexpr ModInt operator - (const ModInt &rhs) const { return ModInt(*this) -= rhs; };
    constexpr ModInt operator * (const ModInt &rhs) const { return ModInt(*this) *= rhs; };
    constexpr ModInt operator / (const ModInt &rhs) const { return ModInt(*this) /= rhs; };
    constexpr ModInt &operator += (const ModInt &rhs) { value += rhs.value; if (value >= M) value -= M; return *this; };
    constexpr ModInt &operator -= (const ModInt &rhs) { value -= rhs.value; if (value <  0) value += M; return *this; };
    constexpr ModInt &operator *= (const ModInt &rhs) { value = value * rhs.value % M; return *this; };
    constexpr ModInt &operator /= (const ModInt &rhs) { return ModInt(*this) *= rhs.inv(); };
    friend ostream &operator << (ostream &os, const ModInt &rhs) { os << rhs.value; return os; }
};

using mint = ModInt<MOD>;

int main() {
    int n, m; cin >> n >> m;
    vector<int> s(n), t(m);
    REP(i, 0, n) cin >> s[i];
    REP(i, 0, m) cin >> t[i];

    mint dp[n + 1][m + 1] = {};
    REP(i, 0, n + 1) dp[i][0] = 1;
    REP(i, 0, m + 1) dp[0][i] = 1;
    REP(i, 0, n) {
        REP(j, 0, m) {
            if (s[i] == t[j]) dp[i + 1][j + 1] += dp[i][j];
            dp[i + 1][j + 1] += dp[i + 1][j] + dp[i][j + 1];
            dp[i + 1][j + 1] -= dp[i][j];

        }
    }
    cout << dp[n][m] << endl;
    return 0;
}

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

void solve()
{
   int a, b;
   cin>>a>>b;
   vector<int> v1, v2;
   for(int i=0; i<b; i++)
   {
       v1.push_back(a);
   }
   for(int i=0; i<a; i++)
   {
       v2.push_back(b);
   }
   if(v1[0]<v2[0])
   {
       for(auto it: v1)
       {
           cout<<it;
       }
       cout<<endl;
   }
   else
   {
       for(auto it: v2)
       {
           cout<<it;
       }
       cout<<endl;
   }

}
int main()
{
    int t;
    t=1;
    while(t--)
    {
        solve();

    }
return 0;
}


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

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	int H, W, jur, jurl,n;
	cin >> H >> W;
	n=0;
	vint del_side(H);
	vint del_leng(W);

	vstr a(H);
	//全部白の行を判定
	for (int i = 0; i < H; i++) {
		jur = 0;
		cin >> a[i];

		for (int j = 0; j < W; j++) {
			if (a[i][j] == '.')jur++;
		}
		if (jur == W)del_side[i] = 1;
		else del_side[i] = 0;

	}

	for (int k = 0; k < W; k++) {
		jurl = 0;

		for (int l = 0; l < H; l++) {

			if (a[l][k] == '.')jurl++;
		}

		if (jurl == H)del_leng[k] = 1;
		else del_leng[k] = 0;
		}

	for (int p = 0; p < W; p++) {
	 
		if (del_leng[p] == 1) {
			for (int o = 0; o < H; o++) {
				a[o].erase(a[o].begin() + (p-n));
				
			}
			n++;
		}
	}
	for (int m = 0; m < H; m++) {

		if (del_side[m] == 0)cout << a[m] << endl;

	}
	

}



Measured memory_bytes: 256
#include<stdio.h>
int fib(int n);
int a[45]={0};
int main()
{
  int n;
  scanf("%d",&n);
  n=fib(n);
  printf("%d\n",n);
  return 0;
}
int fib(int n)
{
  if(n==0 || n==1)return a[n]=1;
  if(a[n]!=0)return a[n];
  return a[n]=fib(n-2)+fib(n-1);
}



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

typedef long long ll;
typedef long double ld;

const int MOD = 998244353;

int add(int a, int b){
    return (a+b)%MOD;
}

int mul(int a, int b){
    return ((ll)a*b)%MOD;
}

int pw(int a, int b){
    if(b == 0) return 1;
    int res = pw(a, b/2);
    res = mul(res, res);
    if(b%2) res = mul(res, a);
    return res;
}

int inv(int a){
    return pw(a, MOD-2);
}

int fact[1000005];

int bcof(int n, int k){
    if(n < 0 || k < 0 || n < k) return 0;
    int res = fact[n];
    res = mul(res, inv(fact[k]));
    res = mul(res, inv(fact[n-k]));
    return res;
}

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n;
    cin >> n;
    fact[0] = 1;
    for(int i=1; i<=n; i++){
        fact[i] = mul(fact[i-1], i);
    }
    ll a, b, k;
    cin >> a >> b >> k;
    int res = 0;
    for(int i=0; i*a<=k && i<=n; i++){
        ll c = k - (i*a);
        if(c%b) continue;
        c /= b;
        res = add(res, mul(bcof(n, i), bcof(n, c)));
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 1408
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};

int main(){int a,b;scanf("%d%d",&a,&b);double ret=0;for(int i=1;i<=a;i++){double tmp=1.0/a;int now=i;while(now<b){now*=2;tmp/=2;}ret+=tmp;}printf("%.12f\n",ret);}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    vector<pair<int, int>> time(N);
    rep(i, N) cin >> time[i].second >> time[i].first;

    sort(time.begin(), time.end());

    vector<vector<ll>> dp(N+1, vector<ll>(N+1, INF));
    dp[0][0] = 0;

    rep(i, N) {
        rep(j, N) {
            dp[i+1][j] = dp[i][j];
        }
        rep(j, N) {
            if (dp[i][j] == INF) continue;
            if (dp[i][j] + time[i].second <= time[i].first) {
                chmin(dp[i+1][j+1], dp[i][j] + time[i].second);
            }
        }
    }

    int ans = 0;
    rep(i, N+1) {
        if (dp[N][i] != INF) ans = i;
    }

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


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
#define int long long
int T,A,B,C,D;
int pd(int A,int B,int k){
	return (B+1)*k>=A&&(A+1)*k>=B;
}
char check(int A,int B,int z){
	int k=max((A-1)/(B+1),(B-1)/(A+1))+1;
	int l=0,r=A;
	while (l<r){
		int mid=(l+r+1)/2;
		if (pd(A-mid,B-(mid-1)/k,k))l=mid;
		else r=mid-1;
	}
	if (z<=l+(l-1)/k){
		if (z%(k+1)==0)return 'B';
		return 'A';
	}
	z-=l+max(0ll,(l-1)/k);
	A-=l;B-=max(0ll,(l-1)/k);
	int t=B%k;
	if (!t)t=k; 
	if (z<=t)return 'B';
	z-=t;B-=t;
	if (z%(k+1)==1)return 'A';
	return 'B';
}
signed main(){
	scanf("%lld",&T);
	while (T--){
		scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
		for (int i=C;i<=D;i++)
			printf("%c",check(A,B,i));
		puts("");
	}
}

Measured memory_bytes: 384
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <deque>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

#define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

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

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

template <typename T> T gcd(T m, T n) { return n == 0 ? m : gcd(n, m % n); }
template <typename T> T lcm(T m, T n) { return n * m / gcd(n, m); }

signed main(void)
{
  int num;

  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  vector<int> b(n);
  vector<int> c(n);
  b[0] = a[0];
  c[n - 1] = a[n - 1];
  
  for (int i = 1; i < n; ++i) {
    b[i] = max(a[i], b[i - 1]);
    c[n - 1 - i] = max(a[n - 1 - i], c[n - i]);
  }

  for (int i = 0; i < n; ++i) {
    if (i == 0) {
      cout << c[i + 1] << endl;
    } else if (i == n - 1) {
      cout << b[i - 1] << endl;
    } else {
      cout << max(b[i - 1], c[i + 1]) << endl;
    }
  }
  
}


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

using namespace std;

#define F first
#define S second

const int INF = (1 << 30);

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	int n;
	cin >> n;
	vector<int> max_pref_balance(n),balance(n);
	vector<int> pos,neg;
	for(int i = 0; i < n; ++i){
		string s;
		cin >> s;
		int len = static_cast<int>(s.size());
		int op = 0, cl = 0;
		for(int j = 0; j < len; ++j){
			if(s[j]=='(')++op;
			else ++cl;
			max_pref_balance[i] = max(max_pref_balance[i],cl-op);
		}
		if(op>=cl){
			pos.push_back(i);
			balance[i] = op - cl;
		}else{
			neg.push_back(i);
			balance[i] = cl - op;
		}
	}
	sort(pos.begin(),pos.end(),[&](const int & a, const int & b){
		return max_pref_balance[a] < max_pref_balance[b];
	});
	int total_balance = 0;
	for(int i = 0; i < (int)pos.size(); i++){
		int id = pos[i];
		if(max_pref_balance[id] > total_balance){
			cout << "No\n";
			return 0;
		}
		total_balance += balance[id];
	}
	sort(neg.begin(),neg.end(),[&](const int & a, const int & b){
		return max_pref_balance[a] - balance[a] > max_pref_balance[b] - balance[b]; 
	});
	
	for(int i = 0; i < (int)neg.size(); i++){
		int id = neg[i];
		if(max_pref_balance[id] > total_balance){
			cout << "No\n";
			return 0;
		}
		total_balance -= balance[id];
	}
	if(total_balance){
		cout << "No\n";
	}else{
		cout << "Yes\n";
	}
	
	return 0;
}


Measured memory_bytes: 15184
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    l = [0] * N
    for i in range(N, 0, -1):
        t = 0
        for j in range(i, N+1, i):
            t += l[j-1]
        l[i-1] = abs(A[i-1] - (t % 2))
    print(sum(l))
    l2 = [i + 1 for i, j in enumerate(l) if j == 1]
    print(' '.join([str(i) for i in l2]))
main()


Measured memory_bytes: 19888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

struct edge {
  int to;
  ll cost;
  edge(int t, ll c): to(t), cost(c) {};
};

using P = pair<ll, int>;

vector<ll> d;
vector<int> par;
void dijkstra(int s, int N, vector<vector<edge>>& G) {
  priority_queue<P, vector<P>, greater<P> > que;
  d = vector<ll>(N, longinf);
  par = vector<int>(N, -1);
  d[s] = 0;
  que.push(P(0, s));

  while(!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;

    for(int i=0; i<(int)G[v].size(); i++) {
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
        par[e.to] = v;
      }
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<vector<edge>> G(3*N);
  rep(i, M) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    rep(j, 3) G[j*N+u].push_back({((j+1)%3)*N+v, 1});
  }
  int s, t;
  cin >> s >> t;
  s--; t--;
  dijkstra(s, 3*N, G);
  cout << (d[t] == longinf ? -1 : d[t]/3) << "\n";
  return 0;
}


Measured memory_bytes: 23200
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(H: int):
    x = 0
    while H > 0:
        H -= 2 ** x
        x += 1

    ans = 0
    while x > 0:
        ans = 2*ans + 1
        x -= 1

    print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    solve(H)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <cstdio>

int n,an,bn,i,j;
int a[10000],b[10000];
int main (){
	n=1;
	while(n){
		scanf("%d",&n);
		if(n==0) break;
		an=0;
		bn=0;
		for (i=0;i<n;i++){
			scanf("%d %d",&a[i],&b[i]);
		}
		for(j=0;j<n;j++){
			if(a[j]>b[j]) an=an+(a[j]+b[j]);
			else if(a[j]<b[j]) bn=bn+(a[j]+b[j]);
			else if (a[j]==b[j]) { 
				an=an+a[j];
				bn=bn+b[j];
			}
		}
		printf("%d %d\n",an,bn);
	}
	return 0;
}

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first


string s;
deque<char> qu;
ll q,t,f,a;
bool rev;
char c;

int main(){
  cin >> s;
  for(auto c:s){
    qu.push_back(c);
  }
  cin >> q;
  while(q--){
    cin >> t;
    if(t==1){
            rev=!rev;
    }
    if(t==2){
        cin >> f >> c;
        if(f==1){
            if(rev){qu.push_back(c);}
            else{qu.push_front(c);}
        }
        else{
            if(rev){qu.push_front(c);}
            else{qu.push_back(c);}
        }
    }
  }
  if(rev){
    while(!qu.empty()){
        cout << *(qu.rbegin());
        qu.pop_back();
    }
    return 0;
  }
  while(!qu.empty()){
    cout << qu.front();
    qu.pop_front();
  }
  return 0;
}

Measured memory_bytes: 1024
k = int(input())
li = [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]
print(li[k-1])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
    #define ull unsigned long long
    # define ll long long
    # define mod 1000000007LL 
    using namespace std;
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll n;
        cin>>n;
        ll t;
        cin>>t;
        ll arr[n];
        queue<ll>check;
        for(int i=0;i<n;i++)
        cin>>arr[i];
        for(int i=0;i<t;i++)
        check.push(arr[i]);
        for(int i=t;i<n;i++)
        {
            ll temp=check.front();
            if(temp<arr[i])
            cout<<"Yes"<<"\n";
            else
            {
                cout<<"No"<<"\n";
            }
            check.pop();
            check.push(arr[i]);
            
        }



        
        return 0;
    }

Measured memory_bytes: 6348
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

struct Seg {
    int l, r;
};
bool operator <(const Seg &a, const Seg &b) { return a.r - a.l < b.r - b.l; }

template<class T>
struct BIT {
    vector<T> bit[2];
    int N;

    BIT(int n): N(n) { for (int i = 0; i < 2; i++) bit[i].assign(n + 1, 0); }

    //[1, n]
    void init(int n) {
        for (int i = 0; i < 2; i++) bit[i].assign(n + 1, 0);
        N = n;
    }

    T sub_sum(int p, int i) {
        T s = 0;
        while (0 < i) {
            s += bit[p].at(i);
            i -= i & -i;
        }
        return s;
    }
    // [1, i], 1-indexed
    T sum(int i) { return sub_sum(0, i) + sub_sum(1, i) * i; }
    // [a, b]
    T sum(int a, int b) { return sum(b) - sum(a - 1); }

    void sub_add(int p, int i, T v) {
        while (i <= N) {
            bit[p].at(i) += v;
            i += i & -i;
        }
    }
    //[a, b] 1-indexed
    void add(int a, int b, T v) {
        sub_add(0, a, -v * (a - 1));
        sub_add(1, a, v);
        sub_add(0, b + 1, v * b);
        sub_add(1, b + 1, -v);
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<Seg> s(n);
    rep(i, n) cin >> s[i].l >> s[i].r;
    sort(s.begin(), s.end());
    
    BIT<int> bit(m);
    int ptr = 0;
    repr(d, 1, m + 1) {
        int res = 0;
        res += n - ptr;
        for (int i = 1; d * i <= m; i++) {
            res += bit.sum(d * i, d * i);
        }
        cout << res << endl;
        
        while (ptr < n && s[ptr].r - s[ptr].l + 1 <= d) {
            bit.add(s[ptr].l, s[ptr].r, 1);
            ptr++;
        }
    }
}

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

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

  // ここにプログラムを追記
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    
    if (i == N - 1) {
      cout << "Three" << endl;
    } 
  } 
}


Measured memory_bytes: 256
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()


n = int(arr_data[0][0])
arr = arr_data[1]
arr2=list(map(int, arr))
arr2.sort(reverse=True)


mysum1=0
mysum2=0

flg=True

for v in arr2:
    
    if flg:
        
        flg=False
        mysum1+=v
        
    else:
        
        flg=True
        mysum2+=v
        

print(mysum1-mysum2)        
        

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;


int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    ll ans=0,now=A[0];
    for(int i=1; i<N; i++){
        if(now>A[i]){
            ans+=now-A[i];
        }else{
            now=A[i];
        }
    }

    cout << ans << endl;
    


    return 0;
}

Measured memory_bytes: 4760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
int main() {
	ll X,Y;
	cin>>X>>Y;
	ll ans=-1;
	ll N=X;
	ll i=1;
	if(X%Y!=0){
		while(N<=1e18){
			if(X*i%Y!=0){
				ans=X*i;
				break;
			}
			i++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long int ll;
 
int main() {
    int n;
    cin>>n;
    double prob[n];
  	for(int i=0; i<n; i++){
      cin>>prob[i];
    }
    
    double dp[n+1][n+1];
    memset(dp, 0.0, sizeof(dp));
    dp[0][0] = 1.0;
    for(int i=1; i<=n; i++){
        for(int j=0; j<=n; j++){
            if(j==0){
                dp[i][j] = (1-prob[i-1]) * dp[i-1][j];
            }
            else{
                dp[i][j] = (1-prob[i-1]) * dp[i-1][j] + prob[i-1] * dp[i-1][j-1];
            }
        }
    }
  	double ans = 0.0;
  	for(int j=(n+1)/2; j<=n; j++){
    	ans += dp[n][j];
    }
    cout << fixed << setprecision(12) << ans;
}

Measured memory_bytes: 74096
MOD = 10**9+7

h, w, a, b = list(map(int, input().split()))
ans = 0

facts = [1]
for i in range(1, h+w-1):
    facts.append((i*facts[i-1])%MOD)
# print(facts[:20])
    
def get_path(n, r):
    return (facts[n] * pow(facts[r], MOD-2, MOD)%MOD * pow(facts[n-r], MOD-2, MOD)%MOD) % MOD

y, x = h-a, b+1
while(True):
    path_0 = get_path(y+x-2, x-1)
    path_1 = get_path(h-y+w-x, w-x)
    # print(y, x, path_0, path_1)
    ans += (path_0*path_1)%MOD
    ans %= MOD

    y -= 1
    x += 1
    if y == 0 or x > w:
        break
    
print(ans)


Measured memory_bytes: 11028
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X;
    cin >> X;
    if(X==3 || X==5 || X==7) cout << "YES" <<endl;
    else cout << "NO" <<endl;
    return 0;
}


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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int i##_to_ = (t), i = (f); i <= i##_to_; i++)
#define uptil(f, t, i)   for(int i##_to_ = (t), i = (f); i <  i##_to_; i++)
#define downto(f, t, i)  for(int i##_to_ = (t), i = (f); i >= i##_to_; i--)
#define downtil(f, t, i) for(int i##_to_ = (t), i = (f); i >  i##_to_; i--)
typedef long double LD;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
#define debug true
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 2
#define _LIBCPP_DEBUG2 2
#define ln << endl
#else
#define debug false
#define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '


int pyon[1<<26];

signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    times(1<<26, i) pyon[i] = INT_MAX-486;
    string S; cin >> S;

    vector<int> d(S.size()+1);
    int z = 0;
    pyon[z] = 0;
    times(S.size(), i) {
        d[i+1] = pyon[z] + 1;
        z ^= 1 << (S[i] - 'a');
        d[i+1] = min(d[i+1], pyon[z] + 1);
        times(26, j) {
            d[i+1] = min(d[i+1], pyon[z ^ (1<<j)] + 1);
        }
        pyon[z] = min(pyon[z], d[i+1]);
        if(debug) cout << z << ":" << pyon[z] sp;
    }

    if(debug) {
        cout ln;
        times(d.size(), i) cout << (i?" ":"") << d[i]; cout ln;
    }

    cout << d[S.size()] ln;

    return 0;
}


Measured memory_bytes: 263572
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 100000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
 
using namespace std ;
 
typedef tree<pair<pll,lli>,null_type,less<pair<pll,lli>>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
 
#define N 100005
 
int main() 
{
/////////////////////////////////////
    
    fastio;
   
/////////////////////////////////////  
   
	char c;
	cin>>c;

	cout<<char(c+1);

}

        
 


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char ** argv)
{
  //
  int a[9];
  bool flg = false;
  for (int i = 0; i < 10; i++) {
    a[i] = 0;
  }
  for (int i = 0; i < 3; i++) {
    int v;
    std::cin >> v;
    a[v]++;
  }

  int max = 0;
  for (int i = 0; i < 10; i++) {
    max = std::max(max, a[i]);
  }
  if (max == 2) {
    std::printf("Yes\n");
  } else {
    std::printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, b, n) for (int i = b; i <= n; ++i)

using namespace std;


void solve(long Q, vector<long> l, vector<long> r) {

  vector<bool> isPrime(1E5+1, true);
  isPrime[0] = false;
  isPrime[1] = false;
  FOR(i, 2, 1E5)
    if (isPrime[i])
      for(long j = 2 * i; j <= 1E5; j += i)
	isPrime[j] = false;
    
  vector<long> count(1E5+1);
  count[0] = 0;
  FOR(i, 0, 1E5)
    if (isPrime[i] && isPrime[(i + 1) / 2])
      count[i] = count[i - 1] + 1;
    else
      count[i] = count[i - 1];
					       
  REP(i, Q)
    cout << count[r[i]] - count[l[i] - 1] << endl;
}

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

  long Q;
  cin >> Q;
  vector<long> l(Q);
  vector<long> r(Q);
  REP(i, Q)
    cin >> l[i] >> r[i];

  solve(Q, move(l), move(r));

  return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <string>

int main() {
  using namespace std;

  int n;
  int ac = 0, wa = 0, tle = 0, re = 0;
  string ans;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ans;
    if (ans == "AC")
      ++ac;
    else if (ans == "WA")
      ++wa;
    else if (ans == "TLE")
      ++tle;
    else if (ans == "RE")
      ++re;
  }

  cout << "AC x " + to_string(ac) << endl;
  cout << "WA x " + to_string(wa) << endl;
  cout << "TLE x " + to_string(tle) << endl;
  cout << "RE x " + to_string(re) << endl;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define MAX 1e9
using namespace std;
int frog1(vector<int>arr,int n)
{
    vector<int>dp(n+1);
    dp[1]=0;
    for(int i=2;i<=n;++i)
    {
        int op1,op2;
        //op1=op2=INT_MAX;
        op1=abs(arr[i]-arr[i-1])+dp[i-1];
        op2=(i==2)? MAX:abs(arr[i]-arr[i-2])+dp[i-2];
        dp[i]=min(op1,op2);
    }
    return dp[n];
    
}
int frog2(vector<int>arr,int n,int k)
{
    vector<int>dp(n+1);
    dp[1]=0;
    for(int i=2;i<=n;++i)
    {
        dp[i]=MAX;
        for(int j=i-1;j>=1 and (i-j)<=k;--j)
        {
            dp[i]=min(dp[i],abs(arr[i]-arr[j])+dp[j]);
        }
    }
    return dp[n];
}
int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    vector<int>arr(n+1);
    for(int i=1;i<=n;++i)
        scanf("%d",&arr[i]);
    //int dp[MAX]={0};
    cout<<frog2(arr, n,k)<<endl;
    
}


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

//-std=c++11
//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long
#define FI ios_base::sync_with_stdio(false); cin.tie(NULL);
#define PREC cout << setprecision(10) << fixed;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 9;
const int MX = 3e5 + 5;

vector<int> inp;

struct SegTree {
    vector<int> tree;

    SegTree(int n) {
        tree.resize(4*n);
    }

    // void build(int node, int st, int en) {
    //     if(st == en) {
    //         tree[node] = inp[st];
    //         return;
    //     } 
    //     int mid = (st + en)/2;
    //     build(2*node, st, mid);
    //     build(2*node + 1, mid + 1, en);
    //     tree[node] = min(tree[2*node], tree[2*node + 1]);
    // }

    void update(int node, int st, int en, int id, int val) {
        if(id < st || id > en) return;
        if(st == en && st == id) {
            tree[node] = max(val, tree[node]);
            return;
        }
        int mid = (st + en)/2;
        update(2*node, st, mid, id, val);
        update(2*node + 1, mid+1, en, id, val);
        tree[node] = max(tree[2*node], tree[2*node + 1]);
    }

    int query(int node, int st, int en, int i, int j) {
        if(i > en || j < st) {
            return 0;
        }
        if(i <= st && en <= j) {
            return tree[node];
        }
        int mid = (st + en)/2;
        int left = query(2*node, st, mid, i, j);
        int right = query(2*node+1, mid+1, en, i, j);
        return max(left, right);   
    }
};

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

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

	int ans = 1;

	SegTree seg(MX);
	seg.update(1, 0, MX - 1, A[0], 1);

	for(int i=1;i<n;i++) {
		int mx = seg.query(1, 0, MX-1, max(0,A[i] - k), min(MX-1, A[i] + k));
		seg.update(1, 0, MX-1, A[i], mx + 1);
		ans = max(ans, mx + 1);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 9076
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
const ll mod=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int n;cin>>n;
  ll l;cin>>l;
  ll x[n+2],c[n+2];
  rep(i,n)cin>>x[i+1]>>c[i+1];
  x[0]=0;
  x[n+1]=l;
  ll left[n+1],right[n+1],lt[n+1],rt[n+1];
  left[0]=right[n+1]=lt[0]=rt[n+1]=0;
  ll pos=0;
  rep(i,n){
    pos+=c[i+1]-x[i+1]+x[i];
    left[i+1]=max(pos,left[i]);
    }
  pos=0;
  rep(i,n){
    pos+=c[n-i]-x[n-i+1]+x[n-i];
    right[n-i]=max(pos,right[n-i+1]);
    }
  pos=0;
  rep(i,n){
    pos+=c[i+1]-2*(x[i+1]-x[i]);
    lt[i+1]=max(pos,lt[i]);
    }
  pos=0;
  rep(i,n){
    pos+=c[n-i]-2*(x[n-i+1]-x[n-i]);
    rt[n-i]=max(pos,rt[n-i+1]);
    }
  ll ans=0;
  rep(i,n+1){
    ans=max(lt[i]+right[i+1],ans);
    ans=max(left[i]+rt[i+1],ans);
    }
  cout<<ans<<endl;
  return 0;
  }

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

int main() {
    int n, b, f, r, v;
    cin >> n;
    int roomInfo[5][4][11] = {0};
    
    for(int i = 0; i < n; i++){
            cin >> b >> f >> r >> v;
            roomInfo[b][f][r] += v;
    }
    for(int i = 1; i <= 4; i++){
        for(int j = 1; j <= 3; j++){
            for(int k = 1; k <= 10; k++){
                cout << " " << roomInfo[i][j][k]; 
            }
            cout << endl;
        }
        if(i != 4){
            cout << "####################" << endl;
        }
    }
	return 0;
}



Measured memory_bytes: 3120
# from sys import exit
H, W = [int(n) for n in input().split()]
h, w = [int(n) for n in input().split()]
# N = int(input())
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
# exit()
print(H*W - h*W - H*w + h*w)


Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

bool yee(char a, char b) {
	return a>b;
}

int main() {
	string a, b;
	while (cin >> a >> b) {
		sort(a.begin(), a.end()); sort(b.begin(), b.end(), yee);
		cout << (a<b ? "Yes\n" : "No\n");
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

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

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

#define BIT_ON(x,b) ((x)|=(b))
#define BIT_OFF(x,b) ((x)&=~(b))
#define BIT_IS_ON(x,b) (((x)&(b))==(b))


using namespace std;

int main(void){
  int A,B,C;
  cin >> A >> B >> C;
  int sum = A+B;
  if (sum >= C) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256