akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;

long charCounter(string sentence, char character) {
    return count(sentence.cbegin(), sentence.cend(), character);
}

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

    if ((charCounter(S, S[0]) == 2) && (charCounter(S, S[1]) == 2) &&
        (charCounter(S, S[2]) == 2) && (charCounter(S, S[3]) == 2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''

cnt=0
s=input().strip("\n")
for i in range(2):
    if s[i]=="R" and cnt==0:
        cnt+=1
    if s[i]==s[i+1]=="R":
        cnt+=1
if s[2]=="R" and cnt==0:
    cnt+=1
print(cnt)

Measured memory_bytes: 9116
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main()
{
	string s;
	set<int> m2;
	vector<int> result;
	cin>>s;
	for(int i = 0; i < s.length(); i++){
		int num = s[i] - 'a';
		if(m2.count(num) == 0) m2.insert(num);
	}
	
	for(int i = 0; i < 26; i++){
		if( m2.count(i) == 0) result.push_back(i);
	}
	if( result.size() == 0){
		cout<<"None"<<endl;
	}else{
		cout<<(char)(result[0] + 'a')<<endl;
	}
	return 0;
}



Measured memory_bytes: 3168
a = [0]*1000000
a[0] = int(input())

for i in range(1,1000000):
  if a[i-1]%2 == 0:
    if a[i-1]/2 in a:
      print(i+1)
      break
    a[i] = a[i-1]/2
  else:
    if 3*a[i-1]+1 in a:
      print(i+1)
      break
    a[i] = 3*a[i-1]+1


Measured memory_bytes: 70128
#include <iostream>
#include <queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s){
    queue<int> q;
    q.push(s);
    for(int i=0; i<n; i++) d[i] = INFTY;
    d[s] = 0;
    int u;
    while(!q.empty()){
        u = q.front(); q.pop();
        for(int v=0; v<n; v++){
            if(M[u][v] == 0) continue;
            if(d[v] != INFTY) continue;
            //cout <<v<<" "<<d[v];
            d[v] = d[u] + 1;
            //cout <<"->"<< d[v] << endl;
            q.push(v);
        }
    }
    for(int i=0; i<n; i++){
        cout << i+1 << " " << ((d[i] == INFTY) ? (-1):d[i]) << endl;
    }
}

int main(){
    int u, k, v;
    
    cin >> n;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++) M[i][j] = 0;
    }
    
    for(int i=0; i<n; i++){
        cin >> u >> k;
        u--;
        for(int j=0; j<k; j++){
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    
    bfs(0);
    
    return 0;
}


Measured memory_bytes: 3128
n, a, b, c, d = map(int, input().split())
s = input()
a-=1
b-=1

index1 = s[a:c].find("##")
index2 = s[b:d].find("##")

ans = "No"

if index1 == -1 and index2 == -1:
  if c < d :
    ans = "Yes"
  elif s[b-1:d+1].find("...") != -1 :
    ans = "Yes"
  
print(ans)

Measured memory_bytes: 3572
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
#include <random>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
#define DBG(a) cerr<<(a)<<endl;
#define dump(a) cerr<<#a <<' '<< a <<endl;
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
typedef pair<int,int>PI; typedef vector<int> VI;
const LL LINF=334ll<<53; const int INF=15<<26; const LL MOD=1E9+7;

long long modpow(long long a, long long n){
    if(n==0) return 1;
    long long re=modpow((a*a)%MOD,n/2)%MOD;
    if(n%2==1) re= (re*a)%MOD;
    return re;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI a(n);
    REP(i,n) cin >> a[i];
    sort(ALL(a));
    if(a[0]==0){
        FOR(i,1,n){
            if(a[i]!=i+i%2){
                cout << 0 << endl;return 0;
            }
        }
        cout << modpow(2,n/2)<<endl;
    }else if(a[0]==1 and a[1]==1){
        FOR(i,2,n){
            if(a[i]!=i+1-(i%2)){
                cout << 0 << endl;return 0;
            }
        }
        cout << modpow(2,n/2)<<endl;
    }else{
        cout << 0 << endl;return 0;
    }


    return 0;
}


Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = input()
S = input()

ans = 0

for i in range(1000):
    x = str(i).zfill(3)
    idx = 0
    for s in S:
        if x[idx] == s:
            idx += 1
        if idx == 3:
            break
    if idx == 3:
        ans += 1
print(ans)


Measured memory_bytes: 78840
#include <cstdio>
    #include <iostream>
    #define MAXN 1005
    using namespace std;
    int n, m;
    int a[MAXN][MAXN];
    long long ans[MAXN][MAXN];
    char c;
    int main(){
        cin >> n >> m;
        for (int i = 1; i <= n; i++){
            for (int j = 1; j <= m; j++){
                cin >> c;
                if (c == '.'){
                   a[i][j] = 0;
                }else{
                   a[i][j] = 1;
                }
            }
        }
        ans[1][1] = 1;
        for (int i = 1; i <= n; i++){
            for (int j = 1; j <= m; j++){
                if (a[i][j] == 0){
                if (a[i][j - 1] == 0){
                   ans[i][j] += ans[i][j - 1];
                }
                if (a[i - 1][j] == 0){
                   ans[i][j] += ans[i - 1][j];
                }
                }
                ans[i][j] = ans[i][j] % 1000000007;
            }
        }
        cout << ans[n][m] << endl;
        /*for (int i = 0; i <= 3; i++){
            for (int j = 0; j <= 4; j++){
                cout << ans[i][j] << ' ';
            }
            cout << endl;
        }*/
    }

Measured memory_bytes: 12032
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void){

    string S,T; cin>>S>>T;
    int T_size = T.size();

    S+=S;
    for (int i = 0; i < T_size; ++i) {
        if(T == S.substr(i, T_size)){
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
# include <iostream>
using namespace std;
int a[20],n,m,k;
bool f;
void dfs(int w,int tar)
{
	if(tar == 0) { f = true; return ;}
	for(int i = w+1;i < n;i++) if(a[i] <= tar) dfs(i,tar-a[i]);
}
int main(void)
{
	scanf("%d",&n);
	for(int i = 0;i < n;i++) scanf("%d",&a[i]);
	scanf("%d",&m);
	while(m--)
	{
		f = false;
		scanf("%d",&k);
		dfs(-1,k);
		printf("%s\n",f?"yes":"no");
	}
	return 0;
} 


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define int long long

bool isPrime(int n)
{
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
            return 0;
    }
    return 1;
}

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    //int t=1 ; cin>>t ; while(t--)
    {
        int n;
        cin >> n;

        for(int i=n;;i++)
        {
            if(isPrime(i))
                return cout << i, 0;
        }


    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <vector>
using namespace std;
int V, s, t, p, q, d[100]; vector<pair<int, int> > G[100];
int main() {
	scanf("%d", &V);
	for(int i = 0; i < V; i++) {
		scanf("%d%d", &s, &t);
		for(int j = 0; j < t; j++) {
			scanf("%d%d", &p, &q);
			G[i].push_back(make_pair(p, q));
		}
	}
	for(int i = 1; i < V; i++) d[i] = 999999999;
	priority_queue<pair<int, int> > que; que.push(make_pair(0, 0));
	while(!que.empty()) {
		int v = que.top().second; que.pop();
		for(int i = 0; i < G[v].size(); i++) {
			int u = G[v][i].first, w = G[v][i].second;
			if(d[u] > d[v] + w) {
				d[u] = d[v] + w;
				que.push(make_pair(-d[u], u));
			}
		}
	}
	for(int i = 0; i < V; i++) printf("%d %d\n", i, d[i]);
	return 0;
}

Measured memory_bytes: 2728
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )

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


int main()
{

        string s; cin>>s;

        for(int i = 0 ; i<s.length() ; i++)
        {
            cout<<"x";
        }



    return 0;
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
mod = 1000000007
def main():
    N = I()
    L = LI()
    D = [0]*(N+2)
    D[0] = 3
    ans = 1
    
    for num in L:
        if D[num] == 0 or D[num+1] >= 3:
            print(0)
            sys.exit()
        temp = D[num] - D[num+1]
        D[num+1] += 1
        ans *= temp
        ans = ans % mod
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 79576
H,W=map(int,input().split())
a=[]
for y in range(H):
    a.append(list(map(int,input().split())))

ans = []
for y in range(H-1):
    for x in range(W):
        if a[y][x] % 2 == 1:
            ans.append((y+1, x+1, y+2, x+1))
            a[y][x] -= 1
            a[y+1][x] += 1
y=H-1
for x in range(W-1):
    if a[y][x] % 2 == 1:
        ans.append((y+1, x+1, y+1, x+2))
        a[y][x] -= 1
        a[y][x+1] += 1

print(len(ans))
for t in ans:
    print(' '.join(map(str,t)))


Measured memory_bytes: 26252
#include<iostream>
using namespace std;
#include<iostream>
using namespace std;
int main(){
    int r,c,num;
    int array[101][101];
    int sarray[101][101];
    int i,j;
    int rsum=0,csum=0,fsum=0;

    cin>>r>>c;
    //input number
    for(i=0;i<r;i++){
        for( j=0;j<c;j++){
            cin>>array[i][j];
            rsum += array[i][j];
            
        }
        array[i][c] = rsum;
        fsum += rsum;
        rsum = 0;
    }

    for(i=0;i<c;i++){
        for(j=0;j<r;j++){
            csum += array[j][i];
        }
        array[j][i] = csum;
        csum = 0;
    }
    array[r][c] = fsum;

    //output number
    for(i=0;i<=r;i++){
        for(j=0;j<=c;j++){
          cout<<array[i][j];
          if(j==c)break;
          cout<<" ";
        }
        cout<<endl;
    }

    return 0;
}


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

int main(){
/*	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
*/	
	int n;
	scanf("%d",&n);
	int a[n];
	for(int i = 0 ; i < n; i++){
		scanf("%d",&a[i]);
	}
	
	int max = a[0];
	int min = a[0];
	for(int i = 0; i < n; i++){
		if(a[i] < min)
			min = a[i];
		if(a[i] > max)
			max = a[i];
	}

	cout << max - min << endl;

  	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int H,W,i,j;
    
    while(1){

    scanf("%d %d",&H,&W);
    if(H==0 && W==0) break;
    
    for(j=0;j<H;j++){
    for(i=0;i<W;i++){
        printf("#");
    }
    printf("\n");
    }
    
    printf("\n");
    }
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> v(n+10);
  vector<int> c(n+10);
  rep(i,n) cin >> v[i];
  rep(i,n) cin >> c[i];
  int ans = 0;
  rep(i,n){
    if(v[i] > c[i]){
      ans += v[i] - c[i];
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

  int res=0;
  for (int i = 1; i <= n; i+=2) {
    int c=0;
    for (int j = 1; j <= i; j++) {
      if(i%j==0)c++;
    }
    if(c==8) res++;
  }

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


Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	S, T := sc.nextStr(), sc.nextStr()

	fmt.Fprintln(wtr, T+S)
	wtr.Flush()
}


Measured memory_bytes: 640
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    ll N;
    cin >> N;
    vec<int> d(N);
    REP(i, N){
        cin >> d[i];
    }
    sort(ALL(d));
    cout << d[N/2]-d[N/2-1] << el;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define mid (l+r>>1)
using namespace std;
int main()
{
	ll T;
	cin>>T;
	while (T--)
	{
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		ll now=max((a-1)/(b+1),(b-1)/(a+1))+1;
		ll l=0,r=min(a/now,b),ret=0;
		while (l<=r)
		{
			ll A=a-now*mid,B=b-mid;
			if (max(B/(A+1),(A-1)/(B+1))<now) ret=mid,l=mid+1;
			else r=mid-1;
		}
		ll lim=ret;
		l=0,r=min(now,a-lim*now),ret=0;
		while (l<=r)
		{
			ll A=a-now*lim-mid,B=b-lim;
			if (max((mid?B:B-(lim==0))/(A+1),(A-1)/(B+1))<now)
				ret=mid,l=mid+1;
			else r=mid-1;
		}
		lim*=now+1;
		lim+=mid+1;
		for (ll i=c;i<lim&&i<=d;i++)
			putchar(i%(now+1)==0?'B':'A');
		for (ll i=max(lim,c);i<=d;i++)
			putchar((a+b-i+1)%(now+1)==0?'A':'B');
		puts("");
	}
	return 0;
}


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

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

	bool flag=true;
	for (int i = 1; i < s.size(); ++i){
		if(s[i]!='9')
			flag=false;
	}

	if(s.size()==1)
		cout<<s[0]-'0'<<endl;
	else if(flag&&s[0]!='9')
		cout<<s[0]-'0'+(s.size()-1)*9<<endl;
	else if(flag&&s[0]=='9')
		cout<<s.size()*9<<endl;
	else
		cout<<s[0]-'0'-1+(s.size()-1)*9<<endl;
		
}


Measured memory_bytes: 256
a,b,c,x = map(int,[input() for i in range(4)])
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500 + j*100 + k*50 == x:
                count = count + 1
print(count)

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
    int S = sc.nextInt();
    int W = sc.nextInt();  
      
  if(W>=S){
  System.out.println("unsafe");
  }
  else{
  System.out.println("safe");  
  }
    }
}

Measured memory_bytes: 35704
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll N,i,ans=0;
    cin>>N;
    ll A[N];
    ll B[N];
    for(i=0;i<N;i++)
    {
        cin>>A[i];
        cin>>B[i];
    }
    sort(A,A+N);
    sort(B,B+N,greater<ll>());
    if (N%2==1){
    ll min = A[N/2];
    ll max = B[N/2];
    ans = max - min + 1;
  } else {
    long long min = (A[N/2-1] + A[N/2]);
    long long max = (B[N/2-1] + B[N/2]);
    ans = max - min + 1;
  }
  cout<<ans;
}

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

int N, r, t;

int main()
{
	cin >> N;
	for (int _i = 0; _i < N; _i++)
	{
		cin >> r >> t;
		int pr = r % 100;
		r /= 100;
		int pt = t % 30;
		t /= 30;
		int x = r + 5 * t;
		if (pr == 0)
		{
			if (pt == 0)
				cout << x << endl;
			else
				cout << x << " " << x + 5 << endl;
		}
		else
		{
			if (pt == 0)
				cout << x << " " << x + 1 << endl;
			else
				cout << x << " " << x + 1 << " " << x + 5 << " " << x + 6 << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		int g = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == 'g') {
				g++;
			}
		}
		int p = s.length() - g;

		if (p < g) {
			System.out.println((g - p) / 2);
		} else {
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 23716
#include <bits/stdc++.h>
#define sc(x) scanf("%d", &x)
#define pr(x) printf("%d\n", x)
#define lowbit(x) (x & -x)
#define ll long long
#define N 100010
#define memset(x) memset(x, 0, sizeof(x))
using namespace std;
int n, ans, a[N];
int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	sc(n);
	for (int i = 1; i <= n; i++)
	sc(a[i]);
	ans = 0;
	for (int i = 1; i <= n; i++)
	for (int j = i + 1; j <= n; j++)
	ans += a[i] * a[j];
	printf("%d\n", ans);
	return 0;
}


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

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

    long long sum = 0;
    for (int a = 1; a <= K; ++a) {
        for (int b = 1; b <= K; ++b) {
            int g1 = __gcd(a, b);
            for (int c = 1; c <= K; ++c) {
                int g2 = __gcd(g1, c);
                sum += g2;
            }
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3624
gets
  a=gets.split.map(&:to_i)
  r = 1
  t = 0
  k = 0
  a.each do |x|
    t= 1 if r*x > 10**18
    k = 1 if x == 0
    r *= x if t == 0
  end
  if k==1
    puts 0
  elsif t==1
    puts -1
  else
    puts r
  end

Measured memory_bytes: 24136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
int n, k;
struct edge{
    int u, v;
}e[N];
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> k;
    int MX = (n - 2) * (n - 1) / 2;
    if(k > MX) {
        cout << -1;
        return 0;
    }
    e[1] = {1, 2};
    for(int i = 3; i <= n; i++) e[i - 1] = {2, i} ;
    int tot = n;
    for(int i = 1; MX != k; i++) {
        if(i == 2) continue ;
        for(int j = i + 1; j <= n && MX != k; j++) {
            if(j == 2) continue ;
            e[tot++] = {i, j};
            MX--;
        }
    }
    cout << tot - 1 << '\n';
    for(int i = 1; i < tot; i++) cout << e[i].u << ' ' << e[i].v << '\n';
    return 0;
}


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

int main() {
	ll h, w;
	cin >> h >> w;
	if (min(h, w) == 1) {
		cout << 1 << endl;
		return 0;
	}
	ll n = h * w;
	ll ans = (n + 1) / 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int n, a, b, c;
int l[8] = {};
int ans = 1000000000;

void dfs(string select, int depth) {
    if (depth == n) {
        int len[3] = {};
        int mp = 0;
        rep(i, 0, n) {
            if (select[i] == '0') {
                if (len[0] != 0) mp += 10;
                len[0] += l[i];
            }
            if (select[i] == '1') {
                if (len[1] != 0) mp += 10;
                len[1] += l[i];
            }
            if (select[i] == '2') {
                if (len[2] != 0) mp += 10;
                len[2] += l[i];
            }
        }

        if (!len[0] || !len[1] || !len[2]) return;

        mp += abs(len[0] - a) + abs(len[1] - b) + abs(len[2] - c);
        ans = min(ans, mp);
        return;
    }

    rep(i, 0, 4) {
        dfs(select + (char)(i + '0'), depth + 1);
    }
}

int main() {
    cin >> n >> a >> b >> c;
    rep(i, 0, n) cin >> l[i];

    string x;
    dfs(x, 0);

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


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a, b;
	cin >> n >> a >> b;
	int c = 0, d = 0, e = 0;
	rep(i,n){
		int p;
		cin >> p;
		if(p <= a) ++c;
		else if(p <= b) ++d;
		else ++e;
	}
	int ans = min({c, d, e});
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
map<string,int> num;
int n,ans;
int main()
{
	scanf("%d",&n);
	string s;
	for(int i=1;i<=n;++i) {
		cin>>s;
		if(num[s]==0) ++ans;
		++num[s];
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 19368
#include <iostream>
const int SIZE=10,TOPNUM=3;
using namespace std;

int main(){
  int height[SIZE],top[TOPNUM+1]={0};
  for( int i=0;i<SIZE;i++ ){
    cin>>height[i];
    if( height[i]<0||10000<height[i] )
      return 1;
    for( int j=0;j<TOPNUM;j++ ){
      if( top[j]<=height[i] ){
	for( int k=TOPNUM;k>j;k-- ){
	  top[k]=top[k-1];
	}
	top[j]=height[i];
	break;
      }
    }

  }
  for( int i=0;i<TOPNUM;i++ ){
    cout<<top[i]<<endl;
  }
}

Measured memory_bytes: 1160
numbers = {str(i) for i in range(10)}
N, K = map(int, input().split())
*D, = map(str, input().split())
D = set(D)
available = numbers - D
ans = 0
for i in range(N, 100000):
    nums = set(str(i))
    if nums <= available:
        print(i)
        break


Measured memory_bytes: 3060
def pm(x):
  if X>=0:
    return 1
  else:
    return -1
X,K,D=map(int,input().split())
if (abs(X))<D :
  if K%2==0:
    print(int(abs(X)))
  else:
    a=X-pm(X)*D
    print(int(abs(a)))
else:
  if abs(X)//D>=K:
    a=X-(pm(X))*D*K
    print(int(abs(a)))
  else:
    K=K-int(abs(X)//D)
    X=X-(pm(X))*D*int(abs(X)//D)
    if (abs(X))<D :
      if K%2==0:
        print(int(abs(X)))
      else:
        a=X-(pm(X))*D
        print(int(abs(a)))

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

int dp[3001];

int main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;

    int res = 0;
    rep(i, 3001) rep(j, 3001) {
        int temp = n-(r*i + g*j);
        if(temp >= 0 && temp%b == 0) res++;
    }
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }




int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char>> s(h);
	vector<vector<int>> yoko(h), tate(h);
	rep(i, h) {
		s[i].resize(w);
		yoko[i].resize(w);
		tate[i].resize(w);
		rep(j, w) {
			cin >> s[i][j];
		}
	}

	rep(i, h) {
		int c = 0;
		rep(j, w) {
			if (s[i][j] == '.') {
				c++;			}
			else {
				int back = j-1;
				while (back >= 0 && s[i][back] != '#') {
					yoko[i][back] = c;
					back--;
				}
				c = 0;
			}

			if (j == w - 1 && c > 0) {
				int back = j;
				while (back >= 0 && s[i][back] != '#') {
					yoko[i][back] = c;
					back--;
				}
				c = 0;
			}
		}
	}

	rep(i, w) {
		int c = 0;
		rep(j, h) {
			if (s[j][i] == '.') {
				c++;
			}
			else {
				int back = j - 1;
				while (back >= 0 && s[back][i] != '#') {
					tate[back][i] = c;
					back--;
				}
				c = 0;
			}

			if (j == h - 1 && c > 0) {
				int back = j;
				while (back >= 0 && s[back][i] != '#') {
					tate[back][i] = c;
					back--;
				}
				c = 0;
			}
		}
	}

	int ans = 0;
	rep(i, h) {
		rep(j, w) {
			int z = yoko[i][j] + tate[i][j] - 1;
			ans = max(ans, z);
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 35584
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
w = nsn(n)

flag = True
dic = dict()
last = w[0][0]
for i in range(n):
    if dic.get(w[i], False):
        flag = False
    if last != w[i][0]:
        flag = False
    last = w[i][-1]
    dic[w[i]] = True

print("Yes" if flag else "No")

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

int main()
{
  int N[4];
  for (auto & n : N)
    cin >> n;
  sort(N, N + 4);
  if (1 != N[0])
    cout << "NO";
  else if (4 != N[1])
    cout << "NO";
  else if (7 != N[2])
    cout << "NO";
  else if (9 != N[3])
    cout << "NO";
  else
    cout << "YES";
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

typedef long long LL;
const int mod = 1e9 + 7;

struct matrix{ LL mat[5][5]; }g, g0, ans;
matrix operator*(matrix a, matrix b)
{
    matrix tmp; memset(tmp.mat, 0, sizeof(tmp.mat));
    Rep0(i, 3) Rep0(j, 3) Rep0(k, 3) tmp.mat[i][j] = (tmp.mat[i][j] + a.mat[i][k] * b.mat[k][j]) % mod;
    return tmp;
}
void qpow(matrix &a, int k)
{
    matrix tmp; memset(tmp.mat, 0, sizeof(tmp.mat));
    Rep0(i, 3) tmp.mat[i][i] = 1;
    while (k){
        if (k & 1) tmp = tmp * a;
        a = a * a, k >>= 1;
    }
    a = tmp;
}

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	int la = 0;
	ans.mat[0][0] = 1;
	g0.mat[3][3] = 1;
	g0.mat[1][3] = 1, g0.mat[1][1] = 1;
	g0.mat[2][3] = 1, g0.mat[2][2] = 1;
	g0.mat[0][0] = 1, g0.mat[0][1] = 1, g0.mat[0][2] = 1, g0.mat[0][3] = 1;
	Rep(i, m + 1) {
		int x;
		if (i <= m) scanf("%d", &x);
		else x = n + 1;
		memset(g.mat, 0, sizeof(g.mat));
		g.mat[3][0] = 1, g.mat[3][3] = 1;
		g.mat[1][0] = 1, g.mat[1][1] = 1, g.mat[1][3] = 1;
		g.mat[2][0] = 1, g.mat[2][2] = 1, g.mat[2][3] = 1;
		g.mat[0][3] = 1, g.mat[0][1] = 1, g.mat[0][2] = 1, g.mat[0][0] = 2;
		qpow(g, x - la - 1);
		ans = ans * g;
		if (i <= m) ans = ans * g0; 
		la = x;
	}
	
	printf("%d\n", ans.mat[0][3]);
	
	return 0;
}

Measured memory_bytes: 128
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC
 
------------------------------------------
 
cardOrder = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
 
main :: IO ()
main = do
  [a, b] <- map (fromJust . flip findIndex cardOrder . (==)) <$> readInts
  putStrLn $ case compare a b of
               LT -> "Bob"
               EQ -> "Draw"
               GT -> "Alice"
 
------------------------------------------
 
{- Int input -}
 
parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt
 
parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words
 
readInt :: IO Int
readInt = parseInt <$> BC.getLine
 
readInts :: IO [Int]
readInts = parseInts <$> BC.getLine
 
{- Double Formatting -}
 
doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"

Measured memory_bytes: 508
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  string a;
  cin >> a;
  int b = a.size();
  for(int i = b-2;i>=0;i-=2){
    bool exist = true;
    for(int j = 0;j<i/2;j++){
      if(a.at(j)!=a.at(j+i/2)) exist = false;
    }
     if(exist) {
       cout << i << endl;
       return 0;
     }
  }
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    map<char,int> mp;
    rep(i,n) {
        ++mp[s[i]];
    }
    ll ans = 1;
    for (auto tmp_mp:mp){
      ans = (ans*((ll)tmp_mp.second+1LL)%mod)%mod;
    }
    cout << ans - 1LL << endl;
    return 0;
}


Measured memory_bytes: 512
#pragma GCC optimze("Ofast")
#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;
#define mod 1000000007
#define md 998244353
#define trace(...)
#define ll long long int
#define ld long double
#define fi first
#define se second
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,b,a) for(ll i=b;i>=a;i--)
#define mem(a) memset(a, 0, sizeof(a))
#define vpi std::vector<pair<int,int>>
#define pii pair<int,int>
#define pb push_back
#define sall(v) sort(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define minf -10000000
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
ll power(ll x, ll y,ll p) { 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {  
        if (y & 1) // If y is odd, multiply x with result
            res = (res*x) % p;  
        y = y>>1; // y = y/2 // y must be even now
        x = (x*x) % p;   
    } 
    return res; 
}
ll power(ll x, ll y) { 
    ll res = 1;      // Initialize result 
    while (y > 0) {    
        if (y & 1)// If y is odd, multiply x with result 
            res = (res*x) ;  
        y = y>>1; // y = y/2 // y must be even now 
        x = (x*x);   
    } 
    return res; 
}
 
ll max3(ll a,ll b,ll c){
    return max(a,max(b,c));
}
ll min3(ll a,ll b,ll c){
    return min(a,min(b,c));
}
bool isPrime(ll n) { // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}

void solve() {
    int n;cin>>n;
    int arr[n+1];
    fr(i,1,n)cin>>arr[i];
    sort(arr+1,arr+n+1);
    cout<<arr[n/2+1]-arr[n/2]<<endl; 
    return ;
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout<<fixed<<setprecision(8);
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    #ifndef ONLINE_JUDGE
    //cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif
    return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3

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

    ans = [0] * (N + 1)

    for x in range(1, 100):
        for y in range(1, 100):
            for z in range(1, 100):
                f = x * x + y * y + z * z + x * y + y * z + z * x
                if f < N + 1:
                    ans[f] += 1
    ans.remove(0)
    print('\n'.join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9440
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

lli xorx(lli x) {
    if (x < 0) return 0;
    if (x % 4 == 0) return x;
    if (x % 4 == 1) return 1;
    if (x % 4 == 2) return (x + 1);
    if (x % 4 == 3) return 0;
}

void solve() {
    lli a, b;
    cin >> a >> b;
    lli ans = xorx(b) ^ xorx(a - 1);
    cout << ans << endl;
}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int64 sum=0;

int64 calc(int index,int n,char *s){
  if(index==n) return sum;
  int64 res=0;
  int64 m=0;
  int i;
  for(i=index;i<n;i++){
    int d=s[i]-'0';
    m=10*m+d;
    sum+=m;
    res+=calc(i+1,n,s);
    sum-=m;
  }
  return res;
}

void run(void){
  char s[11];
  scanf("%s",s);
  int n=0;
  while(s[n]!='\0') n++;
  int64 ans=calc(0,n,s);
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vpl vector<pair<long long,long long>>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
long long MOD = 1000000007;
const long double pi = 3.1415926535897932;
#define pb push_back
#define mp make_pair
#define mt make_tuple
using Grid = vector<vector<char>>;
#define vc vector<char>
//(mod m)でのaの逆元を計算する
//a/b(mod m)=a(mod m)*modinv(b,m)
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//UF
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll N,M,K;
    cin>>N>>M>>K;
    map<ll,ll> m;
    UnionFind uf(N);
    rep(i,M){
        ll a,b;
        cin>>a>>b;
        a--; b--;
        m[a]++;
        m[b]++;
        uf.merge(a,b);
    }
    rep(i,K){
        ll a,b;
        cin>>a>>b;
        a--; b--;
        if(uf.issame(a,b)){
            m[a]++;
            m[b]++;
        }
    }
    rep(i,N){
        ll Ans=uf.size(i);
        Ans--;
        Ans-=m[i];
        cout<<Ans<<" ";
    }
    cout<<endl;
}

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

int main() 
{
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(), v.end());

    double ans = 0;
    auto div = [&](double x, int m) {
        rep(i,m) {
            x /= 2.0;
        }
        return x;
    };
    ans += div(v[0], n-1);
    for(int i=1; i< n; i++) {
        ans += div(v[i], n-i);
    }

    printf("%.10f\n", ans);
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>

using namespace std;
using ll = long long;

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

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


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


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

    vector<vector<int>> upper(h, vector<int>(w)), bottom(h, vector<int>(w));
    vector<vector<int>> left(h, vector<int>(w)), right(h, vector<int>(w));
    for (int j = 0; j < w; j++) {
        int cnt = 0;
        for (int i = 0; i < h; i++) {
            if (s[i][j] == '.') cnt++;
            else cnt = 0;
            upper[i][j] = cnt;
        }

        cnt = 0;
        for (int i = h-1; i >= 0; i--) {
            if (s[i][j] == '.') cnt++;
            else cnt = 0;
            bottom[i][j] = cnt;
        }
    }

    for (int i = 0; i < h; i++) {
        int cnt = 0;
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '.') cnt++;
            else cnt = 0;
            left[i][j] = cnt;
        }

        cnt = 0;
        for (int j = w-1; j >= 0; j--) {
            if (s[i][j] == '.') cnt++;
            else cnt = 0;
            right[i][j] = cnt;
        }
    }

    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') continue;
            int add = upper[i][j] + bottom[i][j] + left[i][j] + right[i][j] - 3;
            ans = max(ans, add);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 67200
s = str(input())
n = len(s)
k = 0
ls =[]
for i in range(2**(n-1)):
    a = []
    for j in range(n-1):
        if (i >> j)&1:
            a.append(j)
    ls.append(a)
for p in range(len(ls)):
    l = list(s)
    for q in ls[p][::-1]:
        l = l[:q+1] + ["+"] + l[q+1:]
    b = eval("".join(l))
    k += b
print(k)

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

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

    int n, m;
    cin >> n >> m;
    vector<int> hs(n);
    for (int i = 0; i < n; i++) cin >> hs[i];
    vector<vector<int>> adj(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        bool ok = true;
        for (int a : adj[i]) {
            if (hs[a] >= hs[i]) {
                ok = false;
                break;
            }
        }
        if (ok) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 8748
import * as fs from "fs";

const split = (str: string): string[] =>
  str.split(" ").map((v: string) => v.trim());
const split_number = (str: string): number[] =>
  split(str).map((v: string) => +v);

export function main(input: string) {
  const lines = input.split("\n");
  const n = split_number(lines[0]);

  n.sort();

  if (n[0] === n[1] && n[1] === n[2]) {
    return "No";
  } else if (n[0] === n[1] || n[1] === n[2]) {
    return "Yes";
  } else {
    return "No";
  }
}

if (!process.env.LOCAL_DEBUG) {
  console.log(main(fs.readFileSync("/dev/stdin", "utf8")));
}


Measured memory_bytes: 7372
package main

import "fmt"

func main() {
	//変数の定義
	var N int
	//変数の読み込み %dは整数を表す。
	fmt.Scanf("%d", &N)
	//Nが奇数かどうかの判定。yは奇数となる確率を表す。
	//x := N % 2
	//Nの余りを計算。偶数ならｘは0。奇数ならxは1。
	//条件分岐
	if N%2 == 1 {
		fmt.Printf("%.10f", (float64(N+1)/2)/float64(N))
	} else {
		fmt.Printf("%.10f", float64(0.5))
	}
	//	i := N
	//	d := i / 3
	//	m := i % 3
	//	fmt.Println(d, m)

	// 参考
	//var a, b int
	//var calc string

	//fmt.Printf("Please enter the calculation formula.\n")
	//fmt.Printf("ex) 1 + 1 = ? -> 1 1 +\n")
	//fmt.Scanf("%d %d %s", &a, &b, &calc)

	//fmt.Printf("%d %s %d = ", a, calc, b)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in insert
#define mp make_pair
#define F first
#define pb push_back
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}
int main(){
    ll n,m; cin>>n>>m;
    vector<ll> a;
    ll sum=0;
    for(ll i=0;i<n;i++){
        ll x; cin>>x;
        a.pb(x);
    }
    vector<pair<ll,ll> > v(m);
    for(ll i=0;i<m;i++){
        cin>>v[i].second>>v[i].first;
    }
    sort(v.begin(),v.end(), greater<pair<ll,ll> > ());
     ll count=0;
    for(ll i=0;i<m;i++){
        ll b=v[i].second;
        ll c=v[i].first;
        for(ll j=0;j<b;j++){
            if(count==n)
                break;
            a.pb(c);
            count++;
        }
   
    }
    sort(a.begin(),a.end(),greater<ll>());
    for(ll i=0;i<n;i++)
        sum+=a[i];
    cout<<sum;
    return 0;
}


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

using namespace std;
vector<long long> factors;
#define ll long long


#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

template<typename T>
int BS(vector<T> &mas, T val)
{
	int l, r;
	l = 0;
	r = mas.size() - 1;
	while (r - l > 1)
	{
		int mid = l + (r - l) / 2;
		if (mas[mid] < val)
		{
			l = mid;
		} else
			r = mid;
	}
	if (mas[r] == val)
		return r;
	if (mas[l] == val)
		return l;
	return -1;
}

ll mod(ll a, ll m)
{ return (a + (abs(a) / m) * m + m) % m; }

struct elem
{
	ll a, b, delta;
};

int main()
{
	IOS

	int n;
	cin >> n;
	vector<elem> vec(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> vec[i].a >> vec[i].b;
		vec[i].delta = vec[i].a + vec[i].b;
	}
	sort(all(vec),[](elem a, elem b){
		if(a.delta!=b.delta)
		return a.delta < b.delta;
		else{
			return a.a < b.a;
		}
	});
	ll t  =0 ,a = 0;
	ll r = n - 1;
	for(int i = 0;i < n ;++i){
		if(i%2 == 0){
			t+=vec[r].a;
			--r;
		}else{
			a+=vec[r].b;
			--r;
		}
	}
	cout << t - a;
	return 0;
}

/*
 	map<ll,vector<pll>> res;
	for(int i = 0;i < n; ++i){
		ll a,b;
		cin >> a >> b;
		res[b - a].push_back({a,b});
	}
	for(auto& i : res){
		sort(all(i.second),[](pll a,pll b){
			return a.first < b.first;
		});
	}
	int ind = 0;
	ll ao = 0;
	ll tak  =0;
	for(int i = 0;i < res.size();){
		if(ind % 2 == 0){
			auto i = res.rbegin();
			tak += i->second[i->second.size() - 1].first;
			i->second.pop_back();
			if(i->second.size() == 0)
				res.erase(i->first);
		}else{
			auto i = res.begin();
			ao += i->second[i->second.size() - 1].second;
			i->second.pop_back();
			if(i->second.size() == 0)
				res.erase(i->first);
		}
		++ind;
	}

	cout << tak - ao;
 */

Measured memory_bytes: 2560