akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>

using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main(){
    int M,N,X;
    cin>>N>>M>>X;
    
    ll C[N];
    ll A[N][M];
    ll Al_SUM[M];
    
    ll C_SUM=0;
    ll min;
    ll min_inf;

    
    for(int i=0;i!=N;++i){
        cin>>C[i];
        for(int j=0;j!=M;++j){
            cin>>A[i][j];
        }
    }
    
    for(int i=0;i!=M;++i) Al_SUM[i]=0;
    for(int i=0;i!=N;++i) min_inf+=C[i];
    min=min_inf;
   /*
    for(int i=0;i!=N;++i){
        for(int j=0;j!=M;++j){
            cout<<"A["<<i<<"]["<<j<<"]"<<A[i][j]<<" ";
        }
    }
    cout<<endl;
    */
    
    
    for(int bit=0;bit<(1<<N);++bit){

        for(int i=0;i<N;++i){        //iは本の冊数
            if(bit>>i&1){
                for(int j=0;j!=M;++j){
                    Al_SUM[j]+=A[i][j];
                    //cout<<"Al_SUM["<<j<<"]:"<<Al_SUM[j]<<endl;
    
                }
                C_SUM+=C[i];
                //cout<<C_SUM<<endl;
            }
        }
        //for(int i=0;i!=M;++i)cout<<"Al_SUM["<<i<<"]:"<<Al_SUM[i]<<endl;
        bool ok=true;
        for(int j=0;j!=M;++j){
            if(Al_SUM[j]<X){
                ok=false;
                //cout<<flag<<endl;
                break;
            }else{
                
            }
        }
        if(ok){
        min=(C_SUM<min)?C_SUM:min;
        }
        for(int j=0;j!=M;++j)Al_SUM[j]=0;
        C_SUM=0;
    }
    
    //cout<<"flag:"<<flag<<endl;
    
    if(min!=min_inf){
        cout<<min<<endl;
       
    }else{
         cout<<-1<<endl;
    }
    
}



Measured memory_bytes: 3616
s = input()
t = input()

flag = 0

if(len(t)> len(s)):
    print("UNRESTORABLE")
else:
    for i in reversed(range(len(s)-len(t)+1)):
        for j in range(len(t)):
            if(s[i+j] == t[j] or s[i+j] == "?"):
                if(j == len(t) -1):
                    flag = 1
                    break
            else:
                break

        if(flag == 1):
            break

    if(flag == 0):
        print("UNRESTORABLE")
    else:
        kotae = list(s[0:i] + t + s[i+len(t):])
        for i in range(len(kotae)):
            if(kotae[i] == "?"):
                kotae[i] = "a"
        kotae = "".join(kotae)
        print(kotae)

Measured memory_bytes: 62084
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;

int main(){
  map<int,bool>memo;
  int N;
  cin>>N;

  int cnt=0;

  for(int i=0;i<N;i++){
    int p[3];
    cin>>p[0]>>p[1]>>p[2];

    sort(p,p+3);

    int k=((p[0])*1000+(p[1]))*1000+(p[2]);

    if(memo.find(k)!=memo.end()){
      cnt++;
    }else{
      memo[k]=true;
    }
  }
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3200
# -*- coding: utf-8 -*-

import sys

a, b, c, d = map(int, input().split())

g = 0
gc = d

if d - a > 0 and a > 0:
    g += a
    d -= a
elif a > 0:
    g += d
    print(str(g))
    sys.exit()

if d - b > 0 and b > 0:
    d -= b
elif b > 0:
    print(str(g))
    sys.exit()

if d == c and c > 0:
    g -= d
elif c > 0:
    g -= d

print(str(g))


Measured memory_bytes: 9092
#include<stdio.h>

int main()
{
  int i,j;
  int G[10][10];
  char m[11];
  while(scanf("%s",m)!=EOF){
  for(i=0;i<10;i++){
    G[0][i]=(m[i]-'0');
  }
  for(i=0;i<9;i++){
    for(j=i;j<9;j++){
      G[i+1][j+1]=(G[i][j]+G[i][j+1])%10;
    }
  }
  printf("%d\n",G[9][9]);
  }
  return 0;
}

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

signed main(void)
{
	ll n;
	vector<char> out;
	cin >> n;
	while(n != 0)
	{
		n--;
		out.push_back('a' + n % 26);
		n /= 26;
	}
	reverse(out.begin(), out.end());
	rep(i, out.size()) cout << out[i];
	cout << endl;
	return 0;
}


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

int val[10010];
int wt[10010];
int max(int a, int b) { return (a > b) ? a : b; }

int main() {
	
	int W;
	int n;
	cin >> n >> W;
	for (int i = 0; i < n; i++) {
		cin >> val[i] >> wt[i];
	}
	int i, w;
	unsigned int K[10010] = {0};

	for (i = 0; i <= n; i++) {
		for (w = 1; w <= W; w++) {
			if (wt[i] <= w) {
				K[w] = max(val[i] + K[w - wt[i]], K[w]);   //changed from 0-1 problem
			}
		}
	}
	

	cout << K[W] << endl;
	return 0;

}

Measured memory_bytes: 3148
import java.util.Scanner;

public class Main {
    private static final long MOD = 1000000007L;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            char[][] t = new char[n][2];
            for (int i = 0; i < 2; i++) {
                String s = sc.next();
                for (int j = 0; j < n; j++) {
                    t[j][i] = s.charAt(j);
                }
            }
            System.out.println(solve(n, t));
        }
    }

    private static long solve(int n, char[][] t) {
        long[][][] dp = new long[n + 1][4][4];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if ( t[0][0] == t[0][1] ) {
                    if ( i == j ) {
                        dp[0][i][j] = 1;
                    }
                } else {
                    if ( i != j ) {
                        dp[0][i][j] = 1;
                    }
                }
            }
        }

        for (int i = 0; i < n - 1; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if ( dp[i][j][k] == 0 ) {
                        continue;
                    }

                    for (int nj = 0; nj < 3; nj++) {
                        for (int nk = 0; nk < 3; nk++) {
                            if ( t[i][0] == t[i + 1][0] ) {
                                if ( j == nj && k == nk ) {
                                    dp[i + 1][nj][nk] += dp[i][j][k];
                                    dp[i + 1][nj][nk] %= MOD;
                                }
                            } else {
                                if ( j != nj && k != nk ) {
                                    if ( t[i + 1][0] == t[i + 1][1] && nj == nk ||
                                        t[i + 1][0] != t[i + 1][1] && nj != nk ) {
                                        dp[i + 1][nj][nk] += dp[i][j][k];
                                        dp[i + 1][nj][nk] %= MOD;
                                    }
                                }
                            }
                        }
                    }

                }
            }
        }

        long ans = 0;
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                ans += dp[n - 1][j][k];
                ans %= MOD;
            }
        }

        return ans;
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int MOD = 1e9 + 7;

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

    long long n;
    cin >> n;

    vector<long long> A(n + 1, 0);
    for(int i = 2; i <= n; i++){
        int a = i, j = 2;
        while(a > 1){
            if(a % j) j++;
            else{
                a /= j;
                A[j]++;
            }
        }
    }

    long long ans = 1;
    for(int i = 2; i <= n; i++){
        if(A[i]) ans = (ans * (A[i] + 1)) % MOD;
    }
    cout << ans << endl;

    return 0;
}

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N; cin >> N;
    int K = 2;
    while(K*K-1 < 2*N) K++;
    if(K*(K-1) == 2*N){
        cout << "Yes" << endl;
        cout << K << endl;
        int ans[K][K-1];

        ans[0][0] = 1;
        int val1 = 1, val2 = 1;
        for(int i = 0; i < K; i++){
            for(int j = i; j < K-1; j++){
                ans[i][j] = val1;
                val1++;
            }
            for(int j = i+1; j < K; j++){
                ans[j][i] = val2;
                val2++;
            }
        }
        rep(i, K){
            cout << K-1 << " ";
            for(int j = 0; j < K-1; j++){
                if(j == K-2) cout << ans[i][j] << endl;
                else cout << ans[i][j] << " ";
            }
        }
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

void solve(){}

Measured memory_bytes: 2176
#include <stdio.h>

/*
1 bubbleSort(A, N) // N ??????????´?????????? 0-????????????????????? A
2   flag = 1 // ????????£??\????´?????????¨??????
3   while flag
4     flag = 0
5     for j ??? N-1 ?????? 1 ?????§
6       if A[j] < A[j-1]
7         A[j] ??¨ A[j-1] ?????????
8         flag = 1
 */

#define		MXPRG		100+10

int			bubbleSort( int *ARY , int );	//???????????°?????????

int			A[MXPRG];

int		main(void)
{
	int		i;
	int		N;
	int		chg;

	scanf("%d",&N);
	for(i=0; i<N; i++)
	{
		scanf("%d",&A[i]);
	}

	chg = bubbleSort( A , N);

	for(i=0; i<N-1; i++)
	{
		printf("%d",A[i]);
		printf(" ");
	}
	printf("%d",A[N-1]);
	printf("\n");
	printf("%d\n",chg);

	return 0;
}

int		bubbleSort( int ary[], int num )
{
	int		chg;
	int		flag;
	int		j;
	int		tmp;

	chg = 0;
	flag = 1;
	while(flag)
	{
		flag = 0;
		for( j=num-1; j>=1; j-- )
		{
			/*
			printf("ary[j]=%d ",ary[j]);
			printf("ary[j-1]=%d\n",ary[j-1]);
			*/

			if( ary[j] < ary[j-1] )
			{
				tmp = ary[j];
				ary[j] = ary[j-1];
				ary[j-1] = tmp;
				chg = chg + 1;
				flag =1;
			}
		}
	}

	//printf("%d\n",chg);
	return chg;
}

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

#define MOD 1000000007

int main(){
    int N;
    cin>>N;
    vector<int>v;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    bool flag=false;
    int prev;
    if(v.size()%2==0){
        for(int i=0;i<v.size();i++){
            if(i==0){
                if(v[i]!=1){
                    flag=true;
                    break;
                }
                prev=v[i];
            }else if(i%2==1){
                if(v[i]!=prev){
                    flag=true;
                    break;
                }
            }else if(i%2==0){
                if(v[i]!=prev+2){
                    flag=true;
                    break;
                }
                prev=v[i];
            }
        }
    }
    if(v.size()%2==1){
        for(int i=0;i<v.size();i++){
            if(i==0){
                if(v[i]!=0){
                    flag=true;
                    break;
                }
                prev=v[i];
            }else if(i%2==1){
                if(v[i]!=prev+2){
                    flag=true;
                    break;
                }
                prev=v[i];
            }else if(i%2==0){
                if(v[i]!=prev){
                    flag=true;
                    break;
                }
            }
        }
    }
    if(flag)cout<<0<<endl;
    else{
        int ans=1;
        for(int i=0;i<v.size()/2;i++){
            ans*=2;
            ans%=MOD;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 892
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Collections;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ir = new Resolver(new ConsoleReader());
            Console.WriteLine(ir.Resolve());
        }
    }

    public class Resolver
    {
        IInputReader InputReader { get; }
        public List<string> Messages { get; set; } = new List<string>();

        int n;
        List<long[]> ls = new List<long[]>();

        public void ParseLines() {
            n = int.Parse(InputReader.ReadLine());
            foreach (var i in Enumerable.Range(0, n))
            {
                ls.Add(InputReader.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray());
            }

        }

        public class Table
        {
            public long PointA { get; set; } = 0;
            Person A { get; }
            Person B { get; }
            int[] _dishes;

            public Table(Person a, Person b, int ndish)
            {
                this.A = a;
                this.B = b;
                this._dishes = Enumerable.Range(0, ndish).ToArray();
            }

            public long CalculatePoint()
            {
                PointA += _dishes
                .Select(x => A.Taste[x] + B.Taste[x])
                .OrderBy(x => -x)
                .Where((x, i) => i % 2 == 0)
                .Sum();

                PointA -= B.Taste.Values.Sum(x => x);
                return PointA;
            }


        }


    public class Person{
            public Dictionary<int, long> Taste { get; }
            public long HappyScore { get; set; } = 0;

            public Person(Dictionary<int, long> taste)
            {
                Taste = taste;
            }

        }


        public string Resolve()
        {
            var range = Enumerable.Range(0, n);

            var a = new Person(range.ToDictionary(i => i, i => ls[i][0]));
            var b = new Person(range.ToDictionary(i => i, i => ls[i][1]));

            var table = new Table(a, b, n);

            return table.CalculatePoint().ToString();
        }


        public Resolver(IInputReader inputReader)
        {
            InputReader = inputReader;
            ParseLines();
        }

    }

    public interface IInputReader
    {
        string ReadLine();
    }

    class ConsoleReader : IInputReader
    {
        string IInputReader.ReadLine()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 38088
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main(void)
{
  unsigned short *A, *B;
  
  int C[VMAX+1];
  int n, i, j;
  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=0;i<=VMAX;i++) C[i] = 0;
  
  for(i=0;i<n;i++) {
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  
  for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];
  
  for(j=1;j<=n;j++) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i=1;i<=n;i++) {
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 9584
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M,X;
vector<int> C;
vector<vector<int>> A;
void input(){
    fast_io();
    cin >> N >> M >> X;
    A.assign(N,vector<int>(M,0));
    for (int i = 0; i < N; i++)
    {
        int c; cin >> c;
        C.push_back(c);
        for (int j = 0; j < M; j++) cin >> A[i][j];
    }
}

bool isok(int bit){
    vector<int> rikai(M,0);
    for (int i = 0; i < N; i++)
    {
        if((bit>>i)&1) {
            for (int j = 0; j < M; j++) rikai[j] += A[i][j];            
            }
    }
    for(int r:rikai) if(r<X) return false;
    return true;    
}

int cost_al(int bit){
    int ret = 0;
    for (int i = 0; i < N; i++)
    {
        if((bit>>i)&1) ret += C[i];
    }
    return ret;    
}

int solve(){
    int ans = INT_INF;
    for (int bit = 0; bit < (1<<N); bit++)
    {
        if(isok(bit)){
            ans = min(ans,cost_al(bit));
        }
    }
    if(ans==INT_INF) ans=-1;
    cout << ans << endl;
    return 0;
}   

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

Measured memory_bytes: 3668
import math
N=int(input())
m=int(len(str(N)))
for j in range(1,int(math.sqrt(N))+2):
    if N%j==0:
        a=j
        b=N//j
        m1=len(str(max(a,b)))
        m=min(m,m1)
print(m)


Measured memory_bytes: 38768
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int k,s;
    cin >> k >> s;
    int ans = 0;
    rep(i,k+1) rep(j,k+1) {
        if(i+j > s) continue;
        if(s-i-j > k) continue;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

typedef pair<long long,long long> pr;

inline long long read()
{
	long long x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}

inline void chkmax(long long &a,long long b){if(a<b)a=b;}

inline bool cmp(pr a,pr b)
{
	return a.first-a.second<b.first-b.second;
}

const long long N=1e5+9;

priority_queue<long long,vector<long long>,greater<long long> > q;
long long x,y,z,f[N],g[N],ans;
pr p[N];

int main()
{
	if(fopen("vj.in","r"))
	{
		freopen("vj.in","r",stdin);
		freopen("vj.out","w",stdout);
	}

	x=read();y=read();z=read();
	for(long long i=1,a,b,c;i<=x+y+z;i++)
	{
		a=read();b=read();c=read();
		p[i]=pr(a-c,b-c),ans+=c;
	}
	sort(p+1,p+x+y+z+1,cmp);

	f[0]=0;
	for(long long i=1;i<=y+z;i++)
	{
		q.push(p[i].second);
		f[i]=f[i-1]+p[i].second;
		if(y<i)
			f[i]-=q.top(),q.pop();
	}
	while(!q.empty())q.pop();
	g[x+y+z+1]=0;
	for(long long i=x+y+z;i>y;i--)
	{
		q.push(p[i].first);
		g[i]=g[i+1]+p[i].first;
		if(i<=y+z)
			g[i]-=q.top(),q.pop();
	}

	long long tans=f[y]+g[y+1];
	for(int i=y+1;i<=y+z;i++)
		chkmax(tans,f[i]+g[i+1]);

	printf("%lld\n",ans+tans);
	return 0;
}


Measured memory_bytes: 3704
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
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 main(){
    int n,k;
    cin >> n >> k;
    vector<int>a(n);
    rep(i,n){
        cin >> a[i];
    }
    vector<int> pre = a;
    rep(i,k){
        if(i!=0){
            if(a==pre)break;
        }
        pre = a;
        vector<int>b(n+1);
        rep(j,n){
            int k = max(0,j-a[j]);
            int l = min(n,j+a[j]+1);
            b[k]++;
            b[l]--;
        }
        rep(j,n){
            b[j+1] += b[j];
        }
        rep(j,n){
            a[j] = b[j];
        }
    }
    rep(i,n)cout << a[i] << " ";
    cout <<"\n";
    return 0;
}

Measured memory_bytes: 5288
N,K = gets.split.map &:to_i
es = (0..N).map{ {} }
rs = (0..N).map{ {} }
(N-1).times{
  a,b = gets.split.map &:to_i
  es[a][b] = es[b][a] = 1
}

ans = 1
Mod = 10**9+7
queue = [0,1]
Visited = Array.new(N+1,false)
VisitedNext = Array.new(N+1, 0)
while queue.size > 0 do
  n = queue.pop
  break if n == 0
  if Visited[n]
    VisitedNext[n] += 1
  else 
    Visited[n] = true
#    p [queue[-1], n, VisitedNext[queue[-1]], ans]
    ans = (ans * [K-VisitedNext[queue[-1]], 0].max) % Mod
    VisitedNext[n] = (queue[-1] == 0 ? 0 : 1) + 1
    es[n].keys.each{ |m|
      next if Visited[m]
      queue << n; queue << m
    }
  end
end

p ans

Measured memory_bytes: 56248
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include <iostream>
#include<string.h>     
#include<algorithm>
#define ll long long
#define hengheng main ()
int i,j,n,m,k,sum,count,x,y,t;
int a[10000];
using namespace std;

int hengheng
{
	while(scanf("%d",&n)!=EOF)
	{
		sum=0;
		for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
		i=1;
		while(100)
		{
			i=1;
			while(i<=n)
			{
				k=10000;
				x=i;
				for(i;i<=n;i++)
					{
						if(a[i]<=0)
						break;
						if(k>=a[i]) k=a[i];		
					}
			//	printf("%d\n",k);
				i++;
				if(k>1000) k=0;
				sum+=k;
				for(x;x<i-1;x++)
					{
						a[x]-=k;
					}
			//	for(t=1;t<=n;t++) printf("%d  ",a[t]);
			}
			//printf("%d\n",k);
			int flag=0;
			for(t=1;t<=n;t++)
			{
				if(a[t]!=0)
				flag=1;
			}
			
			if(flag==0) break;
		}
		printf("%d\n",sum);
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define UMap        std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd   ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm   ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs   ( llong n )          { return ( n < 0 ) ? -n : n; }
    template<class A, class B>inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B>inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    Vi vi;

    signed call_of_Cthulhu( signed datum ) {

        int n;
        read n;
        for ( int i = 0; i < n; i++ ) {
             int a;
             read a;
             vi.bash ( a );
        }
        int sum = 0;
        bozo_sort(alles(vi));
        for ( int i = 0; i < n-1; i++ ) {
            sum += vi[i];
        }
        if ( vi[n-1] < sum ) {
            echo "Yes" fin;
        }
        else {
            echo "No" fin;
        }

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char& ch) {
	string s = "";
	s += ch;
	return "'" + s + "', ";
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL_DEFINE
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
   
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
typedef pair<int, int> pii;
const int mod = (int) 1000000007; // 998244353;
const int inf = (int) 2e18;



int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	int n;
	cin >> n;
	vector<int> a(n);
	map<int, int> mp;
	int su = 0;
	for(auto& x : a)
	{
		cin >> x;
		su += x;
		++ mp[x];
	}
	debug(su);
	int q;
	cin >> q;
	while(q --)
	{
		int b, c;
		cin >> b >> c;
		int fb = mp[b];
		int fc = mp[c];
		mp[b] = 0;
		mp[c] += fb;
		su -= fb * b;
		su += fb * c;
		cout << su << '\n';
	}
	
	return 0;
}






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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


 
signed main() {
    int A, B, K;
    cin>>A>>B>>K;

    rep(i,K){
        if(i%2==0){
            if(A%2==1) A--;
            B+=A/2;
            A/=2;
        }else{
            if(B%2==1) B--;
            A+=B/2;
            B/=2;
        }
    }
    cout << A << " " << B << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int n;
    int i, x;
    scanf("%d", &n);
    for(i=3; i<=n; i++){
        x = i/10;
        if(i/10%10 == 3 || i/10/10%10 == 3 || i/10/10/10%10 == 3){
            printf(" %d", i);
        }else if(i%10 == 3 || i%3 == 0){
            printf(" %d", i);
        }
    }
    printf("\n");
    return 0;
}

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

using namespace std;

int main()
{
    int n;
    long long s, x = 0, a_1, a_2;
    cin >> n >> a_1 >> a_2;
    s = a_1 + a_2;

    for (int i = 2; i < n; i++) 
    {
        long long a;
        cin >> a;
        x ^= a;
    }
    
    if (s - x < 0 || (s - x) % 2 == 1) 
    {
        cout << -1;
        return 0;
    }
    
    long long d = (s - x) / 2;
    if (d > a_1 || (d & x) != 0) 
    {
        cout << -1;
        return 0;
    }
    
    long long y = 0;
    for (int i = 45; i >= 0; i--) 
    {
        const long long x_i = x & (1LL << i);
        if (x_i > 0 && (d ^ (y + x_i)) <= a_1)
        {
            y += x_i;
        }
    }
    
    if ((d ^ y) == 0) 
    {
        cout << -1;
        return 0;
    }
    
    cout << a_1 - (d ^ y);
}


Measured memory_bytes: 3608
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int c = Integer.parseInt(sc.next());
    if(a + b + c > 21) System.out.println("bust");
    else System.out.println("win");
  }
}


Measured memory_bytes: 22228
#include<bits/stdc++.h>
#define ll long long
#define ii pair<ll,int>
using namespace std;

struct DSU {
    vector <int> P, R;
    DSU (int n) {
        P.resize(n), R.resize(n);
        for (int i = 0; i < n; i++) {
            P[i] = i, R[i] = 1;
        }
    }

    int find(int x) {return x == P[x] ? x : P[x] = find(P[x]);}

    bool unionS (int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return false;

        if (R[y] > R[x]) swap(x, y);
        R[x] += R[y];
        P[y] = x;
        return true;
    }
};
struct edge {
    int u, v;
    ll w;
    bool operator<(const edge & E) const {
        return w < E.w;
    }
};

int main(){
    int k,x;cin>>k>>x;
    for(int i =(x-k)+1;i < x+k;i++){
        cout<<i<<" ";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {

	int a,b,c;
	cin >> a >> b >> c;

	// ?????????????´?
	int arr[3] = {a, b, c};

	// ?????????
	sort(arr, arr + 3);
	cout << arr[0] << " " << arr[1] << " " << arr[2] << endl;


	return 0;
}

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

int main() {
  int64_t n, k;
  cin >> n >> k;
  vector<int64_t> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  int64_t lowest = -2e18, highest = 2e18;
  for (;;) {
    int64_t half = (highest + lowest) / 2, count = 0; // half以下になるペアの個数
    for (int i = 0; i < n - 1; i++) {
      if (a.at(i) < 0) {
        int64_t r = half / a.at(i);
        if (r * a.at(i) > half) r++;
        count += a.end() - lower_bound(a.begin() + i + 1, a.end(), r);
      } else if (a.at(i) == 0) {
        if (half >= 0) count += n - i - 1;
      } else {
        int64_t r = half / a.at(i);
        if (r * a.at(i) > half) r--;
        count += upper_bound(a.begin() + i + 1, a.end(), r) - (a.begin() + i + 1);
      }
    }
    if (count < k) {
      lowest = half;
    } else {
      highest = half;
    }
    if (highest - lowest == 1) break;
  }
  cout << highest << endl;
}


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

int main() {
    long long X;
    cin >> X;
    long long money = 100;
    int year = 0;
    
    while(1){
        if(money >= X){
            break;
        }
        money = money * 1.01;
        year++;
    }
    cout << year << endl;
	return 0;
}

Measured memory_bytes: 3228
# coding: utf-8
# Your code here!

N, M = map(int,input().split())
li = [list(map(int,input().split())) for i in range(M)]
L = [li[j][0] for j in range(M)]
R = [li[k][1] for k in range(M)]
ctr = 0

if min(R) - max(L) >= 0:
    print(min(R) - max(L) + 1)
else:
    print(0)

Measured memory_bytes: 29032
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,w;
	cin>>n>>w;
	long long we[n+1];
	long long v[n+1];
	we[0]=v[0]=0;
	for(long long i=1;i<=n;i++)
	cin>>we[i]>>v[i];
	long long dp[n+1][w+1];
	for(long long i=0;i<=n;i++)
	{
		for(long long j=0;j<=w;j++)
		{
			dp[i][j]=0;
		}
    }	
	for(long long i=1;i<=n;i++)
	{
		for(long long j=1;j<=w;j++)
		{
			if((j-we[i])>=0)
			dp[i][j]=max(dp[i-1][j-we[i]]+v[i],dp[i-1][j]);
			else
			dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][w];
	return 0;
}

Measured memory_bytes: 79104
import sys

def gcd(a, b):
    if a < b:
        a, b = b, a
    while b:
        a, b = b, a % b
    return a



def lcm(a, b):
    return a * b // (gcd(a, b))



def main():
    A, B, C, D = map(int, input().split())
    Aone = A - 1
    CDlcm = lcm(C, D)

    Bc = B // C
    Bd = B // D
    Blcm = B // CDlcm
    Bdec = B - Bc - Bd + Blcm

#    print(Bc,Bd,Blcm)

    Ac = Aone // C
    Ad = Aone // D
    Alcm = Aone // CDlcm
    Adec = Aone - Ac - Ad + Alcm

#    print(Ac,Ad,Alcm)

    print(Bdec - Adec)


main()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
typedef long long ll;
const int INF = 1e9 + 7;
using namespace std;

int main(){
    int H,N; cin >> H >> N;
    ll ans;
    rep(i,N){
        int A;cin >> A;
        ans+=A;
    }
    if (ans>=H) cout << "Yes";
    else cout << "No";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    string s;
    cin>>s;
    if(s=="SUN") cout<<7;
    else if(s=="MON") cout<<6;
    else if(s=="TUE") cout<<5;
    else if(s=="WED") cout<<4;
    else if(s=="THU") cout<<3;
    else if(s=="FRI") cout<<2;
    else if(s=="SAT") cout<<1;
}

Measured memory_bytes: 3580
N=int(input())
As=list(map(int,input().split()))

s=0
d={}
for i,Ai in enumerate(As):
    s+=Ai
    if Ai in d:
        d[Ai]+=1
    else:
        d[Ai]=1

Q=int(input())
for i in range(Q):
    b,c = map(int,input().split())
    if b in d:
        nb=d[b]
        d[b]=0
        s-=nb*b
        if c in d:
            d[c]+=nb
        else:
            d[c]=nb
        s+=nb*c
    print(s)

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

int main(void) {
    int n,m,city;
    cin >> n >> m;
    vector<int> cap(n);
        
    rep(i,m*2){
        cin >> city;
        // the array counts from 0 so subscript is (city-1)
        //Count number of cap.at(0) AND cap.at(1)~~~     Increase array element values
       /* cap.at(city-1)=cap.at(city-1)+1; */
       cap.at(city-1)++;
        }
    rep(i,cap.size()) {
        cout << cap.at(i) << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
const ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  int D[N][2];
  bool ans = false;
  for (int i = 0; i < N; i++) {
    cin >> D[i][0] >> D[i][1];
  }
  for (int i = 0; i < N-2; i++) {
    if (D[i][0] == D[i][1] && D[i+1][0] == D[i+1][1] && D[i+2][0] == D[i+2][1]) {
      ans = true;
    } 
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

string s;
int ans;

int main()
{
	cin>>s;
	int l=s.length();
	for(int i=1;i<l;i++)
		if(s[i]!=s[i-1]) ans++;
	cout<<ans<<endl;
	return 0;
}

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

const int MOD = (int)1e9+7;

int main(){
	int X,Y,Z,K;
	cin >> X >> Y >> Z >> K;
	vector<long long> A(X);
	vector<long long> B(Y);
	vector<long long> C(Z);
	for(int i=0;i<X;i++)	cin >> A.at(i);
	for(int i=0;i<Y;i++)	cin >> B.at(i);
	for(int i=0;i<Z;i++)	cin >> C.at(i);

	sort(A.begin(),A.end(),greater<long long>());
	sort(B.begin(),B.end(),greater<long long>());
	sort(C.begin(),C.end(),greater<long long>());

	vector<long long> AB;
	for(int i=0;i<X;i++){
		for(int j=0;j<Y;j++){
			AB.push_back(A.at(i)+B.at(j));
		}
	}

	sort(AB.begin(),AB.end(),greater<long long>());
	vector<long long> ABC;
	int size=min(K,X*Y);
	for(int i=0;i<size;i++){
		for(int j=0;j<Z;j++){
			ABC.push_back(AB.at(i)+C.at(j));
		}
	}
	
	sort(ABC.begin(),ABC.end(),greater<long long>());
	for(int i=0;i<K;i++){
		cout << ABC.at(i) << endl;
	}
	
	return 0;
}


Measured memory_bytes: 43240
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	for i := 0; i < k; i++ {
		if i%2 == 0 {
			if a%2 == 1 {
				a--
			}
			b += a / 2
			a /= 2
		} else {
			if b%2 == 1 {
				b--
			}
			a += b / 2
			b /= 2
		}
	}
	fmt.Println(a, b)
}


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

int main(){
  int s, w;
  cin >> s >> w;
  cout << (w >= s ? "unsafe" : "safe") << endl;
  return 0;
}


Measured memory_bytes: 3636
N, M = map(int,input().split())
X = list(map(int, input().split()))
X.sort()
Xd = [0] * (M-1)
for i in range(M-1):
  Xd[i] = X[i+1] - X[i]

Xd.sort()

if N>=M:
  print(0)
else:
  print(sum(Xd[0:M-N]))

Measured memory_bytes: 13960
#include <bits/stdc++.h>
using namespace std;
#define ALL(a)  (a).begin(),(a).end()

int root(int x, vector<int> &par){
  //自分自身が根
  if(par.at(x) < 0) return x;
  
  //親の根を親にする
  par.at(x) = root(par.at(x), par);
  return par.at(x);
}

void unite(int x, int y, vector<int> &par){
  x = root(x, par); y = root(y, par);
  if(x == y) return;
  
  if(par.at(x) < par.at(y)) swap(x, y);
  //サイズが小さいxをyに連結
  par.at(y) += par.at(x);
  par.at(x) = y;
  return;
}

bool same(int x, int y, vector<int> &par){
  if(root(x, par) == root(y, par)) return true;
  return false;
}

int main(){
  int N, M, K;
  cin >> N >> M >> K;
  vector<int> par(N, -1);
  //最初は根。根はサイズの負の数で表す。

  vector<vector<int>> fri(N, vector<int>(0));
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    unite(a, b, par);
    fri.at(a).push_back(b);
    fri.at(b).push_back(a);
  }

  //ブロック関係
  vector<vector<int>> blo(N, vector<int>(0));
  for(int i = 0; i < K; i++){
    int c, d;
    cin >> c >> d;
    c--; d--;
    blo.at(c).push_back(d);
    blo.at(d).push_back(c);
  }


  for(int i = 0; i < N; i++){
    int result = -1 * par.at(root(i, par)) - 1 - fri.at(i).size(); //友達でつながっている全員から自分自身とすでに友達の人とブロック関係の人を引く。
    for(int j = 0; j < blo.at(i).size(); j++){
      if(same(i, blo.at(i).at(j), par)) result--;
    }
    cout << result << ' ' << endl;
  }
}

Measured memory_bytes: 12280
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

int main(void)
{
    string s;
    cin >> s;
    
    irep(i, s.size()) {
        cout << "x";
    }
    return 0;
}
/** atcoder **/


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 524388
#define MOD 924844033
using namespace std;
typedef long long ll;
struct node{
	int x;
	node *nxt;	
}edge[MAXN*2];
node *head[MAXN],*ncnt=edge;
void add_edge(int x,int y){
	ncnt++;
	ncnt->x=y;
	ncnt->nxt=head[x];
	head[x]=ncnt;	
}
ll f[MAXN],g[MAXN];
ll G=5;
int u,v;
ll fsp(ll x,int y){
	ll res=1;
	while(y){
		if(y&1)
			res=res*x%MOD;
		x=x*x%MOD;
		y>>=1;
	}
	return res;
}
void ntt(ll a[],int N,int flag){
	int i,j,k;
	for(i=1,j=0;i<N;i++){
		for(int d=N;j^=d>>=1,~j&d;);
		if(i<j)
			swap(a[i],a[j]);	
	}
	for(i=1;i<N;i<<=1){
		ll wn=fsp(G,(MOD-1)/(i<<1));
		if(flag==0)
			wn=fsp(wn,MOD-2);
		for(j=0;j<N;j+=i<<1){
			ll w=1;
			for(k=0;k<i;k++,w=w*wn%MOD){
				ll x=a[j+k],y=w*a[i+j+k]%MOD;
				a[j+k]=(x+y)%MOD;
				a[i+j+k]=(x-y+MOD)%MOD;
			}
		}
	}
	if(flag==0){
		ll inv=fsp(N,MOD-2);
		for(i=0;i<N;i++)
			a[i]=a[i]*inv%MOD;
	}
}
int siz[MAXN];
int cnt[MAXN];
int n;
void dfs(int x,int f){
	siz[x]=1;
	for(node *v=head[x];v!=NULL;v=v->nxt){
		int u=v->x;
		if(u==f)
			continue;
		dfs(u,x);
		cnt[siz[u]]++;
		cnt[n-siz[u]]++;
		siz[x]+=siz[u];
	}
}
ll fac[MAXN],ifac[MAXN];
int main(){
	SF("%d",&n);
	for(int i=1;i<n;i++){
		SF("%d%d",&u,&v);
		add_edge(u,v);
		add_edge(v,u);
	}
	dfs(1,0);
	for(int i=1;i<n;i++)
		cnt[i]=MOD-cnt[i];
	cnt[n]=n;
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=fac[i-1]*i%MOD;
	ifac[n]=fsp(fac[n],MOD-2);
	for(int i=n;i>=1;i--)
		ifac[i-1]=ifac[i]*i%MOD;
		
	for(int i=1;i<=n;i++)
		f[n-i]=cnt[i]*fac[i]%MOD;
	for(int i=0;i<=n;i++)
		g[i]=ifac[i];
	int len=1;
	while(len<=n*2)
		len<<=1;
	/*for(int i=0;i<n;i++){
		ll res=0;
		for(int j=0;j<=i;j++)
			res=(res+f[j]*g[i-j])%MOD;
	}*/
	ntt(g,len,1);
	ntt(f,len,1);
	for(int i=0;i<len;i++)
		g[i]=g[i]*f[i]%MOD;
	ntt(g,len,0);
	for(int i=1;i<=n;i++)
		PF("%lld\n",g[n-i]*ifac[i]%MOD);
}

Measured memory_bytes: 36224
N = int(input())
S = [input() for _ in range(N)]

C0 = 0  # AC
C1 = 0  # WA
C2 = 0  # TLE
C3 = 0  # RE

for target_str in range(N):
    if S[target_str] == "AC":
        C0 = C0 + 1
    elif S[target_str] == "WA":
        C1 = C1 + 1
    elif S[target_str] == "TLE":
        C2 = C2 + 1
    else:
        C3 = C3 + 1

print("AC x {}".format(C0))
print("WA x {}".format(C1))
print("TLE x {}".format(C2))
print("RE x {}".format(C3))



Measured memory_bytes: 16296
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    int n,m;
   
    cin >> n >> m;
    vector<int> a(m),b(m),cnt(n);

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

    for(int i=0;i<m;i++){
        cnt[a[i]-1]++;
        cnt[b[i]-1]++;
    }
    
    for(int i=0;i<n;i++){
        cout << cnt[i] << endl;
    }
    //cout << (flag ? "Yes" : "No");
    //cout << ans;
    //printf("%.10f",ans_d);

    cout << endl;
}


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

typedef long long ll;

const int maxn = 2e5 + 100;

ll s[maxn];

ll a[maxn];

int main()
{
    int n,k;
    cin >> n >> k;
    for(int i = 1; i <= n ; i++)
    {
        cin >> a[i];
        s[i] = (s[i-1] + a[i]); 
    }
    for(int i = 1; i <= n ; i++)
    {
        s[i] = (s[i] - i) % k;
    }
    
    map<ll,ll>cnt;
    ll ans = 0;
    for(int i = 0; i <= n ; i++)
    {
        ans += cnt[s[i]];
        cnt[s[i]]++;
        if(i - k + 1 >= 0)
            cnt[s[i - k + 1]]--;
    }

    printf("%lld\n",ans);

    return 0;
}

Measured memory_bytes: 15872
# -*- coding: utf-8 -*-

n = int(input())
strings = input()

newStr = ''
for i in range(len(strings)):
    nextAlpha = ord(strings[i]) + n
    if nextAlpha <= 90:
        newStr += chr(nextAlpha)
    else:
        nextAlpha -= 91
        newStr += chr(65 + nextAlpha)
        
print(newStr)       

Measured memory_bytes: 3060
#include <iostream>
#include<stdio.h>
#include <cmath>
using namespace std;
int main(){

    while(true){
        int n;
        cin>>n;
        
        if(n==0)break;
        
        int ten[n];
        double ave=0;
        int i=0;
        
        while(i<n){
            cin>>ten[i];
            ave=ave+ten[i];
            i++;
        }
        
        ave=ave/i;
        double ans=0;
        
        for(int j=0;j<n;j++){
            ans+=pow(ten[j]-ave,2);
        }
        ans=sqrt(ans/i);
        printf("%f\n",ans);
        
    }
return 0;
}



Measured memory_bytes: 3176