akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;

string subsum(int* A,int n,int m){
  bitset<2010> E(1);

  rep(i,0,n){
    E |= (E<<A[i]);
  }

  if(E.test(m)) return "yes";
  else return "no";
}

vector<bool> seen;
vector<int> d;
vector<int> f;
#define pi 3.141592653589793

vector<int64_t> dsy(vector<int64_t>dis,vector<vector<pair<int64_t,int64_t>>> g,int64_t start,int64_t goal){
    int n=dis.size();
    priority_queue<pair<int64_t,int64_t>,vector<pair<int64_t,int64_t>>,greater<pair<int64_t,int64_t>>> Q;
    dis[start]=0;
    Q.push(make_pair(0,start));

    while(!Q.empty()){
        int pos=Q.top().second;Q.pop();
        for(int i=0;i<g.at(pos).size();i++){
            int to=g.at(pos).at(i).first;
            int cost=g.at(pos).at(i).second;
            if(dis[to]==-1||dis[to]>dis[pos]+cost){
                dis[to]=dis[pos]+cost;
                Q.push(make_pair(dis[to],to));
            }
        }
    }
    return dis;
}


int main(int argc,char **argv){
  int n; cin>>n;
  ll a[n];
  bool guu=true;
  rep(i,0,n) {
    cin>>a[i];
  }

  sort(a,a+n);
  ll ans=a[0];
  rep(i,0,n-1){
    ans=min(ans,__gcd(a[i],a[i+1]));
  }
  cout<<ans<<endl;
  }

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

bool solve[10001];

void prime(){
  memset(solve,true,sizeof(solve));
  for(int i=2;i<=5000;i++){
    for(int j=2;i*j<=10000;j++) solve[i*j] = false;
  }
}


int main(){
  prime();
  int n;
  while(cin >> n){
    int cnt = 0;
    for(int i=2;i<n;i++){
      if(solve[i] && solve[n-i+1]) cnt++;
    }
    cout << cnt << endl;
  }
}

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

int main() {
	int n; cin >> n;
	vector<int>a(n); for (auto&& p : a)cin >> p;

	int cnt2 = 0, cnt4 = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] >= 4 && a[i] % 4 == 0)cnt4++;
		else if (a[i] >= 2 && a[i] % 2 == 0)cnt2++;
	}
	cnt4 += (cnt2 / 2);
	cout << (cnt4 >= n / 2 ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 640
n=1000000
num=[True]*(n+1)
num[0]=num[1]=False

for i in range(2,int(n**0.5)+1):
    if num[i]:
        for j in range(i*2,n+1,i):
            num[j]=False
# 0 1 2 2 3 3 4
# 1 2 3 4 5 6 7
ans=[0]*(n)
for i in range(1,n):
    if num[i]:
        ans[i]=ans[i-1]+1
    else:
        ans[i]=ans[i-1]
while True:
    try:
        s=int(input())
    except:
        break
    print(ans[s])


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

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9 + 7)
#define MAX_N (100000)

ll X, Y;

void solve() {
  if (abs(X - Y) > 1) {
    printf("Alice\n");
  } else {
    printf("Brown\n");
  }
}

int main() {
  cin >> X >> Y;

  solve();

  return 0;
}


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

n, d = map(int, input().split())

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

cnt = 0
for i in range(n):
    l = math.sqrt(index_list[i][0] ** 2 + index_list[i][1] ** 2)
    if l <= d:
        cnt += 1

print(cnt)


Measured memory_bytes: 45384
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  string s;
  cin >> s;
  int N = s.size();
  int w = 0, l = 0;

  Rep(i, N) {
    if( i % 2 == 0 ) {
      if( s[i] == 'p' ) l++;
    } else {
      if( s[i] == 'g' ) w++;
    }
  }

  cout << w - l << endl;
}


Measured memory_bytes: 512
// Last Change: 04/20/2020 17:19:39.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

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

  using a_type = pair<ll, int>;
  vector<a_type> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i].first;
    A[i].second = i + 1;
  }

  sort(A.begin(), A.end(), greater<a_type>());

  vector<vector<ll>> dp(N + 5, vector<ll>(N + 5, 0));
  for (int i = 1; i <= N; ++i) {
    a_type& t = A[i - 1];
    dp[i][0] = dp[i - 1][0] + t.first * abs(t.second - i);
    dp[0][i] = dp[0][i - 1] + t.first * abs(N - i + 1 - t.second);
  }

  ll res = max(dp[N][0], dp[0][N]);
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N - i; ++j) {
      a_type& t = A[i + j - 1];
      ll a = dp[i - 1][j] + t.first * abs(t.second - i);
      ll b = dp[i][j - 1] + t.first * abs(N - j + 1 - t.second);
      dp[i][j] = max(a, b);

      if (i + j == N) {
        res = max(res, dp[i][j]);
      }
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 34508
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
 
using namespace std;



int main(){

	int n,q;
	while(cin>>n>>q,n||q){

		vector<string> era(n);
		vector<long long> a(n),b(n);

		for(int i=0;i<n;i++){
			cin>>era[i]>>a[i]>>b[i];
		}


		while(q--){
			long long y;
			cin>>y;

			
			bool ok=false;
			for(int i=0;i<n;i++){
				if( b[i]-a[i]+1<=y && y<=b[i] ){
					ok=true;
					cout<<era[i]<<" "<<y-b[i]+a[i]<<endl;
				}
			}
			
			if(!ok)cout<<"Unknown"<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3164
from heapq import *
x,y,z,k = map(int,input().split())
A,B,C = [list(map(int,input().split())) for n in range(3)]
D = nlargest(k,(a+b for a in A for b in B))
E = nlargest(k,(d+c for d in D for c in C))
print("\n".join(map(str,E)))

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

const int nax = 305;
double p[nax][nax][nax];
double ev[nax][nax][nax];

int main()
{
    int n;
    cin >> n;
    vector<int> counts(4);
    for(int i = 0; i < n; i++) {
        int k;
        cin >> k;
        counts[k]++;
    }

    p[counts[1]][counts[2]][counts[3]] = 1;
    ev[counts[1]][counts[2]][counts[3]] = 0;
    //dp[a][b][c] -> dp[a-1][b][c], dp[a+1][b-1][c], dp[a][b+1][c-1].
    for(int c = n; c >= 0; c--) {
        for(int b = n; b >= 0; b--) {
            for(int a = n; a >= 0; a--) {
                if(a == 0 && b == 0 && c == 0) {
                    continue;
                }
                if(a+b+c > n) {
                    continue;
                }
                double p_wasted = 1 - (double)(a+b+c)/n;
                double wasted = p_wasted/(1-p_wasted) + 1;
                ev[a][b][c] += wasted*p[a][b][c];

                if(c > 0) {
                    double p_c = (double)c/(a+b+c);
                    p[a][b+1][c-1] += p_c*p[a][b][c];
                    ev[a][b+1][c-1] += p_c*ev[a][b][c];
                }
                if(b > 0) {
                    double p_b = (double)b/(a+b+c);
                    p[a+1][b-1][c] += p_b*p[a][b][c];
                    ev[a+1][b-1][c] += p_b*ev[a][b][c];
                }
                if(a > 0) {
                    double p_a = (double)a/(a+b+c);
                    p[a-1][b][c] += p_a*p[a][b][c];
                    ev[a-1][b][c] += p_a*ev[a][b][c];
                }
            }
        }
    }

    cout << fixed << setprecision(10) << ev[0][0][0] << endl;
}


Measured memory_bytes: 438528
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

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

    int max = 0;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (max < a[i]) max = a[i];
    }

    vector<int> d(max + 1);
    for (int i = 0; i < n; i++) {
        for (int j = 1; j * a[i] <= max; j++) {
            d[j * a[i]]++;;
        }
    }

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (d[a[i]] <= 1) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 7868
f=->a,b{a.size.times.map{|i|a[b[i]]}}
n,*z=`dd`.split.map &:to_i
t=[*0...n]
e=[*0...n]
a=z.shift(n+1)
n.downto(1){|i|a[i]-=a[i-1]}
k,*z=z
z.map{|x|t[x-2],t[x-1]=t[x-1],t[x-2]}
(e=f[e,t]if k%2>0;t=f[t,t];k/=2)while k>0
k,*a=a
n.times{|i|p k;k+=a[e[i]]}

Measured memory_bytes: 73232
#include <iostream>
#include <cmath>
using std::cout;
using std::cin;
using std::endl;
using std::string;

int main()
{
    const long int MAX_N = 1000000000000;
    long int N;
    cin >> N;
    
    long int result = MAX_N;
    for (long int i = 1; i <= (int)sqrt(N); i++)
    {
        if (N % i == 0)
        {
            long int j = N / i;
            long int current = i + j - 2;
            if (current < result)
            {
                result = current;
            }
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() # input string
ni = lambda: int(readline().rstrip()) # input int
nm = lambda: map(int, readline().split()) # input multiple int 
nl = lambda: list(map(int, readline().split())) # input multiple int to list

n = ni()
l = nl()
ans = 0

for i, usa in enumerate(l):
    if l[usa - 1] == i + 1:
        ans += 1
print(ans // 2)

Measured memory_bytes: 52444
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    int idx = min_element(all(A)) - A.begin();
    int ans = 1 << 30;
    rep(i, idx - K + 1, idx + K) {
        chmin(ans, (N - 1 - i + K - 2) / (K - 1) + (i + K - 2) / (K - 1));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<fstream>
#include<string>

using namespace std;

int main(){
	int a[50][3];
	int b[50][3];
	int i=0;
	int j=0;
	int n=0;
	int m=0;
	int x=0;
	int y=0;
	string e;
	string f;
	f="WBR";
	
	for(i=0;i<50;i++){                                   
		for(j=0;j<3;j++){
			a[i][j]=0;
			b[i][j]=0;
		}
	}
	cin>>n;
	cin>>m;
	for(i=0;i<n;i++){
		cin>>e;
		for(j=0;j<m;j++){
		
			if(e[j]==f[0]){
				a[i][0]++;
			}else if(e[j]==f[1]){
				a[i][1]++;
			}else{
				a[i][2]++;
			}
		}
	}
	b[0][0]=a[0][1]+a[0][2];
	b[1][0]=b[0][0]+a[1][1]+a[1][2];
	b[1][1]=b[0][0]+a[1][0]+a[1][2];
	b[2][0]=b[1][0]+a[2][1]+a[2][2];
	x=b[1][0]+a[2][0]+a[2][2];
	y=b[1][1]+a[2][0]+a[2][2];
	if(x<y){
		b[2][1]=x;
	}else{
		b[2][1]=y;
	}
	b[2][2]=b[1][1]+a[2][0]+a[2][1];
	for(i=3;i<n;i++){
		b[i][0]=b[i-1][0]+a[i][1]+a[i][2];
		for(j=1;j<3;j++){
			if(b[i-1][j-1]<b[i-1][j]){
				b[i][j]=b[i-1][j-1]+m-a[i][j];
			}else{
				b[i][j]=b[i-1][j]+m-a[i][j];
			}
		}
	}
	cout<<b[n-1][2]<<endl;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
	string a;
	cin >> a;
	int n=a.size();
	(n == 2)? cout << a : cout << a[2] << a[1] << a[0];

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<vector>

using namespace std;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int Max = 100000;

int S[2002][2002];
int A[2002][2002];
int B[2002][2002];
int C[2002][2002];

int main() {
	int h, w,q;
	cin >> h >> w>>q;
	string s;
	
	for (int i = 1; i <= h; i++) {
		cin >> s;
		for (int j = 1; j <= w; j++) {
			S[i][j] = s[j-1] - '0';
		}
	}
	// A[i][j] is sum of 
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			int num = S[i + 1][j] + S[i][j + 1] + S[i - 1][j] + S[i][j - 1];
			int x=0;
			if (num == 0)x = 2;
			if (num == 1)x = 1;
			if (num == 3)x = -1;
			if (num == 4)x = -2;
			if (S[i][j] == 0)x = 0;
			A[i][j] = x + A[i - 1][j] + A[i][j - 1] - A[i - 1][j - 1];
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			B[i][j] = B[i][j - 1] + S[i][j] * S[i - 1][j];
			C[i][j] = C[i-1][j] + S[i][j] * S[i][j-1];
		}
	}
	for (int i = 0; i < q; i++) {
		int xs, ys, xe, ye;
		cin >> xs >> ys >> xe >> ye;
		int ans = 0;
		ans += A[xs - 1][ys - 1] - A[xs - 1][ye] - A[xe][ys - 1] + A[xe][ye];
		ans += B[xs][ye] - B[xs][ys - 1];
		ans += B[xe+1][ye] - B[xe+1][ys - 1];
		ans += C[xe][ys] - C[xs-1][ys];
		ans += C[xe][ye+1] - C[xs-1][ye+1];
		cout << ans/2 << endl;
	}
}


Measured memory_bytes: 64384
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define fo(i,n) for(int i=0;i<n;++i)
#define Fo(i,k,n) for(int i=k;i<n;++i)
typedef long long int lli;
int main(){
    FIO
    int n; cin>>n;
    fo(i,n){
        cout<<"A"<<"C"<<"L";
    }
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	int N, T; cin >> N >> T;
	vector<ll>t(N + 1, INF);
	rep(i, N)cin >> t[i];
	ll ans = 0;
	rep(i, N) {
		if (t[i + 1] - t[i] <= T) {
			ans += t[i + 1] - t[i];
		}
		else {
			ans += T;
		}
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1792
using System;
class Hello
{

    static void Main(string[] args)
    {
        var AB = Console.ReadLine().Split(' ');
        byte a = byte.Parse(AB[0]);
        byte b = byte.Parse(AB[1]);
        for(var i = 0; i < a*2-1; i++)
        {
            Console.Write((b - a+i+1)+" ") ;
        }
       
    }

}

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

ll ctoll(char a){
    return (ll)a-'0';
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	string N;
    cin>>N;
    ll a;
    a = ctoll(N[N.size()-1]);
    string ans;
    ll h[] = {2,4,5,7,9};
    ll p[] = {0,1,6,8};
    ll b[] = {3};
    for(auto v:h){
        if(v==a){
            ans = "hon";
        }
    }
	for(auto v:p){
        if(v==a){
            ans = "pon";
        }
    }
    for(auto v:b){
        if(v==a){
            ans = "bon";
        }
    }
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    string s_front=s.substr(0,2);
    string s_back=s.substr(2,2);
    int front=stoi(s_front);
    int back=stoi(s_back);
    if ((front>=13||front==0)&&back<=12&&back!=0) {
        cout<<"YYMM"<<endl;
    } else if (front<=12&&front!=0&&(back>=13||back==0)) {
        cout<<"MMYY"<<endl;
    } else if (front<=12&&front!=0&&back<=12&&back!=0) {
        cout<<"AMBIGUOUS"<<endl;
    } else {
        cout<<"NA"<<endl;
    }
}


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

public class ITP1_9_D{
    public static void Main(){
        var str = Console.ReadLine();
        var q = int.Parse(Console.ReadLine());
        
        for (var i = 0; i < q; i++)
        {
            var command = Console.ReadLine().Split(' ');
            var cmd_name = command[0];
            var a = int.Parse(command[1]);
            var b = int.Parse(command[2]);
            
            var len = b - a + 1;
            
            if (cmd_name == "print")
            {
                Console.WriteLine(str.Substring(a, len));
            }
            else
            {
                var substr1 = str.Substring(0, a);
                var substr2 = str.Substring(b + 1);
                
                if (cmd_name == "reverse")
                {
                    var substr_rev = str.Substring(a, len);
                    substr_rev = string.Join("", substr_rev.Reverse());
                    str = substr1 + substr_rev + substr2;
                }
                else
                {
                    str = substr1 + command[3] + substr2;
                }
            }
        }
    }
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
  int k=2;
  int i,j;
  while(true)
  {
    if(k*(k-1)/2==n)
    {
      break;
    }
    else if(k*(k-1)/2>n)
    {
      k=-1;
      break;
    }
    k++;
  }
  if(k==-1)cout<<"No"<<endl;
  else
  {
    cout<<"Yes"<<endl;
    cout<<k<<endl;
    vector<vector<int>> anss(k);
    int num=1;
    rep(i,k)
    {
      for(j=i+1;j<k;j++)
      {
        anss[i].emplace_back(num);
        anss[j].emplace_back(num);
        num++;
      }
    }
    rep(i,k)
    {
      cout<<anss[i].size();
      rep(j,anss[i].size())
      {
        cout<<' '<<anss[i][j];
      }
      cout<<endl;
    }
  }
  
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

bool ch[3];
int main() {
	ll n;
	string s,t;
	cin>>n>>s>>t;
	for(ll i=0;i<n;i++){
		cout << s[i]<<t[i];
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, X;
std::vector<std::vector<LL>>res;
std::vector<LL>cnt, all;
std::map<std::pair<LL, LL>, LL>memo;

LL f(LL l, LL x)
{
	if (l == 0) return 1;
	if (memo[std::make_pair(l, x)] > 0) return memo[std::make_pair(l, x)];
	LL sum = 0;
	for (int i = 4; i >= 0; --i)
	{
		if (x <= 0) break;
		if (i == 3 || i == 1)
		{
			if (x >= all[l - 1]) sum += cnt[l - 1];
			else sum += f(l - 1, x);
		}
		if (i == 2) ++sum;
		x -= res[l][i];
	}
	return memo[std::make_pair(l, x)] = sum;
}

int main()
{
	in >> N >> X;

	res.resize(N + 1);
	rep(i, res.size()) res[i].resize(5, 1);
	cnt.resize(N + 1); all.resize(N + 1);
	cnt[0] = 1; all[0] = 1;
	LL sum = 1;
	for (LL i = 1; i <= N; ++i)
	{
		res[i][1] = res[i][3] = sum;
		sum = 0;
		rep(j, 5) sum += res[i][j];
		cnt[i] = cnt[i - 1] * 2 + 1;
		all[i] = all[i - 1] * 2 + 3;
	}

	out << f(N, X) << std::endl;
	return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a, Ts... ts) {return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int m, d;
    cin >> m >> d;

    int ans = 0;
    FOR(i, 1, m+1)
    {
        FOR(j, 1, d+1)
        {
            if(j % 10 < 2 || j / 10 < 2) continue;
            
            if(i == (j%10) * (j/10)) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef double real;
typedef int64_t i64;
typedef uint64_t u64;

int main() {
	ios_base::sync_with_stdio(false);
	i64 x = 1, y = 1;
	int n;
	cin >> n;
	for(; n > 0; n--) {
		int a, b;
		cin >> a >> b;
		auto k = max((x + (a - 1)) / a, (y + (b - 1)) / b);
		x = a * k;
		y = b * k;
	}
	cout << x + y << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
#define lowbit(x) ((x) & (-(x)))
using namespace std;

const int N = 1e5 + 10;
typedef long long ll;
ll n, L, ch[N][26], sz;
char s[N];

void insert(char s[]) {
    int u = 0, len = strlen(s + 1);
    rep(i, 1, len) {
        int c = s[i] - '0';
        if (!ch[u][c]) ch[u][c] = ++sz;
        u = ch[u][c];
    }
}

ll dfs(int x, int d) {
    if (!x && d) return lowbit(L - d + 1);
    return dfs(ch[x][0], d + 1) ^ dfs(ch[x][1], d + 1);
}

int main() {
    cin >> n >> L;
    rep(i, 1, n) {
        scanf("%s", s + 1);
        insert(s);
    }
    puts(dfs(0, 0) ? "Alice" : "Bob");
    return 0;
}


Measured memory_bytes: 23808
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		
		if (a >= 13) {
			System.out.println(sc.nextInt());
		} else if (a >= 6) {
			System.out.println((int) (sc.nextInt() / 2.));
		} else {
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 23764
o,f,i=998244353,[1],1
while i<o/399:f+=[f[-1]*i%o];i+=1
c=lambda n,k:f[n]*pow(f[n-k],o-2,o)*pow(f[k],o-2,o)
n,m=map(int,input().split())
w,u,j=3*m,n-1,m+1
a=c(w+u,u)-n*c(n+m-2,u)
if w-j&1:j+=1
while j<=min(w,n):a-=c(n,j)*c((w-j)//2+u,u);j+=2
print(a%o)

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

using namespace std;
#define MAX 1000000
typedef unsigned long long ULL;

void process();
int main(){
    int N;
    int data;
    int *dataSet;
    int i,j,max;
    cin >> N;
    dataSet = new int[MAX+1];
    max = 0;
    for(i=0;i<=MAX;i++){
        dataSet[i] = 0;
    }
    for(i=0;i<N;i++){
        cin >> data;
        if(max < data){
            max = data;
        }
        dataSet[data]++;
    }
    for(i=0;i<=MAX;i++){
        if( dataSet[i] != 0){
            for(j=i*2;j<=MAX;j+=i){
                if( dataSet[j] > 0){
                    dataSet[j] = -1;
                }
            }
        }
    }
    int count = 0;
    for(i=0;i<=MAX;i++){
        if( dataSet[i] == 1){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 7544
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const int MAXN = 40000;

int n;
int p[MAXN];
int q[MAXN];
int a[MAXN];
int b[MAXN];

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> p[i], --p[i];
	for (int i = 0; i < n; ++i)
		q[p[i]] = i;
	int bs = 1e9 + 1;
	a[0] = 1;
	b[0] = 1e9;
	bs -= q[0];
	int na = 1;
	int nb = 1e9;
	for (int i = 1; i < n; ++i) {
		++na;
		--nb;
		if (na + nb < bs + q[i]) {
			na += bs + q[i] - na - nb;
		}
		else {
			nb -= na + nb - bs - q[i];
		}
		a[i] = na;
		b[i] = nb;
	}
	for (int i = 0; i < n; ++i)
		cout << a[i] << " ";
	cout << "\n";
	for (int i = 0; i < n; ++i)
		cout << b[i] << " ";
	cout << "\n";

	return 0;
}




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

using namespace std;

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int m[] = new int[n];
		int min = Integer.MAX_VALUE;
		int sum = 0;

		for (int i = 0; i < n; i++) {
			m[i] = sc.nextInt();
			min = Math.min(min, m[i]);
			sum += m[i];
		}

		System.out.println(n + (x - sum) / min);

		sc.close();

	}

}


Measured memory_bytes: 35996
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll pair<int,int>
#define mp make_pair
#define bp __builtin_popcountll
const int N = 10000005;
const int MOD = 1000000007;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
    ll n,k;
    cin >> n >> k;
    ll a[n+1];
    for(ll i=1;i<=n;i++)    cin >> a[i];
    if(k>100)
    {
        for(ll i=1;i<=n;i++)   cout<<n<<" ";
        return;
    }
    while(k--)
    {
        ll n_a[n+2];
        memset(n_a,0,sizeof(n_a));
        for(ll i=1;i<=n;i++)
        {
            ll left = i - a[i];
            ll right = i + a[i];
            left = max(left,1LL);
            right = min(right,n);
            n_a[left]++;
            n_a[right+1]--;
        }
        for(ll i=1;i<=n;i++)    n_a[i] += n_a[i-1];
        for(ll i=1;i<=n;i++)    a[i] = n_a[i];
    }
    for(ll i=1;i<=n;i++)   cout<<a[i]<<" ";
}

int main()
{
    FAST;
    ll t = 1;
   // cin >> t;
    while(t--)
    {
        solve();
    }
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int N;
VI a;
double dp[301][301][301];

double rec(int a, int b, int c){
    if(dp[a][b][c] != -1) return dp[a][b][c];
    if(a==0 && b==0 && c==0) return dp[a][b][c] = 0;

    double n = a+b+c;
    double res = (double)N/n;
    if(a>0) res += rec(a-1,b,c)*a/n;
    if(b>0) res += rec(a+1,b-1,c)*b/n;
    if(c>0) res += rec(a,b+1,c-1)*c/n;
    return dp[a][b][c] = res;
}

int main(void){
    cin >> N;
    REP(i,N+1)REP(j,N+1)REP(k,N+1) dp[i][j][k] = -1;
    a.assign(N,0);
    int n[3]; REP(i,3) n[i] = 0;
    REP(i,N){
        cin >> a[i];
        n[a[i]-1]++;
    }

    double ans = rec(n[0], n[1], n[2]);
    cout << fixed << setprecision(12) << ans << en;
    return 0;
}

Measured memory_bytes: 213376
import math
a,b,x=map(int,input().split())
s=a*a*b
p=2*(s-x)/(a**3)
#print(s,p)
if s==x:
    print(0)
elif x>=s/2:
    print(math.degrees(math.atan(p)))
else:
    print(math.degrees(math.atan(a*b*b/(2*x))))



Measured memory_bytes: 38480
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>
using namespace std;

int n, k, a, cnt;

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a;
		cnt += min(a, k - a);
	}
	cout << cnt * 2 << endl;
	return 0;
}

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

int main(){

    int fib[50];
    fib[0] = fib[1] = 1;
    for(int i = 2; i <= 45; i++){
        fib[i] = fib[i - 1] + fib[i - 2];
    }

    int n; cin >> n;
    cout << fib[n] << endl;
    return 0;
}


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

long gcd(long x, long y) {
   if (x % y == 0) {
       return(y);
   } else {
       return(gcd(y, x%y));
   }
}

int main() {
    int n; long x;
    scanf("%d%ld", &n, &x);
    long cities[n];
    for (int i = 0; i < n; i++) {
        scanf("%ld", &cities[i]);
    }
    if (n == 1) {
        printf("%ld\n", abs(x-cities[0]));
        return 0;
    }
    long ans = gcd(abs(x-cities[0]), abs(x-cities[1]));
    for (int i = 2; i < n; i++) {
        ans = gcd(ans, abs(x-cities[i]));
    }
    printf("%ld\n", ans);
}

Measured memory_bytes: 4496
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
#define con 1000000007
using namespace std;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll i,j,m,n,k;
    ll t;
    cin>>n;
    if(n%1000!=0)
    cout<<1000-(n%1000);
    else
        cout<<0;
}





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

int main(){
	int A;
	int B;


	cin >>A>>B;

	int sum = 0;
	int i = 0;

	if (B == 1) {
		cout << i << endl;
	}
	else {
		while (1) {
			if (i == 0) {
				sum = A;
				i++;
			}
			else if (B <= sum) {
				break;
			}
			else {
				sum = sum + (A - 1);
				i++;
			}
		}

		cout << i << endl;
	}
	return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define N_ALPHABET 26

int main() {
    string S; cin >> S;
    S = 'a' + S + 'a';
    i64 L = S.length();

    using P = pair<char, i64>;
    vector<P> ss;
    REP(i, L) {
        if (S[i] != 'x') ss.emplace_back(S[i], i);
    }

    REP(i, ss.size()) {
        if (ss[i].first != ss[ss.size() - 1 - i].first) {
            cout << -1 << endl;
            return 0;
        }
    }
    i64 cnt = 0;
    i64 r = ss.size() / 2;
    i64 l = (ss.size() - 1) / 2;
    while (0 < l) {
        i64 nl = l - 1;
        i64 nr = r + 1;
        cnt += abs(ss[l].second - ss[nl].second - (ss[nr].second - ss[r].second));
        l--;
        r++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 2532
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll [[maybe_unused]] = long long;
using ull [[maybe_unused]] = unsigned long long;
using ld [[maybe_unused]] = long double;

[[maybe_unused]] static constexpr int mod = (int)1e9 + 7;
[[maybe_unused]] static constexpr int inf = 100100100;
[[maybe_unused]] static constexpr ll linf = 1e18;
[[maybe_unused]] static constexpr double eps = 1e-9;
[[maybe_unused]] static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a) for (ll i = a; i >= 0; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A;
    A.pb(0);
    rep (i, N) {
        ll a;
        cin >> a;
        A.pb(a);
    }
    A.pb(0);
    ll S = 0;
    for (ll i = 1; i < N + 2; ++i) {
        S += abs(A[i] - A[i - 1]);
    }
    for (ll i = 1; i < N + 1; ++i) {
        if (A[i] <= min(A[i - 1], A[i + 1])) {
            cout << S - 2 * abs(A[i] - min(A[i - 1], A[i + 1])) << endl;
        } else if (max(A[i - 1], A[i + 1]) < A[i]) {
            cout << S - 2 * abs(A[i] - max(A[i - 1], A[i + 1])) << endl;
        } else {
            cout << S << endl;
        }
    }
}


Measured memory_bytes: 2164
# https://atcoder.jp/contests/abc057/tasks/abc057_c

def digits(n)
  n.to_s.size
end

n = gets.to_i

threshold = Math.sqrt(n).to_i

res = digits(n)
2.upto(threshold) do |i|
  if n % i == 0
    res = digits([i, n / i].max)
  end
  # break if current >= threshold
end
puts res

Measured memory_bytes: 1916
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v, w = LI()
        G[u-1].append((v - 1, w))
        G[v-1].append((u - 1, w))

    # print(G)

    ans = [-1] * N
    ans[0] = 0
    visited = [False] * N

    def dfs(c):
        visited[c] = True
        for n, w in G[c]:
            if not visited[n]:
                if w % 2 == 0:
                    ans[n] = ans[c]
                else:
                    ans[n] = 1 - ans[c]
                dfs(n)

    dfs(0)

    for i in ans:
        print(i)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 98520
// E - Roadwork
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int n, q, x;
	cin >> n >> q;
	vector<pair<int, pair<int, int> > > a(n);
	for (int i = 0; i < n; i++) cin >> a[i].second.first >> a[i].second.second >> a[i].first;
	set<pair<int, int> > d;
	for (int i = 0; i < q; i++) cin >> x, d.insert(make_pair(x, i));

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

	vector<int> ans(q, -1);
	for (int i = 0; i < n; i++) {
		int l = a[i].second.first - a[i].first, r = a[i].second.second - a[i].first;
		set<pair<int, int> >::iterator it = d.lower_bound(make_pair(l, -1));
		while (d.size() > 0 && it != d.end()) {
			if (it->first >= r) break;
			ans[it->second] = a[i].first;
			d.erase(it++);
		}
	}

	for (int i = 0; i < q; i++) cout << ans[i] << endl;
	return 0;
}


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

int a[26];

int main()
{
    ll h;
    cin >> h;
    ll x = h;
    ll cnt = 0;
    while(x != 0) {
        x /= 2;
        cnt++;
    }
    ll ans = 1;
    rep(i, cnt) {
        ans *= 2;
    }
    cout << ans - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
#define PI 3.141592653589793
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};


using namespace std;
using Graph = vector< vector<int> > ;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (s.length() <= k){
        cout << s << endl;
    }else{
        cout << s.substr(0,k) << "..." << endl;
    }

        
}

Measured memory_bytes: 3608
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    let p = new Array(n).fill(0)
    let a = []
    let b = []
    while (hasNext()) {
        let tmp = nextIntArray()
        a.push(tmp[0])
        b.push(tmp[1])
    }
    let cnt = 0
    for (let i = n - 1; i >= 0; i--) {
        let tmp = a[i] + cnt
        if(tmp % b[i] == 0){
            continue
        } else if (tmp < b[i]){
            cnt += b[i] - tmp
        } else {
            cnt += b[i] - (tmp % b[i])
        }
        tmp += p[i]
    }
    console.log(cnt)
}
Main()



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

using namespace std;

int n, m, k;
vector<vector<int>> g, blk;
vector<int> cc;
map<int, set<int>> grp;

void dfs(int i, int num)
{
    cc[i] = num;
    for (int v: g[i]) {
        if (cc[v] == 0) dfs(v, num);
    }
}

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

    cin >> n >> m >> k;
    g.resize(n), blk.resize(n), cc.resize(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for (int i = 0; i < k; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        blk[u].push_back(v);
        blk[v].push_back(u);
    }

    int num = 1;
    for (int i = 0; i < n; ++i) {
        if (cc[i] == 0) {
            dfs(i, num);
            num++;
        }
    }

    for (int i = 0; i < n; ++i) grp[cc[i]].insert(i);
    for (int i = 0; i < n; ++i) {
        int val = grp[cc[i]].size() - g[i].size() - 1;
        for (int v: blk[i]) {
            if (grp[cc[i]].count(v)) --val;
        }
        cout << val << ' ';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 22144
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

#define MAX 1000002

int Lv[MAX], A[MAX], newLv[MAX];
int n, k;
std::string T;

bool cmp_Lv(const int i, const int j){ return Lv[i] < Lv[j]; }

bool cmp(const int i, const int j){
	if(Lv[i] != Lv[j]){ return Lv[i] < Lv[j]; }
	int L_i = (i + k >= n ? -1 : Lv[i + k]);
	int L_j = (j + k >= n ? -1 : Lv[j + k]);

	return L_i < L_j;
}

int main()
{
	std::cin >> T;
	n = T.size();

	int i;
	for(i = 0; i < n; i++){ A[i] = i; }
	for(i = 0; i < n; i++){ Lv[i] = T[i]; }
	std::sort(A, A + n, cmp_Lv);

	newLv[A[0]] = 0;
	for(i = 1; i < n; i++){
		newLv[A[i]] = newLv[A[i - 1]] + (Lv[A[i]] != Lv[A[i - 1]] ? 1 : 0);
	}
	for(i = 0; i < n; i++){ Lv[i] = newLv[i]; }

	k = 1;
	while(1){
		if(k > n) break;

		std::sort(A, A + n, cmp);
		newLv[A[0]] = 0;
		for(i = 1; i < n; i++){ newLv[A[i]] = newLv[A[i - 1]] + (cmp(A[i - 1], A[i]) ? 1 : 0); }
		for(i = 0; i < n; i++){ Lv[i] = newLv[i]; }

		if(Lv[A[n - 1]] == n - 1) break;
		k <<= 1;
	};

	std::string P;
	int q, left, right, mid, crit;
	bool exist;
	scanf("%d", &q);

	A[n] = n;

	while(q){
		std::cin >> P;
		left = 0, right = n, exist = false;
		while(left < right){

			if(n < P.size()){ exist = false; break; }

			mid = (left + right) / 2;
			crit = T.compare(A[mid], P.size(), P);

			if(crit > 0){ right = mid; }
			else if(crit < 0){ left = mid + 1; }
			else{ exist = true; break; }
		};
		if(T.compare(A[right], P.size(), P) == 0) exist = true;
		if(exist){ printf("1\n"); }else{ printf("0\n"); }
		q--;
	}
	return 0;
}

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

using namespace std;
#define ll long long
#define ull unsigned ll
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
const int N = 1e6 + 10;
const ll M = 998244353;
ll dp[N] = {};
ll bit[N] = {};
int n;

void add(int idx, ll val) {
    while (idx < N) {
        bit[idx] = (bit[idx] + val + M) % M;
        idx += idx & -idx;
    }
}

void range_add(int l, int r, ll val) {
    if (l > n)
        return;
    if (r > n)
        r = n;
    add(l, val);
    add(r + 1, -val);
}

ll query(int idx) {
    ll sum = 0;
    while (idx > 0) {
        sum = (sum + bit[idx]) % M;
        idx -= idx & -idx;
    }
    return sum;
}

int main() {
    int k;
    cin >> n >> k;
    vector<pii> v(k);
    for (int i = 0; i < k; ++i) {
        cin >> v[i].first >> v[i].second;
    }

    range_add(1, 1, 1);

    for (int i = 1; i < n; ++i) {
        ll curr = query(i);
        for (auto x : v) {
            range_add(i + x.first, i + x.second, curr);
        }
    }
    cout << query(n) << endl;
}

Measured memory_bytes: 5168
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, K;
    cin >> N >> K;
    vi A(N);
    REP(i, N) cin >> A[i];
    sort(ALL(A));

    int ans = 0;
    REP(i, K) ans += A[i];

    print(ans);
    
}


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

string ans[11][5] = {
  {"wa","","nn","","wo"},
  {"a","i","u","e","o"},
  {"ka","ki","ku","ke","ko"},
  {"sa","si","su","se","so"},
  {"ta","ti","tu","te","to"},
  {"na","ni","nu","ne","no"},
  {"ha","hi","hu","he","ho"},
  {"ma","mi","mu","me","mo"},
  {"ya","","yu","","yo"},
  {"ra","ri","ru","re","ro"}
};

int main(){

  string str;
  cin >> str;
  //int k = str[0];
  //cout << k << endl;;
  for(int i = 1; i <= str.size(); i+=2){
    if(str[i] == 'T'){
      int k = str[i-1]-48;
      cout << ans[k][0];
    }else     if(str[i] == 'L'){
      int k = str[i-1]-48;
      cout << ans[k][1];
    }else     if(str[i] == 'U'){
      int k = str[i-1]-48;
      cout << ans[k][2];
    }else     if(str[i] == 'R'){
      int k = str[i-1]-48;
      cout << ans[k][3];
    }else     if(str[i] == 'D'){
      int k = str[i-1]-48;
      cout << ans[k][4];
    }

  }
    cout << endl;


}

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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf LLONG_MAX

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

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

    ll test=1;
    //cin>>test;
    while(test--)
    {
        string s,t;
        cin>>s>>t;
        
        string sb=t.substr(0,t.length()-1);
        
        if(sb==s)
        cout<<"Yes";
        else
        cout<<"No";
    }
}














Measured memory_bytes: 3656
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
public class Hello{
    public static void Main(){
        // Your code here!
        //var n = int.Parse(Console.ReadLine());
        //string str = Console.ReadLine();
        string str = Console.ReadLine();
        string ans = "";
        //var t = Console.ReadLine();
        if(str.Equals(str.ToUpper())){
            ans = "A";
        }
        else{
            ans = "a";
        }
        
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 17392