akhauriyash/Code-Regression huggingface dataset:
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    n = inp()
    print(0.5 if n % 2 == 0 else 1 - ((n // 2) / n))
            
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1],1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)

def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))

def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()

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

using namespace std;

string s, t;
int szs, szt, ans = 0;
int mem[3001][3001];

string trace(int pos1, int pos2) {
	if (pos1 == 0 || pos2 == 0)
		return "";
	else if (s[pos1 - 1] == t[pos2 - 1])
		return s[pos1 - 1] + trace(pos1 - 1, pos2 - 1);
	else if(mem[pos1][pos2] == mem[pos1 - 1][pos2])
		return trace(pos1 - 1, pos2);
	else
		return trace(pos1, pos2 - 1);
}

int main() {

	cin >> s >> t;
	szs = s.length();
	szt = t.length();

	for (int i = 0; i <= szs; ++i) {
		for (int j = 0; j <= szt; ++j) {
			if (i == 0 || j == 0)
				mem[i][j] = 0;
			else if (s[i - 1] == t[j - 1])
				mem[i][j] = mem[i - 1][j - 1] + 1;
			else
				mem[i][j] = max(mem[i - 1][j], mem[i][j - 1]);
		}
	}

	string ans = trace(szs, szt);

	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 35968
n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)
count = 0

for i in 0..n-1
    min = i
    for j in i..n-1
        if arr[j] == arr[i+1..n-1].min && arr[j] < arr[min]
            min = j
            arr[i],arr[min] = arr[min],arr[i]
            count += 1
        end
        min = i
    end
end

puts arr.join(" ")
puts count

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

using namespace std;

int dfs(vector<vector<int>>& G, int u, int p, int lev) {
    int ret = (lev < 0);
    for (int v: G[u]) {
        if (v != p) {
            ret += dfs(G, v, u, lev - 1);
        }
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    
    vector<vector<int>> G(n, vector<int> ());
    vector<pair<int, int>> E;
    
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        G[u - 1].emplace_back(v - 1);
        G[v - 1].emplace_back(u - 1);
        E.push_back({u - 1, v - 1});
    }
    
    int ans = numeric_limits<int>::max();
    if (k & 1) {
        for (int i = 0; i < n - 1; i++) {
            ans = min(ans, dfs(G, E[i].first, E[i].second, k / 2) + dfs(G, E[i].second, E[i].first, k / 2));    
        }
    } else {
        for (int i = 0; i < n; i++) {
            ans = min(ans, dfs(G, i, -1, k / 2));
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cctype>
using namespace std;

int main()
{
	char ch;
	int cnt[26] = {};

	while (cin >> ch) {
		ch = tolower(ch);
		if (isalpha(ch)) {
			cnt[ch - 'a']++;
		}
	}
	for (int i = 0; i < 26; i++) {
		printf("%c : %d\n", i + 'a', cnt[i]);
	}
	return 0;
}

Measured memory_bytes: 3124
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
 
 
class Main
{
    public static void main(String[] args)
    {
        int ans = 0;
        
        Scanner scanner = new Scanner(System.in);
        int d = scanner.nextInt();
        int n = scanner.nextInt();
        
        switch (d){
            case 0:
                if(n==100){
                    System.out.println(n+1);
                }else{
                System.out.println(n);
                }
                break;
            case 1:
                if(n==100){
                    System.out.println(n*100+100);
                }else{
                System.out.println(n*100);
                }
                break;
            case 2:
                if(n==100){
                    System.out.println(n*10000+10000);
                }else{
                System.out.println(n*10000);
                }
                break;
        }
        scanner.close();
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
 

vector <int > H;
int N; 
  
int main()
{
  cin >> N;
  int ans = 0;

  if(N/10 == 0){
    cout << N << endl;
  } else if(N/100 == 0){
    cout << 9;
  } else if(N/1000 == 0){
    cout << N - 100 + 10;
  } else if(N/10000 == 0){
    cout << 999-100+10;
  } else if(N/100000 == 0){
    cout << N - 10000 + 10 + 999-99;
  } else {
    cout << 99999-10000+10+999-99;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<stack>
#include<set>
using namespace std;
#define pb push_back
#define POP pop_back()
#define ll long long
#define db double
#define POP pop_back()
#define endl '\n'
#define PII pair<int,int>
#define FI first
#define SE second
#define VI vector<int>
#define QI queue<int>
#define SI stack<int>
#define debug cout<<"debug"<<endl;
#define PLL pair<ll,ll>
#define PDD pair<double,double>
#define ULL unsigned long long
#define fo(i,a,b) for (int i=a;i<=b;++i)
#define fd(i,a,b) for (int i=a;i>=b;--i)
#define mem(x,a) memset(x,a,sizeof(x))
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int a[maxn];
int main(){
	int n,m;cin >> n >> m;
	ll sum = 0;
	fo(i,1,m)scanf("%d",a + i) , sum += a[i];
	if(sum > n)cout << "-1\n";
	else cout << n - sum << endl;
	return 0;
}

Measured memory_bytes: 3760
#include<iostream>
    #include<cstdio>
    #include<cmath>
    #include<cstring>
    #include<string>
    #include<stack>
    #include<queue>
    #include<vector>
    #include<algorithm>
    #include<iomanip>
    typedef long long int ll;
    using namespace std;
    #define FOR(i,a,b) for (int i=(a);i<(b);i++)
    #define REP(i,n) for (int i=0;i<(n);i++)
    #define EREP(i,n) for (int i=1;i<=(n);i++)
    #define ALL(a) (a).begin(),(a).end()
    //#define EVEL 1
     
    #ifdef EVEL
    #define DEB(X) cout << #X << ":" <<X<<" " ;
    #define TF(f) f ? cout<<"true  " : cout<<"false ";
    #define END cout<<"\n";
    #else
    #define DEB(X) {}
    #define TF(f) {}
    #define END {}
    #endif
    const int MOD = 1000000007;
    const int INF = 2000000000;
        ll ans=0,id;
        int N,M;
        ll A,B,C,W;
        int a[100010];
        bool f=false;
        ll sum=0;
        string S;
     
    int main(){
        ios_base::sync_with_stdio(false);
        cin>>N;
        A=1;
        while(A*2<=N){
            A*=2;
        }
        cout<<A;
        return 0;
    }

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(true) {
			int n=in.nextInt(),l=in.nextInt();
			if(n==0)break;
			List<Integer> A=new ArrayList<>();
			for(int i=0;i<n;i++)A.add(Integer.parseInt(in.next()));
			Collections.sort(A,Collections.reverseOrder());
			int max=0;
			for(int i=0;i<n-1;i++) {
				for(int j=i+1;j<n;j++) {
					int sum=A.get(i)+A.get(j);
					if(sum<=l)max=Math.max(max,sum);
				}
			}
			
			if(max>0)System.out.println(max);
			else System.out.println("NONE");
		}
		
	}

}



Measured memory_bytes: 42288
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const int INFI = 1000000000;
 const ll INFL = (1LL << 60);

 int main() {
   ll N;
   cin >> N;
   vector<int> A(N);
   map<int, int> card;
   rep(i, 0, N) {
     cin >> A.at(i);
     card[A.at(i)]++;
   }
   if (card.size() % 2 == 1) cout << card.size() << endl;
   else cout << card.size() - 1 << endl;
 }


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

#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define ll                long long
#define mod               1000000007
#define fr                first
#define sc                second
#define vl                vector<ll>
#define pll               pair<ll,ll>
#define u_map             unordered_map<ll,ll>

#define pi                3.141592653589793
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define printV(v) for(auto itr:v) cout<<itr<<" "; cout<<endl;
#define printA(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printC cout<<"yes"<<endl;
#define printVP(v) for(auto itr:v) cout<<itr.fr<<" "<<itr.sc<<endl;
#define cinarr(a,n) for(int i=0; i<n; i++) cin>>a[i];



void solve(){
	string s,t; cin>>s>>t;
	int n=s.size(), m=t.size();
	int ans=INT_MAX;
	
	for(int i=0;i<=n-m;i++)
	{
		int cnt=0;
		for(int j=i; j<i+m; j++)
		{
			if(s[j]!=t[j-i]) cnt++;
		}
		ans=min(ans, cnt);
	}
	cout<<ans<<endl;

}



signed main(){
    ios;
	int testcases=1;
	//cin >> testcases;

	while(testcases--){
	    solve();
	}

	return 0;
}


Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main(void)
{
    int N, A, B;
    cin >> N >> A >> B;

    int ans = 0;
    for(int i = 1; i <= N; ++i)
    {
        int sum = 0;
        int j = i;
        while(j / 10)
        {
            sum += j % 10;
            j /= 10;
        }
        sum += j;
        if((A <= sum) && (sum <= B))
        {
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
	static Scanner sc = new java.util.Scanner(System.in);

	public static void main(String[] args) {
		int[] numA = new int[4];
		int[] numB = new int[4];
		while (sc.hasNext()) {
			int hit = 0;
			int blow = 0;
			for (int i = 0; i < 4; i++) {
				numA[i] = sc.nextInt();
			}
			for (int i = 0; i < 4; i++) {
				numB[i] = sc.nextInt();
			}
			for (int i = 0; i < 4; i++) {
				if (numA[i] == numB[i]) {
					hit++;
				}
			}
			for (int i = 0; i < 4; i++) {
				for (int j = 0; j < 4; j++) {
					if (numA[i] == numB[j]) {
						blow++;
					}
				}
			}
			System.out.println(hit + " " + (blow - hit));
		}

	}

}

Measured memory_bytes: 26276
#define _CRT_SECURE_NO_WARNINGS
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int printkigou(int, char);

int main(void) {
#ifdef DEBUG
	printf("");
#endif

	char S[26] = { '\0' };
	int i,j;
	int flag = 0;

	scanf("%s", S);

	for (i = 0; i < 26; i++) {
		if (S[i] == '\0') {
			break;
		}

		for (j = i+1; j <26; j++) {
			if (S[j] == '\0') {
				break;
			}
			if (S[i] == S[j]) {
				flag = 1;
				break;
			}
		}
		if (flag == 1) {
			break;
		}

	}
	if (flag == 0) {
		printf("yes\n");
	}
	else {
		printf("no\n");
	}

	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,W,N;
    cin >> H >> W >> N;
    ll a[100010], b[100010];
    rep(i,0,N){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    ll cnt[11] = {};
    map<lpair, ll> mp;
    vector<lpair> lp;
    rep(i,0,N){
        rep(j,0,3){
            rep(k,0,3){
                if(a[i] - 1 + j >= 1 && a[i] - 1 + j <= H - 2 && b[i] - 1 + k >= 1 && b[i] - 1 + k <= W - 2){
                    mp[make_pair(a[i] - 1 + j, b[i] - 1 + k)]++;
                    if(mp[make_pair(a[i] - 1 + j, b[i] - 1 + k)] == 1){
                        lp.push_back(make_pair(a[i] - 1 + j, b[i] - 1 + k));
                    }
                }
            }
        }
    }
    ll cnt_0 = 0;
    rep(i,0,lp.size()){
        ll val = mp[lp[i]];
        cnt[val]++;
        cnt_0++;
    }
    cnt[0] = (H - 2) * (W - 2) - cnt_0;
    rep(i,0,10){
        print(cnt[i]);
    }


}


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

int table[10010] = {} ;

void f(){
	table[0] = 1 ;
	table[1] = 1 ;
	for( int i=2 ; i<=10000 ; i++ ){
		if( !table[i] ){
			for( int j=2 ; i*j<=10000 ; j++ ) table[i*j] = 1 ;
		}
	}
}

main(){
	f() ;
	
	int n ;
	while( cin >> n , n ){
		int p = 0 ;
		for( int i=5 ; i<=n ; i++ ){
			if( !table[i] && !table[i-2] ) p = i ;
		}
		
		cout << p-2 << " " << p << endl ;
	}
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;



signed main(){
  int n;
  scanf("%lld", &n);
  if(n == 7 or n == 5 or n == 3){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n;
ll x;
ll h[51],p[51];
ll dfs(ll n,ll x){
    if(n==0&&x>0) return 1;
    if(n==0&&x<=0) return 0;
    if(x<=h[n-1]+1) return dfs(n-1,x-1);
    return dfs(n-1,x-h[n-1]-2)+p[n-1]+1;
}
int main(){
    cin>>n>>x;
    h[0]=1,p[0]=1;
    FOR(i,1,n){
        h[i]=h[i-1]*2+3;
        p[i]=p[i-1]*2+1;
    }
    cout<<dfs(n,x)<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	In := readLineInt()
	Result := In[0] + In[1]
	if Result >= 10 {
		fmt.Println("error")
	} else {
		fmt.Println(Result)
	}
}

/////////////////////////////////////////

func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		i, _ := strconv.Atoi(v)
		result = append(result, i)
	}
	return result
}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}


Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
using namespace std;
long long t;
int min(int a,long long b){
	if(a>b)	return b;
	return a;
}
int main(){
	long long a,b,minn=0x6f6f6f6f6f6f6f;
	scanf("%d %d",&a,&b);
	if(a>=b){
		printf("0");
		return 0;
	}
	for(int i=a;i<=b;i++){
		for(int j=i+1;j<=b;j++){
			if(i%2019==0||j%2019==0){
				printf("0");
				return 0;
			}
			minn=min(minn,(i%2019)*(j%2019)%2019);
		}
	}
	printf("%d",minn);
	return 0;
}

Measured memory_bytes: 128
from collections import Counter
 
M = 998244353
n = int(input())
a = map(int, input().split())
x, c = next(a), Counter(a)
r = 0
if x == c[0] == 0:
    r = p = i = 1
    try:
        while True:
            x = c.get(i)
            r = r * pow(p, x, M) % M
            p = x; n -= p; i += 1
    except:
        pass
print((r, 0)[n > 1])

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

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

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int root[SIZE];
int sz[SIZE];
void init() {
    for( int i = 0; i < SIZE; ++i ) {
        root[i] = i;
        sz[i] = 1;
    }
}

int Root( int x ) {
    if( x == root[x] ) return x;
    int rt = Root(root[x]);
    sz[x] = sz[rt];
    return rt;
}

bool Unite( int x, int y ) {
    int rx, ry;
    rx = Root( x );
    ry = Root( y );

    if( rx == ry ) return false;
    if( sz[rx] > sz[ry] ) {
        root[ry] = rx;

    } else {
        root[rx] = ry;

    }
    sz[rx] += sz[ry];
    sz[ry] = sz[rx];
    return true;

}

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

    int N;
    int M;
    cin >> N >> M;
    init();

    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        Unite(a, b);
    }

    int res = 0;
    for(int i = 1; i <= N; ++i) {
        Root(i);
        res = max(res, sz[i]);
    }

    cout << res << endl;
    return 0;
}



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

int main(){
	int n, ans=0;
	cin >> n;
	string color;
	cin >> color;
	rep(i,n-1){
		if(color[i]!=color[i+1]) ++ans;
	}
	++ans;
	cout << ans << endl;
		 
	return 0;
}
	

Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

LL N;

LL F(LL m) {
    LL ret = 0;
    while (m) {
	ret += m % 10;
	m /= 10;
    }
    return ret;
}

void MAIN() {
    scanf("%lld", &N);

    LL ans = F(N);

    REP (i, 20) {
	int a = N % 10;
	N /= 10;
	int b = N % 10;
	if (b > 0) amax(ans, F(N-1) + (i+1)*9);
    }
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

using namespace std;

int main(){
  string str1,str2;
  int i,j,k;
  cin >> str1 >> str2;
  for(i=1,j=0,k=0;i<=str1.size()+str2.size();i++){
    if(i%2==1){
      cout << str1[j];
      j++;
    }else{
      cout << str2[k];
      k++;
    }
  }
  cout <<endl;
  return 0;
}

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

using namespace std;

//mem(a, b) memset(a, (b), sizeof(a))

typedef long long ll;

#define f(i,a,b) for (ll i=a ; i<b ; i++)

#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define faster ios::sync_with_stdio(0);cin.tie(0);
typedef pair<int, int> p;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<p> vii;
typedef vector<vi> vvi;
typedef map<int,int> mp;
typedef set<int> se;
typedef multiset<int> MSETI;


// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

// traversal function to avoid long template definition. Now with C++11 auto alleviates the pain.
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)

// find if a given value is present in a container. Container version. Runs in log(n) for set and map
#define present(c,x) ((c).find(x) != (c).end())

//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())

// Avoiding wrap around of size()-1 where size is a unsigned int.
#define sz(a) int((a).size())


struct duo{
    ll x,y;
};

bool mycomp(duo a,duo b) { return a.x < b.x ;}

bool comp(int a,int b){
	return a<b;
}


int main()
{
	faster


	ll t,n,a=0,b=0,d,i,j,k,c,sum;
    n=5;
    
    f(i,0,5)
    {
        cin>>a;
        if(a==0)
        {
            cout<<i+1;
            exit(0);
        }
    }
    
    
	
	
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    string s;
    cin>>s;
    ll n = sz(s);
    reverse(rng(s));
    s.push_back('0');
    vvl dp(n + 2, vl(2, LINF));
    dp[0][0] = 0, dp[0][1] = 0;
    rep(i, n + 1) rep(j, 2) rep(k, 2) {     // j:繰り上がりをする k:繰り上がりされた
        ll c = s[i] - '0';
        if (i > 0 && k) c++;
        if (c == 10 && j == 0) continue;
        if (c == 0 && j == 1) continue;
        if (j) chmin(dp[i + 1][j], dp[i][k] + (10 - c) % 10);
        else chmin(dp[i + 1][j], dp[i][k] + c);
    }
    cout<<min(dp[n + 1][0], dp[n + 1][1])<<endl;
}

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

int main(){
    int N;
    cin >> N;
    int X[N];
    int max = 0;
    int min = 100;
    for(int i = 0; i < N; i++){
        cin >> X[i];
        if(max < X[i]) max = X[i];
        if(min > X[i]) min = X[i];
    }
    // cout << max << endl;
    // cout << min << endl;
    int sigma = 0;
    for(int i = 0; i < N; i++){
        sigma += (X[i]-min)*(X[i]-min);
    }

    for(int p = min; p <= max; p++){
        int sigma2 = 0;
        for(int i = 0; i < N; i++){
            sigma2 += (X[i]-p)*(X[i]-p);
        }
        if(sigma2 < sigma) sigma = sigma2;
    }
    cout << sigma << '\n';

}

Measured memory_bytes: 888
program main
    implicit none
    integer :: i,n,j
    integer,dimension(:),allocatable :: x
    integer :: mx,mn,power,ptmp

    read *,n
    allocate(x(n))
    read *,(x(i),i=1,n)
    mx=maxval(x)
    mn=minval(x)
    power=1000000000
    do i=mn,mx
        ptmp=0
        do j=1,n
            ptmp=ptmp+(i-x(j))**2
        end do
        power=min(power,ptmp)
    end do
    print '(i0)',power
end program main

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define ll long long 
#define Fastest ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
 
ll arr[100005], dp[100005], n;
 
int main()
{
	Fastest
	
	cin >> n;
	
	for(int i = 1; i <= n; i++){
		cin >> arr[i];
	}
	
	dp[1] = 0;
	dp[2] = abs(arr[1] - arr[2]);
	
	for(int i = 3; i <= n; i++){
		dp[i] = min(dp[i-1]+abs(arr[i] - arr[i-1]), dp[i-2]+abs(arr[i] - arr[i-2]));
	}
	
	cout << dp[n] << endl;
		
	return 0;
}

Measured memory_bytes: 1792
sx, sy, tx, ty = map(int, raw_input().split())
tx -= (sx - 1)
sx = 1
ty -= (sy - 1)
sy = 0

def solve(tx, ty):
    res = []
    for i in range(1, ty):
        res.append("U")
    for i in range(1, tx):
        res.append("R")
    for i in range(ty, 1, -1):
        res.append("D")
    for i in range(tx, 1, -1):
        res.append("L")
    res += "L"
    for i in range(1, ty + 1):
        res.append("U")
    for i in range(0, tx):
        res.append("R")
    res += "DR"
    for i in range(ty, 0, -1):
        res.append("D")
    for i in range(tx, 0, -1):
        res.append("L")
    res.append("U")
    return "".join(res)
print solve(tx, ty)

Measured memory_bytes: 33004
#include <stdio.h>
int main(void)
{
  int N,i,num;
  i=0;

  scanf("%d",&N);
  num=N;
  while(num>0){

    i=num%10+i;
    if(num<10){
      num=-1;
    }
    num=num/10;
  }
  if((N%i)==0){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int fact(int z) {
  int r = 1;
  int i = z;
  while (i) {
    r *= i;
    i--;
  }
  return r;
}
int main() {
  int n,m, a, b;
  int p[8] = { };
  int q[8] = { };
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> m;
    p[i] = m;
  }
  for (int i = 0; i < n; i++) {
    cin >> m;
    q[i] = m;
  }
  a = 0;
  b = 0;
  //1,2,4,3だと1番目が1なので+0,2番目が2なので+0,3番目が4なので1!*1
  //4,3,2,1の並びの場合1番目に4だと3!*3,2番目が3で2!*2,3番目が2で1!*1
  //a番目がbの場合(n-a)!*b-本来と離れた数
  for (int i = 1; i <= n; i++) {
    a += (p[i - 1] - 1) * fact(n - i);
    b += (q[i - 1] - 1) * fact(n - i);
    for (int j = i; j < n; j++) {
      if(p[i-1] < p[j]) p[j]--;
      if(q[i-1] < q[j]) q[j]--;
    }
  }
  cout << abs(a - b);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<int> color(9, 0);
  rep(i, 0, n) {
    int a;
    cin >> a;
    if (a < 400)
      color[0]++;
    else if (a < 800)
      color[1]++;
    else if (a < 1200)
      color[2]++;
    else if (a < 1600)
      color[3]++;
    else if (a < 2000)
      color[4]++;
    else if (a < 2400)
      color[5]++;
    else if (a < 2800)
      color[6]++;
    else if (a < 3200)
      color[7]++;
    else
      color[8]++;
  }

  int count = 0;
  rep(i, 0, 8) if (color[i]) count++;

  if (count == 0)
    cout << 1 << " " << color[8] << endl;
  else
    cout << count << " " << count + color[8] << endl;
}


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

int main(){
  string s;
  cin >> s;
  string sea="CF";
  int x=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)==sea.at(x)){
      x++;
    }
    if(x==2){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3548
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

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

	if(a.length() > b.length()){
		cout << "GREATER" << endl;
		return 0;
	}else if(a.length() < b.length()){
		cout << "LESS" << endl;
		return 0;
	}else{
		int i=0;
		while(a.at(i) != b.at(i) && i < a.length()){
			if(a.at(i) > b.at(i)){
				cout << "GREATER" << endl;
				return 0;
			}else if(a.at(i) < b.at(i)){
				cout << "LESS" << endl;
				return 0;
			}
			i++;
		}
		cout << "EQUAL" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
/*
	author: parv2809
*/

#include<bits/stdc++.h>
#define int long long int
#define mod 1000000007
#define inf 1e18
#define fo(i,y,n,inc)	for(int i=y;i<n+y;i+=inc)
#define cin(t) int t;cin>>t
#define w(t) while(t--)
#define nl cout<<endl;
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define ft(i) (i&(-1*i))
#define arrIn(arr,size)		for(int i=0;i<size;i++){cin>>arr[i];}
#define arrOut(arr,size,seperater)	for(int i=0;i<size;i++){cout<<arr[i]<<seperater;}
using namespace std;

int max(int a, int b) {
	if (a > b)
		return a;
	return b;
}

int min(int a, int b) {
	if (a < b)
		return a;
	return b;
}

int powmd(int a, int b) {
	if (b == 1)	return a;
	if (b == 0)	return 1;

	int half = powmd(a, b / 2);
	int ans = half * half;
	ans %= mod;
	if (b & 1) {
		ans *= a;
	}
	ans %= mod;
	return ans;
}

void fastIO() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}

struct block {
	int weight, solidness, value;
};

bool custom_compare(block& a, block& b) {
	return (a.weight + a.solidness) > (b.weight + b.solidness);
}

int dp[1005][10005];

void solve(vector<block>& blocks) {

	int n = blocks.size();

	for (int i = 0; i <= 10000; i++) {
		if (blocks[0].solidness >= i)
			dp[0][i] = blocks[0].value;
		else
			dp[0][i] = 0;
	}

	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= 10000; j++) {
			int first = dp[i][j] = dp[i - 1][j];
			int second = 0;
			if (blocks[i].solidness >= j) {
				second = blocks[i].value + ((j + blocks[i].weight > 10000) ? 0 : dp[i - 1][j + blocks[i].weight]);
			}
			dp[i][j] = max(first, second);
		}
	}

}

int32_t main() {

	fastIO();
	int t = 1;
	w(t) {

		int n;
		cin >> n;

		vector<block> blocks(n);

		for (int i = 0; i < n; i++) {
			cin >> blocks[i].weight >> blocks[i].solidness >> blocks[i].value;
		}

		sort(blocks.begin(), blocks.end(), custom_compare);

		solve(blocks);
		cout << dp[n - 1][0];
	}

	return 0;
}

// cout << "Case #" << i << ": " << answer << endl;

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

int main() {
	cin.tie(0)->sync_with_stdio(false);

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

	ll res = 1000;
	ll stock = 0;
	REP(i, n - 1) {
		if (a[i] < a[i + 1] && res >= a[i]) {
			stock = res / a[i];
			res %= a[i];
		} else if (a[i] > a[i + 1] && stock > 0) {
			res += stock * a[i];
			stock = 0;
		}
	}

	cout << res + stock * a[n - 1] << '\n';
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll a, b;
    cin >> a >> b;
    if (a >= 13) {
        cout << b << endl;
        return 0;
    } else if (a >= 6) {
        cout << b / 2 << endl;
        return 0;
    } else {
        cout << 0 << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n-1); i >= 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main(){
	int n,m,x; cin >> n >> m >> x;
	vint a(m);
	rep(i,m) cin >> a[i];
	int ansa=0;
	int ansb=0;
	mrep(i,x) {
		rep(j,m) {
			if(i==a[j]) ansa++;
		}
	}
	rrep(i,x,n) {
		rep(j,m) {
			if(i==a[j]) ansb++;
		}
	}
	cout << min(ansa,ansb) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a;
	while(scanf("%d",&a)!=EOF)
	{
		int b,c,d,e;
		e=a%10;d=(a%100-b)/10;
		c=(a%1000-a%100)/100;
		b=(a-a%1000)/1000;
		if(b+c+d+e==7) printf("%d+%d+%d+%d=7\n",b,c,d,e);
		else if(b+c-d+e==7) printf("%d+%d-%d+%d=7\n",b,c,d,e);
		else if(b+c+d-e==7) printf("%d+%d+%d-%d=7\n",b,c,d,e);
		else if(b+c-d-e==7) printf("%d+%d-%d-%d=7\n",b,c,d,e);
		else if(b-c-d+e==7) printf("%d-%d-%d+%d=7\n",b,c,d,e);
		else if(b-c+d-e==7) printf("%d-%d+%d-%d=7\n",b,c,d,e);
		else if(b-c+d+e==7) printf("%d-%d+%d+%d=7\n",b,c,d,e);
		else if(b-c-d-e==7) printf("%d-%d-%d-%d=7\n",b,c,d,e);
		return 0;
		
	}
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>


using namespace std;

const int MaxN = 1e5 + 5;

int dp[MaxN][3] , a[MaxN] , b[MaxN] ,c[MaxN] , n;
int main(){
	scanf("%d",&n);
	for(int i = 1; i <= n ; i++){
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
	}
	for(int i = 1 ;i <= n ; i++){
		dp[i][0] = max(dp[i - 1][1] + a[i] , dp[i - 1][2] + a[i]);
		dp[i][1] = max(dp[i - 1][0] + b[i] , dp[i - 1][2] + b[i]);
		dp[i][2] = max(dp[i - 1][0] + c[i] , dp[i - 1][1] + c[i]);
	}
	printf("%d\n",max(dp[n][0],max(dp[n][1],dp[n][2])));
	return 0;
}

Measured memory_bytes: 2560
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

bool compare(P a, P b){
    return a.first - a.second < b.first - b.second;
}

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

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    vector<P> x(n);
    rep(i, n) x[i] = {a[i], b[i]};
    sort(ALL(x), compare);

    int sum = 0;
    int s = -1;
    rep(i, n){
        if(x[i].first >= x[i].second){
            break;
        }
        sum += x[i].second - x[i].first;
        s = i;
    }

    int t = -1;
    for(int i = n - 1; i >= 0; i--){
        if(x[i].first <= x[i].second){
            break;
        }
        if(sum <= 0){
            break;
        }
        sum -= x[i].first - x[i].second;
        t = i;
    }

    if(sum > 0){
        cout << -1 << endl;
        return 0;
    }

    if(s == -1 || t == -1){
        cout << 0 << endl;
    }else{
        cout << s + 1 + n - t << endl;
    }

    return 0;
}


Measured memory_bytes: 3704
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int m,n;
double dp[17][(1<<16) + 1];
double prob[17][17];

double calc(int f, int s) {

    if (f == n)   return 1.0;
    if (dp[f][s] != -1.0) return dp[f][s];

    double ret = 0;
    for (int k=0; k<m; ++k) if (!(s & (1<<k))) { // ???????????????????????????
        double cp = 1.0;
        double sum = 0;
        for (int j=f; j<n && cp > 0.0; ++j) { // ?????????????????¢
            if (prob[k][j] < 1.0) {
                sum += calc(j, s|(1<<k)) * cp * (1.0 - prob[k][j]);
            }
            cp *= prob[k][j];
        }
        // ???????????§???????¶????????¢????(????????§?¢????0????????£?????????????????§??§??????
        sum += cp;
        ret = max(ret, sum);
    }
    //printf("f:%d\ts:%d\tp:%f\tret:%f\n",f,s,p,ret);
    return dp[f][s] = ret;
}

int main() {
    cin >> m >> n;
    for (int i=0; i<m; ++i) {
        for (int j=0; j<n; ++j) {
            cin >> prob[i][j];
        }
    }
    // init
    for (int i=0; i<17; ++i) for (int j=0; j<(1<<16)+1; ++j) dp[i][j] = -1.0;

    printf("%.12f\n", calc(0, 0));

    return 0;
}

Measured memory_bytes: 11988
from collections import defaultdict


# xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


# xとyの属する集合の併合
def unite(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        # sizeの大きいほうがx
        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y]
        par[y] = x
        return True


# xとyが同じ集合に属するかの判定
def same(x, y):
    return find(x) == find(y)


# xが属する集合の個数
def size(x):
    return -par[find(x)]


n, m, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
cd = [list(map(int, input().split())) for i in range(k)]

# 初期化
# 根なら-size,子なら親の頂点
par = [-1] * n

not_see = defaultdict(set)

for a, b in ab:
    a -= 1
    b -= 1
    unite(a, b)
    if same(a, b):
        not_see[a].add(b)
        not_see[b].add(a)

for c, d in cd:
    c -= 1
    d -= 1
    if same(c, d):
        not_see[c].add(d)
        not_see[d].add(c)

for i in range(n):
    print(size(i) - len(not_see[i]) - 1)


Measured memory_bytes: 119812
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    //方針
    //毎日満足度は低下し続ける
    //満足度上昇の方法はコンテスト開催のみ
    //開催されてないコンテストを放置すると低下が著しくなる
    //実際にコンテストを開いた時の満足度上昇が最大のものを採用してみる
    //低下をなくせる分を上昇と捉えると、c_i(d-last(d,i)) + s_{d,i} だけペイすると考えられる？→あんまり適当じゃない
    //r日ずつ全探索を[D/r+1]回繰り返す
    //探索パターン数は26^rで、シミュレーションには26r回かかる、これを[D/r+1]回繰り返すので
    //計算量はO(D26^{r+1})
    //r = 3が限界
    int D;cin>>D;
    int c[26],last[26]={},s[365][26],lastcpy[26];
    REP(i,26) cin>>c[i];
    REP(i,D) REP(j,26) cin>>s[i][j];
    constexpr int r = 6;//何日に分けて全探索を行うか
    constexpr int num = 6;//1日毎にいくつ全探索するか:cを降順ソートして前半num個だけを選び続ける貪欲
    int all = 1;
    REP(i,r) all *= num;
    int up,ptncpy;
    int res[r],calcres[r],reslast[26];
    int ord[26];
    iota(ord,ord+26,0);
    stable_sort(ord,ord+26,[&](int x,int y){return c[x]>c[y];});
    stable_sort(c,c+26,[](int x,int y){return x>y;});
    for(int i=0;i<D;i+=r){
        int tmp = -1e9;
        for(int pattern = 0; pattern < all; pattern++){    //r日でそれぞれ何処を選ぶか全探索
            up = 0; ptncpy = pattern;
            memcpy(lastcpy,last,sizeof(int)*26);                //lastを更新しなければならないのでコピーを取る
            REP(j,r){                                           //r日探索
                if(i+j>=D) break;
                calcres[j] = ptncpy%num;
                REP(k,26){                                      //スコアに影響のある26パターンについて処理しなければならない
                    if(calcres[j] == k){                        //選ぶパターンのときはlastを更新してスコアを加算
                        last[k] = i+j;
                        up += s[i+j][k];
                    }
                    else up -= c[k]*(i+j - last[k]);            //そうでないときはlastを参照して減算
                }
                ptncpy /= num;                                   //これをi+r-1日目まで繰り返して終了
            }
            
            if(tmp<up){                                         //もしスコアが高くなるならば結果を更新する
                tmp = up;
                memcpy(res, calcres, sizeof(int)*r);            //
                memcpy(reslast, last, sizeof(int)*26);
            }
            memcpy(last, lastcpy, sizeof(int)*26);
        }
        memcpy(last, reslast, sizeof(int)*26);
        REP(j,r) if(i+j<D){
            cout<<ord[res[j]]+1<<endl;
        }
    }
}


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

using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;

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

    int fscore = 0;
    rep(i,n-1) {
        if(s[i] == s[i+1]) fscore++;
    }

    int ans = min(fscore + 2*k , n-1);
    cout << ans;
}

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

int main() {
  int n,a;
  cin>>n;
  vector<int> vec(100001);
  for(int i=0;i<n;i++){
    cin>>a;
    vec.at(a)++;
  }
  int answer=-1;
  for(int i=0;i<99999;i++){
    answer=max(answer,(vec.at(i)+vec.at(i+1)+vec.at(i+2)));
  }
  cout<<answer<<endl;
}

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

using ll = long long;

vector<ll> AB;
vector<ll> ABC;

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

    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    ll A[X], B[Y], C[Z];
    for (int i = 0; i < X; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < Y; ++i) {
        cin >> B[i];
    }
    for (int i = 0; i < Z; ++i) {
        cin >> C[i];
    }

    for (int i = 0; i < X; ++i) {
        for (int j = 0; j < Y; ++j) {
            AB.push_back(A[i] + B[j]);
        }
    }
    sort(AB.rbegin(), AB.rend());
    int ab_length = min(K, X * Y);
    for (int i = 0; i < ab_length; ++i) {
        for (int j = 0; j < Z; ++j) {
            ABC.push_back(AB[i] + C[j]);
        }
    }

    sort(ABC.rbegin(), ABC.rend());

    for (int i = 0; i < K; ++i) {
        cout << ABC[i] << '\n';
    }

    return 0;
}


Measured memory_bytes: 43364
#include<stdio.h>

int main(){
  int anthena[6]={0},i=0,k=0,j=0;
  for(i=0;i<6;i++){
  	scanf("%d",&anthena[i]);
  }
  for(i=4;i>0;i--){
    for(j=0;j<i;j++){
    if(anthena[i]-anthena[j]>anthena[5]){
    	k++;
    }
    }
  }
  
  if(k>0){
    printf(":(");
  }else{
  	printf("Yay!");
  }
  
  return 0;
}

Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::cmp::{max, min} ;

fn main() {
    input! {
        n: usize,
        p: [usize; n],
    }
    let mut ans = 0;
    let mut min = *(p.first().unwrap());
    for p_i in &p {
        if  *p_i <= min {
            min = *p_i;
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

#define ll long long
#define forn(i, n) for(int i=0; i<int(n); i++)
#define endl '\n'
const int N = 1e5+5;

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

    int n; cin>>n;
    vector<vector<int>> dp(n+1, vector<int>(3, -0));
    int in[n+1][3];

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

        for(int j=0; j<3; j++) {
            cin>>in[i][j];
            if(i == 1) {
                dp[i][j] = in[i][j];
                continue;
            }
            forn(k, 3) {
                if(j != k) 
                    dp[i][j] = max(dp[i][j], dp[i-1][k]+in[i][j]);
            }

        }

    }


    cout<<max(dp[n][0], max(dp[n][1], dp[n][2]));
}
 


Measured memory_bytes: 9776
# coding: UTF-8
import math
import sys
import copy

numlist = []
for line in sys.stdin.readlines():
  numlist.append(int(line.rstrip()))
N = numlist.pop(0)

nlist = copy.deepcopy(numlist)
Amax1 = max(nlist)
nlist.remove(Amax1)
Amax2 = max(nlist)

for num in numlist:
  if num != Amax1:
    print(Amax1)
  else:
    print(Amax2)


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

namespace ABC_Training
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var p = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int [] minArray = new int[n];
            minArray[0] = p[0];
            var ans = 1;
            for(int i = 1; i < n; i++)
            {
                minArray[i] = Math.Min(p[i], minArray[i - 1]);
                if (minArray[i] == p[i])
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 33628