akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;
class carr {
	int** c;
	int level;
	int N;
public:
	carr(int n, int t = 0) {
		N = n;
		for (int i = 0; i < 30; i++) {
			if (1 << i >= n) {
				level = i + 1;
				break;
			}
		}
		c = new int*[level];
		for (int i = 0; i < level; i++) {
			c[i] = new int[1 << (level - 1 - i)];
			for (int j = 0; j < 1 << (level - 1 - i); j++) {
				if (i == 0) {
					c[0][j] = j < n ? t : 0;
				}
				else {
					c[i][j] = c[i - 1][j << 1] + c[i - 1][(j << 1) + 1];
				}
			}
		}
	}
	carr(int n, int *t) {
		for (int i = 0; i < 30; i++) {
			if (1 << i >= n) {
				level = i + 1;
				break;
			}
		}
		c = new int*[level];
		for (int i = 0; i < level; i++) {
			c[i] = new int[1 << (level - 1 - i)];
			for (int j = 0; j < 1 << (level - 1 - i); j++) {
				if (i == 0) {
					c[0][j] = j < n ? t[j] : 0;
				}
				else {
					c[i][j] = c[i - 1][j << 1] + c[i - 1][(j << 1) + 1];
				}
			}
		}
	}
	void cadd(int n, int a = 1) {
		for (int i = 0; i < level; i++) {
			c[i][n >> i] += a;
		}
	}
	void csub(int n, int a = 1) {
		for (int i = 0; i < level; i++) {
			c[i][n >> i] -= a;
		}
	}
	int prev(int n) {
		for (int i = 0; i < level; i++) {
			if (n&(1 << i) && c[i][(n >> i) - 1]) {
				int r = (n >> i) - 1;
				for (int j = i - 1; j >= 0; j--) {
					r <<= 1;
					if (c[j][r | 1])r |= 1;
				}
				return r;
			}
		}
		return -1;
	}
	int next(int n) {
		for (int i = 0; i < level; i++) {
			if ((n&(1 << i)) == 0 && c[i][(n >> i) + 1]) {
				int r = (n >> i) + 1;
				for (int j = i - 1; j >= 0; j--) {
					r <<= 1;
					if (c[j][r] == 0)r |= 1;
				}
				return r;
			}
		}
		return -1;
	}
	int count_before(int n) {
		int res = 0;
		for (int i = 0; i < level; i++) {
			if (n&(1 << i)) {
				res += c[i][(n >> i) - 1];
			}
		}
		return res;
	}
	int count_after(int n) {
		return c[level - 1][0] - count_before(n) - c[0][n];
	}
	int nth(int n) {
		if (n > c[level - 1][0])return -1;
		int r = 0;
		for (int i = level - 1; i >= 0; i--) {
			r <<= 1;
			if (c[i][r] > n) {
				r |= 1;
			}
		}
		return r;
	}
	int min() {
		if (c[0][0])return 0;
		else return next(0);
	}
	int max() {
		if (c[0][N - 1])return N - 1;
		else return prev(N - 1);
	}
};

int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	int *P = new int[N];
	for (int i = 0; i < N; i++)scanf("%d", P + i);
	int res = 1;
	carr c(N);
	for (int i = 0; i < K; i++) {
		c.cadd(P[i]);
	}
	for (int i = 1; i <= N - K; i++) {
		int min = c.min();
		int max = c.max();
		if (P[i - 1] > P[i] || P[i + K - 2] > P[i + K - 1]) {
			res++;
		}
		else if (P[i - 1] != min || P[i + K - 1] < max) {
			res++;
		}
		c.csub(P[i - 1]);
		c.cadd(P[i + K - 1]);
	}
	int noc = 0;
	int a = 0;
	for (int i = 0; i < N - 1; i++) {
		if (P[i] < P[i + 1]) {
			a++;
		}
		else {
			if (a >= K - 1)noc++;
			a = 0;
		}
	}
	if (a >= K - 1)noc++;
	if (noc >= 2)res -= noc - 1;
	printf("%d", res);
	return 0;
}

Measured memory_bytes: 3072
JPY_lst=[]
BTC_lst=[]
for i in range(int(input())):
    a,b=input().split()
    if b=='JPY':
        JPY_lst.append(float(a))
    else:
        BTC_lst.append(float(a))
print(sum(JPY_lst)+sum(BTC_lst)*380000)

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

int N,T,S,A[3000],B[3000];

int dp[3010];
int main(){
    scanf("%d%d%d",&N,&T,&S);
    for(int i=0;i<N;i++)scanf("%d%d",&A[i],&B[i]);


    for(int i=0;i<N;i++){
        for(int j=T;j>=0;j--){
            dp[j]=max(dp[j],dp[j]);
            if(j-B[i]<0||(j>S&&j-B[i]<S))continue;
            dp[j]=max(dp[j],dp[j-B[i]]+A[i]);
        }
    }

    printf("%d\n",*max_element(dp,dp+T+1));
    return 0;
}

Measured memory_bytes: 1220
N, K = map(int, input().split())
S = input()

zero = []
one = []
if S[0] == '0':
    one.append(0)
from itertools import groupby
for k, g in groupby(S):
    if k == '0':
        zero.append(len(list(g)))
    else:
        one.append(len(list(g)))
if S[-1] == '0':
    one.append(0)

if len(zero) <= K:
    print(N)
    exit()

zerob = [0]
oneb = [0]
for i in range(len(zero)):
    zerob.append(zerob[i] + zero[i])
for i in range(len(one)):
    oneb.append(oneb[i] + one[i])

ans = 0
for i in range(K, len(zerob)):
    z = zerob[i] - zerob[i-K]
    o = oneb[i+1] - oneb[i-K]
    ans = max(ans, z+o)

print(ans)


Measured memory_bytes: 47836
n = list(map(int, input().split()))
if n[0] != n[1]:
    if n[1] == n[2]:
        print("Yes")
        exit()
    if n[0] == n[2]:
        print("Yes")
        exit()
    if n[0] != n[2]:
        print("No")
        exit()
if n[0] == n[1]:
    if n[0] != n[2]:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 3064
#ifndef ___Class_RangeTree
#define ___Class_RangeTree

// ------ Includes ------ //
#include <limits>
#include <vector>
#include <algorithm>

template<typename Type> class RangeTree {
private:
	int size_; std::vector<std::vector<Type> > dat;
	inline int query_(int a, int b, Type x, int k, int l, int r) {
		// Find range [a, b) : value < x : Now k-th node and the range is [l, r)
		if (r <= a || b <= l) return 0;
		if (a <= l && r <= b) return lower_bound(dat[k].begin(), dat[k].end(), x) - dat[k].begin();
		int lc = query_(a, b, x, (k << 1), l, (l + r) >> 1);
		int rc = query_(a, b, x, (k << 1) + 1, (l + r) >> 1, r);
		return lc + rc;
	}
public:
	RangeTree() : size_(0), dat(std::vector<Type>()) {};
	template<class T>
	RangeTree(T begin_, T end_) {
		int n = (end_ - begin_);
		for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::vector<Type>());
		for (int i = 0; i < n; i++) dat[i + size_] = std::vector<Type>({ *(begin_ + i) });
		for (int i = size_ - 1; i > 0; i--) {
			dat[i].resize(dat[i << 1].size() + dat[(i << 1) + 1].size());
			std::merge(dat[i << 1].begin(), dat[i << 1].end(), dat[(i << 1) + 1].begin(), dat[(i << 1) + 1].end(), dat[i].begin());
		}
	}
	inline int size() { return size_; }
	inline int query(int l, int r, Type x) {
		// Find range [a, b) : value < x
		return query_(l, r, x, 1, 0, size_);
	}
};

#endif

#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
typedef long long ll;
const ll inf = (1LL << 61);
struct edge { int to; ll cost; };
const bool operator<(const edge& e1, const edge& e2) { return e1.cost < e2.cost; }
int N, M, Q, a, b, c; ll z1, z2; vector<edge> G[100009];
vector<ll> dist(int s) {
	vector<ll> ret(N, inf); ret[s] = 0;
	priority_queue<edge> que; que.push(edge{ s, 0 });
	while (!que.empty()) {
		edge u = que.top(); que.pop();
		for (edge e : G[u.to]) {
			if (ret[e.to] > ret[u.to] + e.cost) {
				ret[e.to] = ret[u.to] + e.cost;
				que.push(edge{ e.to, -ret[e.to] });
			}
		}
	}
	return ret;
}
int main() {
	ios::sync_with_stdio(false);
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++) {
		scanf("%d%d%d", &a, &b, &c);
		G[a].push_back(edge{ b, c });
		G[b].push_back(edge{ a, c });
	}
	vector<ll> res1 = dist(0);
	vector<ll> res2 = dist(N - 1);
	vector<pair<ll, ll> > x0(N);
	for (int i = 0; i < N; i++) x0[i] = make_pair(res2[i], res1[i]);
	sort(x0.begin(), x0.end());
	vector<ll> x1(N), x2(N);
	for (int i = 0; i < N; i++) x1[i] = x0[i].second, x2[i] = x0[i].first;
	RangeTree<ll> q(x1.begin(), x1.end());
	scanf("%d", &Q);
	while (Q--) {
		scanf("%lld%lld", &z1, &z2);
		int ptr = lower_bound(x2.begin(), x2.end(), z2) - x2.begin();
		printf("%d\n", q.query(ptr, N, z1 + 1));
	}
	return 0;
}

Measured memory_bytes: 38980
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

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


signed main(){
  int n;cin>>n;int a[210000];rep(i,n)cin>>a[i];
  int m;int b[210000];rep(i,n)b[i] = a[i];
  sort(b,b+n);m = b[n-1];int mi = b[n-2];
  rep(i,n){
    if(a[i] == m){
      cout << mi << endl;
    }else{
      cout << m << endl;
    }
  }
}


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

int main() {
  int N;
  cin >> N;
  int var=0;
  bool p=0,w=0,g=0,y=0;
  // ここにプログラムを追記
  for(int i=0;i<N;i++){
    string op;



    cin >> op ;
    if (op =="P" && p==0){
      var ++;
      p =1;
    }
    if (op =="W" && w==0){
      var ++;
      w=1;
    }
    if (op =="G" && g==0){
      var ++;
      g=1;
    }
    if (op =="Y" && y==0){
      var ++;
      y=1;
    }


  }
  //cout << var<< endl;
  if (var==3){
    cout << "Three"<< endl;
  }
  if (var==4){
    cout << "Four"<< endl;
  }


}


Measured memory_bytes: 256
n = gets.to_i

x = []
y = []

n.times {
	x1, y1 = gets.split.map &:to_i
	x << x1
	y << y1
}

len = []

(0...n).to_a.permutation(n).each{ |pp|
	sum = 0

	pp.each_cons(2){ |a,b|
		sum += ((x[a] - x[b]) ** 2.0 + (y[a] - y[b]) ** 2.0) ** 0.5
	}
	
	len << sum
}

puts len.inject(:+) / len.size


Measured memory_bytes: 2296
import java.util.*;
public class Main {
	static char[] l = new char[] {'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			int x = stdIn.nextInt();
			int y = stdIn.nextInt();
			int s = stdIn.nextInt();
			if(x == 0 && y == 0 && s == 0) break;
			int ans = 0;
			for (int i = 1; i < s; i++) {
				for(int j = 1; j < s; j++) {
					int a = (int)i*(100+x)/100;
					int b = (int)j*(100+x)/100;
					if(a + b == s) {
						int c = (int)i*(100+y)/100;
						int d = (int)j*(100+y)/100;
						if(ans < c + d) {
							ans = c + d;
						}
					}
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 20936
N = int(input())
a = 0
b = 0
while N > 0:
    if N < 10:
        c = N
        break
    if N % 10 != 9:
        b = 1
    N //= 10
    a += 1
if b == 1:
    c -= 1
ans = c + a * 9
print(ans)


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

maze = [["."for i in range(W)] for j in range(H)]

for h in range(H):
    ret = input()
    for i, x in enumerate(ret):
        if x == "#":
            maze[h][i] = "#"
        # else: # == "."
        #     maze[h][i] = True

# print(maze)

def bfs(maze, y, x):
    q = [[y, x]]
    res = 0
    dist = [[-1] * W for j in range(H)]
    dist[y][x] = 0
    while len(q) > 0:
        yy, xx = q[0]
        res = max(res, dist[yy][xx])
        q.pop(0)
        for dy, dx in [[1,0], [0,1], [-1,0], [0,-1]]:
            ny = yy + dy
            nx = xx + dx
            if nx < 0 or ny < 0 or nx >= W or ny >= H:
                continue
            if maze[ny][nx] == '#':
                continue
            if dist[ny][nx] == -1:
                dist[ny][nx] = dist[yy][xx] + 1
                q.append([ny, nx])
    return res

res_max = 0
for j in range(H):
    for i in range(W):
        if maze[j][i] == '#':
            continue
        res_max = max(res_max, bfs(maze, j, i))
print(res_max)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define MAX 2000005
#define MOD 1000000007
#define endl "\n"
lli arr[MAX];
stack  <lli> z;
stack <lli> o;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	string s1, s2;
	lli a = 0;
	cin>>s1>>s2;
	for(lli i =0; i<s1.length(); i++){
		if(s1[i] != s2[i])
			a++;
	}
	cout<<a<<endl;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  map <int,int> M;
  for(int i=1;i<=N;i++){
  int x;
    cin>>x;
    M[x]=i;
  
  }for(auto p:M){
  auto k=p.first;
    auto v=p.second;
  if(k!=N)
    cout<<M.at(k)<<" ";
    else
      cout<<M.at(N)<<endl;
  }
  
    return 0;
}

Measured memory_bytes: 5504
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    S = list(input())

    ans = [0 for _ in range(len(S))]

    for _ in range(2):
        # solve r
        rcnt = 0
        for idx, s in enumerate(S):
            if s == 'R':
                rcnt += 1
            else:
                # print(rcnt)
                ans[idx] += rcnt // 2
                ans[idx - 1] += (rcnt+1) // 2
                rcnt = 0

        # print(ans)
        ans = ans[::-1]
        S = S[::-1]
        for i in range(len(S)):
            if S[i] == 'L':
                S[i] = 'R'
            else:
                S[i] = 'L'

    for a in ans:
        print(a)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 5804
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin >> s;
  int N = s.size();

  int cnt[26] = {};
  for(int i=0;i<N;i++){
    cnt[s[i] - 'a']++;
  }

  for(int i=0;i<26;i++){
    if(cnt[i]%2==1){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
l=[list(mi()) for _ in range(3)]
ans=0
for i in range(a-1):
  ans+=l[1][l[0][i]-1]
  if l[0][i]+1==l[0][i+1]:
    ans+=l[2][l[0][i]-1]
print(ans+l[1][l[0][a-1]-1])

Measured memory_bytes: 68900
#include <iostream>  
#include <algorithm>  
#include <functional>  
#include <vector>  
#include <map>
#include <string>
#include <queue>
#include <deque> 
#include <cmath>
#include <math.h>
using namespace std;
	double pi=acos(-1);
	#define mod 1000000007
	long long int modexp(long long int a, int b){ 
	long long int t=1;
	while( b != 0){
		if( b%2 == 1)
			t = (t*a)%mod ;
		a = (a*a)%mod;
		b /= 2;
	}
	return t%mod;
}
int main(){
	//freopen("input.txt", "r", stdin);   
 	//freopen("output.txt", "w", stdout);
 	int n=1,m=1;
 	scanf("%d %d",&n,&m);
 	if(n>m){
 		int te=m;
 		m=n;
 		n=te;
 	}
 	long long int ans=1;
 	long long int f=2;
 	int i;
 	for(i=1;i<=n;i++) ans=(ans*i)%mod;
 	long long int ans2=1;
 	for(i=1;i<=m;i++) ans2=(ans2*i)%mod;
 	if(m-n>=2) printf("0\n");
 	else if(m-n==1) printf("%lld\n",(ans*ans2%mod)%mod );
 	else if(m==n) printf("%lld\n", (f*(ans*ans2)%mod)%mod );
	return 0;
}

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

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    int r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {
    int N, X; cin >> N >> X;
    int x[N];
    REP(i, 0, N) {
        cin >> x[i];
        x[i] = abs(x[i] - X);
    }

    int ans = x[0];
    REP(i, 1, N) {
        ans = gcd(ans, x[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include<string>
using namespace std;
 
int main(void){
    string s;
    while(true) {
        cin >> s;
        if(s == "0") {
            break;
        }
        int sum = 0;
        for(int i=0; i < s.size(); i++) {
            
            int n = s[i] - '0';
            sum += n;
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define INF (1e9+1)
int n,a,q[100005],r;
int main(){
	scanf("%d",&n);
	int ans=0,cnt=0,Last=0;
	for(int i=1;i<=n;++i){
		scanf("%d",&a);
		if(Last>=a||i==1)cnt++;
			else cnt=1;
		Last=a;
		ans=max(ans,cnt);
	}
	printf("%d",ans-1);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;

int main() {
	ll t, x; cin >> t >> x;
	cout << (double)t / x << endl;

	return 0;
}

Measured memory_bytes: 256
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

module Util =
    let strRev (s: string): string =
        s
        |> Seq.rev
        |> Seq.map string
        |> String.concat ""

    let inline roundup (x: ^a) (y: ^a): ^a =
        let one = LanguagePrimitives.GenericOne
        (x + y - one) / y

type ModInt(x: int64) =
    static let modulo = (int64 1e9) + 7L

    member __.Value: int64 =
        let y = x % modulo
        match y with
        | _ when y < 0L -> y + modulo
        | _ when y >= modulo -> y - modulo
        | _ -> y

    override __.ToString() = __.Value.ToString()

    override __.Equals(rhs: obj) =
        match rhs with
        | :? ModInt as rhs -> __.Value = rhs.Value
        | _ -> false

    override __.GetHashCode() = __.Value ^^^ modulo |> int

    static member (+) (lhs: ModInt, rhs: ModInt) = ModInt(lhs.Value + rhs.Value)

    static member (-) (lhs: ModInt, rhs: ModInt) = ModInt(lhs.Value - rhs.Value)

    static member (*) (lhs: ModInt, rhs: ModInt) = ModInt(lhs.Value * rhs.Value)

    /// フェルマーの小定理
    /// a / b = a * b^-1 (mod p)
    /// b * b^p-2 = 1 (mod p) -> 両辺に b^-1 を掛けて、b^p-2 = b^-1 (mod p)
    static member (/) (lhs: ModInt, rhs: ModInt) = lhs * (rhs ** (modulo - 2L))

    /// **
    /// 繰り返し二乗法
    static member Pow(n: ModInt, m: int64) =
        let mutable res = ModInt(1L)
        let mutable n = n
        let mutable m = m
        while m > 0L do
            if (m &&& 1L) = 1L then res <- res * n
            n <- n * n
            m <- m >>> 1
        res

[<EntryPoint>]
let main _ =
    let n = read int64

    let mutable ans = ModInt(1L)
    for i in 1L..n do ans <- ans * ModInt(i)

    printfn "%A" ans
    0 // return an integer exit code


Measured memory_bytes: 18008
#include<cstdio>
using namespace std;
int main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	int b=(y-2*x)/2;
	int a=x-b;
	if((a+b==x&&2*a+4*b==y)&&(a>=0)&&(b>=0))printf("Yes\n");
	else printf("No\n");
	//printf("%d %d\n",a,b);
	return 0;
} 

Measured memory_bytes: 1660
#include<cstdio>
int main(){
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	printf("%d %d %f",d,r,f);
	return 0;
}


Measured memory_bytes: 2728
from itertools import takewhile
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
#print(X,A)
lmt=len(list(takewhile(lambda x:x<X,A)))
#print(list(takewhile(lambda x:x<X,A)))
#print(lmt)
ans=min(lmt,M-lmt)
print(ans)

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

int main(){
  int a,b;
  cin>>a>>b;
  int N;
  cin>>N;
  int s,f;
  for(int i=0;i<N;i++){
    cin>>s>>f;
    if(a<f && b>s){
      cout<<1<<endl;
      return 0;
    }
    else if(a==s&&b==f){
      cout<<1<<endl;
      return 0;
    }
  }
  cout<<0<<endl;
  return 0;
}



Measured memory_bytes: 3100
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanInit()
	K := scanInt()
	sum := 0
	for i:= 1; i<=K; i++ {
		for j:=1; j<=K; j++ {
			c := gcd(i,j)
			for r:= 1; r<=K; r++{
				k := gcd(c,r)
				sum += k
			}
		}
	}
	fmt.Println(sum)
}
func gcd(a,b int) int {
	if b == 0 {
		return a
	}
	return gcd(b,a%b)
}
var sc = bufio.NewScanner(os.Stdin)
func scanInit () {
	sc.Split(bufio.ScanWords)
}
func scanInt () int{
sc.Scan()
	i,_ := strconv.Atoi(sc.Text())
	return i
}
//func scan () string{
//  sc.Scan()
//	return sc.Text()
//}


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
template<typename T>
void fin(std::vector<T>const& t, char delim=' '){
  if(t.size() > 0) {
    for(int i = 0; i < t.size() -1; ++i) std::cout << t[i] << delim;
    std::cout << t.back();
  }
  std::cout << std::endl;
  exit(0);
}

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N, K; std::cin >> N >> K;
  std::vector<int> A(N), B(N+1);
  for(auto& Ai: A) std::cin >> Ai;

  for(int i = 0; i < K; ++i) {
    std::fill_n(B.begin(), N, 0);
    for(int i = 0; i < N; ++i) {
      int l = std::max(0, i-A[i]), r = std::min(N-1, i+A[i]);
      ++B[l]; --B[r+1];
    }
    for(int i = 1; i < N; ++i) B[i] += B[i-1];
    int cnt = 0;
    for(auto& Bi: B) if(Bi == N) ++cnt;
    if(cnt == N) break;
    std::copy_n(B.begin(), N, A.begin());
  }
  B.pop_back();
  fin(B);
  return 0;
}


Measured memory_bytes: 5212
a,b,k=map(int,input().split())

if a+b<=k:
    print(0,end=" ")
    print(0)
    #exit()
elif a<=k:
    print(0,end=" ")
    print(b-(k-a))
    #exit()
else:
    print(a-k,end=" ")
    print(b)

Measured memory_bytes: 3060
from sys import stdin
n,m = map(int,stdin.readline().split())
di = {}
for _ in xrange(n):
    a = stdin.readline().strip()
    for i in a:
        di[i] = di.get(i,0) + 1
ev = 0
od = 0
for i in di:
    if di[i]%4==2:
        ev+=1
    elif di[i]%4==3:
        od+=1
        ev+=1
    elif di[i]%4==1:
        od+=1
ans = 'Yes'
if od>1:
    ans = 'No'
elif (n*m)%2==0 and od>0:
    ans = 'No'
else:
    if n%2==0 and m%2==0:
        if ev > 0:
            ans = 'No'
    elif n%2==0:
        if ev > n/2:
            ans = 'No'
    elif m%2==0:
        if ev > m/2:
            ans = 'No'
    else:
        if ev > (n/2) + (m/2):
            ans = 'No'
print ans

Measured memory_bytes: 2696
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	fmt.Printf("%s\n", ABC086A(a, b))
}

// ABC086A ...
func ABC086A(a, b int) string {
	if a%2 == 0 || b%2 == 0 {
		return "Even"
	}
	return "Odd"
}


Measured memory_bytes: 1832
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
      InputStream inputStream = System.in;
      OutputStream outputStream = System.out;
      Scanner sc = new Scanner(inputStream);
      PrintWriter out = new PrintWriter(outputStream);
      String a = sc.next();
      String b = sc.next();
      int ab = Integer.parseInt(a + b);
      double number = Math.sqrt(ab);
      if(number == Math.floor(number)){
      	out.println("Yes");
      }else{
      	out.println("No");
      }
      out.close();
    }
}

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

int main() {
  int N;
  cin >> N;
  if (N % 10 == 3) {
    cout << "bon" << endl;
  }
  else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) {
    cout << "pon" <<endl;
  }
  else {
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,b=0,i,ans=0,j,c=1;
    cin>>n;
    int a[n+2];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0; i+1<n; i++)
    {
        if(a[i]==a[i+1])
        {
            b++;
            if(b%2==0)
            {
                c++;
            }
            else c--;
        }
        else
        {
            c++;
            b=0;
        }
    }
    cout<<c<<endl;

}


Measured memory_bytes: 640
# -*- coding:utf-8 -*-
import sys


def allcation(truck, baggage, limit):
    t = 1
    cap = 0
    for weight in baggage:
        if weight <= limit:
            if cap + weight <= limit:
                cap += weight
            else:
                cap = weight
                t += 1

            if t > truck:
                return False
        else:
            return False
    return True


def bin_search(truck, baggage):
    small = 0
    big = 10000 * 100000
    minimum = 0
    while small < big:
        mid = (small + big) >> 1
        if allcation(truck, baggage, mid):
            big = mid
            minimum = mid
        else:
            small = mid + 1

    return minimum


if __name__ == "__main__":
    n = [int(val) for val in input().split()]
    lst = [int(val) for val in sys.stdin.read().splitlines()]
    print(bin_search(n[1], lst))

Measured memory_bytes: 18464
$d[1]=1;map{if(!$p[$i=$_]){@p[map$i*$_,@@]=@@;$k=-$_,map$d[$k*++$_]+=$d[$k],1..map{grep$'%$i**$_<1,//..9}@@for-75..0}}@@=2..<>;print$d[75]+0

Measured memory_bytes: 896
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    ll l=0;
    ll r=0;
    vin a(n);
    rep(i,n){
        cin>>a[i];
        r+=(ll)a[i];
    }
    ll m=INF;
    rep(i,n-1){
        l+=a[i];
        r-=a[i];
        m=(ll)min(m,abs(r-l));
    }
    cout<<m<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void) {
   int A,B,K,N,i;

   scanf("%d",&K);
   scanf("%d %d",&A,&B);

   for(N=A;N<=B;N++){

   if (N % K ==0) { 
   printf("OK"); 
     return 0;
   }

}
printf("NG");
return 0;
}

Measured memory_bytes: 1728
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 数値の入力
        int a = sc.nextInt();
        int b = sc.nextInt();

        int pro = b;
        int target = 1;
        // 整数NをK進数で表した時のパターン
        while ( pro <= a) {
        	target ++;
        	pro *= b;
        }

        System.out.println(target);
    }
}


Measured memory_bytes: 21076
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=1005,M=5005;

int v[M],nxt[M];
int head[N],sum[N],x[N],par[N];
bool can[M];
int n;

il void addedge(int p,int x,int y){
    v[p]=y,nxt[p]=head[x],head[x]=p;
}

il void dfs(int u){
    if(!head[u]){
        sum[u]=x[u];
        return;
    }
    int minsum=0;
    for(int e=head[u];e;e=nxt[e]){
        dfs(v[e]);
        minsum+=qmin(x[v[e]],sum[v[e]]-x[v[e]]);
        sum[u]+=sum[v[e]];
    }
    if(minsum>x[u]){
        puts("IMPOSSIBLE");
        exit(0);
    }
    int need=x[u]-minsum;
    memset(can,0,sizeof(can));
    can[0]=1;
    for(int e=head[u];e;e=nxt[e]){
    	int val=abs(sum[v[e]]-2*x[v[e]]);
    	per(i,need,val) can[i]|=can[i-val];
	}
    int mx=need;
    while(!can[mx]) --mx;
    sum[u]+=need-mx;
}

int main(){
    scanf("%d",&n);
    rep(i,2,n){
        scanf("%d",par+i);
        addedge(i,par[i],i);
    }
    rep(i,1,n) scanf("%d",x+i);
    dfs(1);
    puts("POSSIBLE");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;

void solve(){
    int n, ans=0;
    cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; i++) cin >> p[i];
    int _min = p[0];
    for(int i=0; i<n; i++){
        if(min(_min, p[i]) == p[i]){
            _min = p[i];
            ans++;
        }
    }
    cout << ans << endl;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


Measured memory_bytes: 1024
// I look at my watch
// it say nine twenty-five
// And I think oh God
// I'm still alive
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;




int main(){	
	int R,G,a,b,c;cin>>R>>G>>a>>b>>c;
	vector<ii>app;
	For(i,0,a){
		int val;cin>>val;
		app.pb({val,0});
	}
	For(i,0,b){
		int val;cin>>val;
		app.pb({val,1});
	}
	For(i,0,c){
		int val;cin>>val;
		app.pb({val,2});
	}
	sort(app.rbegin(),app.rend());
	int r=0,g=0,w=0;
	ll ans=0;
	For(i,0,sz(app)){
		if(r==R&&app[i].ss==0)continue;
		if(g==G&&app[i].ss==1)continue;
		if(app[i].ss==0)r++;
		if(app[i].ss==1)g++;
		if(app[i].ss==2)w++;
		ans+=app[i].ff;
		if(r+g+w==R+G)break;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 6384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

struct E{
	vector<int> ov;
	int color;
	int x, y, r;
	E(int _x, int _y, int _r, int _c){
		color = _c;
		x = _x;
		y = _y;
		r = _r;
	}
};

bool dp[(1<<25)] = {0};
int main(){
	int n;
	while(cin >> n, n){
		int x, y, r, c, _ans=0;
		vector<E> e;
		queue<int> que;
		for(int i=0; i<n; i++){
			cin >> x >> y >> r >> c;
			E tmp(x,y,r,c);
			for(int j=0; j<e.size(); j++){
				if( (e[j].x-x)*(e[j].x-x) + (e[j].y-y)*(e[j].y-y) < (e[j].r+r)*(e[j].r+r) ){
					tmp.ov.push_back( j );
				}
			}
			e.push_back( tmp );
		}
		fill(dp, dp+(1<<25), false);
		dp[0] = true;
		que.push(0);
		int ans=0;
		while( !que.empty() ){
			int i = que.front();
			que.pop();
			if(dp[i]){
				_ans = 0;
				for(int v=1; v<(1<<n); v<<=1){
					if( v & i )
						_ans++;
				}
				ans = max(ans, _ans);
				for(int k=0; k<n; k++){
					for(int l=0; l<k; l++){
						if( k != l && !(i&(1<<k)) && !(i&(1<<l)) && e[k].color == e[l].color){
							bool f=true;
							for(int j=0; j<e[k].ov.size(); j++){
								if( !(i & (1<<e[k].ov[j])) ){
									f=false;
									break;
								}
							}
							for(int j=0; f&&j<e[l].ov.size(); j++){
								if( !(i & (1<<e[l].ov[j])) ){
									f=false;
									break;
								}
							}
							if( f ){
								if( !dp[ i | (1<<k) | (1<<l) ] ){
									dp[ i | (1<<k) | (1<<l) ] = true;
									que.push( i | (1<<k) | (1<<l) );
								}
							}
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 35360
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a % b)

N = int(input())
A = list(map(int, input().split(" ")))

A.sort()

l = [0]
m = A[0]
for i in range(1, N):
    tmp = gcd(m, A[i])
    if tmp < m:
        l.append(i)
    m = tmp
    # print(m)

max_num = m
for l_i in l:
    b = A.copy()
    b.pop(l_i)
    x = b[0]
    for i in range(1, N-1):
        # print("a:", i)
        x = gcd(x, b[i])
    # print(x)
    max_num = max(max_num, x)

print(max_num)

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

int main(void){
    int a, b, cnt = 0, sum;
    cin >> a >> b;

//b==1のとき（電源タップがいらないとき）
    if(b==1){
        cout << 0 << endl;
    return 0;
    }
    //電源タップが必要なとき
    cnt = (b - 1) / (a - 1);
    if((cnt*(a-1)+1)>=b)
        cout << cnt << endl;
    else
        cout << cnt + 1 << endl;

    return 0;
}

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

int main(){
  int n,*d,ans=0;
  cin >> n;
  d = new int[n];
  for(int i=0;i<n;i++){
    cin >> d[i];
  }

  for(int j=0;j<n;j++){
    for(int k=0;k<n;k++){
      if(j==k){ continue; }
        ans += d[j]*d[k];
    }
  }
  cout << ans/2;
  delete d;
  return 0;
}

Measured memory_bytes: 256
from collections import deque
n,m  = map(int, input().split())
r = [[] for _ in range(n+1)]
ans = [0]*(n+1)
for i in range(m):
  a,b  = map(int, input().split())
  r[a].append(b)
  r[b].append(a)

q = deque([1])
while q:
  fr = q.popleft()
  for i in r[fr]:
    if ans[i] != 0:
      continue
    ans[i] = fr
    q.append(i)
print("Yes")
for i in ans[2:]:
  print(i)

Measured memory_bytes: 34848
#include <iostream>
#include <set>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

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

  set<int> st;
  int d;
  rep(i, N) {
    cin >> d;
    st.insert(d);
  }

  cout << st.size() << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
template <class T, class S> ostream& operator<<(ostream& s, unordered_map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n, k; cin >> n >> k;
  if (k == 1) {
    cout << 0 << endl; return 0;
  }
  cout << n - k << endl;
}


Measured memory_bytes: 384
//
//  AAAAAB.cpp
//  my_programs
//
//  Created by Jiatuo Zou on 7/22/20.
//  Copyright © 2020 Jiatuo Zou. All rights reserved.
//

#include <iostream>
#include <string>

int main()
{
    using namespace std;
    
    int q, t, f, total = 0;
    string s;
    char c;
    cin >> s >> q;
    for(int i = 0; i < q; i++){
        cin >> t;
        if(t == 2){
            cin >> f >> c;
            if(total % 2 == 0){
                f == 1 ? s = c + s : s += c;
            } else{
                f == 1 ? s += c : s = c + s;
            }
        } else{
            total++;
        }
    }
    if(total % 2 == 0){
        cout << s << endl;
    } else{
        for(int i = s.length() - 1; i >= 0; i--){
            cout << s[i];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 4612
#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <cmath>
using namespace std;
int main(void){
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int k = n / r;
    int ans = 0;
    for(int i=0; i<k+1; i++){
        int l = (n - r*i)/g;
        for(int j=0; j < l+1; j++){
            if((n-r*i-j*g)%b == 0){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

c = 0
n = int(input())
l = list(map(int,input().split()))

l_cm = lcm_list(l)

for i in range(0,n):
    c = c + l_cm//l[i]
print(c%(10**9 + 7))

Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct FenwickTree{
  static const int SIZE = 1<<17;
  int n, tree[SIZE+1];
public:
  FenwickTree(int n_){
    n = n_;
    for(int i=0; i<n+1; i++) tree[i] = 0;
  }
  void add(int i, int value){
    for(; i<n; i|=i+1) tree[i] += value;
  }
  int sum(int i){
    int s = 0;
    for(; i>=0; i=(i&i+1)-1) s += tree[i];
    return s;
  }
};

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


int main(){
  int N, M, Q;
  cin >> N >> M >> Q;

  vector<ST> v;
  rep(i,M){
    int l, r;
    cin >> l >> r;
    v.push_back((ST){l,r,0});
  }
  sort(ALLOF(v));
  
  vector<ST> w;
  rep(i,Q){
    int p, q;
    cin >> p >> q;
    w.push_back((ST){p,q,i});
  }
  sort(ALLOF(w));

  const int SZ = 1<<17;
  FenwickTree ft(SZ);

  vector<int> ret(Q);
  
  int vi = v.size()-1;
  for(int i=w.size()-1; i>=0; i--){
    while(vi>=0 && v[vi].l >= w[i].l){
      ft.add(v[vi].r, 1);
      vi--;
    }
    ret[w[i].i] = ft.sum(w[i].r);
  }

  rep(i,ret.size()){
    cout << ret[i] << endl;
  }
  
  return 0;
}



Measured memory_bytes: 7024
import java.util.*;
class Main {
    public static void main(String [] args){

                Scanner sc = new Scanner(System.in);

                    String s= sc.next();
                    ArrayList<Integer> res = new ArrayList<>();
                    for(int i=0;i<s.length();i++){

                        if(s.charAt(i)=='R'){
                            int c=0;
                            while( i <= s.length()-1 && s.charAt(i)!='S' ){
                                i++;
                                c++;
                            }
                            res.add(c);
                            i=i-1;
                        }
                        else{
                            continue;
                        }
                    }

                    int max= Integer.MIN_VALUE;
                    for(int i: res){
                        max=Math.max(max,i);
                    }
                    if(max<0){
                        System.out.println("0");
                    }
                    else
                    System.out.println(max);
                }
            }

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

using namespace std;

main()
{
    int a, b, cnt=0;
    
    string s;
    
    cin>>a>>b>>s;
    
    int l = s.size();
    
   
         for(int i=0; i<l; i++)
         {
            if(s[i]=='-' && i!=a)
            {
                cout<<"No"<<endl;
                return 0;
            }
            else if(s[i]=='-')
            {
               cnt++;
            }
        }
    
    
    if(cnt!=1) cout<<"No"<<endl;
    
    else if(cnt==1 && l==a+b+1) cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
w = [int(input()) for _ in range(n)]
left = max(w)-1
right = sum(w)

while (right - left) > 1:
    mid = (left + right)//2
    count = 1
    c = 0
    for s in w:
        if mid < c + s:
            c = s
            count += 1
        else:
            c += s
    if count <= k:
        right = mid
    else:
        left = mid
print(right)


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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}

//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}

//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}

//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}



int main(){
  int a, b, n;
  cin >> a >> b >> n;
  int c;
  c = max(a, b);
  int ans = n / c;
  if(ans * c >= n) cout << ans << endl;
  else cout << ans + 1 << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int ans=0;
	ans+=c*min(a,b);
	ans+=d*max(a-b,0);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x, y;
  cin >> x >> y;
  cout << x + y / 2 << endl;
  return 0;
}


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

int dx[]={0,0,-1,1};
int dy[]={-1,1,0,0};
int main(){
  int height,width; cin >> height >> width;
  char maze[height][width];
  for(int h=0;h<height;h++)  for(int w=0;w<width;w++) cin >> maze[h][w];

  vector<vector<int>> dist(height,vector<int>(width,-1));
  
  vector<vector<int>> prev_x(height,vector<int>(width,-1));
  vector<vector<int>> prev_y(height,vector<int>(width,-1));

  queue<pair<int,int>> que;

  for(int i=0;i<height;i++){
    for(int j=0;j<width;j++){
      if(maze[i][j]=='#') {
        que.push(make_pair(i,j));
        dist[i][j]=0;
      }
    }
  }

  while(!que.empty()){
    const auto current = que.front();
    const int x=current.first;
    const int y=current.second;
    que.pop();

    for(int i=0;i<4;i++){
      int next_x=x+dx[i];
      int next_y=y+dy[i];

      if(next_x<0||next_y<0||next_x>=height||next_y>=width)continue;
      if(maze[next_x][next_y]=='.'){
        maze[next_x][next_y]='#';
        que.push(make_pair(next_x,next_y));
        dist[next_x][next_y]=dist[x][y]+1;
        prev_x[next_x][next_y]=x;
        prev_y[next_x][next_y]=y;
      }
    }
  }
  int ans=0;
  for(int i=0;i<height;i++){
    for(int j=0;j<width;j++){
      ans=max(ans,dist[i][j]);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 21264
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] strs = br.readLine().split(" ");
		int[] inputData = new int[n];
		for (int i = 0; i < n; i++) {
			inputData[i] = Integer.parseInt(strs[i]);
		}
		int swapCnt = bubbleSort(inputData, n);
		printArray(inputData);
		System.out.println(swapCnt);

	}

	public static int bubbleSort(int[] A, int N) {
		int swapCnt = 0;
		boolean flag = true;
		while (flag) {
			flag = false;
			for (int i = N - 1; i > 0; i--) {
				if (A[i] < A[i - 1] ) {
					int temp = A[i];
					A[i] = A[i - 1];
					A[i - 1] = temp;
					swapCnt++;
					flag = true;
				}
			}
		}
		return swapCnt;
	}

	public static void printArray(int[] target) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < target.length; i++) {
			sb.append(target[i]);
			if (i < target.length - 1) {
				sb.append(" ");
			}
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 24208
n, l = gets.split.map(&:to_i)
apples = Array.new(n) { nil }
apples = apples.map.with_index { |a, i| l + i }
min_abs = apples[0]
apples.each do |a|
  min_abs = a if min_abs.abs > a.abs
end
puts apples.inject(:+) - min_abs


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    FOR(i, 1, s.size()) {
        if (s[i] == s[i - 1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
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; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int main(){
  ll a,b; cin >> a >> b;
  ll x; cin >> x;
  ll r=b/x;
  if(a!=0){
    r -= (a-1)/x;
  }else{
    r += 1;
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
	int n,a[100005],d[100005],maxs=0;
	scanf("%d",&n);
	memset(d,0,sizeof(d));
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		d[a[i]]++;
	} 
	for(int i=0;i<n;i++)
	{
		int x=a[i];
		int t;
		if(x==0)t=d[0]+d[1];
		else t=d[x-1]+d[x]+d[x+1];
		maxs=max(maxs,t);
	}
	printf("%d\n",maxs);
	return 0;
}

Measured memory_bytes: 1024