akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <map>
#define int long long
using namespace std;
const int mod=1000000007;
char str[12][100];
signed main()
{
    int n;
    scanf("%lld",&n);
    for(int i=0;i<2;i++)
	{
        scanf("%s",str[i]);
    }
    bool flag=false;
    int f=0;
    int t=1;
    for(int i=0;i<n;i++){
        if(str[0][i]==str[0][i+1]){
            if(f==0){
                t*=3;
                t*=2;
                f=1;
            } else {
                if(flag){
                    t*=2;
                    t*=1;
                } else {
                    t*=3;
                }
            }
            flag=false;
            i++;
        } else {
            if(str[0][i]==str[1][i]){
                if(f==0){
                    t*=3;
                    f=1;
                } else {
                    if(flag) 
					t*=2;
                    else 
					t*=1;
                }
                flag=true;
            }
        }
        t%=mod;
    }
    cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 256
#AGC015-B
if False:
    S=list(input())
    N=len(S)
    ans=0
    for i in range(N):
        if S[i]=='U':
            ans+=N-(i+1)
            ans+=i*2
        else:
            ans+=(N-(i+1))*2
            ans+=i
    print(ans)
            
#ARC069-C
if False:
    N,M=map(int,input().split())
    ans=min(N,M//2)
    if N<(M//2):
        ans+=((M//2-N)*2+(M%2))//4
    print(ans)

#ABC028-D
if False:
    N,K=map(int,input().split())
    ans=3*(N-1)+6*(K-1)*(N-K)+1
    ans=ans/(N**3)
    print(ans)

#ABC133-D
if False:
    N=int(input())
    A=[int(i) for i in input().split()]
    ANS=[sum(A)-2*sum(A[1::2])]
    for i in range(N-1):
        ANS.append(2*A[i]-ANS[-1])
    print(*ANS)

#ARC066-C
N=int(input())
A=[int(i) for i in input().split()]
const=10**9+7
cnt={}
ans=0
flag=True
if N%2==0:
    for k in range(N):
        cnt[k]=0
    for a in A:
        cnt[a]+=1
    for k in range(1,N,2):
        if cnt[k]!=2:
            flag=False
            break
    if flag: ans=pow(2,N//2,const)
else:
    for k in range(N):
        cnt[k]=0
    for a in A:
        cnt[a]+=1
    for k in range(0,N,2):
        if k==0:
            if cnt[0]!=1:
                flag=False
                break
        else:
            if cnt[k]!=2:
                flag=False
                break
    if flag: ans=pow(2,(N-1)//2,const)
print(ans)
    

Measured memory_bytes: 20704
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*


fun main(args: Array<String>) {
    val inputReader = InputReaderc(System.`in`)

    val s = inputReader.nextLine().split(" ").map { i -> i.toLong() }

    print(lcm(s[0], s[1]))
}

fun lcm(i: Long, j: Long): Long {
    return (i * j) / gcd(i, j)
}

fun gcd(i: Long, j: Long): Long {
    return if (i == 0L) j else gcd(j % i, i)
}

class InputReaderc(stream: InputStream) {
    private var reader: BufferedReader = BufferedReader(InputStreamReader(stream))
    private var tokenizer: StringTokenizer? = null

    init {
        tokenizer = null
    }

    operator fun next(): String {
        while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }

    fun nextInt(): Int {
        return Integer.parseInt(next())
    }

    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }

    fun nextDouble(): Double {
        return java.lang.Double.parseDouble(next())
    }

    fun nextLine(): String {
        var str = ""
        try {
            str = reader.readLine()
        } catch (e: IOException) {
            e.printStackTrace()
        }

        return str
    }
}


Measured memory_bytes: 35636
import sys,os
from collections import defaultdict, deque
from math import ceil, floor, inf
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
class Combinations:
    def __init__(self,n,p):
        self.n = n
        self.p = p
        self.g1 = [1,1]
        self.g2 = [1,1]
        inverse = [0,1]
        for i in range(2, self.n + 1):
            self.g1.append( ( self.g1[-1] * i ) % self.p )
            inverse.append( ( -inverse[self.p % i] * (self.p//i) ) % self.p )
            self.g2.append( (self.g2[-1] * inverse[-1]) % self.p )
    def nCr(self,r):
        if r < 0 or self.n < r:
            return 0
        r = min(r, self.n-r)
        return self.g1[self.n] * self.g2[r] * self.g2[self.n-r] % self.p

def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD =  998244353

    N,M,K = LMIIS()
    ans = 0
    cmb = Combinations(N-1,MOD)
    #i個のブロックを連結、全体でN-i個、どこを連結させるかは(N-1)Ci通り
    powtable = [0] * N
    powtable[N-K-1] = M * pow(M-1,N-K-1,MOD) % MOD
    for i in range(N-K,N):
        powtable[i] = powtable[i-1] * (M-1) % MOD

    for i in range(K+1):
        ans += powtable[N-i-1] * cmb.nCr(i)
        ans %= MOD
    # for i in range(K+1):
    #     ans += M * pow(M-1,N-i-1,MOD) * cmb.nCr(i)
    #     ans %= MOD
    print(ans)

    

if __name__ == '__main__':
    main()

Measured memory_bytes: 111424
import math
a, b, h, m = list(map(int, input().split()))

l = m * 6
s = h * 30 + m * 0.5
theta = abs(l - s)

c = a*a + b*b - 2*a*b*math.cos(math.radians(theta))
print('{:.15f}'.format(math.sqrt(c)))

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

int main(){
    ll n;
    cin >> n;
    cout << (n-1)/2 << endl;
}

Measured memory_bytes: 256
from collections import defaultdict

N=input()

Parts=defaultdict(lambda: 0)

for i in range(1,N+1):
	num_sqrt=int(i**0.5)+2

	for n in range(2,num_sqrt):
		while i%n==0:
			i/=n
			Parts[n]+=1
	else:
		if i!=1:
			Parts[i]+=1


C=defaultdict(lambda: set()) 
for val,cnt in  Parts.items():
	#print val,cnt
	if 0<=cnt: C[1].add(val)
	if 2<=cnt: C[3].add(val)
	if 4<=cnt: C[5].add(val)
	if 14<=cnt: C[15].add(val)
	if 24<=cnt: C[25].add(val)
	if 74<=cnt: C[75].add(val)

ans=0
#25,3
for x in C[25]:
	for y in C[3]:
		if x!=y:	ans+=1

#15,5
for x in C[15]:
	for y in C[5]:
		if x!=y:	ans+=1

#5,5,3
for x in C[5]:
	for y in C[5]:
		for z in C[3]:
			if x<y and x!=z and y!=z:	ans+=1

#75
ans+=len(C[75])

print ans

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

using namespace std;
using ll = long long;

int main() {
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  double s = (double)w * (double)h / 2.0;
  if (x + x == w && y + y == h) {
    cout << fixed << setprecision(10) << s << " " << '1' << endl;
  } else {
    cout << fixed << setprecision(10) << s << " " << '0' << endl;
  }
  return 0;
}


Measured memory_bytes: 3768
n,k=map(int,input().split())
t=list(map(int,input().split()))
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
ans=t[0]
for i in range(n):
    ans=gcd(ans,t[i])
if k%ans==0:
    if k<=max(t):
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")


Measured memory_bytes: 14096
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int n;
    cin >> n;
    int A[n];
    REP(i,n) cin >> A[i];

    int ma = -1;
    int res = 0;
    REP(i,n){
        if(ma <= A[i]){
            res ++;
            ma = A[i];
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
s = input()
n = len(s) - 1
answers = []
sl = [s[i] for i in range(len(s))]
for i in range(2 ** n):
    tmp = []
    for j in range(n):
        if ((i >> j) & 1):
            tmp.append(j)
    ll = ['*']*len(s)
    for k in tmp:
        ll[k] = '+'
    ans = []
    for k, _ in zip(sl, ll):
        ans.append(k)
        ans.append(_)
    ans = [_ for _ in ans if _ != '*']
    ans = ''.join(ans)
    ans = ans.split('+')
    ans = [int(_) for _ in ans if _ != '+']
    ans = sum(ans)
    answers.append(ans)
print(sum(answers))


Measured memory_bytes: 3064
s=list(input())
import copy
d=copy.copy(s)
x=0
y=1
for i in range(len(s)-1):
  if s[i]==s[i+1]:
    if s[i+1]=='1':
       s[i+1]='0'
    else:s[i+1]='1'
    x+=1
if d[0]=='1':
  d[0]='0'
else:d[0]='1'
for i in range(len(d)-1):
  if int(d[i])==int(d[i+1]):
    if d[i+1]=='1':
      d[i+1]='0'
    else:d[i+1]='1'
    y+=1
print(min(x,y))

Measured memory_bytes: 5032
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include <iostream>
#include<stdlib.h>
//#include <algorithm>
#include <limits>
#include<string>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
struct DSU{
  ll num;
  ll size;
};
DSU *par;//親の番号
//n要素で初期化
void init(int n){
  rep(i,n){
    par[i].num=i;
    par[i].size=1;
  }
  return;
}
//木の根を求める
ll root(ll x){
  if(par[x].num==x){
    return x;
  }else{
    ll r = root(par[x].num);
    par[x].num=r;
    return r;//経路圧縮
  }
}

//x,yが同じ集合に属するか否か
bool same(ll x,ll y){
  if(root(x)==root(y)){
    return true;
  }else{
    return false;
  }
}
//x,yの属する集合を併合
void unite(ll x,ll y){
  if(same(x,y)==true){
    return;
  }
  par[root(x)].size+=par[root(y)].size;
  par[root(y)].size=par[root(x)].size;
  par[root(y)].num=root(x);
  return;
}
ll size(ll x){
  ll sum = par[root(x)].size;
  return sum;
}
int main(void){
	ll N,M;
  cin >> N >> M;
  par = (DSU*)malloc(sizeof(DSU)*N);
  init(N);
  ll ans[M+1];
  ll Na=1;
  ll Nb=1;
  ll a[M],b[M];
  rep(i,M){
    cin >> a[i] >> b[i];
    a[i]-=1;
    b[i]-=1;
  }
  ans[M]=(N*(N-1))/2;
  for(int i=M-1;i>=1;i--){
    if(same(a[i],b[i])==true){
      Na=0;Nb=0;
      //cout << "same";
      ans[i]=ans[i+1];
      continue;
    }
    Na=size(a[i]);
    Nb=size(b[i]);
      //cout << size(a[i],N) << " " << size(b[i],N) << endl;
      unite(a[i],b[i]);
    ans[i]=ans[i+1]-(ll)(Na*Nb);
  }
  for(int i=0;i<M;i++){
    cout << ans[i+1] << endl;
  }
	return 0;
}

Measured memory_bytes: 5248
#include <stdio.h>

int a[1005];
int b[1005];
int c[1005];
int d[105][105];

int main() {

	int N, M;

	scanf("%d %d",&N,&M);

	int i,j,k;

	for (i = 0; i < M; i++) {
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
		a[i]--;
		b[i]--;
	}
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			if (i == j) {
				d[i][j] = 0;
			}
			else {
				d[i][j] = 99999999;
			}
		}
	}

	for (i = 0; i < M; i++) {
		d[a[i]][b[i]] = c[i];
		d[b[i]][a[i]] = c[i];
	}

	for (k = 0; k < N; k++) {
		for (i = 0; i < N; i++) {
			for (j = 0; j < N; j++) {
				if (d[i][j] > d[i][k] + d[k][j]) {
					d[i][j] = d[i][k] + d[k][j];
				}
			}
		}
	}

	int ans = 0;

	for (i = 0; i < M; i++) {
		if (d[a[i]][b[i]] < c[i]) {
			ans++;
		}
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	long long i,sum=0,min=0,max=0,a,b;
	scanf("%lld\n",&a);
	for(i=0;i<a;i++){
		scanf("%lld ",&b);
		if(i==0){
		min=b;
		max=b;}
		if(min>b)
		min=b;
		if(max<b)
		max=b;
		sum=sum+b;
	}
	printf("%lld %lld %lld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 1848
s=input()
count=0
maxcount=0

for i in range(len(s)):
  if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
    count+=1
    if count>=maxcount:
      maxcount=count
  else:
    count=0

print(maxcount)

Measured memory_bytes: 3060
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int M=stdIn.nextInt();
		int D=stdIn.nextInt();
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		if(M!=A)
			System.out.println(1);
		else
			System.out.println(0);
	}
}


Measured memory_bytes: 22356
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stdio.h>
#include<deque>
#include<map>
#include<queue>
#include<cmath>

typedef long long ll;

#define debug(x) cout << #x << '=' << x << endl;
#define debug_arr(a, n) for(ll i = 0; i < n; i++)cout << a[i] << ' '
#define inf 100000000000
#define loop(i,n) for(ll i = 0; i < n; i++)
#define graph vector<vector<ll>>
#define P pair<ll,ll>

using namespace std;

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

    vector<int> v(n);

    loop(i,n){
        cin >> v[i];
    }

    ll result = 0;

    // i個の宝石を取る
    loop(i,min(n,k)+1){
        // j個だけ左から取る
        loop(j,i+1){
            vector<int> minusJewel = {};
            ll tmp = 0; 
            loop(l,j){
                tmp += v[l];
                if(v[l] < 0)minusJewel.push_back(v[l]);
            }
            loop(l,i-j){
                tmp += v[n-1-l];
                if(v[n-l-1] < 0)minusJewel.push_back(v[n-l-1]);
            }
            sort(minusJewel.begin(),minusJewel.end());
            ll minusNum = minusJewel.size();
            
            loop(l,min(k-i, minusNum)){
                tmp -= minusJewel[l];
            }
        
            result = max(tmp, result);
        }
    }

    cout << result << endl;
}

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

int main(){
	int a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	int ans = 0;
	ans = a*x + b*y;
	//cout << ans << endl;
	ans = min(ans,c*max(x,y)*2);
	//cout << ans << endl;
	int ans2;
	if(min(x,y) == x) ans2 = min(x,y)*c*2 + abs(x-y)*b;
	if(min(x,y) == y) ans2 = min(x,y)*c*2 + abs(x-y)*a;
	ans = min(ans,ans2);
	cout << ans << endl;
}


Measured memory_bytes: 3192
fun main(args: Array<String>) {
    val n = next().toInt()

    val i = when (n) {
        in 400..599 -> {
            8
        }
        in 600..799 -> {
            7
        }
        in 800..999 -> {
            6
        }
        in 1000..1199 -> {
            5
        }
        in 1200..1399 -> {
            4
        }
        in 1400..1599 -> {
            3
        }
        in 1600..1799 -> {
            2
        }
        in 1800..1999 -> {
            1
        }
        else -> -1
    }
    println(i)
}
fun next() = readLine()!!

Measured memory_bytes: 34456
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m = map(int, input().split())
graph = [0] + [[] for _ in range(n)]
for _ in range(m):
    n1, n2 = map(int, input().split())
    graph[n1].append(n2)
    graph[n2].append(n1)

from collections import deque

def bfs(graph, queue, dist, prev):
    while queue:
        current = queue.popleft()

        for c in graph[current]:
            if dist[c] != -1:
                continue
            dist[c] = dist[current] + 1
            prev[c] = current
            queue.append(c)

queue = deque([1])
dist = [0] + [-1] * n
dist[1] = 0
prev = [0] + [-1] * n
prev[1] = 0
bfs(graph, queue, dist, prev)
if -1 in prev:
    print('No')
else:
    print('Yes')
    for p in prev[2:]:
        print(p)


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

int main(){
	int s, m, h;
	cin >> s;

	m = s / 60;
	h = m / 60;

	m -= h * 60;
	s = s - h * 60 * 60 - m*60;

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Graph;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 100000 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

long long fac[MAX_N];

long long fact(int n) {
    if (n == 1) return fac[n] = 1;
    if (fac[n]) return fac[n];
    return fac[n] = (fact(n - 1) * n) % M;
}

int main() {
    int n;
    cin >> n;
    vector<P> v(n, P(0, 0));
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        v[i] = make_pair(a, b);
    }
    int perm[n];
    rep(i, n) {
        perm[i] = i;
    }
    double ans = 0;
    do {
        for (int i = 1; i < n; i++) {
            int from = perm[i - 1];
            int to = perm[i];
            ans += sqrt((v[to].first - v[from].first) * (v[to].first - v[from].first) + (v[to].second - v[from].second) * (v[to].second - v[from].second));
        }
    } while (next_permutation(perm, perm + n));
    ans /= fact(n);
    cout << setprecision(12) << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

ll N, M;
vi dx = {1, 1, 1, 0, 0, -1, -1, -1};
vi dy = {1, 0, -1, 1, -1, 1, 0, -1};
ll func(int y, int x){
  int counter = 0;
  for(int i = 0; i < 8; i++){
      int yy = y + dy.at(i);
      int xx = x + dx.at(i);
      if(xx >= 0 && xx < M && yy >= 0 && yy < N) counter++;
  }
  if(counter % 2 == 0) return 1LL;
  else return 0LL;
}

int main(){
  cin >> N >> M;
  ll ans = func(0, 0);
  if(M >= 2){
    ans += func(0, M-1);
    if(M > 2){
      ans += func(0, 1) * (M - 2);
    }
  }
  if(N >= 2){
    ans *= 2;
    if(N > 2){
      if(M>=2)ans += 2 * func(1, 0) * (N - 2);
      else ans += func(1, 0) * (N - 2LL);
    }
  }
  if(N > 2 && M > 2) ans += (N-2LL) * (M-2LL);
  cout << ans << endl;
}

Measured memory_bytes: 256
//セレクションソートはMAXを求める感じのソート、バブルソートの一種ともいえるか…
#include<iostream>
#include<algorithm>
using namespace std;

int n,A[100];

int Selectionsort(int *p,int size){
	int count = 0;
	for(int i = 0;i < size-1;i++){
		//int minest = A[i];		//配列データ捨てたくないので、これはだめ
		int minest = i;
		for(int j = i+1;j < size;j++){
			if(A[minest] > A[j])
				minest = j;
		}
		if(A[minest] < A[i]){
			swap(A[minest],A[i]);
			count++;
		}
	}
	return count;
}
int main(){
	int count;
	cin >> n;
	for(int i = 0;i < n;i++)
		cin >> A[i];
	count = Selectionsort(A,n);
	for(int i = 0;i < n-1;i++)
		cout << A[i] << " ";
	cout << A[n-1] << endl;
	cout << count << endl;
	return 0;
}
	

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

typedef long long ll;
typedef unsigned long long ull;

#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 SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

int gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int l, r, d;
  cin >> l >> r >> d;
  int ans = r/d - l/d;
  if (l % d == 0) ans++;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3648
# Binary Index Tree (2-dimension)
class BIT2:
    # H*W, 0-based
    def __init__(self, h, w):
        self.w,self.h=w,h
        self.data = [{}for i in range(h+1)]
    #O(logH*logW)
    #[0.i)x[0.j)
    def sum(self, i, j):
        s = 0
        i -= 1
        data = self.data
        while i >= 0:
            el = data[i]
            k = j - 1 
            while k >= 0:
                s += el.get(k, 0)
                k =( k & (k+1)) - 1

            i = (i&(i+1))-1
        return s

    # O(logH*logW)
    def add(self, i, j, x):
        w = self.w; h = self.h
        data = self.data
        while i < h:
            el = data[i]
            k = j
            while k < w:
                el[k] = el.get(k, 0) + x
                k|=(k+1)
            i|=(i+1)
    # [x0, x1) x [y0, y1)
    def range_sum(self, x0, x1, y0, y1):
        return self.sum(x1, y1) - self.sum(x1, y0) - self.sum(x0, y1) + self.sum(x0, y0)
ans=0
bit=BIT2(20,20)
for i in range(int(input())):
    a=input().split('.')
    if len(a)==1:
        cnt2,cnt5=9,9
        a=int(a[0])
        while a%2==0 and cnt2<18:
            cnt2+=1
            a//=2
        while a%5==0 and cnt5<18:
            cnt5+=1
            a//=5
    else:
        a=int(a[0])*10**9+int((a[1][::-1].zfill(9))[::-1])
        cnt2,cnt5=0,0
        for j in range(18):
            if a%2==0:
                a//=2
                cnt2+=1
            if a%5==0:
                a//=5
                cnt5+=1
    ans+=bit.range_sum(18-cnt2,19,18-cnt5,19)
    bit.add(cnt2,cnt5,1)
print(ans)

Measured memory_bytes: 86412
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);
//桁数に注意 long long　にする

int main() {
  int n,m;
  cin >> n >> m;
  
  vector<int> p(n);
  
  int ans = 0;
  int sum = 0;
  
  rep(i,n) {
  cin >> p[i];
  sum+=p[i];
  }
  
  rep(i,n) {
    if(sum<=4*m*p[i])ans++; 
  } 
  
  cout << (ans>=m?"Yes":"No");
  
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main(){
	int n,k,ans=0;
	cin>>n>>k;
	if(k==1)ans=0;
	else{
		ans=n-k;
	}

	print(ans);

}

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

def resolve():
    N=int(input())
    import math
    def prime_factorize1(N):
        """
        Nをくって、Nの素因数を格納したリストresを返す。
        リストの要素をすべて掛ければNになる"""
        res = []
        x = N
        y = 2
        while y*y <= x:
            while x % y == 0:
                res.append(y)
                x //= y
            y += 1
        if x > 1:
            res.append(x)
        return res
    if N==1:
        print(1)
    else:
        num=[]
        for i in range(2,N+1):
            l=prime_factorize1(i)
            num.extend(l)
        from collections import Counter
        c=Counter(num)
        ans=1
        for x in c.values():
            ans=(ans*(x+1))%(10**9+7)
        print(ans)
resolve()

Measured memory_bytes: 39408
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mset(x, y) memset((x), (y), sizeof(x))
#define sz(x) ((int)(x).size())
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define cerr cout
#define endl '\n'
using namespace std;

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	ll n;
	cin >> n;
	cout << ((binpow(10LL, n) - 2LL * binpow(9, n) + binpow(8LL, n)) % mod + mod) % mod;

	// for(n = 2; n <= 1e6; n++)
	// {
	// 	if((binpow(10LL, n) - 2LL * binpow(9, n) + binpow(8LL, n) + mod) % mod < 0)
	// 		cout << n << endl;
	// 	//assert((binpow(10LL, n) - 2LL * binpow(9, n) + binpow(8LL, n) + mod) % mod > 0);
	// }
}

Measured memory_bytes: 3632
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define T int t = 0; cin >> t; while(t--)
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef  long double lld;
const ll mod = 1e9 + 7;
const ll mx = 2e6 + 5;

void input(){
    int a, b , c;
    cin >> a >> b >> c;
    map<int, int>m;
    ++m[a];
    ++m[b];
    ++m[c];
    if(m.size() == 2)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    input();
    return 0;
}

Measured memory_bytes: 256
struct Read<R: std::io::BufRead> {
    stdin: R,
    v: Vec<String>,
    i: usize,
    buf: String,
}
impl<R:std::io::BufRead> Read<R> {
    pub fn new(stdin: R) -> Self {
        Read{
            stdin,
            v: Vec::new(),
            i: 0,
            buf: String::with_capacity(2097152),
        }
    }
    pub fn read_until<T: std::str::FromStr>(&mut self) -> T {
        if self.i == self.v.len() {
            self.read_line();
        }
        let elem = &self.v[self.i];
        self.i += 1;
        elem.parse().unwrap_or_else(|_| panic!())
    }
    #[allow(dead_code)]
    pub fn read_i32(&mut self) -> i32 {
        if self.i == self.v.len() {
            self.read_line();
        }
        let elem = self.v[self.i].parse().unwrap();
        self.i += 1;
        elem
    }

    pub fn read_string(&mut self) -> String {
        if self.i == self.v.len() {
            self.read_line();
        }
        let elem = &self.v[self.i];
        self.i += 1;
        elem.to_owned()
    }
    pub fn read_line(&mut self) {
        self.i = 0; self.v.clear(); self.buf.clear();
        self.stdin.read_line(&mut self.buf).unwrap();
        let buf = self.buf.trim().to_owned();
        let mut ws = buf.split_whitespace();
        loop {
            let x = ws.next();
            if x.is_none() {
                break;
            }
            let x = x.unwrap().to_owned();
            self.v.push(x);
        }
    }
}
fn main() {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let mut read = Read::new(stdin);

    let mut n:usize = read.read_until();
    let mut s:Vec<String> = Vec::new();
    for _i in 0..n {
        s.push(read.read_string());
    }
    s.sort();
    let mut ans = 1;
    for i in 0..n-1 {
        if s[i] != s[i+1] {
            ans+=1;
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 14896
#include <algorithm>
#include <cstdio>

const int N = 100050;

int A[N];

int main() {
  int n;
  scanf("%d", &n);
  A[0] = A[n + 1] = 0;
  for (int i = 1; i <= n; ++i) scanf("%d", &A[i]);
  int sum = 0;
  for (int i = 0; i <= n; ++i) sum += std::abs(A[i + 1] - A[i]);
  for (int i = 1; i <= n; ++i)
    printf("%d\n", sum - std::abs(A[i + 1] - A[i]) - std::abs(A[i] - A[i - 1]) + std::abs(A[i + 1] - A[i - 1]));
   return 0; 
}

Measured memory_bytes: 1536
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int a, b;

int main()
{
	in >> a >> b;
	if (a > b)
	{
		out << a - 1 << std::endl;
	}
	else
	{
		out << a << std::endl;
	}
	return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */
int n, d;
lint solve(int a, int b){
    lint ans = 0;
    if(a == b) ans++;
    int top = n / pow(10, d-1);
    int bot = n % 10;
    int mid = (n % (int)pow(10, d-1) - bot) / 10;

    for(int k = 2; k <= d; k++){
        if(k < d || a < top){
            ans += pow(10, k - 2);
            continue;
        }
        if(a > top) continue;
        if(b <= bot){
            ans += mid + 1;
        }
        else{
            ans += mid;
        }
    }
    return ans;
}

int main(){
    cin >> n;
    int m = n;
    while(m > 0){
        m /= 10; d++;
    }
    if(d == 1){
        cout << n << endl; return 0;
    }
    lint ans = 0;
    repn(a, 9) repn(b, 9){
        lint p = solve(a, b);
        lint q = solve(b, a);
        ans += p * q;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int H, W;
    cin >> H >> W;
    bool down[H], across[W];
    char grid[H][W];

    for (int i = 0; i < H; i++) {
        scanf("%s", grid[i]);
        // cout << grid[i] << endl;
    }

    for (int i = 0; i < H; i++) {
        down[i] = false;
        for (int j = 0; j < W; j++) {
            if (grid[i][j] == '#') down[i] = true;
        }
        // cout << "down[" << i << "]: " << (down[i] ? "true" : "false") << endl;
    }

    for (int j = 0; j < W; j++) {
        across[j] = false;
        for (int i = 0; i < H; i++) {
            if (grid[i][j] == '#') across[j] = true;
        }
        // cout << "across[" << j << "]: " << (across[j] ? "true" : "false") << endl;
    }



    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (down[i] && across[j]) cout << grid[i][j];
            // cout << (down[i] && across[j] ? 't' : 'f');
        }
        if (down[i]) cout << endl;
        // cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;
string k;
int n,m,ans;
int dp[11111][2][111];
signed main(){
	cin>>k>>m;
	n=k.size();
	dp[0][0][0]=1;
	rep(i,n){
		int num=k[i]-'0';
		rep(smaller,2){
			rep(j,m){
				for(int x=0;x<=(smaller?9:num);x++){
					dp[i+1][smaller||x<num][(j+x)%m]+=dp[i][smaller][j];
					dp[i+1][smaller||x<num][(j+x)%m]%=MOD;
				}
			}
		}
	}
	ans=dp[n][0][0]+dp[n][1][0];
	ans%=MOD;
	ans--;ans=(ans+MOD)%MOD;
	cout<<ans<<endl;
}


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

using namespace std;

int n,m;
vector<int> susjed[100005];
int closest[100005];


void bfs(int start){
    closest[start]=1;
    queue<int> q;
    q.push(start);
    while(!q.empty()){
        int cur=q.front();
        q.pop();
        for(int i=0;i<susjed[cur].size();i++){
            if(closest[susjed[cur][i]]==0){
                closest[susjed[cur][i]]=cur;
                q.push(susjed[cur][i]);
            }
        }
    }
}

int main(){
    cin >>n>>m;
    int a,b;
    for(int i=0;i<m;i++){
        cin >> a>>b;
        susjed[a].push_back(b);
        susjed[b].push_back(a);
    }
    memset(closest,0,sizeof(closest));
    /*for(int i=1;i<=n;i++){
        cout <<i<<":"<<endl;
        for(int j=0;j<susjed[i].size();j++){
            cout <<susjed[i][j]<<endl;
        }
    }*/
    bfs(1);
    bool t=true;
    for(int i=1;i<=n;i++){
        if(closest[i]==0)
            t=false;
    }
    if(!t){
        cout <<"No"<<endl;
        return 0;
    }
    cout <<"Yes"<<endl;
    for(int i=2;i<=n;i++){
        cout <<closest[i]<<endl;
    }
}


Measured memory_bytes: 10344
def solve():
    S = list(input())
    
    ans, n = 0, len(S)
    for i in range(1, n):
        if S[i-1] == S[i] == '0':
            S[i] = '1'
            ans += 1
        elif S[i-1] == S[i] == '1':
            S[i] = '0'
            ans += 1
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3956
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var result = 0;
            for (int i = 0; i < 2; i++)
            {
                if (input[0] > input[1])
                {
                    result += input[0];
                    input[0]--;
                }
                else
                {
                    result += input[1];
                    input[1]--;
                }
            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 13268
#include<stdio.h>
#include<math.h>
int i,j;
int main(){
  int x;
  scanf("%d",&x);
  if(x==1)
    printf("1\n");
  else {
    int max=1;
    for(i=2;i*i<=x;++i){
      for(j=2;pow(i,j)<=x;++j)
	max=pow(i,j)>max? pow(i,j):max;
    }
    printf("%d\n",max);}
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <unordered_set>

//#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

#define MAX_N   (200000)                  // 10^5
#define BASE    (1000000000 + 7)          // 10^9 + 7
#define INFI    (1000000000 + 7)          // 10^9 + 7
#define INFL    (1000000000000000000 + 7) // 10^18 + 7

const int N = 3;
ll A[N], B[N];

void solve() {
  ll ans = 0;
  sort(A, A + N);
  while (true) {
    ll mn = INFL, mx = -1;
    for (int i = 0; i < N; i++) {
      if (A[i] % 2 > 0) {
        cout << ans << endl;
        return;
      }
      mn = min(mn, A[i]);
      mx = max(mx, A[i]);
    }
    if (mx - mn < 2) break;

    for (int i = 0; i < N; i++) {
      B[i] = 0;
      for (int j = 0; j < N; j++) if (i != j) B[i] += A[j];
    }
    for (int i = 0; i < N; i++) A[i] = B[i] / (N - 1);

    ans++;
  }
  cout << -1 << endl;
}

int main() {
  for (int i = 0; i < N; i++) cin >> A[i];

  solve();

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,m;
    std::cin >> n >>m;
    int city[51]={0};
    for (int i = 0; i < m; i++) {
        int a,b;
        std::cin >> a >>b;
        city[a]++;
        city[b]++;
    }
    for (int i = 1; i <= n; i++) {
        std::cout << city[i] << std::endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int cnt;
	long long int s;
	while(1){
		scanf("%lld" , &s);
		if(s==0) break;
		cnt = 0;
		while(s!=1){
			if(s%2==0) s /= 2;
			else s = s*3 + 1;
			cnt++;
		}
		printf("%d\n" , cnt);
	}
	return 0;
}

Measured memory_bytes: 0
import heapq
import sys
input=sys.stdin.readline

N,Q = map(int,input().split(" "))
querys = []
START = 1
GOAL = 0
GO = 2

for _ in range(N):
    s,t,x = (map(int,input().split(" ")))
    s -=(x + 0.5)
    t -= (x + 0.5)
    querys.append( (s,START,x) )
    querys.append( (t,GOAL,x) )

for _ in range(Q):

    querys.append( (int(input()),GO,-1)  )
koji_place = []
koji_um = set([])
heapq.heapify(koji_place)
querys.sort()
for query in querys:
    time,qtype,place = query
    if qtype == START:
        heapq.heappush(koji_place,place)
        koji_um.add(place)
    elif qtype == GOAL:
        koji_um.remove(place)
    else:
        while koji_place and koji_place[0] not in koji_um: #更新と最近の場所のチェックを同時に行う
            heapq.heappop(koji_place) #koji place のpopは最大で place分，つまり合計で10 ** 5回行われるため ここのwhile
            # はOに影響を与えない
        if not koji_place:
            print(-1)
        else:
            print(koji_place[0])





Measured memory_bytes: 86544
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
#define lint long long
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
class Seg_Tree{
    private:
    int e=1000000007;
    int n;
    vector<int> node;
    public:
    int process(int left,int right){
        if(left==e)return right;
        if(right==e)return left;
        return left+right;
    }
    Seg_Tree(vector<int> v){
        int num=1;
        int size=v.size();
        while(num<size){
            num*=2;
        }
        n=num;
        node.resize(2*num-1,e);
        for(int i=0;i<size;i++)node[i+num-1]=v[i];
        for(int i=n-2;i>=0;i--)node[i]=process(node[i*2+1],node[i*2+2]);
    }
    void update(int x,int val){
        x+=(n-1);
        node[x]+=val;
        while(x>0){
            x=(x-1)/2;
            node[x]=process(node[x*2+1],node[x*2+2]);
        }
    }
    int out(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        if(a>=r||b<=l)return e;
        if(a<=l&&b>=r)return node[k];
        int vl=out(a,b,k*2+1,l,(l+r)/2);
        int vr=out(a,b,k*2+2,(l+r)/2,r);
        return process(vl,vr);
    }
};
signed main(){
  int n,k;cin>>n>>k;
  vector<int> a(n+1,0);
  vector<int> sum(n+1,0);
  rep1(i,n){
    cin>>a[i];
  }
  rep1(i,n){
    sum[i]=sum[i-1]+a[i]-k;
  }
  vector<int> na(n+1);
  rep(i,n+1){
    na[i]=sum[i];
  }
  sort(na.begin(),na.end());
  vector<int> p(n+1);
  rep(i,n+1){
    auto it=upper_bound(ALL(na),sum[i]);
    --it;
    int ind=it-na.begin();
    p[i]=ind;
  }
  Seg_Tree tree(vector<int> (n+5,0));
  tree.update(p[0],1);
  int res=0;
  rep1(i,n){
    int num=tree.out(0,p[i]+1);
    res+=num;
    tree.update(p[i],1);
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 12160
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int k = scanner.nextInt();
        final int c = scanner.nextInt();
        final String s = scanner.next();
        final List<Integer> workableDays = IntStream.range(0, n)
                .filter(i -> s.charAt(i) == 'o')
                .boxed()
                .collect(Collectors.toList());

        final int[] frontGreedy = new int[k];
        frontGreedy[0] = workableDays.get(0);
        for (int i = 1; i < k; i++) {
            final int next = Collections.binarySearch(workableDays, frontGreedy[i - 1] + c + 1);
            frontGreedy[i] = workableDays.get(next >= 0 ? next : ~next);
        }

        final int[] backGreedy = new int[k];
        backGreedy[k - 1] = workableDays.get(workableDays.size() - 1);
        for (int i = k - 2; i >= 0; i--) {
            final int next = Collections.binarySearch(workableDays, backGreedy[i + 1] - c - 1);
            backGreedy[i] = workableDays.get(next >= 0 ? next : ~next - 1);
        }

        for (int i = 0; i < k; i++) {
            if (frontGreedy[i] == backGreedy[i]) {
                System.out.println(frontGreedy[i] + 1);
            }
        }
    }
}


Measured memory_bytes: 47684
#include <bits/stdc++.h>
using namespace std;
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)

int main() {
  long long A, B;
  cin >> A >> B;
  int pre=1;
  FOR(i,1,100){
  	pre = pre*B;
    if(pre>A){
    	cout << i << endl;
      	return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
/**
 *      ///----- My Info -----///
 *      Code by: Unk
 *      Codeforces User: Ernest0_0Abreu
 *      Country: Cuba
 *      E-mail: ernestoabreup@gmail.com
 *      CopyRight
**/
#include <bits/stdc++.h>
#ifdef Ernest0_0Abreu 
#include <debug/to_string.h>
#endif
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
        ///----- My Template -----///
///===================================================================================================================================
/// Debug
#define _end cout << "\n"
#ifndef Ernest0_0Abreu
#define db(x) ;
#define dbrange(x,begin,end) ;
#define dbname(x) ;
#define dbnamerange(x,begin,end) ;
#define dbmat(x,begin_n,end_n,begin_m,end_m) ;
#define dbST(x,end) ;
#define db_end ;
#endif
///Function
#define pi ( acos(-1) )
#define lg2(x) ( 31-__builtin_clz(x) )
#define lgx(x,n) ( log(n) / log(x) )
/// Macros
#define fst first
#define scd second
#define left (node<<1)
#define right ((node<<1)+1)
#define _sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
/// Typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/// Constant
const int MAXN = 1e6+7;
const int MOD = 1e9+7;
const ull BASE = 311;
const ld EPS = 1e-9;
const int INF = ((1<<30)-1);
const ll INFLL = ((1ll<<62ll)-1ll);
const ll oo = 2e18;
/// Hash Prime Numbers: 2, 277, 293, 307, 331, 337, 1009, 2027, 3079, 10079;
/// Module Prime Numbers: 3, 200017, 1000033, 998244353, 1000000007, 1000000009, 1000000021;
#define int long long
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
///===================================================================================================================================
        ///----- My code -----///



int32_t main(){
    
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

	int N; string s;
	cin >> N; cin >> s;
     int cnt = 0;
	for(int i = 0; i <= N-3; ++i){
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') cnt++;
	}

	cout << cnt;

    return 0;
}



Measured memory_bytes: 256