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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    if(S == "RRR") cout << 3 << endl;
    else if(S == "RRS" || S == "SRR") cout << 2 << endl;
    else if(S == "SSS") cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;
const long long MOD=1e9+7;
long long c[2005][2005];
int n, k;
long long C(int N, int M)
{
	if(N<M)
		return 0;
	return c[N][M];
}
void woh(int N)
{
	for(int i=0; i<=N; i++)
		c[i][0]=c[i][i]=1;
	for(int i=1; i<=N; i++)
		for(int j=1; j<=i-1; j++)
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%MOD;
}
int main()
{
	cin>>n>>k;
	woh(n);
	for(int i=1; i<=k; i++)
	{
		long long ans=C(n-k+1, i)*C(k-1, i-1)%MOD;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 30080
import sys

N = int(input())
H = list(map(int, input().split()))

new_H = list(reversed(H))

max = new_H[0]

for i in range(1,N):
  if new_H[i] <= max:
    max = new_H[i]
  elif new_H[i] == max + 1:
    max = new_H[i] - 1
  else:
    print('No')
    sys.exit()

print('Yes')

Measured memory_bytes: 14396
import copy

def score(i,j):
  Ali = copy.deepcopy(data)
  Ali[i][j] = 0
  score = 0
  turn = 0
  
  for i in range(1,H+1):
    for j in range(W):
      if Ali[-i][j] == 0:
        for k in range(i+1,H+1):
          if Ali[-k][j] != 0:
            Ali[-i][j] = Ali[-k][j]
            Ali[-k][j] = 0
            break
            
  while True:
    sc = score
    #同じものを消す処理
    for i in range(H):
      a = 0 #今の数字
      b = 0 #今の数字が始まった場所
      
      for j in range(W):
        if Ali[i][j] != a:
          if j-b >= K:
            for k in range(b,j):
              score += Ali[i][k]*2**turn
              Ali[i][k] = 0
          a = Ali[i][j]
          b = j
      if W-b >= K:
        for k in range(b,W):
          score += Ali[i][k]*2**turn
          Ali[i][k] = 0
      
      
    if sc == score:
        break
    turn += 1
      
    #落としていく処理
    #下から上に見ていく
    for i in range(1,H+1):
      for j in range(W):
        if Ali[-i][j] == 0:
          for k in range(i+1,H+1):
            if Ali[-k][j] != 0:
              Ali[-i][j] = Ali[-k][j]
              Ali[-k][j] = 0
              break
              
  return score
  
H,W,K = map(int,input().split())
data = [[int(d) for d in input()] for _ in range(H)]
res = 0

for i in range(H):
  for j in range(W):
    res = max(res,score(i,j))
    
print(res)

Measured memory_bytes: 58716
#include<iostream>
#include<vector>
using namespace std;
 int main(){
  long long int n,i,j,sum=0;
  cin>>n;
  vector<int>a(n);
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      sum=sum+a[i]*a[j];
    }
  }
  cout<<sum<<"\n";
  return 0;
}

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

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

Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

ll gen(ll x, ll y){
  if(y == 1)return x;
  ll res = 1;
  if(y%2){
    res = x*gen(x,y-1);
  }else{
    res = gen(x,y/2)*gen(x,y/2);
  }
  return res%MOD;
}

ll nijou(ll x){
  if(x==1)return 2;
  ll res;
  if(x%2){
    res = 2*nijou(x-1);
  }else{
    res = nijou(x/2)*nijou(x/2);
  }
  return res%MOD;
}

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

  ll resa,resb;
  resa = 1;
  resb = 1;
  ll a1,b2,nn;
  nn = n;
  a1 = 1;
  b2 = 1;
  while(nn>=n-a+1 || a1<=a){
    resa = (resa*nn)%MOD;
    resa = (resa*gen(a1,MOD-2))%MOD;
    nn--;
    a1++;
  }
  nn = n;
  while(nn>=n-b+1 || b2<=b){
    resb = (resb*nn)%MOD;
    resb = (resb*gen(b2,MOD-2))%MOD;
    nn--;
    b2++;
  }

  ll all = nijou(n);
  //cout << all << endl;
  ll ans = all-resa-resb-1;
  ans %= MOD;
  if(ans < 0)ans += MOD;
  //if(ans < 0) ans += MOD;
  //cout <<  resa << " " << resb << endl;
  //cout  << nijou << endl;
  cout << ans << endl;
}


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

using namespace std;

using ll = long long;

const int MAX_N = (int) 1e5;
int n;
int bit[MAX_N + 1];
int a[MAX_N];

int sum(int i) {
    int s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(int i, int x) {
    while (i <= n) {
        bit[i] += x;
        i += i & -i;
    }
}

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

    int q;
    cin >> n >> q;
    n++;

    for (int i = 0; i < q; ++i) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            add(x, y);
        } else {
            cout << sum(y) - sum(x - 1) << '\n';
        }
    }

    return 0;
}



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

int main() {
    string s;
    cin >> s;
    string t = "";
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'A') t = t + "A";
        else if (s.substr(i, 2) == "BC") {
                t = t + "D"; i++;
        }
        else t = t + s[i];
    }
    
    long long ans = 0;
    int a = 0;
    for (auto c : t) {
        if (c == 'A') a++;
        else if (c == 'D') ans += a; 
        else a = 0;
    }
    
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  for (int x = 1; x <= 100000; x++) {
    if (x * 108 / 100 == N) {
      cout << x << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    double a, b, d, e;
    int c;
    scanf("%lf%lf", &a, &b);
    e = (a + b) / 2;
    c = (a + b) / 2;
    d = e - c;

    if (d >= 0.5)
    {
        c = c + 1;
        printf("%d", c);
    }
    else
    {
        printf("%d", c);
    }
}

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

int main(){
  vector<int> A(3);
  rep(i,3) cin >> A[i];
  sort(A.begin(),A.end());
  cout << A[0]*A[1]/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int a,b,c,d,n;
	cin>>a>>b>>c>>d>>n;
	int minv=min(min(a*4,b*2),c);
	if(minv*2<=d){
		cout<<minv*n;
	}
	else{
		cout<<(n%2)*minv+n/2*d;
	}
	return 0;
}


Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void) {
    int m=0, f=0, r=0, s=0;
    while (1) {
        scanf("%d%d%d", &m, &f, &r);
        if (m == -1 && f == -1 && r == -1)break;
        if (m == -1 || f == -1) {
            printf("F\n");
            continue;
        }
        if (m == -1)m = 0;
        if (f == -1)f = 0;
        if (r == -1)r = 0;
        s = m + f;
        if (s >= 80)printf("A\n");
        if (65 <= s && s < 80)printf("B\n");
        if (50 <= s && s < 65)printf("C\n");
        if (30 <= s && s < 50) {
            if (r >= 50)printf("C\n");
            else printf("D\n");
        }
        if (s < 30)printf("F\n");
    }
    return 0;
}


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

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

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

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}

void type2(string S){
    
}


int main()
{
    string S;
    ll n;

    cin >> S ;

    n=S.size();

    if(n%2==1){
        cout << "No" << endl;
        return 0;
    }

    for(int i=0;i<n;i++){
        if(i%2==0&&S[i]!='h'){
            cout << "No" << endl;
            return 0;
        }else if(i%2==1&&S[i]!='i'){
            cout << "No" << endl;
            return 0;
        }
    }

    cout <<"Yes"<< endl;



 
    return 0;

}

Measured memory_bytes: 256
//
//  main.cpp
//  project for C++
//
//  Created by 伊藤博隆 on 2020/04/17.
//  Copyright © 2020 伊藤博隆. All rights reserved.
//

#include <iostream>
#include<set>
#include<string>
#include <sstream>
#include <algorithm>
#include <math.h>

using namespace std;
int a,b,k;





int main(){
    bool ans = false;
    cin >> k >> a >> b;
   
        for(int i=a; i<=b; i++){
            if ( (i >= k) && ((i % k) == 0) ){
                

                ans = true;
                
                break;
            }else{
                ans= false;
               
            }


        }
    
    if(ans == true){cout << "OK" << endl;}
    if(ans == false){cout << "NG" << endl;}
    
    return 0;
}




Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define INF 1e17;
#define MAX_V 100000
typedef long long ll;
typedef pair<int, int> P;

//int cost[MAX_V][MAX_V];
vector<ll> d1, d2;
//bool used[MAX_V];
ll V;
struct edge {
	ll to, cost;
};
vector<edge> G1[MAX_V], G2[MAX_V];

ll m, s, t;
const int MAX_M = 1e5;
ll u[MAX_M], v[MAX_M], a[MAX_M], b[MAX_M];



// O(ElogV)
vector<ll> dijkstra(ll s, vector<edge> G[]) {
	vector<ll> d(V);
	rep(i, 0, V) d[i] = INF;
	d[s] = 0;
	priority_queue<pair<ll, ll>, vector<pair<ll, ll> >, greater<pair<ll, ll> > > q;
	q.push(make_pair(0, s)); // distance, index)

	while(!q.empty()) {
		pair<ll, ll> p = q.top();
		q.pop();
		ll v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				q.push(pair<ll, ll>(d[e.to], e.to));
			}
		}
	}
	return d;
}

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

	cin >> V >> m >> s >> t;
	rep(i, 0, m) {
		cin >> u[i] >> v[i] >> a[i] >> b[i];
		u[i]--; v[i]--;
		edge e1, e2, e3, e4;
		e1.to = v[i], e1.cost = a[i];
		G1[u[i]].push_back(e1);
		e2.to = u[i], e2.cost = a[i];
		G1[v[i]].push_back(e2);
		e3.to = v[i], e3.cost = b[i];
		G2[u[i]].push_back(e3);
		e4.to = u[i], e4.cost = b[i];
		G2[v[i]].push_back(e4);
	}

	d1 = dijkstra(--s, G1);
	d2 = dijkstra(--t, G2);

	ll max_val = 0;
	ll rsl[V];
	for(int i = V - 1; i >= 0; i--) {
		ll val = 1e15 - (d1[i] + d2[i]);
		max_val = max(max_val, val);
		rsl[i] = max_val;
	}

	rep(i, 0, V) cout << rsl[i] << endl;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   int t;
   cin>>t;
   int arr[t];
   for(int i=0;i<t;i++)
    cin>>arr[i];
   long long int sum=0;
   for(int i=0;i<t;i++)
   sum=sum+arr[i];
 
   int q;
   cin>>q;
   while(q--)
   {
      int a,b;
      cin>>a>>b;
      cout<<sum+b-arr[a-1]<<endl;
      
   }
   
    return 0;
}








Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

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


int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

ll dp[110][4][4][4] = { 0 };
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    dp[0][0][0][0] = 1;
    //T=0,A=1,G=2,C=3
    for (int i = 0; i < N; ++i) {
        for (int a = 0; a < 4; ++a) {
            for (int b = 0; b < 4; ++b) {
                for (int c = 0; c < 4; ++c) {
                    for (int d = 0; d < 4; ++d) {
                        if (b == 1 && c == 2 && d == 3) continue;
                        if (b == 2 && c == 1 && d == 3) continue;
                        if (b == 1 && c == 3 && d == 2) continue;
                        if (a == 1 && c == 2 && d == 3) continue;
                        if (a == 1 && b == 2 && d == 3) continue;
                        dp[i + 1][b][c][d] = (dp[i + 1][b][c][d] + dp[i][a][b][c]) % MOD;
                    }
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 4; ++j) {
            for (int k = 0; k < 4; ++k) {
                ans =(ans + dp[N][i][j][k])%MOD;
            }
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  unsigned int X, a, b, c, temp, ans;
  int count = 0;
  int A[200];
  cin >> a >> b >> c >> X;
  // a = 30, b = 40, c = 50, X = 6000;
  for(int i=0; i<a+1; i++){
    for(int j=0; j<b+1; j++){
      for(int k=0; k<c+1; k++){
        if(500*i+100*j+50*k == X){
          count++;
        }
      }
    }
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    char S[3];
    int answer = 700;
    cin >> S;
    for(int i = 0; i < 3; i++){
        if(S[i] == 'o') answer+= 100;
    }
    cout << answer << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
  int main(){
    int x,y,z;
    scanf("%d %d",&x,&y);
    if(x<y){
      while(x!=0){
        z=x;
        x=y%x;
        y=z;
      }
      printf("%d\n",y);
    }

    else{
      while(y!=0){
        z=y;
        y=x%y;
        x=z;
      }
      printf("%d\n",x);
    }

    return 0;
  }



Measured memory_bytes: 2140
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int idx(int n){
    if(n<0) return 20-n;
    else return n;
}

bool isArive(vector<int>& w, int r, int time){
    for(int i=-r+1; i<r; i++){
        if(sqrt(r*r-i*i)-r+time/1e5 > w[idx(i)]){
            return false;
        }
    }
    return true;
}

int bin_search(vector<int>& w, int r, int imin, int imax){
    if(imax <= imin){
        return imax;
    }else{
        int imid = (imax+imin)/2;
        if(isArive(w, r, imid)){
            return bin_search(w, r, imid+1, imax);
        }else{
            return bin_search(w, r, imin, imid-1);
        }
    }
}


int main(){
    while(1){
        int r,n;
        cin >> r >> n;
        if(r==0) break;

        vector<int> wall(41, 0); //(int coordinates)
        for(int i=0; i<n; i++){
            int xl,xr,h;
            cin >> xl >> xr >> h;
            for(int j=xl; j<xr; j++){
                wall[idx(j)] = max(wall[idx(j)], h);
            }
        }
        for(int i=19; i>=-19; i--){
            wall[idx(i)] = min(wall[idx(i-1)], wall[idx(i)]);
        }

        int dmsec = bin_search(wall, r, 0, 40*1e5);
        cout << fixed;
        cout << setprecision(5);
        cout << dmsec/1e5 << endl;
    }
    return 0;
}

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


int main() {
	float n, x;
	int x1,x2;
	cin >> n;
	x = n / 1.08;
	x1 = ceil(x);
	x2 = floor(x);

	if (n == floor(x1*1.08)) {
		cout << x1 << endl;
    	return 0;
	}
	else if (n == floor(x2*1.08)) {
		cout << x2 << endl;
      	return 0;
	}
	else {
		cout << ":(" << endl;
      	return 0;
	}
}

Measured memory_bytes: 256
import numpy as np
n,k = map(int,input().split())
#li = []
#append = li.append
#for i in range(n):
#    append(i+1)
#print(li)
alist = []
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in a:
        alist.append(j)

alist = set(alist)
print(n -len(alist))


Measured memory_bytes: 26996
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意

int main(){
  int a; cin>>a;
  //string s; cin>>s;
  cout<<a+a*a+a*a*a <<endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

/*
Range Sum Query by FenwickTree(Binary Indexed Tree)

total number: n
queries:
    1. add(i, val): bit[i] += val 
    2. sum(n): sum(bit[0] + ... + bit[n-1])
time complexity: O(log n)
space complexity: O(N)

Self-balancing binary search tree or Segment Tree can do the same, it takes longer to program and complexity also increases.

Thanks: http://hos.ac/slides/20140319_bit.pdf
    
used in ARC031 C, indeednow finalB E, DSL2B(AOJ), ARC033 C, yukicoder No.59
*/

template<typename T> struct RangeSumQuery {
  int N;
  vector<T> dat;

  RangeSumQuery(int N) : N(N) {
    assert(N > 0);
    dat.resize(N, 0);
  }

  void add(int k, T val) {
    assert(0 <= k && k < N);
    for (int x = k; x < N; x |= x + 1) {
      dat[x] += val;
    }
  }

  // [0, k)
  T sum(int k) {
    assert(k >= 0);
    T ret = 0;
    for (int x = k - 1; x >= 0; x = (x & (x + 1)) - 1) {
      ret += dat[x];
    }
    return ret;
  }
  // [l, r)
  T sum(int l, int r) {
    assert(0 <= l && l <= r && r <= N);
    return sum(r) - sum(l);
  }

  T index(int k) {
    assert(0 <= k && k < N);
    return sum(k+1) - sum(k);
  }
};

int A[200010];
P idx[200010];

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  REP(i, N) {
    int a;
    cin >> a;
    idx[i] = P(a, i);
  }
  RangeSumQuery<ll> fwt(N);
  sort(idx, idx + N);

  ll ans = 0;
  REP(i, N) {
    P p = idx[i];
    ans += i - fwt.sum(p.second);
    fwt.add(p.second, 1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4164
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')

INF = 10**9 + 7


def main():
    N = in_n()
    arms = [tuple()] * N

    for i in range(N):
        x, l = in_nn()
        arms[i] = (x - l, x + l)

    arms.sort(key=lambda x: x[1])
    # print(arms)

    r_max = -INF
    count = 0
    for i in range(N):
        l, r = arms[i]
        if r_max <= l:
            r_max = r
            count += 1

    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23900
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = true;
}  // namespace mydef
using namespace mydef;
#define pb push_back
//#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N, P, cnt[5];

void solve() {
}

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

    cin >> N >> P;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        cnt[a % 2]++;
    }

    cout << (1ll << cnt[0]) * ((P == 0 && cnt[1] == 0) ? 1 : (1ll << cnt[1]) / 2) << endl;

    solve();
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(LL i=0; i<(n); i++)
#define FOR(i, m, n) for(LL i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back
#define INF INT_MAX

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i, n)cin >> a[i];

	vector<int> s;
	REP(i, n) {
		if (i % 2 == 0)s.PB(a[i]);
		else s.insert(s.begin(), a[i]);
	}
	if (n % 2 == 1)REVE(s);
	REP(i, n) {
		cout << s[i];
		if (i != n - 1)cout << " ";
		else puts("");
	}
}

Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

vector<int> sieve(int n){
  vector<int> ret;
  bool is_prime[n+1];
  memset(is_prime, true, sizeof(is_prime));
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<n+1;i++){
    if(is_prime[i]){
      ret.push_back(i);
      for(int j=2*i;j<n+1;j+=i)is_prime[j]=false;
    }
  }
  return ret;
}

int main(){
  int n;
  vector<int> prime = sieve(55556);
  cin >> n;
  
  vector<int> ans;
  int i = 0;
  while(n){
    if(prime[i] % 5 == 1){
      ans.pb(prime[i]); 
      n--;
    }
    i++;
  }

  for(int i = 0; i < ans.size();  i++){
    if(i == 0)cout << ans[i];
    else cout << " " << ans[i];
  }
  cout << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std ;
 
#define lli long long int
#define pb push_back 
 
int main ()
{
    ios_base::sync_with_stdio(false) ; 
    cin.tie(NULL) ;

    lli n , a , b ;
    cin >> n >> a >> b ;

    if (a >= n)
    {
        cout << n << endl ;
    }
    else if ((a + b) > n)
    {
        cout << a << endl ;
    }
    else
    {
        lli cof = n / (a + b) ;
        lli res = n % (a + b) ;

        if (res > a)
        {
            res = a ;
        }

        lli ans = (cof * a) + res ;
        
        cout << ans << endl ;
    }
    
    return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

const int V = 100005;
vector<int> to[V*2];
bool visited[V*2];

int xCount = 0;
int yCount = 0;

void dfs(int n) {
    if (!visited[n]) {
        if (V < n) {
            ++xCount;
        } else {
            ++yCount;
        }
        visited[n] = true;
        for (int next: to[n]) {
            dfs(next);
        }
    }
}

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

    rep(i, N) {
        int x, y;
        cin >> x >> y;
        y += V;
        to[x].push_back(y);
        to[y].push_back(x);
    }

    LL ans = 0;
    rep(n, V) {
        if (!visited[n]) {
            xCount = 0;
            yCount = 0;
            dfs(n);
            ans += (LL) xCount * (LL) yCount;
        }
    }

    ans -= N;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = (int)1e6+7;

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

    int a,b;
    cin >> a >> b;
    cout << max(max(a+b,a-b),a*b) << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
//一点更新区間取得
#include<vector>
#include<functional>
#include<limits>
template<typename T>
struct segtree{
	function<T(T,T)>calcfn;
	function<T(T,T)>updatefn;
	int n;
	T defvalue;
	vector<T>dat;
	segtree(int n_=0,T defvalue_=numeric_limits<T>::max(),
		function<T(T,T)>calcfn_=[](T a,T b){return a<b?a:b;},
		function<T(T,T)>updatefn_=[](T a,T b){return b;}
	):defvalue(defvalue_),calcfn(calcfn_),updatefn(updatefn_)
	{
		init(n_);
	};
	void init(int n_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,defvalue);
	}
	void copy(vector<T>v)
	{
		for(int i=0;i<v.size();i++)dat[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--)dat[i]=calcfn(dat[i*2+1],dat[i*2+2]);
	}
	void update(int i,T a)
	{
		i+=n-1;
		dat[i]=updatefn(dat[i],a);
		while(i>0)
		{
			i=(i-1)/2;
			dat[i]=calcfn(dat[2*i+1],dat[2*i+2]);
		}
	}
	T query(int a,int b,int i=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		if(r<=a||b<=l)return defvalue;
		else if(a<=l&&r<=b)return dat[i];
		else
		{
			return calcfn(
				query(a,b,i*2+1,l,(l+r)/2),
				query(a,b,i*2+2,(l+r)/2,r)
			);
		}
	}
};

main()
{
	int n,q;cin>>n>>q;
	segtree<int>rmq(n);
	for(int i=0;i<q;i++)
	{
		int c,x,y;cin>>c>>x>>y;
		if(c)cout<<rmq.query(x,y+1)<<endl;
		else rmq.update(x,y);
	}
}



Measured memory_bytes: 3832
import io, sys, atexit, os

import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations


def li ():
	return list (map (int, input ().split ()))


def num ():
	return map (int, input ().split ())


def nu ():
	return int (input ())


def find_gcd ( x, y ):
	while (y):
		x, y = y, x % y
	return x


mm = 1000000007



def solve ():
	t = 1
	for it in range (t):
		n,q=num()
		s=input()
		ff=[0]*n
		for i in range(n-1):
			if(s[i]=="A" and s[i+1]=="C"):
				ff[i]=1
		for i in range(1,n):
			ff[i]=ff[i-1]+ff[i]
		for i in range(q):
			l,r=num()
			l-=1
			r-=1
			if(s[r]=="A"):
				r-=1
			if(l==0):
				print(ff[r])
			else:
				print(ff[r]-ff[l-1])







if __name__ == "__main__":
	solve ()

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

int main() {
    long long n, k;
    cin >> n >> k;
    if (k % 2 == 0) {
        long long a = n / k;
        long long b = (n + (k/2)) / k;
        cout << a*a*a + b*b*b << endl;
    }
    else {
        long long a = n / k;
        cout << a*a*a << endl;
    }
}

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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	string s;
	cin >> s;
	P(s.substr(0,s.length()-8));
}

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


Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
AB = list(list(map(int, input().split())) for _ in range(N))

dp = [0] * (M + max(a for a, b in AB))

AB.sort(key=lambda x:x[0])
q = []
heapq.heapify(q)
i = 0
ans = 0
for day in range(1, M+1):
  while i < len(AB) and AB[i][0] <= day:
    heapq.heappush(q, -1*AB[i][1])
    i += 1
  if q:
    ans += -1 * heapq.heappop(q)
    
print(ans)

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

int main() {
  int A, B;
  string S;

  cin >> A >> B >> S;

  string regex_a, regex_b;

  for (int i = 0; i < A; i++) {
	  regex_a += "\\d";
  }
  for (int i = 0; i < B; i++) {
	  regex_b += "\\d";
  }

  string regex_in = regex_a + "\\-" + regex_b;

  regex regex(regex_in);

  if (regex_match(S, regex)) {
	  cout << "Yes" << endl;
  } else {
	  cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 384
class segtree():
    def segfunc(x,y):
        return min(x,y)
    #####単位元######
    ide_ele = -1
    n=1
    init_val=[0]*n
    #num:n以上の最小の2のべき乗
    num =2**(n-1).bit_length()
    seg=[ide_ele]*2*num
    
    def __init__(self,INIT_VAL,SEGFUNC,IDE_ELE):
        self.ide_ele=IDE_ELE
        self.init_val=[i for i in INIT_VAL]
        self.segfunc=SEGFUNC
        self.n=len(self.init_val)
        self.num =2**(self.n-1).bit_length()
        self.seg=[self.ide_ele]*2*self.num

        #set_val
        for i in range(self.n):
            self.seg[i+self.num-1]=self.init_val[i]    
        #built
        for i in range(self.num-2,-1,-1) :
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 
        
    def update(self,k,x):
        k += self.num-1
        self.seg[k] = x
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])
        
    def query(self,p,q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res
N,M=map(int,input().split())
Edge=[]
for i in range(M):
    l,r,c=map(int,input().split())
    Edge.append((l-1,r-1,c))
Edge.sort()
INF=10**15
dp=segtree([INF for i in range(N)],min,INF)
dp.update(0,0)
for i in range(M):
    l,r,c=Edge[i]
    dist=dp.query(l,r+1)
    tmp=dp.query(r,r+1)
    dp.update(r,min(tmp,dist+c))
ans=dp.query(N-1,N)
if ans==INF:
    ans=-1
print(ans)


Measured memory_bytes: 106456
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

int main()
{
    int N,M;
    string s[100];
    string t[100];
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> s[i];
    cin >> M;
    for(int i = 0; i < M; ++i) cin >> t[i];
    map<string, int> m;
    for(int i = 0; i < N; ++i){
        m[s[i]] += 1;
    }
    for(int i = 0; i < M; ++i){
        m[t[i]] -= 1;
    }
    int mm = 0;
    for(auto itr = m.begin(); itr != m.end(); ++itr){
        mm = max(mm, itr->second);
    }

    cout << mm << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import collections as cl
import sys


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 main():
    n, k = MI()
    scores = LI()

    score_now = 1

    for i in range(k, n):
        next_score = scores[i] / scores[i - k]
        print("Yes" if next_score > 1 else "No")


main()


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

#define pb push_back
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000

using namespace std;

typedef long long ll;   
typedef double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<int> vi;

ll mod = 1e9 + 7;
vll fac(200005);

ll fast_exp(ll base, ll exp)
  {
    ll res=1;
    while(exp>0)
      {
        if(exp%2==1) res=(res*base)%mod;
        base=(base*base)%mod;
        exp/=2;
      }
    return res%mod;
  }

ll getInverse(ll n)
  {
    return fast_exp(n, mod-2) ;
  }

ll divide(ll a, ll b)
  {
    a=a%mod ;
    b=b%mod ;
    return (a*(getInverse(b)%mod))%mod ;
  }

ll nck(ll n, ll k){
    ll res = fac[n];
    ll denom = (fac[k]*fac[n-k]) % mod;
    res = divide(res, denom);

    return res%mod;
}

int main(){

    ll n, k;

    fac[0] = 1;
    for(ll i=1;i<200005;i++) fac[i] = (i*fac[i-1])%mod;

    cin>>n>>k;

    ll ans = 0;
    
    ll mini = 0, maxi = 0;

    for(int i=0;i<k-1;i++) mini += i, maxi += n-i % mod;
    int pos = k-1;
    for(int i=k;i<=n+1;i++){
        mini += pos % mod;
        maxi += n - pos % mod; pos++;
        ans = (ans + (maxi-mini+1)%mod )%mod;
    }

    cout<<ans<<endl;


    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}


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

int main() {
    static int N, n[100001], a[3] = {1, 6, 9};
    fill(n, n + 100001, 100001);
    cin >> N;
    n[0] = 0;
    for(int i = 1; i <= N; ++i) {
        for(int j = 0; j < 3; ++j) {
            if(i - a[j] >= 0)
                n[i] = min(n[i], n[i - a[j]] + 1);
            if(j != 0) {
                int p = a[j];
                while(i - p >= 0) {
                    n[i] = min(n[i], n[i - p] + 1);
                    p *= a[j];
                }
            }
        }
    }
    cout << n[N] << endl;
    return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    a, b = map(int, input().split())
    
    ans = 0
    for i in range(a, b+1):
        s = str(i)
        flg = True
        for j in range(len(s)):
            tmp = (j * -1) -1
            if s[j] != s[tmp]:
                flg = False
        if flg == True:
            ans += 1
    
    print(ans)
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 41836
#include <stdio.h>

int main( void ) 
{
	int m,f,r;
	
	while( EOF != scanf( "%d%d%d", &m, &f, &r ) ) {
		if( -1==m && -1==f && -1==r ) { break; }		

		if( -1==m || -1==f ) {
			printf( "F\n" );
		} else {
			if( 80<=(m+f) ) {
				printf( "A\n" );
			} else {
				if( 65<=(m+f) ) {
					printf( "B\n" );
				} else {
					if( 50<=(m+f) ) {
						printf( "C\n" );
					} else {
						if( 30<=(m+f) ) {
							if( 50<=r ) {
								printf( "C\n" );
							} else {
								printf( "D\n" );
							}
						} else {
							printf( "F\n" );
						}						
					}
				}
			}
		}
	}


	return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;
    
    cin >> n;
    for ( int i = 0; i < n; i++ ) cin >> R[i];
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for ( int i = 1; i < n; i++ ) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 3884
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int k = sc.nextInt();

    double result = 0;
    int now = 0;

    for (int i = 1; i <= n; i++) {

      now = i;
      int count = 0;

      while (now < k) {
        now *= 2;
        count++;
      }

      result += Math.pow(0.5, count) / n;
    }

    System.out.println(result);
  }
}


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

int main(){
	string s; cin>>s;
	
	int all=s.size();
	int a=1;
	for(int i=0; i<all; i++){
		if(s[i]=='A'){
			a=i;
			break;
		}
	}
	int z=all;
	for(int i=all; i>0; i--){
		if(s[i]=='Z'){
			z=all-1-i;
			break;
		}
	}
	cout<<all-a-z<<endl;
}

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

using namespace std;

using ll = long long;

const ll NMAX = 10001;
const ll DMAX = 101;
const ll MOD = 1e9 + 7;

ll dp[NMAX][DMAX][2] = {0};

int main()
{
    string k;
    cin>>k;
    ll D, n, num;
    cin>>D;
    n = k.length();
    dp[0][0][1] = 1;
    for(ll i = 0 ; i < n ; i++){
        num = k[i] - '0';
        for(ll j = 0 ; j < D ; j++){
            for(ll p = 0 ; p < 10 ; p++){
                dp[i + 1][(j + p) % D][0] += dp[i][j][0];
                dp[i + 1][j][0] %= MOD;
            }
            dp[i + 1][(j + num) % D][1] += dp[i][j][1] % MOD;
            for(ll p = 0 ; p < num ; p++){
                dp[i + 1][(j + p) % D][0] += dp[i][j][1];
                dp[i + 1][j][0] %= MOD;
            }
        }
    }

    cout<< (dp[n][0][0] + dp[n][0][1] - 1 + MOD) % MOD;
    return 0;
}


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

using namespace std;

using int64 = long long;

int main() {
  int N;
  vector< int > tt;
  for(int k = 0; k < 2; k++) {
    cin >> N;
    for(int i = 0; i < N; i++) {
      int h, m;
      cin >> h >> m;
      tt.emplace_back(h * 60 + m);
    }
  }
  sort(begin(tt), end(tt));
  tt.erase(unique(begin(tt), end(tt)), end(tt));

  for(int i = 0; i < tt.size(); i++) {
    if(i) cout << " ";
    printf("%d:%02d", tt[i] / 60, tt[i] % 60);
  }
  cout << endl;
}



Measured memory_bytes: 3280
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    String T=gs();

	    System.out.println(T.replaceAll("\\?", "D"));
	}

	public static double f(double r, double n, double m, double i) {
		double a = 0;
		double b=0;
		if(0<i&&i<n) {
			a=Math.abs(r-((2*r/n)*i));
			a= Math.sqrt(Math.pow(r, 2) - Math.pow(a, 2));
		}
		if(0<i-m&&i-m<n) {
			b=Math.abs(r-(2*r*(i-m)/n));
			b=Math.sqrt(Math.pow(r, 2) - Math.pow(b, 2));
		}
		return 2* Math.max(a, b);
	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 53548
n,m=map(int,input().split())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([a,b])
l.sort()
x,ans=0,0
for i,j in l:
    if x+j<m:
        ans+=i*j
        x+=j
    else:
        ans+=i*(m-x)
        break
print(ans)

Measured memory_bytes: 20064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ms(a,x) memset(a,x,sizeof(a))
const int Max=1000000+10;
int main()
{
    int n,m;
    cin>>n>>m;
    cout<<(n+m/2)<<endl;
    return 0;
}


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

void solve(long long N, std::string S, long long K)
{
    char c = S[K - 1];

    for (int i = 0; i < N; i++)
    {
        if (S[i] == c)
        {
            cout << S[i];
        }
        else
        {
            cout << "*";
        }
    }
    cout << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::string S;
    std::cin >> S;
    long long K;
    scanf("%lld", &K);
    solve(N, S, K);
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N;
	int bt = 22;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	long long int x = 0;
	for (auto i : v)x ^= i;
	x ^= v[0] ^ v[1];
	long long int y = v[0] + v[1];
	vector<long long int>up;
	vector<long long int>eq;
	for (int i = 0; i < 1 << bt; i++) {
		if (y < i)continue;
		long long int num = y - i;
		num &= (1 << bt) - 1;
		if (((i ^ num)) == (x&((1 << bt) - 1))) {
			if (num + i >= 1 << bt)up.push_back(i);
			else eq.push_back(i);
		}
	}
	long long int m = -1;
	for (long long int j = 0; j < 1 << bt; j++) {
		if ((y >> bt) < j)continue;
		long long int num = (y >> bt) - j;
		long long int box = (num^j) << bt;
		if ((box >> bt) == (x >> bt)) {
			auto it = upper_bound(eq.begin(), eq.end(), v[0] - (j << bt));
			if (it != eq.begin()) {
				--it;
				m = max(m, (j << bt) + *it);
			}
		}
	}
	for (long long int j = 0; j < 1 << bt; j++) {
		if ((y >> bt) - 1 < j)continue;
		long long int num = (y >> bt) - 1 - j;
		long long int box = (num^j) << bt;
		if ((box >> bt) == (x >> bt)) {
			auto it = upper_bound(up.begin(), up.end(), v[0] - (j << bt));
			if (it != up.begin()) {
				--it;
				m = max(m, (j << bt) + *it);
			}
		}
	}
	if (m == -1 || m == 0)m = v[0] + 1;
	cout << v[0] - m << endl;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
int res[100001];
using namespace std;

void fun2(int w,int wt[],int val[],int n)
{
    long int dp[n+1][w+1];

    for(int i=0;i<n+1;i++)
    {
        for(int j=0;j<w+1;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
        }
    }

    for(int i=1;i<n+1;i++)
    {
        for(int j=1;j<w+1;j++)
        {
            if(wt[i-1]<=j)
            {
                dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
            }
            else
                dp[i][j]=dp[i-1][j];
        }
    }

    cout<<dp[n][w];
}

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

    int n,w;
    cin>>n>>w;

    int val[n],wt[n];

    for(int i=0;i<n;i++)
        cin>>wt[i]>>val[i];


    fun2(w,wt,val,n);
    return 0;
}


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

int a[100];

int main(){
    int n;cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];
    int ans=1e9;
    for(int b=-100;b<=100;b++){
        int cost=0;
        for(int i=0;i<n;i++){
            cost+=(a[i]-b)*(a[i]-b);
        }
        ans=min(ans,cost);
    }
    cout << ans << endl;
    return 0;
}

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

int selectionsort (int a[],int n){
    int ans = 0;
    for (int i = 0; i <  n ; ++i) {
        int m = i;
        for (int j = i+1 ; j < n ; ++j) {
            if(a[j]<a[m]) m=j;
        }
            if(m!=i)
            ans++;
        swap(a[m],a[i]);
    }
    return ans;
}

int main(){
    int a[100],n,count;
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        cin >> a[i];
    }
    count = selectionsort(a,n);

    for (int i = 0; i < n-1 ; ++i) {
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
using namespace std;
int n,m;
char a[505][505],b[505][505],c[505][505];
int main()
{
	scanf("%d%d",&n,&m);for(int i=1;i<=n;++i) scanf("%s",a[i]+1);
	for(int i=1;i<=n;++i) b[i][1]='#';
	for(int i=1;i<=n;i+=2) for(int j=1;j<m;++j) b[i][j]='#';
	for(int i=1;i<=n;++i) c[i][m]='#';
	for(int i=2;i<=n;i+=2) for(int j=2;j<=m;++j) c[i][j]='#';
	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) if(a[i][j]=='#') if(i&1) c[i][j]='#';else b[i][j]='#';
	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) {if(b[i][j]!='#') b[i][j]='.';if(c[i][j]!='#') c[i][j]='.';}
	for(int i=1;i<=n;++i) printf("%s\n",b[i]+1);putchar('\n');for(int i=1;i<=n;++i) printf("%s\n",c[i]+1);
	return 0;
}

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

#define endl '\n'

using namespace std;
using ll = long long int;

vector<int> factors(1e6 + 10, 0);

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    vector<int> values(n);
    int gcd = 0;
    for(auto &v: values) {
        cin >> v;
        gcd = __gcd(gcd, v);
    }

    for (int p=0; p<n; p++){
        int num = values[p];

        for (int i=1; i*i <=num; i++){
            if (num % i == 0){
                factors[i]++;
                factors[num / i]++;

                if (i == num/i) factors[i]--;

                if (i != 1 and factors[i] > 1){

                    if (gcd == 1) puts("setwise coprime");
                    else puts("not coprime");

                    return 0;
                }

                if (num / i != 1 and factors[num / i] > 1){
                    
                    if (gcd == 1) puts("setwise coprime");
                    else puts("not coprime");

                    return 0;
                }
            }

        }
    }

    puts("pairwise coprime");

    return 0;
}

Measured memory_bytes: 11024