akhauriyash/Code-Regression huggingface dataset:
a,b,k = map(int,input().split())
t = range(a,b+1)
if k > len(t):
  for i in t:
    print(i)
else:
  ls = []
  for i in range(k):
    ls.append(t[i])
  for i in range(k):
    ls.append(t[-i -1])
  ls = sorted(set(ls))
  for s in ls:
    print(s)

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

Int calc(Int x){
  string s=to_string(x);
  Int res=0;
  for(Int i=0;i<(Int)s.size();i++) res+=s[i]-'0';
  return res;
}

signed main(){
  Int k;
  cin>>k;
  Int ans=calc(k);
  Int INF=1LL<<55;
  vector<Int> dist((k+100)*2,INF);
  using P=pair<Int,Int>;
  priority_queue<P,vector<P>,greater<P> > q;
  dist[k]=0;
  q.push(P(dist[k],k));
  while(!q.empty()){
    P p=q.top();q.pop();
    Int v=p.second,d=p.first;
    if(dist[v]<d) continue;
    ans=min(ans,dist[v]+calc(v));
    //cout<<v<<":"<<d<<endl;
    for(Int i=0;i<10;i++){
      Int t=(v+k*i);
      Int c=t%10,u=t/10;
      assert(u<(k+100)*2);
      if(dist[v]+c>=dist[u]) continue;
      //cout<<u<<":::"<<c<<endl;
      dist[u]=dist[v]+c;
      q.push(P(dist[u],u));
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC
using namespace std;


template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}

const int N=5e5+10;

template<typename T>
struct Fenwick{
    vector<T> tree;
    Fenwick(int n){
        tree.resize(n);
    }

    T query(int i){
        int sum=0;
        while(i){
           sum+=tree[i];
           i-=i&(-i);
       }  
       return sum;
    }
    void update(int i,int n,T val){
       while(i<=n){
          tree[i]+=val;
          i+=i&(-i);
       }
    }
};


int solve(){
 	int n;cin>>n;
 	vector<char>v(n+1);
 	int cnt=0;
 	rep(i,1,n+1){
 		cin>>v[i];
 		if(v[i]=='R')cnt++;
 	}
 	int ans=cnt;
 	rep(i,1,cnt+1){
 		if(v[i]=='R')ans--;
 	}cout<<ans<<endl;
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

void solve(long long N, long long x, vector<long long> a){
	ll ans = 1e15;
	ll list[2010] = {};
	fill(list,list+2010,1e15);

	FOR(k,0,N){
		ll sum = k*x;
		
		REP(i,N){			
			int d = (i - k + N) % N;
			list[i] = min(list[i],a[d]);
			sum += list[i];
		}

		ans = min(ans,sum);
	}

	cout << ans << endl;
}



int main(){	
	ios::sync_with_stdio(false);
	long long N;
	long long x;
	cin >> N;
	vector<long long> a(N-1+1);
	cin >> x;
	for(int i = 0 ; i <= N-1 ; i++){
		cin >> a[i];
	}
	solve(N, x, a);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  char out;
  int max_alp = 'Z' - 'A';
  int check;
  for(int i = 0; i < s.length(); ++i){
    check = s[i] - 'A' + n;
    check = check > max_alp ? check - max_alp - 1 : check; 
    out = check + 'A';
    cout << out;
  }
  cout << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int A, B; cin >> A >> B;
    if(A + B >= 10) cout << "error" << endl;
    else cout << A + B << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(void){
    char ca[3];
    char cb[3];
    cin >> ca >> cb;
    //cout << ca[0] << ca[1] << ca[2] << endl;
    //cout << cb[0] << cb[1] << cb[2] << endl;
    if (ca[2] == cb[0] && ca[1] == cb[1] && ca[0] == cb[2]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    string S;
	cin >> S;
    sort(all(S));
    if(S[0] == S[1] && S[1] != S[2] && S[2] == S[3])
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 384
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    c = 1
    i = 7
    while True:
        if i % K == 0:
            print(c)
            exit()
        i = i % K * 10 + 7
        c+=1

Measured memory_bytes: 9172
//Mir_123
/* Once in your life, try something.
   Work hard at something.
   Try to change.
   Nothing bad can happen
                        -------Jack Ma */
#include<bits/stdc++.h>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<iterator>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define bin binary_search
bool cmp_sec(pair<ll,ll> &a,pair<ll,ll> &b)
{
  if(a.second!=b.second)
    return a.second<b.second;
  return a.first<b.first;
}
//Use set if your want your array to be auto sorted
//sort takes log(N) time
int main(void)
{
  ll n,W;
  cin>>n>>W;
  vector<ll>w(n),v(n);
  ll i,j;
  for(i=0;i<n;i++) cin>>w[i]>>v[i];
  vector< vector<ll> >dp(n,vector<ll>(W+1,0));
  dp[0][w[0]]=v[0];
  for(i=1;i<n;i++)
  {
    for(j=W;j>0;j--)
    {
      dp[i][j]=dp[i-1][j];
      if(j+w[i]<=W&&dp[i][j]>0)
        dp[i][j+w[i]]=max(dp[i][j+w[i]],dp[i][j]+v[i]);
    }
    dp[i][w[i]]=max(dp[i-1][w[i]],v[i]);
  }
  sort(dp[n-1].begin(),dp[n-1].end());
  cout<<dp[n-1][W];
  return 0;
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'
 
int main()
{
    fastio;
    int d,t,s;
    cin>>d>>t>>s;

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

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int n,d;
cin>>n>>d;
vector<vi>v(n,vi(d));
for(int i=0;i<n;i++)
{
	for(int j=0;j<d;j++)
	cin>>v[i][j];
}
int cnt=0;
for(int i=0;i<n;i++)
{
	for(int j=i+1;j<n;j++)
	{
		int ans=0;
	for(int k=0;k<d;k++)
	{
		ans+=(v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
	}
	int  sq=sqrt(ans);
	if(sq*sq==ans)
	cnt++;
	}
}
cout<<cnt;
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
solve();
cout<<endl;
}
}


Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;

string ERROR_SPELL = "zzzzzz";

// ??????????????????
vector<vector<string> > dijk(pair<int, int>  s, vector<vector<vector<pair<string, pair<int, int> > > > > adjlist){
  int v = adjlist.size();
  int t = adjlist[0].size();
  priority_queue<pair<string, pair<int, int> >,
                 vector<pair<string, pair<int, int> > >,
                 greater<pair<string, pair<int, int> > > > wait;
  vector<vector<string> > result(v, vector<string>(t, ERROR_SPELL));

  // ??????????????°????????????
  result[s.first][s.second] = "";
  wait.push(make_pair("", s));

  // ????????????????????¬???
  while (!wait.empty()) {
    // ??????
    pair<int, int> nowpoint = wait.top().second;
    string nowcost = wait.top().first;
    wait.pop();
    // ????????????????????¢?´¢??????????????????????????§????????´?????????????£???°???
    if (result[nowpoint.first][nowpoint.second] < nowcost) { continue; }
    
    // ?????????????????¨??£??\??????????????????????????????????????????
    for (size_t i = 0; i < adjlist[nowpoint.first][nowpoint.second].size(); i++) {
      pair<int, int> nextpoint = adjlist[nowpoint.first][nowpoint.second][i].second;
      string nextcost = nowcost + adjlist[nowpoint.first][nowpoint.second][i].first;
      // ??¢?´¢????????????????????°?????§???????????§????????°??????????????´??°??????????????????????????\??????????´?
      if(result[nextpoint.first][nextpoint.second] > nextcost){
        result[nextpoint.first][nextpoint.second] = nextcost;
        wait.push(make_pair(nextcost, nextpoint));
      }
    }
  }

  return result; // ?????????: ?????????
}


int main(void){
  for(int i = 0; i < 7; i++){ ERROR_SPELL += ERROR_SPELL; }
  
  while(true){
    int n, a, s, g;
    cin >> n >> a >> s >> g;
    if(n == 0 && a == 0 && s == 0 && g == 0){ break; }
    
    vector<vector<vector<pair<string, pair<int, int> > > > >
      adj(n,
          vector<vector<pair<string, pair<int, int> > > >((n + 2) * 12));
    
    // ??\??????????????????
    for(int i = 0; i < a; i++){
      int x, y;
      string lab;
      cin >> x >> y >> lab;
      for(int j = 0; j < (n + 1) * 12; j++)
        adj[x][j].push_back(make_pair(lab, make_pair(y, j + lab.length())));
    }

    vector<vector<string> > result = dijk(make_pair(s, 0), adj);
    
    string ans = ERROR_SPELL, over = ERROR_SPELL;
    for(int i = 0; i <= n * 6; i++){ ans = min(ans, result[g][i]); }
    for(int i = n * 6 + 1; i < (int)result[g].size(); i++){ over = min(over, result[g][i]); }
    if(ans >= ERROR_SPELL || ans >= over){ cout << "NO" << endl; }
    else{ cout << ans << endl; }
  }
  
  return 0;
}

Measured memory_bytes: 20080
#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;


void white_cells()
{
  int H, W, h, w;
  cin >> H >> W >> h >> w;

  cout << (H * W) - (h * W) - (H * w) + (h * w) << "\n";
}


void double_helix()
{
  char b;
  cin >> b;

  if (b == 'A') cout << "T\n";
  else if (b == 'T') cout << "A\n";
  else if (b == 'C') cout << "G\n";
  else  cout << "C\n";

}


void five_antennas()
{
  vector<int> a(5);
  for (int i = 0; i < 5; ++i) cin >> a[i];
  int k;
  cin >> k;

  if (a[4] - a[0] > k)
  {
    cout << ":(\n";
    return;
  }
  cout << "Yay!\n";

}

void buttons()
{
  int a, b;
  cin >> a >> b;

  int v_max = 0;
  for (int i = 0; i < 2; ++i) {
    if (a > b) {
      v_max += a;
      --a;
    }
    else
    {
      v_max += b;
      --b;
    }
  }
  cout << v_max << "\n";
}


void biscuit_generator()
{
  int a, b, t;
  cin >> a >> b >> t;

  cout << t / a * b << "\n";
}


void changing_a_character()
{
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  s[k - 1] += 32;
  cout << s <<"\n";
}


void ferris_wheel()
{
  int a, b;
  cin >> a >> b;

  if (a >= 13) cout << b << "\n";
  else if(a >= 6) cout << b / 2 << "\n";
  else cout << 0 << "\n";
}


void apple_pie()
{
  int a, p;
  cin >> a >> p;

  p += 3 * a;

  cout << p / 2 << "\n";
}


void airplane()
{
  vector<int> a(3);
  for (int i = 0; i < 3; ++i) cin >> a[i];

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

  cout << a[0] + a[1] << "\n";
}


void rounding()
{
  int x, a;
  cin >> x >> a;

  if (x < a) cout << 0 << "\n";
  else cout << 10 << "\n";
}




void can_you_solve_this()
{
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for (int i = 0; i < m; ++i) cin >> b[i];
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) cin >> a[i][j];

  int cnt = 0;
  for (int i = 0; i < n; ++i)
  {
    int point = 0;
    for (int j = 0; j < m; ++j) point += a[i][j] * b[j];

    if (point > -c) ++cnt;
  }
  cout << cnt << "\n";
} 


int main()
{
  //white_cells();
  //double_helix();
  //five_antennas();
  //buttons();
  //biscuit_generator();
  //changing_a_character();
  //ferris_wheel();
  //apple_pie();
  //airplane();
  //rounding();


  can_you_solve_this();

}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Scanner;
public class Main{
	public static void main(String[] args)throws Exception{
		new Main().solve();
		//		new Q0118().make_sample();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		while(true){
			int h=sc.nextInt();
			int w=sc.nextInt();
			if(h==0&&w==0)break;
			char[][] table=new char[h][w];
			checked=new boolean[h][w];
			for(int i=0;i<h;i++){
				table[i]=sc.next().toCharArray();
				//#,*,@
			}
			int count=0;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(!checked[i][j]){
						dfs(table,j,i,w,h);
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
	int[] dx={1,-1,0,0};
	int[] dy={0,0,-1,1};
	boolean[][] checked;
	void dfs(char[][] table,int x,int y,int w,int h){
		ArrayDeque<State>dq=new ArrayDeque<State>(w*h);
		dq.addFirst(new State(x,y));
		while(!dq.isEmpty()){
			State s=dq.pollFirst();
			for(int i=0;i<4;i++){
				int nextx=s.x+dx[i];
				int nexty=s.y+dy[i];
				if(nextx<0||nextx>w-1||nexty<0||nexty>h-1)continue;
				if(table[s.y][s.x]==table[nexty][nextx]&&!checked[nexty][nextx]){
					checked[nexty][nextx]=true;
					dq.addFirst(new State(nextx,nexty));
				}
			}
		}
	}
	class State{
		int x;
		int y;
		State(int x,int y){
			this.x=x;
			this.y=y;
		}
	}
	void make_sample(){
		System.out.println("100 100");
		for(int i=0;i<100;i++){
			for(int j=0;j<100;j++){
				int a=(int)(Math.random()*3);
				switch(a){
				case 0:
					System.out.print("@");
					break;
				case 1:
					System.out.print("*");
					break;
				case 2:
					System.out.print("#");
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 94176
#include <stdio.h>
int main(void){
    int a,b,c,d;
    scanf("%d %d %d",&a,&b,&c);
    if(a > b){
        d = a;
        a = b;
        b = d;
    }
    if(b > c){
        d = b;
        b = c;
        c = d;
    }
    if(a > b){
        d = a;
        a = b;
        b = d;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 2072
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

int main()
{
    int W, H, x, y;
    cin >> W >> H >> x >> y;

    double area;
    area = (double(W) * double(H)) / 2;

    string way = "0";
    if (x + x == W && y + y == H)
    {
        way = "1";
    }

    cout << area << " " << way << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
class UnionFind{//UnionFind木
 private:
    vector<int> Parent,es;
    vector<ll> diff_weight;
 public:
    UnionFind(int N){
        es.resize(N,0);
        Parent.resize(N,-1);
        diff_weight.resize(N,0LL);
    }

    int root(int A){
        if(Parent[A]<0) return A;
        else{ 
            int r = root(Parent[A]);
            diff_weight[A] += diff_weight[Parent[A]]; // 累積和をとる
            return Parent[A]=r;
        }
    }
    bool issame(int A,int B){
        return root(A)==root(B);
    }
    ll weight(int x) {
        root(x); // 経路圧縮
        return diff_weight[x];
    }
    ll diff(int x, int y) {
        return weight(y) - weight(x);
    }
    int size(int A){
        return -Parent[root(A)];
    }
    int eize(int A){
        return es[root(A)];
    }
    bool connect(int A,int B){
        A=root(A); B=root(B);
        if(A==B) return false;
        if(size(A)<size(B)) swap(A,B);
        Parent[A]+=Parent[B];
        es[A]+=es[B]+1;
        Parent[B]=A;
        return true;
    }
    void unite(int A,int B){
        A=root(A); B=root(B);
        if(A==B){ 
            es[A]++;
            return;
        }
        if(size(A)<size(B)) swap(A,B);
        Parent[A]+=Parent[B];
        es[A]+=es[B]+1;
        Parent[B]=A;
        return;
    }
    bool merge(int A, int B, ll w) {
        // x と y それぞれについて、 root との重み差分を補正
        w += weight(A); w -= weight(B); 
        A=root(A); B=root(B);
        if(A==B) return false;
        if(size(A)<size(B)) swap(A,B),w=-w;
        Parent[A]+=Parent[B];
        Parent[B]=A;
        // x が y の親になるので、x と y の差分を diff_weight[y] に記録
        diff_weight[B] = w; 
        return true;
    }
};
int main(){
    ll N,M,Q;
    cin>>N>>M>>Q;
    UnionFind uni(N);
    vector<tuple<int,int,int>> q(Q);
    REP(i,Q){
        int a,b,c;cin>>a>>b>>c;
        q[i]=tie(c,a,b);
        
    }
    sort(All(q));
    if(M==N-1){
        if(get<0>(q.back())==1) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
        return 0;
    }
    REP(i,Q){
        int a,b,c;
        tie(c,a,b)=q[i];
        if(c==0) uni.connect(a,b);
        if(c==1&&uni.issame(a,b)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    ll num=0;
    vector<bool> used(N,false);
    REP(i,N) if(!used[uni.root(i)]){
        used[uni.root(i)]=true;
        num++;
    }
    if(M<=N-num+num*(num-1)/2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

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

using namespace std;

struct UnionFind { /* {{{ */
  vector<int> par;
  vector<int> cnt;

  UnionFind(int n) {
    par.resize(n);
    for (int i = 0; i < n; i++) {
      par[i] = i;
    }
    cnt.resize(n, 1);
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  int count(int x) {
    return cnt[root(x)];
  }
  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
    cnt[ry] += cnt[rx];
  }
  bool same(int x, int y) { return root(x) == root(y); }
}; /* }}} */

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  UnionFind T(N);
  vector<int> cnt(N, -1);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    T.unite(a, b);
    cnt[a]--;
    cnt[b]--;
  }
  for (int i = 0; i < K; i++) {
    int c, d;
    cin >> c >> d;
    c--;
    d--;
    if (T.same(c, d)) {
      cnt[c]--;
      cnt[d]--;
    }
  }
  for (int i = 0; i < N; i++) {
    cnt[i] += T.count(i);
  }
  for (int i = 0; i < N; i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << cnt[i];
  }
  cout << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 2432
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, K, Q = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))

if Q == 1:
    print(0)
    exit()


def argsort(li, key=None, reverse=False):
    return [i for _, i in
            sorted([(a, i) for i, a in enumerate(li)], key=(lambda t: key(t[0])) if key else None, reverse=reverse)]


idx = argsort(A)
used = [False] * N
ans = INF
# 小さい方の値を決め打つ
for min_i in idx:
    groups = [[]]
    for i in range(N):
        if used[i]:
            if groups[-1]:
                groups.append([])
        else:
            groups[-1].append(A[i])
    nums = []
    for group in groups:
        if len(group) >= K:
            group.sort()
            nums += group[:len(group) - K + 1]
    if len(nums) < Q:
        break
    nums.sort()
    ans = min(ans, nums[Q - 1] - nums[0])
    used[min_i] = True
print(ans)


Measured memory_bytes: 45148
import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        int[] a=new int[n];
        Map<Integer,Integer> mp=new HashMap<Integer,Integer>();
        for(int i=0;i<n;i++){
            a[i]=scan.nextInt();
        }
        for(int i=0;i<(1<<n);i++){
            int cnt=0;
            for(int j=0;j<n;j++){
                if((1&i>>j)==1) cnt+=a[j];
            }
            mp.put(cnt,1);
        }
        int q=scan.nextInt();
        while(q>0){
            int m=scan.nextInt();
            if(mp.containsKey(m)) System.out.println("yes");
            else System.out.println("no");
            q--;
        }
    }
}


Measured memory_bytes: 46544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll N, M; cin >> N >> M;
  vector<ll> a[N];
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < M; j++) {
      ll x; cin >> x; a[i].push_back(x);
    }
  }
  ll p[N];
  set<ll> s;
  fill(p, p+N, 0);
  ll num = 0;
  ll res = 10000;
  while (num < M) {
    map<ll,ll> count;
    ll mx = 0;
    for (ll i = 0; i < N; i++) {
      if (p[i] < M) {
        count[a[i][p[i]]]++;
        mx = max(mx, count[a[i][p[i]]]);
      }
    }
    res = min(res, mx);
    for (ll i = 0; i < N; i++) {
      if (p[i] < M && count[a[i][p[i]]] == mx) {s.insert(a[i][p[i]]);}
    }
    for (ll i = 0; i < N; i++) {
      while (p[i] < M && s.count(a[i][p[i]])) p[i]++;
    }
    ll n = 10000;
    for (ll i = 0; i < N; i++) {n = min(n, p[i]);}
    num = n;
  }
  cout << res << endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(0);
     cin.tie(0);
    cout.tie(0);
    double x,t,v;
    cin>>x>>t>>v;
    if(x/v<=t)  cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}




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

int H, N[5000000];

void MaxHeap(int i)
{
	int l = 2 * i;
	int r = l + 1;
	int largest = i;
	int temp;

	if (l <= H && N[l] > N[largest])   //---------
		largest = l;

	if (r <= H && N[r] > N[largest])
		largest = r;

	if (largest != i)
	{
		temp = N[i];
		N[i] = N[largest];
		N[largest] = temp;

		MaxHeap(largest);
	}
}

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

	cin >> H;
	for (int i = 1; i <= H; i++)
		cin >> N[i];

	for (int i = H / 2; i >= 1; i--)
		MaxHeap(i);
	
	for (int i = 1; i <= H; i++)
		cout << " " << N[i];

	cout << endl;
	return 0;
}


Measured memory_bytes: 5108
#include<stdio.h>
int main()
{
	int N,A,B,C;
	100<=N&&N<=999;
	scanf("%d",&N);
	A=N/100;
	B=N/10-A*10;
	C=N-A*100-B*10;
	if(A==C)
	{
		printf("Yes");
	}
	else
		printf("No");
}


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

ll mod_pow(ll n, ll p, ll mod){
    n %= mod;
    // return (n^p) % mod
    if(p==0) return 1;
    ll res = mod_pow(n*n%mod, p/2, mod);
    if(p%2==1) res = res * n % mod;
    return res;
}

int main(){
    ll mod = 1e9+7;
    ll X, Y;  cin >> X >> Y;
    ll a = -1, b = -1;
    if ((2*Y - X)%3==0 && (2*Y - X) >= 0){
        a = (2*Y - X)/3;
    }
    if ((2*X - Y)%3==0 && (2*X - Y) >= 0){
        b = (2*X - Y)/3;
    }
    if(a==-1 || b==-1){
        cout << 0 << endl;
        return 0;
    }

    vector<ll> fct(a+b+1,1);
    vector<ll> invFct(a+b+1, 1);
    for(ll i=1; i<=a+b; i++){
        fct[i] = (fct[i-1]*i)%mod;
    }
    invFct[a+b] = mod_pow(fct[a+b], mod-2, mod);
    for(ll i=a+b-1; i>=1; i--){
        invFct[i] = (invFct[i+1]*(i+1))%mod;
    }

    ll ans = fct[a+b];
    ans = (ans*invFct[a])%mod;
    ans = (ans*invFct[b])%mod;
    cout << ans << endl;
}

Measured memory_bytes: 10624
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    if(abs(b-a)<=d && abs(c-b)<=d){
        cout << "Yes" << endl;
    }else{
        if(abs(c-a)<=d){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int 	     	  long long   // [9,223,372,036,854,775,807 to -9.....808] 19 digits
#define pb                push_back 
#define all(x)            (x).begin(),(x).end()
#define mp                make_pair
#define vi                vector<int> 
#define vpi               vector<pair<int,int>>
#define mii               map<int,int>
#define x                 first
#define y                 second 
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define sz(x)             (int)((x).size())

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order()  // order_of_key

//const int32_t mod=163577857; const int32_t hellhsh = 444440583533; const double pi=2*acos(0.0); const int32_t mod=998244353; 
const int32_t mod = 1e9+7;
const int32_t maxn=2e5+5;


void solve(){
    int n;cin>>n;
    int a[n+1];rep(i,1,n+1) cin>>a[i];
    int r[n+2]={0},l[n+2]={0};
    rep(i,1,n+1){
        l[i]=a[i]^l[i-1];
        r[n-i+1]=r[n-i+2]^a[n-i+1];
    }
    rep(i,1,n+1){
        cout<<(l[i-1]^r[i+1])<<' ';
    }
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tc=1,k=1;                                                                                                                  
    //cin>>tc;
    while(tc--){
        //cout<<"Case #"<<k++<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 8344
def f(n):
  ans = 0
  while n > 0:
    ans += n % 10
    n = n // 10
  return ans

n, a, b = map(int, input().split())
ans = 0
for i in range(1, n + 1):
  if a <= f(i) <= b:
    ans += i
print(ans)

  

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> f(n);
    map<string, int> mp;
    mp["123"] = 0; // id
    mp["132"] = 1; // swap
    mp["213"] = 2; // swap
    mp["231"] = 3; // <<
    mp["312"] = 4; // >>
    mp["321"] = 5; // swap

    vector<int> cnt(6, 0);

    inc(i, 0, n){
        int w;cin >> w;
        string s = "123";
        inc(j, 0, w){
            int a;cin >> a;
            if(a == 0) swap(s[0], s[1]);
            if(a == 1) swap(s[1], s[2]);
        }
        f[i] = mp[s];
        cnt[f[i]]++;
    }

    string ans = "no";

    if(cnt[0] >= 1) ans = "yes"; // id
    if(cnt[1] >= 2) ans = "yes"; // swap
    if(cnt[2] >= 2) ans = "yes"; // swap
    if(cnt[5] >= 2) ans = "yes"; // swap
    if(cnt[3] >= 3) ans = "yes"; // <<3
    if(cnt[4] >= 3) ans = "yes"; // >>3
    if(cnt[3] >= 1 && cnt[4] >= 1) ans = "yes"; // << >>
    if(cnt[1]+cnt[2]+cnt[5] >= 2 && cnt[3]+cnt[4] >= 1) ans = "yes";

    cout << ans << endl;

    return 0;
}



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

#define NMAX 100001
#define MAX(a, b) (a > b ? a : b)

using namespace std;

//ifstream fin("f.in");
//ofstream fout("f.out");

long long r, D, oldX, newX;

int main()
{
    cin >> r >> D >> oldX;
    for(int i = 0; i < 10; i++)
    {
        newX = r * oldX - D;
        cout << newX << '\n';
        oldX = newX;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lg2 std::__lg

typedef std::set <int> set;
typedef std::pair <int, int> pr;
struct __hash__ {
	typedef unsigned long long u64;
	static std::hash <u64> H;
	inline size_t operator () (const pr &x) const {return H(x.first | (u64)x.second << 32);}
};
typedef std::unordered_map <pr, int, __hash__> map;
const int N = 100054;

int n;
int p[N];
set s[N];
map dict;
pr que[2003731];

int ancestor(int x) {return p[x] == x ? x : (p[x] = ancestor(p[x]));}

int main() {
	int i, u, v, U, V, h, t = 0, E = 0; pr e;
	map::iterator it;
	scanf("%d", &n), std::iota(p, p + (n + 1), 0);
	dict.reserve(n * (1 + lg2(n))), dict.rehash(20030731);
	for (i = 2; i < 2 * n; ++i) {
		scanf("%d%d", &u, &v);
		s[u].emplace(v), s[v].emplace(u), e = std::minmax(u, v);
		if (++dict[e] == 2) que[t++] = e;
	}
	for (h = 0; h < t; ++h) {
		std::tie(u, v) = que[h];
		if ((U = ancestor(u)) == (V = ancestor(v))) continue;
		if (s[U].size() > s[V].size()) std::swap(U, V);
		s[U].erase(V), s[V].erase(U), p[U] = V, ++E;
		for (int x : s[U]) {
			it = dict.find(std::minmax(U, x));
			if (!--it->second) dict.erase(it);
			e = std::minmax(V, x);
			if (++dict[e] == 2) que[t++] = e;
			s[x].erase(U), s[x].insert(V), s[V].insert(x);
		}
		s[U].clear();
	}
	return puts(E == n - 1 ? "YES" : "NO"), 0;
}

Measured memory_bytes: 199824
#include <iostream>

int main() {
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;
  while (a > 0 || c > 0) {
    c -= b;
    if (c <= 0) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
    a -= d;
    if (a <= 0) {
      std::cout << "No" << std::endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3628
"""
参考
blog名  ベスパリブ    #プログラミングを主とした日記・備忘録です
URL     https://takeg.hatenadiary.jp/entry/2019/09/10/234417
id:     takeg
"""
# 初期入力
H,W = (int(x) for x in input().split())
S = [list(input()) for i in range(H)]
import numpy as np
S_np = (np.array(S) ==".")*1 #文字を数字に変換 Trueの所のみ演算、Falseは０


#置いたマス(i,j)から4方向探す
L = np.zeros((H,W),dtype=int)
R = np.zeros((H,W),dtype=int)
U = np.zeros((H,W),dtype=int)
D = np.zeros((H,W),dtype=int)
for i in range(W):
    # if S_int[i,j] ==0:これはいらない？⇒*S_npで１or０をかけてるから不要
    if i == 0: 
        L[:,i]      = S_np[:,i]
        R[:,W-i-1]  = S_np[:,W-i-1]
    else:
        L[:,i]      = (L[:,i-1] +1) * S_np[:,i]
        R[:,W-i-1]  = (R[:,W-i] +1) * S_np[:,W-i-1]

for i in range(H):
    if i == 0: 
        D[i,:]      = S_np[i,:]
        U[H-i-1,:]  = S_np[H-i-1,:]
    else:
        D[i,:]      = (D[i-1,:] +1) * S_np[i,:]
        U[H-i-1,:]  = (U[H-i,:] +1) * S_np[H-i-1,:]

#各方向を位置ごとに足す(numpyなら足すだけで行列の和) 
light = L + R + D + U -3 #基準点を4方向＋１してるからー３
light_max = np.max(light)
print(light_max)

Measured memory_bytes: 266552
#include<string>
#include<iostream>

std::string s;

int main(){
    std::cin >> s;

    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '1'){
            ans++;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
import copy
from collections import defaultdict

n = int(input())

count = defaultdict(int)

# (先頭, 末尾) = (h, t) となるモノの数を数える
for i in range(1, n + 1):
    h = int(str(i)[0])
    t = int(str(i)[-1])
    count[(h, t)] += 1

copied_count = copy.deepcopy(count)
ans = 0
for (h, t), v in count.items():
    ans += v * copied_count[(t, h)]

print(ans)


Measured memory_bytes: 3444
def parse_input(raw,format):
    raw=raw.split()
    format=format.split()

    ret={}
    rawpos=0
    for f in format:
        pass


def A(S):
    ret=700
    ret+=S.count("o")*100
    return ret

def B(N,X,m):
    ret=0
    X-=sum(m)
    ret+=len(m)

    ret+=int(X/min(m))

    return ret

def C(A,B,C,X,Y):
    both_price=min(A+B,C*2)
    A_price=min(A,C*2)
    B_price=min(B,C*2)

    both_num=min(X,Y)
    X_num=X-both_num
    Y_num=Y-both_num
    return both_price*both_num+X_num*A_price+Y_num*B_price

import sys

inp = sys.stdin.read().split()
inp=[int(i) for i in inp]
print(C(inp[0], inp[1], inp[2],inp[3],inp[4]))



Measured memory_bytes: 3188
def get_input():
    while True:
        try:
            yield ''.join(raw_input())
        except EOFError:
            break

if __name__ == '__main__':
    a = list(get_input())

for n in a:
    inl=n.split()
    num=int(inl[0])+int(inl[1])
    l=list(str(num))
    time=0
    for i in l:
        time+=1
    print time

Measured memory_bytes: 6356
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    string S, T; cin >> S >> T;
    int N = S.size();

    vec StoT(26, -1);
    vector<bool> T_used(26, false);
    REP(i, N){
        int s = (int)(S[i] - 'a');
        int t = (int)(T[i] - 'a');
        if(StoT[s] == -1 && !T_used[t]){
            StoT[s] = t;
            T_used[t] = true;
        }else if(StoT[s] != t){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";

    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define ll long long
#define F first
#define S second
#define pb push_back
int main()
{
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    int jmp = 1, mx = -1, i, ind = -1;
    vector<int> ans;
    for (i = n - 1; i >= 0; i--, jmp++)
    {
        if (jmp > m)
        {
            if (ind == -1)
                break;
            ans.pb(mx);
            jmp = ind - i;
            ind = -1;
            mx = -1;
        }
        if (s[i] == '0')
        {
            if (jmp > mx)
                ind = i, mx = jmp;
        }
    }
    if (ind == -1)
    {
        cout << "-1\n";
        return 0;
    }
    ans.pb(jmp - 1);
    reverse(ans.begin(), ans.end());
    for (auto it : ans)
        cout << it << ' ';
    cout << endl;
    return 0;
}

Measured memory_bytes: 1144
from collections import deque
n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))
if n == 2:
    print(abs(A[1]-A[0]))
    exit()
A.sort()
s = sum(A)
if n % 2 == 1:
    small = 0
    for i in range(n//2):
        small += A[i]
    big = s - small
    ans1 = 2*big-2*small-A[n//2]-A[n//2+1]
    small += A[n//2]
    big = s-small
    ans2 = 2*big -2*small+A[n//2]+A[n//2-1]
    print(max(ans1,ans2))
else:
    small = 0
    for i in range(n//2):
        small += A[i]
    big = s -small
    ans1 = 2*big -2*small + A[n//2-1]-A[n//2]
    small += A[n//2]
    big = s -small
    ans2 = 2*big-2*small+A[n//2]-A[n//2+1]
    print(max(ans1,ans2))

Measured memory_bytes: 7824
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Best-of-(2n-1)
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_M = MAX_N * 2;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;

struct Rat {
  int n, d;
  Rat(): n(0), d(1) {}
  Rat(int _n): n(_n), d(1) {}
  Rat(int _n, int _d): n(_n), d(_d) {}

  Rat operator+(const Rat r) const {
    return Rat(((ll)n * r.d % MOD + (ll)r.n * d % MOD) % MOD,
	       (ll)d * r.d % MOD);
  }

  Rat operator*(const Rat r) const {
    return Rat((ll)n * r.n % MOD, (ll)d * r.d % MOD);
  }

  void print() { printf("%d/%d\n", n, d); }
};

/* global variables */

int eas[MAX_N + 1], ebs[MAX_N + 1];
int eabs[MAX_M + 1], fracs[MAX_M + 1];

/* subroutines */

int powmod(int a, int n) {  // a^n % MOD
  ll pm = 1;
  while (n > 0) {
    if (n & 1) pm = (pm * a) % MOD;
    a = (ll)a * a % MOD;
    n >>= 1;
  }
  return pm;
}

/* main */

int main() {
  int n, a, b, c;
  scanf("%d%d%d%d", &n, &a, &b, &c);
  int n2 = n * 2;

  eas[0] = ebs[0] = 1;
  for (int i = 1; i <= n; i++) {
    eas[i] = (ll)eas[i - 1] * a % MOD;
    ebs[i] = (ll)ebs[i - 1] * b % MOD;
  }

  eabs[0] = fracs[0] = 1;
  for (int i = 1; i <= n2; i++) {
    eabs[i] = (ll)eabs[i - 1] * (a + b) % MOD;
    fracs[i] = (ll)fracs[i - 1] * i % MOD;
  }
  
  Rat sum(0);
  for (int m = n; m < n2; m++) {
    Rat p(fracs[m - 1], (ll)fracs[n - 1] * fracs[m - n] % MOD);
    int k =
      ((ll)eas[n] * ebs[m - n] % MOD + (ll)eas[m - n] * ebs[n] % MOD) % MOD;
    Rat q((ll)k * m % MOD * 100 % MOD, eabs[m + 1]);
    sum = sum + (p * q);
  }
  //sum.print();

  printf("%d\n", (int)((ll)sum.n * powmod(sum.d, MOD - 2) % MOD));
  return 0;
}


Measured memory_bytes: 2560
import bisect
import sys
input = sys.stdin.readline

n,d,a= map(int, input().split())
x= [list(map(int, input().split())) for i in range(n)]

x.sort()
y=[]
for i in range(n):
    y.append(x[i][0])
    x[i][1]=-(-x[i][1]//a)

# どのモンスターまで倒したか管理しながら進める。
ans=0
# いつ効力が切れるか記録
z=[0]*(n+1)
# 今の攻撃力
atk=0
for i in range(n):
    atk+=z[i]
    if x[i][1]-atk>0:
        ans+=x[i][1]-atk
        q=bisect.bisect_right(y,x[i][0]+2*d,i,n)
        z[q]-=x[i][1]-atk
        atk+=x[i][1]-atk
print(ans)

Measured memory_bytes: 88924
#include <stdio.h>
int main (void)
{
	int a , b;

	scanf("%d %d", &a , &b);
	
	if(a < b){
		printf("a < b\n" ,a  , b);
	}

	else if(a > b){
		printf("a > b\n" ,a  , b);
	}

	else if(a == b){
		printf("a == b\n" ,a  , b);
	}

	return 0;


}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long n,i,top,zhan[200005],f[200005],sum[200005],l,r,mid,min1,ans;
struct nyh{
	long long x,v,l,r;
}o[200005];
bool cmp(nyh u,nyh v){
	return u.v<v.v;
}
bool cmp2(nyh u,nyh v){
	return u.r<v.r||u.r==v.r&&u.l<v.l;
}
int main(){
	n=read();
	for(i=1;i<=n;i++){
		o[i].x=read();
		o[i].v=read();
	}
	sort(o+1,o+n+1,cmp);
	for(i=1;i<=n;i++){
		if(o[i].x>o[zhan[top]].x||top==0){
			top++;
			zhan[top]=i;
		}
		l=1;r=top;mid=(l+r)/2;min1=top;
		while(l<=r){
			if(o[zhan[mid]].x>=o[i].x){
				r=mid-1;
				min1=min(min1,mid);
			}
			else
				l=mid+1;
			mid=(l+r)/2;
		}
		o[i].l=zhan[min1];
	}
	top=0;
	for(i=n;i>=1;i--){
		if(o[i].x<o[zhan[top]].x||top==0){
			top++;
			zhan[top]=i;
		}
		l=1;r=top;mid=(l+r)/2;min1=top;
		while(l<=r){
			if(o[zhan[mid]].x<=o[i].x){
				r=mid-1;
				min1=min(min1,mid);
			}
			else
				l=mid+1;
			mid=(l+r)/2;
		}
		o[i].r=zhan[min1];
	}
	sort(o+1,o+n+1,cmp2);
	for(i=1;i<=n;i++){
		l=1;r=i;mid=(l+r)/2;min1=r;
		while(l<=r){
			if(o[mid].r+1>=o[i].l){
				min1=min(min1,mid);
				r=mid-1;
			}
			else
				l=mid+1;
			mid=(l+r)/2;
		}
		if(o[i].l==1)
			f[i]=1;
		f[i]=(f[i]+sum[i-1]-sum[min1-1]+mo)%mo;
		if(o[i].r==n)
			ans=(ans+f[i])%mo;
		sum[i]=(sum[i-1]+f[i])%mo;
	}
	pus(ans,2);
	return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<vector>

using namespace std;

int main()
{
	int n;
	vector<int> prime;
	int i,j;
	
	for(i=0;i<1000000;i++)
	{
		prime.push_back(1);
	}
	prime[0]=prime[1]=0;
	
	for(i=0;i<1000000;i++)
	{
		if(prime[i]==1)
		{
			for(j=2;j*i<1000000;j++)
			{
				prime[i*j]=0;
			}
		}
	}
	
	for(;;)
	{
		cin >> n ;
		if(n==0)
			break;
		
		int ans=0;
		
		for(i=0;i<=n-i;i++)
		{
			if(prime[i]==1)
			{
				if(prime[n-i]==1)
				{
					ans++;
//					cout << "f1:" << i << " f2:" << n-i << " ans:" << ans << endl;
				}
			}
		}
		
		cout << ans << endl;
		
	}
}

Measured memory_bytes: 0
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
import numpy as np
#decimal.getcontext().prec = 10

N, C = MAP()

n = [[] for _ in range(C)]
for _ in range(N):
	s, t, c = MAP()
	n[c-1].append((s, t))

m = [[] for _ in range(C)]

for i in range(C):
	if n[i] == []:
		continue
	n[i].sort(key = lambda y:y[0])
	s = n[i][0][0]
	t = n[i][0][1]
	L = len(n[i])
	n[i].append((0, 0))
	for j in range(L):
		if j < L and n[i][j][1] == n[i][j+1][0]:
			t = n[i][j+1][1]
		else:
			m[i].append((s, t))
			s = n[i][j+1][0]
			t = n[i][j+1][1]

#print(m)
cnt = [0]*(10**5+1)

for x in m:
	for s, t in x:
		cnt[s-1] += 1
		cnt[t] -= 1


cnt = list(accumulate(cnt))
#print(cnt)
print(max(cnt))


Measured memory_bytes: 49776
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 1000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
bitset<maxx/2>vis;
vector<ll>prime;
void sieve(){
    ll x=maxx/2, y=sqrt(maxx)/2;
    for(ll i=1;i<=y;i++){
        if(vis[i]==0){
            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
                vis[j]=1;
        }
    }
    prime.push_back(2);
    for(ll i=3;i<maxx;i+=2)
        if(vis[i/2]==0)
        prime.push_back(i);
}
bool isprime(ll a)
{
    if(a==2){
        return true;
    }
    if(a%2==0){
        return false;
    }
    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++){
        if(a%prime[i]==0){
            return false;
        }
    }
    return true;
}
ll lcm(ll a,ll b)
{
    return (a*b)/__gcd(a,b);
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    string a,b;
    cin>>a>>b;
    ll cnt=0;
    for(int i=0;i<a.size();i++){
        if(a[i]!=b[i])cnt++;
    }
    cout<<cnt<<endl;
    return;
}
int main()
{
	FastIO;
	///sieve();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3796