akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  string w;
  cin >> w;
  vector<int> cnt(26);
  for (int i = 0; i < w.size();i++){
    cnt[w[i] - 'a']++;
  }
  for (int i = 0; i < 26;i++){
    if (cnt[i] % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val an = (1..n).map { readLine()!!.toInt() - 1 }

    val visited = Array(n) { false }
    visited[0] = true
    var no = 0
    var ans = 0
    (0 until n).forEach {
        if (no == 1) {
            println(ans)
            return
        }
        val next = an[no]
        if (visited[next]) {
            println(-1)
            return
        }
        visited[next] = true
        ans++
        no = next
    }
    println(-1)
}

Measured memory_bytes: 39848
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M, S, G;
	cin >> N >> M >> S >> G;
	S--; G--;
	vector<vector<int> > g(N);
	vector<vector<int> > A(N);
	vector<vector<int> > B(N);
	vector<vector<int> > K(N);
	int u, v, a, b;
	for (int i = 0; i < M; i++) {
		cin >> u >> v >> a >> b;
		u--; v--;
		g[u].push_back(v);
		A[u].push_back(a);
		B[u].push_back(b);
		g[v].push_back(u);
		A[v].push_back(a);
		B[v].push_back(b);
		
		int k = max((int)0, (int)sqrt(b) - a - 10);
		int mnk = (int)1 << 60;
		int kk = -1;
		for (int j = k; j <= k + 20; j++) {
			if (mnk > j + ((b + j + a - 1) / (j + a))) {
				mnk = j + ((b + j + a - 1) / (j + a));
				kk = j;
			}
		}
		//cerr << k + ((b + k + a - 1) / (k + a)) << " " << k + 1 + ((b + k + a) / (k + a + 1)) << endl;
		//cerr << mnk << endl;
		//cerr << kk << endl;
		K[u].push_back(kk);
		K[v].push_back(kk);
	}
	int INF = (int)1 << 60;
	vector<int> mn(N, INF);
	vector<int> V(N, 0);
	priority_queue<pair<int, int> > pq;
	mn[S] = 0;
	pq.emplace(0, S);
	V[S] = 1;
	while ((int)pq.size() > 0) {
		int X = pq.top().second;
		pq.pop();
		V[X] = 0;
		for (int i = 0; i < g[X].size(); i++) {
			int d;
			if (mn[X] > K[X][i]) {
				d = mn[X] + ((B[X][i] + A[X][i] + mn[X] - 1) / (A[X][i] + mn[X]));
			}
			else {
				d = K[X][i] + ((B[X][i] + A[X][i] + K[X][i] - 1) / (A[X][i] + K[X][i]));
			}
			if (mn[g[X][i]] > d) {
				mn[g[X][i]] = d;
				if (V[g[X][i]] == 0) {
					V[g[X][i]] = 1;
					pq.emplace(-d, g[X][i]);
				}
			}
		}
	}
	if (mn[G] == INF) {
		cout << -1 << endl;
	}
	else {
		cout << mn[G] << endl;
	}
}


Measured memory_bytes: 63184
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    string S; cin >> S;
    cout << S[0] << S[1] << S[2] << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3624
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

string S;

void input() {
  cin >> S;
}

void solve() {
  for (int n=0;n<S.size();n++) {
    if (S[n] == '1') cout << 9;
    else if (S[n] == '9') cout << 1;
    else cout << S[n];
  }
  cout << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


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

int main(){
    int H;
    int i,j;
    int memo[10][5];
    bool update;
    int score;

    cin >> H;
    while(H>0){
        score = 0;
        vector<int> tow[5];
        vector<int>::iterator t;

        //input
        for(i=0; i<H; i++){
            for(j=0; j<5; j++){
                cin >> memo[i][j];
            }
        }

        //make tower
        for(j=0; j<5; j++){
            for(i=H-1; i>=0; i--){
                tow[j].push_back(memo[i][j]);
            }
        }

        //shoumetsu hantei
        update = 1;
        while(update){
            update=0;
            vector<int> dou[10];
            for(i=0; i<H; i++){
                for(j=0; j<3; j++){
                    if(tow[j][i]==tow[j+1][i]&&tow[j][i]>0){
                        if(tow[j+1][i]==tow[j+2][i]){
                            update = 1;
                            if(j<2){
                                if(tow[j+2][i]==tow[j+3][i]){
                                    if(j<1){
                                        if(tow[j+3][i]==tow[j+4][i]){
                                            dou[i].push_back(j);
                                            dou[i].push_back(j+4);
                                            dou[i].push_back(tow[j][i]);
                                            break;
                                        }
                                    }
                                    dou[i].push_back(j);
                                    dou[i].push_back(j+3);
                                    dou[i].push_back(tow[j][i]);
                                    break;
                                }
                            }
                            dou[i].push_back(j);
                            dou[i].push_back(j+2);
                            dou[i].push_back(tow[j][i]);
                            break;
                        }
                    }
                }
            }

            //add score
            for(i=0; i<H; i++){
                if(!dou[i].empty()){
                    score += (dou[i][1]-dou[i][0]+1)*dou[i][2];
                }
            }

            //erase
            for(i=H-1; i>=0; i--){
                if(!dou[i].empty()){
                    for(j=dou[i][0]; j<=dou[i][1]; j++){
                        tow[j].erase(tow[j].begin()+i);
                    }
                }
            }

            //add -1(none)
            for(j=0; j<5; j++){
                while(tow[j].size()<H){
                    tow[j].push_back(-1);
                }
            }
        }

        //answer
        cout << score << endl;

        //input
        cin >> H;
    }
    return 0;
}


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

int main() {
	int n; cin >> n;
	vector<int>a(n); for (auto&& x : a)cin >> x;
	long long ans1 = 0, ans2 = 0, sum = 0;
	
	for (int i = 0; i < n; i++) {
		sum += a[i];
		if (i % 2 == 0 && sum <= 0) {
			ans1 += -sum + 1;
			sum = 1;
		}
		else if (i % 2 == 1 && sum >= 0) {
			ans1 += sum + 1;
			sum = -1;
		}
	}

	sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
		if (i % 2 == 1 && sum <= 0) {
			ans2 += -sum + 1;
			sum = 1;
		}
		else if (i % 2 == 0 && sum >= 0) {
			ans2 += sum + 1;
			sum = -1;
		}
	}
	cout << min(ans1, ans2) << endl;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int n, m, k, a[114514], ans;
void check(int i) {
	if (k >= n)
		if (ans == 114514)ans = i;
	return;
}
int main() {
	while (cin >> n >> m) {
		if (!m && !n)return 0;
		for (int i = 1; i <= n; i++)cin >> a[i];
		k = 1;
		ans = 114514;
		for (int i = 1; i <= m; i++) {
			int s; cin >> s;
			if (ans == 114514)k += s;
			check(i);
			if (ans == 114514)k += a[k];
			check(i);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 2992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int H = sc.nextInt();
		int W = sc.nextInt();
		String[] c = new String[H+1];

		for (int i = 0; i <= H; i++) {
			c[i] = "#" + sc.nextLine() + "#";
		}
		for (int i = 0; i <= W; i++) {
			System.out.print("#");
		}

		System.out.println("#");
		
		for (int i = 1; i <= H; i++) {
			System.out.println(c[i]);
		}
		
		for (int i = 0; i <= W+1; i++) {
			System.out.print("#");
		}

		sc.close();
	}
}


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


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int w=sc.nextInt();
        int h=sc.nextInt();
        long[]p=new long[w],q=new long[h];
        for(int i=0;i<w;++i)p[i]=sc.nextInt();
        for(int i=0;i<h;++i)q[i]=sc.nextInt();
        long[]taplis=new long[w+h];
        for(int i=0;i<w;++i)taplis[i]=(long)p[i]<<32|i;
        for(int i=0;i<h;++i)taplis[w+i]=(long)q[i]<<32|(w+i);
        Arrays.sort(taplis);
        long ans=0;
        int row=h+1,col=w+1;
        for(long yasuna:taplis){
            long cost=yasuna>>>32;
            int ind=(int)yasuna;
            if(ind>=w){
                ans+=col*cost;
                row--;
            }else{
                ans+=row*cost;
                col--;
            }
        }
        out.println(ans);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                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());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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


int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  map<long long,long long> mp;
  for(long long i=0;i<n;++i){
    cin >> a[i];
    mp[a[i]]++;
  }
  bool ans=false;
  if(mp.size()==3){
    vector<bitset<100>> bs;
    for(auto p : mp){
      if(p.second!=n/3){
        cout << "No" << endl;
        return 0;
      }
      bs.push_back(p.first);
    }
    if((bs[0]^bs[1])==bs[2]){
      cout << "Yes" << endl;
      return 0;
    }else{
      cout << "No" << endl;
      return 0;
    }
  }
  if(mp.size()==1){
    for(auto p : mp){
      if(n==p.second && p.first==0){
        ans=true;
      }
    }
  }

  if(mp.size()==2){
    vector<pair<long long,long long>> pp(2);
    long long k=0;
    for(auto p : mp){
      pp[k]=make_pair(p.first,p.second);
      k++;
    }
    sort(pp.begin(),pp.end());
    if(n%3==0 && pp[1].first==0){
      if(pp[1].second==n/3){
        ans=true;
      }
    }
    if(n%3==0 && pp[0].first==0){
      if(pp[0].second==n/3){
        ans=true;
      }
    }
  }

  if(ans==true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 5632
using System;
class p
{
  static void Main()
  {
    string[] ipt = Console.ReadLine().Split(' ');
    int H = int.Parse(ipt[0]);
    int A = int.Parse(ipt[1]);
    Console.WriteLine((H % A == 0) ? (H / A) : (H / A) + 1);
  }
}

Measured memory_bytes: 13140
#include <stdio.h>

int main(void)
{
  int N,A[20],B[50],C[50],i,s;

  scanf("%d",&N);

  for(i=0;i<N;i++){
   scanf("%d",&A[i]);
  }
  for(i=0;i<N;i++){
   scanf("%d",&B[i]);
  }
   for(i=0;i<N-1;i++){
   scanf("%d",&C[i]);
  }

   s=0;
   for(i=0;i<N;i++){
    s+=B[A[i]-1];
    if((i>0)&&(A[i]==A[i-1]+1)){
     s+=C[A[i-1]-1];  
    }
   }

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

  return 0;
 }



Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  int k , s;
  cin >> k >> s;
  long sum = 0;
  rep(x,0,k+1){
    rep(y,0,k+1){
      int z = s-x-y;
      if(z >= 0 && z <= k)
        sum++;
    }
  }
  P(sum);
  ret 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
const ll N=998244353;
void solve()
{
    vector<vector<bool>> vect(3, vector<bool>(3, false));
    map<ll, pair<ll, ll>> mp1;
    forr(i, 3)
    {
        forr(j, 3)
        {
            ll x=0;
            cin>>x;
            mp1[x]=mp(i, j);
        }
    }
    ll n;
    cin>>n;
    //cout<<n<<endl;
    forr(i, n)
    {
        ll pt;
        cin>>pt;
        if(mp1.find(pt)!=mp1.end())
        {
            vect[mp1[pt].first][mp1[pt].second]=true;
        }
    }
    bool check2=true;
    bool check3=true;
    forr(i, 3)
    {
        bool check=true;
        forr(j, 3)
        {
            if(i==j)
            check2=check2&&vect[i][j];
            if(i+j==2)
            check3=check3&&vect[i][j];
            check=check&&vect[i][j];
        }
        if(check==true)
        {
            cout<<"Yes\n";
            return;
        }
        
    }
    if(check2||check3)
    {
        cout<<"Yes\n";
        return;
    }
    forr(i, 3)
    {
        bool check=true;
        forr(j, 3)
        {
            check=check&&vect[j][i];
        }
        if(check==true)
        {
            cout<<"Yes\n";
            return;
        }
    }
    cout<<"No";
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 3564
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner (System.in);
	int n = Integer.parseInt(scan.nextLine());
	String[] input;
	int a, b, c;
	for (int i = 0; i < n; i++) {
	    input = scan.nextLine().split(" ");
	    a = Integer.parseInt(input[0]);
	    b = Integer.parseInt(input[1]);
	    c = Integer.parseInt(input[2]);
	    if (isRightTriangle(a, b, c)) {
		System.out.println("YES");
	    } else {
		System.out.println("NO");
	    }
	}
    }
    static boolean isRightTriangle (int a, int b, int c) {
	int a2 = a * a, b2 = b * b, c2 = c * c;
	if (a2 + b2 == c2 || a2 + c2 == b2 || b2 + c2 == a2) {
	    return true;
	}
	return false;
    }
}

Measured memory_bytes: 31544
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main(){

    input!{
        n: usize,
        a: [usize;n],
    }

    let mut cnt = 0;

    for i in 0..n {
        if i%2==0 && a[i]%2!=0 {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}

Measured memory_bytes: 2100
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b;
	cin >> a >> b;
	int cur = 1;
	int ans = 0;
	while (cur < b)
	{
		cur += a - 1;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
namespace ITP1_3_C
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                var S = Console.ReadLine().Split();
                var x = int.Parse(S[0]);
                var y = int.Parse(S[1]);
                if(x == 0 && y == 0) break;
                Console.WriteLine("{0} {1}", Math.Min(x, y), Math.Max(x, y));
            }
        }
    }
}


Measured memory_bytes: 15948
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{    
    // 記述はないがmは高々5万
    int N, M;
    cin >> N >> M;
    // テーブルナンバー
    int a[M], b[M];

    if(N%2 != 0){
        int half = N/2;
        for(int i=0; i<M; ++i){
            a[i] = half-i;
            b[i] = half+i+1;
        }
    }
    // 折り返しから奇数番にすれば良い気がする
    else{
        int half = (2*M)/2;
        if(M%2 != 0){
            // 初期値はこれで固定
            for(int i=0; i<M/2+1; ++i){
                a[i] = half-i;
                b[i] = half+i+1;
            }
            for(int i=M/2+1; i<M; ++i){
                a[i] = half-i;
                b[i] = half+i+2;
            }
        }
        else{
            // 初期値はこれで固定
            for(int i=0; i<M/2; ++i){
                a[i] = half-i;
                b[i] = half+i+1;
            }
            for(int i=M/2; i<M; ++i){
                a[i] = half-i;
                b[i] = half+i+2;
            }
        }

    }

    for(int i=0; i<M; ++i) cout << a[i] << " " << b[i] << endl;
    return 0;
}

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

int main() {
	vector<int> a, b, c;
	int n;
	cin >> n;
	a.resize(n);
	b.resize(n);
	c.resize(n-1);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] --;
	}

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

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

	}


	int p = b[a[0]];
	for (int i = 1; i < n; i++) {
		int a_now = a[i];
		int a_p = a[i - 1];
		p += b[a_now];
		
		if (a_now - a_p == 1) {
			p += c[a_p];
		}

		//cerr << p << endl;
	}

	cout << p << endl;

	return 0;
}

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A==5 && B==5 && C==7){
    cout << "YES" << endl;
  }
  else if(A==5 && B==7 && C==5){
    cout << "YES" << endl;
  }
  else if(A==7 && B==5 && C==5){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>

using namespace std;

long long MOD = 1e9 + 7;

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

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

    std::sort(l.begin(), l.end());
    
    int count = 0;
    // 短いほうから2つ棒を選ぶ
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            // l[i]: 一番短い棒
            // l[j]: 二番目に短い棒
            // l[i] + l[j]以上で最も小さな値の入った箇所のイテレータを返す。無い場合大きくマイナスの値。
            auto itr = std::lower_bound(l.begin(), l.end(), l[i] + l[j]);
            // vector上でのインデックスに変換
            int lowerBoundIndex = itr - l.begin();
            // l[j] < num && num < l[i] + l[j](残り1辺の条件)を満たす数をカウント。
            count += std::max(lowerBoundIndex - (j + 1), 0);
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        int[][] a = new int[n][m];
        int [] b = new int [m];
        int[] c = new int[n];
        
        for(int i=0; i < n; i++){
            for(int j=0; j < m; j++){
                a[i][j] = sc.nextInt();
            }
        }
        
        for(int i=0; i<m; i++){
            b[i] = sc.nextInt();
        }

        for(int i=0; i < n; i++){
            for(int j=0; j < m; j++){
                c[i] += a[i][j] * b[j];
            }
        }
        for(int res : c) System.out.println(res);
    }
}



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

int N, x, a[200001], cnt[200001];
long long ways;

int main() {
    scanf("%d", &N);
    for (int i=0;i<N;++i) {
        scanf("%d", &a[i]);
        ways += cnt[a[i]];
        cnt[a[i]]++;
    }

    for (int i=0;i<N;++i) {
        ways -= cnt[a[i]] - 1;
        printf("%lld\n", ways);
        ways += cnt[a[i]] - 1;
    }
    
}

Measured memory_bytes: 3712
fun main(args: Array<String>) {
    val primeTable = primeTable(100000)
    val table2017 = BooleanArray(100000 + 1) { false }
    for (i in primeTable.indices) {
        val tmp = (i + 1) / 2
        table2017[i] = tmp >= 0 && primeTable[i] && primeTable[tmp]
    }

    val cumulativeSumList = IntArray(table2017.size + 1)
    for (i in 1 until cumulativeSumList.size) {
        cumulativeSumList[i] += cumulativeSumList[i - 1] + if (table2017[i - 1]) 1 else 0
    }

    val q = readInteger()
    val ans = mutableListOf<Int>()
    repeat(q) {
        val (l, r) = readIntegerList()
//        ans.appendln(cumulativeSumList[r + 1] - cumulativeSumList[l])
        ans += cumulativeSumList[r + 1] - cumulativeSumList[l]
    }
    println(ans.joinToString("\n"))
}

fun primeTable(n: Int): BooleanArray {
    val table = BooleanArray(n + 1) { true }
    if (n >= 0) table[0] = false
    if (n >= 1) table[1] = false
    var i = 2
    while (i * i <= n) {
        if (table[i]) {
            for (j in (i + i)..n step i) {
                table[j] = false
            }
        }

        i++
    }
    return table
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 60460
n=int(input())
A=list(map(int,input().split()))
if 0 in A:
  print(0)
  exit()
a=1
f=0
for i in range(n):
  a=a*A[i]
  if a>10**18:
    f=1
    break
if f==0:
  print(a)
else:
  print(-1)

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

int main (){
    string S;
    cin>>S;
    vector<char> Vec(S.size());
    for(int i=0; i<S.size(); i++){
        Vec.at(i)=S.at(i);
    }
    int Count=0;
    int Key=0;
    int Size=S.size();
    while(Key<Size-1){
        if(Vec[Key]==Vec[Key+1]){
            Key ++;
            continue;
        }
        else{
            Vec.erase(Vec.begin()+Key);
            Vec.erase(Vec.begin()+Key);
            Size -= 2;
            Count += 2;
            if(Key>0){
                Key --;
            }
        }
    }
    cout<<Count;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long t,x,n;
  cin >> n;
  int a[n];
  long long s=0;
  for( int i=0;i<n;i++)
  {
      cin >> a[i];
  }
  for(int i=1;i<n;i++)
  {
      if(a[i-1]>a[i])
      {
          s+=a[i-1]-a[i];
          a[i]=a[i-1];
      }
  }
  cout << s <<endl;
  return 0;
}


Measured memory_bytes: 4392
N, M, K = (int(x) for x in input().split())
R = [int(x)-1 for x in input().split()]

dist = [[10e8 for _ in range(N)] for _ in range(N)]
for i in range(N): dist[i][i] = 0
for _ in range(M):
    a, b, c = (int(x) for x in input().split())
    dist[a-1][b-1] = dist[b-1][a-1] = c 
del a, b, c, K

for k in range(N):
    for i in range(N):
        for j in range(i,N):
            dist[i][j] = dist[j][i] = min(dist[i][j], dist[i][k]+dist[k][j])

def mindist(x, X):
    global dist
    Y = X.copy()
    Y.remove(x)
    if len(Y) == 0: return 0
    return min([dist[x][y] + mindist(y,Y) for y in Y])

ans = min([mindist(r, R) for r in R])
print(ans)

Measured memory_bytes: 9924
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n; cin >> n;
    vector<vector<int>> tr(n);
    rep(i,n-1){
        int a,b; cin >> a >> b;
        a--; b--;
        tr[a].pb(b);
        tr[b].pb(a);
    }
    queue<int> q;
    vector<bool> visit(n,0);
    vector<bool> clr(n);
    q.push(0); visit[0]=1;
    clr[0]=0;
    while(!q.empty()){
        int v=q.front(); q.pop();
        for(auto u:tr[v]){
            if(visit[u]) continue;
            if(clr[v]) clr[u]=0;
            else clr[u]=1;
            visit[u]=1;
            q.push(u);
        }
    }
    int num0=0,num1=0;
    rep(i,n){
        if(clr[i]) num1++;
        else num0++;
    }
    vector<int> ans(n);
    //clr[i]=0でcnt1
    int cnt0=1,cnt1=0,cnt2=0;
    if(num0>(n/3) && num1>(n/3)){
        rep(i,n){
            if(clr[i]){
                if(cnt2*3+2<=n){
                    ans[i]=cnt2*3+2;
                    cnt2++;
                }else{
                    ans[i]=cnt0*3;
                    cnt0++;
                }
            }else{
                if(cnt1*3+1<=n){
                    ans[i]=cnt1*3+1;
                    cnt1++;
                }else{
                    ans[i]=cnt0*3;
                    cnt0++;
                }
            }
        }
    }else if(num1<=n/3){
        rep(i,n){
            if(clr[i]){
                ans[i]=cnt0*3;
                cnt0++;
            }else{
                if(cnt1*3+1<=n){
                    ans[i]=cnt1*3+1;
                    cnt1++;
                }else if(cnt2*3+2<=n){
                    ans[i]=cnt2*3+2;
                    cnt2++;
                }else{
                    ans[i]=cnt0*3;
                    cnt0++;
                }
            }
        }
    }else{
        rep(i,n){
            if(!clr[i]){
                ans[i]=cnt0*3;
                cnt0++;
            }else{
                if(cnt1*3+1<=n){
                    ans[i]=cnt1*3+1;
                    cnt1++;
                }else if(cnt2*3+2<=n){
                    ans[i]=cnt2*3+2;
                    cnt2++;
                }else{
                    ans[i]=cnt0*3;
                    cnt0++;
                }
            }
        }
    }
    rep(i,n) cout << ans[i] << " ";
}


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

template<typename T>
constexpr T modpow(T a,T n,T mod){//(a^n)%MOD
    T ret=1;
    while(n>0){
        if((n&1)!=0){//n%2==1
            ret=ret*a%mod;
        }
        a=a*a%mod;
        n=n/2;
    }
    return ret;
}

using namespace std;

int mod13hoge(int k,int v){
    return v*modpow(10,k,13)%13;
}

int main(){
    string s;
    cin>>s;
    int n=s.size();
    vector<vector<long long>> dp(s.size(),vector<long long>(13,0));
    if(s[0]=='?'){
        for (int i = 0; i < 10; ++i) {
            ++dp[0][mod13hoge(n-1,i)];
        }
    }
    else{
        dp[0][mod13hoge(n-1,s[0]-'0')]=1;
    }

    for (int i = 1; i < n; ++i) {
        int nk=n-i-1;
        if(s[i]=='?'){
            for (int k = 0; k < 10; ++k) {
                for (int j = 0; j < 13; ++j) {
                    int ti=(j+mod13hoge(nk,k))%13;
                    dp[i][ti]+=dp[i-1][j];
                    dp[i][ti]%=1000000007;
                }
            }
        }
        else{
            for (int j = 0; j < 13; ++j) {
                int ti=(j+mod13hoge(nk,s[i]-'0'))%13;
                dp[i][ti]+=dp[i-1][j];
                dp[i][ti]%=1000000007;
            }
        }
    }
    cout<<dp[n-1][5]<<endl;
    return 0;
}

Measured memory_bytes: 13696
#include<iostream>
using namespace std;
int main()
{
	int n;
	int i = 1;
	cin >> n;
	if (n!=1||n!=0)
	{
		while (i <= n)
		{
			i *= 2;
		}
		cout << i / 2 << endl;
	}
	else
	{
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(max(a, b), min(a, b)); }

int main() {
    int N, L;  cin >> N >> L;

    vector<pair<int, int>> taste;
    rep(i, N) {
        taste.push_back(make_pair(abs(L+i), L+i));
    }

    sort(all(taste));

    int ans = 0;
    for (int i = 1; i < N; ++i) {
        ans += taste[i].second;
    }

    print(ans);

}

Measured memory_bytes: 256
# B - Trick or Treat

n, k = map(int, input().split())
safe = set()  # お菓子を持っているすぬけ
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    assert len(a) == d
    safe.update(a)

print(n - len(safe))


Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define r(i, n) for (int i=0;i<n;i++)
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b;
  r(i,10000) {
    if (b<=(a-1)*i+1) {
      c=i;
      break;
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
N,M,C=map(int,input().split())
B = list(map(int,input().split()))
cnt=0
for i in range(N):
    number = list(map(int,input().split()))
    value=0
    for j in range(M):
        value += number[j]*B[j]
    value += C
    if value>0:
        cnt += 1
print(cnt)


Measured memory_bytes: 62320
a = gets.chomp
m = a[0..1].to_i
n = a[2..3].to_i 

if (1 <= m && m <= 12) && (1 <= n && n <= 12)
   puts "AMBIGUOUS"    
elsif (1 > m || m > 12) && (1 <= n && n <= 12)
   puts "YYMM"
elsif (1 <= m && m <= 12) && (1 > n || n > 12)
   puts "MMYY"
else  (1 > m || m > 12) && (1 > n || n > 12) 
   puts "NA"
end

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
using namespace std;

int main(){
	int N,M;
	cin>>N>>M;
	vector<long>X;
	long tmp;
	for(int i=0;i<M;++i){
		cin>>tmp;
		X.push_back(tmp);
	}
	if(M>1){
		sort(X.begin(),X.end());
		vector<long>arr;
		for(int i=1;i<M;++i){
			arr.push_back(X[i]-X[i-1]);
		}
		sort(arr.begin(),arr.end());
		/*
		for(int i=0;i<M;++i){
			cout<<arr[i]<<" ";
		}
		cout<<endl;
		*/
		for(int i=0;i<N-1;++i){
			if(arr.size()>0)arr.pop_back();
		}
		cout<<accumulate(arr.begin(),arr.end(),0)<<endl;
	}
	else cout<<0<<endl;
}


Measured memory_bytes: 2548
#include <iostream>
#include <utility>
#include <string>
#include <cctype>

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  --K;

  S[K] = tolower(S[K]);
    
  cout << S << endl;

  return 0;
}

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

int main(){
	string s,t;	cin>>s>>t;

	bool flag=true;
	for(int i=0;i<s.length();i++){
		if(s[i]!=t[i]){
			flag=false;	break;
		}
	}

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


	return 0;
}


Measured memory_bytes: 3628
unittest
{
	assert( [ "4 10" ].parse.expand.solve == 3 );
	assert( [ "8 9" ].parse.expand.solve == 2 );
	assert( [ "8 8" ].parse.expand.solve == 1 );
}



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

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

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ab = input.front.split.to!( long[] );
	return tuple( ab[ 0 ], ab[ 1 ] );
}

auto solve( long a, long b )
{
	auto ans = 0L;
	while( 1 + ans * ( a - 1 ) < b )
	{
		ans++;
	}
	return ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
/*----------------------------------------------------------------------------------*/


int main() {
    int h, w; cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];

    vector<vector<bool>> ok(h, vector<bool>(w,false));
    
    // h->h, w->w, grid[][]->s[][]
    auto bfs = [&](int sy, int sx) -> ll {
        ll a = 1, b = 0;
        queue<pair<int, int>> que;
        que.push(make_pair(sy, sx));
        ok[sy][sx] = true;
        while(!que.empty()) {
            pair<int, int> cur = que.front(); que.pop();
            int y = cur.first, x = cur.second;
            for(int i = 0; i < 4; ++i) {
                int ny = y + dy[i], nx = x + dx[i];
                if(ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
    
                if(ok[ny][nx]) continue;
    
                if((s[ny][nx] != s[y][x])) {
                    // cout << ny << ' ' << nx << endl;
                    que.push(make_pair(ny, nx));
                    ok[ny][nx] = true;
                    if (s[ny][nx] == s[sy][sx]) a++;
                    else b++;
                }
            }
        }
        return a*b;
    };

    ll ans = 0;
    rep(i,h) rep(j,w) {
        if (!ok[i][j]) ans += bfs(i,j);
        // cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
N, M = map(int, input().split())

from_one = set()
to_n = set()
for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        from_one.add(b)
    if b == N:
        to_n.add(a)

if len(from_one & to_n) > 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
        

Measured memory_bytes: 18936
#include<stdio.h>
void PR(int,int);
void PR(int x,int y){
    for(int h=1;h<=x;h++){
        for(int w=1;w<=y;w++){
            printf("#");
        }
        printf("\n");
    }
    printf("\n");
    return;
}
int main(void){
    int H,W;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0){
            break;
        }
        PR(H,W);
    }
    return 0;
}


Measured memory_bytes: 2084
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

pair<int, int> operator-(pair<int, int>& y, pair<int, int>& x) {
    return {y.fi - x.fi, y.se - x.se};
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    for(auto& x : v) cin >> x.fi >> x.se;

    map<pair<int, int>, int> f;
    int mx = 0;
    for(int i = 0; i < (int)v.size() - 1; ++i) {
        for(int j = i + 1; j < v.size(); ++j) {
            pair<int, int> tmp = v[j] - v[i];
            f[tmp] += 1;
            mx = max(mx, f[tmp]);
            tmp = v[i] - v[j];
            f[tmp] += 1;
            mx = max(mx, f[tmp]);

        }
    }
    cout << n - mx << endl;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] ds = new int[n];
        for (int i = 0; i < n; i++) {
            ds[i] = Integer.parseInt(br.readLine());
        }
        
        int[] mochi = new int[105];
        for (int i = 0; i < n; i++) {
            mochi[ds[i]]++;
        }
        
        int result = 0;
        for (int i = 1; i <= 100; i++) {
            if (mochi[i] > 0) result++;
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 21076
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <set>

#define rep(i,n)  for (int i = 0; i < (int)(n); i++)
#define INF 9999999999
#define PI 3.14159265359
using namespace std;

int main()
{
	int i,j=0,x,n,ans;
	cin >>x>>n;
	if (n==0){
		cout << x << endl;
		return 0;
	}
	vector<int> p(n);
	rep(i,n)cin >> p[i];
	sort(p.begin(),p.end());
	i=0;
	while(find(p.begin(),p.end(),x+i)!=p.end()){
		i*=-1;
		if(i<=0)	i=i-1;
	}
	ans=x+i;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3156
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int i;
	vector<char> v;
	string s;
	cin>>s;
	int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
	if(a+b+c+d==7)printf("%d+%d+%d+%d=7",a,b,c,d);
	else if(a+b+c-d==7)printf("%d+%d+%d-%d=7",a,b,c,d);
	else if(a+b-c+d==7)printf("%d+%d-%d+%d=7",a,b,c,d);
	else if(a+b-c-d==7)printf("%d+%d-%d-%d=7",a,b,c,d);
	else if(a-b+c+d==7)printf("%d-%d+%d+%d=7",a,b,c,d);
	else if(a-b+c-d==7)printf("%d-%d+%d-%d=7",a,b,c,d);
	else if(a-b-c+d==7)printf("%d-%d-%d+%d=7",a,b,c,d);
	else if(a-b-c-d==7)printf("%d-%d-%d-%d=7",a,b,c,d);
	
	
	
	
//////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# %%

import sys


def solve(N: int):
    return (N+1)//2/N


# %%

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(solve(N))


if __name__ == '__main__':
    main()


# %%


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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  double ans = 0;
  for (int i = 1; i <= N; ++i) {
    double t = 1;
    for (int j = i; j < K; j *= 2) t /= 2;
    ans += t / N;
  }
  cout << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};


int a[100005];
int p[10005];

vector<string>v,ans;
map<string,int>mp,taken;
int main(){
   int n;
   cin>>n;
   int mx=0;
   for(int i=0;i<n;++i){
      string s;
      cin>>s;
      v.pb(s);
      mp[s]+=1;
      mx=max(mx,mp[s]);
   }
   for(int i=0;i<n;++i){
      if(mp[v[i]]==mx and !taken[v[i]]){
         taken[v[i]]=1;
         ans.pb(v[i]);
      }
   }
   sort(all(ans));
   for(int i=0;i<ans.size();++i){
      cout<<ans[i]<<endl;
   }

   return 0;
}

Measured memory_bytes: 40816
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>
#include <cmath>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back
#define UNIQ(a) a.erase(unique(all(a)), end(a))

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}
template<typename T>bool chmin(T&a,T b){return a>b?(a=b,1):0;}
template<typename T>bool chmax(T&a,T b){return a<b?(a=b,1):0;}
int read(){int a;scanf("%lld",&a);return a;}

const double pi = acos(-1);
constexpr int inf = 3*TEN(18) + 10;
constexpr int mod = TEN(9) + 7;

int N;
vpii x[100010]; // x[i] := y = i にあるx座標の列(sorted)
vpii y[100010]; // y[i] := x = i にあるy座標の列(sorted)
pii P[100010];
bool visited[100010];

int bfs(int idx)
{
	if (visited[idx]) return 0;
	queue<pair<pii, int>> q;
	q.emplace(P[idx], idx);

	set<int> SX, SY;
	SX.insert(P[idx].first);
	SY.insert(P[idx].second);
	visited[idx] = true;

	int sub = 1;

	while (q.size()) {
		auto cur = q.front(); q.pop();

		int curx = cur.first.first, cury = cur.first.second;
		int pid = cur.second;

		int xidx = lower_bound(all(x[cury]), pii(curx, pid)) - begin(x[cury]);
		int yidx = lower_bound(all(y[curx]), pii(cury, pid)) - begin(y[curx]);

		for (int i = -1; i <= 1; ++i) {
			if (0 <= xidx + i and xidx + i < x[cury].size()) {
				pii neix = x[cury][xidx + i];
				int nx = neix.first;
				int id = neix.second;

				if (visited[id]) continue;
				sub++;

				SX.insert(nx);
				q.emplace(pii(nx, cury), id);
				visited[id] = true;
			}
		}
		for (int i = -1; i <= 1; ++i) {
			if (0 <= yidx + i and yidx + i < y[curx].size()) {
				pii neiy = y[curx][yidx + i];
				int ny = neiy.first;
				int id = neiy.second;

				if (visited[id]) continue;
				sub++;
				SY.insert(ny);
				q.emplace(pii(curx, ny), id);
				visited[id] = true;
			}
		}
	}

	return SX.size() * SY.size() - sub;
}

signed main()
{
	cin >> N;

	rep(i, N) {
		int a, b; cin >> a >> b;
		P[i] = pii(a, b);
		x[b].PB(a, i);
		y[a].PB(b, i);
	}

	rep(i, 100010) {
		sort(all(x[i]));
		sort(all(y[i]));
	}

	int ans = 0;

	rep(i, N) {
		if (visited[i]) continue;
		int v = bfs(i);
		ans += v;
	}

	cout << ans << endl;
}



Measured memory_bytes: 19852
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) (x).begin(), (x).end() 
const int inf = 1e9;
const long long INF=1e15;
#define endl '\n'
#define rep(i, n) for(int i=0;i<(n);++i)
#define repp(i, a, b) for(int i=(a);i<=(b);++i)
#define pb push_back
#define eb emplace_back
#define fastio ios::sync_with_stdio(false);cin.tie(0); //cout.tie(0);

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

ll f(ll x) {
	return x*(x-1)/2;
}
int main() {
	int n; cin >> n;
	vi a(n); rep(i, n) cin >> a[i];
	vi cnt(n+1, 0); rep(i, n) cnt[a[i]]++;
	ll ans = 0; repp(i, 1, n) ans += f(cnt[i]);
	rep(i, n) {
		ans += f(cnt[a[i]]-1) -  f(cnt[a[i]]);
		cout << ans << endl;
		ans -= f(cnt[a[i]]-1) -  f(cnt[a[i]]);
	} 
}

Measured memory_bytes: 4096
import sys
sys.setrecursionlimit(200000)

n = int(input())
abc = [[] for _ in range(n)]
for _ in range(n-1):
  a, b, c = map(int, input().split())
  a -= 1
  b -= 1
  abc[a].append((b, c))
  abc[b].append((a, c))
  
q, k = map(int, input().split())
k -= 1

depth = [0 for _ in range(n)]
def dfs(v, p = -1, d = 0):
  depth[v] = d
  for i, j in abc[v]:
    if i == p:
      continue
    dfs(i, v, d+j)
dfs(k)


queries = []
for _ in range(q):
  x, y = map(int, input().split())
  x -= 1
  y -= 1
  print(depth[x]+depth[y])


Measured memory_bytes: 150460