akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <list>
using namespace std;

// list 常用函数
/**
size()
begin 表头的迭代器
end 返回指向表尾的迭代器
push_front 在表的开头添加元素
push_back 在表的末尾添加元素
pop_front 在表头删除元素
pop_back 在表的末尾删除元素
inset(p,x) 在表的位置p插入元素x
erase(p) 删除表中位置p的元素
clear 删除表中的所有元素
**/

int main() {
  int q, x;
  char com[20];
  list<int> v;
  scanf("%d", &q);

  for (int i = 0; i < q; i++) {
    scanf("%s", com);
    if (com[0] == 'i') {
      scanf("%d", &x);
      v.push_front(x);
    } else if (com[6] == 'L') {
      v.pop_back();
    } else if (com[6] == 'F') {
      v.pop_front();
    } else if (com[0] == 'd') {
      scanf("%d", &x);
      for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
        if (*it == x) {
          //传入位置的迭代器，删除元素
          v.erase(it);
          break;
        }
      }
    }
  }
  int i = 0;
  for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
    if (i++)
      printf(" ");
    printf("%d", *it);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 33908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
string s,t;
int cnt[100005],cnt2[100005];
int main(){
	cin>>s>>t;
	int q;cin>>q;
	for(int i=0;i<s.size();i++){
		cnt[i+1]=cnt[i]+(s[i]=='A'?2:1);
	}
	for(int i=0;i<t.size();i++){
		cnt2[i+1]=cnt2[i]+(t[i]=='A'?2:1);
	}
	rep(i,q){
		int a,b,c,d;cin>>a>>b>>c>>d;
		int  X = cnt[b]-cnt[a-1];
		int  Y = cnt2[d]-cnt2[c-1];
		puts(X%3 == Y%3?"YES":"NO");
	}
}

Measured memory_bytes: 1664
#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 whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
const int INF = 1001001001;

vector<int> to[607];
double dp[607];

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        to[s].emplace_back(t);
        to[t].emplace_back(s);
    }

    
    double ans = INF;
    for (int i=n-1; i>=0; i--) {
        if (i==n-1) {
            dp[i] = 0.0;
            continue;
        }
        int num = 0;
        double v = 0.0;
        for (int e: to[i]) {
            if (e>i) {
                num++;
                v+= (dp[e]+1.0);
            }
        }
        dp[i] = v/num;
    }
    ans = min(ans, dp[0]);
    

    rep(i, n) {
        int num0 = 0;
        for (int e:to[i]) {
            if (e>i) num0++;
        }
        if (num0<=1) continue;

        for (int j=n-1; j>=0; j--) {
            if (j==n-1) {
                dp[j] = 0.0;
                continue;
            }
            int num = 0;
            double v = 0.0;
            double big = 0.0;
            for (int e: to[j]) {
                if (e>j) {
                    num++;
                    v+= dp[e]+1.0;
                    big = max(big, dp[e]+1.0);
                }
            }
            if (j==i) {
                num--;
                v -= big;
            }
            dp[j] = v/num;
        }


        ans = min(ans, dp[0]);
        
    }
    
    
    
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 2944
c = []
for i in range(0, 3):
    c.append(list(map(int, input().split())))
for i in range(3):
    for j in range(2):
        if c[i][j] - c[i][j + 1] != c[0][j] - c[0][j + 1]:
            print("No")
            exit()

for i in range(3):
    for j in range(2):
        if c[j][i] - c[j + 1][i] != c[j][0] - c[j + 1][0]:
            print("No")
            exit()
print("Yes")


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

#define ll long long
#define sz(x) (int)x.size();
#define go ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

int main(){
	go;
	char a;
	cin>>a;
	if(a>='A' && a<='Z')cout<<"A";
	else cout<<"a";	
	
}

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

using namespace std ; 


const int N = 1e5 + 7 ; 

int n; 

int main(){
        ios_base::sync_with_stdio(0) ; 
        cin.tie(0) ; 
        //freopen("in.in" , "r" , stdin) ; 
        int x , y ; 
        cin >> x >> y ; 
        if(y%2){
                cout<<  "No"  ; 
                return 0 ; 
        }
        int r = y /2 ; 
        if(r < x || r > x * 2){
                cout<<"No" ; 
        }
        else{
                cout<<"Yes" ;
        }

        return 0 ; 
}

Measured memory_bytes: 3616
#include <stdio.h>

int main(void){
    int x, y;
    scanf("%d %d",&x ,&y);
    
    while(x != 0 || y != 0){
     if(x < y){
       printf("%d %d\n",x ,y);
     } else {
       printf("%d %d\n",y ,x);
     }
     scanf("%d %d",&x ,&y);
}   

  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=1e6+5;
vector<ll> V;
int pre[maxn];
int has[maxn][10];
int main() {
	for(int i=1;i<maxn;i++)
		for(int j=0;j<10;j++)
			has[i][j]=has[i/10][j]|(i%10==j?1:0);
	int n,k;cin>>n>>k;
	for(int i=1;i<=k;i++) {
		int x;cin>>x;V.push_back(x);
	}
	for(int i=n;;i++) {
		bool ok=1;
		for(auto x:V) {
			if(has[i][x]) {ok=0;break;}
		}
		if(ok) return 0*printf("%d\n",i);
	}    
    return 0;
}

Measured memory_bytes: 42832
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		boolean ok = true;
		for(int i = 0;i < n; ++i){
			if((i&1) == 0){
				if((s.charAt(i) != 'R') && (s.charAt(i) != 'U') && (s.charAt(i) != 'D')){
					ok = false;
					// System.out.println(i);
					break;
				}
			}else{
				if((s.charAt(i) != 'L') && (s.charAt(i) != 'U') && (s.charAt(i) != 'D')){
					ok = false;
					// System.out.println(i);
					break;
				}
			}
		}
		if(ok){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}	
}

Measured memory_bytes: 23252
#include<iostream>
    #include<string>
    using namespace std;
     
    int main(){
      string A,S="abcdefghijklmnopqrstuvwxyz";
      long memo[26]={},ans=1;
      cin>>A;
      for(int i=0;i<A.size();i++){
        for(int j=0;j<26;j++){
          if(A[i]==S[j]){
            ans+=i-memo[j];
            memo[j]+=1;
          }
        }
      }
      cout<<ans<<endl;
      return 0;
    }

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

int n,a,b,c;
vector<int> G[MAX];
int size[MAX];
int par[MAX];
//int cur[MAX];
int dep[MAX];
int depth[MAX];
//int het[MAX];
int parent[MAX];

void idfs(int pos,int prev){
  int m=-1;
  parent[pos]=prev;
  if(G[pos].size()==1&&prev!=-1)return;  
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    depth[to]=depth[pos]+1;
    idfs(to,pos);
    size[pos]+=size[to];
    //het[pos]=max(het[pos],het[to]+1);
    if(m==-1||size[m]<size[to]){
      m=to;
    }
  }
  //cur[pos]=m;
  par[m]=pos;
  //het[pos]=max(het[pos],het[m]);
}

int calc(int x){
  if(par[x]==x)return x;
  return par[x]=calc(par[x]);
}

void init(){
  for(int i=0;i<MAX;i++){
    //G[i].clear();
    size[i]=1;
    par[i]=i;
    //cur[i]=-1;
    //dep[i]=0;
    //depth[i]=0;
    //het[i]=0;
    //parent[i]=0;
  }
  for(int i=0;i<n;i++){    
    scanf("%d",&a);
    while(a--){
      scanf("%d",&b);
      G[i].push_back(b);
      G[b].push_back(i);
    }
  }
  for(int i=0;i<n;i++)sort(G[i].begin(),G[i].end());
  depth[0]=0;
  idfs(0,-1);
  for(int i=0;i<n;i++){
    int root=calc(i);
    //het[i]=het[root];
    int p=par[i];
    while(p>0){
      p= par[ parent[p] ];      
      dep[i]++;
    }

    /*    
    cout<< (char)('A'+i) <<"   -> ";
    cout<< (char)('A'+par[i]) <<endl;    
    cout<<"size = "<< size[i]<<" , ";    
    cout<<"depth = "<< depth[i]<<" , ";
    cout<<"dep = "<< dep[i]<<" , ";
    cout<<"parent = "<< (char)('A'+parent[i]) <<" , ";
    cout<<"cur = "<< (char)('A'+cur[i]) <<" , ";
    cout<<"het = "<< het[i] << endl;
    
    cout<<endl;
    */
  }

  
}

int main(){
  while( scanf("%d",&n)!=EOF){
    init();
    int q;
    scanf("%d",&q);
    while(q--){
      scanf("%d %d",&a,&b);

      while(par[a]!=par[b]){
        if(dep[a]<dep[b])swap(a,b);
        a=parent[par[a]];
      }
      printf("%d\n",(depth[a]<depth[b]?a:b));      

    }
    break;
  }

  
  return 0;
}

Measured memory_bytes: 16048
import math

nums = [int(e) for e in input().split()]

if nums[2] >= ((nums[0]**2 * nums[1]) / 2):
    a = 2*((nums[0]**2 * nums[1]) - nums[2]) / nums[0]**3
    print(math.degrees(math.atan(a)))

else:
    a = (nums[0] * nums[1]**2) / (2 * nums[2])
    print(math.degrees(math.atan(a)))


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

int N;
int X;
bool OK = true;

int main()
{
	scanf("%d", &N);
	for(int i=1; i<=N; i++)
	{
		scanf("%d", &X);
		if(X % 2 == 0 && (X % 3 != 0 && X % 5 != 0))
		{
			OK = false;
		}
	}
	if(OK)
	{
		printf("APPROVED");
	}
	else
	{
		printf("DENIED");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len;
    string s;
    cin >> len >> s;
    map<int, int> m;
    for(char c : s) {
        m[c] += 1;
    }
    int ans = 0, curr = 0;
    set<int> left;
    for(int i = 0; i < len; i++) {
        if(!left.count(s[i]))
            curr += 1;
        left.insert(s[i]);
        m[s[i]] -= 1;
        if(m[s[i]] == 0)
            curr -= 1;
        ans = max(ans, curr);
    }
    cout << ans;
}

Measured memory_bytes: 3628
import java.util.*;
import java.lang.*;
import java.io.*;

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

        if(X < A){
            System.out.println(0);
        }
        else {
            System.out.println(10);
        }
        

    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, nuint_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define int long long
#define MOD 1000000007
#define what_is(x) cerr << #x << " is " << x << endl;
#define loop(i,a,n) for(int i=a;i<n;i++)
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, szof(x))
#define sortall(x) sort(aint(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626 
 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int, int> pt;

// int arr[2][2]={{0,1},{1,0}};
signed main() {

	fastio();
	//#define LOCAL_DEFINE	
	#ifdef LOCAL_DEFINE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		//https://zhuhan0.blogspot.com/2017/09/leetcode-425-word-squares.html
		//https://yzygitzh.github.io/algorithm/2018/11/09/leetcode-summary.html
		//https://beginnersbook.com/2015/03/why-dont-we-call-run-method-directly-why-call-start-method/
		//https://leetcode.com/problems/lfu-cache/
	// int n,k;
	// cin>>n>>k;
	// vector<int> arr(n);
 // 	for(int i=0;i<n;i++)
 // 	{
 // 		cin>>arr[i];
 // 	}
 // 	set<int> hash;
 // 	int ans=0;
 // 	bool flag=false;
 // 	for(int i=0;i<k;i++)
 // 	{
 // 		if(hash.lower_bound(arr[i])!=hash.end())
 // 		{
 // 			flag=true;
 // 		}
 // 		hash.insert(arr[i]);
 // 	}
 // 	if(flag)
 // 	{
 // 		ans++;
 // 	}
 // 	bool flag1=false;
 // 	for(int i=k;i<n;i++)
 // 	{
 // 		cout<<ans<<endl;
 // 		hash.erase(arr[i-k]);
 // 		if(hash.lower_bound(arr[i])!=hash.end())
 // 		{
 // 			ans++;
 // 		}else if(hash.lower_bound(arr[i-k])!=hash.begin())
 // 		{
 // 			ans++;
 // 		}else{
 // 			flag1=true;
 // 		}

 // 		hash.insert(arr[i]);	
 // 	}
 // 	if(!flag || !flag1)
 // 		ans++;
 // 	cout<<ans;

	int a,b;
	cin>>a>>b;
	int g=__gcd(a,b);
	int ans=0;
	int x=g;

	for(int i=2;i*i<=x;i++)
	{
		if(g%i==0)
		{
	
			ans++;
			while((g%i)==0)
			{
				g=(g/i);
			}
		}

	}
	if(g!=1)
		ans++;
	cout<<ans+1;
 	return 0;
}
 

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int ans=0;
    string s,t;cin >>s>>t;
    int n=s.size();
    for (int i = 0; i < n; ++i) {
        if(s[i]!=t[i])ans++;
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 3916
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let v: Vec<usize> = read_vec();
    let (h, w) = (v[0], v[1]);
    let grid: Vec<Vec<char>> = (0..h).map(|_| read::<String>().chars().collect()).collect();
    let big_int: u64 = 1000_000_000 + 7;

    let mut dp = vec![vec![0u64; w]; h];
    dp[0][0] = 1;

    for i in 0..h {
        for j in 0..w {
            if grid[i][j] == '#' {
                continue;
            }
            if i > 0 {
                dp[i][j] += dp[i - 1][j];
                dp[i][j] %= big_int;
            }
            if j > 0 {
                dp[i][j] += dp[i][j - 1];
                dp[i][j] %= big_int;
            }
        }
    }
    println!("{:?}", dp[h - 1][w - 1]);
}


Measured memory_bytes: 16636
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.DP
{
    class EDPC_K
    {
        public static void Main()
        {
            var nk = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int n = nk[0];
            int k = nk[1];

            var dp = new bool[k + 1];
            dp[0] = false;

            for (int i = 0; i <= k; i++)
                for (int j = 0; j < n; j++)
                    if (i >= a[j])
                        dp[i] |= !dp[i - a[j]];
            Console.WriteLine(dp[k] ? "First" : "Second");
        }
    }
}


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

int main() {
	const ll MOD = 1e9 + 7;
	int H, W, K;
	cin >> H >> W >> K;
	vector<int> x(W + 1, 0);
	x[0] = 1, x[1] = 2;
	for (int i = 2; i < x.size(); ++i) {
		x[i] = x[i - 2] + x[i - 1];
	}
	vector<int> y(W, 0);
	for (int i = 1; i < y.size(); ++i) {
		int l = max(0, i - 2), r = max(0, W - i - 2);
		y[i] = x[l] * x[r];
	}
	vector<int> z(W + 1, 0);
	for (int i = 1; i < z.size(); ++i) {
		int l = max(0, i - 2), r = max(0, W - i - 1);
		z[i] = x[l] * x[r];
	}

	vector<vector<ll>> dp(H + 2, vector<ll>(W + 1, 0));
	dp[0][1] = 1;
	for (int i = 0; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			if (i == H) {
				dp[i + 1][j] = dp[i][j];
				continue;
			}

			ll add = (dp[i][j] * z[j]) % MOD;
			dp[i + 1][j] = (dp[i + 1][j] + add) % MOD;

			if (j - 1 > 0) {
				add = (dp[i][j] * y[j - 1]) % MOD;
				dp[i + 1][j - 1] = (dp[i + 1][j - 1] + add) % MOD;
			}
			if (j + 1 <= W) {
				add = (dp[i][j] * y[j]) % MOD;
				dp[i + 1][j + 1] = (dp[i + 1][j + 1] + add) % MOD;
			}
		}
	}

	ll res = dp[H + 1][K];
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll dep[200001];
ll visited[200001]={0};
vector<vector<ll> > v(200001);
void dfs(ll node){
    visited[node]=1;
    dep[node]=1;
    for(ll child:v[node]){
        if(visited[child]==1) continue;
        dfs(child);
        dep[node]+=dep[child];
    }
}

int main() {
    fastio
	ll n,t,i,j,x,k,m;
    cin>>n>>m;
    set<pair<ll,ll>> st;
    
    ll a,b;
    for(i=0;i<m;i++){
        cin>>a>>b;
        if(!st.count({a,b}) && !st.count({b,a})){
            v[a].push_back(b);
            v[b].push_back(a);
            st.insert({a,b});
        }
    }
    
    ll ans=0;
    for(i=1;i<=n;i++){
       if(visited[i]==0)
       dfs(i);
       ans=max(ans,dep[i]);
    }
    cout<<ans;
    
	return 0;
}

Measured memory_bytes: 42212
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            String filename = "";
            if (filename.isEmpty()) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader(filename + ".in"));
                out = new PrintWriter(filename + ".out");
            }
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine(), " :");
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 1l * 200 * 1024 * 1024).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    void solve() throws IOException {
        int[] a = readIntArray(readInt());
        int min = a[0];
        int max = a[0];
        for (int x : a) {
            min = Math.min(min, x);
            max = Math.max(max, x);
        }
        out.println(max - min);
    }


}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

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

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ld l; cin >> l;
	ld ans = l/3;
	ans = ans*ans*ans;
	cout << setprecision(12) << ans << endl; 
}	
/* Benq's
	stuff you should look for
	* ll, int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 256
import math

N=int(input())
X=[]
Y=[]
for i in range(N):
	x,y=map(int,input().split())
	X.append(x)
	Y.append(y)
L=[]
for i in range(N-1):
	for j in range(i,N):
		l=math.sqrt(((X[i]-X[j])**2)+((Y[i]-Y[j])**2))
		L.append(l)
kai=(math.factorial(N))
ans=sum(L)*((kai*2)/N)/kai
print(ans)

Measured memory_bytes: 3188
import sys

def divisors(n):
  res = []
  for i in range(1, int(n ** 0.5) + 1):
    if n % i: continue
    res.append(i)
  return res

n = int(sys.stdin.readline().rstrip())

def main():
    res = divisors(n)
    print(len(str(n // res[-1])))

if __name__ ==  '__main__':
    main()

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

bool match(char x, char y) {
	return (x == '?' || y == '?' || x == y);
}

void Main() {
	vector<string> abc(3);
	cin >> abc;
	vint dat = {0, 1, 2};

	int ans = 6000;
	do {
		string a = abc[dat[0]], b = abc[dat[1]], c = abc[dat[2]];
		int A = a.size(), B = b.size(), C = c.size();
		vector<bool> bc(b.size()+1, false);

		vint cab, cac;
		for (int i = 0; i <= A; i++) {
			bool flag = true;
			for (int j = 0; j < B && i+j < A; j++) {
				flag &= match(a[i+j], b[j]);
			}
			if (flag) cab.push_back(i);
		}

		for (int i = 0; i <= B; i++) {
			bool flag = true;
			for (int j = 0; j < C && i+j < B; j++) {
				flag &= match(b[i+j], c[j]);
			}
			if (flag) bc[i] = true;
		}
		for (int i = 0; i <= A+B; i++) {
			bool flag = true;
			for (int j = 0; j < C && i+j < A; j++) {
				flag &= match(a[i+j], c[j]);
			}
			if (flag) cac.push_back(i);
		}

		for (int i = 0; i < cab.size(); i++) {
			for (int j = 0; j < cac.size(); j++) {
				if (cab[i] > cac[j]) continue;
				if (cac[j] - cab[i] >= b.size() || bc[cac[j] - cab[i]]) {
					chmin(ans, max({a.size(), cab[i] + b.size(), cac[j] + c.size()}));
				}
			}
		}
	} while (next_permutation(begin(dat), end(dat)));
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


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

int main()
{
    int prime[30000];
        prime[0] = 2;
    int num = 1, n;

    for(int i=3; i<50100; i++){
        bool f = true;
        for(int j=0; j<num; j++){
            if(i%prime[j] == 0){
                f = false;
                break;
            }
        }
        if(f){
            prime[num] = i;
            num++;
        }
    }

    while(cin >> n, !cin.eof()){

        int i;

        for(i=0; prime[i]<n; i++){
        }
        cout << prime[i-1] << ' ' << ((prime[i] == n) ? prime[i+1] : prime[i]) << endl;
    }

    return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define inf          INT_MAX
#define zer          INT_MIN
#define nl cout<<'\n' ; 
void prl(ll x) {cout << x <<'\n';}
void speed() { ios_base::sync_with_stdio(false);cin.tie(NULL);}
void checker(){ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);}

void solve()
{
	int n ; cin>>n ; 

	vector<vector<int>> dp(n+1 , vector<int>(3 , 0)) ; 

	dp[0][0]=0 , dp[0][1]=0 , dp[0][2] = 0; 

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

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

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

int main()
{
	speed();
  //  checker() ; 
    int T = 1;
   // cin >> T;
    while (T--){
    solve();
}
}



Measured memory_bytes: 8700
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
using namespace std;
using namespace __gnu_pbds;

const int MAXN = 200228;
ll a[MAXN];
ll b[MAXN];
int val[MAXN];
vector<int> e[MAXN];

ll ans = 0;

using Val = pair<ll, ll>;

const ll INF = (1ll << 60);

struct Better {
    bool operator()(const Val& l, const Val& r) const {
        return l.first * r.second > l.second * r.first;
    }
};

using Set = multiset<Val, Better>;
Better cmp;

Set dfs(int v) {
    Val vl = { val[v] == 0, val[v] == 1 };

    if (e[v].empty()) {
        return { vl };
    }

    vector<Set> c;
    for (int u : e[v]) {
        c.emplace_back(dfs(u));
    }

    int b = 0;
    for (int i = 1; i < c.size(); ++i) {
        if (c[i].size() > c[b].size()) {
            b = i;
        }
    }

    Set cur = move(c[b]);
    c[b].clear();
    for (Set& s : c) {
        for (auto elem : s) {
            cur.insert(elem);
        }

        s.clear();
    }

    while (!cur.empty() && !cmp(vl, *cur.begin())) {
        ans += ll(vl.second) * cur.begin()->first;
        vl.first += cur.begin()->first;
        vl.second += cur.begin()->second;
        cur.erase(cur.begin());
    }

    cur.insert(vl);
    return cur;
}

int main() {
#ifdef PAUNSVOKNO
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);  
    int n;
    cin >> n;
    for (int i = 2; i <= n; ++i) {
        int p;
        cin >> p;
        e[p].push_back(i);
    }

    for (int i = 1; i <= n; ++i) {
        cin >> val[i];
    }

    auto res = dfs(1);
    ll c1 = 0;
    for (auto val : res) {
        ans += c1 * val.first;
        c1 += val.second;
    }

    cout << ans << "\n";
}

Measured memory_bytes: 50176
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;

int n, k, cnt;
vector<P> e; vector<vector<int>> g;
void dfs(int now, int u, int cost) {
	if (cost > k / 2) cnt++;
	for (int v : g[now]) {
		if (v != u) dfs(v, now, cost + 1);
	}
}

int main() {
	cin >> n >> k;
	g.resize(n);
	rep(i, 0, n-1) {
		int a, b; cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
		e.push_back({ a,b });
	}
	int ans = inf;
	rep(rot, 0, 2) {
		if (k % 2) {
			for (P v : e) {
				cnt = 0;
				dfs(v.first, v.second, 0);
				dfs(v.second, v.first, 0);
				ans = min(ans, cnt);
			}
		}
		else {
			rep(i, 0, n) {
				cnt = 0;
				dfs(i, -1, 0);
				ans = min(ans, cnt);
			}
		}
		k--;
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 512
import heapq

x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())),reverse=True)
q=sorted(list(map(int,input().split())),reverse=True)
r=sorted(list(map(int,input().split())))

qu=[]

for i in range(x):
    heapq.heappush(qu,p[i])

for i in range(y):
    heapq.heappush(qu,q[i])

while r:
    rr=r.pop()

    if rr<qu[0]:
        break

    heapq.heappop(qu)
    heapq.heappush(qu,rr)

print(sum(qu))

Measured memory_bytes: 107388
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// 
int N, X;
int point[101000];
int diff[101000];
int ans = 0;


int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}


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

    rep(i, 0, N){
        cin >> point[i];
        diff[i] = abs(point[i] - X);
    }
    
    if(N == 1){
        ans = diff[0];
    }else{
        sort(diff, diff+N);
        int tmp = diff[0];
        if(tmp == 0) tmp = diff[1];
        rep(i, 0, N){
            if(diff[i] == 0) continue;
            tmp = gcd(tmp, diff[i]);
        }
        ans = tmp;
    }

    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
inline void solve(){
	int n;cin>>n;
	int d[n][3];
	for(int i=0;i<n;i++)for(int j=0;j<3;j++)cin>>d[i][j];
	int dp[n][3];
	memset(dp,-1,sizeof(dp));
	dp[0][0]=d[0][0];
	dp[0][1]=d[0][1];
	dp[0][2]=d[0][2];
	for(int i=1;i<n;i++){
		for(int j=0;j<3;j++){
			dp[i][j]=d[i][j];
			if(j==0)dp[i][j]+=max(dp[i-1][1],dp[i-1][2]);
			if(j==1)dp[i][j]+=max(dp[i-1][0],dp[i-1][2]);
			if(j==2)dp[i][j]+=max(dp[i-1][1],dp[i-1][0]);
		}
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return;
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;

namespace F
{
    class Program
    {
        static void Main(string[] args)
        {
            var Nuv = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = Nuv[0]; var u = Nuv[1]; var v = Nuv[2];
            var connections = new List<int>[N + 1];
            for (int i = 0; i < N + 1; i++) connections[i] = new List<int>();
            for (int i = 0; i < N - 1; i++)
            {
                var ab = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                connections[ab[0]].Add(ab[1]);
                connections[ab[1]].Add(ab[0]);
            }
            var distanceT = new int[N + 1];
            for (int i = 0; i < N + 1; i++) distanceT[i] = -1;
            distanceT[u] = 0;
            var queueT = new Queue<int>();
            queueT.Enqueue(u);
            while (queueT.Count > 0)
            {
                var current = queueT.Dequeue();
                foreach (int next in connections[current])
                {
                    if (distanceT[next] != -1) continue;
                    distanceT[next] = distanceT[current] + 1;
                    queueT.Enqueue(next);
                }
            }

            var distanceA = new int[N + 1];
            for (int i = 0; i < N + 1; i++) distanceA[i] = -1;
            distanceA[v] = 0;
            var queueA = new Queue<int>();
            queueA.Enqueue(v);
            while (queueA.Count > 0)
            {
                var current = queueA.Dequeue();
                foreach (int next in connections[current])
                {
                    if (distanceA[next] != -1) continue;
                    distanceA[next] = distanceA[current] + 1;
                    queueA.Enqueue(next);
                }
            }

            var end = 0;
            for (int i = 1; i < N + 1; i++)
            {
                if (distanceA[i] < distanceT[i]) continue;
                end = Math.Max(end, distanceA[i]);
            }
            Console.WriteLine(end - 1);
        }
    }
}


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

int main() {
    int N;
    cin >> N;
    int max_count = 0;
    unordered_map<string, int> hash;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        hash[s]++;
        max_count = max(max_count, hash[s]);
    }


    vector<string> S;
    for (auto p : hash) {
        if (p.second == max_count) {
            S.push_back(p.first);
        }
    }

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

    for (string s : S) {
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 26692
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <chrono>
#include <thread>
#include <thread>
#include <fstream>

using namespace std;

//const bool debug = false;

#ifndef M_PI
    const double M_PI = acos(-1.0);
#endif // M_PI

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
//#define ll long long
const int mod = int(1e9) + 7;
//const int inf = 1e7;
//const long long infLL = 1e16;
//const int MX2 = 10100500; //  e7
//const long long INF = 1e18 + 0.5;
const int MX = 300500; //       e6
const int SZ = 122;

int a[MX];

int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        if(u > v) swap(u, v);
        if(u == 0) a[v] |= 1;
        if(v == n - 1) a[u] |= 2;
    }
    for(int i = 0; i < n; i++){
        if(a[i] == 3) {cout << "POSSIBLE" << endl; return 0;}
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


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

int main()
{
    string input;
    cin >> input;

    bool isLucky = false;
    int l = input.length();

    for (int i = 0; i < l; ++i)
    {
        if (input.at(i) == '7')
        {
            isLucky = true;
            break;
        }
    }

    cout << (isLucky ? "Yes" : "No") << endl;
}

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

int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<int>> s(h + 1, vector<int>(w + 1));
  for (int i = 0; i < h; i ++) {
    for (int j = 0; j < w; j ++) cin >> s[i][j];
  }

  for (int i = 0; i < h; i ++) {
    int sum = 0;
    for (int j = 0; j < w; j ++) {
      sum += s[i][j];
    }
    s[i][w] = sum;
  }

  for (int j = 0; j < w + 1; j ++) {
    int sum = 0;
    for (int i = 0; i < h; i ++) {
      sum += s[i][j];
    }
    s[h][j] = sum;
  }

  for (int i = 0; i < h + 1; i ++) {
    for (int j = 0; j < w + 1; j ++) {
      if (j) cout << " ";
      cout << s[i][j];
    }
    cout << endl;
  }
}


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

const int INF = 1e9;

int main() {
    int n, k;
    cin>>n>>k;
    string s;
    cin>>s;
    s[k-1] = s[k-1] - 'A' + 'a';
    cout<<s<<endl;

}

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

int st[100];
int si=0;

int pop(){
  return st[--si];
}

void push(int val){
  st[si++]=val;
}

int main(){
  char t[10];
  int a,b;
  while (cin >>t){
    if ('0'<=t[0]&&t[0]<='9')push(atoi(t));
    else{
	b=pop();
	a=pop();
      if (t[0]=='+')push(a+b);
      else if (t[0]=='-')push(a-b);
      else if (t[0]=='*')push(a*b);
    }
  }
  cout << pop() << endl;
  return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod (1000000007)
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
void solve() 
{
    int n;cin>>n;
    ll sum0=0,sum=1;
    map<pair<ll,ll>,pair<int,int>>cnt;
    for(int i=0;i<n;i++){
        ll a,b;cin>>a>>b;
        if(a==0&&b==0){
            sum0++;
            continue;
        }
        ll G=gcd(a,b);
        a/=G;b/=G;
        if(b<0)a=-a,b=-b;//-180
        if(a<=0)cnt[{b,-a}].second++;//-90
        else cnt[{a,b}].first++;//0
    }
    for(auto it:cnt)(sum*=(mod+power(2,it.second.first)+power(2,it.second.second)-1)%mod)%=mod;//s-1+t-1+1
    cout<<(sum+sum0+mod-1)%mod<<endl;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

int main(){
  string S, T;
  cin >> S >> T;
  int count = 0;
  int ans = S.size();
  
  for (int i=0; i< S.size(); i++){
    if (S.at(i) == T.at(i)){
      count++;
    }
  }
    ans -= count;
    cout << ans << endl;
}

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

typedef unsigned long long int ll; 
#define MOD 1000000007
#define rep(i,n) fp(i,0,n)  
#define fp(i,a,b) for(ll i=(a);i<(b);++i)
#define fn(i,a,b) for(ll i=(a);i>(b);i--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define ff first
#define ss second
typedef pair<ll, ll> pll; 
typedef vector<pll> vpll;
typedef vector<ll> vll;
#define rs(t) string t;cin>>t
#define ri(t) int t;cin>>t
#define rll(t) long long int t;cin>>t
#define mk make_pair
#define pb push_back
#define po pop_back




int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a;
  cin >> a;
  int b;
  cin >> b;
  int count =0;
  int cv = 1;
  while(b>cv){
  	cv+=a-1;
  	count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
a=gets.chomp.split(" ").map { |e| e.to_i  }
a.sort!

def absolute(a,b)
  if a-b>0
    return a-b
  else
    return b-a
  end

end


cost = 0

for i in 1..2 do
  cost += absolute(a[i],a[i-1])
end

puts cost

Measured memory_bytes: 1788
n, m = map(int, input().split())

root = [-1]*n#各数字の親を-1で初期化
def r(x):
    if root[x] < 0: #親がなければ自分自身の値を返す
        return x
    else:
        root[x] = r(root[x])#親を辿る
        return root[x]

def unite(x, y):
    x = r(x)
    y = r(y)
    if x == y:#親が同じ場合
        return
    root[x] += root[y]
    root[y] = x #xをyの親とする

for i in range(m):
    a, b = map(int, input().split())
    a -= 1#0_indexにする
    b -= 1
    unite(a, b)

ans = 0
for i in range(n):
    ans = max(ans, -root[i])#要素数が最大の親が答え

print(ans)

Measured memory_bytes: 80916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
ll n,k,r,s,p;
string t;
cin >> n >> k;
cin >> r >> s >> p;
cin >> t;
ll ans = 0;
string a;
rep(i,k) {
  if (t[i] == 'r') {
    ans += p;
    a.push_back('p');
  } else if (t[i] == 's') {
    ans += r;
    a.push_back('r');
  } else if (t[i] == 'p') {
    ans += s;
    a.push_back('s');
  }
}
for (int i = k;i < n;i++) {
  if (t[i] == 'r' && a[i-k] != 'p') {
    ans += p;
    a.push_back('p');
  } else if (t[i] == 's' && a[i-k] != 'r') {
    ans += r;
    a.push_back('r');
  } else if (t[i] == 'p' && a[i-k] != 's') {
    ans += s;
    a.push_back('s');
  } else a.push_back('a');
}

cout << ans << endl;
return 0;
}



Measured memory_bytes: 3764
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))

a=min(A)
ans=0
l=[]

def gcd(lis,num):
    temp=[]
    for item in lis:
        if num%item!=0:
            pass
        else:
            temp.append(item)
    return temp

for i in range(1,int(a**0.5)//1+1):
    if a%i==0:
        l.append(i)
        l.append(a//i)

for item in A:
    l=gcd(l,item)

print(max(l))

Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long sumi = 0;
		long sumi1 = 0;
		long countPlus = 0;
		long countMinus = 0;
		long[] a = new long[n];
		for(int i = 0; i < n; i++) {
			a[i] = Long.valueOf(scan.next());
		}
		
		// 奇数がプラス
		for(int i = 0; i < n; i++) {
			sumi1 = sumi + a[i];
			if((i + 1) % 2 == 1) {
				if(sumi1 <= 0) {
					countPlus += Math.abs(sumi1) + 1;
					sumi1 += Math.abs(sumi1) + 1;
				}
			} else if((i + 1) % 2 == 0) {
				if(sumi1 >= 0) {
					countPlus += Math.abs(sumi1) + 1;
					sumi1 -= Math.abs(sumi1) + 1;
				}
			}
			sumi = sumi1;
		}
		sumi = 0;
		sumi1 = 0;
		
		// 奇数がマイナス
		for(int i = 0; i < n; i++) {
			sumi1 = sumi + a[i];
			if((i + 1) % 2 == 1) {
				if(sumi1 >= 0) {
					countMinus += Math.abs(sumi1) + 1;
					sumi1 -= Math.abs(sumi1) + 1;
				}
			} else if((i + 1) % 2 == 0) {
				if(sumi1 <= 0) {
					countMinus += Math.abs(sumi1) + 1;
					sumi1 += Math.abs(sumi1) + 1;
				}
			}
			sumi = sumi1;
		}
		
		if(countPlus < countMinus) {
			System.out.println(countPlus);
		} else {
			System.out.println(countMinus);
		}
		
		scan.close();

	}

}


Measured memory_bytes: 49312
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,C,D;
  int L,R;
  cin >> A >> B >> C >> D;
  L=A+B;
  R=C+D;
  if(L>R)
    cout << "Left" << endl;
  else if(L<R)
    cout <<"Right" << endl;
  else
    cout <<"Balanced" << endl;
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors





n = int(input()) 


l = list(range(n + 1))[1::2]

num = 0
for i in l:
    if len(make_divisors(i)) == 8:
        num += 1

print(num)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int x1 = sc.nextInt(), y1 = sc.nextInt(), x2 = sc.nextInt(), y2 = sc.nextInt();
        int x = x2 - x1;
        int y = y2 - y1;
        print(x2 - y, y2 + x, x2 - y - x, y2 + x - y);
    }

    private void print(int a, int b, int c, int d) {
        System.out.println(a + " " + b + " " + c + " " + d);
    }
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n, k;
  cin >> n >> k;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
    a[i]--;
  }

  vector<ll> visited(n, 0);
  int u = 0;
  int b = 1;
  while (visited[u] == 0){
    visited[u] = b;
    b++;
    u = a[u];
  }
  if (b < k){
    k = (k - visited[u] + 1) % (b - visited[u]);
    for (int i = 0; i < k; i++){
      u = a[u];
    }
  }
  else {
    u = 0;
    for (int i = 0; i < k; i++){
      u = a[u];
    }
  }

  cout << u + 1 << endl;
  

  

  return 0;
}


Measured memory_bytes: 6428
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

ll n , m;

int main(){
  cin >> n >> m;
  ll ans = min(n , m / 2);
  m -= n + n;
  if(m > 0) ans += m / 4;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main(){
  long long X,Y;
  cin>>X>>Y;
  if(-1<=X-Y&&X-Y<=1)cout<<"Brown"<<endl;
  else cout<<"Alice"<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/ruby
#coding: utf-8

require 'date'

KI = 1
W = 20 * KI
T = 18 * W
KA = 20 * T
B = 20 * KA

n = Date.new(2012, 12, 21)

def mayan(d)
  d = d.to_i
  s = []
  s << ((d / B) % 13).to_s
  d %= B
  s << (d / KA).to_s
  d %= KA
  s << (d / T).to_s
  d %= T
  s << (d / W).to_s
  d %= W
  s << d
  s.join('.')
end

def greg(d)
end

loop do
  s = gets.chomp
  break if s =~ /#/
  if s =~ /\d*\.\d*\.\d*\.\d*\.\d*/
    b, ka, t, w, ki = s.split('.').map(&:to_i)
    puts (n + b * B + ka * KA + t * T + w * W + ki * KI).to_s.split('-').map(&:to_i).join('.')
  else
    y, m, d = s.split('.').map(&:to_i)
    puts mayan(Date.new(y, m, d) - n)
  end
end

Measured memory_bytes: 6280