akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
	long int A,B,C;
	cin >> A;
	cin >> B;
	if((A+B)>=(A-B)&&(A+B)>=(A*B)){
		C=A+B;
	}
	if((A-B)>=(A+B)&&(A-B)>=(A*B)){
		C=A-B;
	}
	if((A*B)>=(A-B)&&(A*B)>=(A+B)){
		C= A*B;
	}
	cout << C;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

struct Edge{
    ll to, cost;
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
const ll inf = 1e18;
// 隣接リストのdijkstra
// s -> all の最短距離 O(ElogV)


// x 回の補給を行って燃料 y を持って next に到達できるという情報を持ちながら計算
// x が小さい方が良くて, x が等しいならば y が大きい方が良い
vector<P> dijkstra(const Graph &g, int s, ll L){
    ll N = g.size();
    vector<P> d(N, P{inf, 0});
    d[s] = P{0, -L};
    priority_queue<pair<P, ll>, vector<pair<P, ll>>, greater<pair<P, ll>>> que;
    que.push({P{0, -L}, s});
    while(!que.empty()){
        P pp = que.top().first;
        ll cur = que.top().second;
        que.pop();
        if(d[cur] < pp) continue;
        for(const auto &e: g[cur]){
            if(e.cost > L) continue;
            ll pit = d[cur].first;
            ll fuel = -d[cur].second;
            if(fuel < e.cost){
                fuel = L;
                pit++;
            }
            fuel -= e.cost;
            if(d[e.to] < P{pit, -fuel}) continue;
            d[e.to] = P{pit, -fuel};
            que.push({P{pit, -fuel}, e.to});
        }
    }
    return d;
}

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

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

    Graph g(n);

    ll a, b, c;
    REP(i, m){
        cin >> a >> b >> c;
        a--;
        b--;
        g[a].push_back(Edge{b, c});
        g[b].push_back(Edge{a, c});
    }
    // s -> all への最短路が dijkstra により O(V^2) で求まった
    // all -> all は O(V^3)
    vector<vector<P>> d(n);
    REP(i, n){
        d[i] = dijkstra(g, i, l);
    }
    vvll res(n, vll(n));
    REP(i, n){
        REP(j, n){
            res[i][j] = d[i][j].first;
            if(res[i][j] == inf) res[i][j] = -1;
        }
    }
    ll q;
    cin >> q;
    ll s, t;
    while (q) {
        cin >> s >> t;
        s--; t--;
        cout << res[s][t] << endl;
        q--;
    }
    return 0;
}

Measured memory_bytes: 6400
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.immutable._
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}

object Main {
  def solve(sc: => Scanner): Unit = {
    println(sc.next.filter(x => x == 'o').size * 100 + 700)
  }

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 25804
#include<stdio.h>
#include<stdlib.h>
#define N 5000000
void print(int);
int n, tree[N];

int main() {
  int i, j;
  
  scanf("%d", &n);
  
  for (i = 1; i <= n; i++) scanf("%d", &tree[i]);
  for (i = 1; i <= n; i++) print(i);
  return 0;
}
void print(int u) {
  int right = u * 2 + 1;
  int left = u * 2;
  int parent = u / 2;
  printf("node %d: key = %d, ", u, tree[u]);
  if (1 < u) printf("parent key = %d, ", tree[parent]);
  if (left <= n) printf("left key = %d, ",tree[left]); 
  if (right <= n) printf("right key = %d, ", tree[right]);
  printf("\n");
}

Measured memory_bytes: 1032
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { //CASH MONEY
 
	public static void main(String[] args) { //Ball out dawg
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		String S = I.next();
		String ans = "2018";
		ans+=S.substring(4,S.length());
		O.pln(ans);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25520
S = list(input())

if S[0] != "A":
    print("WA")
    exit()

S.pop(0)

res = True
c = False

for i in range(len(S)):
    if i == 0 or i == len(S) - 1:
        if not S[i].islower():
            res = False
    
    else:
        if S[i] == "C":
            if not c:
                c = True
            else:
                res = False

        else:
            if not S[i].islower():
                res = False

if res and c:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 8964
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *
readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

a, b, c, d = readmi()
t1 = b // c - (a - 1) // c
t2 = b // d - (a - 1) // d
l = lcm(c, d)
t3 = 0
t3 = b // l - (a - 1) // l
k = t1 + t2 - t3
print(b - a + 1 - k)


Measured memory_bytes: 6036
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9+5;
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for (int i=0; i<n; i++) {
        cin >> a[i];
        cin >> b[i];
        cin >> c[i];
    }
    int dp[n][3];
    for (int i=0; i<n; i++) {
        for (int j=0; j<3; j++) {
            dp[i][j] = 0;
        }
    }
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for (int i=1; i<n; i++) {
        dp[i][0] = max(dp[i-1][1]+a[i], dp[i-1][2]+a[i]);
        dp[i][1] = max(dp[i-1][2]+b[i], dp[i-1][0]+b[i]);
        dp[i][2] = max(dp[i-1][1]+c[i], dp[i-1][0]+c[i]);
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    return 0;
}


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

using namespace std;
using ll = long long;

int main(void) {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
   int j = vec[i - 1];
   if (vec[j - 1] == i) {
    ans++; 
   }
  }
  cout << ans / 2 << endl;
	return 0;
}


Measured memory_bytes: 640
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

ll n;
vector<ll> a;
vector<ll> cnt(100000);

bool judge(ll P){
    if(a[0]%P){return false;}
    if(P>=n+10){
        for(auto &I:a){
            if(abs(I)%P!=0){return false;}
        }
        return true;
    }
    for(int i=0;i<=P;i++){cnt[i]=0;}
    for(int i=0;i<=n;i++){cnt[i%(P-1)]+=a[i]; cnt[i%(P-1)]%=P;}
    for(int i=0;i<=P;i++){
        if(cnt[i]%P!=0){return false;}
    }
    return true;
}

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

bool prime(ll a){
    if(a<2){return false;}
    for(ll i=2;i*i<=a;i++){
        if(a%i==0){return false;}
    }
    return true;
}

int main(){
    cin>>n;
    a.resize(n+1);
    ll g=-1;
    ll sum=0;
    ll sum2=0;
    for(auto &I:a){
        cin>>I;
        sum+=I;
        sum2+=I;
        sum2*=-1;
        if(I!=0){
            if(g==-1){g=abs(I);}
            else{g=gcd(g,abs(I));}
        }
    }
    reverse(a.begin(),a.end());
    
    vector<ll> ans;
    
    sum/=g;
    sum2/=g;
    
    set<ll> S;
    vector<ll> X;
    for(ll i=2;i*i<=g;i++){
        if(g%i==0){
            X.push_back(i);
            while(g%i==0){g/=i;}
        }
    }
    if(g!=1){X.push_back(g);}
    for(auto &I:X){
        if(prime(I) && judge(I)){
            S.insert(I);
            ans.push_back(I);
        }
    }
    
    
    for(ll i=2;i<5*n;i++){
        if(S.count(i)==0 && prime(i) && judge(i)){ans.push_back(i); S.insert(i);}
    }
    if(!S.empty()){
        for(auto I=S.begin();I!=S.end();++I){
            if(judge(*I) && prime(*I)){
                cout<<(*I)<<endl;
            }
        }
    }
    
    
    return 0;
}


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

int main(){

    int N,K;
    long C = 0;
    cin >> N >> K;
    vector<long> H(N);
    rep(i,N){
        cin >> H[i];
    }
    sort(H.begin(),H.end(),greater<int>());

    for(int M = K;M < H.size();M++){
        C += H[M] / 1;
    }
    cout << C << endl;
    return 0;
}

Measured memory_bytes: 1792
def attack(h, n, A):
  sum = 0
  for i in range(n):
    sum += A[i]
  if sum >= h:
    print('Yes')
  else:
    print('No')
  
h, n = map(int, input().split())
A = list(map(int, input().split()))
attack(h, n, A)

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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll target;
    string s;
    cin>>target>>s;
    vector<ll> pow2(100,1);
    FOR(i,1,100){
      pow2[i]=pow2[i-1]*2;
    }


    while(target>0){
      ll size = s.size()-1;
      ll res = 0;
      ll flag = 2;
      ll res_bit = 0;
      deque<ll> ans;
      FOR(bit,0,pow2[size]){
        ll tmp_res = s[size] - '0';
        ll tmp = 1;
        deque<ll> tmp_ans;
        ll var = tmp_res;
        FOR(i,0,size){
          tmp *= 10;
          if(!(bit&(1<<(size-1-i)))) tmp = 1;
          ll x = s[size-i-1] - '0';
          tmp_res += x*tmp;
          if(tmp == 1){
             tmp_ans.push_back(var);
             var = 0;
          }
          var += x*tmp;
        }
        tmp_ans.push_back(var);


        if(tmp_res<=target){
          if(tmp_res == res) flag = 1;
          if(tmp_res>res){
            res = tmp_res;
            ans = tmp_ans;
            res_bit = bit;
            flag = 0;
          }
        }

      }
      if(flag == 0) {
        cout<<res;
        while(!(ans.empty())){
          cout<<" "<<ans.back();
          ans.pop_back();
        }
        cout<<endl;
      }
      else if(flag == 1) cout<<"rejected"<<endl;
      else cout<<"error"<<endl;

      cin>>target>>s;
    }
}



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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  ll x;  cin >> x;
  int N = 1e3;
  for (int i = -N; i <= N; ++i){
    for (int j = -N; j <= N; ++j){
      ll now = (1LL*i*i*i*i*i) - (1LL*j*j*j*j*j);
      if(now==x){
        cout << i << " " << j << "\n";
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3640
import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
abc = [LI() for _ in range(N)]
dp = [[0,0,0] for _ in range(N)]
dp[0] = abc[0]
for i,j,k in itertools.product(range(1,N),[0,1,2],[0,1,2]):
    if j==k:
        continue
    dp[i][j] = max(dp[i][j],dp[i-1][k]+abc[i][j])
print(max(dp[-1]))


Measured memory_bytes: 72924
// 2020-08-25 18:59:56
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll x, y;
  cin >> x >> y;
  string ans = "Alice";
  if(abs(x-y) <= 1) ans = "Brown";
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
	string s;
	int a;
	cin>>a;
	cin>>s;
	if(a<3200) {
		cout<<"red"<<endl;
		return 0;
	} else {
		cout<<s<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var v = Array.ConvertAll(line, int.Parse);
        line = Console.ReadLine().Trim().Split(' ');
        var c = Array.ConvertAll(line, int.Parse);
        Console.WriteLine(getAns(v,c,n));
    }
    static int getAns (int[] v , int [] c ,int n)
    {
        var ans = 0;
        for (int i = 0; i < n; i++)
            if (v[i] - c[i] > 0) ans += v[i] - c[i];
        return ans;
    }
}

Measured memory_bytes: 11092
n,m,k = map(int,input().split())
mod = 10**9+7

def make_array_for_comb(N, mod=10**9+7):
    fact = [1,1]
    fact_inv = [1,1]
    inv = [0,1]
    for i in range(2, N+1):
        fact.append((fact[-1]*i) % mod)
        inv.append((-inv[mod%i] * (mod//i)) % mod)
        fact_inv.append((fact_inv[-1]*inv[i]) % mod)
    return fact, fact_inv

def comb(n, r, mod=10**9+7):
  if (r < 0) or (n < r):
      return 0
  r = min(r, n - r)
  return fact[n] * fact_inv[r] * fact_inv[n-r] % mod

fact, fact_inv = make_array_for_comb(n*m,mod)

l = comb(n*m-2,k-2,mod)
ans = 0
for a in range(1,n+1):
  ans += a*m*(a-1)*m
  ans -= a*m*(n-a)*m
ans %= mod

for b in range(1,m+1):
  ans += b*n*(b-1)*n
  ans -= b*n*(m-b)*n
ans %= mod

print(ans*l%mod)

Measured memory_bytes: 27040
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

bool check(int h, int w, int y, int x, const vector<string>& g) {
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i];
		int ny = y + dy[i];

		if (nx < 0 || nx >= w || ny < 0 || ny >= h) {
			continue;
		} else if (g[ny][nx] == '#') {
			return true;
		}
	}

	return false;
}

bool solve(int h, int w, const vector<string>& g) {
	for (int i = 0; i < g.size(); i++) {
		for (int j = 0; j < g[i].size(); j++) {
			if (g[i][j] == '.') {
				continue;
			}
			
			if (!check(h, w, i, j, g)) {
				return false;
			}
		}
	}

	return true;
}

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

	int h, w;
	cin >> h >> w;

	vector<string> g(h);
	for (auto& v : g) {
		cin >> v;
	}

	cout << (solve(h, w, g) ? "Yes" : "No") << endl;
	return 0;
}


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

using namespace std;

int main() {
	int num;
	char blood[2];
	char row[1000];
	map<string, int> type;
	type.insert(make_pair("A", 0));
	type.insert(make_pair("B", 0));
	type.insert(make_pair("O", 0));
	type.insert(make_pair("AB", 0));
	while(cin>>row){
		if(cin.eof()) break;
		sscanf(row,"%d,%s", &num, &blood);
		type[blood]++;
	}
	cout<<type["A"]<<endl;
	cout<<type["B"]<<endl;
	cout<<type["AB"]<<endl;
	cout<<type["O"]<<endl;
	return 0;
}

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

int c[3][3];

int main() {
    for(int i=0; i<3; ++i){
        cin >> c[i][0] >> c[i][1] >> c[i][2];
        // cout << c[i][0] << c[i][1] << c[i][2] << endl;
    }
    
    bool isEnable = false;

    for(int a1=0; a1<=100; ++a1) {
        for(int a2=0; a2<=100; ++a2) {
            for(int a3=0; a3<=100; ++a3) {
                if ( (c[0][0] - a1 == c[1][0] - a2 && c[0][0] - a1 == c[2][0] - a3) 
                    && (c[0][1] - a1 == c[1][1] - a2 && c[0][1] - a1 == c[2][1] - a3) 
                    && (c[0][2] - a1 == c[1][2] - a2 && c[0][2] - a1 == c[2][2] - a3)) {
                        isEnable = true;
                }
            }
        }
    }

    if(isEnable) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int G[100][100] = {{0}};
int main() {
    int N, M;
    cin >> N >> M;
    //cout << N << endl;
    for(int i = 0; i < 100; i++) {
        for(int j = 0; j < 100; j++) {
            if (i == j) G[i][j] = 0;
            else G[i][j] = INF;
            
        }
    }
    vector<int> A(M), B(M), C(M);
    for(int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        //cout << a << ", " << b << ", " << c << endl;
        G[a][b] = G[b][a] = c;
        A[i] = a; B[i] = b; C[i] = c;
    }

    for(int k = 0; k < N; k++) {
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
/*
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cout << G[i][j] << ", ";
        }
        cout << endl;
    }
*/
    int ans = 0;
    for (int m = 0; m < M; m++) {
        bool flag = true;
        for(int s = 0; s < N; s++) {
            for (int t = 0; t < N; t++) {
                if (s == t) continue;
                if (G[s][A[m]] + G[B[m]][t] + C[m] == G[s][t] || G[s][B[m]] + G[A[m]][t] + C[m] == G[s][t]) {
                    flag = false;
                }
            }
        } 
        if (flag) {
            //cout << m << ": " << A[m] + 1 << ", " << B[m] + 1 << endl;
            ans++;
        }
    }
    
    cout << ans << endl;

    return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}

int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}
void read_cr() {
    fgets(_buf, 256, stdin);
}

ll solve(int N, vi& a) {
    ll ans = 0;
    rep(i,N) ans += a[i]-1;
    return ans;
}

int main() {
    vi a;
    int N = loadvec(a);
    cout << solve(N,a) << endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void){
    

    char N[101];
    int S,i;

    scanf("%d",&S);
    scanf("%s",N);

    if(S % 2 != 0){
        printf("No\n");
        return 0;
    }

    for(i = 0;i < S/2;i++){
        if(N[i] != N[i+S/2]){
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");
    return 0;
}

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

struct node {
	int key;
	int par;
};

int n;
struct node A[10000];

void unite(int x, int y) {
	int xb = x, yb = y;
	for (int i = 0;i < n;i++) {
		if (A[i].key == x) {

			while (true) {
				if (xb == A[xb].par) {
					break;
				}
				xb = A[xb].par;
			}

		}
		if (A[i].key == y) {

			while (true) {
				if (yb == A[yb].par) {
					break;
				}
				yb = A[yb].par;
			}

		}

	}
	A[yb].par = A[xb].par;
}
void same(int x,int y) {
	int xb=x, yb=y;
	for (int i = 0;i < n;i++) {
		if (A[i].key == x){
			
			while (true) {
				if (xb == A[xb].par) {
					break;
				}
				xb = A[xb].par;
			}

		}
		if (A[i].key == y) {

			while (true) {
				if (yb == A[yb].par) {
					break;
				}
				yb = A[yb].par;
			}

		}

	}
	if (xb == yb) {
		cout << "1" << endl;
	}
	else {
		cout << "0" << endl;
	}
}
int main() {
	cin >> n;
	for (int i = 0;i < n;i++) {
		A[i].key = i;
		A[i].par = A[i].key;
	}
	int q;
	cin >> q;
	int ord,x,y;
	for (int i = 0;i < q;i++) {
		cin >> ord >> x >> y;
		if (ord == 0) {
			unite(x, y);
		}
		else {
			same(x, y);
		}
	}
	return 0;
}


Measured memory_bytes: 3164
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c for j in range(b)] for i in range(a)]
def list3d(a, b, c, d): return [[[d for k in range(c)] for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**19
MOD = 10**9 + 7
EPS = 10**-10

N = INT()
ans = 1 - N
print(ans)


Measured memory_bytes: 9508
#include <iostream>

using namespace std;

int main() {
    int n, a[100], ans = 0;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0, minj; i < n; ++i) {
        minj = i;
        for (int j = i; j < n; ++j) {
            if (a[minj] > a[j]) {
                minj = j;
            }
        }
        if (i != minj)
            ans++;
        swap(a[i], a[minj]);
    }
    for (int i = 0; i < n; ++i) {
        cout << a[i];
        if (i < n - 1)
            cout << " ";
    }
    cout << endl << ans << endl;

    return 0;
}


Measured memory_bytes: 3108
a,b,m = map(int,input().split())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
discount_list = [list(map(int,input().split())) for _ in range(m)]

min_price = min(a_list) + min(b_list)

for discount in discount_list:
    min_price = min(min_price,a_list[discount[0]-1]+b_list[discount[1]-1]-discount[2])

print(min_price)

Measured memory_bytes: 38484
import collections

N = int(raw_input())

l = []

for i in range(N):
    l.append(raw_input())

c = collections.Counter(l)

values, counts = zip(*c.most_common())

num_max = counts[0]
index_list = []

for i in range(len(counts)):
    if counts[i] == num_max:
        index_list.append(i)

ans_list = []
for item in index_list:
    ans_list.append(values[item])

for item in sorted(ans_list):
    print item


Measured memory_bytes: 64812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    rep(i, 0, 5){
        ll x;
        cin >> x;
        if(x == 0) cout << i+1 << endl;
    }
    return 0;
}

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

using namespace std;

const int mod = 1000000007;
const int K = 10005;
const int D = 105;

string k;
int memo[K][D][2], d, n;
bool vis[K][D][2];

int dp(int idx, int sum, bool p){
    if(idx == n){
        if(sum == 0) return 1;
        return 0;
    }

    if(vis[idx][sum][p]) return memo[idx][sum][p];
    vis[idx][sum][p] = true;

    int ans = 0, r;
    for(int i = 0; i < 10; i++){
        r = 0;
        if(p && k[idx] - '0' == i) r = dp(idx + 1, (sum + d - i) % d, true);
        else if(!p || k[idx] - '0' > i) r = dp(idx + 1, (sum + d - i) % d, false);

        ans += r;
        ans %= mod;

        //f(idx == 0) cout << i << " " << r << endl;
    }

    return memo[idx][sum][p] = ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> k >> d;
    n = k.size();
    
    cout << (dp(0, 0, true)  - 1 + mod) % mod << endl;
}

Measured memory_bytes: 11392
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
 
int q;
 
int main(){
    cin >> q;
    multiset<int> msa;
    for(int i = 0; i < q; i++){
        char query;
        cin >> query;
        if(query == '0'){
            int x;
            cin >> x;
            msa.insert(x);
            cout << msa.size() << endl;
        }else if(query == '1'){
            int x;
            cin >> x;
            cout << msa.count(x) << endl;
        }else if(query == '2'){
            int x;
            cin >> x;
            msa.erase(x);
        }else if(query == '3'){
            int L, R;
            cin >> L >> R;
            multiset<int>::iterator itr, itr1, itr2;
            itr1 = msa.lower_bound(L);
            itr2 = msa.upper_bound(R);
            for(itr = itr1; itr != itr2; itr++){
                cout << *itr << endl;
            }
        }
    }
    return 0;
}


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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	sc.Scan()
	var input     = strings.Split(sc.Text(), " ")
	var min, _    = strconv.Atoi(input[0])
	var max, _    = strconv.Atoi(input[1])
	var scope, _  = strconv.Atoi(input[2])
	
	if (max - min + 1 <= scope * 2) {
		for min <= max {
			fmt.Println(min)
			min++
		}
	} else {
		for i := 0; i < scope; i++ {
			fmt.Println(min + i)
		}
		for i := scope - 1; i >= 0; i-- {
			fmt.Println(max - i)
		}
	}
	
}

Measured memory_bytes: 640
import sys
a,b,c,d,e,f=map(int,input().split())

if a>b:
    a, b = b, a

ans1 = a*100
ans2 = 0

for _a in range(f//(a*100) + 1):
    for _b in range((f - _a*100)//(b*100) + 1):
        for _c in range((f - _a*100 - _b*100)//c + 1):
            for _d in range((f - _a*100 - _b*100 - _c * c)//d + 1):
                if a*100*_a+b*100*_b+c*_c+d*_d == 0:
                    continue                
                if a*100*_a+b*100*_b+c*_c+d*_d > f:
                    continue  
                    
                if (c*_c+d*_d)/(a*100*_a+b*100*_b+c*_c+d*_d) == e/(100+e):
                    print(a*100*_a+b*100*_b+c*_c+d*_d, c*_c+d*_d)
                    sys.exit(0)
                elif (c*_c+d*_d)/(a*100*_a+b*100*_b+c*_c+d*_d) > e/(100+e):
                    continue
                else:
                    if ans2/ans1 < (c*_c+d*_d)/(a*100*_a+b*100*_b+c*_c+d*_d):
                        ans1 = a*100*_a+b*100*_b+c*_c+d*_d
                        ans2 = c*_c+d*_d
else:
    print(ans1, ans2)


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

using namespace std;

typedef long long ll;
typedef pair<int,int> p;


int main()
{
  int n;
  cin >> n;
  int x = n * 800;
  int y = (n / 15) * 200;
  cout << x - y << endl;

  return 0;
}


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

int main() {
  int n, x, l, d = 0, c = 1;
  cin >> n >> x;
  REP(i, n) {
    cin >> l;
    d += l;
    if (d <= x) ++c;
    else break;
  }
  cout << c << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

signed main(){
    int N; cin >> N;
    int total = 0, longest = -1;
    rep(i,N){
        int L; cin >> L;
        total += L;
        longest = max(longest, L);
    }
    cout << (longest < total - longest ? "Yes" : "No") << endl;
}

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

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

    long long m=0,a=0,r=0,c=0,h=0;

    rep(i,n){
        string s;
        cin >> s;
        if(s[0]=='M') m++;
        if(s[0]=='A') a++;
        if(s[0]=='R') r++;
        if(s[0]=='C') c++;
        if(s[0]=='H') h++;
    }

    long long ans=0;
    ans = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h;

    cout << ans << endl;
}

Measured memory_bytes: 256
#B

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr



n = int(input())

g = factorization(n)

#print(g)
f = []
for x in g:
    for y in range(1,x[1]+1):
        f.append(x[0])

#print(f)
f.sort()
#print(f)

ans = False


l = len(f)
dex = 0
a = f[0]
while l > 2 and dex < len(f)-1:
    if a * f[dex+1] < 10:
        dex += 1
        a *= f[dex]
        l -= 1
    else:
        break

b_dex = dex+1
b = 1
while b_dex < len(f):
    b *= f[b_dex]
    b_dex += 1

#print(a,b)
if a < 10 and b < 10:
        ans = True

if ans:
    print('Yes')
else:
    print('No')


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

int main() {
  string n;
    cin >> n;
    
  if ((n[0]==n[1] && n[1]==n[2]) || (n[1]==n[2] && n[2]==n[3]) ) { cout << "Yes" << endl;
                                     }
  else { cout << "No" << endl;
       }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int S, h, m, s;

  scanf("%d", &S);
  h=S/3600;
  m=S%3600 / 60;
  s=S%3600 % 60;

  printf("%d:%d:%d\n", h, m, s);

  return 0;
}

Measured memory_bytes: 1796
import sys
import math
from collections import deque
import copy

INF = 10 ** 9 + 7
N, W = map(int, input().split())
weight = []
value = []
for i in range(N):
    tempW, tempV = map(int, input().split())
    weight.append(tempW)
    value.append(tempV)

dp = [[INF for _ in range(N * 1000 + 1)] for _ in range(N + 1)]
dp[0][0] = 0

for i in range(1, N + 1):
    for l in range(N * 1000 + 1):
        if l - value[i - 1] >= 0:
            dp[i][l] = min(dp[i - 1][l], dp[i - 1][l - value[i - 1]] + weight[i - 1])
        else:
            dp[i][l] = dp[i - 1][l]
for i in range(N * 1000 + 1):
    if dp[N][i] <= W:
        ans = i
print(ans)


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

#define ll long long
#define pb push_back

const int maxn = 4e2 + 20;
const int maxm = 1e5 + 20;

bitset<maxn> adj[maxn] , tmp;

int x[maxm] , y[maxm];

bool has[maxn];

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

	int n , m;
	cin >> n >> m;

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

	memset(has , 1 , sizeof has);

	for(int i = 0; i < n; i++)
		for(int j = m - 1; j >= 0; j--)
		{
			adj[i][i] = 1;
			if(adj[i][x[j]] && adj[i][y[j]])
			{
				has[i] = 0;
				break;
			}

			adj[i][x[j]] = adj[i][y[j]] = adj[i][x[j]] | adj[i][y[j]];
		}

	int res = 0;

	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(has[i] && has[j])
			{
				tmp = adj[i]&adj[j];

				res += !tmp.any();
			}

	cout << res << endl;
}





Measured memory_bytes: 1024
S = int(input())


def add(a, b, BIGMOD):
    return (a + b) % BIGMOD


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10 ** 9 + 7  # 出力の制限
Nn = 10 ** 6
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, Nn + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

Sum = 0
MOD = 10 ** 9 + 7

for i in range(1, S // 3 + 1):
    if 3 * i <= S:
        Sum = add(Sum, cmb(S - 3 * i + (i - 1), i - 1, MOD), MOD)
print(Sum)

Measured memory_bytes: 231084
from collections import deque
def main():
    n = int(input())
    S1 = deque(list(input()))
    S2 = deque(list(input()))
    mod = 1000000007
    A = []
    while S1:
        s1 = S1.popleft()
        s2 = S2.popleft()
        if s1 == s2:
            A.append(0)
        else:
            S1.popleft()
            S2.popleft()
            A.append(1)
    if A[0] == 0:
        ans = 3
    else:
        ans = 6
    for i in range(1, len(A)):
        if A[i] == 0:
            if A[i - 1] == 0:
                ans = ans * 2 % mod
            else:
                pass
        else:
            if A[i - 1] == 0:
                ans = ans * 2 % mod
            else:
                ans = ans * 3 % mod
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
using namespace std;
int x[55];
long long dp[55][55][2555];
int main( void )
{
  ios::sync_with_stdio(false);
  int N, A;
  cin >> N >> A;
  for( int i=0; i<N; i++ ){
    cin >> x[i];
  }
  int c = 0;
  dp[0][0][0] = 1;
  long long ret = 0;
  for( int i=1; i<=N; i++ ){
    for( int j=0; j<i; j++ ){
      for( int k=0; k<=2500; k++ ){
        dp[i][j][k]          += dp[i-1][j][k];
        dp[i][j+1][k+x[i-1]] += dp[i-1][j][k];
      }
    }
  }
  for( int i=1; i<=N; i++ ){
    ret += dp[N][i][A*i];
  }
  cout << ret << endl;
}

Measured memory_bytes: 26880
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vi vector<int>



int factorial(int n){
  if (n==1){
    return 1;
  }
  else {
    return n*factorial(n-1);
  }
}






int main(){


  int n;
  cin>>n;
  
  vector<pair<int,int>> data(n,pair<int,int>());
  
  rep(i,n){
    int x,y;
    cin>>x>>y;
    data.at(i).first=x;
    data.at(i).second=y;
  }
  
  vi vec(0);
  
  rep(i,n){
    vec.push_back(i);
  }
  
  
  double answer=0;
  
  do{
    double tmp;
    for (int i=0;i<n-1;i++){
      double xx=pow(data.at(vec.at(i+1)).first-data.at(vec.at(i)).first,2);
      double yy=pow(data.at(vec.at(i+1)).second-data.at(vec.at(i)).second,2);
      tmp+=sqrt(xx+yy);
    }
    answer+=tmp;
  }while(next_permutation(vec.begin(),vec.end()));
  
  
  answer=answer/factorial(n);
  
  
  cout<<fixed<<setprecision(12);
  cout<<answer<<endl;
       

  
}



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

using namespace std;

int n, m;
int a[200005];
int cnt[200005];
map<int, int> mp;

int main(void)
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cnt[a[i]]++;
	
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < cnt[i]; j++){
			if(i-j > 0) mp[i-j]++;
		}
	}
	
	int x, y;
	for(int i = 1; i <= m; i++){
		cin >> x >> y;
		int t = a[x]-cnt[a[x]]+1;
		if(t > 0){
			mp[t]--;
			if(mp[t] == 0) mp.erase(t);
		}
		cnt[a[x]]--;
		
		a[x] = y, cnt[a[x]]++;
		t = a[x]-cnt[a[x]]+1;
		if(t > 0) mp[t]++;
		cout << n - (int)mp.size() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <bitset>

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

using namespace std;

vector<int64_t> A = { 2, 1 };

int main() {
	int N;
	scanf("%d", &N);
	for (int i = 2; i < N + 1; i++) {
		A.push_back(A[i - 1] + A[i - 2]);
	}
	printf("%lld\n", A[N]);
}

Measured memory_bytes: 3764
/*2019/08/25 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
int llasc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
int lldesc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
/*
int asc_t(const void *a,const void *b){return ((struct_t*)a)->member - ((struct_t*)b)->member;}
int desc_t(const void *a,const void *b){return ((struct_t*)b)->member - ((struct_t*)a)->member;}
*/

int main(){
    int n;
    scanf("%d",&n);
    printf("%d\n",n*n*n);

    return 0;
}

Measured memory_bytes: 128
#include "iostream"
using namespace std;

int main()
{
	double r;
	cin >> r;

	double are;
	double circ;
	are = r*r*3.141592653589;
	circ = 2 * r*3.141592653589;

	cout << fixed << are <<" " <<fixed << circ << endl;

	//printf("%f %f\n",are,circ);

	return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int q;
    cin>>q;
    priority_queue<ll> left;
    priority_queue<ll,vector<ll>,greater<ll>> right;
    ll left_sum=0,right_sum=0;
    ll b_sum=0;
    while(q--) {
        int query;
        cin>>query;
        if(query==1) {
            ll a,b;
            cin>>a>>b;
            a*=-1;
            b_sum+=(ll)b;
            
            if(sz(right)==0 && sz(left)==0) {
                right.push(a);
                right_sum+=a;
                continue;
            }
               
            if(a>=right.top()) {
                right.push(a);
                right_sum+=a;
            }
            else {
                left.push(a);
                left_sum+=a;
            }
            
            if(sz(left)<sz(right) && (sz(left)+sz(right))%2==0) {
                ll x=right.top(); right.pop();
                right_sum-=x;
                left.push(x);
                left_sum+=x;
            }
            
            if(sz(left)>sz(right)) {
                ll x=left.top(); left.pop();
                left_sum-=x;
                right.push(x);
                right_sum+=x;
            }
            
        }
        else {
            ll ans=b_sum+right_sum-left_sum;
            if((sz(right)+sz(left))%2==1) ans+=(-right.top());
            cout<<-right.top()<<" "<<ans<<endl;
            //cout<<left_sum<<" "<<right_sum<<endl;
        }
    }
}


Measured memory_bytes: 3828
// 解説参照

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

using ll = long long;

int N, M;
int P[100000], Y[100000];
vector<int> yd[100001];

int main() {
  cin >> N >> M;
  REP(i, M) {
    cin >> P[i] >> Y[i];
    yd[P[i]].push_back(Y[i]);
  }
  REP(i, N)
    sort(yd[i + 1].begin(), yd[i + 1].end());
  REP(i, M)
    printf("%012lld\n", ll(P[i]) * 1000000 + int(lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin()) + 1);
}


Measured memory_bytes: 7808
#include<stdio.h>
int main(void)
{
	int a,b,c,x;
	
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	if(b-a==c-b) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	
	return 0;
}
	
	

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


int main() {
  ll n,x=100,flag=0;
  cin>>n;
  
  while(x<n){
    x+=x/100;
    flag++;
  }
      
  cout<<flag<<endl;   
  
}

Measured memory_bytes: 3636
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long 
#define sort(v) sort(v.begin(),v.end()) 
#define pb push_back
vector<ll>sv;
ll ar[1000000+9]={0}; 
void seiv() { 
ll n=1000000,i,j; 
ar[1]=1; 
for(i=4;i<=n;i+=2)ar[i]=1; 
for(i=3;i<=n;i+=2) 
{ if(ar[i]==0) 
{ for(j=i*i;j<=n;j+=i*2)ar[j]=1; }
 } 
for(i=2;i<=n;i++){
        if(ar[i]==0)sv.pb(i);
}
}
int main()
{
       seiv();
  map<ll,ll>m;
  ll a,b,c,d,e,i,j,k,l;
  vector<ll>v;
  cin>>a;k=1;
  for(i=1;i<=a;i++)
  {
  cin>>b;v.pb(b);
                
             k=max(k,m[b]);
  if(i==1)c=__gcd(b,b);
 else c=__gcd(c,b);
  }
    if(c!=1){
cout<<"not coprime\n";return 0;}
 else{c=0;d=0;
 
  m.clear();c=0;
 for(i=0;i<v.size();i++) 
{
 b=v[i];
 for(j=0;j<sv.size();j++)
 {
    if(sv[j]>b) break;
    if(ar[b]==0){m[b]++;
            c=max(c,m[b]);                     b=0;
                   break;}
  if(b%sv[j]==0){
            m[sv[j]]++;
          c=max(c,m[sv[j]]);
      while(b%sv[j]==0){b/=sv[j];}
                } 
 }
    if(b>1){m[b]++;m[1]=0;
                c=max(c,m[b]);
          cout<<b<<endl;
          }
}   
 }
if(c>1)cout<<"setwise coprime\n";  
else cout<<"pairwise coprime\n";
//cout<<m[7]<<" "<<c;
}

Measured memory_bytes: 81884