akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))
 
vector<ll> ansR(string s){
	ll l = s.size();
	vector<ll> firstL(l,0),ans(l,0);
	FOR(i,1,l){
		firstL[i] = firstL[i-1] + (s[i]=='L');
	}
	FOR(i,0,l){
		if(s[i]=='R'){
			ll fl = POSU(firstL,firstL[i]);
			fl -= i;
			if(fl%2){
				ans[fl-1+i]++;
			}else{
				ans[fl+i]++;
			}
		}
	}
	return ans;
}



int main(){ 
	string s,sm;
	cin >> s;
	sm = s;
	FOR(i,0,s.size()){
		if(s[i]=='R'){
			sm[i]='L';
		}else{
			sm[i] = 'R';
		}
	}
	REV(sm);
	vector<ll> ans1,ans2;
	ans1 = ansR(s);
	ans2 = ansR(sm);
	REV(ans2);
	cout << ans1[0]+ans2[0];
	FOR(i,1,s.size()){
		cout << " " << ans1[i]+ans2[i];
	}
	cout << endl;
}


Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
if a[0] == 0:
    print(0)
else:
    s = 1
    for aa in a:
        s *= aa
        if s > 1e18:
            print("-1")
            break
    if s <= 1e18:
        print(s)

Measured memory_bytes: 89244
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (c >= a && c <= b) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pb push_back
#define mp make_pair
const unsigned int mod = 1e9+7;
const int mx=1e5+5;
ll n,m;
vector <ll> loc[1<<17];
int main(){
	cin >> n >> m;
	vector <int> a(n),b(n);
	rep(i,n)cin >> a[i] >> b[i];
	rep(i,n){
		if(m-a[i]<0)continue;
		loc[m-a[i]].push_back(b[i]);
	}
	ll ans=0;
	priority_queue <long long> pq;
	for(int i=m;i>=0;--i){
		for(int j=0;j<loc[i].size();++j)pq.push(loc[i][j]);
		if(!pq.empty()){
			ans+=pq.top();
			pq.pop();
		}
	}


	cout << ans << endl;
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}




// combination mod prime
// mintが必要
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

bool a[1000010];
bool b[1000010];

int main(){
    int n,m;
    cin >> n >> m;
    rep(i,n){
        int A;
        cin >> A;
        a[A]=true;
    }
    rep(i,m){
        int B;
        cin >> B;
        b[B]=true;
    }
    int v_cnt = 0;
    int p_cnt = 0;
    mint ans = 1;
    int M = n*m;
    for(int i=M;i>=1;i--){
        int u = M-i;
        if(a[i]&&b[i]){
            v_cnt++;
            p_cnt++;
        }
        else if(a[i]){
            ans *= p_cnt;
            v_cnt++;
        }
        else if(b[i]){
            ans *= v_cnt;
            p_cnt++;
        }
        else{
            ans *= (v_cnt*p_cnt-u);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
mod = 10**9+7
n, k = map(int, input().split())
a = [int(x) for x in input().split()]

pl = []
mn = []
zr = []

tmp = 1
cnt = 0

for x in a:
    if x > 0:
        pl.append(x)
    elif x < 0:
        mn.append(-x)
    else:
        zr.append(x)

pl = sorted(pl, reverse=True)
mn = sorted(mn, reverse=True)

ans = 0

if n == k:
    ans = 1
    for i in range(n):
        ans *= a[i]
        ans %= mod
    print(ans)
    exit()

if len(mn) >= k and k % 2:
    tmp = 1
    for i in range(1, k+1):
        tmp *= mn[-i]
        tmp %= mod
    ans = -tmp

if len(zr) > 0:
    ans = max(0, ans)

pl_cum = [1]
for i, x in enumerate(pl):
    pl_cum.append(pl_cum[-1]*x % mod)

mn_cum = [1]
for i, x in enumerate(mn):
    mn_cum.append(mn_cum[-1]*x % mod)


for p in range(0, k+1, 2):
    if len(mn) < p:
        break
    first = False
    if len(pl) >= k-p:
        first = True
        pl_ind = k-p
        mn_ind = p
        break

if not first:
    print(ans % mod)
    exit()

while pl_ind-2 > -1 and mn_ind+1 < len(mn):
    if pl[pl_ind-1]*pl[pl_ind-2] <= mn[mn_ind]*mn[mn_ind+1]:
        pl_ind -= 2
        mn_ind += 2
    else:
        break

if pl_ind < 0:
    ans = mn_cum[mn_ind]
else:
    ans = pl_cum[pl_ind]*mn_cum[mn_ind]

print(ans % mod)


Measured memory_bytes: 134960
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;

int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
       string s,t,ans;
       cin >> s >> t;
       ans=t;
       ans+=s;
       cout << ans << '\n';

}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

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

    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = i; j <= n; j+=i) {
            ans += j;
        }
    }

    cout << ans << endl;

    return 0;
}


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

typedef pair<int, int> P;
const int N = 2e5;
const int INF = 1e9;

struct edge{ int to,cost; };
vector< edge > G[N];
int n;

void dikstra(int s){
  priority_queue<P,vector<P>,greater<P>> que;
  int d[N]; //sからの最短距離
  fill(d,d+N,INF);
  d[s] = 0;
  que.push({0,s}); //{頂点,最短距離}

  while( !que.empty() ){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(int i = 0; i < G[v].size(); i++){
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push( {d[e.to],e.to} );
      }
    }
  }

  for(int i = 0; i < n; i++){
    cout << i << " " << d[i] << endl;
  }
}

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

  cin >> n;
  for(int i = 0; i < n; i++){
    int u,k; cin >> u >> k;
    for(int j = 0; j < k; j++){
      int v,c; cin >> v >> c;
      G[u].push_back({v,c});
    }
  }
  dikstra(0);

  return 0;
}



Measured memory_bytes: 9500
#include "bits/stdc++.h"
// Begin Header {{{
#define let             const auto
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#define lowerBound(...)                 lowerBound_(__VA_ARGS__)
#define upperBound(...)                 upperBound_(__VA_ARGS__)
#define lowerBound_(begin, end, ...)    (lower_bound((begin), (end), __VA_ARGS__) - (begin))
#define upperBound_(begin, end, ...)    (upper_bound((begin), (end), __VA_ARGS__) - (begin))

#ifdef DBG
#define trace(...) trace_g(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a && (a=b, true);}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a && (a=b, true);}
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
inline bool   isRangeIn(i64 a, i64 low, i64 high) { return (low <= a && a <= high); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
vector<T> makeVec(size_t sz) { return vector<T>(sz); }

template<class T, class... Args>
auto makeVec(size_t sz, Args... args) {
    return vector<decltype(makeVec<T>(args...))>(sz, makeVec<T>(args...));
}

template<class T>
inline void input(T &x) { cin >> x; }

template<class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }

template<class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template<class T>
ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}

template<class T>
ostream& operator<< (ostream &out, const vector<vector<T>> &mat) {
    static constexpr const char *tail[] = { "\n", "" };
    for (const auto &row : mat) out << row << tail[&row == &mat.back()];
    return out;
}

template <class T>
void trace_g(const char *s, T&& x) {
    clog << '{';
    while(*s != '\0') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void trace_g(const char *s, Head&& head, Tail&&... tail) {
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    trace_g(s, std::forward<Tail>(tail)...);
}
// }}} End Header

signed main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);
    var(int, n);

    print(n * n * n);

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,S[10000],q,T[10000],C = 0,i,j;
  
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i = 0 ; i < q ; i++){
    scanf("%d",&T[i]);
  }
  
  for(i = 0 ; i < q ; i++){
    for(j = 0 ; j < n ; j++){
      if(S[j] == T[i]){
	C++;
	break;
      }
    }
  }
  printf("%d\n",C);
  return 0;
}



Measured memory_bytes: 2144
#include <iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    for (char c='a'; c<='z'; c++) {
        if (s.find(c) == string::npos) {
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second

#define N 114514

pair<P,ll> p[N];
ll par[N];
ll ran[N];
ll root(ll x){
	return par[x]==x?x:par[x]=root(par[x]);
}
void unite(ll x,ll y){
	x=root(x);
	y=root(y);
	if(x==y)return;
	if(ran[x]<ran[y])par[x]=y;
	else{
		par[y]=x;
		if(ran[x]==ran[y])ran[x]++;
	}
}
int main(){
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>p[i].ff>>p[i].fs;
		p[i].second=i+1;
	}

	priority_queue<pair<ll,P>>que;
	sort(p,p+n);
	for(int i=1;i<n;i++){
		que.push({-p[i].ff+p[i-1].ff,{p[i].second,p[i-1].second}});
		swap(p[i-1].ff,p[i-1].fs);
	}
	swap(p[n-1].ff,p[n-1].fs);
	sort(p,p+n);
	for(int i=1;i<n;i++){
		que.push({-p[i].ff+p[i-1].ff,{p[i].second,p[i-1].second}});
	}
	
	for(int i=1;i<=n;i++)par[i]=i;
	ll ans=0;
	while(!que.empty()){
		pair<ll,P> x=que.top();
		que.pop();
		if(root(x.sf)!=root(x.ss)){
			ans-=x.first;
			unite(x.sf,x.ss);
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 12064
N = str(input())
a = N[-1]

if a == '2' or a == '4' or a == '5' or a == '7' or a == '9':
    print('hon')
elif a == '0' or a == '1' or a == '6' or a == '8':
    print('pon')
else:
    print('bon')


Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
#define endl '\n'
#define pb(a) push_back(a)
#define ALL(x) x.begin(), x.end()
#define SIZE(x) int(x.size())
#define IOS ios::sync_with_stdio(0);


int main() {
	ll n;
	scanf("%lld",&n);
	if(n<=26) {
		printf("%c",'a'+n-1);
		return 0;
	}
	stack<char>s;
	while(n>0) {
		n--;
		s.push('a'+n%26);
		n/=26;
	}
	while(!s.empty()) {
		printf("%c",s.top());
		s.pop();
	}
	return 0;
	
} 

Measured memory_bytes: 3748
#include<iostream>
using namespace std;
#define MAX 100000

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;
    if (a <= 8 & b <= 8){
        cout << "Yay!";
    } else
    {
        cout << ":(";
    }
    return 0;
}

Measured memory_bytes: 256
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<int> b(n-1);
  vector<int> a(n);
  rep(i, n-1) {
    cin >> b[i];
  }
  a[0] = b[0];
  for(int i = 1; i < n-1; i++) {
    a[i] = min(b[i-1], b[i]);
  }
  a[n-1] = b[n-2];
  ll ans = 0;
  rep(i, n) {
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from functools import lru_cache
from collections import Counter

@lru_cache()
def comb(a,b):
  if not a>=b>=0:
    return 0
  if b==1:
    return a
  elif b==0:
    return 1
  return comb(a-1,b)+comb(a-1,b-1)

n,a,b=map(int,input().split())
v=sorted(map(int,input().split()))[::-1]

tg=v[:a]
avg=sum(tg)/a
ans=0

e=Counter(v)
for i in range(a,b+1):
  tmp=1
  tg=v[:i]
  d=Counter(tg)
  if sum(tg)/i!=avg:break
  for i in d.keys():
    tmp*=comb(e[i],d[i])
  ans+=tmp

print(avg)
print(ans)

Measured memory_bytes: 3680
#include <iostream>
#include <stack>
#include <cstring>
#include <algorithm>
#include <vector> 
#include <map>
#include <string>
using namespace std;
long long gcd(long long x, long long y) {
	if (y == 0)return x;
	else return gcd(y, x%y);
}
int main() { // a * b = gcd * lcd     
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	long long a, b, c, d; cin >> a >> b >> c >> d;
	if (c == 1 || d == 1) {
		cout << 0 << '\n'; return 0;
	}
	long long sum = b - a + 1;
	sum -= (b / c - (a - 1) / c);
	sum -= (b / d - (a - 1) / d);
	long long t = c * d / gcd(c, d);
	sum += (b / t - (a - 1) / t);
	cout << sum << '\n';






}

Measured memory_bytes: 256
table=[[0,300,500,600,700,1350,1650],
       [6,0,350,450,600,1150,1500],
       [13,7,0,250,400,1000,1350],
       [18,12,5,0,250,850,1300],
       [23,17,10,5,0,600,1150],
       [43,37,30,25,20,0,500],
       [58,52,45,40,35,15,0]]
while True:
    init=input()
    if init==0:break
    h1,m1=map(int,raw_input().split())
    fin=input()
    h2,m2=map(int,raw_input().split())
    if init>fin:
        init,fin=fin,init
    t1=h1*60+m1
    t2=h2*60+m2
    f=False
    if table[fin-1][init-1]<=40 and 1050<=t1<=1170 or 1050<=t2<=1170:
        f=True
    temp=table[init-1][fin-1]
    if f:
        temp/=2
        if temp%50>0:
            temp+=50-temp%50
    print temp

Measured memory_bytes: 4296
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

using namespace std;

#define PI			3.14159265
#define OO			1e9
#define SS       	second
#define FF       	first
#define Trace(n)  	cout<< #n <<" = "<< n << endl; 
#define ll			long long
//#define endl		"\n"
#define all(v) ((v).begin()), ((v).end())
#define boom main
#define cn(n)  scanf("%d", &n)
#define cnl(n)  scanf("%lld", &n)
#define F(i, a, b) for(int i=a; i<=b; i++)
#define rep(i, n) for(int i=0; i<n; i++)
#define Fill(ar, val) memset(ar, val, sizeof(ar))
#define bit(n) (1<<(n))

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

void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}

int main()
{
	fast();
	ll ans = 0;
	int n;
	cin >> n;
	vector<int> v(n), c(n);

	for (int i = 0; i < n; i++)
		cin >> v[i];
	for (int i = 0; i < n; i++)
		cin >> c[i];

	for (int mask = 1; mask <= (1 << n); mask++)
	{
		ll X, Y;
		X = Y = 0;
		for (int i = 0; i < n; i++)
		{
			if (mask&(1 << i))
			{
				X += v[i];
				Y += c[i];
			}
		}

		ans = max(ans, X - Y);
	}

	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int L, R;
    int d;
    int cnt;

    cin >> L >> R >> d;

    cnt = 0;
    for(int i = L; i <= R; i++)
    {
        if( i % d == 0)
        {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


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

int main(void){
	char array[100][100];
	int i,j,w,h;
	while(1){
		cin >> w;
		cin >> h;
		if(w == 0 || h == 0) break;
		for(i=0;i<w;i++) for(j=0;j<h;j++) cin >> array[i][j];		
		i=0;j=0;
		while(1){
			if(array[i][j] == '>'){ array[i][j] = '/'; j++;}
			else if(array[i][j] == '<'){ array[i][j] = '/'; j--;}
			else if(array[i][j] == '^'){ array[i][j] = '/'; i--;}
			else if(array[i][j] == 'v'){ array[i][j] = '/'; i++;}
			else break;
		}
		if(array[i][j] == '/'){ cout << "LOOP" << endl; }
		else { cout << j << " " << i << endl; }
	}
	return 0;
}

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

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

    int n;
    cin >> n;
    
    float total = 0;

    for(int i = 0; i < n; i ++) {
        int x;
        cin >> x;
        total = total + 1.0/x;
    }

    cout << 1/total;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
class UnionFind
{
public:
  int par[100005];
  int depth[100005];
  int nGroup[100005];
 
  UnionFind(int n) {
    init(n);
  }
 
  void init(int n) {
    for(int i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }
 
  int root(int x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
 
  bool same(int x, int y) {
    return root(x) == root(y);
  }
 
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return;
 
    if(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
} 
int main() {
string s; cin>>s;
ll K; cin>>K;
ll n = s.size();
ll dp[200][10][10]={};
dp[0][0][0]=1;
for(ll i=0; i<n; i++){
ll p = s.at(i) - '0';
for(ll j=0; j<2; j++){
for(ll k=0; k<=K; k++){
for(ll h=0; h<=(j?9:p); h++){
if(h == 0){
dp[i+1][j||(h<p)][k]+=dp[i][j][k];}
else{
dp[i+1][j||(h<p)][k+1]+=dp[i][j][k];}
}}}}
ll ans = dp[n][0][K]+dp[n][1][K];
cout << ans << endl;
}


Measured memory_bytes: 3816
#include<iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int array[n];
    for (int i = n-1; i >= 0; i--) {
        cin >> array[i];
    }
    for (int i = 0; i < n; i++) {
        if (i != 0) cout << " ";
        cout << array[i];
    }
    cout << endl;
}

Measured memory_bytes: 1160
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

N = int(input())
l = make_divisors(N)


ans = float("inf")
if len(l)%2:
    ans = l[len(l)//2]*2-2
else:
    for i in range(len(l)//2):
        ans = min(ans, l[i]-1+N//l[i]-1)
print(ans)

Measured memory_bytes: 3344
INF = 10000000000

n = gets.to_i
as = gets.split.map(&:to_i)

lefts = []
accum = 0
as.each_with_index do |a|
  lefts.push(accum)
  accum = accum.gcd(a)
end

rights = []
accum = 0
as.reverse_each do |a|
  rights.unshift(accum)
  accum = accum.gcd(a)
end

p lefts.zip(rights).map { |a, b| a.gcd(b) }.max

Measured memory_bytes: 16076
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let n = scan "%d" id
let a = scan_array ~sep: ' ' Int.of_string
let b = scan_array ~sep: ' ' Int.of_string
let c = scan_array ~sep: ' ' Int.of_string

let () =
  Array.sort Int.compare a;
  Array.sort Int.compare b;
  Array.sort Int.compare c;
  ArrayL.map b ~f:(fun v ->
      let i = lower_bound (Array.length a) (fun i -> v <= a.(i)) in
      let j = lower_bound (Array.length c) (fun i -> v < c.(i)) in
      i * (Array.length c - j))
  |> Array.sum
  |> Printf.printf "%d\n"


Measured memory_bytes: 18972
#include <bits/stdc++.h>
using namespace std;
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

class Point {
public:
    double x,y;

    Point(double x=0,double y=0):x(x),y(y) {}
    Point operator + (Point p) {return Point(x+p.x,y+p.y);}
    Point operator - (Point p) {return Point(x-p.x,y-p.y);}
    Point operator * (Point p) {return Point(x*p.x,y*p.y);}
    Point operator / (Point p) {return Point(x/p.x,y/p.y);}

    double abs() {return sqrt(norm());}
    double norm() {return x*x+y*y;}

    bool operator<(const Point &p) const {
        return x!=p.x ? x<p.x : y<p.y;
    }
    bool operator==(const Point &p) const {
        return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
    }
};

typedef Point Vector;

double dot(Vector a,Vector b) {
    return a.x*b.x+a.y*b.y;
}

double cross(Vector a,Vector b) {
    return a.x*b.y-a.y*b.x;
}

bool isOrthogonal(Vector a,Vector b) {
    return equals(dot(a,b),0.0);
}

bool isPallalel(Vector a,Vector b) {
    return equals(cross(a,b),0.0);
}

int main(void) {
    int n;
    cin>>n;
Vector a1,a2,b1,b2;
    while(n) {
        cin>>a1.x>>a1.y>>a2.x>>a2.y>>b1.x>>b1.y>>b2.x>>b2.y;
        Vector s,t;
        s=a1-a2;
        t=b1-b2;
        if(isPallalel(s,t)) cout<<2<<endl;
        else if(isOrthogonal(s,t)) cout<<1<<endl;
        else cout<<0<<endl;
        n--;
    }
    return 0;
}

Measured memory_bytes: 3228
#include <stdio.h>
int main() {
   int a,b,c,k;	
    scanf("%d ",&a);	
    scanf("%d ",&b);
    scanf("%d ",&c);
    scanf("%d ",&k);
   int i,t=0;

for(i=1;i<=k; i++){
  if(i<=a) t++;
  else if(i<=(a+b)) t+=0;
  else t--;
}
printf("%d",t);
    return 0;
}


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

int main() {
  while(1) {
    string r,g,s,ans="";
    cin >> r;
    if(r=="-") break;
    cin >> g >> s;

    int ri=0,gi=1,si=0;
    char next=g[0];
    while(1) {
      if(ri==r.size() && gi==g.size()) break;
      if(si<s.size() && s[si]==next) {
	si++;
	next=r[ri++];
      } else {
	ans+=next;
	next=g[gi++];
      }
    }
    cout << ans+next << endl;
  }
  return 0;
}


Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>
#include <stack>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;
using Graph = Vvec<int>;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    if(V<=W){
        cout << "NO\n"; return 0;
    }
    ll D = abs(A-B);
    ll X = abs(V-W);
    cout << ((D<=X*T) ? "YES" : "NO") << "\n";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#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))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

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

	vector<string> s(N);
	REP(i, N) {
		cin >> s[i];
		SORT(s[i]);
	}

	SORT(s);
	// vdebug(s);

	ll coincidecnt = 1;
	ll ans = 0;

	FOR(i, 1, N) {
		if (s[i] == s[i - 1]) coincidecnt++;
		else if (coincidecnt > 1) {
			ans += coincidecnt * (coincidecnt - 1) / 2;
			coincidecnt = 1;
		}
	}
	if (coincidecnt > 1) {
		ans += coincidecnt * (coincidecnt - 1) / 2;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6;
vector<int>a(N);
vector<int>b(N);

int32_t main()
{
   int n; cin>>n; a.resize(n); b.resize(n);
   for(int i=0;i<n;i++) cin>>a[i]>>b[i]; double ans=0.00;
    for(int i=0;i<n;i++) for(int j=i;j<n;j++)
    {
        double x=a[i]-a[j]; double y=b[i]-b[j];
        ans+=pow(x*x+y*y,0.5); 
    }
    cout<<fixed<<setprecision(12)<<ans*2/n;
}

                        
           
                            

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define in(s) ll s; cin>>s
#define pr(r) cout<<r<<endl
#define prr(m,n) cout<<m<<" "<<n<<endl
#define prarr(a,i,n) fab(j,i,n) cout<<a[j]<<" "
#define wh(t) ll t; cin>>t; while(t--)
#define sz(u) u.size()
#define all(v) v.begin(),v.end()
#define arr(a,n) ll a[n]; fab(i,0,n) cin>>a[i]
#define showdp(d,n,m) fab(i,0,n){ fab(j,0,m) if(d[i][j]==-1 || d[i][j]>9) cout<<d[i][j]<<" "; else cout<<" "<<d[i][j]<<" "; cout<<endl; }
#define prs(u) cout<<u<<" "
#define fab(i,a,b) for(ll i=a;i<b;i++)
#define fba(i,b,a) for(ll i=b;i>=a;i--)
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MX 1000000007
#define MAX 10000007
#define endl "\n"
#define ll long long int
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define pl pair<ll,ll>
#define pll pair<ll,pl>
#define vvl vector<vl>
#define mxe(x,n) *max_element(x,x+n)
#define mne(x,n) *min_element(x,x+n)
#define mp make_pair
#define pb push_back
#define fs first
#define sd second
#define fr front()
#define bk back()
#define rr return
#define N 300005
#define inf 1e18+7
 
bool rsort1(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.first > b.first);}
bool rsort2(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.second>b.second);}
bool sort2(const pair<ll,ll> &a,const pair<ll,ll> &b){ return (a.second < b.second);}
 
bool isPrime(ll p)
{
    for(ll i=2;i*i<=p;i++)
        if(p%i==0)
            rr false;
    rr true;
}
 
void sieve(ll n,vl &v)
{
    v.pb(2);
    bool prime[n+1];
    memset(prime,true,sizeof(prime));
    for(ll i=3;i*i<=n;i+=2)
        if(prime[i])
            for(ll j=i;j*i<=n;j+=2)
                prime[j*i]=false;
        
    for(ll i=3;i<=n;i+=2)
        if(prime[i])
            v.pb(i);
}

ll phi(ll n)
{
    ll result=n;
    for(ll p=2;p*p<=n;p++)
    {
        if(n%p==0)
        {
            while(n%p==0)
                n/=p;
            result-=result/p;
        }
    }

    if(n>1)
        result-=result/n;
    return result;
}


int main()
{
	sup;
    
    ll n;
    cin>>n;
    map<pl,ll>m;
    ll first,last,ans=0,d=1;
    fab(i,1,n+1)
    {
        if(i/d==10) d*=10;
        first=i/d,last=i%10;
        if(m[{last,first}]>0)
            ans+=m[{last,first}]*2;
        if(first==last)
            ans++;
        m[{first,last}]++;
    }
    cout<<ans;
    return 0;
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

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

    if(n == 0) {
        cout << 0 << endl;
        ret();
    }

    string ans = "";
    while (n != 0) {
        if (n < 0) {
            ll k = -n;
            ll now = k % 2;
            char c = '0' + now;
            ans += c;
            k = (k + 1) / 2;
            n = k;
        } else {
            ll now = n % 2;
            char c = '0' + now;
            ans += c;
            n /= -2;
        }
    }
    reverse(ans.begin(), ans.end());
    for (char c : ans) cout << c;
    cout << endl;

}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        int a = 0;
        ArrayDeque<Integer> stack = new ArrayDeque<>();
        ArrayDeque<Integer[]> stack2 = new ArrayDeque<>();
        for(int i = 0; i < s.length(); i++){
            if(s.substring(i, i+1).equals("\\")){
                stack.push(i);
            }else if(s.substring(i, i+1).equals("/")){
                if(!stack.isEmpty()){
                    int j = stack.pop();
                    a += i - j;
                    int k = 0;
                    while(!stack2.isEmpty() && j < stack2.peek()[0]){
                        k += stack2.pop()[1];
                    }
                    Integer[] b = new Integer[2];
                    b[0] = j;
                    b[1] = k + i - j;
                    stack2.push(b);
                }
            }
        }
        
        int k = stack2.size();
        StringBuilder sb = new StringBuilder();
        sb.append(a).append(System.lineSeparator());
        sb.append(k).append(" ");
        int[] b = new int[k];
        for(int i = 0; i < k; i++){
            b[b.length-1-i] = stack2.pop()[1];
        }
        for(int i = 0; i < k; i++){
            sb.append(b[i]).append(" ");
        }
        sb.deleteCharAt(sb.length()-1);
        
        System.out.println(sb);
    }
}


Measured memory_bytes: 29808
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int a, b, res;
	cin >> a >> b;

	res = max(2*a - 1, 2*b - 1);
	res = max(a + b, res);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int ans=0;
  if(a>b){
    ans+=a;
    ans+=max(a-1,b);
  }else{
    ans+=b;
    ans+=max(a,b-1);
  }
  cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = Integer.parseInt(scanner.next());
        int y = Integer.parseInt(scanner.next());

        if (x == y) {
            System.out.println(x);
            return;
        }

        if (x < y) {
            int tmp = x;
            x = y;
            y = tmp;
        }

        while (true) {
            int z = x % y;
            if (x % z == 0 && y % z == 0) {
                System.out.println(z);
                break;
            }
            x = y;
            y = z;
        }
    }
}

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

int X[10];
int Y[10];

double dist(int i, int j){
  double dx = X[i] - X[j];
  double dy = Y[i] - Y[j];
  return sqrt(dx * dx + dy * dy);
}

int main(){
  int N;
  cin >> N;
  for(int i= 1; i <= N; i++){
    cin >> X[i] >> Y[i];
  }
  double ans = 0.0;
  for(int i =1; i <=N; i++){
    for(int j = i+1; j <= N; j++){
      ans += dist(i,j) * 2/N;
    }
  }
  cout << fixed << setprecision(10) << ans << endl;
  
}

Measured memory_bytes: 3848
/*input
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

int main()
{
	int q;
	cin>>q;
	while(q--){
		ll a,b;
		cin>>a>>b;
		if(a>=b) swap(a,b);
		if(a==b){
			cout<<2*(a-1)<<'\n';
			continue;
		}
		ll tmp=sqrt(a*b);
		while(tmp*tmp>a*b) tmp--;
		while((tmp+1)*(tmp+1)<=a*b) tmp++;
		if(tmp*tmp==a*b){
			cout<<2*(tmp-1)-1<<'\n';
		}
		else if(tmp*(tmp+1)<a*b) cout<<2*tmp-1<<'\n';
		else cout<<2*tmp-2<<'\n';
	}	
	return 0;
}



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

using namespace std;

const string abacus[] = {"* = ****",
                         "* =* ***",
                         "* =** **",
                         "* =*** *",
                         "* =**** ",
                         " *= ****",
                         " *=* ***",
                         " *=** **",
                         " *=*** *",
                         " *=**** "};
const int height = 8;

int main()
{
    string s;
    bool flag = false;
    int index;

    while (cin >> s) {
        if (flag)
            putchar('\n');

        while (s.size() < 5)
            s = '0' + s;

        for (int i = 0; i < height; i++) {
            for (int j = 0; j < s.size(); j++) {
                index = (int)(s[j] - '0');
                putchar(abacus[index][i]);
            }
            putchar('\n');
        }
        flag = true;
    }

    return 0;
}

Measured memory_bytes: 1160
N,M = map(int,input().split())
H = list(map(int,input().split()))
H.insert(0,0)
G = {i:[] for i in range(1,N+1)}
for _ in range(M):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
cnt = 0
for i in range(1,N+1):
    flag = 1
    for x in G[i]:
        if H[x]>=H[i]:
            flag = 0
            break
    if flag==1:
        cnt += 1
print(cnt)

Measured memory_bytes: 94992
import collections

x,y = map(int, input().split())



def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

#素数判定(試し割り法)
def is_prime(n):
    if n == 1:
        return False
    if n == 2:
        return True

    limit = n ** 0.5
    for i in range(2 , n):
        if n % i == 0:
            return False
        if i >= limit: 
            return True
    print('err')

    

uoo = list(set(prime_factorize(x)) & set(prime_factorize(y)))


print(len(uoo) + 1)



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

using namespace std;

#define PB push_back  
#define MP(A, B) make_pair(A, B)  
#define fi first  
#define se second  

#define gcd(a,b) __gcd(a,b)
#define pi acos(-1.0)
#define pii pair<int,int>
#define ll long long  
#define MAX 1000005  
#define MOD 998244353  
#define M 998244353  
#define INF 0x3f3f3f3f  
#define EXP 1e-8  
#define lowbit(x) (x&-x)  

long long qpow(long long a, long long n) {
    long long ret = 1;
    a = (a % M + M) % M;
    for (; n; n >>= 1) {
        if (n & 1) ret = (ret * a) % M;
        a = (a * a) % M;
    }
    return ret;
}
 
vector<int64_t> fact, seq_inv, fact_inv;
 
void create_fact_mod(int num){
    fact[0] = fact[1] = 1;
    for(int i=2; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
}
 
void create_seq_inv_mod(int num){
    seq_inv[0] = seq_inv[1] = 1;
    for(int i=2; i<=num; i++) seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
}
 
void create_fact_inv_mod(int num){
    fact_inv[0] = fact_inv[1] = 1;
    for(int i=2; i<=num; i++) fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
}
 
void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}
 
int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}
 
int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}
 
int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}
 
int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}
 
int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 


long long n,m, k; 
long long dp[200005] = {0};
int main() {
    cin >> n >> m >> k;
    long long ans = 0;
    create_mod_tables(200005);
    // for (int i = 1; i <= n; ++i) {
    //     int t = min((int)k, i-1);
    //     for (int j = t; j >= 0; --j) {
    //         if (i == 1) {dp[j] = m; continue;}
    //         dp[j] = (dp[j-1] + (m-1)*dp[j]) % MOD;
    //     }
    // }
    long long c = 1;
    for (int i = 0; i <= k; ++i) {
        dp[i] = (m * power_mod(m-1, n-i-1) %MOD * c) %MOD;
        // dp[i] = (m * qpow(m-1, n-i-1) %MOD * comb_mod(n-i, i)) %MOD;
        c = c*(n-i-1)%MOD*power_mod(i+1,MOD-2)%MOD;
        ans = (ans + dp[i]) % MOD;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int N = 1234567;

int a[N], cnt[N], b[N];

int main() {
  int n, tt;
  scanf("%d %d", &n, &tt);
  int empty = n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    cnt[a[i]]++;
    int pos = a[i] - cnt[a[i]] + 1;
    if (pos >= 1) {
      if (b[pos] == 0) {
        empty--;
      }
      b[pos]++;
    }
  }
  while (tt--) {
    int x, y;
    scanf("%d %d", &x, &y);
    {
      int pos = a[x] - cnt[a[x]] + 1;
      if (pos >= 1) {
        b[pos]--;
        if (b[pos] == 0) {
          empty++;
        }
      }
    }
    cnt[a[x]]--;
    a[x] = y;
    cnt[a[x]]++;
    {
      int pos = a[x] - cnt[a[x]] + 1;
      if (pos >= 1) {
        if (b[pos] == 0) {
          empty--;
        }
        b[pos]++;
      }
    }
    printf("%d\n", empty);
  }
  return 0;
}


Measured memory_bytes: 8448
# -*- coding: utf-8 -*-
import sys
N,M,K=map(int, sys.stdin.readline().split())

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

def root(x):
    while par[x]!=x:
        x=par[x]
    return x

def same(x,y):
	return root(x)==root(y)

def unite(x,y):
    x=root(x)
    y=root(y)
    if x==y: return
    if size[x]<size[y]: x,y=y,x  #xの要素数が大きいように
    size[x]+=size[y]
    par[y]=x


def getsize(x):
	return size[root(x)]

al_ok=[ 0 for i in range(N+1) ]	#隣接で友達関係のカウント

for _ in range(M):
    a,b=map(int, sys.stdin.readline().split())
    unite(a,b)
    al_ok[a]+=1
    al_ok[b]+=1

al_ng=[ 0 for i in range(N+1) ]	#隣接でブロックしている人のカウント
for _ in range(K):
    c,d=map(int, sys.stdin.readline().split())
    if same(c,d):
        al_ng[c]+=1
        al_ng[d]+=1

for i in range(1,N+1):
    print getsize(i)-1-al_ok[i]-al_ng[i],


Measured memory_bytes: 39324