akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void){
  int prime[1000001],i,j,n,count;

  for(i=0;i<1000001;i++)
    prime[i]=0;
  
  prime[0]=prime[1]=1;

  for(i=2;i*i<1000001;i++){
    if(prime[i]==0){
      for(j=2*i;j<1000001;j+=i){
	prime[j]=1;
      }
    }
  }
  
  while(scanf("%d",&n),n){
    count=0;
    for(i=2;i<=n/2;i++)
      if(prime[i]==0 && prime[n-i]==0)count++;

    printf("%d\n",count);
}

  return 0;
}

Measured memory_bytes: 0
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store,no-stack-protector")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "#" << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ld = long double;  using ui = uint_fast32_t;
using ll = int_fast64_t; using ul = uint_fast64_t;

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

void solve() {
    int s[2], h[2];
    for (int i = 0; i < 2; ++i) {
        cin >> h[i] >> s[i];
    }
    int p = 0;
    while (1) {
        h[p ^ 1] -= s[p];
        if (h[1 ^ p] <= 0) {
            if (p ^ 1) {
                cout << "Yes\n";
            } else {
                cout << "No\n";
            }
            return;
        }
        p ^= 1;
    }
}

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

int main() {
    fast_io; // cout_precision;
#ifdef LOCAL
    cin_exception;
#endif
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <chrono>

using namespace std;

unsigned int xor32(){
    static unsigned int y = 2463534242;
    y = y ^ (y << 13); y = y ^ (y >> 17);
    return y = y ^ (y << 5);
}

int main(){
    int D; cin >> D;
    vector<int> c(26, 0);
    for(auto& t : c) cin >> t;
    vector s(D, vector(26, 0));
    for(auto& v : s){
        for(auto& t : v) cin >> t;
    }
    vector<int> last(26, 0);
    vector<set<int>> days(26);
    for(int i=0;i<26;i++){
        days[i].insert(0);
        days[i].insert(D+1);
    }
    vector<int> select(D+1, -1);
    long long score = 0;
    for(int i=1;i<=D;i++){
        int t = -1;
        long long best = 0;
        for(int j=0;j<26;j++){
            long long cur = s[i-1][j];
            for(int k=0;k<26;k++){
                if(j==k) continue;
                cur -= c[k] * (i - last[k]);
            }
            if(t == -1 || best < cur){
                t = j;
                best = cur;
            }
        }
        days[t].insert(i);
        select[i] = t;
        last[t] = i;
        score += best;
    }
    const double startTemp = 100;
    const double endTemp = 10;
    auto res = select;
    double bestScore = score;
    auto start = chrono::system_clock::now();
    const double tl = 1900;
    while(true){
        auto cur = chrono::system_clock::now();
        auto time = chrono::duration_cast<chrono::milliseconds>(cur-start).count();
        if(time > tl) break;
        const double temp = time/tl * (endTemp - startTemp) + startTemp;
        for(int i=0;i<100000;i++){
            int d = xor32()%D + 1;
            int q = xor32()%26;
            long long sub = 0;
            sub -= s[d-1][select[d]];
            sub += s[d-1][q];
            auto it = days[select[d]].find(d);
            --it;
            auto pre = *it;
            ++it; ++it;
            auto next = *it;
            sub += ((d-pre)*(d-pre-1)/2 + (next-d)*(next-d-1)/2) * c[select[d]];
            sub -= (next-pre)*(next-pre-1)/2 * c[select[d]];
            it = days[q].lower_bound(d);
            next = *it;
            --it;
            pre = *it;
            sub -= ((d-pre)*(d-pre-1)/2 + (next-d)*(next-d-1)/2) * c[q];
            sub += (next-pre)*(next-pre-1)/2 * c[q];
            if(sub > 0 || exp(0.01*sub)/temp > rand()%10000000*1e-7){
                days[select[d]].erase(d);
                days[q].insert(d);
                select[d] = q;
                score += sub;
                if(score > bestScore){
                    bestScore = score;
                    res = select;
                }
            }
        }
    }
    for(int i=1;i<=D;i++) cout << res[i]+1 << endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back
char s[10];
int ask(int a, int b){
    printf("? %d %d\n", a-1, b-1);
    fflush(stdout);
    scanf("%s", s);
    if(s[0] == 'N') return 0;
    return 1;
}

int ans[4005];
int main(){
    int a, b;
    scanf("%d%d", &a, &b);   
    int n = a+b;
    if(a <= b){
        printf("Impossible\n");
        fflush(stdout);
        return 0;
    }
    stack<int> st;
    for(int i=1;i<=n;i++){
        if(st.empty()) st.push(i);
        else{
            int res = ask(st.top(), i);
            if(res == 0) st.pop();
            else st.push(i);
        }
    }
    ans[st.top()] = 1;
    for(int i=1;i<=n;i++){
        if(i == st.top()) continue;
        int res = ask(st.top(), i);
        ans[i] = res;
    }
    printf("! ");
    for(int i=1;i<=n;i++) printf("%d", ans[i]);
    printf("\n");
    fflush(stdout);
}

Measured memory_bytes: 724
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b;
  char op;
  cin >> a >> op >> b;
  while(op!='?'){
    int c;
    if(op=='+') c=a+b;
    if(op=='-') c=a-b;
    if(op=='*') c=a*b;
    if(op=='/') c=a/b;
    cout << c << endl;
    cin >> a >> op >> b;
  }
  return 0;
}



Measured memory_bytes: 3112
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&a!=c&&b!=c||c==b&&c!=a&&b!=a||a==c&&b!=c&&b!=a)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int ma=(n+1)/2;
	if(ma>=k) cout<<"YES";
	else cout<<"NO";
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
// https://www.youtube.com/watch?v=hh97LmRSjeY 37:40
const ll mod = 1e9 + 7;

map<pair<ll,ll>,ll> dp;

ll f(ll x, ll y) {
  if (x<0 || y<0) return 0;
  if (dp.count({x,y})) return dp[{x,y}];
  if (x==0 && y==0) return 1;

  ll res = 0;
  if (x>=2 && y>=2) res += f((x-2)/2, (y-2)/2); //1, 1
  if (x>=1 && y>=1) res += f((x-1)/2, y/2); //1, 0
  res += f(x/2, y/2);
  res %= mod;
  res += mod;
  res %= mod;

  return dp[{x,y}] = res;
}

ll n;
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cin>>n;
  ll res = f(n,n);
  res %= mod;
  res += mod;
  res %= mod;
  cout<<res<<endl;
  

  return 0;
}
// don't forget to read in the input :^)


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        
        if((A-2*B)>0){
            System.out.println(A-2*B);
        } else { 
            System.out.println(0);
        }

        

        
    }
}

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

#define mp       make_pair
#define mt       make_tuple
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int N,K,X,Y;
int main(){
  cin >> N >> K >> X >> Y;
  ll ans = 0;
  for (int i = 0; i < N; i++){
    if (i < K){
      ans += X;
    }else{
      ans += Y;
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	/*
	for (int i = 0; i + K <= N; i++) {
		vector<int> B = A;
		sort(B.begin() + i, B.begin() + (i + K));
		for (int j = 0; j < N; j++) {
			cerr << B[j] << " ";
		}
		cerr << endl;
	}*/
	vector<int> X(N, 0);
	vector<int> Y(N, 0);
	set<int> st;
	for (int i = 0; i < K - 1; i++) {
		st.insert(A[i]);
	}
	
	for (int i = K - 1; i < N; i++) {
		st.insert(A[i]);
		auto t = st.end(); t--;

		if ((*t) == A[i]) {
			X[i] = 1;
		}
		st.erase(A[i - K]);
	}

	reverse(A.begin(), A.end());
	st.clear();
	for (int i = 0; i < K - 1; i++) {
		st.insert(A[i]);
	}

	for (int i = K - 1; i < N; i++) {
		st.insert(A[i]);
		if ((*st.begin()) == A[i]) {
			Y[i] = 1;
		}
		st.erase(A[i - K]);
	}
	reverse(Y.begin(), Y.end());
	res = N - K + 1;
	UnionFind uf(N - K + 1);
	for (int i = 0; i + K < N; i++) {
		if (X[i + K] == 1 && Y[i] == 1) {
			uf.unionSet(i, i + 1);
		}
	}
	reverse(A.begin(), A.end());
	int cur = 1;
	int l = -1;
	for (int i = 1; i < N; i++) {
		if (A[i - 1] < A[i]) {
			cur++;
			if (cur >= K) {
				if (l != -1) {
					uf.unionSet(l, i - K + 1);
					//cerr << l << " " << i - K + 1 << endl;
				}
				l = i - K + 1;
			}
		}
		else {
			cur = 1;
		}
	}
	st.clear();
	for (int i = 0; i < uf.data.size(); i++) {
		st.insert(uf.root(i));
	}
	cout << st.size() << endl;
}

Measured memory_bytes: 15872
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i <= (n);i++)
using namespace std;
int main(){
    int n,k,d,x,cnt=0;
    cin>>n>>k;
    vector<int> vec(n);
    vector<int> a(n,0);
    rep(i,k){
        cin>>d;
        rep(i,d){
            cin>>x;
            a[x-1]++;
        }
    }
    for(int i=0;i<n;i++){
        if(a[i]==0)cnt++;
    }
    cout<<cnt;
    }


Measured memory_bytes: 3636
# frozen_string_literal: true

N = gets.to_i
B = gets.split.map(&:to_i)
a = [B[0]]

1.upto(N - 2) { |i| a[i] = B[i - 1] < B[i] ? B[i - 1] : B[i] }
a[N - 1] = B[N - 2]

puts a.inject(:+)

Measured memory_bytes: 3836
import java.util.ArrayDeque
import java.math.*

fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val AList = readInputLine().split(" ").map { it.toInt() }.sorted()
    val absSum = AList.sumBy { Math.abs(it) }
    val deque = ArrayDeque<Int>(N)
    
    for (a in AList) {
        deque.addLast(a)
    }
    
    val first = deque.peekFirst()
    val last = deque.peekLast()
    
    if (last < 0) {
        println(absSum - last * -2)
        println("$last $first")
        deque.pollFirst()
        deque.pollLast()
        deque.addLast(last - first)
    } else if (first > 0) {
        println(absSum - first * 2)
        println("$first $last")
        deque.pollFirst()
        deque.pollLast()
        deque.addFirst(first - last)
    } else {
        println(absSum)
    }
    
    if (deque.size == 1) {
        return
    }
    
    while (deque.size > 2) {
        val first = deque.pollFirst()
        val last = deque.pollLast()
        
        if (deque.peekFirst() >= 0) {
            println("$first $last")
            deque.addFirst(first - last)
        } else {
            println("$last $first")
            deque.addLast(last - first)
        }
    }
    
    println("${deque.pollLast()} ${deque.pollLast()}")
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 62756
n, m = [int(i) for i in input().split()]
a = [[int(j) for j in input().split()] for i in range(n)]
b = [int(input()) for i in range(m)]

ans = [sum([a[j][i] * b[i] for i in range(m)]) for j in range(n)]
print(*ans, sep='\n')


Measured memory_bytes: 6028
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;

  std::vector< ll > va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  ll ans = INF;
  for (ll i = -200; i < 200; i++) {
    ll cost = 0LL;
    for (auto a : va) {
      cost += std::pow((a - i), 2);
    }
    ans = std::min(ans, cost);
  }

  print(ans);
  return 0;
}


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

#define MAX 100005//c语言用define来宏定义，不要用c++习惯的const int 

typedef struct pp{//千万不要少了前面的typedef关键字 
	char name[100];//task name
	int t;//task
}p;

p Q[MAX];//有了这个结构体数组就能很方便的将任务名和任务对应存入了 

int head,tail;

/* 
//判断栈空
int isEmpty()
{
	return head==tail;	//如果定义成bool类型要预编译调用c标准库里的布尔函数 
} 

//判断栈是否满 
int isFull()
{
	return head==(tail+1)%MAX;	
} */

//入队
void enqueue(p x)
{
	//if(isFull)return;
	Q[tail]=x;//这里只能是tail，不能是head ，因为队列是先进先出，tail对应的等会儿能用head直接取出来，否则不满足先进先出 
	tail=(tail+1)%MAX;
}

//出队 ，定义成结构体类型才能返回结构体作为值 
p dequeue()
{
	//if(isEmpty())return;
	p x=Q[head];//这里只能是head，不能是tail 
	head=(head+1)%MAX;
	return x;
}

int main()
{
	//读入数据 
	int n,tms;
	scanf("%d%d",&n,&tms); 
	int i;
	for(i=1;i<=n;i++){
		scanf("%s",Q[i].name);//字符串存入不能加取地址符 
		scanf("%d",&Q[i].t);
	}
	p u;//为了后面输出 
	head=1,tail=n+1;
	int cnt=0;
	while(head!=tail){
		u=dequeue();
		//int cnt=0;注意这里不能临时定义一个变量cnt存储时间，后面出队的元素肯定已经经过了前面元素的时间，所以时间是叠加的 
		if(u.t>=tms){
			cnt+=tms;
		}else{
			cnt+=u.t;
		}
		u.t-=tms; 
		if(u.t<=0){
			printf("%s %d\n",u.name,cnt);
		}else{
			enqueue(u);
		} 
	}
	return 0;
}


Measured memory_bytes: 11868
#include <bits/stdc++.h>
using namespace std;
int a[501][501];
int main() {
    int k;
    scanf("%d", &k);
    if (k <= 500) { cout << k << endl; for (int i = 1; i <= k; ++ i) for (int j = 1; j <= k; ++ j) printf("%d%c", i, j == k ? '\n' : ' ' ); return 0; }
    int n = ((k + 3) / 4) << 1; cout << n << endl;
    for (int i=1;i<=n;++i)for(int j=1;j<=n;++j){a[i][j]=(i+j)%n+(i&1?0:n)+1;if(a[i][j]>k)a[i][j]-=n;printf("%d%c",a[i][j],j==n?'\n':' ');}
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n,h,w;
    cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REPR(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define FOR(i, x, n) for (int i = x; i < (int)(n); ++i)
#define ALL(n) begin(n), end(n)
#define ll long long
#define INF 1e9
int main() {
    string s, t;
    cin >> s >> t;
    int count = 0;
    REP(i, s.size()) {
        if (s[i] != t[i]) count++;
    }
    cout << count << endl;
    return 0;
}

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

int main(){
	int k,t;
	cin>>k>>t;
	vector<int>a(t);
	for(int i=0;i<t;i++){
		cin>>a[i];
	}
	if(t==1){
		cout<<k-1<<endl;
		return 0;
	}
	sort(a.begin(),a.end());
	for(int i=a.size();i>=2;i--){
		int b=a[i-1];
		int c=a[i-2];
		a.pop_back();
		a.pop_back();
		a.push_back(b-c);
		sort(a.begin(),a.end());
	}
	if(a[0]==0){
		cout<<0<<endl;
		return 0;
	}
	cout<<a[0]-1<<endl;
	return 0;
}

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

int main(){
    int N;
    cin >>N;
    double sum = 0;

    double V[N];
    string S[N];
    for(int i = 0; i < N; i++){
        cin >> V[i];
        cin >> S[i];

        if(S[i] == "JPY"){
            sum += V[i];
        }else{
            sum += V[i]*380000.0;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int n,u,k,v;
    scanf("%d",&n);
    int A[n+1][n+1];
    for(int i = 0; i <= n; i++){
        for(int j =0 ; j <= n; j++) A[i][j] = 0;
    }
    for(int i = 1; i <= n; i++){
        scanf("%d %d",&u,&k);
        for(int j = 0; j < k; j++){
            scanf("%d",&v);
            A[u][v] = 1;
        }
    }
    
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            printf("%d",A[i][j]);
            if(j != n) printf(" ");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3212
<?php
$stdins = array();
    while(true)
    {
        $stdin = trim(fgets(STDIN));
        if ($stdin === '0')
        {
          foreach($return as $value) {
            echo $value . PHP_EOL;
          }
            exit;
 
        } else {
          $n = $stdin;
          $y = trim(fgets(STDIN));
          $max = 0;
          $num = null;
          for ($n ; 0 < $n; $n--) {
            list($b, $r, $t) = explode(' ', trim(fgets(STDIN)));
            if ($t == 1) {
              $money = 1+$y*($r/100);
            } else {
              $money = pow(1+($r/100), $y);
            }
            if ($max < $money) {
              $max = $money;
              $num = $b;
            }
          }
 
          $return[] = $num;
 
        }
        $stdins[] = $stdin;
    }
?>

Measured memory_bytes: 15584
import sys

readline = sys.stdin.readline

N = int(readline())
A = list(map(int, readline().split()))

A.sort()

amax = A.pop(-1)
amin = A.pop(0)
neg = [a for a in A if a < 0]
pos = [a for a in A if a >= 0]

log = []

m = amin
for a in pos:
    log.append((m, a))
    m = m - a

M = amax
for a in neg:
    log.append((M, a))
    M = M - a

log.append((M, m))
ans = M - m

print(ans)
for l, r in log:
    print('{} {}'.format(l, r))
    

Measured memory_bytes: 63128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main(){
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
    string a,b;
    cin>>a>>b;
    if(a.size()!=(b.size()-1)){
      cout<<"No";
      return 0;
    }
    for(int i=0;i<a.size();i++){
      if(a[i]!=b[i]){
        cout<<"No";
        return 0;
      }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cctype>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    int n;
    cin>>n;
    string str;
    getline(cin,str);
    while(n--){
        getline(cin,str);
        bool f=false;
        for(int a=1;!f;a++){
            if(a%2==0||a%13==0)continue;
            for(int b=0;!f&&b<26;b++){
                char m[26];
                for(int i=0;i<26;i++)m[(i*a+b)%26]=i+'a';
                string t=str;
                for(int i=0;i<t.size();i++){
                    if(islower(t[i]))t[i]=m[t[i]-'a'];
                }
                bool f_this=(t.find("this")!=string::npos);
                bool f_that=(t.find("that")!=string::npos);
                if(f_this||f_that){
                    str=t;
                    f=true;
                }
            }
        }
        cout<<str<<endl;
    }
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
#define ar array
#define endl '\n'
#define ll long long
#define in insert
#define pb push_back
#define vt vector
#define P_Q(x) priority_queue<x>
#define p_q(x) priority_queue<x, vector<x>, greater<x>>
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(ll i=a;i>=b;i--)
#define FOR(m) Rep(i,1,m)
#define For(m) Rep(i,0,m-1)
#define Rbl(x,a) for(auto &x : a)
#define FIO ios::sync_with_stdio(0);   cin.tie(0);
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpii vector<pii>
#define vpll vector<pll>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define mod 1000000007
 
const int mxN = 1e5 + 1;
ll a[mxN];
ll w[mxN];
ll dp[101][mxN] = {};
ll n, W;
 
 
int main()
{
FIO
 
    cin >> n >> W;
    FOR(n) cin >> w[i] >> a[i];
    FOR(n)
    {
        for(int j = 1; j <= W; j++)
        {
            if(w[i] <= j)
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + a[i]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    cout << dp[n][W] << endl;
}

Measured memory_bytes: 81676
#include <iostream>
#include <cstdio>
#include <queue>
#define N 55
using namespace std;

int n, m, cnt;
int dr[4] = {-1, 1, 0, 0}, dc[4] = {0, 0, -1, 1};
struct st {
	int r, c, z;
};
queue<st> qu;
char a[N][N];
bool v[N][N];
void f(int p, int q, int w) {
	if (v[p][q] || a[p][q] != '.') return;
	v[p][q] = 1;
	qu.push({p, q, w});
}
int main()
{
	int i, j;
	st t;
	cin >> n >> m;
	for (i = 1; i <= n; i++) {
		scanf ("%s", &a[i][1]);
		for (j = 1; j <= m; j++) if (a[i][j] == '#') cnt++;
	}
	f(1, 1, 1);
	while (!qu.empty()) {
		t = qu.front(); qu.pop();
		if (t.r == n && t.c == m) break;
		for (i = 0; i < 4; i++) {
			f(t.r + dr[i], t.c + dc[i], t.z + 1);
		}
	}
	if (t.r == n && t.c == m) cout << n * m - cnt - t.z;
	else cout << -1;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

const int N = 2e5+5;
ll n , m , a[N] , nn , ans[105][105];

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

    cin >> n >> m;
    cin >> nn;
    for(int i=1; i<=nn; i++)
        cin >> a[i];

    int k = 1;
    for(int i=1; i<=n; i++)
    {
        if (i%2)
        {
            for(int j=1; j<=m; j++)
            {
                if (a[k]==0) k++;
                ans[i][j] = k;
                a[k]--;
            }
        }
        else
        {
            for(int j=m; j>=1; j--)
            {
                if (a[k]==0) k++;
                ans[i][j] = k;
                a[k]--;
            }
        }
    }

    for(int i=1; i<=n; i++)
    {
        for(int j=1;j<=m; j++)
            cout << ans[i][j] << ' ';
        cout << '\n';
    }

    return 0;
}

Measured memory_bytes: 512
#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 <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;



int main(void) {
  int n;
  cin >> n;
  VI a(n);
  int f4 = 0;
  int f2 = 0;
  int f1 = 0;
  REP(i, 0, n) {
    cin >> a[i];
    if (a[i] % 4 == 0) {
      f4 += 1;
    } else if (a[i] % 2 == 0) {
      f2 += 1;
    } else {
      f1 += 1;
    }
  }
  if (f2 >= 1) {
    f2 = 0;
    f1 += 1;
  }
  cout << (f4 < f1 - 1 ? "No" : "Yes") << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
	int W,H;
	int x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(H<y+r) puts("No");
	else if(0>y-r) puts("No");
	else if(W<x+r) puts("No");
	else if(0>x-r) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n, q; string s;
    cin >> n >> s >> q;
    vector<set<ll>> st(26);
    rep(i, n) st[s[i]-'a'].insert(i);
    rep(times, q){
        ll op;  cin >> op;
        if(op==1){
            ll index;   char c;
            cin >> index >> c;  index--;
            char oc = s[index];
            s[index] = c;
            st[oc-'a'].erase(index);
            st[c-'a'].insert(index);
        }else{
            ll l, r;    cin >> l >> r;
            l--, r--;
            ll res=0;
            rep(i, 26){
                if(st[i].empty()) continue;
                auto left = st[i].lower_bound(l);
                auto right = st[i].upper_bound(r);
                res += left!=right;
            }
            cout << res << endl;
        }
        
    }

}


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

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

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

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

  double ans = (v[0] + v[1]) / 2.0;

  for(int i = 2; i < n; i++) {
    ans = (ans + v[i]) / 2.0;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */
namespace utils{

    class Repeater{
        int st;
        int ed;
        int d;
    public:
        class rep_iterator{
            int i; int d;
        public:
            rep_iterator(int x, int pd) :i(x), d(pd) {}

            int& operator*(){ return i; }
            bool operator==(const rep_iterator& k) const { return i == k.i; }
            bool operator!=(const rep_iterator& k) const { return i != k.i; }
            rep_iterator& operator++(){ i+=d; return *this; }
        };

        explicit Repeater(int N) :st(0), ed(N), d(1) {}
        Repeater(int b, int e) :st(b), ed(e), d(1) {if(st > ed){ st--; ed--; d = -1; } }

        rep_iterator begin() const{ return rep_iterator(st, d); }
        rep_iterator end() const{ return rep_iterator(ed, d); }

    };

    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;


void sub_main(istream &is) {
    ll N, K;
    is >> N >> K;
    if(!is) return;
    double ans = 0;

    for (int i : Repeater(1, N+1)) {
        double k = 1;

        while(i < K){ i *= 2; k /= 2; }
        ans += k;
    } // end i
    ans /= N;

    cout << ans << endl;
}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_C.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


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

int main() {
    int N; cin >> N;
    vector<pair<int, int>> xy(N);
    for (int i = 0; i < N; i++) {
        int x, y; cin >> x >> y;
        xy[i] = pair<int, int>(x, y);
    }
    double ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            ans += sqrt((xy[i].first - xy[j].first) * (xy[i].first - xy[j].first) +
                        (xy[i].second - xy[j].second) * (xy[i].second - xy[j].second));
        }
    }
    // for (int i = N; 1 <= i; i--) ans /= i;
    // ans *= N-1;
    cout << setprecision(13) << ans * 2 / N << endl;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

template <typename T, class Operator>
struct SegTree
{
	vector<T> tree;
	Operator op;
	T def;
	int s;
	SegTree(int size, T val, Operator opr)
	{
		s=size;
		op=opr;
		tree.resize(4*size,val);
		def=val;
	}

	void add(int pos, T value)
	{
		add(pos,value,0,s,0);
	}

	// [low, hi) は全体の範囲
	void add(int pos, T value, int low, int hi, int i)
	{
		while(1)
		{
			tree[i]=op(tree[i],value);
			if(low+1<hi){
				int mid=(low+hi)/2;
				if(pos<mid){
					i=2*i+1;
					hi=mid;
				}
				else
				{
					i=2*i+2;
					low=mid;
				}
			}
			else
			{
				break;
			}
		}
	}

	// [a,b) を取得
	T get(int a, int b)
	{
		return get(a,b,0,s,0);
	}

	T get(int a, int b, int low, int hi, int i)
	{
		if(hi<=a||b<=low||hi<=low){
			return def;
		}
		if(a<=low&&hi<=b){
			return tree[i];
		}
		int mid=(low+hi)/2;
		return op(get(a,b,low,mid,2*i+1),get(a,b,mid,hi,2*i+2));
	}
};
struct Min
{
	int operator()(int a,int b){
		return min(a,b);
	}
};
int N;
const int inf=1<<29;
const int L=2e5+10;
int indices[L];
typedef array<int,4> A;
priority_queue<A,vector<A>, greater<A> > pq;
int main() {
	cin >> N;
	SegTree<int,Min> even(N,inf,Min()), odd(N,inf,Min());
	auto f=[&](int s,int e){
		if(s>=e){
			return;
		}
		int v,w;
		if(s%2==0){
			v=even.get(s,e);
			w=odd.get(indices[v]+1,e);
			pq.push(A{{v,w,s,e}});
		}
		else{
			v=odd.get(s,e);
			w=even.get(indices[v]+1,e);
			pq.push(A{{v,w,s,e}});
		}
	};
	for(int i=0;i<N;i+=2){
		int p;
		cin >> p;
		even.add(i,p);
		indices[p]=i;
		cin >> p;
		odd.add(i+1,p);
		indices[p]=i+1;
	}
	f(0,N);
	auto sp="";
	while(pq.size()){
		A a=pq.top();
		pq.pop();
		cout << sp << a[0] << " " << a[1];
		sp=" ";
		int s=a[2];
		int e=a[3];
		int p=indices[a[0]];
		int q=indices[a[1]];
		f(s,p);
		f(p+1,q);
		f(q+1,e);
	}
	cout << endl;

	return 0;
}



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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+5, mod = 1e9+7;

void solve() {
    int n, d; cin >> n >> d;

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        double x, y; cin >> x >> y;

        x = pow(x, 2);
        y = pow(y, 2);

        double z = sqrt(x + y);
        if (z <= d) {
            ++ans;
        }
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1; 
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 3804
def main():
  MOD = 1000000007
  n, l = map(int, input().split())
  xlst = map(int, input().split())
  alst = map(int, input().split())
  can_use = []
  for x, a in zip(xlst, alst):
    if a == 0:s = {x}
    else:s = {k for k in range(x, l, a)}
    can_use.append(s)
  
  dp = [[0] * l for _ in range(n)]
  for j in range(l):
    dp[0][j] = dp[0][j - 1] + int(j in can_use[0])
  
  for i in range(1, n):
    acc = 0
    dpi = dp[i]
    dpi1 = dp[i - 1]
    st = can_use[i]
    for j in range(1, l):
      if j in st:acc = (acc + dpi1[j - 1]) % MOD
      dpi[j] = acc
  print(dp[n - 1][l - 1])

main() 


Measured memory_bytes: 1235264
#-*-coding:utf-8-*-

def main():
    s = input()
    n = int(input())
    for _ in range(n):
        commands=input().split()
        if commands[0]=="replace":
            s=s[:int(commands[1])]+commands[3]+s[int(commands[2])+1:]
        elif commands[0]=="reverse":
            reverse_point=s[int(commands[1]):int(commands[2])+1]
            s=s[:int(commands[1])]+reverse_point[::-1]+s[int(commands[2])+1:]
        elif commands[0]=="print":
            print(s[int(commands[1]):int(commands[2])+1])

if __name__=="__main__":
    main()


Measured memory_bytes: 5620
n = gets.chomp.to_i

ans = []

n.times do |i|
  ans_count = gets.chomp.to_i
  ans[i] = []
  ans_count.times do |j|
    x, y = gets.chomp.split.map(&:to_i)
    ans[i][j] = [x - 1, y == 1]
  end
end

[true, false].repeated_permutation(n) do |comb|
  catch :next_comb do
    n.times do |i|
      next unless comb[i]
      #i番目の人が正直なとき矛盾するかどうか
      ans[i].each do |an|
        #an[0]番目の人がan[1]だと言っている
        throw :next_comb if comb[an[0]] != an[1] #矛盾していたら終了
      end
    end
    puts comb.count {|c| c }
    exit
  end
end


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int n;
ll dp[101][100010];

int main() {
	int capacity;
	cin >> n >> capacity;
	vector<int> w(n);
	vector<ll> v(n);
	rep(i,n) {
		cin >> w[i] >> v[i];
	}
	rep(i,n) {
		for(int j=0; j<=capacity; j++) {
			if(i==0) {
				if(j>=w[0]) dp[0][j] = v[0];
				else dp[0][j] = 0;
			}
			else {
				if (j >= w[i]) {
					dp[i][j] = max(dp[i - 1][j - w[i]] + v[i], dp[i - 1][j]);
				}
				else {
					dp[i][j] = dp[i-1][j];
				}
			}
		}
	}
	cout << dp[n-1][capacity] << endl;
  return 0;
}


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

main() {
  int N, T; cin >> N >> T;
  vector<int> t(N); for (int i = 0; i < N; i++) cin >> t[i];

  ll ans = T;
  for (int i = 1; i < N; i++) ans += min(T, t[i] - t[i - 1]);
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

ll moddiff(ll a, ll b) {
  ll res = a - b;
  if (res < 0) res += MOD;
  return res;
}

ll modpow(ll a, ll n) {
  ll res = 1;
  while(n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while(b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

ll nCr(ll n, ll r){
  ll num = 1;
  for(int i = 1; i <= r; i++){
      num = num * (n - i + 1) % MOD;
      num = num * modinv(r - i + 1, MOD) % MOD;
  }
  return num;
}

void solve(istream& cin, ostream& cout) {
  int n, a, b;
  cin >> n >> a >> b;
  ll ans;
  ans = moddiff(modpow(2, n), 1);
  ans = moddiff(ans, nCr(n, a));
  ans = moddiff(ans, nCr(n, b));
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b[10000],c,d,s,i;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&b[i]);
  }
  d=a-1;
  for(i=d;i>=0;i--){
    if (i>0)printf("%d ",b[i]);
    else printf("%d",b[i]);
  }
  printf("\n");
  return 0;
}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = (x << 3) + (x << 1) + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;

int main() {
  int n =read(), m=read();
  cout << n * (n - 1) / 2 + m * (m - 1) / 2;
  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* [💭] [💡] [🎈] */

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

    string str;
    cin >> str;
    if (str[1]=='B') {
        cout << "ARC";
    } else {
        cout << "ABC";
    }

    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
int main(void)
{
	char str[100000];
	int l,i,c=0;
	scanf("%s",str);
	l=strlen(str);
	for(i=0;i<l-1;i++){
		if(str[i]!=str[i+1]) c++;
	}
	printf("%d\n",c);
	return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  int WA[N+1];
  bool AC[N+1];
  rep(i, N+1){
    AC[i] = false;
    WA[i] = 0;
  }
  rep(i, M){
    int p;
    string s;
    cin >> p >> s;
    if (AC[p]==true) continue;
    else if (s=="AC"){
      AC[p] = true;
    }
    else WA[p]++;
  }
  int sum_wa = 0;
  int sum_ac = 0;
  rep(i, N+1){
    if (AC[i]) sum_wa += WA[i];
    sum_ac += AC[i];
  }
  cout << sum_ac << " " << sum_wa << endl;
}


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

int main(){
  long long n;
  cin>>n;
  long long sum=0;
  
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  
  for(int i=0;i<n-1;i++){
    if(a[i]>a[i+1]){
      sum+=a[i]-a[i+1];
      a[i+1]=a[i];
    }
  }
  cout<<sum<<endl;
}



Measured memory_bytes: 3928
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
} 
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int k;
	cin>>k;
	if(k%2==0||k%5==0)cout<<"-1\n";
	else{
		int h=0;
		fo(i,0,k+2){
			h=(h*10+7)%k;
			if(h==0){
				cout<<i+1<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {

	long long int n;
	cin >> n;

	long long int ans = 0;
	long long int ans2 = 0;

	long long int n2 = n;
	while (n2 > 0) {
		ans += (n2 % 10LL);
		n2 /= 10LL;
	}

	while (n >= 10) {
		ans2 += 9LL;
		n /= 10LL;
	}
	ans2 += n;
	ans2--;

	cout << max(ans, ans2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cfenv>
using ll = unsigned long long;
using namespace std;
int gcd(int x,int y){
    if(y==0){
        return x;
    }else{
        return gcd(y,x%y);
    }
}
int lcm(int x,int y){
    return x/gcd(x,y)*y;
}
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> vec1(n);
    vector<int> vec2(n);
    if(s[0]=='#'){
        vec1[0]=1;
    }
    if(s[n-1]=='.'){
        vec2[n-1]=1;
    }
 //   int c=0;
    for(int i=1;i<n;i++){
        vec1[i]=vec1[i-1];
        if(s[i]=='#'){
            vec1[i]++;
        }
    }
    for(int i=n-2;i>=0;i--){
        vec2[i]=vec2[i+1];
        if(s[i]=='.'){
            vec2[i]++;
        }
    }
    int Min=vec1[n-1];
    Min = min(vec2[0],Min);
  //  cout<<Min<<endl;
    for(int i=0;i<n;i++){
        Min = min({Min,vec1[i]+vec2[i+1]});
    //    cout<<vec1[i]+vec2[i]<<endl;
    }
    cout<<Min<<endl;
}

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

int main(){
	int n, d;
	scanf("%d %d", &n, &d);
	int ans = 0;
	for (int i=1; i<=n; i += (2*d+1)){
		ans++;
		if(i+d > n) break;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
bool cmp (int a, int b) {
	return a > b;
}
int a[100005];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort (a + 1, a + 1 + n, cmp);
	int ans = 0;
	bool b = 0;
	for (int i = 1; i <= n + 1; i++) {
		if (a[i] == i){
			ans = i;
			break;
		}
		if (a[i] < i) {
			ans = i - 1;
			b = 1;
			break;
		}
	}
	bool sum = 0;
	if (!b) {
		sum = 1;
		for (int i = ans + 1; ; i++) {
			if (ans != a[i]) break;
			sum = !sum;
		}
	}
	else {
		sum = (a[ans] - ans + 1) % 2;
		if (ans == a[ans + 1] && sum == 1) {
			sum = 1;
			for (int i = ans + 1; ; i++) {
				if (ans != a[i]) break;
					sum = !sum;
			}
		} 
	}
	cout << (sum ? "Second" : "First");
	return 0;
}

Measured memory_bytes: 640
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 200005;

vector<pair<ll, ll>> a;
vector<ll> b;
ll f[N], h[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    ll cons;
    cin >> n >> cons;
    rep(i, 0, n) {
        cin >> h[i];
    }
    b.emplace_back(1);
    a.emplace_back(make_pair(-2 * h[0], h[0]*h[0] + cons));
    rep(i, 1, n) {
        int x = lower_bound(b.begin(), b.end(), h[i]) - b.begin();
        if(x == sz(b)) {
            x--;
        }
        if(b[x] > h[i]) {
            x--;
        }
        f[i] = a[x].first * h[i] + h[i] * h[i] + a[x].second;
        pair<ll, ll> c = make_pair(-2 * h[i], f[i] + h[i] * h[i] + cons);
        if(a.back().first * h[n - 1] + a.back().second <= c.first * h[n - 1] +
           c.second) {
            continue;
        }
        while(!b.empty()) {
            if(a.back().first * b.back() + a.back().second >= c.first * b.back() +
               c.second) {
                b.pop_back();
                a.pop_back();
            } else {
                break;
            }
        }
        if(b.empty()) {
            b.emplace_back(1);
        } else {
            ll lo = b.back();
            ll hi = h[n - 1];
            while(lo < hi) {
                ll mi = (lo + hi) / 2;
                if(c.first * mi + c.second < a.back().first * mi + a.back().second) {
                    hi = mi;
                } else {
                    lo = mi + 1;
                }
            }
            b.emplace_back(lo);
        }
        a.emplace_back(c);
    }
    cout << f[n - 1] << endl;
}

Measured memory_bytes: 10468