akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

template<typename T>
T power(typename std::common_type<T>::type a, int n) {
  T ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans *= a;
    }
    a = a * a;
    n >>= 1;
  }
  return ans;
}

using namespace std;

int main() {
  lli N, M; cin >> N >> M;
  lli a = power<lli>(2, M);
  cout << (1900*M + 100*(N-M)) * a << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;

int main()
{
	ll x;
	cin>>x;
	ll ans=x/11*2;
	x%=11;
	if(x>6) ans+=2;
	else if(x) ans++;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

int main(){
  int X, Y;
  cin >> X >> Y;
  if(Y % 2 == 0 && Y >= 2 * X && Y <= 4 * X) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3624
from heapq import heappush,heappop,heapify
from collections import defaultdict
X,Y,Z,K=map(int,input().split())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
A.sort()
B.sort()
C.sort()
heap=[(-(A[X-1]+B[Y-1]+C[Z-1]),X-1,Y-1,Z-1)]
heapify(heap)
D=defaultdict(bool)
for k in range(K):
  s,x,y,z=heappop(heap)
  while D[(x,y,z)]:
    s,x,y,z=heappop(heap)
  s*=-1
  D[(x,y,z)]=True
  print(s)
  if x>=1:
    heappush(heap,(-A[x-1]-B[y]-C[z],x-1,y,z))
  if y>=1:
    heappush(heap,(-A[x]-B[y-1]-C[z],x,y-1,z))
  if z>=1:
    heappush(heap,(-A[x]-B[y]-C[z-1],x,y,z-1))


Measured memory_bytes: 57304
n = int(input())
s = [2]
ans = []
t = 1
for i in range(3,55556):
    flg = True
    for _ in s:
        if i % _ == 0:
            flg = False
    if flg:
        s.append(i)
        if i % 5 == 1:
            ans.append(str(i))
            t += 1
    if t > n:
        break
print(' '.join(ans))

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

int main(){
  int n,k;
  cin >> n >> k;
  int l[n];
  for(int i=0;i<n;++i){
    cin >> l[i];
  }

  sort(l,l+n);
  int H = 0;
  for(int i=n-1;i>=n-k;--i){
    H += l[i];
  }

  cout << H << endl;
}


Measured memory_bytes: 256
import math

def getangle(pointstart,pointend):
    [sx,sy]=pointstart
    [ex,ey]=pointend
    return math.atan2(ey-sy,ex-sx)
    
def getdistance(pointstart,pointend):
    [sx,sy]=pointstart
    [ex,ey]=pointend
    return math.sqrt((ex-sx)**2+(ey-sy)**2)

while(1):
    n=int(raw_input())
    if n==0:
        break
    else:
        pointsnotyet=[]
        for i in range(n):
            pointsnotyet.append([int(x) for x in raw_input().split()])
        pointstart=[0,0]
        angle=math.pi/2
        ans=0
        for i in range(n):
            pointangle=getangle(pointstart,pointsnotyet[0])
            diff=-pointangle+angle
            if diff<0:
                diff+=math.pi*2
            candidateangle=diff
            candidatedistance=getdistance(pointstart,pointsnotyet[0])
            candidateindex=0
            for j in range(1,len(pointsnotyet)):
                pointangle=getangle(pointstart,pointsnotyet[j])
                pointdistance=getdistance(pointstart,pointsnotyet[j])
                diff=-pointangle+angle
                if diff<0:
                    diff+=math.pi*2
                if diff<candidateangle:
                    candidateangle=diff
                    candidatedistance=pointdistance
                    candidateindex=j
                elif diff==candidateangle and pointdistance<candidatedistance:
                    candidateangle=diff
                    candidatedistance=pointdistance
                    candidateindex=j
            pointend=pointsnotyet.pop(candidateindex)
            ans+=getdistance(pointstart,pointend)
            angle=getangle(pointstart,pointend)
            pointstart=pointend
        print round(ans,1)
                

Measured memory_bytes: 6584
use std::io::*;
use std::str::FromStr;

fn main() {
	let (taka_h, taka_a): (f32, f32) = (read(), read());
	let (aoki_h, aoki_a): (f32, f32) = (read(), read());
	let ans = if (taka_h/aoki_a).ceil() >= (aoki_h/taka_a).ceil() { "Yes" } else { "No" };
	println!("{}", ans);
}
 
fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 2620
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
int main(){

 //   freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();
    int n;cin>>n;
    double arra[n];

    forn(i,n)cin>>arra[i];

    double partial_ans = 0;
    forn(i,n){
    	partial_ans += 1.0/arra[i];
    }
    partial_ans = 1.0/partial_ans;

    cout<<setprecision(10)<<partial_ans;
    cerr << endl << setprecision(15) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


Measured memory_bytes: 256
/* Author : bhavye9499 - Bhavye Anand Gupta */

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define endl "\n"
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<ll,ll>
#define showArr(A,a,n) {for(int i=a; i<a+n; i++) cout << A[i] << " "; cout << endl;}
#define showPair(A,a,n) {for(int i=a; i<a+n; i++) cout << A[i].fi << " " << A[i].se << endl;}

const ll MOD = 1e9 + 7;

ll dp[101000], A[101000], n, k;

ll fun(ll i);

int main() {
    ios::sync_with_stdio(false);
    memset(dp, -1, sizeof(dp));
    memset(A, 0, sizeof(dp));
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
    	cin >> A[i];
    }
    for(int i = n; i < n + k; i++) {
    	A[i] = LLONG_MAX / 2;
    }
    ll ans = fun(0);
    cout << ans << endl;
}

ll fun(ll i) {
	if(i == n-1)
		return dp[i] = 0;
	if(i >= n)
		return dp[i] = LLONG_MAX / 2;
	if(dp[i] == -1) {
		ll ans = LLONG_MAX / 2;
		for(int j = i + 1; j < i + k + 1; j++) {
			ans = min(ans, abs(A[i] - A[j]) + fun(j));
		}
		return dp[i] = ans;
	}
	return dp[i];
}

Measured memory_bytes: 6528
import scala.io.StdIn._

object Main extends App {


  val Array(n,m) = readLine().split(" ").map(_.toInt)

  val as = Array.fill(m)(readInt())

  def solve() = {
    val broken = Array.fill(n+2)(false)
    as.foreach { num =>
      broken(num) = true
    }

    val mod = (1e9 + 7).toInt
    val dp = Array.fill(n+2)(0)
    dp(n) = 1

    for(i <- n-1 to 0 by -1) {
      if(!broken(i)) {
        dp(i) = (dp(i+1) + dp(i+2)) % mod
      }
    }
    dp(0)
  }

  println(solve())

}



Measured memory_bytes: 56740
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int a[] = new int[M];
		int b[] = new int[M];
		for(int i = 0; i < M; i++) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;
		}
		
		int cnt = 0;
		outside : for(int i = 0; i < M; i++) {
			
			UnionFind union = new UnionFind();
			union.init(N);
			for(int j = 0; j < M; j++) {
				if(j != i) {
					union.unite(a[j], b[j]);
				}
			}
			for(int j = 1; j < N; j++) {
				if(!union.same(0, j)) {
					cnt++;
					continue outside;
				}
			}
		}
		
		System.out.println(cnt);
	}
}

class UnionFind {
	static int N;
	static int par[];
	static int rank[];
	//初期化
	public static void init(int n) {
		N = n;
		par = new int[N];
		rank = new int[N];
		for(int i = 0; i < N; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}

	//木の根を求める
	public static int find(int x) {
		if(par[x] == x) {
			return x;
		} else {
			return par[x] = find(par[x]);
		}
	}
	
	//連結処理
	public static void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y) return;
		
		if(rank[x] < rank[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}
	
	//同じ集合に属するか判定する
	public static boolean same(int x, int y) {
		return find(x) == find(y);
	}
}


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

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

    if(a<b && c<b && a<c)
    cout << "Yes" << endl;
    else if(b<a && a>c && b<c)
    cout << "Yes" << endl;
    else
    cout << "No" << endl;

    return 0;
}

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

int main(){
  string S;
  cin >> S;
  set<char> s;
  for(int i=0;i<S.size();i++){
    s.insert(S.at(i));
  }
  for(auto x:s){
    if(x=='N'){
      if(!s.count('S')){
        cout << "No" << endl;
        return 0;
      }
    }else if(x=='S'){
      if(!s.count('N')){
        cout << "No" << endl;
        return 0;
      }
    }else if(x=='E'){
      if(!s.count('W')){
        cout << "No" << endl;
        return 0;
      }
    }else{
      if(!s.count('E')){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3572
//author : Yogi79

#include<bits/stdc++.h>
using namespace std;

vector<double>v;

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   long n;
   cin>>n;
   double t,ans;
   while(n--)
   {
      cin>>t;
      v.push_back(t);
   }
   sort(v.begin(),v.end());
   ans = v[0];

   for(int i=1;i<v.size();i++)
   {
      ans = (ans+v[i])/2.00;
   }
   cout<<ans;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int r = scan.nextInt();	//行数
		int c = scan.nextInt();	//列数
		int[][] array = new int[r + 1][c + 1];
		for(int i = 0; i < r; i++){
			for(int l = 0; l < c; l++){
					array[i][l] = scan.nextInt();
			}//for
			array[i][c] = sum(array[i]);
		}//for
		for(int i = 0; i < c + 1; i++){
			array[r][i] = sum(array, i);
		}
		for(int i = 0; i < r + 1; i++){
			for(int l = 0; l < c + 1; l++){
				if(l != 0) System.out.print(" ");
				System.out.print(array[i][l]);
			}//for
			System.out.println();
		}//for
	}
	public static int sum (int[] array){
		int n = 0;
		for(int i = 0; i < array.length - 1; i++){
			n += array[i];
		}
		return n;
	}
	public static int sum (int[][] array, int col){
		int n = 0;
		for(int i = 0; i < array.length - 1; i++){
			n += array[i][col];
		}
		return n;
	}
}

Measured memory_bytes: 38676
#include<iostream>
using namespace std;
int mp[200];
int main()
{
	int x,n;
    cin>>x>>n;
	for(int i=1;i<=n;i++){
		int k;
        cin>>k;
		mp[k]=1;
	}
	for(int i=0;i<=100;i++)
	{
		if(mp[x-i]==0){
			cout<<x-i<<endl;
			break;
		}
		else if(mp[x+i]==0){
			cout<<x+i<<endl;
			break;
		}
	}
}

Measured memory_bytes: 3184
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; i++)

char c[14][14];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

int belong[14][14];
int ok[10000];
int gx,gy;

int ans = 0;
int ccc = 0;
int dfs(int x,int y,int C,int px,int py){
	if( c[y][x] == '#' || c[y][x] == '*') return 0;
	if( C + abs(x-gx) + abs(y-gy) >= ans ) return 0;
	if( c[y][x] == 'G'){
		ans = C;
		return 0;
	}
	for(int i = 0 ; i < 4 ; i++){
		int tx = x + dx[i];
		int ty = y + dy[i];
		if( px == tx && ty == py ) continue;
		if( c[ty][tx] == '*' ) return 0;
	}
	char cur = c[y][x];
	c[y][x] = '*';
	for(int i = 0 ; i < 4 ; i++){
		int tx = x + dx[i];
		int ty = y + dy[i];
		if( c[ty][tx] == 'X' ){
			int b = belong[ty][tx];
			if( ok[b] > 0 ){
				ok[b]--;
				dfs(tx,ty,C+1,x,y);
				ok[b]++;
			}
		}else{
			dfs(tx,ty,C+1,x,y);
		}
	}
	c[y][x] = cur;
	return 0;
}
int grouping(int x,int y,int k){
	if( c[y][x] != 'X') return 0;
	if( belong[y][x] != -1 ) return 0;
	belong[y][x] = k;
	ccc++;
	for(int i = 0 ; i < 4 ; i++)
		grouping(x+dx[i],y+dy[i],k);
}

int main(){
	ios_base::sync_with_stdio(false);
	int W,H;
	while(cin >> W >> H && W){
		rep(i,14)rep(j,14) belong[i][j] = -1;
		rep(i,14)rep(j,14) 
			c[i][j] = '#';
		int sx , sy;
		for(int i = 0 ; i < H ; i++){
			for(int j = 0 ; j < W ; j++){
				cin >> c[i+1][j+1];
				if(c[i+1][j+1] == 'S'){
					c[i+1][j+1] = '.';
					sx = j+1 , sy = i+1;
				}else if(c[i+1][j+1] == 'G' ){
					gx = j+1 , gy = i+1;
				}
			}
		}
		int k = 0;
		for(int i = 1 ; i <= H ; i++){
			for(int j = 1 ; j <= W ; j++){
				if( c[i][j] == 'X' && belong[i][j] == -1){
					ccc = 0;
					grouping(j,i,k);
					ok[k] = ccc / 2;
					k++;
				}
			}
		}
		ans = 1e7;
		dfs(sx,sy,0,-1,-1);
		cout << ans << endl;
		
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<int>vec(N);
  int a =0;
  int b =0;
  for(int i = 0; i < N; i ++){
      cin >> vec.at(i);
  } 
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  for(int i = 0; i < N; i ++){
    if (i % 2 == 0){
      a += vec.at(i);
    }
    else {
      b += vec.at(i);
    }
  }
  cout << a -b <<endl;
}


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


#define ll long long
#define ull unsigned ll
#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define INF (int)1e9
#define EPS 1e-9
#define all(i, a, b) for(int i=a; i < b; i++)
#define all(a) a.begin(), a.end()
#define in(a,b) ( (b).find(a) != (b).end())
#define pb push_back
#define fill(a,constant) memset(a, constant, sizeof(a))
#define mp make_pair
#define checkbit(n,b) ( (n >> b) & 1)
#define PI acos(-1.0)
#define DEBUG 0
int main ()
{
    fast;

    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    vector <ll> red(a);
    vector <ll> green(b);
    vector <ll> null(c);
    vector <ll> mixed;

    for (int p=0; p<a; p++)
    {
        cin >> red[p];
    }
    for (int p=0; p<b; p++)
    {
        cin >> green[p];
    }
    for (int p=0; p<c; p++)
    {
        cin >> null[p];
    }

    ll sum = 0;

    sort(red.rbegin(), red.rend());
    sort(green.rbegin(), green.rend());
    sort(null.rbegin(), null.rend());

    for (int i=0; i<x; i++)
    {
        mixed.pb(red[i]);
    }

    for (int i=0; i<y; i++)
    {
        mixed.pb(green[i]);
    }

    sort(mixed.rbegin(), mixed.rend());
    int j;

    for (int i=mixed.size()-1, j=0; i>=0; i--, j++)
    {
        if (mixed[i] < null[j])
            mixed[i] = null[j];
        else break;
    }
    for (int p=0; p<mixed.size(); p++)
        {
            sum += mixed[p];
        }

    cout << sum << endl;



    return 0;
}


Measured memory_bytes: 4852
#include <bits/stdc++.h>
#include <fstream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define ll unsigned long long

const ll MOD = 1000000000000000000;

int main() {
	//入力
	vector<vector<int>> c(3, vector<int>(3));
	rep(i, 3) {
		rep(j, 3) {
			cin >> c[i][j];
		}
	}

	//処理
	string ans = "No";
	vector<int> a(3);
	vector<int> b(3);
	int a1 = min(min(c[0][0], c[0][1]),c[0][2]) + 1;
	int a2 = min(min(c[1][0], c[1][1]), c[1][2]) + 1;
	int a3 = min(min(c[2][0], c[2][1]), c[2][2]) + 1;
	rep(i, a1) {
		a[0] = i;
		int flg0 = 0;
		rep(ii, 3) {
			b[ii] = c[0][ii] - a[0];
			if (b[ii] < 0) {
				++flg0;
				break;
			}
		}
		if (flg0 == 0) {
			rep(j, a2) {
				int flg1 = 0;
				a[1] = j;
				rep(jj, 3) {
					if (b[jj] != c[1][jj] - a[1]) {
						++flg1;
						break;
					}
				}
				if (flg1 == 0) {
					rep(k, a3) {
						int flg2 = 0;
						a[2] = k;
						rep(kk, 3) {
							if (b[kk] != c[2][kk] - a[2]) {
								++flg2;
								break;
							}
						}
						if (flg2 == 0) {
							ans = "Yes";
							std::cout << ans << endl;
							return 0;
						}
					}
				}
			}
		}
	}

	//出力
	std::cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3636
import math

a, b, x = map(int, input().split())
v = a * a * b
if 2 * x <= v:
    print(90 - math.degrees(math.atan(((2 * x) / (a * b)) / b)))
else:
    print(math.degrees(math.atan((2 * (v - x) / (a * a)) / a)))


Measured memory_bytes: 2940
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 1e4 + 10;

int n, a[N];

vector<int> v;
void factorize(int n){
   for (int i = 2; i*i <= n; ++i)
   {
      if(n%i)continue;
      int expo = 0;
      while(n%i == 0){
         expo++;
         n/= i;
      }
      smax(v[i], expo);
   }
   if(n > 1){
      smax(v[n], 1LL);
   }
}

int power(int a, int b, int m = mod){a %= m; if(b < 0)b += m-1; int r = 1; while(b){if(b&1)r=(r*a)%m; a = (a*a)%m; b>>=1;}return r;}

int ans = 0;

int factorize2(int n){
   int pro2 = 1;
   for (int i = 2; i*i <= n; ++i)
   {
      if(n%i)continue;
      int expo = 0;
      while(n%i == 0){
         expo++;
         n/= i;
      }
      pro2 *= power(i, expo);
      pro2 %= mod;
   }
   if(n > 1){
      pro2 *= power(n, 1);
      pro2 %= mod;
   }
   return pro2;
}


int32_t main(){_
   
   cin>>n;
   v.resize(1e6 + 10);

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

   int pro = 1;
   for (int i = 0; i < (int)(v.size()); ++i)
   {
      pro *= power(i, v[i]);
      pro %= mod;
   }

   tr(pro);
   int ans = 0;
   for (int i = 0; i < n; ++i)
   {
      int vals = factorize2(a[i]);
      int curr = pro * power(vals, -1) % mod;
      ans += curr;
      ans %= mod;
   }
   
   cout<<ans;

   return 0;
}

Measured memory_bytes: 8192
n, x = map(int, input().split())
a = list(map(int, input().split()))

sort_a = sorted(a)
count = 0
if x > sum(a):
  count-=1
for i in sort_a:
  if x >= i:
    count+=1
    x-=i
  else:
    print(count)
    exit()
print(count)


Measured memory_bytes: 3060
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


n, m, l = map(int, input().split())
d = [[10**12 for i in range(n)] for i in range(n)]
for i in range(m):
    ai, bi, ci = map(int, input().split())
    d[ai-1][bi-1] = ci
    d[bi-1][ai-1] = ci
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０

d = warshall_floyd(d)
for i in range(n):
    for j in range(n):
        if d[i][j] <= l:
            d[i][j] = 1
        else:
            d[i][j] = 10**12

d = warshall_floyd(d)

q = int(input())
for i in range(q):
    si, ti = map(int, input().split())
    if d[si-1][ti-1] >= 10**12:
        print(-1)
    else:
        print(d[si-1][ti-1]-1)

Measured memory_bytes: 58584
n = int(input())
a = list(map(int,input().split()))
flg = 0
ans = a[0]

if 0 in a:
    print(0)
    flg = 2
if flg != 2:
    for i in range(1,n):
        ans = ans * a[i]
        if ans > 10 ** 18:
            flg = 1
            print(-1)
            break


if flg == 0:
    print(ans)


Measured memory_bytes: 84548
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <list>
 
// hloya template v25
  
// ░░░░░░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░░░░░
// ░░░░░░█░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░█░░░░░
// ░░░░░░█░█░▀░░░░░▀░░▀░░░░█░█░░░░░
// ░░░░░░█░█░░░░░░░░▄▀▀▄░▀░█░█▄▀▀▄░
// █▀▀█▄░█░█░░▀░░░░░█░░░▀▄▄█▄▀░░░█░
// ▀▄▄░▀██░█▄░▀░░░▄▄▀░░░░░░░░░░░░▀▄
// ░░▀█▄▄█░█░░░░▄░░█░░░▄█░░░▄░▄█░░█
// ░░░░░▀█░▀▄▀░░░░░█░██░▄░░▄░░▄░███
// ░░░░░▄█▄░░▀▀▀▀▀▀▀▀▄░░▀▀▀▀▀▀▀░▄▀░
// ░░░░█░░▄█▀█▀▀█▀▀▀▀▀▀█▀▀█▀█▀▀█░░░
// ░░░░▀▀▀▀░░▀▀▀░░░░░░░░▀▀▀░░▀▀░░░░
  
#include <bits/stdc++.h>
#include <valarray>
using namespace std;
  
bool dbg = 0;
  
clock_t start_time = clock();
#define current_time fixed<<setprecision(6)<<(ld)(clock()-start_time)/CLOCKS_PER_SEC
  
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
  
#define ll long long
#define ld long double
#define pii pair<int,int>
#define umap unordered_map<int, int>
  
#define files1 freopen("input.txt","r",stdin)
#define files2 freopen("output.txt","w",stdout)
#define files files1;files2
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)
  
// #define endl '\n'
#define ln(i,n) " \n"[(i) == (n) - 1]
  
void bad(string mes = "Impossible"){cout << mes;exit(0);}
void bad(int mes){cout << mes;exit(0);}
  
template<typename T>
string bin(T x, int st = 2){
    string ans = "";
    while (x > 0){
        ans += char('0' + x % st);
        x /= st;
    }
    reverse(ans.begin(), ans.end());
    return ans.empty() ? "0" : ans;
}
  
template<typename T>
void upmax(T& x, T y) {
    x = max(x, y);
}
  
template<typename T>
void upmin(T& x, T y) {
    x = min(x, y);
}
 
// inline int popcount(int x){
//     int count = 0;
//     __asm__ volatile("POPCNT %1, %0;":"=r"(count):"r"(x):);
//     return count;
// }
  
template<typename T>
T input(){
    T ans = 0, m = 1;
    char c = ' ';
  
    while (!((c >= '0' && c <= '9') || c == '-')) {
        c = getchar();
    }
  
    if (c == '-')
        m = -1, c = getchar();
    while (c >= '0' && c <= '9'){
        ans = ans * 10 + (c - '0'), c = getchar();
    }
    return ans * m;
}
  
template<typename T> void read(T& a) { a = input<T>(); }
template<typename T> void read(T& a, T& b) { read(a), read(b); }
template<typename T> void read(T& a, T& b, T& c) { read(a, b), read(c); }
template<typename T> void read(T& a, T& b, T& c, T& d) { read(a, b), read(c, d); }
  
const int inf = 1e9 + 20;
const short short_inf = 3e4 + 20;
const long double eps = 1e-6;
const int maxn = (int)3e5 + 12;//, base = 1e9 + 7;
const ll llinf = 2e18 + 5;
const double PI = acos(-1.0);
 
const int mod = 1e9 + 7;
  
template<typename T>
T binpow(T n, T s)
{
    if (s <= 0)
        return 1LL;
    if (s % 2 == 0){
        T b = binpow(n, s / 2);
        return ( 1LL * b * b ) % mod;
    } else {
        return (1LL* binpow(n, s - 1) * n) % mod;
    }
}

int main() {
	// files1;
	fast_io;
	
	ll n, a, b;
	cin >> n >> a >> b;

	if ((b - a) % 2 == 0) {
		cout << (b - a) / 2;
	} else {
		ll ans1 = a + (b - a) / 2;
		ll ans2 = n - b + 1 + (b - a) / 2;

		cout << min(ans1, ans2) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

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

	int n;
	cin >> n;

	ll sum = 0;
	vector<ll> as(n);
	for (int i = 0; i < n; ++i) {
		cin >> as[i];
		sum += as[i];
	}

	ll split = 0;
	ll pref = 0;
	for (int i = 0; i < n; ++i) {
		pref += as[i];
		if (abs(2*pref - sum) < abs(2*split - sum)) split = pref;
	}
	cout << abs(2*split - sum) << '\n';
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(void){
    int n, k, ans = 0;
    vector<int> p;
    set<int> s, u;
    cin >> n >> k;
    p.assign(n, 0);
    for(int i=0;i<n;i++){
        cin >> p[i];
    }

    int v = 0;
    for(int i=1;i<n;i++){
        if(p[i] < p[i-1]){
            v = i;
        }
        if(i-v+1 >= k){
            u.insert(i-k+1);
        }
    }

    for(int i=0;i<k;i++){
        s.insert(p[i]);
    }
    ans = n-k+1;
    for(int i=0;i<n-k;i++){
        s.erase(p[i]);
        auto mn = s.begin();
        auto mx = s.end(); mx--;

        if(p[i] < (*mn) && (*mx) < p[i+k]){
            if(u.find(i) == u.end() || u.find(i+1) == u.end())ans--;
        }

        s.insert(p[i+k]);

    }

    if(u.size() > 1){
        ans -= u.size()-1;
    }


    cout << ans << endl;

}


Measured memory_bytes: 10368
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007

using namespace std;


int main(void) {
	int n;
	int p;
	int count = 0;
	int *a;

	cin >> n;
	a = new int[n + 1];
	FOR(i, 1, n) {
		cin >> a[i];
	}
	sort(a, a + n + 1);
	FOR(i, 1, n - 1) {
		p = 1;
		FOR(t, i + 1, n) {
			if (a[i] == a[t]) {
				a[t] = -1;
				p++;
			}
			else {
				if (p % 2 == 0) {
					a[i] = -1;
				}
				i = t-1;
				break;
			}
			if (t == n) {
				if (p % 2 == 0) {
					a[i] = -1;
				}
				i = t-1;
				break;
			}
		}
	}
	FOR(i, 1, n) {
		//cout << a[i] << endl;
		if (a[i] != -1) {
			count++;
		}
	}
	cout << count << endl;

	delete[] a;
	return 0;
}

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

int main()
{
  ll n,k; cin>>n>>k;
  ll ans = k * pow(k-1, n-1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// for文、配列使わない方法。komeziさんより抜粋備忘

int main() {
    int in,s1=0,s2=0,s3=0;
    cin >> in;
    s1 = in / 100;
    s2 = in / 10 - s1 * 10;
    s3 = in - s1 * 100 - s2 * 10;
    cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
 
  if ((a+b) == (c+d)) {
    cout << "Balanced" << endl;
  }
  else if ((a+b) > (c+d)) {
    cout << "Left" << endl;
  }
  else  {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3608
import itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
V = N*10**3
dp = [[float('INF')]*(V+1) for _ in range(N+1)]
dp[0][0] = 0
for i,j in itertools.product(range(1,N+1),range(V+1)):
    w,v = wv[i-1]
    if j-v>=0 and dp[i-1][j-v]+w<=W:
        dp[i][j] = min(dp[i][j],dp[i-1][j-v]+w)
    dp[i][j] = min(dp[i][j],dp[i-1][j])
for k in range(V+1)[::-1]:
    if dp[-1][k]<=W:
        print(k)
        break


Measured memory_bytes: 316360
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,m;cin >> n >>m;
    vector<pair<pl,ll>> v(m);
    rep(i,m){
        cin >> v[i].fi.fi >> v[i].fi.se;
        v[i].se=i;
    }
    sort(all(v));
    vector<string> s(m);
    ll k=1;
    rep(i,m){
        string res;
        if(i!=0){
            if(v[i].fi.fi!=v[i-1].fi.fi)k=1;
            else k++;
        }
        ll p=k;
        while(p){
            res.pb((p%10)+'0');
            p/=10;
        }
        while(res.size()<6){
            res+='0';
        }
        rev(all(res));
        string form;
        ll city=v[i].fi.fi;
        while(city){
            form.pb((city%10)+'0');
            city/=10;
        }
        while(form.size()<6){
            form+='0';
        }
        rev(all(form));
        s[v[i].se]=form+res;
    }
    rep(i,m)cout << s[i] <<endl;
}

Measured memory_bytes: 9344
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), k = scanner.nextInt();
			int[] x = new int[n];
			IntStream.range(0, n).forEach(i -> x[i] = scanner.nextInt());
			System.out.println(IntStream.range(0, n - k + 1).map(i -> {
				if (x[i + k - 1] <= 0) {
					// 最大値が負数の場合
					return Math.abs(x[i]);
				} else if (x[i] >= 0) {
					// 最小値が整数の場合
					return x[i + k - 1];
				} else {
					return Math.max(-x[i], x[i + k - 1]) + 2 * Math.min(-x[i], x[i + k - 1]);
				}
			}).min().getAsInt());
		}
	}
}


Measured memory_bytes: 66812
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int k=sc.nextInt();
		int t=sc.nextInt();
		int count=0;
		for(int i=0;i<=k&&i<=t;i++) {
			for(int j=0;j<=k&&i+j<=t;j++) {
				if(t-(i+j)<=k)count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
int main()
{
    long long ans = 0;
    int n;
    cin>>n;
    int t;
    cin>>t; 
    for(int i = 1; i < n ; i++){
        int x;
        cin>>x;
        if(t > x){
            ans += abs(t-x);
        }
        else{
            t = x;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;

ll Getdigit(ll num){
	ll digit=0;
	while(num!=0){
		num /= 10;
		digit++;
		}
	return digit;
	}

int main(){
	ll N;
	cin >> N;
	ll ans=0;
	for(ll i=1;i<Getdigit(N);i+=2){
		ans+=9*pow(10,i-1)
	;}
	if(Getdigit(N)%2==1){ans+=N-pow(10,Getdigit(N)-1)+1;}
	cout<<ans<<endl;
	

return 0;
}  



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <utility>
#include <cctype>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#define LL long long
#define LB long double
#define x first
#define y second
#define Pair pair<int,int>
#define pb push_back
#define pf push_front
#define mp make_pair
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+9;
const LL LINF=2e16;
const int INF=2e9;
const int magic=348;
const double eps=1e-10;
const double pi=acos(-1);

inline int getint()
{
    char ch;int res;bool f;
    while (!isdigit(ch=getchar()) && ch!='-') {}
    if (ch=='-') f=false,res=0; else f=true,res=ch-'0';
    while (isdigit(ch=getchar())) res=res*10+ch-'0';
    return f?res:-res;
}

int n,e;
bool ga[748][748];
vector<int> v[748];
int type[748];
bool f=true;
int a[748];int tot=0;
int c1,c2;
bool dp[748][748];

inline int myabs(int x) {return x>=0?x:-x;}

inline void dfs(int cur)
{
	int i,y;
	if (type[cur]==1) c1++; else c2++;
	for (i=0;i<int(v[cur].size());i++)
	{
		y=v[cur][i];
		if (!type[y])
		{
			type[y]=3-type[cur];
			dfs(y);
		}
		else
		{
			if (type[y]+type[cur]!=3) f=false;
		}
	}
}

int main ()
{
	int i,x,y,j;n=getint();e=getint();
	for (i=1;i<=e;i++)
	{
		x=getint();y=getint();
		ga[x][y]=ga[y][x]=true;
	}
	int cnt=0;
	for (i=1;i<=n;i++)
		for (j=1;j<=n;j++)
			if (i!=j && !ga[i][j]) v[i].pb(j),cnt++;
	cnt/=2;
	for (i=1;i<=n;i++)
		if (!type[i])
		{
			type[i]=1;c1=c2=0;
			dfs(i);a[++tot]=myabs(c1-c2);
		}
	if (!f)
	{
		printf("-1\n");
		return 0;
	}
	dp[0][0]=true;
	for (i=0;i<=tot-1;i++)
		for (j=0;j<=n;j++)
			if (dp[i][j])
			{
				dp[i+1][j+a[i+1]]=true;
				dp[i+1][myabs(j-a[i+1])]=true;
			}
	int pt=0;
	while (!dp[tot][pt]) pt++;
	c1=(n+pt)/2;c2=(n-pt)/2;
	cnt=c1*c2-cnt;
	printf("%d\n",e-cnt);
	return 0;
}


Measured memory_bytes: 3072
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int main(){
  int x;
  cin >> x;
  cout << (x < 1200 ? "ABC\n" : "ARC\n");
}


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

long long N, M;

bool odd[100005];
bool even[100005];
vector<long long> tree[100005];


void dfs(long long cur, bool evenf){
	if(evenf){
		if(even[cur]){
			return;
		}else{
			even[cur] = true;
		}
	}else{
		if(odd[cur]){
			return;
		}else{
			odd[cur] = true;
		}
	}

	for(long long i = 0; i < tree[cur].size(); i++){
		dfs(tree[cur][i], !evenf);
	}
}

int main(){
	cin >> N >> M;
	for(long long i = 0; i < M; i++){
		long long A, B;
		cin >> A >> B;
		A--;B--;
		tree[A].push_back(B);
		tree[B].push_back(A);
	}
	dfs(0, true);

	long long oddnum = 0;
	long long evennum = 0;
	long long bothnum = 0;
	for(long long i = 0; i < N; i++){
		if(even[i]){
			evennum++;
			if(odd[i]){
				bothnum++;
			}
		}
		if(odd[i]){
			oddnum++;
		}
	}
	if(bothnum){
		long long ans;
		ans = N * (N-1)/2;
		cout << ans - M<< endl;

	}else{
		cout << (oddnum * evennum) - M<< endl;
	}





}


Measured memory_bytes: 8704
def calc_comb(n,r):
    numerator=1
    for i in range(n-r+1,n+1):
        numerator=(numerator*i)%mod
    denominator=1
    for i in range(1,r+1):
        denominator=(denominator*i)%mod
    return (numerator*pow(denominator,mod-2,mod))%mod
n,a,b=map(int,input().split())
mod=1000000007
print((pow(2,n,mod)-1-calc_comb(n,a)-calc_comb(n,b)+mod)%mod)



Measured memory_bytes: 9160
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    S = input()

    count = 0
    for i in range(N)[::-1]:
        if S[i] == ')':
            count += 1
        else:
            if count:
                count -= 1
            else:
                S += ')'
    S = '('*count + S
    print(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
import math
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def init(n):
  for i in range(1,N+1):
    par[i] = i
    rnk[i] = 0
    size[i] = 1
def find(x):
  if par[x] == x:
    return x
  else:
    par[x] = find(par[x])
    return par[x]
def numfind(x):
  if par[x] == x:
    return size[x]
  else:
    return numfind(par[x])
def unite(x, y):
  x = find(x)
  y = find(y)
  if x == y:
    return
  if (rnk[x] < rnk[y]):
    par[x] = y
    size[y] += size[x]
  else:
    par[y] = x
    size[x] += size[y]
    if(rnk[x] == rnk[y]):
      rnk[x] += 1
def same(x, y):
  return find(x) == find(y)

N,M,K = IL()
ab = [IL() for i in range(M)]
cd = [IL() for i in range(K)]

par = [0 for i in range(N+1)]
rnk = [0 for i in range(N+1)]
size = [0 for i in range(N+1)]
init(N)

fr = [[] for i in range(N+1)]
bl = [[] for i in range(N+1)]
for a,b in ab:
  fr[a].append(b)
  fr[b].append(a)

for a,b in ab:
  if same(a,b):
    continue
  else:
    unite(a,b)

ans = [-1]*N
for i in range(1,N+1):
  cnt = numfind(i) - len(fr[i]) -1
  ans[i-1] = cnt

for c,d in cd:
  if same(c,d):
    ans[c-1] -= 1
    ans[d-1] -= 1
print(*ans)


Measured memory_bytes: 126424
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll p=998244353;
ll n,m,ans,jc[1000010],ny[1000010];
ll ksm(ll x,ll y){
	ll xlh=1;
	while(y){
		if(y&1)xlh=xlh*x%p;
		x=x*x%p;
		y/=2;
	}
	return xlh;
}
ll C(ll x,ll y){
	return jc[x]*ny[y]%p*ny[x-y]%p;
}
int main(){
	ll i,op;
	scanf("%lld%lld",&n,&m);
	jc[0]=ny[0]=1;
	for(i=1;i<=max(n,m);i++)jc[i]=jc[i-1]*i%p,ny[i]=ksm(jc[i],p-2)%p;
	for(i=0;i<=min(n,m);i++){
		if(i%2)op=-1;
		 else op=1;
		ans=(ans+op*C(n,i)%p*C(m,i)%p*jc[i]%p*ksm(n+1,m-i)%p*ksm(m+1,n-i)%p+p)%p;
	}
	printf("%lld",ans);
}

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


#define ll long long int
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 

int main()
{
    ll n,m;
    cin>>n>>m;
    
    if(max(n,m)-min(n,m)>=2)
		cout<<0;
	else
	{
		if(n==m)
		{
		    ll x=fact(n);
		    ll ans=(x*x*2)%1000000007;
		    cout<<ans;
		}
		else
		{
		    cout<<(fact(n)*fact(m))%1000000007;
		}
	}
	return 0;
    // cout<<(fact(100000)*fact(100000)*2)%1000000007;
}

Measured memory_bytes: 3572
s = str(input())
if s == 'SUN':
    print(7)
elif s =='MON':
    print(6)
elif s == 'TUE':
    print(5)
elif s ==  'WED':
    print(4)
elif s ==  'THU':
    print(3)
elif s ==  'FRI':
    print(2)
else:
    print(1)

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

typedef long long ll;
const int mod=1e9+7;
int main(){
    ll m,n;
    cin>>m>>n;

    ll ans=1;

    for(int i=0;i<40;i++){
        if((n>>i)&1)ans=ans*m%mod;
        m=m*m%mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>

int main()
{
    char c;
    
    scanf( "%c", &c );

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' )
        printf( "vowel\n" );
    else
        printf( "consonant\n" );

        return 0;
}

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

using namespace std;

const long long MOD = 1e9 + 7;

int main() {
    int N, M;
    scanf("%d %d", &N, &M);

    long long nfac = 1, mfac = 1;
    for (int i = 2; i <= N; ++i) {
        nfac = (nfac * i) % MOD;
    }
    for (int i = 2; i <= M; ++i) {
        mfac = (mfac * i) % MOD;
    }

    if (N == M) {
        printf("%lld\n", (nfac * mfac) % MOD * 2 % MOD);
    } else if (N == M + 1 || M == N + 1) {
        printf("%lld\n", nfac * mfac % MOD);
    } else {
        printf("0\n");
    }

    return 0;
}


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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto N=in(),K=in();
	auto A=vecin(N);

	double ng = -1;
	double ok = 1ll<<50;

	while(abs(ok-ng)>1ll){
		double mid = ((ok + ng)*0.5);

		ll S=0;
		REP(i,N){
			S += (ll)ceil(A[i]/mid)-1ll;
		}
		if(S<=K) ok = mid;
		else ng = mid;
	}
	out((ll)ceil(round(ok)));
	return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <LL,LL>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,n2=1,a[200010],b[200010],dat[800010],dat2[800010],ans=0;
vector <LL> v,vv[200010];
map <LL,LL> mp;

void upd(LL k,LL val)
{
	dat[k]=max(dat[k],val);
	while(k>0)
	{
		k=(k-1)/2;
		dat[k]=max(dat[k],val);
	}
}

void upd2(LL k,LL val)
{
	dat2[k]=max(dat2[k],val);
	while(k>0)
	{
		k=(k-1)/2;
		dat2[k]=max(dat2[k],val);
	}
}

LL query(LL k,LL lb,LL ub,LL tlb,LL tub)
{
	if(ub<tlb||tub<lb) return 0;
	if(tlb<=lb&&ub<=tub) return dat[k];
	return max(query(k*2+1,lb,(lb+ub)/2,tlb,tub),query(k*2+2,(lb+ub)/2+1,ub,tlb,tub));
}

LL query2(LL k,LL lb,LL ub,LL tlb,LL tub)
{
	if(ub<tlb||tub<lb) return 0;
	if(tlb<=lb&&ub<=tub) return dat2[k];
	return max(query2(k*2+1,lb,(lb+ub)/2,tlb,tub),query2(k*2+2,(lb+ub)/2+1,ub,tlb,tub));
}

int main()
{
	cin>>n;
	rep(i,n)
	{
		scanf("%lld%lld",&a[i],&b[i]);
		v.pb(a[i]);
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	rep(i,v.size()) mp[v[i]]=i;
	rep(i,n) vv[mp[a[i]]].pb(b[i]);
	rep(i,v.size()) sort(vv[i].begin(),vv[i].end());
	while(n2<v.size()) n2*=2;
	rep(i,v.size())
	{
		ans=max(ans,vv[i].back()-vv[i][0]);
		if(i>0)
		{
			//cout<<ans<<endl;
			ans=max(ans,query(0,0,n2-1,0,i-1)-(LL)(1e9)+v[i]-(LL)(1e9)+vv[i].back());
			//cout<<query(0,0,n2-1,0,i-1)<<endl;
			ans=max(ans,query2(0,0,n2-1,0,i-1)-(LL)(1e9)+v[i]-vv[i][0]);
			//cout<<ans<<endl;
		}
		upd(i+n2-1,1e9-vv[i][0]+1e9-v[i]);
		upd2(i+n2-1,vv[i].back()+1e9-v[i]);
		//cout<<i<<' '<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 37776
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	// "sort"
	// "strconv"
	// "strings"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}

func NewConsole() Console {
	return Console{bufio.NewWriter(os.Stdout)}
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintln(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}

func PrintList(list []int) {
	con := NewConsole()
	defer con.Flush()
	for i := range list {
		if i == 0 {
			con.Printf("%d", list[i])
		} else {
			con.Printf(" %d", list[i])
		}
	}
	con.Println("")
}

func main() {
	con := NewConsole()
	defer con.Flush()

	var n uint32
	fmt.Scanf("%032d", &n)

	fmt.Printf("%032b\n", n)
	fmt.Printf("%032b\n", ^n)
	fmt.Printf("%032b\n", n<<1)
	fmt.Printf("%032b\n", n>>1)

}



Measured memory_bytes: 1180
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static long N;
        //static long X;
        //static int[] H;
        //static string S, T; 

        public static void Input()
        {
            var cin = new Scanner();
           
            N = long.Parse(Console.ReadLine());
            
        }

        static void Main(string[] args)
        {
            Input();
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            Console.WriteLine(N * (N - 1) / 2);

            //Console.Out.Flush();
        }

    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

        public int[] MultiLineReader(int N)
        {
            int[] ret = new int[N];
            for(var i = 0; i < N; i++)
            {
                ret[i] = int.Parse(Console.ReadLine());
            }

            return ret;
        }
        public long[] MultiLineReaderL(int N)
        {
            long[] ret = new long[N];
            for (var i = 0; i < N; i++)
            {
                ret[i] = long.Parse(Console.ReadLine());
            }

            return ret;
        }

    }

    public class Graph
    {
        
    }
}

    



Measured memory_bytes: 13140