akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)


int main() {
    ll n;
    cin >> n;
    vector<ll> vec(n);
    rep(i,n){
        cin >> vec.at(i);
    }


    vector<ll> dp(n,INF);

    rep(i,n){
        if(i==0){
            dp.at(i) = 0;
            continue;
        }
        if(i==1){
            dp.at(i) = dp.at(i-1) + abs(vec.at(i) - vec.at(i-1));
            continue;
        }

        chmin(dp.at(i), dp.at(i-1) + abs(vec.at(i) - vec.at(i-1)));
        chmin(dp.at(i), dp.at(i-2) + abs(vec.at(i) - vec.at(i-2)));
        
    }

    cout << dp.at(n-1) << endl;
    
}


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
using namespace std;
int main () {
    int a;
    cin >> a;
    cout << "ABC" << a <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define Maxn 1000000 + 7
using namespace std;
int n,x;
long long a,b;
int main()
{
    cin>>a>>b;
    if( (a * b) % 2 == 0)
        cout<<"Even"<<endl;
    else
        cout<<"Odd"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <map>
#include <deque>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define pi(a,b) pair<ll,ll>(a,b)
#define pis(a,b) pair<ll,string>(a,b)
#define pc(c,d) pair<ll,pair<ll,string>>(c,d)
#define pp(a,b,c) pair<pair<ll,ll>,ll>(pi(a,b),c)
#define ps(a,b,c) pair<string,pair<ll,ll>>(a,pi(b,c))
using namespace std;

typedef long long ll;
typedef set<ll>::iterator sit;
typedef vector <ll> ::iterator vit;
typedef map<ll,ll>::iterator mit;
typedef multimap<ll,ll>::iterator mmit;

class Task
{
public:
    void solve(istream& in,ostream& out)
    {
       ll k,s;
       in>>k>>s;
       ll sum=0;
       sum+=c(2+s);
     //  out <<sum<<endl;

       if(s-2*k-2>=0)
       {
          int e=s-k-k;
          sum+=3*c(e);
    //      out <<sum<<endl;
       }

       if(s-k-1>=0)
       {
          int d=s-k+1;
          sum-=3*c(d);
    //      out <<sum<<endl;
       }

       out<<sum<<endl;
    }

    ll c(int n)
    {
       return n*(n-1)/2;
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	Task solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in,out);
	out.flush();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		int sum = 0;
		for(int i = 0; i < n; i++){
		    int a = sc.nextInt();
		    int day = 1;
		    while(day <= d){
		        sum++;
		        day += a;
		    }
		}
		
		// 計算
		int result = x + sum;
		
		// 出力
		System.out.println(result);
		
	}
}




Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
    	int N, K;
        
        void solve(InputReader in, PrintWriter out) {
        	N = in.nextInt();
        	K = in.nextInt();
        	
        	out.println(K > 1 ? N - K : 0);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }

        long nextLong() { return Long.parseLong(next()); }

        long[] nextLongArray(int n) {
        	long[] arr = new long[n];
        	for (int i = 0; i < n; ++i) {
        		arr[i] = nextLong();
        	}
        	return arr;
        }
    }
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 1
#define INF (1LL<<50)
#define MOD 1000000007
#define WHITE 0
#define BLACK 1

	/* dp[i][j] j 点の座標 i 0 その点が白で塗られている場合、 1 黒で塗られている場合*/
lli dp[2][100100]={0};
lli flag[100100]={0};
map<lli,vector<lli>> m;
lli n;

void calc(lli pos){
	if(flag[pos])return;

	flag[pos]=1;
	lli cnt=0;
	dp[WHITE][pos]=1;
	dp[BLACK][pos]=1;
	for(auto e:m[pos]){
		if(flag[e])continue;
		calc(e);
		cnt++;
		dp[WHITE][pos] *= (dp[WHITE][e] + dp[BLACK][e]);
		dp[WHITE][pos] %= MOD;
		dp[BLACK][pos] *= (dp[WHITE][e]);
		dp[BLACK][pos] %= MOD;
	}
}

signed main(){

	cin>>n;

	REP(i,0,n-1){
		lli x,y;
		cin>>x>>y;
		x--,y--;
		m[x].push_back(y);
		m[y].push_back(x);
	}
	calc(0);
	cout<<(dp[BLACK][0]+dp[WHITE][0])%MOD<<endl;

	return 0;
}


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

using namespace std;

const int N = 500017;

int n;
pair<int, int> a[N];

bool read() {
    if (!(cin >> n))
        return false;

    for (int i = 0; i < n; ++i)
        cin >> a[i].first >> a[i].second;

    return true;
}

void solve() {
    sort(a, a + n,
        [](const pair<int, int>& a, const pair<int, int>& b) {
            return a.second < b.second;
        }
    );

    int r = 0;

    for (int i = 0; i < n; ++i)
        if ((r += a[i].first) > a[i].second) {
            cout << "No\n";
            return ;
        }

    cout << "Yes\n";
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



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

int main(){
	int n, a, b, c, x;
	while(cin>>n>>a>>b>>c>>x,n||a||b||c||x){
		int cnt = 0;
		for(int i = 0; i < n; i++){
			int y;
			cin >> y;
			if(x == y && i == 0) continue;
			while(true){
				cnt++;
				if(cnt > 10000) break;
				x = (a*x+b)%c;
				if(x == y) break;
			}
			if(cnt > 10000){
				for(int j = i+1; j < n; j++) cin >> y;
				cnt = -1;
				break;
			}
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int a=0,b=0;
    for(int i=0;i<s.size();i++)
        if(s[i]=='0') a++;
    else b++;
    cout<<min(a,b)*2<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int maxn=105;
const int maxm=5e2+5;
const int maxq=55;
const int INF=0x3f3f3f3f;
char s[maxn][maxn];
int row[maxn];
int col[maxn];
int main()
{
    int h,w;
    while(~scanf("%d%d",&h,&w))
    {
        memset(row,0,sizeof(row));
        memset(col,0,sizeof(col));
        for(int i=1;i<=h;i++)
        {
            scanf("%s",s[i]+1);
        }
        for(int i=1;i<=h;i++)
        {
            int f=1;
            for(int j=1;j<=w&&f;j++)
            {
                if(s[i][j]=='#') f=0;
            }
            if(f) row[i]=1;
        }
        for(int i=1;i<=w;i++)
        {
            int f=1;
            for(int j=1;j<=h&&f;j++)
            {
                if(s[j][i]=='#') f=0;
            }
            if(f) col[i]=1;
        }
        for(int i=1;i<=h;i++)
        {
            if(row[i]) continue;
            for(int j=1;j<=w;j++)
            {
                if(!col[j]) printf("%c",s[i][j]);
            }
            puts("");
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
using namespace std;

int main(){
  int n,k;
  std::cin >> n>>k;
  int h[n];
  for (int i = 0; i < n; i++) {
    std::cin >> h[i];
  }

  sort(h,h+n,greater<int>());
  int ans = 100000000000;
  for (int i = 0; i <= n-k; i++) {
    ans = min(h[i]-h[i + k -1],ans);
  }

  std::cout << ans << '\n';
  return 0;
}


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

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

    int N;
    cin >> N;
    vector<int> A, B, C;
    A.push_back(0);
    B.push_back(0);
    C.push_back(0);
    for (int i = 1; i <= N; i++) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    for (int i = 1; i <= N; i++) {
        int a;
        cin >> a;
        B.push_back(a);
    }
    for (int i = 1; i <= N - 1; i++) {
        int a;
        cin >> a;
        C.push_back(a);
    }
    int ret = 0;
    for (int i = 1; i <= N; i++) {
        ret += B[A[i]];
        if (i > 1 && A[i - 1] == A[i] - 1) {
            ret += C[A[i - 1]];
        }
    }
    cout << ret << 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;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << fixed << setprecision(12) << (w/2)*h;
    cout << " " << (x == w/2 && y == h/2 ? "1" : "0") << endl;
    return 0;
}

Measured memory_bytes: 256
package main
/*
N A B
*/
import (
        "bufio"
        "fmt"
        // "log"
        "os"
        "strconv"
        "strings"
)
/**
train A -> B : X  
bus B -> C : Y
**/

func main() {
        stdin := bufio.NewScanner(os.Stdin)
        stdin.Scan()
        line := strings.Split(stdin.Text(), " ")
        trainPay, _ := strconv.Atoi(line[0])
        busPay, _ := strconv.Atoi(line[1])
	fmt.Print(trainPay+(busPay/2))
}


Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int H, W, M; cin >> H >> W >> M;
    set<pair<int, int>> items;
    vector<long long> sum_h(W), sum_w(H); 
    for (int i = 0; i < M; i++) {
        int h, w; cin >> h >> w;
        h--; w--;
        sum_h[w]++; sum_w[h]++;
        items.insert(make_pair(h, w));
    }

    set<int> ans_w, ans_h;
    long long max_w = 0, max_h = 0;
    for (int w = 0; w < W; w++) {
        if (max_h < sum_h[w]) {
            max_h = max(max_h, sum_h[w]);
            ans_w.clear();
            ans_w.insert(w);
        }
        else if (max_h == sum_h[w]) {
            ans_w.insert(w);
        }
    }

    for (int h = 0; h < H; h++) {
        if (max_w < sum_w[h]) {
            max_w = max(max_w, sum_w[h]);
            ans_h.clear();
            ans_h.insert(h);
        }
        else if (max_w == sum_w[h]) {
            ans_h.insert(h);
        }
    }

    long long siz = (long long)ans_w.size() * (long long)ans_h.size();
    if (siz > M) {
        cout << max_w + max_h << '\n';
    }
    else {
        for (int w : ans_w) {
            for (int h : ans_h) {
                if (items.find(make_pair(h, w)) == items.end()) {
                    cout << max_w + max_h << '\n';
                    return;
                }
            }
        }
        cout << max_w + max_h - 1 << '\n';
    }
}

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

    solve();

    return 0;
}

Measured memory_bytes: 50096
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef long double ld;
const long double pi = 3.14159265358979323846264338327950288;
int main() {
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
		cout << "YES" << endl;
	}
	else
		cout << "NO\n";
	cin >> a;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long 
#define P pair<long long ,long long>
using namespace std;

int main(){
  int h1, h2, m1, m2 ,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int ans = 0;
  

  if(h1 < h2){
    ans += 60 - m1 + m2;
    ans += 60*(h2 - h1 -1);
  }else {
    ans += (m2 - m1);
  }
  ans -= k;
  cout << ans << endl;
}


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

int f(int a,int b){
  if(to_string(a).size()>to_string(b).size())	return to_string(a).size();
  return to_string(b).size();
}

int main() {
  long int n;
  cin >> n;
  
  int ans=f(1,n);
  for(long int i=2;i*i<=n;i++){
    if(n%i==0){
      if(ans>f(i,n/i)){
      ans=f(i,n/i);
    }
    }
  }
   cout << ans;   
}

Measured memory_bytes: 3652
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val s = sc.next().map(_ == 'o')
  val c = Array.fill(4, n)(false)
  for (i <- 0 to 3) {
    val a0 = (i & 1) == 1
    val a1 = ((i >> 1) & 1) == 1
    c(i)(0) = a0
    c(i)(1) = a1
    for (j <- 2 until n) {
      c(i)(j) = c(i)(j-2) ^ c(i)(j-1) ^ s(j-1)
    }
  }
  c.find(a => !(a(n-1) ^ a(0) ^ a(1) ^ s(0) || a(n-2) ^ a(n-1) ^ a(0) ^ s(n-1))) match {
    case Some(a) => println(a.map(if (_) 'S' else 'W').mkString)
    case None => println(-1)
  }
}

Measured memory_bytes: 56084
unittest
{
	assert( [ "2017/01/07" ].parse.expand.solve == "2018/01/07" );
	assert( [ "2017/01/31" ].parse.expand.solve == "2018/01/31" );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.strip;
	return tuple( s );
}

auto solve( string s )
{
	return replace( s, "2017", "2018" );
}


Measured memory_bytes: 256
N=int(input())
H=list(map(int,input().split()))
ANS = 'Yes'
A=H[0] - 1
M=A
for i in range(1,N):
  #print('H[i-1]:{}, H[i]:{}, M:{}'.format(A, H[i], M))
  if A > H[i] or M > H[i]:
    ANS = 'No'
    #print('H[i-1]:{}, H[i]:{}, M:{}'.format(A, H[i], M))
    break
  else:
    if i != N-1:
    	M=max(M, A,H[i]-1) 
    A=H[i]-1
    
print(ANS)

Measured memory_bytes: 14396
#include <stdio.h>

int main() {
  char s[3][101];
  scanf("%s %s %s", s[0], s[1], s[2]);

  char  t=s[0][0], ans, a=1, b=0, c=0;
  while (1) {
    if (t=='a') {
      t=s[0][a++];
      ans='A';
    } else if (t=='b') {
      t=s[1][b++];
      ans='B';
    } else {
      t=s[2][c++];
      ans='C';
    }

    if (t=='\0') {
      printf("%c\n", ans);
      return 0;
    }
  }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n], boz[n];
	for(int i=0; i<n; i++){
		cin>>a[i];
		if(i==0)
			boz[0]=0;
		if(i==1)
			boz[1]=abs(a[1]-a[0]);
		if(i>1){
			boz[i]=min(boz[i-2]+abs(a[i]-a[i-2]),boz[i-1]+abs(a[i]-a[i-1]));
		}
	}
	cout<<boz[n-1]<<endl;
}


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

using namespace std;

typedef long long ll;

int main() {
	
	ll a,b;
	cin>>a>>b;
	
	ll resp = 0;
	resp += a;
	
	ll lo = min(b, a-b);
	ll hi = max(b, a-b);
	
	while(true){
		
		ll cant = hi / lo;
		ll sob = hi % lo;
		
		resp += 2*lo*cant;
		
		if(sob == 0)break;
		else{
			hi = lo;
			lo = sob;
		}
	}
	
	cout<<resp-lo<<'\n';
		
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
using namespace std;
int a[8000000] = {};
int main() {
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int  n, m, b, c, d, k, sa, h, w, left = 1, right = 0;
	long long int sc, sr, num2, no[1005][1005] = {}, res = 999999999, count = 0, now = 0, mi = 9999999999;

	string str, t;

	cin >> m>>n;
	while (1) {
		res++;
		count = n;
		now = m;
		if (m == 0&&n==0) { return 0; }
		while (1) {
			if (count == 0 && a[now] <= res) {
				cout << now << endl;
				
				break;
			}
			if (a[now] <= res) {
				for (int i = 2; i * now < 7400000; i++) {
					a[i * now] = res+1;
				}
				count--;
			}
			now++;
		}
		cin >> m >> n;
	}
	
}



Measured memory_bytes: 31964
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,m) for(int j=0;j<m;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef vector< vector < int> > vee;
typedef vector<pair<ll,ll> > vepa;
typedef set<char>se;
typedef map<ll,ll> mpp;
const ll N=1e5+5;
ll arr[N],A[N],cnt[N];
bool visited[N];
bool f,ff;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
   int n;
   cin>>n;
    //cout << fixed << showpoint;
     //cout << setprecision(2);
    cout<< n*3.14*2.;
go;
}


Measured memory_bytes: 3804
n=int(input())
s=[input() for _ in range(n)]
s.append('1')
m=int(input())
t=[input() for _ in range(m)]
t.append('1')
res = -float('inf')
for l in s:
    tmp = s.count(l)-t.count(l)
    res = max(res,tmp)
print(res)


Measured memory_bytes: 3060
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int[][] a=new int[3][3];
  		for(int c=0;c<3;c++){
    		a[c][0]=sc.nextInt();
          	a[c][1]=sc.nextInt();
          	a[c][2]=sc.nextInt();
    	}
  
        int n=sc.nextInt();
		
  		int[] b=new int[n];
		for(int d=0;d<n;d++){
    		b[d]=sc.nextInt();
           for(int c=0;c<3;c++){
           		if(a[c][0]==b[d]){
                	a[c][0]=0;
                }else if(a[c][1]==b[d]){
                	a[c][1]=0;
                }else if(a[c][2]==b[d]){
                	a[c][2]=0;
                }
           }
    	}
  		int ans=0;
  
  for(int c=0;c<3;c++){  
 	if(a[c][0]==0&&a[c][1]==0&&a[c][2]==0){
    		ans=1;
    	}
  }
  for(int c=0;c<3;c++){  
 	if(a[0][c]==0&&a[1][c]==0&&a[2][c]==0){
    		ans=1;
    	}
  }
  
  if(a[0][0]==0&&a[1][1]==0&&a[2][2]==0){
    		ans=1;
    	}
   if(a[0][2]==0&&a[1][1]==0&&a[2][0]==0){
    		ans=1;
    	}
	if(ans==1){
    	System.out.println("Yes");
    }else{
    System.out.println("No");
    }
    }
}



Measured memory_bytes: 21716
#問題文
#N個の整数の列A1,…,ANが与えられます
#これらの逆数の総和の逆数 を求めてください。
#
#制約
#1≤N≤100
#1≤Ai≤1000

N = int(input())
A =list(map(int,input().split()))

ans = 0
for i in range(N):
  ans += 1/A[i]
ans = 1/ans
print(ans)


Measured memory_bytes: 2940
#include<iostream>

using namespace std;

int main() {
	long long int a, b, k;
	cin >> a >> b >> k;
	if (a>=k) {
		cout << a - k << " " << b;
		return 0;
	}
	else if(b>=k-a) {
		cout << 0 << " " << b - (k - a);
	}
	else {
		cout << 0 << " " << 0;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int r;
    cin >> r;
    cout << fixed << setprecision(10) << (double)(r * 2 * 3.14159) << endl;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b) a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b) a=b;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if (s.substr(0,4) == "YAKI") cout << "Yes" << '\n';
  else cout << "No" << '\n';
}


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

using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define all(v) v.begin(),v.end()
#define v vector
#define vi vector<int>
#define vi2 vector<vi>
#define vl vector<long long>
#define vl2 vector<vl>

template <class T> T maxAny(T a, T b){
    if(a > b) return a;
    else return b;
}

template <class T> T minAny(T a, T b){
    if(a > b) return b;
    else return a;
}

int main(){
    int n;
    cin >> n;
    vl a(n+1,0), b(n+1,0);
    rep1(i,n) {
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    sort(all(b));
    long long mida = a[(n+1)/2], midb = b[(n+1)/2];
    if(n % 2 == 1){
        cout << (long long)(midb - mida + 1) << endl;
    }else{
        long long mida1 = a[n/2+1], midb1 = b[n/2+1];
        cout << (long long)((-(double)(mida1 + mida)/2 + (double)(midb1 + midb)/2)/0.5 + 1) << endl;
    }
}

Measured memory_bytes: 6360
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

void dfs(int node, std::vector<std::vector<int>>& v, std::vector<int>& colors, int color) {
    colors[node] = color;
    for (int i=0; i<v[node].size(); i++) {
        if (node != v[node][i] and colors[v[node][i]] == 0) {
            dfs(v[node][i], v, colors, color);
        }
    }
} 

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n, m, q, s, t, color=1;
    std::cin >> n >> m;
    std::vector<std::vector<int>> v(n);
    std::vector<int> colors(n);
    for (int i=0; i<m; i++) {
        std::cin >> s >> t;
        v[s].push_back(t);
        v[t].push_back(s);
    }
    for (int i=0; i<n; i++) {
        if (colors[i] == 0) {
            dfs(i, v, colors, color++);
        }
    }
    std::cin >> q;
    for (int i=0; i<q; i++) {
        std::cin >> s >> t;
        if (colors[s] == colors[t] and colors[s] != 0) {
            std::cout << "yes\n";
        } else {
            std::cout << "no\n";
        }
    }

    return 0;
}


Measured memory_bytes: 14904
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 998244353
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

bool prime(ll n)
{
	if(n<=1)return false;
	if(n<=3)return true;
	if(n%2==0||n%3==0)return false;
	for(ll i=5;i*i<=n;i+=6)
	{
		if(n%i==0||n%(i+2)==0)return false;
	}
	return true;
}

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
		if(b&1)r=(r*a)%m;
		b = b>>1;
		a=(a*a)%m;
	}
	return r%m;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n,s; cin>>n>>s;
	vi arr(n);
	rep(i,0,n)cin>>arr[i];
	vi dp(s+1);
	ll ans = 0;
	//cout<<endl;
	//rep(i,0,s+1)cout<<i<<" ";
	//cout<<endl;
	rep(i,0,n)
	{
	    dp[0]++;
	    for(ll j=s;j>=arr[i];j--)
        {
            dp[j]=(dp[j]+dp[j-arr[i]])%mod;
        }
        //for(auto x:dp)cout<<x<<" ";
        //cout<<endl;
        ans = (ans+dp[s])%mod;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int[] cash = new int[n];
        int[][] exp = new int[n][m];
        int ans = Integer.MAX_VALUE;
        /**Input */
        for(int i = 0;i<n;i++){
            cash[i] = sc.nextInt();
            for(int j = 0;j < m;j++)
                exp[i][j] = sc.nextInt();
        }

        /**calc */
        for(int i = 1;i < 1<<n;i++){
            boolean jdg = true;
            int[] ar = new int[m];
            int sum = 0;
            for(int j = 0;j < n;j++){
                if((1&(i>>j))==1){
                    sum += cash[j];
                    for(int k = 0;k < m;k++)
                        ar[k] += exp[j][k];
                }
            }

            for(int j = 0;j < m;j++){
                if(ar[j] < x)
                    jdg = false;
            }
            if(jdg)
                ans = Math.min(ans,sum);
        }

        System.out.println(ans < Integer.MAX_VALUE? ans : -1);
    }
}

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

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define PB push_back
#define F first
#define S second
#define SZ(a) a.size()
#define MP(a,b) make_pair(a,b)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define NL << "\n"

#define mod 1000000007
#define pi 3.14159265359

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;
typedef pair<ll, ll> pll;
typedef pair<ll, string> pls;
typedef pair<string, ll> psl;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef double ld;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  
  string today;
  cin >> today;
  
  if(today == "Sunny"){
    cout << "Cloudy" NL;
  } else if (today == "Cloudy"){
    cout << "Rainy" NL;
  } else {
    cout << "Sunny" NL;
  }
  
  return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		(new Main()).execute();
	}
	public void execute() {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int ans = checkAnswer(N) ;
		System.out.println(ans);
	}

	public int getAnswer(int N) {
		int ans = 0 ;

		if(N/10 == 0) {//1桁のとき
			ans = N ;
		}else if(N/100 == 0) {//2桁のとき
			ans = 9 ;
		}else if(N/1000 == 0) {//3桁のとき
			ans = 9 + (N - 99);
		}else if(N/10000 == 0) {//4桁のとき
			ans = 9 + (1000 - 99);
		}else {//5桁のとき
			ans = 9 + (1000 - 99) + (N - 9999);
		}

		return ans ;
	}

	public int checkAnswer(int N) {
		int ans = 0 ;
		for(int i = 1 ; i <= N ;i ++) {
			if(i < 10 || (100 <= i &&  i <= 999)|| (10000 <= i &&  i <= 99999)) {
				ans ++ ;
			}
		}
		return ans ;
	}
}


Measured memory_bytes: 23892
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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

  int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K; cin>>K;

  int  ans = A[K-1];
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	int n;
	cin >> n;
	double a = 0;
	for (int i = 0; i < n; i++) {
		double x;
		cin >> x;
		a += 1 / x;
	}
	cout << setprecision(20);
	cout << 1 / a << endl;
	
	return 0;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
int main() {
  ll n;
  cin>>n;
  ll a=1;
  for(ll i=1;i*i<=n;i++)if(n%i==0)a=i;
  a=max(a,n/a);
  string s=to_string(a);
  cout<<s.size()<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define debug(x) cout << #x << " = " << x << endl;
#define debret(x) cout << #x << " = " << x << endl; return 0;

using namespace std;

int pushCount = 0;

void incrNtime(int n){
    pushCount += n;
}
void inversePush(void){
    pushCount += 1;
}


int main(void){

    int x,y;
    cin >> x >> y;
    // x != y

    
    if((x >= 0 && y >= 0) || (x <= 0 && y <= 0)){
        if(x > y){
            int diff = x-y;
            inversePush();
            incrNtime(diff);
            inversePush();
            if(x == 0 || y == 0) pushCount--;
        }else{ // x < y
            int diff = y-x;
            incrNtime(diff);
        }
        cout << pushCount << endl;
        return 0;
    }

    if(x <= 0 && y >= 0){

        if(abs(x) >= y){
            int diff = abs(x) - y;
            incrNtime(diff);
            inversePush();
            if(x == 0 || y == 0) pushCount--;
        }else{ // abs(x) < y
            int diff = y - abs(x);
            inversePush();
            incrNtime(diff);
            if(x == 0 || y == 0) pushCount--;
        }

        cout << pushCount << endl;
        return 0;
    }

    if(x >= 0 && y <= 0){

        if(x >= abs(y)){
            int diff = x - abs(y);
            inversePush();
            incrNtime(diff);
            if(x == 0 || y == 0) pushCount--;
        }else{ // x < abs(y)
            int diff = abs(y) - x;
            incrNtime(diff);
            inversePush();
            if(x == 0 || y == 0) pushCount--;
        }
        cout << pushCount << endl;
        return 0;
        
    }

    return 0;
}


Measured memory_bytes: 256
N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
count = 0
flag = True

for i in range(len(A)):
  if x - A[i] >= 0:
    x -= A[i]
    count += 1
  else:
    flag = False
    break
    
if x > 0 and flag:
  print(count-1)
else:
  print(count)

Measured memory_bytes: 9072
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    return a * b // gcd(a, b)
    
def main():
    N = int(input())
    T = []

    for i in range(N):
        T.append(int(input()))
    
    while len(T) > 1:
        T_tmp = []
        for i in range(1, len(T)):
            tmp = lcm(T[i-1], T[i])
            T_tmp.append(tmp)
        T = T_tmp
    
    print(T[0])
    
if __name__=="__main__":
    main()

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

int main (){
  int N;
  cin >> N;
  
  long double ans;
  
  vector<int> v(N);
  for (int i=0;i<N;i++){
    cin >> v[i];
  }
  
  sort(v.begin(),v.end());
  
  ans = v[0];
  
  for(int i=0;i<N-1;i++){
    ans += v[i+1];
    ans /= 2;
  }
  
  cout << fixed << setprecision(7);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e15;
const ll MOD = 1000000007;  // 1e9 + 7

ll dr[4] = { 1, -1, 0, 0 };
ll dc[4] = { 0, 0, 1, -1 };

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll h,w,k;
  cin >> h >> w >> k;
  ll r1,c1,r2,c2;
  cin >> r1 >> c1 >> r2 >> c2;
  --r1; --c1; --r2; --c2;
  vector<string> mp(h);
  rep(r,h) {
    cin >> mp[r];
  }

  // For Debug
  // rep(r,h) {
  //   cout << mp[r] << endl;
  // }

  // BFS
  vector<vector<ll>> d(h, vector<ll>(w, INF));
  queue<P> q;
  q.emplace(r1,c1);
  d[r1][c1] = 0;
  while (!q.empty()) {
    P p = q.front(); q.pop();
    ll r = p.first;
    ll c = p.second;

    if (p.first == r2 && p.second == c2) { // found
      cout << d[r2][c2] << endl;
      return 0;
    }
    // Visit 4-directions
    rep(i,4) {
      for (ll j = 1; j <= k; ++j) {
        ll nr = r + dr[i]*j;
        ll nc = c + dc[i]*j;
        if (nr < 0 || nr >= h || nc < 0 || nc >= w) { break; } // invalid
        // cout << "(r,c): " << r << "," << c << endl;
        // cout << "(nr,nc): " << nr << "," << nc << endl;
        // cout << "mp[nr][nc]: " << mp[nr][nc] << endl;
        if (mp[nr][nc] == '@') { break; } // reached to leaf
        if (d[nr][nc] <= d[r][c]) { break; } // (nr,nc) is small. We don't check further
        // Here, "d[nr][nc] == INF" or "d[nr][nc] == d[r][c]+1"
        if (d[nr][nc] == INF) { // not visited
          d[nr][nc] = d[r][c] + 1;
          q.emplace(nr,nc);
        }
      }
    }
  }

  // rep(r,h) {
  //   printvec(d[r]);
  // }

  // Here, we can not reach to (r2,c2)
  cout << -1 << endl;
}


Measured memory_bytes: 19788
import sys
from string import ascii_lowercase as AL

input = sys.stdin.readline


def main():
    s = input().rstrip()
    K = int(input())

    N = len(s)
    total = 0
    for al in AL:
        induces = []
        for i in range(N):
            if al == s[i]:
                induces.append(i)
        if not induces:
            continue
        match = [al]
        for i in range(1, 5):
            for idx in induces:
                if idx + i < N:
                    match.append(s[idx:idx + i + 1])
        match = set(match)
        match = sorted(match)
        if total + len(match) >= K:
            ans = match[K - 1 - total]
            break
        else:
            total += len(match)
    print(ans)


if __name__ == "__main__":
    main()


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

#define PI 3.141592653589

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

    double theta1 = 30 * h + 0.5 * m;
    double theta2 = 6 * m;
    printf("%.20f\n", sqrt(a * a + b * b - 2 * a * b * cos(abs(theta1 - theta2) * PI / 180)));
}

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

int main() {
   int E[6];
   int f1, f2, f3, f4;
   f1 = 0; f2 = 0; f3 = 0; f4 = 0;        //////////////// 追加
   int i;

   cin >> E[0] >> E[1];
   cin >> E[2] >> E[3];
   cin >> E[4] >> E[5];

   for ( i = 0; i < 6; i++) {
      if (E[i] == 1) {
         f1++;
      }
      else if (E[i] == 2) {
         f2++;
      }
      else if (E[i] == 3) {
         f3++;
      }
      else if (E[i] == 4) {
         f4++;
      }
   }

   // int flag = 0;
   if (f1 != 3 && f2 != 3 && f3 != 3 && f4 != 3) {
      cout << "YES" << endl;
   }
   else {
      cout << "NO" << endl;
      // flag = 1;
   }

   // if (f1 == 3 || f2 == 3 || f3 == 3 || f4 == 3 ) {
   //    if (flag!=1) {
   //       cout << "NO" << endl;
   //    }
   // }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#define CHARNUM 26

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

int ctoi(char c){
	int i=0;
	while(c!=c_set[i]&&i<CHARNUM){
		i++;
	}
	return i;
}

int main(){
	char c;
	int v[CHARNUM+1]={0};
	while((c=getchar())!=EOF){
		ungetc(c,stdin);
		while(1){
			c = tolower(getchar());
			if(c == '\n')break;
			v[ctoi(c)]++;
		}
	}

	for(int i=0;i<CHARNUM;i++){
		printf("%c : %d\n",c_set[i],v[i]);
	}
}

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

 
int main(){
  int K, S;
  cin >> K >> S;
  int i,j,k;
  int cnt = 0;
  for(i = 0; i <=K; i++){
    for(j = 0; j <= K; j++){
      if(S - i - j <= K && S - i - j >= 0) cnt++;
    }
  }

  cout << cnt << endl;
}



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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < (s.size()-1); i++) {
        if (s[i] == s[i+1]) {
            ans++;
            s[i+1] = char('1' - s[i] + '0');
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	slice := make([]int, 3*n)
	for i := 0; i < 3*n; i++ {
		slice[i] = nextInt()
	}

	sort.Sort(sort.Reverse(sort.IntSlice(slice)))
	// fmt.Println(slice)
	sum := 0

	for i := 0; i < n; i++ {
		// fmt.Println(slice[2*i+1])
		sum += slice[2*i+1]
	}

	fmt.Println(sum)
}


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

#define FAST_IO                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;

using namespace std;

using ll = long long;

const int MOD = 1e9 + 7;
const ll INF_LLONG = 1e18 + 9;
const int INF_INT = 1e9 + 9;

template<typename T>
unsigned int index_of_max(vector<T>& arr) {
	unsigned int idx = 0;
	for (int i = 0; i < arr.size(); ++i) {
		if (arr[i] > arr[idx])
			idx = i;
	}
	return idx;
}

template<typename T>
unsigned int index_of_min(vector<T>& arr) {
	unsigned int idx = 0;
	for (int i = 0; i < arr.size(); ++i) {
		if (arr[i] < arr[idx])
			idx = i;
	}
	return idx;
}

bool isPalindrome(string s, int l, int r) {
	for (; l <= r; ++l, --r) {
		if (s[l] != s[r])
			return false;
	}
	return true;
}

int main()
{
	//	#ifndef ONLINE_JUDGE
	//		(void)freopen("input.txt", "r", stdin);
	//		(void)freopen("output.txt", "w", stdout);
	//	#endif	
	FAST_IO;
	int n;
	cin >> n;
	vector<ll> cnt(200001);
	vector<int> a(200001);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	ll total = 0;
	for (int i = 1; i <= n; ++i) {
		total += cnt[i] * (cnt[i] - 1) / 2;
	}
	for (int i = 0; i < n; ++i) {
		ll ans = total - (cnt[a[i]] - 1);
		cout << ans << "\n";
	}
	return 0;
}




Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<ll> a(N), b(N), c(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> c[i];
    }

    sort(begin(a), end(a));
    sort(begin(b), end(b));
    sort(begin(c), end(c));

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += (lower_bound(begin(a), end(a), b[i]) - begin(a)) * (end(c) - upper_bound(begin(c), end(c), b[i]));
    }

    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#define in(n, m) for (int i=n; i<m;i++)
#define inj(n, m)for (int j=n; j<m;j++)
#define ink(n, m)for (ll k=n; k<m;k++)
using namespace std;
using ll=long long;
using P =pair<ll, ll>;
const ll INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n, s;
bool can;
int ans;
int x;


int main() {
	int n, k;
	vector<int> A(100);
	int d[100];
	int a;

	cin >> n >> k;
	in(0, k) {
		cin >> d[i];
		inj(0, d[i]) {
			cin >> a;
			A.push_back(a);
		}
	}
	sort(A.begin(), A.end(),greater<int>());
	int sum = 0;
	int cnt = 0;
	in(0, k) sum += d[i];
	in(0, sum) {
		if (A[i] != A[i + 1]) cnt++;
	}
	cout << n-cnt << endl;
	return 0;
}


Measured memory_bytes: 3500
#include        <bits/stdc++.h>
#define ll      long long int
#define pb      push_back
#define mp      make_pair
#define F       first
#define S       second
#define MOD     1000000007
#define pii     pair<int,int>
#define vi      vector<int>
#define fio     ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define N       200010
#define M       21
using namespace std;

int a[510][510];

int main()
{
    fio;
    memset(a,0,sizeof a);
    int n,m,q,x,y;
    cin>>n>>m>>q;
    for(int i=0; i<m; i++){
        cin>>x>>y;
        a[1][y]++;
        a[x+1][y]--;
    }
    
    for(int i=1; i<=n; i++){
        for(int j=2; j<=n; j++){
            a[i][j]+=a[i][j-1];
        }
    }
    for(int j=1; j<=n; j++){
        for(int i=2; i<=n; i++){
            a[i][j]+=a[i-1][j];
        }
    }
    
    for(int i=0; i<q; i++){
        cin>>x>>y;
        cout<<a[x][y]<<endl;
    }
    
    return 0;
}



















Measured memory_bytes: 1920
/*
 #pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
*/
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#define NDEBUG
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <climits>
#include <list>
#include <functional>
#include <numeric>

//find out the use of the below
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define PI acos(-1)

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    fio;
    int n;
    cin >> n;
    int prev = 0, cur, ans = 0;
    for (int i = 0; i < n; ++i){
        int x;
        cin >> x;
        if (x <= prev){
            cur++;
        } else{
            ans = max(ans, cur);
            cur = 0;
        }
        prev = x;
    }
    cout << max(ans, cur);
    return 0;
}
/* BEFORE submitting, check for:
 *  1. Integer overflow
 *  2. Float/Double precision errors
 *  3. Array index out of bounds
 *  4. Edge cases.(n=1, n=max, etc.)
 *  5. Time complexity. No TLEs
 */



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

int main() {
    ll n,ans;
    vector<ll> a(5);
    ll m;

    cin >> n;
    rep(i, 5) {
        cin >> a[i];
    }
    m = a[0];
    for (int i = 1;i < 5;++i) {
        if (m > a[i])
            m = a[i];
    }

    if (n == (n / m) * m)
        ans = n / m;
    else
        ans = n / m + 1;
    ans += 4;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
int main(){
    char c,k;
    int sum=0;
    scanf("%c",&c);
    printf("%c",c);
    while(c=getchar()){
        if(c==' '||c=='\n') break;
        sum++;
        k=c;
    }
    printf("%d%c",sum-1,k);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    ll n, ans = 0;
    cin >> n;
    for (ll i = 1; i <= n; ++i) if (i % 3 && i % 5) ans += i;
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int Atop, Btop, n, ball;
    cin >> n;
    while (n-->0) {
        Atop=0;
        Btop=0;
        bool fine = true;
        for (int i = 0; i < 10; ++i) {
            cin >> ball;
            if (max(Atop, Btop) < ball) {
                if (Atop >= Btop) Atop = ball;
                else Btop = ball;
            } else if (Atop < ball) {
                Atop = ball;
            } else if (Btop < ball) {
                Btop = ball;
            } else {
                fine = false;
            }
        }
        cout << (const char *)(fine ? "YES" : "NO") << endl;
    }
}

Measured memory_bytes: 1152
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val s = sc.nextInt
    println(toHMS(s))
  }
  def toHMS(timeSec: Int): String = {
    val h = timeSec / (60*60)
    val m = (timeSec - h*60*60) / 60
    val s = timeSec - h*60*60 - m*60
    h + ":" + m + ":" + s 
  }
}

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

int main()
{

	int n,W;
	cin >> n >> W;

	vector<int> v(n);
	vector<int> w(n);
	for (int i=0;i<n;++i)
	{
		cin >> v[i] >> w[i];
	}

	vector<int> dp(W+1);
	for (int i=0;i<=W;++i)
	{
		dp[i]=0;
	}

	for (int i=0;i<n;++i)
	{
		int ww=w[i];
		int vv=v[i];
		for (int j=W;j>=ww;--j)
		{
			dp[j]=max(dp[j],dp[j-ww]+vv);
		}
	}

	int maxv=0;
	for (int i=0;i<=W;++i)
	{
		maxv=max(maxv,dp[i]);
	}
	cout << maxv << endl;
}




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

const list = input.split('\n');

const n = Number(list[0]);

const sublist = list[1].split(' ').map((i) => Number(i));

const longest = Math.max.apply(null, sublist);

var total = sublist.reduce((a,c) => {
  return a + c;
});

if (longest < total - longest) {
  console.log('Yes');
} else {
  console.log('No');
}


Measured memory_bytes: 21064