akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define ll long long

int bin_pow(int a, int pow) {
    if (pow == 0) return 1;
    if (pow == 1) return a;
    if (pow % 2 == 0) {
        int tmp = bin_pow(a, pow / 2);
        return tmp * tmp;
    }
    return a * bin_pow(a, pow - 1);
}

int fact(int x) {
    int ans = 1;

    for (int i = 1; i <= x; i++) ans *= i;
    return ans;
}

int count(vector<int> a) {
    int ans = 0;
    unordered_set<int> was;
    for (int i = 0; i < a.size(); i++) {
        int count = a[i] - 1;
        for (int j = 1; j < a[i]; j++) {
            count -= was.count(j);
        }
        ans += count * fact(a.size() - i - 1);
        was.insert(a[i]);
    }

    return ans;
}

ll m = 1000000007;

bool isPrime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

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

    int a, b;
    cin >> a >> b;

    map<int, int> m;

    for (int i = 2; i * i <= a; i++) {
        int cnt = 0;
        while (a % i == 0) {
            a /= i;
            cnt++;
        }
        m[i] = max(m[i], cnt);
    }

    if (a != 1) {
        m[a] = max(m[a], 1);
    }

    for (int i = 2; i * i <= b; i++) {
        int cnt = 0;
        while (b % i == 0) {
            b /= i;
            cnt++;
        }
        m[i] = max(m[i], cnt);
    }

    if (b != 1) {
        m[b] = max(m[b], 1);
    }

    ll ans = 1;

    for (pair<int, int> mm : m) {
        ans *= bin_pow(mm.first, mm.second);
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <cctype>
#include <iostream>
using namespace std;
typedef string::const_iterator State;

map<string,int> table;
bool flag;

int expression(State &begin);
int factor(State &begin);
int atom(State &begin);
int number(State &begin);

int number(State &begin){
	int ret=0;
	while(isdigit(*begin)){
		ret*=10;
		ret+=*begin-'0';
		begin++;
	}
	return ret;
}

int atom(State &begin){
	string name="";
	name+=*begin;
	begin++;
	if(*begin>='a' && *begin<='z'){
		name+=*begin;
		begin++;
	}
	if(table.find(name)==table.end()){
		flag=false;
		return -1;
	}
	int ret=table[name];
	if(isdigit(*begin))ret*=number(begin);
	return ret;
}

int factor(State &begin){
	if(*begin=='('){
		begin++;
		int ret=expression(begin);
		begin++;
		if(isdigit(*begin)){
			ret*=number(begin);
		}
		return ret;
	}else return atom(begin);
}

int expression(State &begin){
	if(!flag)return -1;
	int ret=0;
	while(1){
		if(*begin>='A' && *begin<='Z'){
			ret+=factor(begin);
		}else if(*begin>='a' && *begin<='z'){
			flag=false;
			return -1;
		}else if(isdigit(*begin)){
			ret*=factor(begin);
		}else if(*begin=='('){
			ret+=factor(begin);
		}else break;
	}
	return ret;
}


int main(void){
	while(1){
		string str;
		cin >> str;
		if(str=="END_OF_FIRST_PART")break;
		int x;
		scanf("%d",&x);
		table[str]=x;
	}
	while(1){
		string str;
		cin >> str;
		if(str=="0")break;
		State begin=str.begin();
		flag=true;
		int res=expression(begin);
		if(!flag)printf("UNKNOWN\n");
		else printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 1268
import math

li=[int(input()) for _ in range(5)]
m,last,ans,lm=10,li[0],0,0

for i in range(5):
  l = li[i]
  if 0 < l % 10 < m :
    m = l % 10
    last = l
    lm = i

for i in range(5):
  l=li[i]
  if l == last and i == lm:
    ans += l
  else:
    ans += math.ceil(l/10)*10
    
print(ans)

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

#define int long long
#define F first
#define S second
#define vi vector<int>


void mymain(){
    int n;
    cin >> n;
    vi arr(n);
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    int t = 1;
    for(int i=0;i<n;i++){
        if(arr[i]==t)
            t++;
    }
    t--;
    if(t==0)
        cout << -1 <<endl;
    else
        cout << n-t << endl;

}


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--){
        mymain();
    }
}


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

grid = []
for i in range(H):
    s = input()
    if s != "." * W:
        grid.append(list(s))

H = len(grid)

for i in reversed(range(W)):
    if all(grid[j][i] == "." for j in range(H)):
        for k in range(H):
            grid[k].pop(i)

print("\n".join("".join(r) for r in grid))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

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

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Comparator;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        SequenceDecomposing solver = new SequenceDecomposing();
        solver.solve(1, in, out);
        out.close();
    }

    static class SequenceDecomposing {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = Long.parseLong(in.next());
            }

            List<Long> list = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                long aa = a[i];
                int pos = Collections.binarySearch(list, aa, new LowerBoundComparator<>());
                if (pos < 0) {
                    pos = ~pos;
                }
                if (pos == 0) {
                    list.add(0, aa);
                } else {
                    list.set(pos - 1, aa);
                }
            }
            out.println(list.size());

        }

        class LowerBoundComparator<T extends Comparable<? super T>> implements Comparator<T> {
            public int compare(T x, T y) {
                return (x.compareTo(y) >= 0) ? 1 : -1;
            }

        }

    }
}



Measured memory_bytes: 60936
#include<stdio.h>
   int n;
   int d[105];
   int main()
   {
   while(scanf("%d",&n)!=EOF)
      {
      int sum=0;	
      for(int i=0;i<n;i++)
	     scanf("%d",&d[i]);
	  for(int i=0;i<n;i++)
	     {
	     for(int j=i+1;j<n;j++)
		 sum=sum+d[i]*d[j];	
	     }
	  printf("%d\n",sum);   
      }
	 return 0; 	
   } 

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

int main()
{
  long long n,a[1000000];
  vector<string> b; 
  long long sum=0;
  cin>>n;
  
  for(int i=0;i<n;i++)
  {
    a[i]=i+1;
    if(a[i]%3==0 && a[i]%5==0)
    {
      b.push_back("FizzBuzz");
     // b[i]="FizzBuzz";
      
    }
    else if(a[i]%3==0)
    {
    b.push_back("Fizz");
     //b[i]="Fizz";
    }
    else if(a[i]%5==0)
    {
        b.push_back("Buzz");
     // b[i]="Buzz";
    }
    else
    {
    string s=to_string(i+1);
      b.push_back(s);
     // b[i]=to_string(i);
    }

  }
   
   for(int i=0;i<n;i++)
   {
     
     if(b[i]=="FizzBuzz" || b[i]=="Fizz" || b[i]=="Buzz")
     {
         continue;
     }
     else
     {
        sum+=a[i];
     }
   }
   cout<<sum<<endl;
  
  
  
  return 0;
}


Measured memory_bytes: 42392
#!python3

def resolve():
    A, B = map(int, input().rstrip().split(" "))

    a = b = 2
    X = A
    Y = B
    while True:
        if X == Y:
            break
        elif X < Y:
            X += A
        else:
            Y += B

    print(X)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 2940
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,A,B;
	while(cin>>N>>A>>B) {
		ll a = N/(A+B);
		ll ans = a*A;
		ll rest = N-(A+B)*a;
		ans += min(A, rest);
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// Welcome to my source code!

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    bool flag = true;
    if (a == b && a != c) flag = false;
    else if (b == c && b != a) flag = false;
    else if (a == c && c != b) flag = false;
    if (!flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n-1; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long ll;
using namespace std;


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}

class UnionFind
{
public:
    vector<ll> par; // 各元の親を表す配列
    vector<ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL)
    {
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_)
    {
        siz.assign(sz_, 1LL); // assign: 再代入
        par.resize(sz_);      // resize: 再確保
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x)
    { // 根の検索
        while (par[x] != x)
        {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y])
            swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y)
    { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x)
    { // 素集合のサイズ
        return siz[root(x)];
    }
};

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

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

////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////
int main()
{
    // input
    ll N, M;
    ll node1, node2;
    cin >> N >> M;
    vector<pair<ll,ll>> A(M);
    for (ll i = 0; i < M; i++)
    {
        cin >> node1 >> node2;
        --node1, --node2;
        A[i].first = node1;
        A[i].second = node2;
    }

    // calculation
    vector<ll> ans(M);
    ans[M - 1] = (N * (N - 1)) / 2; // 全ての頂点が孤立している状態

    UnionFind uf(N);
    for (ll i = M - 1; i >= 1; --i)
    {
        node1 = A[i].first, node2 = A[i].second;
        if (uf.issame(node1, node2))
        {
            ans[i - 1] = ans[i];
        }
        else
        {
            // 根が異なるとき，それぞれのサイズの積（頂点の組み合わせ）を引く．
            ans[i - 1] = ans[i] - (uf.size(node1) * uf.size(node2));
            uf.merge(node1, node2);
        }
    }

    REP(i, M)
    {
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 5248
#include <stdio.h>

#define inf 2000000
#define NIL -1000000
#define BLACK 9999999
#define WHITE 8888888

typedef struct{
  int u;
  int k;
  int v[3000];
  int c[3000];
}graph;


void dijkstra(int n, graph w[n], int d[n], int color[n], int pi[n]){
  int i,j,u;
  int mincost;
  for(i = 0; i < n; i++){
    d[i] = inf;
    pi[i] = NIL;
    color[i] = WHITE;
  }
  d[0] = 0;

  while(1){
    mincost = inf;
    for(i = 0; i < n; i++){
      if(color[i] != BLACK && d[i] < mincost){
        mincost = d[i];
        u = i;
      }
    }
    if(mincost == inf)
      break;

    color[u] = BLACK;

    for(j = 0; j < 1000; j++){
//      printf("  d[%d] + w[%d].c[%d] < d[%d] ?\n", u, u, j, j);
//      printf("    %d + %d < %d ?\n", d[u], w[u].c[j], d[j]);
      if(color[j] != BLACK && d[u] + w[u].c[j] < d[j] && w[u].c[j] != inf){
        pi[j] = u;
        d[j] =  d[u] + w[u].c[j];
      }
    }
  }
}

int main(){
  int i,j,k,n,u;
  int tmpj;

  scanf("%d", &n);

  graph w[n];
  for(i = 0; i < n; i++)
    for(j = 0; j < 3000; j++)
      w[i].c[j] = w[i].v[j] = inf;

  int d[n];
  int color[n];
  int pi[n];

  for(i = 0; i < n; i++){
    scanf("%d%d", &w[i].u, &w[i].k);
    for(j = 0; j < w[i].k; j++){
      scanf("%d", &tmpj);
      w[i].v[tmpj] = tmpj;
      scanf("%d", &w[i].c[tmpj]);
    }
  }

  dijkstra(n, w, d, color, pi);

  for(i = 0; i < n; i++){
    printf("%d %d\n", w[i].u, d[i]);
  }
  return 0;
}

Measured memory_bytes: 2944
#include "bits/stdc++.h"

using namespace std;

int main()
{
    int x, y;
    cin >> x >> y;
    if (x > y) {
        cout << "a > b" << endl;
    }
    else if (x == y) {
        cout << "a == b" << endl;
    }
    else {
        cout << "a < b" << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
n=int(input())
a=list(map(int,input().split()))

import heapq
while len(a)>1:
    heapq.heapify(a)
    s=heapq.heappop(a)
    an=[s]
    for i in range(len(a)):
        m=a[i]%s
        if m>0:
            an.append(m)
    a.clear()
    a=an
print(s)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int N, K;
    cin >> N >> K;
    vector<int> num(N, 0);
    REP (i, K) {
        int d;
        cin >> d;
        REP (j, d) {
            int A;
            cin >> A;
            A--;
            num[A]++;
        }
    }
    int ans = 0;
    REP (i, N) ans += (num[i] == 0);
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int Day, num, A;
  cin >> Day >> num;
  for (int i = 0; i < num; i++){
    cin >> A;
    Day -= A;
  }
  cout << ((Day >= 0)? Day : -1) << '\n';
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool flg;
int expr(string s,int& p);
int term(string s,int& p);
int factor(string s,int& p);
int number(string s,int& p);
int expr(string s,int& p){
  int res=term(s,p);
  while(p<(int)s.size()){
    if(flg) return 0;
    if(s[p]=='+'){
      p++;
      res+=term(s,p);
      continue;
    }
    if(s[p]=='-'){
      p++;
      res-=term(s,p);
      continue;
    }
    break;
  }
  return res;
}
int term(string s,int& p){
  int res=factor(s,p);
  while(p<(int)s.size()){
    if(flg) return 0;
    if(s[p]=='*'){
      p++;
      res*=factor(s,p);
      continue;
    }
    break;
  }
  return res;
}
int factor(string s,int& p){
  int res;
  if(s[p]=='-'){
    p++;
    res=-factor(s,p);
  }else if(s[p]=='('){
    p++;
    res=expr(s,p);
    if(p>=(int)s.size()||s[p]!=')'){
      flg=1;
      return 0;
    }
    p++;
  }else if(isdigit(s[p])){
    res=number(s,p);
  }else{
    flg=1;
    return 0;
  }
  return res;
}
int number(string s,int& p){
  if(s[p]=='0'){
    if(p+1<(int)s.size()&&isdigit(s[p+1])){
      flg=1;
      return 0;
    }
    p++;
    return 0;
  }
  int res=0;
  while(p<(int)s.size()&&isdigit(s[p])) res=res*2+s[p++]-'0';
  return res;
}
bool check(string s){
  if(s.size()==0) return 0;
  int op=0;
  for(int i=0;i<(int)s.size();i++){
    if(s[i]=='(') op++;
    if(s[i]==')') op--;
    if(op<0) return 0;
  }
  if(op) return 0;
  return 1;
}
//set<string> ss;
int Q(string s){
  if(count(s.begin(),s.end(),'=')!=1) return 0;
  int k=s.find('=');
  string a=s.substr(0,k);
  string b=s.substr(k+1,s.size()-(k+1));
  if(!check(a)) return 0;
  if(!check(b)) return 0;
  //cout<<s<<endl;
  //cout<<a<<" "<<b<<endl;
  flg=0;
  int p=0;
  int x=expr(a,p);
  //cout<<flg<<" "<<p<<" "<<x<<endl;
  if(flg||p!=(int)a.size()) return 0;
  p=0;
  int y=expr(b,p);
  //cout<<flg<<" "<<p<<" "<<y<<endl;
  if(flg||p!=(int)b.size()) return 0;
  //cout<<a<<" "<<b<<endl;
  //cout<<x<<":"<<y<<endl;
  return x==y;
}
int ans=0;
string l="01+-*()=";
void dfs(string s,int b){
  bool f=1;
  for(int i=0;i<(int)s.size();i++){
    if(!isalpha(s[i])) continue;
    f=0;
    char c=s[i];
    for(int j=0;j<(int)l.size();j++){
      if((b>>j)&1) continue;
      string t=s;
      for(int k=0;k<(int)s.size();k++){
	if(t[k]==c) t[k]=l[j];
      }
      dfs(t,b+(1<<j));
    }
    break;
  }
  if(f) ans+=Q(s);
}
signed main(){
  string s;
  cin>>s;
   
  dfs(s,0);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3196
from sys import stdin
mod = 10**9+7
n,a,b = [int(x) for x in stdin.readline().rstrip().split()]

maxn = max(a,b)
inv = [0,1] + [0]*maxn
for i in range(2,maxn+1):
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    
allc = pow(2,n,mod) - 1

def comb(n,r):
    res = 1
    for i in range(1,r+1):
        res *= (n-i+1)
        res *= inv[i]
        res %= mod
    return res

ans = allc - comb(n,a) - comb(n,b)
ans %= mod
print(ans)

Measured memory_bytes: 10952
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

const long long M = 1000000007;

void solveNCC(){
	int n, c;
	cin >> n >> c;

	vector<int> a(n), b(n);
	cin >> a >> b;

	assert(a == b);

	// make table
	auto t = vectors(500, 500, 0LL);
	range(i,1,500){
		t[i][0] = 1;
		range(j,1,500){
			(t[i][j] = t[i][j - 1] * i) %= M;
		}
	}

	auto dp = vectors(n + 1, c + 1, 0LL);
	dp[0][0] = 1;
	rep(i,n){
		rep(j,c + 1){
			rep(k,c + 1){
				if(j + k > c) break;
				(dp[i + 1][j + k] += (dp[i][j] * t[a[i]][k]) % M) %= M;
			}
		}

		rep(i,dp.size()){ rep(j,dp[0].size()){ cout << dp[i][j] << ' '; } cout << endl; } cout << endl;
	}
	cout << dp[n][c] << endl;
}

void solveNC(){
	int n, c;
	cin >> n >> c;

	vector<int> a(n), b(n);
	cin >> a >> b;

	assert(a == b);

	auto dp = vectors(n + 1, c + 1, 0LL);
	dp[0][0] = 1;
	range(i,1,n + 1){
		dp[i][0] = 1;
		rep(j,c){
			dp[i][j + 1] = (dp[i][j] * a[i - 1] % M + dp[i - 1][j + 1]) % M;
		}

		//rep(i,dp.size()){ rep(j,dp[0].size()){ cout << dp[i][j] << ' '; } cout << endl; } cout << endl;
	}
	cout << dp[n][c] << endl;
}

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

	vector<int> a(n), b(n);
	cin >> a >> b;


	auto dp = vectors(n + 1, c + 1, 0LL);
	dp[0][0] = 1;
	range(i,1,n + 1){
		//dp[i][0] = 1;

		auto _dp = vectors(c + 1, 405, 0LL);
		range(k,a[i - 1],b[i - 1] + 1){
			_dp[0][k] = dp[i - 1][0];
			rep(j,c){
				_dp[j + 1][k] = (_dp[j][k] * k % M + dp[i - 1][j + 1]) % M;
			}
		}

		//rep(i,_dp.size()){ rep(j,4){ cout << _dp[i][j] << ' '; } cout << endl; } cout << endl;

		rep(j,c + 1){
			rep(k,405){
				(dp[i][j] += _dp[j][k]) %= M;
			}
		}

		//rep(i,dp.size()){ rep(j,dp[0].size()){ cout << dp[i][j] << ' '; } cout << endl; } cout << endl;
	}
	cout << dp[n][c] << endl;
}


Measured memory_bytes: 2856
N,A,B,K = map(int,input().split())
sprime = 998244353 # approx 10**9
A,B = sorted((A,B))
if (A+B) * N < K:
	print(0)
	exit()
 
def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)
 
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m
 
memo = [0] * (N+1)
memo[0] = memo[N] = 1
for i in range(1,N//2+1):
	v = memo[i-1] * (N-i+1) * modinv(i,sprime)
	v = v % sprime
	memo[i] = memo[N-i] = v
 
# max is A*N + B*N
sum = 0
for b in range(N+1):
  a = (K-b*B)//A
  if 0 <= a <= N and a*A+b*B == K:
    sum += memo[a]*memo[b]
    sum %= sprime

print(sum)

Measured memory_bytes: 10128
x=int(input())
ans=0
if x>=2000:
    print(1)
else:
    for a in range(20):
        for b in range(20):
            for c in range(20):
                for d in range(20):
                    for e in range(20):
                        for f in range(20):
                            if 100*a+101*b+102*c+103*d+104*e+105*f==x:
                                ans=1
    print(ans)


Measured memory_bytes: 45960
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = 50;
vector < ll > ps;
void Go(int a,int b,int k = N,ll mask = 0) {
    if (!k) {
        if (a == b) 
            ps.pb(mask);
    } else {
        Go(a,b,k - 1,mask);
        if (a >= k && (a % k) >= b)
            Go(a % k,b,k - 1,mask | (1ll << k));
    }
}
int main(void)
{
    int n;
    cin>>n;
    vi a(n);
    vi b(n);
    for (auto & it : a)
        cin>>it;
    for (auto & it : b)
        cin>>it;
    vector < vector < ll > > s;
    for (int i = 0;i < n;++i) {
        ps.clear();
        Go(a[i],b[i]);
        if (ps.empty())
            return puts("-1") * 0;
        s.pb(ps);
    }
    ll ans = 0;
    for (int t = 50;t;--t) {
        int ok = 1;
        for (auto v : s) {
            int nw = 0;
            for (auto it : v)
                if (!((it >> t) & 1))
                    nw = 1;    
            ok &= nw;
        }
        if (ok) {
            vector < vector < ll > > ss;
            for (auto v : s) {
                vector < ll > vv;
                for (auto it : v)
                    if (!((it >> t) & 1))
                        vv.pb(it);
                ss.pb(vv);
            }
            s = ss;
        } else {
            ans |= 1ll << t;
        }
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std;
int main() {
  string s;
  cin >> s;
  if (s == "SUN")
    cout << 7 << endl;
  else if (s == "MON")
    cout << 6 << endl;
  else if (s == "TUE")
    cout << 5 << endl;
  else if (s == "WED")
    cout << 4 << endl;
  else if (s == "THU")
    cout << 3 << endl;
  else if (s == "FRI")
    cout << 2 << endl;
  else if (s == "SAT")
    cout << 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
constexpr double hRAD=0.00872664625997164773718584029893463593907654285431L;
signed main(void)
{
  int A,B,H,M;
  if(~scanf("%d %d %d %d",&A,&B,&H,&M))
  {
    double theta=(60*H-11*M)*hRAD,x=A-B*cos(theta),y=B*sin(theta);
    return printf("%.20f",pow(x*x+y*y,0.5)),0;
  }
}

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

ll f(ll n, ll x)
{
  if(n == -1) return 0;
  return n/x + 1; 
}

int main()
{
  ll a, b, x;
  cin >> a >> b >> x;
  
  cout << f(b,x) - f(a-1,x) << endl; 
}

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

int main () {
  int N , K ;
  string S ;
  cin >> N >> S >> K ;
  char a = S[K-1] ;
  for(int i = 0 ; i < N ; i++ ){
    if(S[i]==a) cout << a ;
    else cout << '*' ;
  }
  cout << endl ;
}


Measured memory_bytes: 256
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let (a, b, c): (String, String, String);
    input!(a, b, c);
    let q = a.to_charvec();
    let w = b.to_charvec();
    let e = c.to_charvec();
    if *q.last().unwrap() == w[0] && *w.last().unwrap() == e[0] {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m; cin>>n>>m;
  //vector<vector<int>> road(n,vector<int>(n,0));
  vector<int> h(n);
  vector<bool> flag(n,true);
  for(int i=0;i<n;i++) cin>>h[i];
  int tmp_a,tmp_b;
  for(int i=0;i<m;i++){
    cin>>tmp_a>>tmp_b;
    /*
    road[tmp_a-1][tmp_b-1]=1;
    road[tmp_b-1][tmp_a-1]=1;
    */
    if(h[tmp_a-1]>h[tmp_b-1]) flag[tmp_b-1]=false;
    if(h[tmp_a-1]<h[tmp_b-1]) flag[tmp_a-1]=false;
    if(h[tmp_a-1]==h[tmp_b-1]) {flag[tmp_b-1]=false;flag[tmp_a-1]=false;}
  }
  int ans=0;
  //bool flag=true;
  for(int i=0;i<n;i++){
    if(flag[i]){ans++;}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string a,b,c;
    int flg=1;
    cin>>a>>b>>c;
    for(;;){
        if(flg==1){
            if(a.size()==0){
                printf("A\n");
                return 0;
            }
            if(a[0]=='b')flg=2;
            if(a[0]=='c')flg=3;
            a.erase(a.begin()+0);
        }
        if(flg==2){
            if(b.size()==0){
                printf("B\n");
                return 0;
            }
            if(b[0]=='a')flg=1;
            if(b[0]=='c')flg=3;
            b.erase(b.begin()+0);
        }
        if(flg==3){
            if(c.size()==0){
                printf("C\n");
                return 0;
            }
            if(c[0]=='a')flg=1;
            if(c[0]=='b')flg=2;
            c.erase(c.begin()+0);
        }
    }
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0

for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            total = 500*a + 100*b + 50*c
            if total == X:
                cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n;cin>>n;cout<<n*n;}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int ans=9999999;
int main(){
	int n,a[1000],sum=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=-100;i<=100;i++){
		sum=0;
		for(int j=0;j<n;j++){
			sum+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
import datetime

# 入力
#N = int(input())
#S = str(input())
#N, A, B = map(int, input().split())
A, B = map(int, input().split())

list = []
list.append(A+B)
list.append(A-B)
list.append(A*B)
list.sort()

print (list[2])


Measured memory_bytes: 3312
a, b = input().split()

i = 1
A = a
while i < int(b):
    A = A + a
    i = i + 1

i = 1
B = b
while i < int(a):
    B = B + b
    i = i + 1

#print(A)
#print(B)

if A < B:
    print(A)
else:
    print(B)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    int A_num, Z_num;
    for (int i = 0; i < S.size(); i++)
    {
        if (S.at(i) == 'A')
        {
            A_num = i;
            break;
        }
    }
    for (int i = 0; i < S.size(); i++)
    {

        if (S.at(i) == 'Z')
        {
            Z_num = i;
            
        }
    }
    cout << Z_num - A_num + 1 << endl;
}



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

int main() {
  int H,N;
  cin >> H >> N;
  int ans = 0;
  for (int i = 0;i<N;i++) {
    int a;
    cin >> a;
    ans += a;
  }
  if (ans >= H) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--) 
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const double pi = 3.14159265358979323846;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	string t; cin >> t;
	rep(i, t.size()) {
		if (t[i] == '?') {
			t[i] = 'D';
		}
	}
	cout << t << endl;
}


Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = 1e9;
int h, w, d;
vector< vector<int> > c(300, vector<int>(300, inf));
map<int, pair<int, int> > p;

void init(){
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      p[ c[i][j] ] = {i, j};
    }
  }
}

int main() {
  cin >> h >> w >> d;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> c[i][j];
    }
  }
  init();
  vector<int> dist(h*w+1, 0);
  for(int i=1; i+d<=h*w; i++){
    dist[i+d] = dist[i] + abs(p[i].first-p[i+d].first) + abs(p[i].second-p[i+d].second);
  }
  int q;
  cin >> q;
  for(int i=0; i<q; i++){
    int l, r;
    cin >> l >> r;
    int sum = 0;
    sum = dist[r] - dist[l];
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 7680
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := makeWordScanner()
	eGetInt(scanner)
	s := eGetChars(scanner)
	t := eGetChars(scanner)
	for i := 0; i < len(s); i++ {
		fmt.Print(s[i])
		fmt.Print(t[i])
	}
	fmt.Println("")
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	return int(math.Pow(float64(a), float64(n)))
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
// #include<unordered_map>
#include<set>
// #include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y, idx;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

template<typename T>
T minT(T a, T b) {
	if (a < b) return a;
	else return b;
}

template<typename T>
T maxT(T a, T b) {
	if (a > b) return a;
	else return b;
}

template<typename T>
T absT(T a) {
	if (a < 0) a *= -1;
	return a;
}

template<typename T>
T powT(T a, T x) {
	T res = 1;
	while (x > 0) {
		if (x & 1) res = res * a;
		a = a * a;
		x >>= 1;
	}
	return res;
}

ll StoLL(string str) {
	ll ret = 0, ini = 0;
	if (str[0] == '-') ini = 1;
	repi(i, ini, str.length()) {
		ret *= 10;
		ret += (ll)(str[i] - '0');
	}
	if (ini) ret *= -1;
	return ret;
}

///////////////////////////////////////////////////////////////////////////////////////

ll N, M, Q;
ll countM[510][510], sumM[510][510];
ll ans;

int main() {
	cin >> N >> M >> Q;
	repi(i, 0, M) {
		ll L, R;
		cin >> L >> R;
		countM[L][R] += 1;
	}
	repi(i, 1, N + 1) {
		sumM[i][i] = countM[i][i];
		repi(j, i + 1, N + 1) {
			sumM[i][j] = countM[i][j] + sumM[i][j - 1];
		}
	}
	repi(q, 0, Q) {
		ll L, R;
		ans = 0;
		cin >> L >> R;
		repi(i, L, R + 1) {
			ans += sumM[i][R];
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int N, M;
vector < vector<int> > edge(20);
int ans = 0;

int main(){
  cin >> N >> M;
  rep(i, M){
    int a, b; cin >> a >> b;
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  int r[N];
  rep(i, N) r[i] = i;
  do{
    if (r[0] != 0) continue;
    bool flag = true;
    rep(i, N-1){
      if (find(begin(edge[r[i]]), end(edge[r[i]]), r[i+1]) == end(edge[r[i]])){
        flag = false;
        break;
      }
    }
    if (flag) ans++;
  }while(next_permutation(r, r+N));
  cout << ans << endl;
}


Measured memory_bytes: 3612
from collections import deque
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(lambda x: int(x)-1, input().split())

    g[a].append(b)
    g[b].append(a)

q = deque()
q.append(0)
dist = [-1 for _ in range(n)]
dist[0] = 0
to = {}

while(len(q) > 0):
    v = q.popleft()

    for nv in g[v]:
        if(dist[nv] != -1): continue
        
        dist[nv] = dist[v] + 1
        to[nv] = v
        q.append(nv)

print('Yes')
for i in range(1, n):
    print(to[i]+1)

Measured memory_bytes: 41648
#include<bits/stdc++.h>
#define int long long 
using namespace std;
vector<int>all;
int a,b;



bool can(int index)
{
  int total=0;
  for(int i=0;i<a;i++)
  {
    total+=(all[i]-1)/index;
  }

  return total<=b;
}


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

   // int a,b;
    cin>>a>>b;
    
    for(int i=0;i<a;i++)
    {
      int first;
      cin>>first;
      all.push_back(first);
    }

    int lo=1,hi=1e9;

    int index=-1;
    while(lo<=hi)
    {
      int mid=(lo+hi)/2;
      if(can(mid))
      {
        hi=mid-1;
        index=mid;
      }
      else
        lo=mid+1;
    }
    cout<<index<<endl;

    //cout<<index<<endl;

   return 0;

   
}

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

int main(int argc, char **argv)
{
	ll N, M; cin >> N >> M;
	vector<ll> P(M), Y(M); for (ll i = 0; i < M; ++i) cin >> P[i] >> Y[i], --P[i];

	vector<vector<ll>> vals(N);

	for (ll i = 0; i < M; ++i) vals[P[i]].push_back(Y[i]);

	for (int v = 0; v < N; ++v)
	{
		sort(vals[v].begin(), vals[v].end());
		vals[v].erase(unique(vals[v].begin(), vals[v].end()), vals[v].end());
	}

	for (ll i = 0; i < M; ++i)
	{
		ll v = P[i];
		printf("%06lld", v+1);
		printf("%06ld\n", lower_bound(vals[v].begin(), vals[v].end(), Y[i]) - vals[v].begin() + 1);
	}
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e9 + 7

using namespace std;

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

int main(void)
{
    int n;
    cin >> n;
    cout << n / 3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,a[200001]={};
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    int max=a[1]-a[0];
    int min=a[0];
    for(int i=1;i<n;i++){
        if(a[i]-min>max)max=a[i]-min;
        if(min>a[i])min=a[i];
    }
    cout<<max<<endl;
    return 0;
}


Measured memory_bytes: 3896
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,d,x;
    cin >> n >> d >> x;
    int ans = 0;
    REP(i,n){
        int a;
        cin >> a;
        int t=1;
        while(t<=d){
            ans++;
            t+=a;
        }
    }
    cout << ans+x << endl;

    return 0;
}

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

using namespace std;
#define int long long
int MOD = 1000000007;

signed main(){
    int N;
    cin >> N;
    int a[N],b[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
        b[i] = i;
    }
    
    int kazu = 1,tmp = 0;
    for(int i=0;i<N;i++){
        if(a[i]==kazu){
            kazu++;
            tmp++;
        }
    }
    
    if(tmp==0) cout << -1 << endl;
    else cout << N+1-kazu << endl;
    
    return 0;
}


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

int n;
vector<int> d;

void input() {
    cin >> n;
    d = vector<int>(n);
    rep(i, n) cin >> d[i];
}

int main() {
    input();
    ll ans = 1;
    if (d[0] != 0) ans = 0;
    vector<int> c(n);
    for (int x : d) c[x]++;
    if (c[0] != 1) ans = 0;
    int max_d = *max_element(d.begin(), d.end());
    for (int i = 1; i <= max_d; i++) {
        rep(j, c[i]) ans = (ans * c[i-1]) % MOD;
    }
    cout << ans << endl;
}


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

int main () {
    int N;
    cin >> N;
    int dp[100010] = {};

    for (int i=0; i <= N+10; i++) dp[i] = N;
    for (int i=0; i < 6; i++) dp[i] = i;

    for (int i=6; i <= N+10; i++) {
        for (int j=1; j <= i; j*=6) {
            dp[i] = min(dp[i], dp[i-j]+1);
        }
        for (int j=1; j <= i; j*=9) {
            dp[i] = min(dp[i], dp[i-j]+1);
        }
    }

    cout << dp[N] << endl;
}

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

int main(){
    int N, M, K;
    cin >> N >> M >> K;
    vector<int64_t> A(N), B(M), SA(N+1), SB(M+1);
    for(int i=0; i<N; i++){
        cin >> A[i];
        SA[i+1] = SA[i] + A[i];
    }
    for(int i=0; i<M; i++){
        cin >> B[i];
        SB[i+1] = SB[i] + B[i];
    }

    int ans = 0;
    for(int i=0; i<=N; i++) if(SA[i] <= K){
        int res = i;
        res += upper_bound(SB.begin(), SB.end(), K-SA[i]) - SB.begin() - 1;
        ans = max(ans, res);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9592