akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int ,int >
#define pl pair<ll ,ll >
#define pb push_back
#define vl vector <long long int >
#define vi vector <int >
#define vp vector <pi>
#define mod 1000000007
#define eps 1e-9
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define _ <<" "<<
#define forn(x,	n) for(int x = 0; x < n ;++ x) 
#define forn1n(x,n) for(int x = 1; x <= n ;++ x)
#define forn1(x,n) for(int x = 1; x < n ;++ x)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#pragma GCC optimize ("Ofast")
void scan(){}
template<typename F, typename... R> void scan(F &f,R&... r){cin>>f;scan(r...);}
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R> void debug_(F &f, R&... r){while(dnms_[di_] != ',')cout<<dnms_[di_++];di_++;cout<<": "<<f<<",";debug_(r...);}
#define debug(...) dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__)

template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}

double sqd(double x1,double x2)
{
	return (x1-x2)*(x1-x2);
}
int main(){
	IOS
	int n;
	cin>>n;
	double x,y;
	vector<pair<double,double> >v;
	forn(i,n)
	{
		cin>>x>>y;
		v.pb({x,y});
	}
	double dist[n][n];

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			dist[i][j] = sqrt(sqd(v[i].fi,v[j].fi)+sqd(v[i].se,v[j].se));
		}
	}
	vector<int>perm;
	for(int i=0;i<n;i++)
		perm.pb(i);
	double tot = 0;
	ll cnt=0;
	do
	{
		double avg = 0;
		for(int i=1;i<perm.size();i++)
			avg += dist[perm[i]][perm[i-1]];
		// debug(avg);
		tot += avg;
		cnt++;
	}while(next_permutation(perm.begin(), perm.end()));
	tot = tot/(double)cnt;
	// debug(cnt);
	cout<<fixed<<setprecision(9)<<tot<<endl;
	return 0;	
}

Measured memory_bytes: 256
import std.stdio, std.string, std.array, std.conv, std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.chomp.split.to!(int[]);
    int q = readln.chomp.to!int;
    foreach (i; 0 .. q) {
        int[] tmp = readln.chomp.split.to!(int[]);
        int b = tmp[0], e = tmp[1], k = tmp[2];
        a[b..e].count(k).writeln;
    }
}


Measured memory_bytes: 2664
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int s;
  cin >> s;
  cout << a[s-1] << "\n";
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
S = input()

flag_m = [0]*(N)
#flag = [0]*(N)
flag_p = [0]*(N)
keta_list_m = [0]*(N)
#keta_list = [0]*(N)
keta_list_p = [0]*(N)

mod = S.count('1')

if mod == 1:
    flag_p[-1] = int(S[-1]) % (mod+1)
    keta_list_p[-1] = 1 % (mod+1)
    keta_p = 1
    for i in reversed(range(N-1)):
        keta_p *= 2
        keta_p %= (mod+1)
        keta_list_p[i] = keta_p
        if S[i] == '1':
            flag_p[i] = keta_p
    sum_f_p = sum(flag_p)

    for i in range(N):
        if S[i] == '1':
            print(0)
            continue
        else:
            num = (sum_f_p + keta_list_p[i]) % (mod+1)
    
        ans = 1
        if num == 0:
            print(ans)
            continue

        while True:
            cnt = 0
            tmp = 0
            while (1 << tmp) <= num:
                if num & 1 << tmp:
                    cnt += 1
                tmp += 1
            num %= cnt
            ans += 1
            if num == 0:
                print(ans)
                break
    exit()

flag_p[-1] = int(S[-1]) % (mod+1)
flag_m[-1] = int(S[-1]) % (mod-1)
keta_list_p[-1] = 1 % (mod+1)
keta_list_m[-1] = 1 % (mod-1)
keta_m = 1
keta_p = 1
for i in reversed(range(N-1)):
    keta_m *= 2
    keta_m %= (mod-1)
    keta_p *= 2
    keta_p %= (mod+1)
    keta_list_m[i] = keta_m
    keta_list_p[i] = keta_p
    if S[i] == '1':
        flag_p[i] = keta_p
        flag_m[i] = keta_m

sum_f_m = sum(flag_m)
sum_f_p = sum(flag_p)
#print(mod)
#print(flag)
for i in range(N):
    if S[i] == '1':
        num = (sum_f_m - keta_list_m[i]) % (mod-1)
    else:
        num = (sum_f_p + keta_list_p[i]) % (mod+1)
    #print('k', num)

    ans = 1
    if num == 0:
        print(ans)
        continue

    while True:
        cnt = 0
        tmp = 0
        while (1 << tmp) <= num:
            if num & 1 << tmp:
                cnt += 1
            tmp += 1
        num %= cnt
        ans += 1
        if num == 0:
            print(ans)
            break
        

Measured memory_bytes: 28380
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

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

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}


int main(){
  ll n,k;
  cin>>n>>k;
  vector<ll> v(100001,0);
  for(int i = 0; i < n; i++){
    int a,b;
    cin>>a>>b;
    v[a-1]+=b;
  }
  int j=0;
  int tmp=0;
  while(k>0){
    k-=v[j];
    tmp=j+1;
    j++;
  }
  cout<<tmp<<endl;
  return 0;
}

  



Measured memory_bytes: 1024
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;


ll N;
bool flag;

int main() {

	cin >> N;

	for (ll w = 1; 4 * w <= 3 * N; w++) {
		for (ll h = ((3 * N + 3) / 4); h <= 3500; h++) {
			if (4 * h*w - N * h - N * w == 0)continue;
				if((w*h*N)%(4*h*w-N*h-N*w)!=0)continue;
				ll W=w*h*N / (4 * h*w - N * h - N * w);
				if (W >= w && W <= h) {
					cout << w << " " << W << " " << h << endl;
					flag = true;
					}
			
			if (flag)break;
		}
		if (flag)break;;
	}



	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        //int N = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        for (int i = 0; i < 26; i++)
        {
            if (!s.Contains(char.ConvertFromUtf32('a' + i)))
            {
                Console.WriteLine(char.ConvertFromUtf32('a' + i));
                return;
            }
        }
        Console.WriteLine("None");
    }
}

Measured memory_bytes: 13200
#include <algorithm>
#include <iostream>
#include <list>
#include <map> //連想配列
#include <queue>
#include <set> //
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector> //動的配列

using namespace std;

int len(char *s) {
  int count = 0;
  while (*(s + count) != '\0') {
    count++;
  }
  return count;
}

int main() {
  char *A = (char *)malloc(101);
  char *B = (char *)malloc(101);
  cin >> A >> B;
  if (len(A) > len(B)) {
    cout << "GREATER" << endl;
    return 0;
  } else if (len(A) < len(B)) {
    cout << "LESS" << endl;
    return 0;
  } else {
    for (int i = 0; i < len(A); i++) {
      if (*(A + i) > *(B + i)) {
        cout << "GREATER" << endl;
        return 0;
      } else if (*(A + i) < *(B + i)) {
        cout << "LESS" << endl;
        return 0;
      }
    }
    cout << "EQUAL" << endl;
    return 0;
  }
}


Measured memory_bytes: 256
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
		a[i]--
	}
	ans := 0
	for i := 0; i < n; i++ {
		j := a[i]
		if a[j] == i {
			ans++
		}
	}
	fmt.Println(ans / 2)
}


Measured memory_bytes: 1920
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}]

int main(){
	ll t1,t2,a1,a2,b1,b2 ;
	cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2 ;
	if(t1*a1+t2*a2==t1*b1+t2*b2) cout << "infinity\n" ;
	else{
		if(a1<b1){
			swap(a1,b1) ;
			swap(a2,b2) ;
		}
		ll d1 = t1*(a1-b1) ;
		ll d2 = t2*(a2-b2) ;
		if(d1+d2>0) cout << 0 << endl ;
		else{
			ll ans = (d1/abs(d1+d2)+1)*2-1 ;
			if(d1%abs(d1+d2)==0) ans-- ;
			cout << ans << endl ;
		}
	}
}


Measured memory_bytes: 3644
INF = float('inf')

N, K = map(int, input().split())
h = list(map(int, input().split()))
h = [0] + h

dp = [INF for i in range(N + 1)]
# 1-indexed, 1 -> N
dp[1] = 0

for i in range(2, N + 1):
    dp[i] = dp[i - 1] + abs(h[i] - h[i - 1])
    for j in range(2, K + 1):
        if i - j >= 1:
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))
print(dp[N])


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

//逆元テーブルと二項係数
const int MAX = 2010;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
  int s;
  cin >> s;
  COMinit();
  int64_t ans=0;
  for(int a=1; a<=s/3; a++){
    ans+=COM(s-2*a-1,a-1);
    ans%=MOD;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3668
n = int(input())
h = list(map(int, input().split()))
h.append(10**9+1)
c = 0
ans = 0
for i in range(n):
  if h[i] >= h[i+1]:
    c += 1
    ans = max(ans,c)
  else:
    ans = max(ans,c)
    c = 0
print(ans)

Measured memory_bytes: 20432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=100005;
int n,sum,a[N],mx;
bool check(){
	for(int i=1;i<=n;i++)if(a[i]!=n-1)return 0;
	return 1;
}
void GG(){
	puts("No"); exit(0);
}
void OK(){
	puts("Yes"); exit(0);
}
int main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	if(check())OK();
	for(int i=1;i<=n;i++){
		mx=max(mx,a[i]);
	}
	for(int i=1;i<=n;i++)if(a[i]!=mx&&a[i]!=mx-1)GG(); else if(a[i]==mx)sum++;
	if(sum==1||n-sum>=mx)GG();
	if(mx>n-sum+sum/2)GG();
	OK();
}

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

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

  // ここにプログラムを追記
  int min,x,tmp;
  bool start = true;
  for(int i = 0; i < N; i++){
    cin >> x;
    
    tmp = 0;
    while(x % 2 == 0 && x != 0){
      tmp++;
      x /= 2;
    }
    
    if(min >tmp || start){
      min = tmp; start = false;
    }
  }
  cout << min << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
const int INF=1e9+7;
const int mod=1e9+7;
struct poi{
	int X;int Y;int Z;
  bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
//ACACACACACACACACACACACAC//
//WAWAWAWAWAWAWAWAWAWAWAWA//
//CECECECECECECECECECECECE//
//RERERERERERERERERERERERE//
//TLETLETLETLETLETLETLETLE//
//
int main(){
  int N;
	int X,Y,Z;
	set<int> A,B;
	cin>>N;
	cin>>X;
	FOR(i,0,X){
		int a;
		cin>>a;
		A.insert(a);
	}
	cin>>Y;
	FOR(i,0,Y){
		int b;
		cin>>b;
		B.insert(b);
	}
	set<int> S;
	cin>>Z;
	FOR(i,0,Z){
		int C;
		cin>>C;
		if(A.find(C)==A.end()){
			S.insert(C);
		}
		if(B.find(C)!=B.end()){
			S.insert(C);
		}
	}
	cout<<(int)S.size()<<endl;
	return 0;
}



Measured memory_bytes: 3096
#define rep(i,n)for(i=0;i<n;i++)
W,H,m,c[10][10];DP[51][10][10][10][10];CalcO(o,x,y){c[x][y]>0?o+=c[x][y]:0;return o>0?o>m?m:o:0;}CalcF(f,x,y){return c[x][y]<0?f+c[x][y]:f;}Walk(x,y,l,r,o,f){int*p=&DP[o][y][x][l][r];f>*p?*p=f:0;}Dig(x,y,l,r,o,f){Walk(x,y,l,r,CalcO(o-1,x,y),CalcF(f,x,y));}*p,x,y,g,d,v,f,o,l,r,f0;main(){for(;scanf("%d%d%d%d%d",&W,&H,&f0,&m,&o)*W;memset(DP,!printf(f?"%d\n":"NA\n",f0-f),sizeof(*DP)*2)){rep(y,H)rep(x,W)scanf("%d",&c[x][y]);f0++;if(o>1)rep(x,W)DP[CalcO(o-1,x,0)][0][x][x][x]=CalcF(f0,x,0);rep(y,H-1)rep(g,W)for(o=m;o>1;o--)rep(d,2)rep(l,W-g)rep(v,g+1)if(r=l+g,p=&DP[o][y][x=d?l+v:r-v][l][r],f=*p){*p=0;Dig(x,y+1,x,x,o,f);x?x>l?Walk(x-1,y,l,r,o-1,f):Dig(x-1,y,x-1,r,o,f):0;x<W-1?x<r?Walk(x+1,y,l,r,o-1,f):Dig(x+1,y,l,x+1,o,f):0;}f=0;rep(x,W)rep(o,m)p=&DP[o+1][H-1][x][x][x],*p>f?f=*p:0,*p=0;}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int c[3][3];
int main() {
  REP(i, 3) REP(j, 3) cin >> c[i][j];
  for (int i = 0; i < 101; i++) {
    for (int j = 0; j < 101; j++) {
      for (int k = 0; k < 101; k++) {
        //int a1 = i, a2 = j, a3 = k;
        //int b1 = c[0][0] - a1, b2 = c[0][1], b3 = c[0][2];
  
        int a[3] = {i, j, k};
        int b[3] = {c[0][0] - i, c[1][1] - j, c[2][2] - k};
        if (b[0] < 0 || b[1] < 0 || b[2] < 0) continue;
        bool t = true;
        REP(l,3)REP(m,3){
          if(c[l][m]!=a[l]+b[m]) {
            t = false;
          }
        }
        if(t){
          puts("Yes");
          return 0;
        }
      }
    }
  }
  puts("No");
}

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

#define int long long

using namespace std;

const int N = 1e5 + 10; 
int cnt[N], b[N], s[N];
int n, m, tot;

/*void Solve(int x, int y) {
	if(x <= n) return void(s[x] += y);
	int pos = lower_bound(b + 1, b + tot + 1, x) - b - 1;
	if(pos == 0) {
		cnt[pos] += y * x / n;
		s[x % n] += y;
		return;
	}
	Solve(b[pos], y * x / b[pos]), Solve(x % b[pos], y);
}*/

signed main() {
	int x;
	scanf("%lld%lld", &n, &m);
	b[++ tot] = n;
	for(int i = 1; i <= m; ++ i) {
		scanf("%lld", &x);
		while(x <= b[tot]) -- tot;
		b[++ tot] = x;
	}
	cnt[tot] = 1;
	for(int i = tot; i >= 2; -- i) {
		cnt[i - 1] += cnt[i] * (b[i] / b[i - 1]);
		int now = b[i] % b[i - 1];
		while(now) {
			int pos = upper_bound(b + 1, b + tot + 1, now) - b - 1;
			if(pos == 0) {
				s[now] += cnt[i]; break;
			}
			cnt[pos] += cnt[i] * (now / b[pos]);
			now %= b[pos];
		}
	}
	s[b[1]] = cnt[1]; 
	for(int i = n; i >= 1; -- i) 
		s[i - 1] += s[i];
	for(int i = 1; i <= n; ++ i)
		printf("%lld\n", s[i]);
	return 0;
}


Measured memory_bytes: 4096
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

auto main (int argc, char** argv) -> int {
  double d, t, s;
  cin >> d >> t >> s;

  if (d / s <= t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define numarr 110
using namespace std;

int main() {
	int N, h[numarr], i, j, ans = 0;
	bool Nh[numarr][numarr], exist;
	cin >> N;
	for (i = 1; i <= N; i++)
		cin >> h[i];
	for (i = 1; i <= N; i++)
	{
		for (j = 1; j <= h[i]; j++)
			Nh[i][j] = true;
		for (j = h[i] + 1; j <= numarr; j++)
			Nh[i][j] = false;
	}
	for (j = 1; j <= numarr; j++)
	{
		exist = false;
		for (i = 1; i <= N; i++)
			if (exist)
			{
				if (!Nh[i][j])
					exist = false;
			}
			else
			{
				if (Nh[i][j])
				{
					ans++;
					exist = true;
				}
			}
	}
		cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
char s[2000001]={};
scanf("%s",s);
int p,q;
for(int i=0;true;i++){
if(s[i]=='A'){
p=i;
break;
}
}
for(int i=200000;true;i--){
if(s[i]=='Z'){
q=i;
break;
}
}
printf("%d\n",q-p+1);
return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();

int main() {
  int n;
  int r;
  scanf("%d", &n);
  scanf("%d", &r);

  int rate = 0;

  if (n < 10) {
    rate = r + 100 * (10 - n);
  } else {
    rate = r;
  }

  printf("%d\n", rate);
  return 0;
}


Measured memory_bytes: 256
L,R = list(map(int,input().split()))

la=L//2019
ra=R//2019
lb=L%2019
rb=R%2019

if ra-la>=1:
    print(0)
else:
    ans = 2018
    for i in range(lb,rb):
        for j in range(i+1,rb+1):
            ans = min((i*j)%2019,ans)

    print(ans)

Measured memory_bytes: 42220
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# 偶奇をあわせて寄せていくだけ

X,P = map(int,read().split())

def f(x):
    y = x // 2
    return y * 100 / P

if X % 2 == 0:
    answer = f(X)
else:
    answer = 1 + (P * f(X-1) + (100-P) * f(X+1))/100

print(answer)



Measured memory_bytes: 2940
#include<stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define MAX 2000000
#define swap(x, y, type) do{type t = x; x = y; y = t;}while(0)

void upheap(int first, int right, int *tab)
{
        int  pare, btn = tab[right],child ;

        for (child = right; child > first; child = pare)
        {
                pare = (child - first + 1) / 2 - 1 + first;
                if (tab[pare] >= btn) break;
                tab[child] = tab[pare];
        }

        tab[child] = btn;
}
void downheap(int first, int left, int right, int *tab)
{
        int child, pare, root = tab[left];

        for (pare = left; pare < (right - first + 1) / 2 + first;
                 pare = child) {
                int l = 2 * pare - first + 1, r = l + 1;
                if (r <= right && tab[r] > tab[l]) {child = r;}
                else {child = l;}
                if (root >= tab[child]){ break;}
                tab[pare] = tab[child];
        }

        tab[pare] = root;
}
void sort(int n, int first, int *a)
{
        int i;
        for (i = (n - first) / 2 - 1 + first; i >= first; i--) {downheap(first, i, n - 1, a);}
        for (i = n - 1; i > first; i--) {
                swap(a[first], a[i], int);
                downheap(first, first, i - 1, a);
        }
}
void delete(int *n, int first, int m, int *a)
{
        int pre = a[m];
        a[m] = a[(*n) - 1];
        (*n)--;
        if (pre > a[m]) {downheap(first, m, (*n) - 1, a);}
        else {upheap(first, m, a);}
}

void insert(int *n, int first, int data, int *a)
{
        (*n)++;
        a[(*n) - 1] = data;
        upheap(first, (*n) - 1, a);
}


main()
{
        int cnt,first,k;
        int a[MAX];
        char cmd[8];
        first=0;
        cnt=0;
        while (1) {
                scanf("%s", cmd);
                if (!strcmp(cmd, "end")) {break;}
                switch (cmd[0]) {
                case 'i':
                        scanf(" %d", &k);
                        insert(&cnt, first, k, a);
                        break;
                case 'e':
                        printf("%d\n", a[first]);
                        delete(&cnt, first , first, a);
                        break;
                }
        }
}



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

typedef long long ll;
#define MOD 998244353

ll c[110000] = {0};

int main() {
  ll n;
  cin >> n;
  vector<ll> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    c[d[i]]++;
  }
  if (d[0] != 0) {
    cout << 0 << endl;
    return 0;
  }
  sort(d.begin(), d.end());
  ll ans = 1;
  if (c[0] != 1) {
    cout << 0 << endl;
    return 0;
  }
  bool flag = false;
  for (ll i = 1; i <= d[n - 1]; i++) {
    if (c[i] == 0) {
      flag = true;
    }
  }
  if (flag) {
    cout << 0 << endl;
    return 0;
  }
  for (ll i = 1; i <= d[n - 1]; i++) {
    for (ll j = 0; j < c[i]; j++) {
      ans *= c[i - 1];
      ans %= MOD;
    }
  }
  cout << ans%MOD << endl;
  return 0;
}

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

namespace ITP1_6_C
{
    class Program
    {
        static void Main(string[] args)
        {
            House[] house = new House[4];
            for (int i = 0; i < 4; i++) house[i] = new House();
            int infonumber = int.Parse(Console.ReadLine());
            int count = 0;
            string distance = new string('#', 20);
            for (int i = 0; i < infonumber; i++)
            {
                int[] input = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();                
                house[input[0] - 1].RenewRoomMember(input[1], input[2], input[3]);               
            }
            foreach (var h in house)
            { 
                h.ShowRoom();
                if (count++ < 3) Console.WriteLine(distance);
            }               
        }
    }
    class House
    {
        private int[,] room = new int[3, 10];

        public int this[int i,int j]
        {
            set { room[i - 1, j - 1] = value; }
            get { return room[i - 1, j - 1]; }
        }
        public void RenewRoomMember(int floor,int number,int member)
        { 
            this[floor, number] += member;
            if (this[floor, number] < 0 || 9 < this[floor, number])
                Console.WriteLine("Error");          
        }
        public void ShowRoom()
        {
            int count = 0;
            foreach(var i in room)
            {
                Console.Write(" " + i);
                if ((++count) % 10 == 0) Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9684
n, m = map(int, input().split())
student = [tuple(map(int, input().split())) for _ in range(n)]
check_points = [tuple(map(int, input().split())) for _ in range(m)]
for i in range(n):
    distance = float('inf')
    index = float('inf')
    for j in range(m):
        now = abs(student[i][0] - check_points[j][0]) + abs(student[i][1] - check_points[j][1])
        if now < distance:
            distance = now
            index = j + 1
    print(index)

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

int main()
{
    int n;
    scanf("%d",&n);
    if((n&(n-1)) == 0){
        printf("No\n");
        return 0;
    }

    printf("Yes\n");
    int line = (n%4==3? n : n-(n%4)-1);
    printf("%d %d\n",line,n+1);
    for(int i=1; i<line; i++){
        printf("%d %d\n",i,i+1);
        printf("%d %d\n",n+i,n+i+1);
    }

    if(n%4 == 0){
        int msb = 1<<(int)log2(n);
        printf("%d %d\n",n,msb);
        printf("%d %d\n",2*n,n-msb+1);
    }
    else if(n%4 == 1){
        printf("%d %d\n",1,n);
        printf("%d %d\n",n-1,n);
        printf("%d %d\n",n+1,n+n-1);
        printf("%d %d\n",n+n-1,n+n);
    }
    else if(n%4 == 2){
        printf("%d %d\n",1,n-1);
        printf("%d %d\n",n-1-1,n-1);
        printf("%d %d\n",n+1,n+n-1-1);
        printf("%d %d\n",n+n-1-1,n+n-1);
        printf("%d %d\n",n-1,n);
        printf("%d %d\n",2,n+n);
    }
}


Measured memory_bytes: 2816
a,b,m = map(int,input().split())
ai = list(map(int,input().split()))
bi = list(map(int,input().split()))
cheap = min(ai)+min(bi)
for i in range(m):
    x,y,c = map(int,input().split())
    cheap = min(ai[x-1]+bi[y-1]-c,cheap)
print(cheap)


Measured memory_bytes: 18612
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  vector<int> P1;
  vector<int> P2;
  vector<int> P3;
  rep(i, N) {
    int p;
    cin >> p;
    if (p <= A) {
      P1.push_back(p);
    } else if (A < p && p <= B) {
      P2.push_back(p);
    } else if (B < p) {
      P3.push_back(p);
    }
  }

  int count = INF;
  count = min(count, (int)P1.size());
  count = min(count, (int)P2.size());
  count = min(count, (int)P3.size());

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
#import numpy as np
# n = int(input())
# a, b = map(int, input().split())
# int_list = list(map(int, input().split()))
# l = list(input().split())



def solve():
    n = int(input())
    rev_list = []
    for i in range(n):
        idx = i + 1
        s, p = input().split()
        rev_list.append([idx, s, int(p)])


    rev_list_p_sorted = sorted(rev_list, key=lambda x: x[2], reverse=True)
    rev_list_s_sorted = sorted(rev_list_p_sorted, key=lambda x: x[1])
    # print(rev_list)
    # print(rev_list_p_sorted)
    # print(rev_list_s_sorted)

    for rev in rev_list_s_sorted:
        print(rev[0])

    # s_list = []
    # p_list = []
    # n = int(input())
    # for i in range(n):
    #     s, p = input().split()
    #     s_list.append(s)
    #     p_list.append(int(p))
    # s_npa = np.array(s_list, dtype=str)
    # p_npq = np.array(p_list, dtype=int)
    #
    # argp = np.argsort(p_npq)[::-1]
    # # print(argp)
    # # print(s_npa[argp])
    # args = np.argsort(s_npa[argp])
    # idx = np.array(range(n))[argp][args] + 1
    # for i in idx:
    #     print(i)

solve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    rep(i, n) {
        vector<bool> f1(26);
        vector<bool> f2(26);
        vector<bool> f3(26);
        rep(j, n) {
            if (j<=i) {
                f1[s[j]-'a'] = true;
            }
            else {
                f2[s[j]-'a'] = true;
            }
        }
        int res = 0;
        rep(j, 26) {
            f3[j] = f1[j] & f2[j];
            if (f3[j]) res++;
        }
        ans = max(ans, res);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
A = list(input())
B = list(map(int, A))
for i in range(2**3):
  ans = B[0]
  for j in range(3):
    if ((i>>j) & 1):
      ans += B[j+1]
    else:
      ans -= B[j+1]
  if ans == 7:
    for k in range(3):
      print(B[k], end = "")
      if ((i>>k) & 1):
        print("+", end = "")
      else:
        print("-", end = "")
    print(B[3], end = "")
    print("=7")
    break


Measured memory_bytes: 38256
A, B = map(int, raw_input() .split())
if A == 1 and B != 1:
    print "Alice"
elif B == 1 and A != 1:
    print "Bob"
elif A == 1 and B == 1:
    print "Draw"
elif A > B:
    print "Alice"
elif B > A:
    print "Bob"
elif A == B:
    print "Draw"


Measured memory_bytes: 2568
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll n;
    cin>>n;
    vector <ll> v(n);
    vector <ll> c(n);
    for (ll i =0; i < n; i++){
        cin>>v[i];
    }
    for (ll i =0; i < n; i++){
       cin>>c[i];
   }
    ll ans = 0;
    for (ll i = 0; i < n; i++){
        if(v[i] > c[i]){
            ans += v[i]-c[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
a, b, c, x = 4.times.map { gets.to_i }
count = 0
(0..a).each do |i|
    (0..b).each do |j|
        (0..c).each do |k|
            count += 1 if i * 500 + j * 100 + k * 50 == x
        end
    end
end

puts count

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
signed main(){
    int n,m,c;
    cin>>n>>m>>c;
    vi l(c);
    REP(i,c){
        cin>>l[i];
    }
    priority_queue<P> que;
    REP(i,n){
        P p;
        cin>>p.se>>p.fi;
        p.se--;
        que.push(p);
    }
    int ans=0;
    while(que.size()&&m){
        P p=que.top();que.pop();
        if(l[p.se]){
            ans+=p.fi;
            l[p.se]--;
            m--;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5604
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Pine1999
 */

#include <bits/stdc++.h>

using namespace std;

void CAXBC(std::istream& in, std::ostream& out) {
    int n;
    in >> n;
    int ans = 0;
    for (int a = 1; a <= n; ++a) {
        ans += (n - 1) / a;
    }
    out << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    CAXBC(in, out);
    return 0;
}

Measured memory_bytes: 3648
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

import static java.util.Comparator.reverseOrder;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] a = new Integer[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a, Comparator.reverseOrder());

        int alice = 0;
        int bob = 0;
        boolean b = true;
        for (Integer tmp : a) {
            if (b) {
                alice += tmp;
            }
            else {
                bob+= tmp;
            }
            b =!b;
        }

        System.out.println(alice - bob);
    }
}

Measured memory_bytes: 23764
#include<cstdio>
#include<iostream>
using namespace std;
int N;
int cnt=1;
int arr[100050];
int check=-1;
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;++i)
	{	
		scanf("%d",&arr[i]);
	}
	for(int i=1;i<N;++i)
	{
		if(check==-1)
		{
			if(arr[i]>arr[i-1])
			{
				check=1;
			}
			else if(arr[i]<arr[i-1])
			{
				check=2;
			}
			else 
			{
				continue;
			}
		}
		if(check==1)
		{
			if(arr[i]>=arr[i-1])
			{
				continue;
			}
			else if(arr[i]<arr[i-1])
			{
				check=-1;
				cnt++;
				continue;
			}
		}
		if(check==2)
		{
			if(arr[i]>arr[i-1])
			{
				check=-1;
				cnt++;
				continue;
			}
			else if(arr[i]<=arr[i-1])
			{
				continue;
			}
		}
	}
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define piii pair<int,pair<int,int> >
#define pii pair<int,int>
#define ll long long
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,x,ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        ans+=x;
    }
    cout<<ans-n<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int dp[200][200];
string sa[200];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>sa[i];
		for(j=0;j<m;j++){
			dp[i][j]=1e9;
		}
	}
	if(sa[0][0]=='#')dp[0][0]=1;
	else dp[0][0]=0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(i==0)a=1e9;
			else if(sa[i-1][j]=='.' && sa[i][j]=='#')a=dp[i-1][j]+1;
			else a=dp[i-1][j];
			dp[i][j]=min(a,dp[i][j]);
			if(j==0)a=1e9;
			else if(sa[i][j-1]=='.' && sa[i][j]=='#')a=dp[i][j-1]+1;
			else a=dp[i][j-1];
			dp[i][j]=min(a,dp[i][j]);
		}
	}
	cout<<dp[n-1][m-1]<<endl;

}

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

using namespace std;
int main(){
    string S;
    cin >> S;
    if(S=="SUN"){
        cout << "7" << endl;
    }

    if(S=="MON"){
        cout << "6" << endl;
    }

    if(S=="TUE"){
        cout << "5" << endl;
    }

    if(S=="WED"){
        cout << "4" << endl;
    }

    if(S=="THU"){
        cout << "3" << endl;
    }

    if(S=="FRI"){
        cout << "2" << endl;   
    }
    if(S=="SAT"){
        cout << "1" << endl;
    }
}


Measured memory_bytes: 256
data = [
    "{0} {1}".format(s, r)
    for s in ('S', 'H', 'C', 'D')
    for r in range(1, 13 + 1)
]
count = int(input())
for c in range(count):
    card = input()
    data.remove(card)
 
for c in data:
    print(c)

Measured memory_bytes: 7640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 100000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

#define MAX 3000

int ans = INF;
vp v;
int ncr[MAX][MAX];

void f(int sx, int sy, int gx, int gy){
    int dist = abs(sx-gx) + abs(sy-gy);
    if(dist > ans)return;
    if(dist < ans){
        ans = dist;
        v.clear();
    }
    v.push_back(pii(abs(sx-gx),abs(sy-gy)));
}

signed main(void) {
    int r,c;
    cin >> r >> c;
    int sx,sy,gx,gy;
    cin >> sx >> sy >> gx >> gy;
    f(r+sx,c+sy,gx,gy);
    f(r+sx,c+sy,gx,c+gy);
    f(r+sx,c+sy,gx,c+c+gy);
    f(r+sx,c+sy,r+gx,gy);
    f(r+sx,c+sy,r+gx,c+gy);
    f(r+sx,c+sy,r+gx,c+c+gy);
    f(r+sx,c+sy,r+r+gx,gy);
    f(r+sx,c+sy,r+r+gx,c+gy);
    f(r+sx,c+sy,r+r+gx,c+c+gy);
    ncr[0][0] = 1;
    rep(i,MAX)rep(j,MAX){
        if(i) ncr[i][j] = (ncr[i][j] + ncr[i - 1][j]) % MOD;
        if(i && j) ncr[i][j] = (ncr[i][j] + ncr[i - 1][j - 1]) % MOD;
    }
    int ans = 0;
    rep(i,v.size()){
        int x = v[i].first;
        int y = v[i].second;
        (ans += ncr[x+y][x]) %= MOD;
    }
    cout << ans << endl;
}



Measured memory_bytes: 73412
n,m=list(map(int,input().split()))
c=[]
for i in range(m):
    a,b=list(map(int,input().split()))
    d=[]
    d.append(a)
    d.append(b)
    c.append(d)
c.sort(key=lambda x: x[1])
#print(c)
cur=0
ans=0
for i in range(m):
    if c[i][0] >= cur:
        cur = c[i][1]
        ans += 1  
print(ans)        

Measured memory_bytes: 29072
/*
g++ -std=c++14 -o2 -Wall ABC.cpp -o .\out\ABC.out
.\out\ABC.out
*/

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

typedef long long ll;

int al[100005];
int ar[100005];

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int lmax = 0;
  int rmin = 200000;
  for (int i = 0; i < m; ++i) {
    int l, r;
    cin >> l >> r;
    lmax = max(lmax, l);
    rmin = min(rmin, r);
  }
  int ans = max(rmin - lmax + 1,0);
  cout << ans << "\n";
}


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

int main(void){
    char a, b;
    cin >> a >> b;
    if((int)a < (int)b) cout << "<" << endl;
    else if((int)a > (int)b) cout << ">" << endl;
    else cout << "=" << endl;

    return 0;
}


Measured memory_bytes: 256
import math


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

d = []
for i in range(n):
    dis = math.fabs(a[i]-b[i])
    d.append(dis)

print(sum(d))

dd_sum = 0
for i in range(n):
    dd_sum += d[i]**2
print(math.sqrt(dd_sum))

ddd_sum = 0
for i in range(n):
    ddd_sum += d[i]**3
print(math.pow(ddd_sum,(1.0/3.0)))

print(max(d))



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

using namespace std;

int main(){
    string s,t;
    cin >> s >> t;

    int res = 0;
    for(int i=0; i<s.size(); i++){
        if(s.at(i) != t.at(i))res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3900
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int cmax=2500;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,s;cin >> n >> m >> s;
    chmin(s,cmax);
    vector<vector<pair<int,int>>> g(n);
    vector<ll> a(m),b(m);
    for(int i=0;i<m;i++){
        int u,v;cin >> u >> v;
        cin >> a[i] >> b[i];
        u--,v--;
        g[u].push_back({v,i});
        g[v].push_back({u,i});
    }
    vector<ll> c(n),d(n);
    for(int i=0;i<n;i++){
        cin >> c[i] >> d[i];
    }
    vector<vector<ll>> dp(n,vector<ll>(cmax+1,INF));
    priority_queue<pair<ll,pair<ll,ll>>,vector<pair<ll,pair<ll,ll>>>,greater<pair<ll,pair<ll,ll>>>> pq;
    dp[0][s]=0;
    pq.push({0,{0,s}});
    while(!pq.empty()){
        ll u=pq.top().first,v=pq.top().second.first,w=pq.top().second.second;
        pq.pop();
        if(u>dp[v][w]){
            continue;
        }
        if(w+c[v]<=cmax){
            if(chmin(dp[v][w+c[v]],u+d[v])){
                pq.push({u+d[v],{v,w+c[v]}});
            }
        }
        for(auto x:g[v]){
            int to=x.first;
            ll A=a[x.second],B=b[x.second];
            if(w<A){
                continue;
            }
            if(chmin(dp[to][w-A],dp[v][w]+B)){
                pq.push({dp[to][w-A],{to,w-A}});
            }
        }
    }
    for(int i=1;i<n;i++){
        ll ans=INF;
        for(int j=0;j<=cmax;j++){
            chmin(ans,dp[i][j]);
        }
        cout << ans << endl;
    }
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   int n;cin >>n;
   ll now=0;
   map<ll,int>mp;
   ll ans=0;
   mp[0]++;
    for (int i = 0; i < n; ++i) {
        ll a;cin >>a;
        now+=a;
        ans+=mp[now];
        mp[now]++;
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 16032
N=int(input())

ls={}
max_ch=0
for i in range(N):
    ch=input()
    if not ch in ls:
        ls[ch]=1
    else:
        ls[ch]+=1
    if max_ch<ls[ch]:
        max_ch=ls[ch]

S=[]
for j in ls:
    if max_ch==ls[j]:
        S.append(j)

S=sorted(S)

for i in S:
    print(i)

Measured memory_bytes: 35616
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

using ipair = pair<int,int>;

int INF = 1e9+7;

using ipair = pair<int,int>;
bool operator>(const ipair a,const ipair b){return a.first > b.first;}

int mod = 998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){

  int N;
  cin >> N;

  vector<string> vect(N);

  rep(i, N){
    cin >> vect[i];
  }

  int ans = 0;
  int num_a = 0;
  int num_b = 0;
  int num_ba = 0;

  rep(i, N){
    string str = vect[i];
    if(str.front() == 'B' && str.back() == 'A'){
      num_ba++;
    }else if(str.front() == 'B'){
      num_b++;
    }else if(str.back() == 'A'){
      num_a++;
    }

    // 中AB
    for(int j=1; j<str.size(); j++){
      if(str[j] == 'B' && str[j-1] == 'A'){
        ans++;
      }
    }
  }

  if(num_ba>=2){
    ans+=(num_ba-1);
    num_ba = 1;
  }

  if(num_a && num_ba){
    ans++;
    num_a--;
  }
  if(num_b && num_ba){
    ans++;
    num_b--;
  }

  ans += min(num_a, num_b);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 768
N, M = map(int, input().split())
if N%2 != 0:
    first = 1
    for i in range(M):
        print(first, N-i)
        first += 1
else:
    mid = N//2
    for i in range((M+1)//2):
        print(i+1,mid-i)
    for i in range(M//2):
        print(mid+1+i, N-1-i)


Measured memory_bytes: 9228
from operator import itemgetter
import sys


class BIT:
    def __init__(self, size: int):
        self.size = size + 1
        self.array = [0] * self.size

    def add(self, i):
        while i < self.size:
            self.array[i] += 1
            i += i & -i

    def sub(self, i):
        while i < self.size:
            self.array[i] -= 1
            i += i & -i

    def sum(self, a, b):
        s = 0
        i = b
        while i > 0:
            s += self.array[i]
            i -= i & -i
        i = a - 1
        while i > 0:
            s -= self.array[i]
            i -= i & -i
        return s


def read():
    return sys.stdin.readline().rstrip()


def main():
    n, q = map(int, read().split())
    c = [int(i) - 1 for i in read().split()]
    queries = [(0, 0, 0) for _ in range(q)]
    for i in range(q):
        l, r = map(int, read().split())
        queries[i] = (i, l, r)
    queries = iter(sorted(queries, key=itemgetter(2)))
    last = [0] * n
    bit = BIT(n)
    ans = [-1] * q
    k, l, r = next(queries)
    for i in range(n):
        ci = c[i]
        li = last[ci]
        if li > 0:
            bit.sub(li)
        last[ci] = i + 1
        bit.add(i + 1)
        while i + 1 == r:
            ans[k] = bit.sum(l, r)
            try:
                k, l, r = next(queries)
            except StopIteration:
                break
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()


Measured memory_bytes: 181964