akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define m_k make_pair
#define inf 0x3f3f3f3f
using namespace std;
const int N=2*1e5+100;
int n,a[N],b[N],dp[N];
int tot,first[N],nxt[N*2],point[N*2];
vector <int> s;
void add_edge(int x,int y)
{
	tot++;
	nxt[tot]=first[x];
	first[x]=tot;
	point[tot]=y;
}
void dfs(int x,int fa)
{
	int kind,p,v;
	if (s.empty() || s[(int)s.size()-1]<a[x])
	{
		kind=1;
		s.push_back(a[x]);
	}
	else
	{
		int pos=lower_bound(s.begin(),s.end(),a[x])-s.begin();
		p=pos;v=s[pos];
		s[pos]=a[x];
		kind=2;
	}
	dp[x]=(int)s.size();
	for (int i=first[x];i!=-1;i=nxt[i])
	{
		int u=point[i];
		if (u==fa) continue;
		dfs(u,x);
	}
	if (kind==1) s.pop_back();
	else s[p]=v;
}
void dfs1(int x,int fa)
{
	dp[x]=max(dp[x],dp[fa]);
	for (int i=first[x];i!=-1;i=nxt[i])
	{
		int u=point[i];
		if (u==fa) continue;
		dfs1(u,x);
	}
}
signed main()
{
	tot=-1;
	memset(first,-1,sizeof(first));
	memset(nxt,-1,sizeof(nxt));
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	for (int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add_edge(u,v);
		add_edge(v,u);
	}
	dfs(1,1);
	dfs1(1,1);
	for (int i=1;i<=n;i++) printf("%d\n",dp[i]);
}


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

int main(){
	ll x,y,z,k;
	cin>>x>>y>>z>>k;
	ll a[x],b[y],c[z];
	for(ll i=0;i<x;i++)cin>>a[i];
	for(ll i=0;i<y;i++)cin>>b[i];
	for(ll i=0;i<z;i++)cin>>c[i];
	sort(a,a+x);
	sort(b,b+y);
	sort(c,c+z);
	ll e[x*y];

	for(ll i=0;i<x;i++){
		for(ll j=0;j<y;j++){
			e[i+j*x]=a[i]+b[j];
		}
	}
	sort(e,e+x*y);
	//for(ll i=0;i<x*y;i++)cout<<e[i]<<endl;
	ll ee[k],t;
	bool flag;
	if(x*y>k){
		flag=true;
		ll j=k-1;
		for(ll i=x*y-1;i>=0;i--){
			ee[j]=e[i];
			//cout<<"j:"<<j<<" ee:"<<ee[j]<<endl;
			j--;
			if(j==-1)break;
		}
		t=k;
	}else{
		t=x*y;
		flag=false;
	}
	ll res[(k)*(z)],w=0;
	for(ll i=0;i<k*z;i++)res[i]=0;
	for(ll i=t-1;i>=0;i--){
		for(ll j=z-1;j>=0;j--){
			if(!flag){
				res[w]=e[i]+c[j];
			}else{
				res[w]=ee[i]+c[j];
			}
			//cout<<"w:"<<w<<" res:"<<res[w]<<endl;
			w++;
		}
	}
	//for(ll i=0;i<k*z;i++)cout<<res[i]<<endl;
	sort(res,res+(k)*(z),greater<ll>());
	for(ll i=0;i<k;i++)cout<<res[i]<<endl;
}


Measured memory_bytes: 31616
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    int N;
    cin >> N;
    vector<int> P(N);
    int sum = 0;
    int max_p = 0;
    for(int i = 0; i < N; i++){
        cin >> P[i];
        sum += P[i];
        max_p = max(max_p, P[i]);
    }
    cout << sum - max_p / 2 << endl;
}


Measured memory_bytes: 3540
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n=int(input())
H=input_array()
INF=10**9
# 最小化問題
dp=[INF]*n
# 初期化
dp[0]=0

for i in range(1,n):
	a=dp[i-1]+(abs(H[i]-H[i-1]))
	b=dp[i-2]+(abs(H[i]-H[i-2]))
	dp[i]=min(a,b)
print(dp[n-1])

Measured memory_bytes: 20560
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int main(){

	int N;
	char buf[1001];

	scanf("%d",&N);

	int dp[N][8];

	for(int i = 0; i < N; i++){
		for(int k = 1; k <= 7; k++){
			dp[i][k] = 0;
		}
	}

	scanf("%s",buf);

	switch(buf[0]){
	case 'J':
		dp[0][4] = 1;
		dp[0][5] = 1;
		dp[0][6] = 1;
		dp[0][7] = 1;
		break;
	case 'O':
		dp[0][6] = 1;
		dp[0][7] = 1;
		break;
	case 'I':
		dp[0][5] = 1;
		dp[0][7] = 1;
		break;
	}

	for(int i = 1; i < N; i++){
		switch(buf[i]){
		case 'J':
			dp[i][4] = (dp[i-1][4] + dp[i-1][5] + dp[i-1][6] + dp[i-1][7])%10007;
			dp[i][5] = (dp[i-1][1] + dp[i-1][3] + dp[i-1][4] + dp[i-1][5] + dp[i-1][6] + dp[i-1][7])%10007;
			dp[i][6] = (dp[i-1][2] + dp[i-1][3] + dp[i-1][4] + dp[i-1][5] + dp[i-1][6] + dp[i-1][7])%10007;
			dp[i][7] = (dp[i-1][1] + dp[i-1][2] + dp[i-1][3] + dp[i-1][4] + dp[i-1][5] + dp[i-1][6] + dp[i-1][7])%10007;
			break;
		case 'O':
			dp[i][2] = (dp[i-1][2] + dp[i-1][3] + dp[i-1][6] + dp[i-1][7])%10007;
			dp[i][3] = (dp[i-1][1] + dp[i-1][2] + dp[i-1][3] + dp[i-1][5] + dp[i-1][6] + dp[i-1][7])%10007;
			dp[i][6] = (dp[i-1][2] + dp[i-1][3] + dp[i-1][4] + dp[i-1][5] + dp[i-1][6] + dp[i-1][7])%10007;
			dp[i][7] = (dp[i-1][1] + dp[i-1][2] + dp[i-1][3] + dp[i-1][4] + dp[i-1][5] + dp[i-1][6] + dp[i-1][7])%10007;
			break;
		case 'I':
			dp[i][1] = (dp[i-1][1] + dp[i-1][3] + dp[i-1][5] + dp[i-1][7])%10007;
			dp[i][3] = (dp[i-1][1] + dp[i-1][2] + dp[i-1][3] + dp[i-1][5] + dp[i-1][6] + dp[i-1][7])%10007;
			dp[i][5] = (dp[i-1][1] + dp[i-1][3] + dp[i-1][4] + dp[i-1][5] + dp[i-1][6] + dp[i-1][7])%10007;
			dp[i][7] = (dp[i-1][1] + dp[i-1][2] + dp[i-1][3] + dp[i-1][4] + dp[i-1][5] + dp[i-1][6] + dp[i-1][7])%10007;
			break;
		}
	}

	int ans = 0;

	for(int i = 1; i <= 7;i++)ans += dp[N-1][i];

	ans %= 10007;

	printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 2728
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


ll fact[100001];
const int mod = 1000000007;

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

	int N;
	cin >> N;
	vector<int> s(N);
	int sum = 0;
	
	REP(i, N) {
		cin >> s[i];
		sum += s[i];
		if (s[i] % 10 == 0) s[i] = 100;
	}
	if (sum % 10 == 0) {
		int mn = 100;
		REP(i, N) mn = min(mn, s[i]);
		if (mn == 100) sum = 0;
		else sum -= mn;
	}
	cout << sum << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.lang.Math.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int mx =1000;
        int count = (int)Math.sqrt(mx);
        int[] num = new int[mx+1];
        int mod = (int)(1e9+7);
        ArrayList<Integer> prime = new ArrayList<>();
        HashSet<Integer> p = new HashSet<>();
        for(int i=2;i<=count;i++){
            int add = i;
            int cur = i;
            if(num[cur]==0){
                cur+=add;
                while (cur<=mx){
                    num[cur] = 1;
                    cur+=add;
                }
            }
        }
        for(int i=2;i<=mx;i++){
            if (num[i]==0){
                prime.add(i);
                p.add(i);
            }
        }
        int n = in.nextInt();
        if(n==1){
            System.out.println(1);
        }
        else {
            int ans = 0;
            int[] check = new int[mx+1];
            for(int i=2;i<=n;i++){
                int cur = i;
                int idex = 0;
                while (cur>1){
                    if (p.contains(cur)){
                        check[cur]+=1;
                        break;
                    }
                    else {
                        if (cur%prime.get(idex)==0){
                            cur = cur/prime.get(idex);
                            check[prime.get(idex)]+=1;
                            idex=0;
                        }
                        else {
                            idex++;
                        }
                    }

                }

            }
            long totol =1;
            for(int k=0;k<=n;k++){
                totol*= check[k]+1;
                totol%=mod;
            }
            System.out.println(totol);

        }
    }
}


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

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++)
        cin >> a[i];
    sort(a,a+n);
    int sum=0;
    for(int i=0;i<k;i++)
        sum+=a[i];
    cout << sum;
}

Measured memory_bytes: 3660
#include <iostream>
using namespace std;
int main(void){
    int c1,c5,c10,c50,c100,c500,x;
    cin>>c1>>c5>>c10>>c50>>c100>>c500;
    x=c1+c5*5+c10*10+c50*50+c100*100+c500*500;
    if(x/1000<=0){
        cout<<"0"<<endl;
    }
    else if(x/1000>=1){
        cout<<"1"<<endl;
    }
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
 
#define S size()
#define E end()
#define B begin()
#define L length()
 
#define endl "\n"
#define cnt count
#define in insert
#define er erase
#define fi first
#define se second
#define fl float
#define ld long double
#define ll long long

#define gcd __gcd
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define all(v) v.B,v.E
#define acc(v) accumulate(all(v), 0)
#define psum partial_sum
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define np next_permutation
#define maxe *max_element
#define mine *min_element
 
#define forl(i,n) for(ll i = 0; i < n; i++)
#define fore(i,m,n) for (ll i = m; i <= n; i++)
#define rforl(i,n) for (ll i = n - 1; i >= 0; i--)
#define rfore(i,m,n) for (ll i = m; i >= n; i--)    
#define iter(s) for(auto it:s)
 

#define prec(n) fixed<<setprecision(n)
#define popcnt(n) __builtin_popcountll(n)
#define parity(n) __builtin_parityll(n)
#define clz(n) __builtin_clzll(n)
#define ctz(n) __builtin_ctzll(n)

#define sll set<ll>
#define sc set<char>
#define mll map<ll,ll>
#define vll vector<ll>
#define vc vector<char>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define msll multiset<ll>
#define msc multiset<char>
#define vvll vector<vector<ll>>
#define rev reverse

#define pat ll n;cin>>n;
#define pat1 vll a(n);forl(i,n)cin>>a[i];
#define pat2 ll n,k;cin>>n>>k;vll a;forl(i,n) cin>>a[i];
#define tc ll q;cin>>q;while(q--)
#define pats string s;cin>>s;
#define loop forl(i,n)
#define yesno if(flag)cout<<"Yes\n";else cout<<"No\n";

#define p0(a) cout << a << " ";
#define p1(a) cout << a << endl;
#define p2(a,b) cout << a << " " << b << endl;
#define p3(a,b,c) cout << a << " " << b << " " << c << endl;
#define p4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl
 
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define mod1 1000000007
#define mod2 998244353
#define PI 3.1415926535897932384626433832

//**********************************
 
int main(){
    
  ll x;cin>>x;
  pat pat1
  ll cnt[102]={0};
  loop{
      cnt[a[i]]++;
  }
ll in1=-1,in2=-1;
      fore(i,x,101){
          if(cnt[i]==0){
              in1=i;
              break;
          }
      }

      rfore(i,x,0){
          if(cnt[i]==0){
              in2=i;
              break;
          }
      }
  
  ll ans;
  if(in1!=-1 && in2!=-1){
      if(abs(in1-x)<abs(in2-x)){
          ans=in1;
      }else{
          ans=in2;
      }
  }else if(in1!=-1){
      ans=in1;
  }else if(in2!=-1){
      ans=in2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;

long long ans;
int n,m,r,xr,a[N];

int main() {
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i];
	xr=0; r=0;
	for (int i=1;i<=n;i++) {
		xr^=a[i-1];
		while (r<n&&(xr^a[r+1])==(xr+a[r+1])) xr+=a[r+1],r++;
		ans+=r-i+1;
	}
	cout<<ans;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;



int loan(int n){
   int amount=100000;
   for(int i=0;i<n;i++){
      amount+=amount*0.05;
      if(amount%1000!=0) amount=(amount-(amount%1000))+1000;
   }
   return amount;
}


int main(){

   int n;

   cin >>n;

   cout <<loan(n)<<endl;

   return 0;

}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<std::vector<int64_t>> a(n, std::vector<int64_t>(n - 1));
  std::cin >> a;

  for (auto &i : a) {
    for (auto &j : i) {
      j--;
    }
  }

  std::vector<int64_t> index(n, 0);
  std::vector<bool> flag(n, false);
  int64_t day = 0;
  while (true) {
    std::fill(flag.begin(), flag.end(), false);
    bool f = false;
    for (int64_t i = 0; i < n; i++) {
      if (flag[i] || index[i] == n - 1) {
        continue;
      }
      const auto j = a[i][index[i]];
      if (a[j][index[j]] == i && !flag[j]) {
        f = true;
        index[i]++;
        index[j]++;
        flag[i] = true;
        flag[j] = true;
      }
    }
    if (!f) {
      break;
    }
    day++;
  }
  bool f = true;
  for (const auto i : index) {
    if (i != n - 1) {
      f = false;
      break;
    }
  }
  if (f) {
    std::cout << day << std::endl;
  } else {
    std::cout << -1 << std::endl;
  }
  return 0;
}

Measured memory_bytes: 10112
#include <iostream>
#include <cmath>

int main () {
    int n, d;

    std::cin >> n >> d;
    if ((n % (d * 2 + 1)) == 0) std::cout << n / (d * 2 + 1);
    else std::cout << n / (d * 2 + 1) + 1;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_N 50100

int isPrime[ MAX_N + 1 ] = { 0, 0, 1 };

int main( void ) {
	int i, j, n, max, min;

	for ( i = 3; i <= MAX_N; i += 2 )
		isPrime[ i ] = 1;

	for ( i = 3; i * i <= MAX_N; i += 2 )
		if ( isPrime[ i ] )
			for ( j = i * 2; j <= MAX_N; j += i )
				isPrime[ j ] = 0;

	for ( ; scanf( "%d", &n ) == 1; printf( "%d %d\n", max, min ) ) {
		for ( max = n; !isPrime[ --max ];  ) ;
		for ( min = n; !isPrime[ ++min ];  ) ;
	}

	return 0;
}

Measured memory_bytes: 792
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  ll s; cin>>s;
  int c = 1000000000;
  int x1=0, y1=0, x2=c, y2=1, x3, y3;
  x3 = (c-s%c)%c;
  y3 = (s+x3)/c;
  cout << x1 SP y1 SP x2 SP y2 SP x3 SP y3 << endl;
  return 0;
}


Measured memory_bytes: 256
from bisect import bisect

def solve():
	mod = 10**9+7
	n,k,*a = map(int,open(0).read().split())
	b = []
	ans = 0
	for j,x in enumerate(a):
		i = bisect(b,x)
		ans += (j-i)*k
		b.insert(i,x)
	bef = max(a)
	j=0
	for i,cur in enumerate(b[::-1]):
		if cur==bef:
			pass
		else:
			j = i
			bef = cur
		ans += k*(k-1)*j//2
	print(ans%mod)

if __name__=="__main__":
	solve()

Measured memory_bytes: 3188
#include <cmath>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define REP(i,n) FOR(i,0,n)

using namespace std;

typedef complex<double> xy_t;
double cross_product(xy_t a, xy_t b){ return (conj(a) * b).imag(); }

int main(){
    int n = 0;
    double x,y,area = 0;
    xy_t p[20];
    while(~scanf("%lf,%lf", &x, &y)){
        p[n] = xy_t(x, y);
        n++;
    }

    REP(i,n - 2){
        area += fabs(cross_product(p[i+1] - p[0], p[i+2] - p[0])) / 2;
    }
    cout << fixed <<setprecision(6) << area << endl;

}

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

const int INF = 1e9;

//2次元ベクトルを表示
void printVec(const vector<vector<int>> v){
    for(int i=0;i<v.size();i++){
        for(int j=0;j<v[i].size();j++){
            cout << v[i][j] << " ";
        }
        cout << endl;
    }
}

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<vector<int>> A(N, vector<int>(M));
  vector<int> C(N);
  for (int i = 0; i < N; i++) {
    cin >> C.at(i);
    for (int j = 0; j < M; j++) {
      cin >> A.at(i).at(j); 
    }
  }
  
  // Powerd Serach
  int ans = INF;
  for(int i = 0; i < (1<<N); ++i) {
    int cost = 0;
    vector<int> d(M);
    for(int j = 0; j < N; ++j) {
      if(i>>j&1) {
        cost += C.at(j);
        for(int k = 0; k < M; ++k) d.at(k) += A.at(j).at(k);
      }
    }
    bool ok = true;
      for(int i = 0; i < M; ++i) {
        if (d.at(i) < X) ok = false; 
      }
    if (ok) ans = min(ans, cost);
  }
  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  long long n;
  string tmp;
  vector<char> table;
  cin >> n;
  // n--;
  for (int i = 0; i <= 26; i++) {
    table.push_back('a' + i);
    // cout << table[i] << endl;
  }
  long long mod = 26;
  while (n > 0) {
    n--;
    mod = n % 26;
    tmp = table[mod] + tmp;
    n /= 26;
    // cout << "mod:" << mod << ", n:" << n << endl;
  }
  cout << tmp << endl;
  return 0;
}


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


int main() {
  int n;
  cin >> n;
  vector<double> a(n);
  rep(i,n) {
    cin >> a.at(i);
  }
  double bunbo = 0;
  double bunsi = 1;
  double kari;
  rep(i,n) {
    bunsi *= a.at(i);
  }
  kari = bunsi;
  rep(j,n) {
    bunbo += kari / a.at(j);
  }
  cout << setprecision(30) << bunsi / bunbo <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int xs,ys;
ll a[2003];
ll b[2003];
bool vis[1009][1009];
int ans[1000004];
// 10 min for problem A : 15
// 15 min for problem B : 16
// 30 min for problem C :
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
    int n,d;
    cin>>n>>d;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        double u=sqrt(1.0*((x*x)+(y*y)));
        if(u<=d)
            ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 3632
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 998244353 ;

void main() {
    auto N = readln.chomp.to!int;
    auto A = iota(N).map!(_ => readln.split.map!(to!long).array).array;

    int ans = N;

    foreach (i; 0..N) {
        foreach (j; i+1..N) {
            long dx = A[i][0] - A[j][0];
            long dy = A[i][1] - A[j][1];
            auto uf = new UnionFind(N);
            foreach (a; 0..N) {
                foreach (b; a+1..N) {
                    if (A[a][0] - A[b][0] == dx && A[a][1] - A[b][1] == dy) {
                        uf.unite(a, b);
                    } else if (A[b][0] - A[a][0] == dx && A[b][1] - A[a][1] == dy) {
                        uf.unite(a, b);
                    }
                }
            }
            ans = min(ans, uf.table.map!(a => a < 0).sum);
        }
    }

    ans.writeln;
}


class UnionFind {
    int N;
    int[] table;

    this(int n) {
        N = n;
        table = new int[](N);
        fill(table, -1);
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (table[x] > table[y]) swap(x, y);
        table[x] += table[y];
        table[y] = x;
    }
}

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

int sumDigits(int n) {
	int sum = 0;
	while (n) {
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main() {
	
	int n, ans = 1e9;

	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		ans = min(ans, sumDigits(i) + sumDigits(n - i));
	}
	printf("%d\n", ans);
	return 0;
}

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

signed main(){

  int n; cin >> n;
  int x = 0,f = 0;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    x ^= a;
    if(1 & x) f = 1;
  }
  cout << (f ? "first" : "second") << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long H = 0;
		long S = 0;
		for(int i = 0 ; i < N ; ++i){
			long A = sc.nextLong();
			if(A < H){
				S += H - A;
			}else{
				H = A;
			}
		}
		System.out.println(S);
	}
}


Measured memory_bytes: 59436
#include <bits/stdc++.h>
#define rep(i, n) for (long long int i = 0; i < (long long int)(n); i++)
using namespace std;
 
int main(){
  string s;
  cin >> s;
  
  int n = s.size();
  bool dance = true;
  rep(i,n){
    if(i%2==0){
       if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
         dance = false;
       }
    }
    if(i%2!=0){
      if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
        dance = false;
      }
    }
  }
  if(dance){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#define all(x) (x).begin(),(x).end()
typedef long long ll;

using namespace std;

int main()
{
    int N, M;   cin >> N >> M;
    vector<int> v(N,0), c(N,1);
    v[0] = 1;
    for(int i=0; i<M; i++){
        int x, y;   cin >> x >> y;
        if(v[x-1] == 1 && c[x-1] == 1){
            v[x-1] = 0;
            v[y-1] = 1;
        }else if(v[x-1] == 1){
            v[y-1] = 1;
        }
        c[x-1] -= 1;
        c[y-1] += 1;
    }
    int ans = 0;
    for(int i=0; i<N; i++)  ans += v[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

  vector<int> a[1000];
  int seat[17], in[100], out[100];
  queue<int> Q;
  fill_n((int*)seat, 17, -1);
  for (int i = 0; i < 1000; i++) {
    if (i < 500 && i % 5 == 0) {
      Q.emplace(i / 5);
      in[i / 5] = i;
    }
    for (int j : a[i]) {
      for (int k = 0; k < 17; k++) {
        if (seat[k] == j) seat[k] = -1;
      }
    }
    while (!Q.empty()) {
      int num = Q.front() % 5 == 1 ? 5 : 2;
      int l = 0, r = 0, flag = 0;
      while (l < 17) {
        while (l < 17 && seat[l] != -1) l++, r++;
        while (r < 17 && seat[r] == -1) r++;
        if (r - l >= num) {
          int group = Q.front();
          Q.pop();
          out[group] = i;
          a[out[group] + 17 * (group % 2) + 3 * (group % 3) + 19].emplace_back(group);
          for (int j = 0; j < num; j++) {
            seat[j + l] = group;
          }
          flag = 1;
          break;
        }
        l = r;
      }
      if (!flag) break;
    }
  }
  int n;
  while (cin >> n) {
    cout << out[n] - in[n] << endl;
  }

  return 0;
}


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>



using namespace std;

char a;
char str = 'a';
char strend = 'a' + 25;
int main(){
    cin >> a;
    if(str <= a && a <= strend ){
        cout << "a" << endl;
    }
    else cout << "A" << endl;

return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
typedef long long ll;
using namespace std;

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

    string s;
    ll cnt[5] = {0};
    for(int i=0; i<n; i++) {
        cin >> s;
        if(s[0]=='M') cnt[0]++;
        else if(s[0]=='A') cnt[1]++;
        else if(s[0]=='R') cnt[2]++;
        else if(s[0]=='C') cnt[3]++;
        else if(s[0]=='H') cnt[4]++;
    }

    int A[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
    int B[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
    int C[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};

    ll ans=0;
    for(int i=0; i<10; i++) {
        ans += cnt[A[i]] * cnt[B[i]] * cnt[C[i]];
    }

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




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
string s, t;

signed main() {
	cin >> n >> s >> t;
	
	int i;
	rep(i, n) cout << s[i] << t[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1000000007;

int main() {
  double n, m, d;
  cin >> n >> m >> d;

  double ans = 2 * (n - d) * (m - 1)/(n*n);
  if (d == 0) ans /= 2;
  printf("%.15f\n", ans);

  return 0;
}


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

int main() {
	double a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f) {
		double y = (a * f - c * d) / (a * e - b * d);
		double x = (c - b * y) / a;
		cout << fixed << setprecision(3) << x << " " << y << endl;
	}
	return 0;
}


Measured memory_bytes: 3204
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    string s;
    cin >> s;
    rep(i, 3) {
        if (s[i] == s[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}


Measured memory_bytes: 256
a, b, m = gets.chomp.split(' ').map(&:to_i)

c = gets.chomp.split(' ').map(&:to_i)
d = gets.chomp.split(' ').map(&:to_i)

g = 10000000000000000000000000

m.times do |i|
  a,b,e = gets.chomp.split(' ').map(&:to_i)
  g = [g, (c[a-1] + d[b - 1] - e)].min
end

puts [g, (c.min + d.min)].min

Measured memory_bytes: 20252
import java.util.*;

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

   if(A==B && B==C){
System.out.println("Yes");
}else{
System.out.println("No");
}



    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a) for(i = 0 ; i < a ; i++)
#define whln(t) while(t--)
#define whlp(t) while(t++)
ll i=0,j=0;


int main(void){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
	// ll t;
	// cin>>t;
	// whln(t){
	
	// }
	ll n,x,t;
	cin>>n>>x>>t;

	cout<<((n+x-1)/x)*t;

}
//   *****  *******   !
//   *		     *    !
//   ***       *      !
//   *       *        !
//   *****  *******   !

Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <queue>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
ll intpow(int n,int m){
    if(m==0)return 1;
    return n*intpow(n,m-1);
}
ll gcd(ll n,ll m){
    n = max(n,m);
    m = min(n,m);
    if(n%m == 0)return m;
    return gcd(m,n%m);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
using Graph = vector<vector<int>>;

int main(){
    int n;cin>>n;
    int x,y;cin>>x>>y;
    Graph G(n);
    rep(i,n-1){
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    G[x-1].push_back(y-1);
    G[y-1].push_back(x-1);

    vector<int> dist[2000]; 
    queue<int> que[2000];
    int num[2000];
    rep(i,2000)num[i]=0;

    rep(i,n)dist[i].assign(n,-1);
    rep(i,n){
        dist[i][i]=0;
        que[i].push(i);
        while (!que[i].empty()) {
        int v = que[i].front(); 
        que[i].pop();

        for (int nv : G[v]) {
            if (dist[i][nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[i][nv] = dist[i][v] + 1;
            num[dist[i][nv]]++;
            que[i].push(nv);
            }
        }
    }
    rep(i,n-1)cout<<num[i+1]/2<<endl;
    
}

Measured memory_bytes: 17408
#include<stdio.h>
#define R_MAX 200000
int main(){
	int i,N;
	int R[R_MAX];
	int maxv, minv;

	scanf("%d",&N);
	for(i=0; i<N; i++){
		scanf("%d",&R[i]);
	}

	maxv = -2000000000;
	minv = R[0];

	for(i=1; i < N; i++){
		if(maxv<R[i]-minv){
			maxv = R[i]-minv;
		}
		if(minv>R[i]){
			minv = R[i];
		}
	}

	printf("%d\n",maxv);
	return 0;
}



Measured memory_bytes: 2548
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();
    let h: usize = iterator.next().unwrap().parse().unwrap();

    let ans: usize = (a + b) * h / 2;
    return ans.to_string();
}


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

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
char dd[5] = ">v<^";

int main(){
    int rep;
    cin >> rep;
    for(int r=0; r<rep; r++){
        int h,w;
        cin >> h >> w;
        vector<vector<char> > field(h+2, vector<char>(w+2, '#'));
        int x, y, dir;
        for(int i=1; i<=h; i++){
            for(int j=1; j<=w; j++){
                char in;
                cin >> in;
                field[i][j] = in;
                if(in=='^' || in=='<' || in=='>' || in=='v'){
                    y = i;
                    x = j;
                    for(int k=0; k<4; k++){
                        if(in == dd[k]) dir=k;
                    }
                }
            }
        }

        int m;
        string manip;
        cin >> m >> manip;
        for(int i=0; i<m; i++){
            switch(manip[i]){
            case 'U':
                dir = 3;
                goto move;
            case 'D':
                dir = 1;
                goto move;
            case 'L':
                dir = 2;
                goto move;
            case 'R':
                dir = 0;
            move:
                if(field[y+dy[dir]][x+dx[dir]] == '.'){
                    field[y][x] = '.';
                    y += dy[dir];
                    x += dx[dir];
                    field[y][x] = dd[dir];
                }else{
                    field[y][x] = dd[dir];
                }
                break;
            case 'S':
                int nx=x, ny=y;
                while(field[ny][nx] != '#' && field[ny][nx] != '*'){
                    ny += dy[dir];
                    nx += dx[dir];
                }
                if(field[ny][nx] == '*'){
                    field[ny][nx] = '.';
                }
            }
        }

        for(int i=1; i<=h; i++){
            for(int j=1; j<=w; j++){
                cout << field[i][j];
            }
            cout << endl;
        }
        if(r<rep-1) cout << endl;
    }
    return 0;
}



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

#define rep(i,n) for(int i=0;i<(n); ++i)
#define INF 100000 // 2^31-1
#define MAX_V 100000


using namespace std;

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

string replaceAll(string &replacedStr, string from, string to) {
    unsigned int pos = replacedStr.find(from);
    int toLen = to.length();
 
    if (from.empty()) {
        return replacedStr;
    }
 
    while ((pos = replacedStr.find(from, pos)) != string::npos) {
        replacedStr.replace(pos, from.length(), to);
        pos += toLen;
    }
    return replacedStr;
}
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

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

int gettt(long long int num){
    int digit=0;
if(num<10){
digit=0;
}else{
    while(num>1){
        num /= 10;
        digit++;
    }
}
    return digit;
}

string sfg[27]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",""};





int main() {

ios::sync_with_stdio(false);
cin.tie(0);
long long int n;
cin>>n;

long long int t=n%1000;
t=(1000-t)%1000;

cout<<t<<endl;




}
//double res=10.11;
//printf("%.10f",ans);
//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;


Measured memory_bytes: 3652
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"	
	typedef long long LL;
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)	
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define read(a) ll a; cin >> a;
	#define reads(s) string s; cin >> s;
	#define readb(a, b) ll a, b; cin >> a >> b;
	#define readc(a, b, c) ll a, b, c; cin >> a >> b >> c;
	#define readarr(a, n) int a[(n) + 1] = {}; forab(i, 0, (n-1)) {cin >> a[i];}
	#define readmat(a, n, m) int a[n + 1][m + 1] = {}; forab(i, 1, n) {forab(j, 1, m) cin >> a[i][j];}
	#define readv(A,n) vll A(n,0); forn(i,n) cin>>A[i]; 
	#define print(a) cout << a << endl;
	#define printarr(a, n) forab (i, 1, n) cout << a[i] << " "; cout << endl;
	#define printv(v) for (int i: v) cout << i << " "; cout << endl;
	#define printmat(a, n, m) forab(i, 1, n) {forab (j, 1, m) cout << a[i][j] << " "; cout << endl;}
	 
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
	void solve()
	{
		read(n);
		readmat(A,n,3);
		//printmat(A,n,3);
		ll dp[100010][3];
		mem(dp,0);
		forab(i,1,n)
		{
			dp[i][0]=max(dp[i-1][1],dp[i-1][2])+A[i][1];
			dp[i][1]=max(dp[i-1][2],dp[i-1][0])+A[i][2];
			dp[i][2]=max(dp[i-1][1],dp[i-1][0])+A[i][3];
			
		}
		//cout<<dp[1][0]<<" "<<dp[1][1]<<" "<<dp[1][2]<<endl;
		//printmat(dp,n,3);
		cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<endl;
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}

	
	

Measured memory_bytes: 7568
#include <stdio.h>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>


using namespace std;

#define MAX_L (20010)
int main()
{
    stack<int> S1;
    stack< pair<int, int> > S2;
    char s[MAX_L];
    int size = 0;
    vector<int> ans;
    int total = 0;
    scanf("%s", s);
    
    while( s[size] != 0 ) {
	size++;
    }

    for ( int i = 0; i < size; i++ ) {
	if ( s[i] == '\\' ) {
	    S1.push( i );
	}
	else if ( s[i] == '/' && !S1.empty() ) {
	    int j = S1.top(); S1.pop();
	    int add_area = ( i - j );
	    // total += ( i - j );
	    while( !S2.empty() && S2.top().first > j ) {
		add_area += S2.top().second;
		S2.pop();
	    }
	    S2.push( make_pair( j, add_area ) );
	}
    }
    
    while ( !S2.empty() ) {
	total += S2.top().second;
	ans.push_back( S2.top().second );
	S2.pop();
    }

    reverse( ans.begin(), ans.end() );

    printf("%d\n", total);
    printf("%d", (int)ans.size());

    for ( int i = 0; i < ans.size(); i++ ) {
	printf(" %d", ans[i]);
    }

    printf("\n");

    return 0;
}

Measured memory_bytes: 1140
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder(br.readLine());
        boolean order = true;
        int q = Integer.parseInt(br.readLine());
        StringBuilder front = new StringBuilder();
        for (int i = 0; i < q; i++) {
            char[] arr = br.readLine().toCharArray();
            if (arr[0] == '1') {
                order ^= true;
            } else {
                int y = arr[2] - '0';
                if (order ^ y == 1) {
                    sb.append(arr[4]);
                } else {
                    front.append(arr[4]);
                }
            }
        }
        if (order) {
            front.reverse();
            System.out.println(front.toString() + sb.toString());
        } else {
            sb.reverse();
            System.out.println(sb.toString() + front.toString());
        }
    }
}


Measured memory_bytes: 39936
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    long double res = 1;
    long double x = 0;
    for (int i = 0; i < n; i++) {
        long double y; cin >> y;
        x += (long double) 1.0 / y;
    }
    cout << res / x << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

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;
}

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  deque<int> ans;
  REP(i,N){
    int tmp;
    cin>>tmp;
    if(i%2){
      ans.push_front(tmp);
    }else{
      ans.push_back(tmp);
    }
  }
  if(N%2)reverse(ALL(ans));
  REP(i,N-1){
    cout<<ans[i]<<" ";
  }
  cout<<ans[N-1]<<endl;
}


Measured memory_bytes: 3072
def primes(n):
    i = 2
    factors = []
    while i**2<= n:
        if n % i:
            i += 1
        else:
            n =n//i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors
a,b=map(int,input().split())
sa=set(primes(a))
sb=set(primes(b))
sans=sa.intersection(sb)
print(len(sans)+1)

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

int main(){
    ll a,b;
    cin>>a>>b;
    ll g = __gcd(a,b);
    ll ans=1;
    for(ll i=2;i*i<=g;i++){
        if(g%i==0){
            ans++;
            while(g%i==0) g/=i;
        }
    }
    if(g!=1) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const n = stdin.split('\n')[0]

const l = stdin.split('\n')[1].split(' ').map(Number)

const max = Math.max(...l)

const maxi = l.indexOf(max)

l.splice(maxi, 1)

const sum = l.reduce((p,c)=> p += c)

if(sum > max){
  console.log('Yes')
} else {
  console.log('No')
}


Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using Data = pair<long long, vector<int>>;
int main()
{
    int X, Y, Z, K;
    vector<long long> A, B, C;
    cin >> X >> Y >> Z >> K;
    rep(i, X)
    {
        long long input;
        cin >> input;
        A.push_back(input);
    }
    rep(i, Y)
    {
        long long input;
        cin >> input;
        B.push_back(input);
    }
    rep(i, Z)
    {
        long long input;
        cin >> input;
        C.push_back(input);
    }
    sort(A.begin(), A.end(), std::greater<long long>());
    sort(B.begin(), B.end(), std::greater<long long>());
    sort(C.begin(), C.end(), std::greater<long long>());
    priority_queue<Data> PQ;
    set<Data> queueData;
    PQ.push(Data(A[0] + B[0] + C[0], vector<int>({0, 0, 0})));
    rep(i, K)
    {
        auto c = PQ.top();
        cout << c.first << endl;
        PQ.pop();
        if (c.second[0] < X - 1)
        {
            long long sum = A[c.second[0] + 1] + B[c.second[1]] + C[c.second[2]];
            auto num = c.second;
            num[0]++;
            auto Anext = Data{sum, num};
            if (!queueData.count(Anext))
            {
                queueData.insert(Anext);
                PQ.push(Anext);
            }
        }
        if (c.second[1] < Y - 1)
        {
            long long sum = A[c.second[0]] + B[c.second[1] + 1] + C[c.second[2]];
            auto num = c.second;
            num[1]++;
            auto Bnext = Data{sum, num};
            if (!queueData.count(Bnext))
            {
                queueData.insert(Bnext);
                PQ.push(Bnext);
            }
        }
        if (c.second[2] < Z - 1)
        {
            long long sum = A[c.second[0]] + B[c.second[1]] + C[c.second[2] + 1];
            auto num = c.second;
            num[2]++;
            auto Cnext = Data{sum, num};
            if (!queueData.count(Cnext))
            {
                queueData.insert(Cnext);
                PQ.push(Cnext);
            }
        }
    }
}

Measured memory_bytes: 1408
n, m = map(int, input().split())
edge = []
graph = [[False]*n for _ in range(n)]
visited = [False]*n
for i in range(m):
  a, b = map(int, input().split())
  edge.append((a, b))
  graph[a-1][b-1] = True
  graph[b-1][a-1] = True

def dfs(v):
  visited[v] = True
  for v2 in range(n):
    if graph[v][v2] == False:
      continue
    if visited[v2] == True:
      continue
    dfs(v2)

ans = 0
for _, e in enumerate(edge):
  graph[e[0]-1][e[1]-1] = False
  graph[e[1]-1][e[0]-1] = False

  for j in range(n):
    visited[j] = False

  dfs(0)

  bridge = False
  for j in range(n):
    if not all(visited):
      bridge = True
  if bridge:
    ans += 1

  graph[e[0]-1][e[1]-1] = True
  graph[e[1]-1][e[0]-1] = True

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X,Y,Z,K;
  cin >> X >> Y >> Z >> K;
  vector<long long> A(X),B(Y),C(Z);
  for (int i=0;i<X;i++){
    cin >> A[i];
  }
  for (int i=0;i<Y;i++){
    cin >> B[i];
  }
  for (int i=0;i<Z;i++){
    cin >> C[i];
  }
  vector<long long> BC;
  for (int i=0;i<Y;i++){
    for (int j=0;j<Z;j++){
      BC.push_back(B[i]+C[j]);
    }
  }
  sort(BC.begin(),BC.end());
  reverse(BC.begin(),BC.end());
  vector<long long> ABC;
  for (int i=0;i<X;i++){
    for (int j=0;j<min(Y*Z,K);j++){
      ABC.push_back(A[i]+BC[j]);
    }
  }
  sort(ABC.begin(),ABC.end());
  reverse(ABC.begin(),ABC.end());
  for (int i=0;i<K;i++){
    cout << ABC[i] << endl;
  }
}

Measured memory_bytes: 43240
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define c1 __builtin_popcount
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS

vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
int n,k;
cin>>n>>k;
cout<<min(k-n%k,n%k);
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 3648