akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
typedef long double ld;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

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

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; };
int main(){
  string s; cin>>s;
  int N=s.size()+1;
  vector<int> l(N,0), r(N,0);
  rep(i,0,N-1){
    if(s[i]=='<') l[i+1] = l[i]+1;
    else l[i+1]=0;
  }
  reverse(all(s));
  rep(i,0,N-1){
    if(s[i]=='>') r[i+1] = r[i]+1;
    else r[i+1] = 0;
  }
  reverse(all(r));
  ll ans=0;
  rep(i,0,N){
    ans += max(r[i], l[i]);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(){
	int n, t;
	cin >> n >> t;
	int a[n], b[n];
	int mini = 10010;
	int ans, cnt = 0;

	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
		if(b[i] <= t){
			if(a[i] < mini){
				mini = a[i];
			}
		}
		if(b[i] > t){
			cnt++;

		}
	}
	if(cnt == n){
		cout <<"TLE";
		return 0;
	}

	cout << mini;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
  
int64 N, D;
int64 X[30], Y[30];
  
vector< pair< int64, int64 > > data[2];
priority_queue< pair< int64, int64 > > Que;
  
  
inline void Greedy(int idx, const int end, int64 Value, int64 Precious, const bool in)
{
  if(idx == end) {
    data[in].push_back(make_pair(Value, Precious));
  } else {
    Greedy(idx + 1, end, Value + X[idx], Precious + Y[idx], in);
    Greedy(idx + 1, end, Value         , Precious,          in);
    Greedy(idx + 1, end, Value - X[idx], Precious - Y[idx], in);
  }
}
  
int main()
{
  srand((unsigned)time(NULL));
  cin >> N >> D;
  for(int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }
  Greedy(0, N >> 1, 0, 0, false);
  Greedy(N >> 1, N, 0, 0,  true);
  sort(data[0].begin(), data[0].end());
  sort(data[1].begin(), data[1].end());
  
  int64 ret = 0;
  for(int i = 0, cur = 0; i < data[0].size(); i++) {
    while(cur < data[1].size() && data[1][cur].first <= data[0][i].first + D) {
      Que.push(make_pair(-data[1][cur].second, data[1][cur].first));
      ++cur;
    }
    while(!Que.empty() && Que.top().second < data[0][i].first - D) {
      Que.pop();
    }
    if(!Que.empty()) {
      ret = max(ret, data[0][i].second + Que.top().first);
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 565120
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

#define MAX_N 2000010
ll inv[MAX_N+10],fac[MAX_N+10],ifac[MAX_N+10];

void setComb(){
  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<MAX_N;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;

    inv[i]=(inv[i]+MOD)%MOD;
    fac[i]=(fac[i]+MOD)%MOD;
    ifac[i]=(ifac[i]+MOD)%MOD;
  }
  return;
}

ll comb(ll n,ll k){
  if(n<k||n<0||k<0) return 0;
  else return ((fac[n]*ifac[k]%MOD*ifac[n-k]%MOD+MOD)%MOD);
}

ll hcomb(ll n,ll r){// this size is really ok??
  if(n==0&&r==0) return 1;
  else if(n<0||r<0) return 0;
  else return comb(n+r-1,r);
}

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

void add(ll &a,ll b){
  a=(a+b)%MOD;
}

void mul(ll &a,ll b){
  a%=MOD;b%=MOD;
  a=a*b%MOD;
}

ll solve(ll r,ll c){
  ll res=0;
  for(int i=0;i<=r;i++){
      res+=comb(i+1+c,i+1);
      res%=MOD;
  }
  return res;
}

int main(){
  ll R[2]={},C[2]={};
  cin>>R[0]>>C[0]>>R[1]>>C[1];

  //R[0]++;C[0]++;R[1]++;C[1]++;
  setComb();

  ll ans=solve(R[1],C[1]);
  ans-=solve(R[1],C[0]-1);
  ans=(ans+MOD)%MOD;
  ans-=solve(R[0]-1,C[1]);
  ans=(ans+MOD)%MOD;
  ans+=solve(R[0]-1,C[0]-1);
  ans=(ans+MOD)%MOD;
  cout<<ans<<endl;

  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	string s;
	cin >> s;

	int n = s.size();

	int ans = 1;
	string prev = "", score = "";;
	prev += s[0];
	for (int i = 1; i < n; i++) {
		score += s[i];

		if (prev != score) {
			ans++;
			prev = score;
			score = "";
			continue;
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 720
from collections import Counter
S = input()
MOD = 2019

ct = Counter()
ct[0] = 1
ans = 0
tmp = 0
digit = 1
for c in S[::-1]:
    c = int(c)
    tmp = c * digit + tmp
    tmp %= MOD
    ans += ct[tmp]
    ct[tmp] += 1
    digit *= 10
    digit %= MOD
print(ans)

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

int main(){
  int n;
  cin >> n;
  int a[200000];
  for(int i = 0; i< n; i++) cin >> a[i];
  sort(a, a+n);
cout << a[n-1] -a[0]<< endl;
}

Measured memory_bytes: 3660
from collections import deque

if __name__ == '__main__':
    n = int(input())
    b = [-1] + [int(s) for s in input().split()]
    ans = deque()
    for _ in range(n):
        flag = False
        for i in range(len(b) - 1, 0, -1):
            if b[i] == i:
                b.pop(i)
                ans.appendleft(i)
                flag = True
                break
        if flag == False:
            print(-1)
            quit(0)
    for x in ans:
        print(x)


Measured memory_bytes: 3316
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
struct cloth{
    int low;
    int high;
    int c;
};
int main(void){

    int D,N;
    cin>>D>>N;
    int t[300];
    cloth d[300];
    for(int i = 1;i <= D;i++){
        cin>>t[i];
    }
    for(int i = 1;i <= N;i++){
        cin>>d[i].low>>d[i].high>>d[i].c;
    }

    int dp[300][300];
    for(int i = 1;i <= D;i++){
        for(int j = 1;j <= N;j++){
            dp[i][j] = -1;
        }
    }
    for(int j = 1;j <= N;j++){
        if(d[j].low <= t[1] && t[1] <= d[j].high)dp[1][j] = 0;
    }
    for(int i = 2;i <= D;i++){
        for(int j = 1;j <= N;j++){
            if(dp[i-1][j]!=-1){
                for(int k = 1;k <= N;k++){
                    if(d[k].low <= t[i] && t[i] <= d[k].high){
                        dp[i][k] = max(dp[i][k],dp[i-1][j] + abs(d[j].c - d[k].c));
                    }
                }
            }
        }
    }
    int ans = 0;
    for(int j = 1;j <= N;j++){
        //cout<<j<<"の服";
        for(int i = 1;i <= D;i++){
            //cout<<i<<"日目: "<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    for(int j = 1;j <= N;j++){
        ans = max(ans,dp[D][j]);
    }
    cout<<ans<<endl;

    return 0;
}

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

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

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; }

ll dp[1010][20010];

/*bool hoge(pair<double, int> a, pair<double,int> b) {
	if(a.fi > b.fi) return true;
	else return false;
}*/

int main() {
	int h,n;
	cin >> h >> n;
	vector<ll> a(n), b(n);
	rep(i,n) cin >> a[i] >> b[i];
	ll maxi = -1;
	rep(i,n) chmax(maxi, a[i]);
	rep(i,n+1)rep(j,h+maxi) dp[i][j] = 1e18;

	rep(i,n+1) dp[i][0] = 0;
	for(int i=1; i<=n; i++) for(int j=0; j<h+maxi;j++)  {
		ll index = i-1;
		//cout << i << " " << j << " " << j+a[index] << " "; 
		if(j >= a[index]) {
			//cout << "case1: ";
			//cout << dp[i][j-a[index]]+b[index] << " " << dp[i-1][j];
			dp[i][j] = min(dp[i][j-a[index]] + b[index], dp[i-1][j]);
		}
		else {
			dp[i][j] = dp[i-1][j];
			//cout << "case2 ";
			//cout << i << " " << j << " " << dp[i][j] << " " << dp[i-1][j];
		}
		//cout << endl;
	}
	/*rep(i,n+1) {
		rep(j,h+maxi) {
			if (dp[i][j] >= 1e9) cout << setw(3) << "na";
			else cout << setw(3) << dp[i][j];
		}
		cout << endl;
	}*/
	ll mini = 1e18;
	for(int i=h; i<h+maxi; i++) chmin(mini, dp[n][i]);
	//cout << dp[n][h] << endl;
	cout << mini << endl;

	/*rep(i,n) {
		if(a[i] > h) a[i] = h;
	}
	vector<pair<double, int>> c(n);
	rep(i,n) c[i] = pair<double, int>(a[i]*1.0/b[i], i);
	sort(c.begin(), c.end(), hoge);
	ll ans = 0;
		while(h > 0) {
			cout << c[0].se << " ";
				
			//int tmp = h / a[c[0].se];
			//cout << tmp << " ";
			ans += b[c[0].se];
			h -= a[c[0].se];
			cout << h << endl;
			rep(i,n) {
				if(a[i] > h) a[i] = h;
				c[i] = pair<double,int>(a[i]*1.0/b[i], i);
		}
		sort(c.begin(),c.end(),hoge);
	}*/


  return 0;
}


Measured memory_bytes: 157056
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main() {
    char S[100];
    char mae[50]={};
    char ato[50]={};
    char mae_mae[25]={};
    char mae_ato[25]={};
    char ato_mae[25]={};
    char ato_ato[25]={};

    scanf("%s",&S);

    strncpy(mae,S,(strlen(S)-1)/2);
    for(int i = 0; i < (strlen(S)-1)/2; ++i){
        ato[i] = S[(strlen(S)- 1 - i)];
    }
    if(strcmp(mae,ato) != 0){
        printf("No");
        return 0;
    }

    if(strlen(mae)% 2 == 1) {
        strncpy(mae_mae, mae, (strlen(mae) - 1) / 2);
        strncpy(ato_mae, ato, (strlen(ato) - 1) / 2);
        for(int i = 0; i < (strlen(mae)-1)/2; ++i){
            mae_ato[i] = S[(strlen(mae)- 1 - i)];
            ato_ato[i] = S[(strlen(mae)- 1 - i)];
        }

    }
    else {
        strncpy(mae_mae, mae, strlen(mae) / 2);
        strncpy(ato_mae, ato, strlen(ato) / 2);
        for (int i = 0; i < (strlen(mae)) / 2; ++i) {
            mae_ato[i] = S[(strlen(mae)- 1 - i)];
            ato_ato[i] = S[(strlen(mae)- 1 - i)];
        }
    }

    if(strcmp(mae_mae,mae_ato) != 0 || strcmp(ato_mae,ato_ato) != 0){
        printf("No");
        return 0;
    }
    else{
        printf("Yes");
        return 0;
    }
}

int A(){
    int N,M;
    int ans;
    scanf("%d %d",&N,&M);

    ans = (N-1)*N/2 + (M-1)*M/2;
    printf("%d",ans);

    return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
ll a, b, c;

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> a >> b >> c;
    cout << (c + max(a, b) - 1) / max(a, b);


    return 0;
}



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

typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  int ans=1;
  bool flag=false;
  for (int i = 1; i < N; i++) {
    for (int j = 0; j < i; j++) {
      if ((H.at(i)-H.at(j))>=0){
        flag=true;
      }else{
        flag=false;
        break;
      }
    }
    if (flag) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
    int to;
    T cost;
    Edge() {};
    Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
    int n;
    bool directed;
    vector<vector<Edge<T>>> edges;
public:

    Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)){};
    Graph() {};

    void add(int from,int to, T cost) {
        edges[from].emplace_back(to, cost);
        if(!directed){
            edges[to].emplace_back(from,cost);
        }
    }


    int size() {
        return n;
    }
};


int main() {

    map<long long,long long> M;

    long long N;
    cin >> N;

    for(long long i = 2; i*i <= N;i++){
        if(N%i!=0)continue;

        long long ex = 0;
 
        while(N%i == 0){
            ++ex;
            N/=i;
        }

        M.emplace(i,ex);
      
    }
     if (N != 1) M[N] = 1;

    int ans = 0;

    for(auto& m:M){
        int a = 1;
        while(1){
            m.second-=a;
            if(m.second < 0){
                break;
            }
            a++;
            ans++;
        };
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

/*
ll mod(ll n, ll m) {
n -= (n / m)*m;
return n;
}
ll loop(ll n, ll m, ll k) {
if (k == 1) {
return n % m;
}
else if (k % 2 == 0) {
ll t = loop(n, m, k / 2);
return t * t%m;
}
else {
return loop(n, m, k - 1)*n%m;
}
}
*/
int main() {
	int a, b, k;
	//int A[100];
	cin >> a >> b >> k;
	//int res[210];
	//long long int res = pow(2,3);
	//res = max({ A, B, C })*(pow(2, K) - 1) + A + B + C;
	//cout << mod(134,10) << endl;
	//int cnt = 0;
	if ((b - a) + 1  >= k * 2) {
		for (int i = 0; i < k; ++i) {
			cout << a + i << endl;
		}
		for (int i = k; i > 0; --i) {
			cout << b - i + 1 << endl;
			//cnt++;
		}
		/*for (int i = 0; i < k; ++i) {
			res[cnt] = a + i;
			cnt++;
		}
		for (int i = k; i > 0; ++i) {
			res[cnt] = b - i + 1;
			cnt++;
		}*/

	}
	else if ((b - a) + 1 < k * 2) {
		/*for (int i = 0; i < b; ++i) {
			res[cnt] = a + i;
			cnt++;
		}*/
		for (int i = 0; i <= b - a; ++i) {
			cout << a + i << endl;
			//cnt++;
		}
	}
	/*
	for (int i = 0; i < size(res); ++i) {
		cout << res[i] << endl;
	}
	*/
	//cout << size(res) << endl;
	return 0;

}


Measured memory_bytes: 256
long long i,j;a[1000000],s;main(){for(i=2;i<1e6;i++){if(!a[i])for(j=i*i;j<1e6;j+=i)a[j]=1;a[i]=s+=!a[i];}for(;~scanf("%d",&i);printf("%d\n",a[i]));}

Measured memory_bytes: 4184
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
#include <cmath>
#include <iomanip> //setprecision(2)
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define for2(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef pair<ll, ll> pair_t;

int bit[114514][40], bit2[40], ans[40];

int main(){
        int n;
        ll k, a;
        cin >> n >> k;
        rep(i, n){
                cin >> a;
                int res1=0;
                while(a>0) {
                        bit[i][res1++]=a&1;
                        a/=2;
                }
        }
        int kres1=0;
        while(k>0) {
                bit2[kres1++]=k&1;
                k/=2;
        }
        bool min=false;
        for2(i, 0, 40){
                int res1=0;
                rep(j, n){
                        if(bit[j][i]) {
                                ++res1;
                        }
                }
                if(res1*2<n) {
                        if(!min && bit2[i]==0) {
                                ans[i]=res1;
                        }
                        else{
                                ans[i]=n-res1;
                        }
                }
                else{
                        ans[i]=res1;
                        if(!min && bit2[i]==1) {
                                min=true;
                        }
                }
        }
        ll res=0, res2=1;
        rep(i, 40){
                res+=res2*ans[i];
                res2*=2;
        }
        cout << res << endl;
        return 0;
}


Measured memory_bytes: 16640
N, M, D = gets.chomp.split(/ /).collect(&:to_i)

beauty = [0.0]
(2 .. M).each do |m|
  prev_beauty = beauty.last
  plus2_case_count = (D > 0 ? (1 + D .. N - D).size : 0)
  plus1_case_count = N - plus2_case_count
  beauty << ((plus1_case_count + plus2_case_count * 2) * (prev_beauty + 1) + (plus1_case_count * (N - 1) + plus2_case_count * (N - 2)) * prev_beauty) / (N * N)
end

puts beauty.last

Measured memory_bytes: 26876
#include <iostream>
#include <bits/stdc++.h>
using namespace std; 
void solve() 
{
    string S,T; 
    cin >> S >> T; 
    int count =0; 
    for(int i = 0 ; i<S.size() ; i++) 
    {
        if(S[i]!=T[i]) 
            count ++; 
    }
    cout << count << endl; 
}
int main () 
{
    int t=1; 
    for (int i=1;i<=t; i++) 
    {
        solve() ; 
    }
    return 0;
}


Measured memory_bytes: 3840
INF = 10 ** 9

n, m = map(int, input().split())
a = [[INF] * n for _ in range(n)]
e = [None] * m
for i in range(n): a[i][i] = 0
for i in range(m):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    e[i] = (u, v, w)
    a[u][v] = w
    a[v][u] = w
for k in range(n):
    for i in range(n):
        for j in range(n):
            a[i][j] = min(a[i][j], a[i][k] + a[k][j])
c = 0
for u, v, w in e:
    if a[u][v] != w: c += 1
print(c)


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


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

	int i;
	int rate[9] = {};
	for (i = 0; i < n; i++) {
		cin >> a;
		a > 3200 ? rate[8]++ : rate[a / 400]++;
	}

	int min = 0;
	for (i = 0; i < 8; i++) {
		if (rate[i])min++;
	}

	cout << (min == 0 ? 1: min) << " " << min + rate[8] << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
void Swap(int &a,int &b)
{
	int temp = a;
	a = b;
	b = temp;
}
int main(void)
{

    int N, a[100],d=0, i, j,min;
	cin >> N;
    for (i = 0; i < N; i++)
        cin >> a[i];
	for (i=0; i<N-1 ; i++)
		{		min = i;
			for(j = i+1; j <N ; j++)
				if (a[j ] < a[min]) 
					min = j;
			if (min!=i)  
			{
                 Swap(a[min],a[i]);
					d++;
			}
		}
	for (i = 0; i < N; i++)
	{
		if(i<N-1)
			cout << a[i] << " ";
		else
			cout<< a[i];
	}
	cout<<endl;
	cout<<d<<endl;
    return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    unordered_map<string, int> res;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        res[s]++;
    }
    for (const auto& i : {"AC", "WA", "TLE", "RE"}) {
        cout << i << " x " << res[i] << endl;
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ll INF = ll(1e18)+1;

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

    ll n;
    double d;
    cin >> n >> d;
    ll result = 0;

    rep(i,n){
        double x,y;
        cin >> x >> y;
        // cout << sqrt(x*x+y*y) << "\n";
        if(sqrt(x*x+y*y) <= d) result++;
    }

    cout << result;
}

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

int m,d;
int ans;

int main()
{
	cin >> m >> d;
	for(int i=1;i<=m;i++)
	{
		for(int j=10;j<=d;j++)
		{
			if(j%10>=2&&j/10>=2&&(j%10)*(j/10)==i) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順


ll lcm(ll a, ll b) {
  return a * b / __gcd(a,b);
}

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll A1 = (B/C) - ((A-1)/C);
    ll A2 = (B/D) - ((A-1)/D);
    ll A3 = (B/lcm(C,D)) - ((A-1)/lcm(C,D));
    cout << B - A + 1 - A1 - A2 + A3 << endl;
}

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

int main() {
    int a, b;
    cin >> a >> b;

    int ans = 0;
    for (int i = a; i <= b; i++) {
        string s = to_string(i);
        string s2 = s;
        reverse (s2.begin(), s2.end());
        if (s == s2) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
N = int(input())
A = []
x = []
y = []
for i in range(N):
    A.append(int(input()))
    lx = []
    ly = []
    for j in range(A[i]):
        xx, yy = map(int, input().split())
        lx.append(xx-1)
        ly.append(yy)
    x.append(lx)
    y.append(ly)

m = -1
for pattern in range(2**N):
    p = format(pattern, '0'+str(N)+'b')[::-1]
    bl = True
    for i in range(N):
        if (pattern>>i)&1:
            for j in range(A[i]):
                if p[x[i][j]] != str(y[i][j]):
                    bl = False
    if bl:
        m = max(p.count('1'), m)

print(m)

Measured memory_bytes: 44136
A,B,C,D=map(int,input().split())

if B<=C or D<=A:
    print(0)
elif A<=C and B<=D:
    print(B-C)
elif C<=A and D<=B:
    print(D-A)
elif A<=C and D<=B:
    print(D-C)
elif C<=A and B<=D:
    print(B-A)
 


Measured memory_bytes: 2940
#include<cstdio>
#include<bitset>
#include<cstring>
using namespace std;
int R,C,MAX;
bitset<10000> A[10];
void dfs(int cur)
{
    int sum1 = 0, sum2 = 0, sum = 0;
    if(cur == R){
        for(int i = 0; i < C; i++){
            for(int j = sum1 = sum2 = 0; j < R; j++){
                if(A[j][i] == 1) sum1++;
                else sum2++;
            }
            sum += max(sum1,sum2);
        }
        MAX = max(sum,MAX);
    }
    else{
     
        dfs(cur+1);
        A[cur].flip();
        dfs(cur+1);
    }
}
int main()
{
    int temp;
    while(scanf("%d%d",&R,&C) && R){
        for(int i = 0; i < R; i++)
            for(int j = 0; j < C; j++)
               scanf("%d",&temp),A[i][j] = temp;
        MAX = -1;
        dfs(0);
        printf("%d\n",MAX);
    }
    return 0;
}

Measured memory_bytes: 1040
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))

l = [0,0,0]
for i in range(N):
    if (P[i] <= A):
        l[0] += 1
    elif (P[i] <= B):
        l[1] += 1
    else:
        l[2] += 1

print(min(l))

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

lint segdata[(1<<19)-1];
lint lazy[(1<<19)-1];

lint neutral(){
    return -INF; //単位元
}
lint calc(lint a,lint b){
    return max(a,b); //演算 デフォルトでは最小値
}
void seginit(){
    rep(i,(1<<19)-1) segdata[i]=neutral();
}
void update(lint i,lint x){ // i番目の値をxに更新 rangeadd()の後に使ったらだめ 単位元が0以外の時だけ使う
    i+=(1<<18)-1;
    segdata[i]=x;
    while(i>0){
        i=(i-1)/2;
        segdata[i]=calc(segdata[i*2+1],segdata[i*2+2]);
    }
}
void eval(lint k,lint l,lint r){
    if(lazy[k]){
        segdata[k]+=lazy[k]/(r-l);
        if(r-l>1) lazy[2*k+1]+=lazy[k]/2,lazy[2*k+2]+=lazy[k]/2;
        lazy[k]=0;
    }
}
void add(lint a,lint b,lint x,lint k,lint l,lint r){
    eval(k,l,r);
    if(r<=a || b<=l) return;
    if(a<=l && r<=b){
        lazy[k]+=(r-l)*x;
        eval(k,l,r);
    }
    else{
        add(a,b,x,2*k+1,l,(l+r)/2);
        add(a,b,x,2*k+2,(l+r)/2,r);
        segdata[k]=calc(segdata[2*k+1],segdata[2*k+2]);
    }
}
lint seg(lint a,lint b,lint k,lint l,lint r){
    eval(k,l,r);
    if(r<=a || b<=l) return neutral();
    if(a<=l && r<=b) return segdata[k];
    else{
        lint left=seg(a,b,k*2+1,l,(l+r)/2);
        lint right=seg(a,b,k*2+2,(l+r)/2,r);
        return calc(left,right);
    }
}
lint query(lint a,lint b){
    return seg(a,b+1,0,0,1<<18); //a~b(閉区間）の範囲での演算
}
void rangeadd(lint a,lint b,lint x){ //a~b(閉区間)にxを加算
    add(a,b+1,x,0,0,1<<18); 
    return;
}

int main(void){
    seginit();
    int N,C;
    cin >> N >> C;
    rangeadd(0,150000,INF);
    pair<int,pint> movie[N];
    rep(i,N) cin >> movie[i].se.fi >> movie[i].se.se >> movie[i].fi;
    sort(movie,movie+N);
    int before=-1,cha=-1;
    rep(i,N){
        if(cha!=movie[i].fi) before=-1,cha=movie[i].fi;
        if(before==movie[i].se.fi) movie[i].se.fi++;
        rangeadd(movie[i].se.fi,movie[i].se.se,1);
        before=movie[i].se.se;
    }
    cout << query(0,150000) << endl;
}

Measured memory_bytes: 8448
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main() {
    char s[105];
    int n;
    long long int d;
    scanf("%s", s);
    scanf("%lld", &d);
    n = strlen(s);

    for (int i=0; i<=n; ++i) {
        if (s[i]== '1' && d==i+1) {
            printf("%c\n", s[i]);
            break;
        }
        else if (s[i]!='1') {
            printf("%c\n", s[i]);
            break;
        }
    }
    return 0;
}


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

string s;

int reversi(char B,char W)
{
	int ans=0;
	bool x=false;
	
	for(int i=1;i<s.size();i++)
	{
		if(s[i]==B&&x==true)
		{
			x=false;
			ans++;
		}
		else if(s[i]==W&&x==false)
		{
			x=true;
			ans++;
		}
	}
	
	return ans;
}
int main()
{
	ios::sync_with_stdio(false);
	
	cin>>s;
	
	char B='B',W='W';
	
	if(s[0]=='B')
		cout<<reversi(B,W)<<endl;
	else
		cout<<reversi(W,B)<<endl;
	
	return 0;
}

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

count = 0
count_list = []
check = S[0]

for i in range(N):
    if S[i] == check:
         count += 1
    else:
        count_list.append(count)
        count = 1
        check = S[i]
    if i == N-1:
        count_list.append(count)

if S[0] == '0':
    count_list.insert(0, 0)
if S[-1] == '0':
    count_list.append(0)

k = min((len(count_list)-1)//2, K)

ans_list = []
for i in range((len(count_list)+1)//2 - k):
    if i == 0:
        tmp = sum(count_list[0:2*k+1])
    else:
        tmp = tmp - count_list[2*(i-1)] - count_list[(2*(i-1)+1)] 
        tmp = tmp + count_list[2*(k+i)-1] + count_list[2*(k+i)]
    ans_list.append(tmp)

print(max(ans_list))

Measured memory_bytes: 6084
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
const int IINF = 1 << 30;
vector<vector<int>> dist(1010, vector<int>(1010, IINF));
vector<vector<bool>> visited(1010, vector<bool>(1010, false));
vector<string> g;
int h, w;
bool is_valid(int y, int x)
{

    return 0 <= y && y < h && 0 <= x && x < w && visited[y][x] == false && g[y][x] != '#';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> h >> w;
    g.resize(h);
    rep(i, h)
    {
        cin >> g[i];
    }
    deque<pair<int, int>> que;
    rep(i, h) rep(j, w)
    {
        if (g[i][j] == '#')
        {
            que.push_back({i, j});
            dist[i][j] = 0;
        }
    }
    int ans = 0;
    int dy[4] = {1,
                 -1,
                 0,
                 0};
    int dx[4] = {0,
                 0,
                 1,
                 -1};
    while (!que.empty())
    {
        deque<pair<int, int>> next;
        while (!que.empty())
        {
            auto cur = que.front();
            que.pop_front();

            int y = cur.first;
            int x = cur.second;
            rep(i, 4)
            {
                int ny = y + dy[i];
                int nx = x + dx[i];
                if (is_valid(ny, nx) && dist[ny][nx] == IINF)
                {

                    next.push_back({ny, nx});
                    dist[ny][nx] = dist[y][x] + 1;

                    visited[ny][nx] = true;
                    ans = max(ans, dist[ny][nx]);
                }
            }
        }
        que = next;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13824
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var s = input.ReadLine();
        var t = input.ReadLine();

        int min = int.MaxValue;

        for(int i=0; i <= s.Length - t.Length; i++) {

            int co = 0;
            for(int j=0; j<t.Length; j++) {
                var c1 = t[j];
                var c2 = s[i+j];

                if(c1 != c2) co++;
            }

            min = Math.Min(co, min);
        }

        return min;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


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

int main() {
  int L,R;  
  cin >>L >>R;
  int K=L;
  L=L%2019;
  R=R-(K-L);
  int x=min(R,L+2020);
  int y=min(R,L+4040);
  int m=2018;
  for (int i=L; i<x; i++){
    for(int j=i+1; j<y+1;j++){
      int l=i*j;
      int n=l%2019;
      m=min(m,n);
    }
  }
  cout <<m;
}

Measured memory_bytes: 256
function Main(input) {
	const lines = input.split('\n');
	const [s, t] = lines[1].split(' ').map(v => v.split(''));
	const result = s.reduce((acc, v, i) => acc + v + t[i], '');

	console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++) cin >> a[i];
  vector<bool> memo(8, false); // その色の人がすでにいるかどうか
  int ans = 0;
  for (int i=0; i<N; i++) {
    if (a[i]<400) {
      if (!memo[0]) {
        ans++;
        memo[0] = true;
      }
    }
    else if (a[i]<800) {
      if (!memo[1]) {
        ans++;
        memo[1] = true;
      }
    }
    else if (a[i]<1200) {
      if (!memo[2]) {
        ans++;
        memo[2] = true;
      }
    }
    else if (a[i]<1600) {
      if (!memo[3]) {
        ans++;
        memo[3] = true;
      }
    }
    else if (a[i]<2000) {
      if (!memo[4]) {
        ans++;
        memo[4] = true;
      }
    }
    else if (a[i]<2400) {
      if (!memo[5]) {
        ans++;
        memo[5] = true;
      }
    }
    else if (a[i]<2800) {
      if (!memo[6]) {
        ans++;
        memo[6] = true;
      }
    }
    else if (a[i]<3200) {
      if (!memo[7]) {
        ans++;
        memo[7] = true;
      }
    }
  }
  int maxi = ans, mini;
  for (int i=0; i<8; i++) {
    if (memo[i]) {
      mini = ans;
      break;
    }
    else mini = 1;
  }
  for (int i=0; i<N; i++) {
    if (3200<=a[i]) maxi++;
  }
  cout << mini << " " << maxi << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int H,W;
char masu[1005][1005];
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
int used[1005][1005];
queue<PII> task;

void update(int h, int w)
{
    //dump(h)
    //dump(w)
    REP(i,4)
    {
        int nh = h + dy[i];
        int nw = w + dx[i];
        dump(nh)
        dump(nw)
        dump(used[nh][nw])
        if(0 <= nh && nh < H && 0 <= nw && nw < W && used[nh][nw] == false)
        {
            used[nh][nw] = true;
            task.push(make_pair(nh,nw));
        }
    }

}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    REP(i,1005) REP(j,1005) used[i][j] = false;
    bool dark = 1;
    REP(i,H)
    {
        REP(j,W)
        {
            cin >> masu[i][j];
            if(masu[i][j] == '#') task.push(make_pair(i,j));
            else dark = 0;
        }
    }
    if(dark)
    {
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;

    while(!task.empty()){
        dump("loop")

        queue<PII> tmptask;
        while(!task.empty())
        {
            tmptask.push(task.front()); task.pop();
        }
        while(!tmptask.empty())
        {
            auto p = tmptask.front(); tmptask.pop();
            dump(p.first)
            dump(p.second)
            //if(used[p.first][p.second] == false)
            if(1)
            {
                used[p.first][p.second] = true;
                update(p.first,p.second);
            }
        }

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



}

Measured memory_bytes: 13328
n = int(input())
A = list(map(int, input().split()))
q = int(input())
S = []
for _ in range(q):
    x, y = map(int, input().split())
    S.append((x, y))

sum = sum(A)
# print(sum)
R = [0 for _ in range(10**5+1)]
for a in A:
    R[a-1] += 1

for (x,y) in S:
    sum += (y-x)*R[x-1]
    R[y-1] += R[x-1]
    R[x-1] = 0
    print(sum)

Measured memory_bytes: 28072
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  sort(ALL(a));
  multiset<int> neg, pos;
  int ans = 0;
  if (0 <= a[0]) {
    neg.insert(a[0]);
    ans -= a[0];
    REP(i, n) {
      if (i == 0) continue;
      pos.insert(a[i]);
      ans += a[i];
    }
  } else if (a[n - 1] < 0) {
    pos.insert(a[n - 1]);
    ans += a[n - 1];
    REP(i, n) {
      if (i == n - 1) continue;
      neg.insert(a[i]);
      ans -= a[i];
    }
  } else {
    REP(i, n) {
      (a[i] < 0 ? neg : pos).insert(a[i]);
      ans += (a[i] < 0 ? -a[i] : a[i]);
    }
  }
  cout << ans << endl;
  while (1 < pos.size()) {
    int x = *neg.begin();
    neg.erase(neg.find(x));
    int y = *pos.begin();
    pos.erase(pos.find(y));
    neg.insert(x - y);
    cout << x << " " << y << endl;
  }
  while (neg.size()) {
    int x = *pos.begin();
    pos.erase(pos.find(x));
    int y = *neg.begin();
    neg.erase(neg.find(y));
    pos.insert(x - y);
    cout << x << " " << y << endl;
  }
  return 0;
}

Measured memory_bytes: 6912
open System
open System.Collections.Generic;

let S =stdin.ReadLine()
[<EntryPoint>]
let sf argv =
    let L = String.length S|>int
    let mutable ok = true
    for i in [0..L-1] do
        match i%2=0 with
        | true -> ok <- if S.[i]= 'L' then false else ok
        | _ -> ok <- if S.[i] = 'R' then false else ok 
    match ok with
    | true -> printfn "Yes"
    |_ -> printfn "No"
    0 


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

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)

typedef long long ll;

const int V_MAX = 1000;
const int E_MAX = 2000;
const ll INF = 1e+18;

struct edge {
  int from;
  int to;
  int cost;
};

int V, E;
edge es[E_MAX];
ll d[V_MAX];
bool negative[V_MAX];

ll shortest_path() {
  fill(d, d + V, INF);
  d[0] = 0;
  REP(i, V - 1) {
    REP(j, E) {
      edge e = es[j];
      if (d[e.from] == INF) continue;
      if (d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
      }
    }
  }
  return d[V - 1];
}

bool has_negative_path() {
  fill(negative, negative + V, false);
  REP(i, V) {
    REP(j, E) {
      edge e = es[j];
      if (d[e.from] == INF) continue;
      if (d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        negative[e.to] = true;
      }
      if (negative[e.from]) negative[e.to] = true;
    }
  }
  return negative[V - 1];
}

void solve() {
  ll ans = shortest_path();
  bool neg = has_negative_path();
  if (neg) {
    puts("inf");
  } else {
    printf("%lld\n", -ans);
  }
}

void input() {
  int N, M;
  scanf("%d%d", &N, &M);
  V = N;
  E = M;
  REP(i, M) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    es[i] = {a - 1, b - 1, -c};
  }
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeSet;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(true){
           int n;
           n=sc.nextInt();
           if(n==0)break;
           int x[]=new int[n];
           for(int i=0;i<n;i++){
               x[i]=sc.nextInt();
        }
        Arrays.sort(x);
        int ans=0;
        for(int i=1;i<n-1;i++){
            ans+=x[i];
        }
        ans/=(n-2);
        System.out.println(ans);
    }
}
}



Measured memory_bytes: 28472
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=998244353;
int sum[200010],dp[200010];
pair<int,int>a[15];
signed main()
{
	int n,k,i,j;
	cin>>n>>k;
	for(i=1;i<=k;i++)
		cin>>a[i].first>>a[i].second;
	sort(a+1,a+k+1);
	dp[1]=1;
	for(i=2;i<=n;i++)
	{
		for(j=1;j<=k;j++)
			sum[j]=(sum[j]+mod+mod-dp[max(0ll,i-a[j].second-1)]+dp[max(0ll,i-a[j].first)])%mod;
		for(j=1;j<=k;j++)
			dp[i]=(dp[i]+sum[j])%mod;
	}
	cout<<dp[n]%mod;
	return 0;
}

Measured memory_bytes: 5184
import java.util.Scanner;

/**
 * Lucky PIN
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            char[] S = sc.next().toCharArray();

            int[] C = new int[N];
            for (int i = 0; i < N; i++) {
                C[i] = S[i] - '0';
            }

            boolean[] d1 = new boolean[10];
            boolean[][] d2 = new boolean[10][10];
            boolean[][][] d3 = new boolean[10][10][10];

            for (int i = 2; i < N; i++) {
                d1[C[i - 2]] = true;

                for (int j = 0; j < 10; j++) {
                    if (!d1[j]) {
                        continue;
                    }

                    d2[j][C[i - 1]] = true;

                    for (int k = 0; k < 10; k++) {
                        if (!d2[j][k]) {
                            continue;
                        }

                        d3[j][k][C[i]] = true;
                    }
                }
            }

            int ans = 0;
            for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 10; j++) {
                    for (int k = 0; k < 10; k++) {
                        if (d3[i][j][k]) {
                            ans++;
                        }
                    }
                }
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 24528
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace ACprac
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int d = int.Parse(str[0]);
            int n = int.Parse(str[1]);
            if (n == 100) n++;
            int kai = n * (int)(Math.Pow(100, d));


            Console.WriteLine(kai);


        }
    }
}



Measured memory_bytes: 13140
/*
[diverta2019-2] C - Successive Subtraction
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;

int N;
int A[MAX_N];

void solve() {
    int idx[MAX_N];
    for (int i = 0; i < N; i++) {
        idx[i] = i;
    }
    sort(idx, idx + N, [](int a, int b) { return A[a] < A[b]; });
    sort(A, A + N);
    int x = lower_bound(A, A + N, 0) - A;
    x = max(min(x, N - 1), 1);

    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += (i < x) ? -A[i] : A[i];
    }
    cout << ans << endl;

    for (int i = x; i < N - 1; i++) {
        cout << A[0] << " " << A[i] << endl;
        A[0] -= A[i];
    }
    for (int i = 0; i < x; i++) {
        cout << A[N - 1] << " " << A[i] << endl;
        A[N - 1] -= A[i];
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
int main() {
    int abc[3];
    REP(i,3){
        cin>>abc[i];
    }
    int cnt=0;
    sort(abc,abc+3);
    while(abc[0]!=abc[1]||abc[1]!=abc[2]||abc[0]!=abc[2]){
        if (abc[0]<abc[2]&&abc[1]<abc[2])
        {
            abc[0]++;
            abc[1]++;
            cnt++;
        }
        else if(abc[0]<abc[2])
        {
            abc[0]+=2;
            cnt++;
        }
        sort(abc,abc+3);
        
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

struct Node{
	Node(){
		left_child = right_child = parent = -1;
	};
	int left_child,right_child,parent;
};

void preORDER(Node order[],int id){
	printf(" %d",id);
	if(order[id].left_child != -1) preORDER(order,order[id].left_child );
	if(order[id].right_child != -1) preORDER(order,order[id].right_child );
}

void inORDER(Node order[],int id){
	if(order[id].left_child != -1) inORDER(order,order[id].left_child );
	printf(" %d",id);
	if(order[id].right_child != -1) inORDER(order,order[id].right_child );
}

void postORDER(Node order[],int id){
	if(order[id].left_child != -1) postORDER(order,order[id].left_child );
	if(order[id].right_child != -1) postORDER(order,order[id].right_child );
	printf(" %d",id);
}

int main(){
	int n,id,left,right,root_id;
	scanf("%d",&n);
	Node order[n];
	for(int i = 0; i < n; i++){
		scanf("%d %d %d",&id,&left,&right);
		if(left != -1){
			order[id].left_child = left;
			order[left].parent = id;
		}
		if(right != -1){
			order[id].right_child = right;
			order[right].parent = id;
		}
	}

	for(root_id = 0; root_id < n; root_id++){
		if(order[root_id].parent == -1) break;
	}

	printf("Preorder\n");
	preORDER(order,root_id);
	printf("\n");

	printf("Inorder\n");
	inORDER(order,root_id);
	printf("\n");

	printf("Postorder\n");
	postORDER(order,root_id);
	printf("\n");
}

Measured memory_bytes: 1048
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,k;
  cin>>n>>k;
  long long ans=(n/k)*(n/k)*(n/k);
  //cout<<ans<<endl;
  if (k%2==0) ans+=(n/(k/2)-n/k)*(n/(k/2)-n/k)*(n/(k/2)-n/k);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
num = list(map(int, input().split()))

count = 0
while True:
    odd_flag = False
    for value in num:
        if value % 2 != 0:
            odd_flag = True
    if odd_flag:
        break
    count += 1
    new_num = [value / 2 for value in num]
    num = new_num
print(count)


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

#define int long long

int32_t main()
{
  
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m;
    cin>>n>>m;
    vector <int> adj[n+1];

    while(m--)
    {
        int x,y;
        cin>>x>>y;

        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    bool vis[n+1];
    map <int,vector <int> > prev;

    for(int i=1;i<=n;i++)
        vis[i]=false;


    queue <int> q;
    q.push(1);
    prev[1].push_back(-1);
    vis[1]=true;

    while(not q.empty())
    {
        int v=q.front();
        q.pop();

        for(int i=0;i<adj[v].size();i++)
        {
            if(not vis[adj[v][i]])
            {
                vis[adj[v][i]]=true;
                q.push(adj[v][i]);
                prev[adj[v][i]].push_back(v);
            }
        }
    }

    for(int i=2;i<=n;i++)
    {
        if(prev[i].size()!=1)
        {
            cout<< "No";
            return 0;
        }
    }
    cout<< "Yes\n";

    for(int i=2;i<=n;i++)
        cout<<prev[i][0]<< "\n";






    return 0;
}


Measured memory_bytes: 22860
import static java.lang.System.*;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		int room[][][] = new int[4][10][3];
		
		for(int a = 1; a <= count; a++) {
			int b = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			int v = sc.nextInt();
			room[b - 1][r - 1][f - 1] += v;
		}
		for(int a = 0; a < 4; a++) {
			for(int b = 0; b < 3; b++) {
				for(int c = 0; c < 10; c++) {
					if(a == 3 && b == 2 && c == 9) {
						out.println(" " + room[a][c][b]);
						exit(0);
					}else {
						out.print(" " + room[a][c][b]);
					}
				}
				out.println();
			}
			if(a != 3) {
				out.println("####################");
			}else {
				out.println();
			}
		}
	}
}


Measured memory_bytes: 29292
a = int(input())
l = list(map(int,input().split()))
b= int(input())
L = list(map(int,input().split()))
from collections import Counter
c = Counter(l)
C = Counter(L)

for i in C:
    if C[i] > c[i]:
        print('NO')
        exit()
print('YES')



Measured memory_bytes: 56928