akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int MOD = 1e9 + 7;

struct Combination{
  const int MOD = 1e9+7;

  vector<int> fact; //　fact[i] = iの階乗
  void init(int n){
    fact.resize(n+1);
    fact[0] = fact[1] = 1;
    for(int i = 2; i <= n; i++){
      fact[i] = i * fact[i-1] % MOD;
    }
  }

  int nCr(int n,int r){ // nCr = n!/r!(n-r)!
    if(n < r) return 0;
    return fact[n] * mod_pow(fact[r]*fact[n-r]%MOD,MOD-2,MOD) % MOD;
  }

  int mod_pow(int n,int p,int MOD){ // a/n ≡ a*n^(p-2) nとpは互いに素
    int r = 1;
    for(; p > 0; p >>= 1){
      if(p & 1LL) r = (r * n) % MOD;
      n = (n * n) % MOD;
    }
    return r; // r = n^p % MOD
  }

}comb;

signed main(){

  int n, k; cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());

  int ans = 0;
  comb.init(n);
  int m = comb.nCr(n, k) - comb.nCr(n-1, k) + MOD;
  for(int i = 0; i < n; i++){
    ans = (ans - (comb.nCr(n - i, k) - comb.nCr(n - i - 1, k) + MOD) * a[i] + MOD) % MOD;
    ans = (ans + (comb.nCr(i+1, k) - comb.nCr(i, k) + MOD) * a[i]) % MOD;
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main(int argc, char **argv)
{
	int a, b, c, k;
	cin>>a>>b>>c;
	cin>>k;
	
	while(b<=a)
	{
		k--;
		b*=2;
	}
	
	while(c<=b)
	{
		k--;
		c*=2;
	}
	
	if(k<0)
	{
		cout<<"No\n";
	}
	else
	{
		cout<<"Yes\n";
	}
}



Measured memory_bytes: 3628
import math


def isprime(x):
    if x == 2:
        return 1
    elif x < 2:
        return 0
    elif x % 2 == 0:
        return 0
    else:
        for i in range(2, int(math.sqrt(x))+1):
            if x % i == 0:
                return 0
    return 1


if __name__ == "__main__":    
    n = int(input())
    n_list = []
    for _ in range(n):
        n_list.append(int(input()))
    cnt = 0
    for num in n_list:
        cnt += isprime(num)
    print(cnt)



Measured memory_bytes: 6004
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')
def Z(f):
    if f:
        print('Yay!')
    else:
        print(':(')
def ispow(n):
    if int(n**.5)**2==n:
        return True
    return False

y('7' in input())

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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	int X, N, P[100]; cin >> X >> N;
	int mn = BIG;
	int ans;
	REP(i, N) cin >> P[i];
	for(int num = 0; num <= 120; num++){
		bool dame = 0;
		REP(i, N){
			if(P[i] == num) dame = 1;
		}
		if(dame) continue;
		if(chmin(mn, abs(X-num))) ans = num;
	}
	cout << ans << ln;
}

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

using namespace std;

void rwFile() {
    freopen("INP.inp", "r", stdin);
    freopen("OUT.out", "w", stdout);
}

string s, t;
int DP[3002][3002];

void Trace(int i, int j) {
    if (i == 0 || j == 0) return;
    if (s[i - 1] == t[j - 1]) {
        Trace(i - 1, j - 1);
        cout << s[i - 1];
    }
    else {
        if (DP[i - 1][j] > DP[i][j - 1]) Trace(i - 1, j);
        else Trace(i, j - 1);
    }
}

void solve() {
    cin >> s >> t;
    int sLen = s.size();
    int tLen = t.size();
//    for (int i = 0; i <= sLen; i++) DP[i][0] = 0;
//    for (int j = 0; j <= tLen; j++) DP[0][j] = 0;
    for (int i = 1; i <= sLen; i++) {
        for (int j = 1; j <= tLen; j++) {
            if (s[i - 1] == t[j - 1]) DP[i][j] = DP[i  - 1][j - 1] + 1;
            else {
                DP[i][j] = max(DP[i - 1][j], DP[i][j - 1]);
            }
        }
    }
    
    Trace(sLen, tLen);
}

int main()
{
    //rwFile();
    solve();
}


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

int main(){
    int n,r; cin >> n >> r;
    if(n >= 10) cout << r;
    else cout << r+100*(10-n) << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())
sorted_a = sorted(a, reverse=True)
max_a = sorted_a[0]
for i in range(n):
    if max_a != a[i]:
        print(max_a)
    else:
        print(sorted_a[1])

Measured memory_bytes: 14160
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,a,b) for(LL i=a; i<=b; i++)
#define FOD(i,a,b) for(LL i=a; i>=b; i--)
#define pa pair<int,int>
#define fi first
#define se second
#define MOD xxx
#define getbit(n,i) ((n>>(i-1))&1)
#define offbit(n,i) ((n^(1<<(i-1))
#define onbit(n,i) (n|(1<<(i-1)))
#define cntone(x) (__builtin_popcount(x))

using namespace std;
const int N = 3e5+5;
const LL MOD = 1e9+7;
LL n;
LL A[N];
LL BITO[105],BITZ[105],ans(0),PT[65];
int main()
{
    cin >> n;
    FOR(i,1,n) cin >> A[i];
    PT[0] = 1;
    FOR(i,1,59) PT[i] = (PT[i-1]*2)%MOD;
    FOR(i,1,n)
    {
        FOR(j,1,60)
        {
            LL u = getbit(A[i],j);
            LL t;
            if(u==0) t = BITO[j];
            else t = BITZ[j];
            ans = (ans + (t * PT[j-1])%MOD )%MOD;
            if(u==1) BITO[j]++;
            else BITZ[j]++;
        }
    }
    cout << ans;
	return 0;
}


Measured memory_bytes: 5916
N,M=map(int,input().split())
LRD=[list(map(int,input().split())) for i in range(M)]
RDW=[[i,0,0] for i in range(N)]
ff=[0]
def compare(p,q,l):
    l_temp1=0
    l_temp2=0
    flag=0
    while(True):
        if q==p:
            flag=1
            break
        temp=RDW[q][0]
        if temp==q:
            break
        else:
            l_temp1+=RDW[q][2]
            q=temp
    if flag==0:
        while(True):
            if p==q:
                flag=1
                break
            temp=RDW[p][0]
            if temp==p:
                break
            else:
                l_temp2+=RDW[p][2]
                p=temp
    if flag==0:
        if RDW[p][1]>=RDW[q][1]:
            RDW[p][1]=max(RDW[p][1],RDW[q][1]+1)
            RDW[q][0]=p
            RDW[q][2]=l_temp2+l-l_temp1
        else:
            RDW[p][0]=q
            RDW[p][2]=-l_temp2-l+l_temp1
            l_temp2+l-l_temp1
    else:
        ll=l_temp1-l_temp2
        if l!=ll:
            ff[0]=1
for i in range(M):
    a,b,c=LRD[i]
    compare(a-1,b-1,c)
    if ff[0]==1:
        print("No")
        break
else:
    print("Yes")

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

int main() {
  int N, N2;
  cin >> N;
  N2 = N * 2;
  int L[N2];
  for (int i = 0; i < N2; i++) {
    cin >> L[i];
  }
  sort(L, L + N2);
  int ans = 0;
  for (int i = 0; i < N2; i += 2) {
    ans += min(L[i], L[i + 1]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
    cin >> N;
    int K;
    cin >> K;
  	int A = 1;
  for (int i = 0; i < N; i++) {
    if (K<A){
      A += K;
      continue;
    }
    A *= 2;
    }
  cout << A << endl;
}

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

using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  ll H, W, m;
  cin >> H >> W >> m;
  vector<ll> h(m), w(m), hs(H), ws(W);
  rep(i, m) {
    cin >> h[i] >> w[i];
    --h[i];
    --w[i];
    ++hs[h[i]];
    ++ws[w[i]];
  }
  using pll = pair<ll, ll>;
  set<pll> s;
  rep(i, m) s.emplace(h[i], w[i]);
  ll hsmax = -1, wsmax = -1;
  itr(x, hs) updatemax(hsmax, x);
  itr(x, ws) updatemax(wsmax, x);
  vector<ll> hsmaxi, wsmaxi;
  rep(i, H) if (hs[i] == hsmax) hsmaxi.push_back(i);
  rep(i, W) if (ws[i] == wsmax) wsmaxi.push_back(i);
  ll ans = hsmax + wsmax;
  if (hsmaxi.size() * wsmaxi.size() <= m) {
    itr(hi, hsmaxi) itr(wi, wsmaxi) {
      if (s.find(pll(hi, wi)) == s.end()) goto end;
    }
    --ans;
  }
end:
  cout << ans << endl;
}


Measured memory_bytes: 39632
import java.util.*;

// ABC 62-D
// http://abc062.contest.atcoder.jp/tasks/arc074_b

public class Main {
	
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int[] scores = new int[N];
		
		int sum = 0;
		ArrayList<Integer> notTenMultiple = new ArrayList<Integer>();
		
		for (int i = 0; i < N; i++) {
			int a = in.nextInt();
			if (a % 10 != 0) {
				notTenMultiple.add(a);
			}
			sum += a;
		}

		notTenMultiple.sort(null);
		
		if (sum % 10 == 0) {
			if (notTenMultiple.size() > 0) {
				sum -= notTenMultiple.get(0);
			} else {
				sum = 0;
			}
		}
		
		System.out.println(sum);
	}
}

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

int main() {
  int S, h, m, s;
  cin >> S;
  h = S / 3600;
  S %= 3600;
  m = S / 60;
  S %= 60;
  s = S;
  
  cout << h << ":" << m << ":" << s << endl;
  
  return 0;
  
}



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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int x, a, b;
int main() {
    std::cin >> x >> a >> b;
    if(std::abs(x-a) < std::abs(x-b)) {
        std::cout << "A" << std::endl;
    } else {
        std::cout << "B" << std::endl;
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        // BufferedReader 效率优于 Scanner
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());

        LinkedList test = new LinkedList();

        for (int i = 0; i < n; i++) {
            String[] cmd = br.readLine().split(" ");
            switch (cmd[0]) {
                case "insert":
                    test.insert(Integer.parseInt(cmd[1]));
                    break;
                case "delete":
                    test.delete(Integer.parseInt(cmd[1]));
                    break;
                case "deleteFirst":
                    test.deleteFirst();
                    break;
                case "deleteLast":
                    test.deleteLast();
                    break;
            }
        }

        test.printList();
    }
}

class Node {
    public int key;
    public Node prev, next;

    public Node() {
        this.prev = this;
        this.next = this;
    }

    public Node(int key) {
        this.key = key;
        this.prev = null;
        this.next = null;
    }
}

class LinkedList {
    public Node head;

    public LinkedList() {
        this.head = new Node();
    }

    public void insert(int key) {
        Node x = new Node(key);
        x.next = this.head.next;
        this.head.next.prev = x;
        this.head.next = x;
        x.prev = this.head;
    }

    public void deleteFirst() {
        Node cur = head.next;
        cur.next.prev = head;
        head.next = cur.next;
    }

    public void deleteLast() {
        Node cur = head.prev;
        cur.prev.next = head;
        head.prev = cur.prev;
    }

    public void delete(int key) {
        Node cur = head.next;
        while(cur != head){
            if(cur.key == key){
                cur.prev.next = cur.next;
                cur.next.prev = cur.prev;
                break;
            }
            cur = cur.next;
        }
    }

    public void printList() {
        Node cur = this.head.next;
        if(cur == this.head){
            System.out.println();
            return;
        }
        StringBuilder sb = new StringBuilder();
        boolean format = true;
        while(cur != this.head){
            if(format){
                sb.append(cur.key);
                format = false;
            }else {
                sb.append(" " + cur.key);
            }
            cur = cur.next;
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 189620
#include <stdio.h>

int min(int a, int b)
{
  return a < b ? a : b;
}

int main(void)
{
  int A, B, C, D;
  scanf("%d%d%d%d", &A, &B, &C, &D);
  printf("%d\n", min(A, B) + min(C, D));  
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,h) for(int i=0;i<h;i++)
 
int main(void) {
  long long int n,cnt=0,ans;
  cin>>n;
  
  while(n/2>0){
    n/=2;
    cnt++;
  }
  
  ans=pow(2,cnt)*2;
  
  cout << ans-1 << endl;
  
  return 0;
}

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

int main() {
	int h, n;
	cin >> h >> n;
	vector<int> a(n), b(n);
	rep(i, n) cin >> a[i] >> b[i];
	const int INF = 1001001001;
	vector<int> dp(h+1, INF);
	dp[0] = 0;
	rep(i, h) {
		rep(j, n) {
			int next_hp = min(h, i + a[j]);
			dp[next_hp] = min(dp[next_hp], dp[i] + b[j]);
		}
	}
	cout << dp[h] << endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int n, w, weight, value, sf, sol[100010];

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

    sf = n * 1000;

    for (int i = 1; i <= sf; i++)
        sol[i] = w + 1;
    sol[0] = 0;

    for (int i = 1; i <= n; i++) {
        cin >> weight >> value;

        int pass = w - weight;

        for (int i = n * 1000 - value; i >= 0; i--)
            if (sol[i] <= pass)
                sol[i + value] = min(sol[i + value], sol[i] + weight);
    }

    for (int i = sf; i >= 0; i--)
        if (sol[i] <= w) {
            cout << i;
            break;
        }
    return 0;
}





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

int main(){
    int N, K;
    cin >> N >> K;
    vector<vector<int>> A(K, vector<int>(N));
    vector<int> d(K);
    for(int i=0; i<K; i++){
        cin >> d.at(i);
        for(int j=0; j<d.at(i); j++){
            cin >> A.at(i).at(j);
        }
    }
    set<int> s;
    for(int i=0; i<K; i++){
        for(int j=0; j<d.at(i); j++) s.insert(A.at(i).at(j));
    }
    cout << N - s.size() << endl;
}

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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

inline void Main() {
  // code
  int a,b;
  cin>>a>>b;
  if((a+b)%2==0) {
    cout << (a+b) / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int x = a.at(i);
		while (true) {
			if (x % 2 == 0) {
				x /= 2;
				ans++;
			}
			else break;
		}
	}
	cout << ans << endl;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int N;
	cin>>N;
	vint A(N);rep(i,N)cin>>A[i];
	rep(i,N){
		if(A[i]&1){
			cout<<"first"<<endl;
			return 0;
		}
	}
	cout<<"second"<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
#include <numeric>
#include <array>

using namespace std;

typedef long long ll;


int main(int argc, const char * argv[]) {
    int N; cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];
    
    for (int i = N - 1; i > 0; i--) {
        if (H[i] < H[i - 1] - 1) {
            cout << "No" << endl;
            return 0;
        } else if (H[i] == H[i - 1] - 1) {
            H[i - 1] -= 1;
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}


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

int N;
int P[200010], Q[200010];
int dp[200010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> P[i];
    P[i]--;
  }
  for (int i = 0; i < N; i++) {
    Q[P[i]] = i;
  }
  dp[0] = 1;
  for (int i = 1; i < N; i++) {
    if (Q[i - 1] < Q[i]) dp[i] = dp[i - 1] + 1;
    else dp[i] = 1;
  }
  cout << N - *max_element(dp, dp + N) << endl;

  return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<utility>
#include<vector>
#include<map>
using namespace std;
typedef pair<int, int> edge;

const int MAX_N = 1e5 + 1;
const int MAX_M = 1e5 + 1;

int u[MAX_M], v[MAX_M];
int color[MAX_N], cnt[MAX_N];
bool is_visited[MAX_N];
vector<int> graph[MAX_N], tree[MAX_N];
map<edge, bool> in_tree;
vector<edge> ans;

void make_tree(int node) {
    color[node] = 2;
    for (int i = 0; i < graph[node].size(); i++) {
        if (color[graph[node][i]]) continue;
        color[graph[node][i]] = 1;
        tree[node].push_back(graph[node][i]);
        tree[graph[node][i]].push_back(node);
        in_tree[edge(node, graph[node][i])] = true;
        in_tree[edge(graph[node][i], node)] = true;
    }
    for (int i = 0; i < tree[node].size(); i++) {
        if (color[tree[node][i]] == 1) make_tree(tree[node][i]);
    }
}

void decide_direction(int node, int prev) {
    is_visited[node] = true;
    for (int i = 0; i < tree[node].size(); i++) {
        if (is_visited[tree[node][i]]) continue;
        decide_direction(tree[node][i], node);
    }
    if (prev < 0) return;
    if (cnt[node] % 2) {
        cnt[node]++;
        ans.push_back(edge(node, prev));
    }
    else {
        cnt[prev]++;
        ans.push_back(edge(prev, node));
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> u[i] >> v[i];
        u[i]--, v[i]--;
        graph[u[i]].push_back(v[i]);
        graph[v[i]].push_back(u[i]);
    }
    if (M % 2) {
        cout << -1 << endl;
        return 0;
    }
    make_tree(0);
    for (int i = 0; i < M; i++) {
        if (in_tree[edge(u[i], v[i])]) continue;
        cnt[u[i]]++;
        ans.push_back(edge(u[i], v[i]));
    }
    decide_direction(0, -1);
    for (int i = 0; i < M; i++) {
        cout << ans[i].first + 1 << ' ' << ans[i].second + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 38388
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;

int n, q;
int v[262144], w[262144];
vector<PII> hv[4096];

int query(int cv, int cl)
{
	if(cl < 0) return -INF;
	if(cv < 4096) return (upper_bound(hv[cv].begin(), hv[cv].end(), MP(cl, INF)) - 1)->second;
	return max(query(cv >> 1, cl), query(cv >> 1, cl - w[cv]) + v[cv]);
}

vector<PII> cur;

int main()
{
	scanf("%d", &n);
	rep1(i, n) scanf("%d%d", &v[i], &w[i]);
	hv[0].push_back(MP(0, 0));
	rep1(i, min(n, 4095)) {
		cur = hv[i >> 1];
		rep(j, cur.size()) {
			cur[j].first += w[i];
			cur[j].second += v[i];
		}
		hv[i].resize(cur.size() + hv[i >> 1].size());
		merge(hv[i >> 1].begin(), hv[i >> 1].end(), cur.begin(), cur.end(), hv[i].begin());
		rep(j, hv[i].size()) if(j > 0) hv[i][j].second = max(hv[i][j].second, hv[i][j - 1].second);
		for(int j = hv[i].size() - 1; j > 0; j --) if(hv[i][j].first == hv[i][j - 1].first) hv[i][j - 1].second = hv[i][j].second;
		hv[i].resize(unique(hv[i].begin(), hv[i].end()) - hv[i].begin());
	}
	scanf("%d", &q);
	rep(i, q) {
		int qv, ql;
		scanf("%d%d", &qv, &ql);
		printf("%d\n", query(qv, ql));
	}
	return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int d,n;cin>>d>>n&&d|n;){
		if(n==100) n++;
		cout<<to_string(n)+string(2*d,'0')<<endl;
	}
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
 
fn input_char_vec() -> Vec<char> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().chars().collect()
}
 
fn main() {
    let s = input_char_vec();
    let mut t = input_char_vec();
    t.remove(t.len() - 1);
    if s == t {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 2104
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

int main(){
    int h,m,s,h1,m1,s1,memo;
    
    for(int i=0;i<3;i++){
        scanf("%d%d%d%d%d%d",&h,&m,&s,&h1,&m1,&s1);
        memo=((h1*60+m1)*60+s1)-((h*60+m)*60+s);
        printf("%d %d %d\n",memo/3600,memo/60%60,memo%60);
    }
    
    return 0;
}

Measured memory_bytes: 1188
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,long double> Pi;
typedef pair <long double,int> Pd;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
vector<ll> d(n);
ll sumb=0;
for(int i=0;i<n;i++){
    ll a,b;
    cin>>a>>b;
    sumb-=b;
    d[i]=a+b;
}
sort(all(d),greater<ll>());
for(int i=0;i<n;i++){
    if(i%2==0)sumb+=d[i];
}
cout<<sumb<<endl;
}



Measured memory_bytes: 1024
from itertools import permutations
import collections
N = int(input())
nums = list(map(int, input().split()))
odd_nums = []
even_nums = []
for i, num in enumerate(nums):
    if i % 2 == 1:
        even_nums.append(num)
    else:
        odd_nums.append(num)

useable_nums = set(nums)
even_length = len(even_nums)
odd_length = len(odd_nums)
even_counter = collections.Counter(even_nums).most_common()
odd_counter = collections.Counter(odd_nums).most_common()
even_counter.append((0, 0))
odd_counter.append((0, 0))
even_counter.sort(key=lambda x: x[1], reverse=True)
odd_counter.sort(key=lambda x: x[1], reverse=True)
# print(even_counter)
# print(odd_counter)


min_ans = None
if even_counter[0][0] == odd_counter[0][0]:
    min_ans = min((odd_length - odd_counter[0][1]) + (even_length - even_counter[1][1]),
                  (odd_length - odd_counter[1][1]) + (even_length - even_counter[0][1]))
else:

    min_ans = odd_length - odd_counter[0][1] + even_length - even_counter[0][1]
print(min_ans)


Measured memory_bytes: 29956
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>
#include<utility>

using namespace std;

int main()
{
	int n;
	cin >> n;
	double ans = 0;
	for (int i = 0; i < n; i++)
	{
		double x;
			string y;
		cin >> x >> y;
		if (y == "JPY")
		{
			ans += x;
		}
		else
		{
			ans += x * 380000;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int com(const void *a,const void *b){
  return *(int*)a - *(int*)b;
}
int main(){
  int n,d[110],i,ans=1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&d[i]);
  }
  qsort(d,n,sizeof(int),com);

  for(i=1;i<n;i++){
    if(d[i]>d[i-1]){
      ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

class UnionFind():
    def __init__(self,n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n

    def root(self,x):
        if x == self.par[x]:
            return x
        r = self.root(self.par[x])
        self.par[x] = r
        return r

    def unit(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y: return False
        if self.rank[x] < self.rank[y]: x, y= y, x,
        if self.rank[x] == self.rank[y]: self.rank[x] += 1
        self.par[y] = x
        return True
#A
def A():
    n, a = II(), II()
    print(n * n - a)
    return

#B
def B():
    _ = II()
    k = II()
    x = LI()
    ans = 0
    for xi in x:
        ans += min(xi, k - xi)
    print(ans * 2)
    return

#C
def C():
    a, b, c, d, e, F = LI()
    ans = [min(a,b)*100, 0]
    for ai in range(F // (100 * a) + 1):
        for bi in range((F - 100 * ai * a) // (100 * b) + 1):
            if ai == bi == 0:
                continue
            ab = ai * 100 * a + bi * 100 * b
            for ci in range((F - ab) // c + 1):
                for di in range((F - ab - ci * c) // d + 1):
                    if (ai * a + bi * b) * e < ci * c + di * d:
                        continue
                    if ans[1] / ans[0] < (ci * c + di * d) / (ab + ci * c + di * d):
                        ans = [ab + ci * c + di * d, ci * c + di * d]
    print(*ans)
    return

#D
def D():
    n = II()
    edg = LIR(n)

    ans = 0
    for i in range(n):
        for k in range(i + 1, n):
            ans += edg[i][k]

    for x in range(n):
        for y in range(x + 1, n):
            for k in range(n):
                if x == k or y == k:
                    continue
                if edg[x][y] > edg[x][k] + edg[k][y]:
                    print(-1)
                    return
                if edg[x][y] == edg[x][k] + edg[k][y]:
                    ans -= edg[x][y]
                    break

    print(ans)

    return

#Solve
if __name__ == '__main__':

    D()


Measured memory_bytes: 44892
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, w, ans = 0; cin >> n >> w;
    vi weight(n), value(n);
    cin >> weight[0] >> value[0];
    ll ofs = weight[0];

    // weight[0]を1として正規化
    repf(i, n-1){
        cin >> weight[i] >> value[i];
        weight[i] -= weight[0];
    }
    weight[0] = 0;

    // dp[i][j][k]; i番目の商品まででj個使って重さkの場合の最大価値
    vector<vvi> dp(n+1, vvi(n+1, vi((n+1)*3+1)));
    for(ll i=0; i<n; i++){
        for(ll j=0; j<n; j++){
            for(ll k=0; k<=n*3+1; k++){
                //chmax(dp[i+1][j][k], dp[i][j][k]);
                if(weight[i] <= k) dp[i+1][j+1][k] = max(dp[i][j+1][k], dp[i][j][k-weight[i]] + value[i]);
                else dp[i+1][j+1][k] = dp[i][j+1][k];
            }
        }
    }

    // テーブルを参照して最大値を出力
    for(ll j=1; j<=n; j++){
        if(w-j*ofs<0) continue;
        chmax(ans, dp[n][j][min(3*n, w-j*ofs)]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 28156
#include<stdio.h>

int main(void){
    int i,n,x,cnt;
    int d1,d2;
    cnt = 1;
    d1 = 0;

    scanf("%d %d",&n,&x);
    int L[n+10];
    for(i=1; i<=n; i++){
        scanf("%d",&L[i]);
    }

    for(i=1; i<=n; i++){
        d2 = d1 + L[i];
        if(d2 <= x){
            cnt++;
            d1 = d2;
            continue;
        }else if(d2 > x){
            break;
        }
    }

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

    return 0;
}

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

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut ans = 1;
    for i in 1..n+1 {
        ans *= i;
        ans = ans % (1000000000 + 7);
    }

    println!("{}",ans);

}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
/* 
int get(int x)
{
	if(x==fa[x])	return x;
	return fa[x]=get(fa[x]);
}//路径压缩 
int merge(int x,int y)
{
	fa[get(x)]=get(y);
}//合并 */ 
int main()
{
	int n;float ans;
	cin>>n;
	int y=n/2+1;
	if(n%2==0)	ans=0.5;
	else
	ans=(float)y/(float)n;
	printf("%.7f",ans);
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
int a,b,c,d,e;
while(1){
scanf("%d",&a);
if(a==0) break;
d=e=0;
for(int i=0;i<a;i++)
{scanf("%d%d",&b,&c);
if(b<c) e=e+b+c;
else if(b>c) d=d+b+c;
else {d=d+b;
e=e+c;}}
printf("%d %d\n",d,e);
}
return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




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

int n;
cin >> n;

auto dig = [&](int c) {
    int res = 0;
    while (c) {
      c /= 10;
      ++res;
    }
    return res;
  };

int ans = 0;
for(int i = 1;i <= n;++i) if(dig(i) % 2 == 1) ans++;

cout << ans << endl;


return 0;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<pair<int, int>> student(N);
    vector<pair<int, int>> check(M);
    for (int i = 0; i < N; i++){
        int a,b;
        cin >> a >> b;
        student.at(i) = make_pair(a,b);
    }
    for (int i = 0; i < M; i++){
        int c,d;
        cin >> c >> d;
        check.at(i) = make_pair(c,d);
    }
    for(int i = 0; i < N; i++){
        int near = 1;
        int dis = 100000000000;
        for (int j = 0; j < M; j++){
            int d;
            d = abs(student.at(i).first - check.at(j).first) + abs(student.at(i).second - check.at(j).second);
            if(d < dis){
                near = j + 1;
                dis = d;
            }
        }
        cout << near << endl;
    }

}

Measured memory_bytes: 256
gets
nums = gets.split(' ').map(&:to_i)
sorted_nums = nums.sort{|a, b| b <=> a}

alice_nums = sorted_nums.select.with_index{|_, i| i.even?}
bob_nums = sorted_nums.select.with_index{|_, i| i.odd?}

p alice_nums.inject(&:+) - bob_nums.inject(&:+)


Measured memory_bytes: 1788
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::BTreeMap;

fn main() {
    input!(n: usize, xy: [(i64, i64); n]);

    let mut mp = BTreeMap::new();

    for i in 0..n {
        let (x1, y1) = xy[i];
        for j in 0..n {
            if i == j {
                continue;
            }
            let (x2, y2) = xy[j];
            *mp.entry((x2 - x1, y2 - y1)).or_insert(0) += 1;
        }
    }

    let mut nax = 0;
    for (_, c) in mp.iter() {
        nax = max(nax, *c);
    }
    let cost = n - nax;
    // println!("nax:{}, cost:{}", nax, cost);
    println!("{}", cost);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//CODE
void solve(void)
{  
  double A,B;
  cin>>A>>B;
  cout<<A/B<<endl;
  
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	char O[64], E[64];
	int i;
	if (scanf("%63s", O) != 1) return 1;
	if (scanf("%63s", E) != 1) return 1;
	i = 0;
	for (;;) {
		if (O[i] == '\0') break;
		putchar((unsigned char)O[i]);
		if (E[i] == '\0') break;
		putchar((unsigned char)E[i]);
		i++;
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
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; }
#define INF 1<<30
int main()
{
	int N, M;
	cin >> N >> M ;
	vector<pair<int,int>> p(M);
	REP(i, M){
		int t1,t2;
		cin >> t1>>t2;
		p[i].first=t2;
		p[i].second=t1;
	}

	sort(p.begin(),p.end());

	int ans=1;
	int t=p[0].first;
	REP2(i,1,M){
		if(t<=p[i].second){
			ans++;
			t=p[i].first;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
  int n;
  cin >> n;
  
  if(n < 105)
    cout << 0 << endl;
  else if(n < 135)
    cout << 1 << endl;
  else if(n < 165)
    cout << 2 << endl;
  else if(n < 189)
    cout << 3 << endl;
  else if(n < 195)
    cout << 4 << endl;
  else
    cout << 5 << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
x,n = map(int, input().split())
cnt = 1

if n > 0:
  p = list(map(int, input().split()))
  if x not in p:
    print(x)
  else:
    while True:
      l = x - cnt
      r = x + cnt
      if l not in p:
        print(l)
        break
      elif r not in p:
        print(r)
        break
      cnt += 1
else:
  print(x)

Measured memory_bytes: 9196
from collections import Counter
s = input()
k = int(input())
se = set()

for i in range(len(s)):
    temp = ''
    last = min(i+5,len(s))
    for j in range(i,last):
        temp+=s[j]
        se.add(temp)
se = list(sorted(se))
print(se[k-1])
    

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

using namespace std;

typedef long long LL; 

int main()
{
	LL x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	LL w=x/d;
	if(w>=k)  x-=k*d;
	else
	{
	    x%=d;
	    k-=w;
	    if(k&1) x-=d;
	    x=abs(x);
	}
	cout<< x <<endl;
	return 0;
}

Measured memory_bytes: 3548
n=int(input())
a,b=1,1

def div(k,l):
    if k%l==0:
        return k//l
    else:
        return k//l+1

for i in range(n):
    x,y=map(int,input().split())
    m=max(div(a,x),div(b,y))
    a=m*x
    b=m*y
print(a+b)


Measured memory_bytes: 3060
import java.util.*;

public class Main {

    private static final long MOD = 1000000007L;

    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    private boolean isAGC(String str) {
        if (str.contains("AGC")) {
            return true;
        } else if (str.contains("GAC")) {
            return true;
        } else if (str.contains("ACG")) {
            return true;
        } else if (str.startsWith("A") && str.endsWith("GC")) {
            return true;
        } else if (str.startsWith("AG") && str.endsWith("C")) {
            return true;
        }
        return false;
    }

    private void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if (N == 3) {
            System.out.println(61);
            return;
        }

        String ACGT = "ACGT";
        Map<String, Long> map = new HashMap<>();
        for (char c1 : ACGT.toCharArray()) {
            for (char c2 : ACGT.toCharArray()) {
                for (char c3 : ACGT.toCharArray()) {
                    for (char c4 : ACGT.toCharArray()) {
                        String key = "" + c1 + c2 +c3 + c4;
                        map.put(key, isAGC(key) ? 0L : 1L);
                    }
                }
            }
        }
        for (int cur = 4; cur < N; cur += 1) {
            Map<String, Long> nextMap = new HashMap<>();
            for (String key : map.keySet()) {
                for (char next : ACGT.toCharArray()) {
                    String nextKey = (key + next).substring(1);
                    if (!isAGC(nextKey)) {
                        if (!nextMap.containsKey(nextKey)) {
                            nextMap.put(nextKey, 0L);
                        }
                        long nextValue = nextMap.get(nextKey) + map.get(key);
                        nextValue %= MOD;
                        nextMap.put(nextKey, nextValue);
                    }
                }
            }
            map = nextMap;
        }

        long ans = 0L;
        for (long value : map.values()) {
            ans += value;
            ans %= MOD;
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 41556
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define riterator reverse_iterator
#define U ((1<<n)-1)
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 18;
const llong INF = 1e17;
llong a[N+3];
int n;

void updmin(llong &x,llong y) {x = min(x,y);}

llong dfs(int l,int r,llong x,llong y)
{
	if(r-l<=1) return 0ll;
	llong ret = INF;
	for(int i=l+1; i<r; i++)
	{
		updmin(ret,dfs(l,i,x,x+y)+dfs(i,r,x+y,y)+a[i]*(x+y));
	}
	return ret;
}

int main()
{
	scanf("%d",&n);
	for(int i=0; i<n; i++) scanf("%lld",&a[i]);
	printf("%lld\n",dfs(0,n-1,1ll,1ll)+a[0]+a[n-1]);
	return 0;
}

Measured memory_bytes: 384