akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int ten[101],zyun[101];
	int n,a,b,c,d,i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++)	{
		ten[i]=0;	zyun[i]=1;
	}
	for(i=0;i<n*(n-1)/2;i++)	{
		scanf("%d %d %d %d",&a,&b,&c,&d);
		if(c>d)	{
			ten[a]+=3;
		}
		else if(c<d){
			ten[b]+=3;
		}
		else {
			ten[a]++;	ten[b]++;
		}
	}
	for(i=1;i<n;i++)	{
		for(j=i+1;j<=n;j++)	{
			if(ten[i]<ten[j])	zyun[i]++;
			if(ten[i]>ten[j])	zyun[j]++;
		}
	}
	for(i=1;i<=n;i++)	{
		printf("%d\n",zyun[i]);
	}
	return 0;
}


Measured memory_bytes: 1028
#include<iostream>

using namespace std;
int n,m;
bool V[1000];
bool C[1000][1000];
int P[1000];

int gcd(int a,int b);
bool match(int a);

int main(){


  while(cin >> n >> m && (n>0 || m>0) ){
    int blue[n],red[m];
    
    for(int i=0;i<n;i++){
      cin >> blue[i];
    }
    for(int i=0;i<m;i++){
      cin >> red[i];
      P[i]=-1;
      V[i]=false;
    }

    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	if(gcd(blue[i],red[j])>1)C[i][j]=1;
	else C[i][j]=0;
      }
    }
    int ans=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++)V[j]=false;
      if(match(i)) ans++;
    }
    
    cout << ans << endl;
  }
}

int gcd(int a,int b){
  if(a<b){
    int temp=b;
    b=a;
    a=temp;
  }

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

bool match(int a){
   if(a<0)return true;

   for(int j=0;j<m;j++){
     if(!C[a][j] || V[j] )continue;
     V[j]=true;
     if(match(P[j])){
       P[j]=a;
       return true;
     }
   }
   return false;
 }

   

Measured memory_bytes: 1676
# AOJ 0034 Railway Lines

while line = gets
  dat = line.split(",").map(&:to_i)
  lengths, v1, v2 = dat[0..9], dat[10], dat[11]

  distances = [0]
  lengths.each.with_index(1) do |l, i|
    distances[i] = distances[i - 1] + l
  end

  x = v1.to_f / (v1 + v2) * distances.last

  distances.each_with_index do |d, i|
    if x <= d
      puts i
      break
    end
  end
end

Measured memory_bytes: 6132
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iostream>

using namespace std;

double norm(int x[], int y[], int p, int n)
{
	long long sum = 0;
	for(int i = 0; i < n; i++)
	{
		sum += pow(abs(x[i] - y[i]), p);
	}
	return pow(sum, 1.0 / p);
}

double inf_norm(int x[], int y[], int n)
{
	int max = abs(x[0] - y[0]);

	for(int i = 1; i < n; i++)
	{
		max = (max > abs(x[i] - y[i])) ? (max) : (abs(x[i] - y[i]));
	}

	return max;
}

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

	int x[n], y[n];
	for(int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	for(int i = 0; i < n; i++)
	{
		cin >> y[i];
	}

	printf("%.8f\n", norm(x, y, 1, n));
	printf("%.8f\n", norm(x, y, 2, n));
	printf("%.8f\n", norm(x, y, 3, n));
	printf("%.8f\n", inf_norm(x, y, n));
	return 0;
}


Measured memory_bytes: 3344
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for(int i=0; i<n; i++){
			s[i] = sc.next();
		}
		Arrays.sort(s);
		int result = n;
		for(int i=0; i<n-1; i++){
			if(s[i].equals(s[i+1])){
				result--;
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 70752
gets.chomp.to_i.times do
  first,second,third,point,out = [0]*5
  while out < 3 do
    action = gets.chomp
    if action == 'HIT'
      point+=1 if third == 1
      first,second,third = 1,first,second
    elsif action == 'HOMERUN'
      point += first + second + third + 1
      first,second,third = [0]*3
    else
      out+=1
    end
  end
  puts point
end

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

int main() {
  //定義一覧
  int tmp = 1;
  int tmpA = 0;
  int tmpB = 0;
  int N;
  int K;
  
  //入力
  cin >> N >> K;
  for(int i = 0; i < N; i++){
  	tmpA = tmp * 2;
    tmpB = tmp + K;
    if(tmpA < tmpB){
    	tmp = tmpA;
    }else{
    	tmp = tmpB;
    }
    //cout << i << ":" << tmp << endl;
  }
  
  cout << tmp << endl;
}

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

using namespace std;

int main(void)
{
    int H, W, i, j, k, l, count[100][100];
    string S[51];

    cin >> H >> W;

    for(i=1; i<=H; i++){
        cin >> S[i];
    }

    for(i=0; i<=H; i++){
        for(j=0; j<=W; j++){
            count[i][j] = 0;
        }
    }


    for(i=1; i<=H; i++){
        for(j=0; j<W; j++){
            if(S[i][j] == '#'){
                for(k=i-1; k<=i+1; k++){
                    for(l=j-1; l<=j+1; l++){
                        if(l!=-1){
                            count[k][l]++;
                        }
                    }
                }
            }
        }
    }

    for(i=1; i<=H; i++){
        for(j=0; j<W; j++){
            if(S[i][j] == '#'){
                cout << '#';
            }
            
            else{
                cout << count[i][j];
            }
        }

        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,sm = 0,a;
  int d[10][10];
  cin >> h >> w;
  for(int x=0;x<10;x++){
    for(int y=0;y<10;y++){
      cin >> d[x][y];
    }
  }
  for(int k=0;k<10;k++)
    for(int i=0;i<10;i++)
      for(int j=0;j<10;j++)
        if(d[i][j] > d[i][k] + d[k][j]) 
          d[i][j] = d[i][k] + d[k][j];
  for(int x=0;x<h;x++){
    for(int y=0;y<w;y++){
      cin >> a;
      if(a == -1) continue;
      sm += d[a][1];
    }
  }
  cout << sm << endl;
}

Measured memory_bytes: 256
n = 287117
a = Array.new(n){|i| i+1}
a[0] = 0
(2..n**(0.50)).each do |i|
  (2..(n/i)).each{|j| a[i*j-1] = 0} if a[i-1]>0
end
b=Marshal.load(Marshal.dump(a))
a.delete(0)

while (m=gets.to_i)>0
  c=0
  a.each_with_index do |i, idx|
    break if i>(m/2)
    c+=1 unless b[m-i-1]==0
  end
  p c
end

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

int main()
{
	int N;
	cin >> N;
	int L[110];
	for (int i = 0;i < N;i++) {
		cin >> L[i];
	}

	sort(L, L + N, greater<int>());

	int sum = 0;

	for (int i = 1;i < N;i++) {
		sum += L[i];
	}

	if (L[0] >= sum) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

bool f(int n) {
    return n / 10 == 9 || n % 10 == 9;
}

int main() {

    int n;
    std::cin >> n;

    if (f(n)) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans = 0;
  if(a + b < c * 2){
    ans = x * a + b * y;
  }else{
    if(x < y){
      ans = min(x * 2 * c + (y - x) * b, y * 2 * c);
    }else{
      ans = min(y * 2 * c + (x - y) * a, x * 2 * c);
    }
  }
  cout << ans << endl;

  return 0;
}




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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}
          
  
int main() {
  string S; 
  cin >> S;
  int N = S.size(); 
  int G = 0, P = 0;
  int cnt=0;
  rep(i,N){
    if(G==P){
      G++;
      if(S[i]=='p') cnt--;
    }
    else if(S[i]=='p'){
      P++;
    }
    else{
      P++;
      cnt++;
    }
  }
  cout << cnt << endl;
}
  



Measured memory_bytes: 512
#include<stdio.h>
int main()
{
  int n,i,a[200001]={0},v[200001]={0};
  scanf("%d",&n);
  for(i=2;i<=n;i++){
    scanf("%d",&a[i]);
    v[a[i]]++;
  }
  for(i=1;i<=n;i++)
    printf("%d\n",v[i]);
  return 0;
}


Measured memory_bytes: 3280
string1 = input()
string2 = input()

dp = [[0 for i in range(len(string1) + 1)] for j in range(len(string2) + 1)]
substring = ""
for i in range(len(string2) + 1):
    for j in range(len(string1) + 1):
        if i == 0 or j == 0:
            dp[i][j] = 0
        elif string2[i - 1] == string1[j - 1]:
            dp[i][j] = 1 + dp[i - 1][j - 1]
        else:
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])

def recon(dp, string1, string2):
    string = ""
    i, j = len(dp) - 1, len(dp[0]) - 1
    while i != 0 and j != 0:
        if dp[i][j] > max(dp[i - 1][j], dp[i][j - 1]):
            string += string2[i - 1]
            i -= 1
            j -= 1
        else:
            if dp[i - 1][j] > dp[i][j - 1]:
                i -= 1
            else:
                j -= 1

    return string

print(recon(dp, string1, string2)[::-1])

Measured memory_bytes: 153276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<int> cnt(n);
	rep(i,m){
		int a,b;cin >> a >> b;
		a--;b--;
		cnt.at(a)++;
		cnt.at(b)++;
	}
	rep(i,n){
		if(cnt.at(i)%2==1){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
            #define REP(i,n) for(int i=0;i<n;i++)
            #define LOOP(i,x,n) for(int i=x;i<n;i++)
            #define ALL(v) (v).begin(),(v).end()
            #define PB push_back
            #define MP make_pair
            #define FIR first
            #define UB upper_bound
            #define LB lower_bound
            #define int long long
            using namespace std;
            const int MOD=1000000007;
            const int INF=1000000009;
             
            signed main(){
              double r,g;
              cin>>r>>g;
              cout<<2*g-r<<endl;
              return 0;
            }

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

using namespace std;

int main() {
  int n, a;
  cin >> n;

  cin >> a;
  double ans = a;
  for (int i = 1; i < n; ++i) {
    cin >> a;
    ans = ans*a/(ans+a);
  }

  cout << scientific << setprecision(8) << ans << endl;

  return 0;
}


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

string s;

int main() {
    cin >> s;
    int n = s.size();
    bool allNine = true;
    for (int i = 1; i < n; i++) {
        if (s[i] != '9') allNine = false;
    }
    int sum = s[0] - '0' + (n - 1) * 9;
    if (!allNine) {
        sum--;
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
q = int(input())
ans = sum(A)
many =[0]*(10**5 + 1)
for a in A :
    many[a] += 1

for i in range(q) : 
    B,C = (int(a) for a in input().split())
    many[C] += many[B]
    ans += many[B] * (C-B)
    many[B] = 0
    print(ans)

Measured memory_bytes: 20820
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 200000;
int f[N], invf[N], x[N], p[23][N];
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
int cnk(int n, int k){
    if (k > n) return 0;
    return f[n] * invf[k] % mod * invf[n - k] % mod;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
	int n, l, q;
	cin >> n;
	for (int i = 0; i < n; i++){
        cin >> x[i];
	}
	x[n] = 2e9 + 10;
	p[0][n] = n;
	int md;
    cin >> md;
	cin >> q;
	for (int i = 0; i < n; i++){
        int l = i + 1;
        int r = n;
        while(r - l > 1){
            int mid = (r + l) / 2;
            if (x[mid] - x[i] <= md){
                l = mid;
            } else{
                r = mid;
            }
        }
        p[0][i] = l;
        //cout << i << " " << l << endl;
	}
	for (int i = 1; i < 20; i++){
        p[i][n] = n;
        for (int j = 0; j < n; j++){
            p[i][j] = p[i - 1][p[i - 1][j]];
        }
	}
	while(q--){
        int s, f;
        cin >> s >> f;
        s--;
        f--;
        if (s > f) swap(s, f);
        int res = 0;
        for (int i = 19; i >= 0; i--){
            if (p[i][s] >= f) continue;
            res += (1 << i);
            s = p[i][s];
        }
        cout << res + 1 << endl;
	}
}


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

#define forn(i,x,y) for(int i = int(x); i<int(y); i++)
#define debug(x) cerr << #x << " == " << (x) << '\n';
#define all(V) V.begin(), V.end()
#define on(x, b) (x & (1LL << b))
#define trav(x, v) for(auto &x : v)

#define f first
#define s second

const int N = 1e5 + 10;

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
    ll x; cin >> x;
    ll curr = 100;
    ll ans = 0;
    while(curr < x) {
        curr += curr / 100;
        ans++;
    }
    cout << ans << "\n";
    return 0;
}

/* don't forget to check:
   int overflow
   min/max cases (n = 1)
   printing index of sorted array
   limits for ans (start with inf)
   s = 'x' + s is linear! dont use it!
 */


Measured memory_bytes: 3608
#include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cstring>
    #include <cmath>
    using namespace std;
    const int N=17000,Mo=998244353;
    int fac[N],inv[N],A[N],B[N],rev[N],f[N];
    inline int Pow(int x,int y) {
        int ret=1;
        while(y) {
    	if(y&1) ret=1LL*ret*x%Mo;
    	x=1LL*x*x%Mo,y>>=1;
        }
        return ret;
    }
    inline void NTT(int *a,int n,int f) {
        for(int i=0;i<n;i++) if(i<rev[i]) swap(a[i],a[rev[i]]);
        for(int i=1;i<n;i<<=1) {
    	int wn=Pow(3,(Mo-1)/(i<<1)),x,y;
    	for(int j=0;j<n;j+=i<<1)
    	    for(int k=0,w=1;k<i;k++,w=1LL*w*wn%Mo) {
    		x=a[j+k],y=1LL*a[j+k+i]*w%Mo;
    		a[j+k]=(x+y)%Mo,a[j+k+i]=(x-y)%Mo;
    	    }
        }
        if(f==1) return;
        reverse(a+1,a+n);
        int Inv=Pow(n,Mo-2);
        for(int i=0;i<n;i++) a[i]=1LL*a[i]*Inv%Mo;
    }
    inline int C(int n,int m) {
        if(n<m) return 0;
        return 1LL*fac[n]*inv[m]%Mo*inv[n-m]%Mo;
    }
    int main() {
        int n,m,s,L,ans=0;
        cin>>n>>m>>s>>L;
        for(s=1,L=0;s<=n+n;s<<=1) L++;
        for(int i=0;i<s;i++) rev[i]=((rev[i>>1]>>1)|((i&1)<<L-1));
        fac[0]=1;
        for(int i=1;i<=n+2;i++) fac[i]=1LL*fac[i-1]*i%Mo;
        inv[n+2]=Pow(fac[n+2],Mo-2);
        for(int i=n+2;i;i--) inv[i-1]=1LL*inv[i]*i%Mo;
        for(int i=1;i<=n;i++) B[i]=inv[i+2];
        NTT(B,s,1),f[0]=1;
        for(int i=1;i<=m;i++) {
    	memset(A,0,sizeof(A));
    	for(int j=0;j<=n;j++) A[j]=1LL*f[j]*inv[j]%Mo;
    	NTT(A,s,1);
    	for(int j=0;j<s;j++) A[j]=1LL*A[j]*B[j]%Mo;
    	NTT(A,s,-1);
    	for(int j=0;j<=n;j++)
    	    f[j]=(1LL*A[j]*fac[j+2]+1LL*f[j]*(C(j+1,2)+1))%Mo;
        }
        for(int i=0;i<=n;i++) ans=(ans+1LL*C(n,i)*f[i])%Mo;
        cout<<(ans+Mo)%Mo;
        return 0;
    }

Measured memory_bytes: 512
N=int(input())
A=[int(x) for x in input().split()]
count_f=0
count_0=0
B=[]
for i in range(N):
  B += [abs(A[i])]
  if A[i]==0:
    count_0 +=1
  elif A[i]<0:
    count_f +=1
if count_f%2==0 or count_0>0:
  print(sum(B))
else:
  print(sum(B)-2*min(B))

Measured memory_bytes: 14412
package main

import ( "fmt" )

func main() {

  var i int
  fmt.Scanf("%d", &i)

  if i == 0 {
    fmt.Printf("0:0:0\n")
  } else {
    s := i % 60
    m := i / 60 % 60
    h := i / 60 / 60
    fmt.Printf("%d:%d:%d\n", h, m, s)
  }

}


Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin>>n;
  if(n%2 ==0)
  { cout<<(n/2)*(n/2); }
  else
  { cout<<((n-1)/2) * ( (n-1)/2 +1);
  }
  return 0;
}

Measured memory_bytes: 256
//ltc.groverkss (Kunwar Shaanjeet Singh Grover)
//IIIT Hyderbad

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll,ll> ii;
typedef vector<ll> vi;                  // Vector of long long
typedef vector<vi> vvi;                 // Vector of vi
typedef vector<ii> vii;                 // Vector of pairs
#define pq priority_queue               // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                        // For pairs
#define ss second                       // For pairs
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

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

    ll n, m;
    cin >> n >> m;

    ll hash[n] = {};
    ll score[n] = {};
    ll c = 0, w = 0;
    for (int i = 0; i < m; i++)
    {
        ll p;
        string x;

        cin >> p >> x;

        if (hash[p - 1] == 0)
        {
            if (x == "WA")
                score[p - 1]++;
            else
                c++, hash[p - 1] = 1;
        }
    }

    for (int i = 0; i < n; i++)
    {
        if (hash[i] == 1)
            w += score[i];
    }

    cout << c << " " << w << "\n";
}


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


#define ll long long
#define MOD 1000000007



int main(){
    int a,b,h,m;
    cin>>a>>b>>h>>m;

    int time = h*60+m;
    double rad = min(abs(time*0.5 - m*6),abs(abs(time*0.5-m*6)-360));
    rad /= 180;
    double cur = floor(cos(rad*M_PI)*10000000000000);
    cur /= 10000000000000;
    double ans = sqrt(a*a + b*b -2*a*b*cur);

    cout<<fixed<<setprecision(15)<<ans<<endl;
}


Measured memory_bytes: 3988
import scala.io.StdIn.{readInt,readLine}

object Main {

  def insert(l:List[Int],b:Int,c:Int):Boolean =
    l match {
      case Nil => true
      case hd::tl =>
        if(b<hd) insert(tl,hd,c)
        else if(c<hd) insert(tl,b,hd)
        else false
    }

  def main(args:Array[String]) =
    println {
      {
        for(i<-0 until readInt) yield if(insert(readLine.split(" ").map(_.toInt).toList,0,0)) "YES" else "NO"
      }.mkString("\n")
    }
}

Measured memory_bytes: 43692
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int min_753 = INF;
  REP(i,s.size()-2){
    int num=0;
    num = (s[i]- '0')*100 + (s[i+1] - '0')*10 + s[i+2] - '0';
    //cout << num << endl;
    min_753 = min(min_753,abs(num-753));
  }
  cout << min_753 << endl;
}

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

using namespace std;

int main()
{
    int a[5], c = 0;

    for (int i = 0; i < 5; i++)
    {
        c++;
        scanf("%d", &a[i]);
        if (a[i] == 0)
        {
            printf("%d", c);
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  cin >> K;
  if(K == 1){
  cout << "ACL" << endl;
  }
  if(K == 2){
    cout << "ACLACL" << endl;
  }
  if(K == 3){
    cout << "ACLACLACL" << endl;
  }
  if(K == 4){
    cout << "ACLACLACLACL" << endl;
  }
  if(K == 5){
    cout << "ACLACLACLACLACL" <<endl;
  }
}

Measured memory_bytes: 3596
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 2;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregio

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  vector<int> L(n);
  rep(i, n) cin >> L[i];
  sort(all(L));
  int sum = 0;
  rep(i, n) REP(j, i + 1, n)
  {
    auto itr = upper_bound(all(L), L[j] - L[i]);
    sum += max((int)distance(itr, L.begin() + i), 0);
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import defaultdict

N = int(input())
A = [int(x) for x in input().split()]

d = defaultdict(int)
for i in A :
    d[i] += 1

ans = 0
ans2 = defaultdict(int)
for a in d :
    ans += d.get(a)*(d.get(a)-1)//2
    ans2[a] = d.get(a)*(d.get(a)-1)//2 - (d.get(a)-1)*(d.get(a)-2)//2

for i in A :
    print(ans - ans2[i])


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

int main() {
   long long n, x, a, ans=0;
   cin >> n >> x;
   vector<long long> box(n);
   for(int i=0; i<n; i++) cin >> box.at(i);
   vector<long long> s(n-1);
   for(int i=0; i<n-1; i++) s.at(i)=box.at(i)+box.at(i+1);
   for(int i=0; i<n-2; i++) {
      a=max(s.at(i)-x, 0LL);
      a=min(box.at(i+1), a); //box.at(i+1)>0//
      s.at(i) -= a;
      s.at(i+1) -= a;
      box.at(i+1) -= a;
      ans += a;
   }
   a=max(s.at(0)-x, 0LL);
   s.at(0) -= a;
   box.at(0) -= a;
   ans += a;

   a=max(s.at(n-2)-x, 0LL);
   s.at(n-2) -= a;
   box.at(n-1) -= a;
   ans += a;
   
   cout << ans << endl;
}

Measured memory_bytes: 1792
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c) {
		cout << "Yes";
	}
	else cout << "No";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a;
    string b;
    cin, a, b;
    if (b.size() == 1) {
        b += ".";
    }
    while (b.size() < 4) {
        b += "0";
    }
    ll c = 100 * (b[0] - '0') + (b[2] - '0') * 10 + b[3] - '0';
    a *= c;
    a /= 100;
    print(a);

    return 0;
}


Measured memory_bytes: 3652
// Gear4        
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define SZ(a) ((int)((a).size()))
#define printCase() "Case #" << caseNum << ": "
#define pb push_back
#define mp make_pair
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
#define ff first
#define ss second
template<typename T> using V = vector<T>;
template<typename T, typename U> using P = pair<T,U>;
using ld = long double;
using ll = long long;
#define endl '\n'
const int inf = 1e9, mod = 1e9 + 7;
const ll INF = 9e18;
const ld EPS = 1e-9, PI = acosl(-1.0);
const int N = 1e5 + 5;
int n, a[N], b[N], c[2*N];
ll solve(int x) {
    memset(c, 0, sizeof c);
    FOR0(i, n) b[i+1] = a[i] < x ? -1: 1;
    b[0] = n;
    FOR0(i, n) b[i+1] += b[i];
    ll ans = 0, cur = 0; c[n] = 1;
    FOR(i, 1, n + 1) {
        if(b[i] > b[i-1]) {
            cur += c[b[i]] + 1;
        }
        else {
            cur -= c[b[i-1]]-1;
        }
        c[b[i]]++;
        ans += cur;
    }
    return (n*1LL*(n+1))/2 - ans;
}
int main() {
    SYNC
    cin >> n;
    map<int, int> m; int cnt = 0;
    FOR0(i, n) {
        cin >> a[i];
        if(!m[a[i]]) m[a[i]] = 1;
    }
    for(auto& x : m) x.second = ++cnt;
    FOR0(i, n) a[i] = m[a[i]];
    int l = 1, r = cnt, ans = -1;
    ll target = (n * 1LL * (n + 1)) / 2;
    target = (target/2 + 1);
    while(l <= r) {
        int mid = (l + r) >> 1;
        ll y = solve(mid);
        cerr << mid << " " << y << endl;
        if(y < target) {
            ans = mid; l = mid + 1;
        } else r = mid - 1;
    }
    for(auto x : m) {if(x.second == ans) {ans = x.first; break;}}
    cout << ans;
}

Measured memory_bytes: 6528
#include<cstdio>
#include<algorithm>
#include<stack>
using namespace std;

#define ll long long
#define debug if (debug_message)

#define file_io 0
#define debug_message 0

ll i,t,j;
ll n,nt,m,k,a[200005],b[200005],sum,cnt;
ll psa[200005],psb[200005];

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

	scanf("%lld%lld%lld",&n,&m,&k);
	for (i=1; i<=n; ++i) {
		scanf("%lld",&a[i]);
		psa[i]=psa[i-1]+a[i];
	}
	for (i=1; i<=m; ++i) {
		scanf("%lld",&b[i]);
		psb[i]=psb[i-1]+b[i];
	}

	for (i=0; i<=n && psa[i]<=k; ++i){
		t=upper_bound(psb+1,psb+m+1,k-psa[i])-psb-1;
		cnt=max(cnt,i+t);
	}

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

	return 0;
}
/*
2 2 7
5 1
1 4
-------
3

5 6
1 5


*/

Measured memory_bytes: 7984
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

typedef long long ll; //64bit型
using namespace std;
const ll INF = 1LL << 20;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main()
{
        int A, B, C, D, E;
        cin >> A >> B >> C >> D >> E;
        vector<int> Time = {A, B, C, D, E};
        vector<int> nextTime(5);

        for (int i = 0; i < 5; i++)
        {
                if (Time[i] % 10 == 0)
                        nextTime[i] = Time[i];

                nextTime[i] = (Time[i] + 10 - 1) / 10 * 10;
        }

        int ans = (int)1e9;

        for (int i = 0; i < 5; i++)
        {
                int res = 0;
                for (int j = 0; j < 5; j++)
                {
                        if (i == j)
                        {
                                res += Time[j];
                        }
                        else
                        {
                                res += nextTime[j];
                        }
                }
                debug(res);
                ans = min(ans, res);
        }

        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define LOOP while(true)
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int N, M;
	cin >> N >> M;
	vector<string> A(N);
	vector<string> B(M);
	rep(i, N)cin >> A[i];
	rep(i, M)cin >> B[i];
	int R = N - M + 1;
	bool JD = false;
	
	for(int i = 0; i < R; i++){//縦
		for(int j = 0; j < R; j++){//横
			if(A[i].substr(j, M) == B[0]){//jからM文字が一致,B[1]~B[M]について確認
				for(int k = 0; k < M; k++){
					if(A[i + k].substr(j, M) == B[k]){
						if(k == M - 1){
							JD = true;
							break;
						}
					} else {
						break;
					}
				}
			}
			if(JD)break;
		}
		if(JD)break;
	}
	cout << ((JD) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N, K;
int M = 0;

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

  if( K > (N-1)*(N-2)/2 )
    puts("-1");
  else
  {
    printf( "%d\n", (N-1)*(N-2)/2-K+N-1 );

    rep( i, N-1 )
      printf( "%d %d\n", 1, i+2 );

    int u = 1, v = 1;
    rep( i, (N-1)*(N-2)/2-K )
    {
      if( u+v == N )
      {
        u = 2;
        ++v;
      }
      else
        ++u;

      printf( "%d %d\n", u, u+v );
    }
  }

  return 0;
}

Measured memory_bytes: 128
import java.util.LinkedList;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        LinkedList<Long> list = new LinkedList<>();
        long n = new Scanner(System.in).nextLong(), devided = n;


        for(long i = 2; i <= Math.sqrt(n); i++) {
            while(devided % i == 0) {
                devided /= i;
                list.add(i);
            }
        }
        if(devided != 1) list.add(devided);

        System.out.print(n + ":");
        for(long each : list) {
            System.out.print(" " + each);
        }
        System.out.println();
    }
}

Measured memory_bytes: 26356
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    K, N = map(int, readline().split())
    A = list(map(int, readline().split()))
    sorted(A)
    d = [A[i]-A[i-1] for i in range(1,N)]
    d.append(K - max(A) + min(A))
    ans = K-max(d)
    print(ans)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 20424
N,x=map(int,input().split(' '))
A=sorted(list(map(int,input().split(' '))))
ans = 0
for i in A:
    if x >= i:
        ans += 1
        x -=i
    else:
        break
if x > 0 and ans==N:
    print(N-1)
else:
    print(ans)

Measured memory_bytes: 3060
from math import pi,cos,sqrt
A,B,H,M = map(int,input().split())
m = M/60
h = (H*60+M)/720
d = abs(m-h)
c = cos(d*2*pi)
ans = sqrt(A**2 + B**2 - 2*A*B*c)
print(ans)

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int K,T;
  cin>>K>>T;
  vector<int> A(T);
  for(int i(0);i<T;i++){
    cin>>A[i];
  }
  sort(A.rbegin(),A.rend());
  int sum(0);
  if(T == 1){
    cout << A[0] - 1 << endl;
  }else{
    for(int i(1);i<T;i++){
      sum += A[i];
    }
    cout << max(A[0]-sum-1,0) << endl;
  }
}



Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<functional>
using namespace std;

#define INF 1<<21
#define MOD 1000000007

int tax(int a,int x) {
  int b;
  b = a*(100 + x) / 100;
  return b;
}

int main(void) {
  int x, y, s;
  int b1, b2;
  int ans;
  while (1) {
	cin >> x >> y >> s;
	ans = 0;
	if (x == 0 &&y == 0 && s == 0) {
	  return 0;
	}
	for (int i = 1; i <= s - 1; i++) {
	  b1 = tax(i, x);
	  for (int j = 1; j <= s - 1; j++) {
		b2 = tax(j, x);
		if (b1 + b2 == s) {
		  ans = max(ans, tax(i, y) + tax(j, y));
		}
	  }
	}
	cout << ans << endl;
  }
}

Measured memory_bytes: 3092
#include <cstdio>
int n, in, a[100001], c[3];
main()
{
    scanf("%d",&n);
    for(int i = 0;i < n;i++)
    {
        scanf("%d",&in);
        a[in]++;
    }
    for(int i = 0;i < 100001;i++)
    {
        if(a[i] == 0) c[0]++;
        else if(a[i]%2 == 0) c[2]++;
        else c[1]++;
    }
    printf("%d",c[1] + c[2] - c[2]%2);
}


Measured memory_bytes: 512
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define rall(v )  reverse(v.begin(), v.end())      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vll vector< pair<ll,ll> > 
#define mpl map<ll, ll>
#define pr pair<ll,ll>
#define tpl tuple<ll,ll,ll>
ll containsDigit(ll number, ll digit){while (number != 0){int curr_digit = number % 10;if (curr_digit == digit) return 1;number /= 10;}return 0;}
ll soltn(ll x, ll n) {if(x>=0) return x%n;    else return n+x%n;}
ll pd(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}
ll coda(ll n,ll d){ll count=0;while(n!=0){if(n%10==d)count++;n/=10;}return count;}
ll mdls(ll x){return max(x,-x);}
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x*x)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;
      
	//   cin>>t;

	      while(t--)
{

//jsmstart
ll n,m;
cin>>n>>m;
if(n<m)
cout<<0;
else
cout<<10;
ee;

}
return 0;
}














Measured memory_bytes: 3608
using System;

class AOJ {
    static void Main(string[] args)
    {
        string s;

        while((s = Console.ReadLine()) != null) {
            string[] n = s.Split(' ');

            int sum = int.Parse(n[0]) + int.Parse(n[1]);

            Console.WriteLine(sum.ToString().Length);
        }
    }
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int val[n+1], cost[n+1];
    int ans = 0;
    for (int i=1; i<=n; i++) cin >> val[i];
    for (int i=1; i<=n; i++) cin >> cost[i];
    for (int i=1; i<=(1<<n); i++){
        int diff = 0;
        for (int j=0; j<n; j++){
            if (i & (1<<j)) diff += (val[j+1] - cost[j+1]);
        }
        ans = max(ans, diff);
    }
    cout << max(ans, 0);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;
typedef vector<map<lli,lli>> graph;

lli n;
vll x,y;
vll xid,yid;

vll par;
vll rnk;
void init(lli n){
    par = vll(n);
    rnk = vll(n);
    for(lli i = 0;i < n;i++) par[i] = i;
}
lli find(lli x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
}
void unite(lli x,lli y){
    x = find(x);y = find(y);
    if(x == y) return;
    if(rnk[x] < rnk[y]) par[x] = y;
    else {
        par[y] = x;
        if(rnk[x] == rnk[y]) rnk[x]++;
    }
}
bool same(lli x,lli y){
    return find(x) == find(y);
}

mat dist;
lli ans = 0;

int main(){
	cin >> n;
	x = vll(n);y = vll(n);
	for(lli i = 0;i < n;i++) cin >> x[i] >> y[i];
	xid = vll(n);yid = vll(n);
	for(lli i = 0;i < n;i++) xid[i] = yid[i] = i;
	sort(xid.begin(), xid.end(),[](lli a,lli b){
		return x[a] < x[b];
	});
	sort(yid.begin(), yid.end(),[](lli a,lli b){
		return y[a] < y[b];
	});
	for(lli i = 0;i < n-1;i++){
		dist.push_back(vll({x[xid[i+1]] - x[xid[i]],xid[i],xid[i+1]}));
		dist.push_back(vll({y[yid[i+1]] - y[yid[i]],yid[i],yid[i+1]}));
	}	
	sort(dist.begin(), dist.end());
	init(n);
	for(lli i = 0;i < dist.size();i++){
		if(!same(dist[i][1],dist[i][2])){
			unite(dist[i][1],dist[i][2]);
			ans += dist[i][0];
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 17324
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    List<Integer> card = new ArrayList<>();
    for (int i = 0; i < 9; i++) {
      card.add(sc.nextInt());
    }

    boolean[] mark = new boolean[9];
    int N = sc.nextInt();

    for (int i = 0; i < N; i++) {
      int b = sc.nextInt();
      for (int j = 0; j < 9; j++) {
        if (card.get(j) == b) {
          mark[j] = true;
        }
      }
    }

    if ((mark[0] && mark[1] && mark[2]) ||
        (mark[3] && mark[4] && mark[5]) ||
        (mark[6] && mark[7] && mark[8]) ||
        (mark[0] && mark[3] && mark[6]) ||
        (mark[1] && mark[4] && mark[7]) ||
        (mark[2] && mark[5] && mark[8]) ||
        (mark[0] && mark[4] && mark[8]) ||
        (mark[2] && mark[4] && mark[6])) {
      System.out.println("Yes");
      return;
    }

    System.out.println("No");

    sc.close();
  }
}

Measured memory_bytes: 24276
#import <Foundation/Foundation.h>
int H,W;
void addToSetIfNotVisited(int value, NSMutableSet *set, int *visited){
    if (value>=0) {
        if (visited[value]==0) {
            [set addObject:@(value)];
        }
    }
}
int pointToValue(int i, int j){
    if(i>=0&&i<H&&j>=0&&j<W){
        return i*W + j;
    }
    return -1;
}
int main(){
    @autoreleasepool {
        scanf("%d %d",&H,&W);
        int *visited = (int*)malloc(sizeof(int)*H*W);
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                char c = getchar();
                if(c=='\n'){
                    c = getchar();
                }
                if(c==EOF){
                    break;
                }
                int value = i*W+j;
                if(c=='#'){
                    visited[value]=1;
                }else if (c=='.'){
                    visited[value]=0;
                }
            }
        }
        NSMutableSet *nextPoints = [NSMutableSet set];
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                int value = i*W+j;
                if(visited[value]==1){
                    addToSetIfNotVisited(pointToValue(i-1,j), nextPoints, visited);
                    addToSetIfNotVisited(pointToValue(i+1,j), nextPoints, visited);
                    addToSetIfNotVisited(pointToValue(i,j-1), nextPoints, visited);
                    addToSetIfNotVisited(pointToValue(i,j+1), nextPoints, visited);
                }
            }
        }
        
        int ans=0;
        while([nextPoints count]>0){
            NSMutableSet *nextnextPoints = [NSMutableSet set];
            for (NSNumber *p in nextPoints){
                int value = [p intValue];
                visited[value]=1;
            }
            for (NSNumber *p in nextPoints){
                int value = [p intValue];
                int i = value/W;
                int j = value%W;
                addToSetIfNotVisited(pointToValue(i-1,j), nextnextPoints, visited);
                addToSetIfNotVisited(pointToValue(i+1,j), nextnextPoints, visited);
                addToSetIfNotVisited(pointToValue(i,j-1), nextnextPoints, visited);
                addToSetIfNotVisited(pointToValue(i,j+1), nextnextPoints, visited);
            }
            nextPoints = nextnextPoints;
            ans++;
        }
        printf("%d",ans);
    }
}


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

using namespace std;
int main(){
#ifdef LOCAL_EXEC
#else
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#endif // LOCAL_EXEC
long long int n,k,i,j,x,y,z,mod=998244353;
cin>>n>>k;
vector<pair<long long int,long long int> >vt;
long long int dp[n+1]={0};
for(i=1;i<=k;i++){
    cin>>x>>y;
    vt.push_back({x,y});
}
sort(vt.begin(),vt.end());
dp[1]=1;
for(i=2;i<=n;i++){
    dp[i]=dp[i-1]%mod;
    for(j=0;j<vt.size();j++){
        if(i>vt[j].first)
            dp[i]+=(dp[i-vt[j].first]+mod-dp[max(0ll,i-vt[j].second-1)]+mod)%mod;
            dp[i]=(dp[i]+mod)%mod;
    }
    dp[i]=(dp[i]+mod)%mod;
   // cout<<dp[i]<<" ";

}
cout<<(dp[n]-dp[n-1]+mod)%mod;
}


Measured memory_bytes: 5160
#include <stdio.h>
#include <string.h>

int main( void )
{
	char str[1001];
	char inst[1001];
	char q[1001];
	char tmp;
	int i, j, n, a, b;
	
	scanf("%s", str);
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		scanf("%s %d %d", inst, &a, &b);
		
		if(strcmp(inst, "replace") == 0){
			scanf("%s", q);
			for(j = a; j <= b; j++){
				str[j] = q[j - a];
			}
		} else if(strcmp(inst, "reverse") == 0){
			for(j = a; j < b-(j-a); j++){
				tmp = str[j];
				str[j] = str[b-(j-a)];
				str[b-(j-a)] = tmp;
			}
		} else if(strcmp(inst, "print") == 0){
			for(j = a; j <= b; j++){
				printf("%c", str[j]);
			}
			printf("\n");
		} else {
			// DO NOTHING
		}
	}
	
	return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod

int main(){
    ll N; cin>>N;
    vec d(N);
    rep(i,N) cin>>d[i];
    sort(ALL(d));
    reverse(ALL(d));
    ll ans=0;
    rep(i,N-1) ans+=d[(i+1)/2];
    cout<<ans<<endl;
}

Measured memory_bytes: 4788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		double x = Double.parseDouble(sc.next());
		double a = Double.parseDouble(sc.next());
		double b = Double.parseDouble(sc.next());

		if (Math.abs(x - a) < Math.abs(x - b)) {
			System.out.println("A");
		} else {
			System.out.println("B");
		}
	}
}


Measured memory_bytes: 25172
N, W = map(int, input().split())
items = []
sum_value = 0
for _ in range(N):
    w, v = (map(int, input().split()))
    sum_value += v
    items.append((w, v))

dp = [[float("inf")] * (sum_value + 1) for _ in range(N + 1)]

dp[0][0] = 0
for i in range(N):
    for j in range(sum_value + 1):
        if j - items[i][1] >= 0:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - items[i][1]] + items[i][0])
        else:
            dp[i + 1][j] = dp[i][j]
for i in range(sum_value, -1, -1):
    w = dp[N][i]
    if w <= W:
        print(i)
        exit()


Measured memory_bytes: 307648
#include<stdio.h>
int main(void){
 int W, H, x, y, r, a, b;
 scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
 a = x + r;
 b = x - r;
 if(b >= 0 && a <= W){
  a = y + r;
  b = y - r;
  if(b >= 0 && a<= H){
  printf("Yes\n");
 }
  else{printf("No\n");
 }
 }
 else{printf("No\n");
}
 return 0;
}

Measured memory_bytes: 584