akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#include <math.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
const int MAX = 510000;

/*-----Library-----*/

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }

    int size(int x){
        return sizeuf[root(x)];
    }
};

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

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/*-----Library-----*/
signed main(){
    int n,a,b; cin>>n>>a>>b;
    if((b-a)%2==0)cout<<"Alice"<<endl;
    else cout<<"Borys"<<endl;
}


Measured memory_bytes: 256
/*WELCOME TO AYUSH RANJAN CODE'S*/
/*EVERY PROBLEM HAS A SOLUTION SOMETIMES ELEGENT OTHERWISE COMPLEX ELEGENCE*/

#include <bits/stdc++.h>
#define ll long long int
using namespace std;

const int mod = 1e9 + 7;

int chkpower2(int x){
    return (x&&!(x&x-1));
}

void solve(){
    ll ans=0;
    string s1;
    cin>>s1;
    for(int i1=0;i1<s1.size();i1++){
        int x=s1[i1]-'0';
        ans+=x;
    }
    if(ans%9==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return;
}

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

    int t;
    t=1;// cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3752
import java.util.*;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String ans ="";
		for(int i=1;i<=S.length();i++){
			ans = ans + "x";
		}
		System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int d, n; cin >> d >> n;
  if(d == 0) cout << (n < 100 ? n : 101) << '\n';
  else if(d == 1) cout << (n < 100 ? n*100 : 10100) << '\n';
  else cout << (n < 100 ? n*10000 : 1010000) << '\n';
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

typedef long long lint;
typedef unsigned long long ulint;
#define MOD 1000000007

lint pow(lint x,lint e){
    if(e==1) return x%MOD;
    if(e==0) return 1;
    return pow(x*x%MOD,e/2)*(e%2==0?1:x)%MOD;
}
lint inv(lint i){
    return pow(i,MOD-2);
}
lint fact[100002],factinv[100002];
lint C(lint n,lint r){
    return fact[n]*factinv[r]%MOD*factinv[n-r]%MOD;
}

int main(){
    lint n,a;
    bool c[100002];
    for(lint i=1;i<=n;i++) c[i]=false;
    lint p[100002];
    lint x,y;

    cin >> n;
    for(lint i=0;i<=n;i++){
        cin >> a;
        if(c[a]){
            x=p[a];
            y=i;
        }
        c[a]=true;
        p[a]=i;
    }


    fact[0]=1;
    for(lint i=1;i<=n+1;i++) fact[i]=i*fact[i-1]%MOD;
    for(lint i=0;i<=n+1;i++) factinv[i]=inv(fact[i]);

    for(lint i=1;i<=n+1;i++){
        lint ans;
        ans=C(n+1,i);
        if(i-1<=n-(y-x)) ans+=MOD-C(n-(y-x),i-1);
        cout << (ans%MOD) << endl;
    }

    return 0;
}

Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0065
{
	class Program
	{
		class Trading
		{
			public	int		no;
			public	int		cnt;
			public	bool	before;
			public	bool	now;
		}

		static void Main(string[] args)
		{
			var	trading	= new List<Trading>();
			
			var	s	= "";
			
			while( string.IsNullOrEmpty( s = Console.ReadLine() ) == false ) {
				var	a	= Array.ConvertAll( s.Split( ',' ), aa => int.Parse( aa ) );
				var	i	= trading.FindIndex( b => b.no == a[ 0 ] );
				if( i != -1 ) {
					trading[ i ].cnt++;
				} else {
					var	t	= new Trading();
					t.no		= a[ 0 ];
					t.cnt		= 1;
					t.before	= true;
					trading.Add( t );
				}
			}

			while( (s = Console.ReadLine()) != null ) {
				var	a	= Array.ConvertAll( s.Split( ',' ), aa => int.Parse( aa ) );
				var	i	= trading.FindIndex( b => b.no == a[ 0 ] );
				if( i != -1 ) {
					trading[ i ].cnt++;
					trading[ i ].now	= true;
				}
			}

			trading.Sort( (t1, t2) => t1.no - t2.no );

			foreach( var t in trading ) {
				if( t.before && t.now ) {
					Console.WriteLine( "{0} {1}", t.no, t.cnt );
				}
			}
		}
	}
}

Measured memory_bytes: 5764
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include <string>
#include <math.h>
#include <queue>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >>y[i];
typedef long long int ll;
using namespace std;

int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
char field[1010][1010];
int main(){
  int h,w; cin >>h>>w;
  queue<pair<int,int> > q,r;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >>field[i][j];
      if(field[i][j]=='#'){
        q.push(make_pair(i,j));
      }
    }
  }
  int ans=0;
  bool qflag=true;
  bool rflag=false;
  while(q.size()>0||r.size()>0){
    rflag=false;
    while(q.size()>0&&qflag==true){
      int y=q.front().first;
      int x=q.front().second;
      q.pop();
      for(int i=0;i<4;i++){
        int nx=x+dx[i];
        int ny=y+dy[i];
        if(0<=nx&&nx<w&&0<=ny&&ny<h&&field[ny][nx]=='.'){
          r.push(make_pair(ny,nx));
          field[ny][nx]='#';
          rflag=true;
        }
      }
    }
    if(rflag==true) ans++;
    qflag=false;
    while(r.size()>0&&rflag==true){
      int y=r.front().first;
      int x=r.front().second;
      r.pop();
      for(int i=0;i<4;i++){
        int nx=x+dx[i];
        int ny=y+dy[i];
        if(0<=nx&&nx<w&&0<=ny&&ny<h&&field[ny][nx]=='.'){
          q.push(make_pair(ny,nx));
          field[ny][nx]='#';
          qflag=true;
        }
      }
    }
    if(qflag==true)ans++;
  }
  cout << ans << endl;
}

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

int cnt[1145140];

int main() {
	int n;
	cin >> n;
	
	for (int x = 1; x <= 100; x++) {
		for (int y = 1; y <= 100; y++) {
			for (int z = 1; z <= 100; z++) {
				int res = x * x + y * y + z * z + x * y + y * z + z * x;
				cnt[res]++;
			}
		}
	}
	
	for (int i = 1; i <= n; i++) cout << cnt[i] << endl;
	return 0;
}

Measured memory_bytes: 3860
#include <cstdio>
#include <cmath>
#include <set>

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

typedef long long   signed int LL;
typedef long long unsigned int LU;

template<typename T> void swap(T &x, T &y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, e, t, x[100002];
LL dp[100001];
int m[100001];

int main() {
	scanf("%lld%lld%lld", &n, &e, &t);
	inc1(i, n) { scanf("%lld", &x[i]); }
	
	int mm = 0;
	inc1(i, n) {
		while( (x[i] - x[mm + 1]) * 2 > t) { mm++; }
		m[i] = mm;
	}
	
	LL mi = 1000000000000000LL;
	inc1(i, n) {
		incID(j, m[i - 1], m[i]) { setmin(mi, dp[j] - 2 * x[j + 1]); }
		dp[i] = min(mi + 2 * x[i], dp[ m[i] ] + t);
	}
	
	printf("%lld\n", dp[n] + e);
	
	return 0;
}


Measured memory_bytes: 2176
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int A, B;

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

  cin >> A >> B;

  int ans = max(A+B, max(A-B, A*B));

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;

void main()
{
	while (1) {
		auto n = readln.chomp.to!int;
		if (!n) break;
		auto area = new int[][](n, n);
		int x = n/2;
		int y = n/2 + 1;
		area[y][x] = 1;
		int cnt = 2;
		while (cnt < n*n+1) {
			x = x + 1 == n ? 0 : x + 1;
			y = y + 1 == n ? 0 : y + 1;
			if (area[y][x] != 0) {
				x = x == 0 ? n - 1 : x - 1;
				y = y + 1 == n ? 0 : y + 1;
			}
			area[y][x] = cnt++;
		}
		foreach (i; 0..n) {
			foreach (j; 0..n) {
				writef("%4d", area[i][j]);
			}
			writeln("");
		}
	}
}

Measured memory_bytes: 1084
use std::io::{self, BufReader, Read};
use std::str::FromStr;
use std::string::String;

fn main() {
	let mut sc = ::Scanner::new(io::stdin());
	let s = sc.next_str().unwrap();
	let k = sc.next_as::<u64>().unwrap();
	let f = s.char_indices().skip_while(|c| c.1 == '1' ).next();
	if let Some(c) = f {
		println!("{}", if k <= c.0 as u64 { '1' } else { c.1 });
	} else {
		println!("{}", '1')
	}
}

#[derive(Debug)]
pub struct Scanner<R> {
	reader: BufReader<R>
}

impl<R: io::Read> Scanner<R> {
	
	pub fn new(read: R) -> Scanner<R> {
		Scanner { reader: BufReader::new(read) }
	}

	pub fn next_str(&mut self) -> Option<String> {
		let mut buf = [0; 1];
		let size = self.reader.read(&mut buf).unwrap();
		if size == 0 {
			None{}
		} else {
			let first = self.skip_whitespace(&mut buf);
			if first.is_none() {
				return None{}
			}
			let mut v = vec![buf[0]];
			loop {
				let size = self.reader.read(&mut buf).unwrap();
				if size == 0 || char::from(buf[0]).is_whitespace() {
					break;
				}
				v.push(buf[0]);
			}
			Some(String::from_utf8(v).unwrap())
		}
	}

	pub fn next_line(&mut self) -> Option<String> {
		let mut buf = [0; 1];
		let mut v :Vec<u8> = vec![];
		let mut size = self.reader.read(&mut buf).unwrap();
		if size == 0 {
			return None{}
		}
		loop {
			if size == 0 || char::from(buf[0]) == '\n' {
				return Some(String::from_utf8(v).unwrap())
			}
			v.push(buf[0]);
			size = self.reader.read(&mut buf).unwrap();
		}
	}

	pub fn next_vec<S: FromStr>(&mut self, size: u32) -> Vec<S> {
		let mut v: Vec<S> = vec![];
		for _ in 0..size {
			let token = self.next_str().unwrap();
			v.push(S::from_str(&token).ok().unwrap());
		}
		v
	}

	pub fn next_as<S: FromStr>(&mut self) -> Option<S> {
		if let Some(s) = self.next_str() {
			if let Ok(v) = S::from_str(&s) {
				return Some(v)
			}
		}
		None{}
	}

	pub fn next_i32(&mut self) -> Option<i32> {
		self.next_as::<i32>()
	}

	pub fn next_i64(&mut self) -> Option<i64> {
		self.next_as::<i64>()
	}

	pub fn next_f32(&mut self) -> Option<f32> {
		self.next_as::<f32>()
	}

	pub fn next_f64(&mut self) -> Option<f64> {
		self.next_as::<f64>()
	}

	fn skip_whitespace(&mut self, mut buf: &mut [u8]) -> Option<u8> {
		loop {
			if !char::from(buf[0]).is_whitespace() {
				return Some(buf[0])
			}
			let size = self.reader.read(&mut buf).unwrap();
			if size == 0 {
				return None{}
			}
		}
	}
}


Measured memory_bytes: 4352
s=input()
l=["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"]
ans=["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"]
for i in range(len(l)):
    if l[i] in s:
        ans.remove(l[i])
if ans==[]:
    print("None")
else:
    print(ans[0])

Measured memory_bytes: 3188
#include<cstdio>
#include<string>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>

using namespace std;

int main(void) {
	std::ios::sync_with_stdio(false);
	int n, k, a, ans;
	while(cin >> n >> k) {
		ans = 0;
		while(n--) {
			cin >> a;
			if(a >= k)
				ans++;
		}
		cout << ans << endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k;
  cin >> k;
  int a, b;
  cin >> a >> b;
  for(int i = a; i < b+1; i++){
    if(i % k == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main() {

	char* N = new char[3];
	cin >> N;

	if (N[0] == '7' || N[1] == '7' || N[2] == '7') {
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;

	return 0;
}

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

#define BR "\n"
#define SP " "

class UnionFind {
  private:
    vector<int> par;

  public:
    UnionFind(int n) {
      par.resize(n);
      for (int i = 0; i < n; i++) par[i] = i;
    }
    int root(int x) { return (par[x] == x) ? x : par[x] = root(par[x]); }
    void unite(int x, int y) { par[root(y)] = root(x); }
    bool same(int x, int y) { return root(x) == root(y); }
};

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

  UnionFind UF(N);

  for (int i = 0; i < Q; i++) {
    int a, b, c;
    cin >> a >> b >> c;

    if (a) {
      if (UF.same(b, c)) {
        cout << "1" << BR;
      } else {
        cout << "0" << BR;
      }
    } else {
      UF.unite(b, c);
    }
  }

  return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
int main(){
    int n,m,x,a,sml=0,big=0;
    cin>>n>>m>>x;
    rep(i,0,m){
        cin>>a;
        if(a<x)sml++;
        else big++;
    }
    cout<<min(sml,big);
}

Measured memory_bytes: 256
import java.util.*;
        public class Main {
        	public static void main(String[] args){
        		Scanner sc = new Scanner(System.in);
        		
        		int a = sc.nextInt();
        		int b = sc.nextInt();
        		int c = a + b/2;
              
        		System.out.println(c);
        	}
        }

Measured memory_bytes: 21716
#include<iostream>

using namespace std;

int main(void){
	int W,H,x,y,r;
	
	cin>>W>>H>>x>>y>>r;
	
	if(0>(x-r) || 0>(y-r) || W<(x+r) || H<(y+r)){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>
int main(){
  int flag1 = 1;
  int i,N,temp,c=0;
  int argv[100];

  scanf("%d",&N);

  for( i=0 ; i<N ; i++ ){
    scanf("%d",&argv[i]);
  }

  while(flag1){
    flag1 = 0;
    for( i=N-1 ; i>0 ; i-- ){
      if(argv[i] < argv[i-1]){
        temp = argv[i];
        argv[i] = argv[i-1];
        argv[i-1] = temp;
        c++;
        flag1 = 1;
      }
    }
  }

  for( i=0 ; i<N-1 ; i++)
    printf("%d ",argv[i]);

  printf("%d\n",argv[N-1]);
  printf("%d\n",c);

  return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
 
int main() {
  int n; cin>> n;
  vector<long long> a(101010);
  vector<long long> mi(101010);
  vector<long long> max(101010);
  for(int i=0;i<=n;i++){
    cin >> a[i];
  }
  if(n==0){
    if(a[0]==1){
      cout << "1";
    }
    else{
      cout <<"-1";
    }
  }
  else{
  mi[n]=a[n];
  max[n]=a[n];
  for(int i=n-1;i>=0;i--){
    max[i]=max[i+1]+a[i];
    if(mi[i+1]%2==0){
      mi[i]=mi[i+1]/2+a[i];
    }
    else{
      mi[i]=mi[i+1]/2+1+a[i];
    }
  }
  if(mi[0]>1||max[0]<1||a[0]!=0){
    cout << "-1" << endl;
  }
  else{
    long long ans=1;
    long long tmp=1;
    for(int i=1;i<n+1;i++){
      ans=ans+min(2*tmp,max[i]);
      tmp=min(2*tmp,max[i])-a[i];
    }
    cout << ans << endl;
  }
  }
}

Measured memory_bytes: 5644
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		double p[] = new double[n + 1];
		double q[] = new double[n + 1];
		for ( int i = 1; i <= n; i++ ) {
			p[i] = in.nextDouble();
			q[i] = 1 - p[i];
		}
		in.close();

		int row = n / 2 + 1;
		double dp[][] = new double[row + 1][n + 2];
		dp[1][1] = 1;
		for ( int r = 1; r <= row; r++ ) {
			for ( int c = 1; c <= n + 1; c++ ) {
				int idx = r + c - 2;
				dp[r][c] += dp[r][c - 1] * p[idx];
				dp[r][c] += dp[r - 1][c] * q[idx];
				if ( idx >= n ) break;
			}
		}

		double ans = 0.0;
		for ( int r = 1, c = n + 1; r <= row; r++, c-- ) {
			ans += dp[r][c];
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 68932
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int xx[MAXN],yy[MAXN],ata[MAXN],p[MAXN];
bool cmp1(int x,int y){
	return (xx[x]<xx[y]);
}
bool cmp2(int x,int y){
	return (yy[x]<yy[y]);
}
int tap(int x){
	if(x==ata[x])
		return x;
	return ata[x]=tap(ata[x]);	
}
bool merge(int x,int y){
	if((x=tap(x))==(y=tap(y)))
		return 0;
	ata[y]=x;return 1;	
}
int main(){
    //~ freopen("file.in", "r", stdin);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",xx+i,yy+i);
		p[i]=i;ata[i]=i;
	}
	vector<pair<int,PII> >edges;
	sort(p+1,p+n+1,cmp1);
	for(int i=1;i<n;i++)
		edges.pb(mp(xx[p[i+1]]-xx[p[i]],mp(p[i],p[i+1])));
	sort(p+1,p+n+1,cmp2);
	for(int i=1;i<n;i++)
		edges.pb(mp(yy[p[i+1]]-yy[p[i]],mp(p[i],p[i+1])));
	sort(all(edges));
	int ans=0;
	tr(it,edges)
		if(merge(it->ss.ff,it->ss.ss))
			ans+=it->ff;
	printf("%d\n",ans);	
	return 0;
}


Measured memory_bytes: 6516
import sys
from functools import lru_cache
sys.setrecursionlimit(1000000)

@lru_cache(maxsize = None)

def dp(n):
	if n == 0:
		return 0
	if n == 1:
		return abs(l[0] - l[1])
	return min(dp(n - 1) + abs(l[n] - l[n - 1]), dp(n - 2) + abs(l[n] - l[n - 2]))

n = int(input())
l = [int(i) for i in input().split(" ")]

print(dp(n - 1)) 

Measured memory_bytes: 265520
# include <bits/stdc++.h>
//# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define fors(i, s) for (int i = 0; s[i]; i++)
# define in freopen("input.txt", "r", stdin)
# define out freopen("output.txt", "w", stdout)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define mkp make_pair
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
 
using namespace std;
const ll mod = 1e17 + 7;
const int N = 5e2 + 7;

string a[25];
int used[25][25], ans;

int main()
{
	speed;
	int h, w;
	cin >> h >> w;
	forn( i, h ) {
		cin >> a[i];
	}
	forn( x1, h ) {
		forn( y1, w ) {
			if ( a[x1][y1] == '.' ) {
				forn( x2, h ) {
					forn( y2, w ) {
						if ( a[x2][y2] == '.' ) {
							if ( x1 == x2 && y1 == y2 ) {
								continue;
							}
							memset( used, 0, sizeof used );  
							queue < pair < int, pair < int, int > > > q;
							q.push( { 0, { x1, y1 } } );
							used[x1][y1] = 1;

							while ( !q.empty() ) {
								int w = q.front().fi;
								int x = q.front().se.fi;
								int y = q.front().se.se;
								q.pop();
								if ( x == x2 && y == y2 ) {
									ans = max( ans, w );
									break;
								}
								if ( x + 1 < h && a[x + 1][y] == '.' && !used[x + 1][y] ) {
									used[x + 1][y] = 1;
									q.push({w + 1, {x + 1, y}});
								}
								if ( x - 1 >= 0 && a[x - 1][y] == '.' && !used[x - 1][y] ) {
									used[x - 1][y] = 1;
									q.push({w + 1, {x - 1, y}});
								}
								if ( y + 1 >= 0 && a[x][y + 1] == '.' && !used[x][y + 1] ) {
									used[x][y + 1] = 1;
									q.push({w + 1, {x, y + 1}});
								}
								if ( y - 1 >= 0 && a[x][y - 1] == '.' && !used[x][y - 1] ) {
									used[x][y - 1] = 1;
									q.push({w + 1, {x, y - 1}});
								}
							}
						}
					}
				}
			}
		} 
	}
	cout << ans << endl;
	time;
}


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

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

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

int main(){
    int A, B;
    cin >> A >> B;

    int diff = B - A;
    int result = 0;

    for(int i = 1; i < diff; i ++){
        result += i;
    }
    result -= A;
    
    cout << result << endl;  
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
   char s[4];
   scanf("%s",s);
   if(strcmp(s,"abc")==0||strcmp(s,"acb")==0||strcmp(s,"bac")==0||strcmp(s,"bca")==0||strcmp(s,"cab")==0||strcmp(s,"cba")==0){
   printf("Yes\n");
   }else{
   printf("No\n");
   }
   return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3005,p=998244353,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int A,B,C,D,f[N][N],g[N][N];
void check(int &x,int y){if ((x+=y)>=p) x-=p;}
int main(){
//	freopen("a.txt","r",stdin);
	A=read();B=read();C=read();D=read();
	f[A][B]=1;
	for (int i=A;i<=C;i++)
	for (int j=B+(i==A);j<=D;j++){
		f[i][j]=((ll)f[i-1][j]*j+g[i-1][j])%p;
		g[i][j]=(ll)(g[i][j-1]+f[i][j-1])*i%p;
	}
	int ans=(f[C][D]+g[C][D])%p;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 74100
A, B, C = map(int, input().split())
K = int(input())
cnt = 0
ans = False
while True:
  if cnt > K:
    break

  if B > A and C > B:
    ans = True
    break

  if B <= A:
    B *= 2
    cnt += 1
    continue
    
  if C <= B:
    C *= 2
    cnt += 1

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

Measured memory_bytes: 9188
N, M = map(int, input().split())
road = []
for i in range(M):
  a, b, c = map(int, input().split())
  road.append((a-1, b-1, -c))

INF = 10**15
d = [INF] * N
d[0] = 0
def bellman_ford():
  global d
  for i in range(N):
    for a, b, c in road:
      d[b] = min(d[b], d[a] + c)

bellman_ford()
for a, b, c in road:
  new_d = d[a] + c
  if new_d < d[b]:
    d[b] = - float('inf')

bellman_ford()
if d[-1] > -float('inf'):
  print(int(-d[-1]))
else:
  print('inf')

Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

typedef long long ll;
const int N=1009;
const int md=1e9+7;

int h,w,vc,hc,bc;
char g[N][N];
ll k;

struct matrix
{
	int lena,lenb;
	ll a[3][3];
	matrix(int _a=0,int _b=0)
	{
		lena=_a,lenb=_b;
		memset(a,0,sizeof(a));
	}
	
	matrix operator * (matrix o)
	{
		matrix ret(lena,o.lenb);
		for(int i=0;i<lena;i++)
			for(int j=0;j<o.lenb;j++)
			{
				for(int k=0;k<lenb;k++)
					ret.a[i][j]+=a[i][k]*o.a[k][j]%md;
				ret.a[i][j]%=md;
			}
		return ret;
	}

	inline void e()
	{
		for(int i=0;i<lena;i++)
			a[i][i]=1;
	}

	matrix operator ^ (ll b)
	{
		matrix ret(lena,lenb);
		ret.e();
		while(b)
		{
			if(b&1)
				ret=ret*(*this);
			(*this)=(*this)*(*this);
			b>>=1;
		}
		return ret;
	}
};

inline ll qpow(ll a,ll b)
{
	ll ret=1;
	while(b)
	{
		if(b&1)
			ret=ret*a%md;
		a=a*a%md;
		b>>=1;
	}
	return ret;
}

inline ll count(int ty)
{
	ll ret=0;
	if(ty==0)
	{
		for(int i=1;i<=h;i++)
			for(int j=1;j<w;j++)
				if(g[i][j]=='#' && g[i][j+1]=='#')
					ret++;
	}
	else
	{
		for(int i=1;i<h;i++)
			for(int j=1;j<=w;j++)
				if(g[i][j]=='#' && g[i+1][j]=='#')
					ret++;
	}
	return ret;
}

int main()
{
	scanf("%d%d%lld",&h,&w,&k);
	for(int i=1;i<=h;i++)
	{
		scanf("%s",g[i]+1);
		
		for(int j=1;j<=w;j++)
			if(g[i][j]=='#')
				bc++;
		if(g[i][1]=='#' && g[i][w]=='#')
			hc++;
	}

	for(int i=1;i<=w;i++)
		if(g[1][i]=='#' && g[h][i]=='#')
			vc++;

	if(hc && vc)
		return puts("1"),0;
	else if(!hc && !vc)
		return printf("%lld\n",qpow(bc,k-1)),0;
	else
	{
		matrix base(2,2);
		base.a[0][0]=bc;
		base.a[0][1]=md-count(hc?0:1);
		base.a[1][0]=0;
		base.a[1][1]=(vc?vc:hc);
		base=base^(k-1);
		printf("%lld\n",(base.a[0][0]+base.a[0][1])%md);
	}
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using Graph = vector<vector<int>>;
using ll = long long;
using p = pair<int, int>;

int main()
{
    int n, x, t;
    cin >> n >> x >> t;

    int ans = (n + (x - 1)) / x * t;

    cout << ans << endl;
}

Measured memory_bytes: 3632
n, k = map(int, input().split())
h = [int(i) for i in input().split()]

def chmin(a, b):
    if a > b:
        return b
    else:
        return a
f_inf = pow(10,9)+99

dp = [f_inf] * (10**5+10)
dp[0] = 0
for i in range(1, n):
    for j in range(1, k+1):
        if i - j >= 0:
            dp[i] = chmin(dp[i], dp[i-j]+ abs(h[i] - h[i - j]))
print(dp[n-1])

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    int cnt = n-1;
    rep(i, n) {
        if (s[i] == 'W') {
            for(int j = cnt; j >= i; j--) {
                cnt--;
                if (j == i) {
                    cout << ans << endl;
                    return 0;
                }
                if (s[j] == 'R') {
                    ans++;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

typedef struct 
{
    unsigned int left;
    unsigned int area;
}AreaInfo_t;

#define CalcArea(x,y) ((x) - (y))

stack<unsigned int> ArealeftIdxStack;
vector<AreaInfo_t> AreaInfoStack;

int Decision(char, unsigned int);
void Fusion(AreaInfo_t);
void PrintArea(void);

int main(void){
    char ch;
    unsigned int idx = 0;
    unsigned int total = 0;
    
    while(cin >> ch)
    {
        total += Decision(ch, idx);
        idx++;
    }
    
    cout << total << endl;
    PrintArea();
    
    return 0;
    
}

int Decision(char ch, unsigned int idx)
{
    switch(ch)
    {
        case '\\':
            ArealeftIdxStack.push(idx);
            break;
        case '/':
            if(ArealeftIdxStack.empty())
            {
                break;
                
            }
            AreaInfo_t area;
            area.left = ArealeftIdxStack.top();
            area.area = CalcArea(idx, ArealeftIdxStack.top());
            Fusion(area);
            ArealeftIdxStack.pop();
            return area.area;
        case '_':
            // pass
            break;
        default:
            return 0;
    }

    return 0;
}

void Fusion(AreaInfo_t tInfo)
{
    
    while(1)
    {
        if(AreaInfoStack.empty())
        {
            AreaInfoStack.push_back(tInfo);
            break;
        }
        
        AreaInfo_t tmp = AreaInfoStack.back();
        if(tmp.left > tInfo.left)
        {
            tInfo.area += tmp.area;
            AreaInfoStack.pop_back();
        }
        else
        {
            AreaInfoStack.push_back(tInfo);
            break;
        }
    }
    return;
}

void PrintArea()
{
    cout << AreaInfoStack.size();
    for(vector<AreaInfo_t>::iterator it = AreaInfoStack.begin(); it != AreaInfoStack.end(); it++)
    {
        cout << ' ' <<  it->area;
    }
    cout << endl;

    return;
}



Measured memory_bytes: 3240
N, M = map(int, input().split())
R = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    R[a - 1].append(b - 1)
    R[b - 1].append(a - 1)
Parents = [[] for i in range(N)]
C = 0

def func(x, c):
    global C
    c += 1
    last = True
    for r in R[x]:
        if r in Parents[x]:
            continue
        for i in range(len(Parents[x])):
            Parents[r].append(Parents[x][i])
        Parents[r].append(x)
        last = False
        func(r, c)
        for i in range(len(Parents[x])):
            Parents[r].remove(Parents[x][i])
        Parents[r].remove(x)
    if last:
        if c == N:
            C += 1

func(0, 0)
print(C)

Measured memory_bytes: 42716
E = 10 ** -10
def check(lst):
  x1, y1, x2, y2, x3, y3, x4, y4 = lst
  vabx, vaby = x2 - x1, y2 - y1
  vcdx, vcdy = x4 - x3, y4 - y3
  if abs(vabx * vcdy - vcdx * vaby) < E:
    return True
  else:
    return False

n = int(input())
for _ in range(n):
  plst = list(map(float, input().split()))
  print("YES" if check(plst) else "NO")


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

int main(){
    int N;
    cin >> N;
    bool approved = true;
    for(int i =0; i < N; i++){
        int a;
        cin >> a;
        if(a%2 ==0&& a%3 != 0 && a%5 !=0) approved = false;
    }
    if(approved) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main(){
    int n;
    cin >> n;
    int t = n / 100;
    if (n <= t * 111)cout << t * 111 << endl;
    else cout << t * 111 + 111 << endl;
    return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI p(n);

  rep(i,n) cin >> p[i];
  map<int,int> mp;
  rep(i,n){
    mp[p[i]] = mp[p[i]-1] + 1;
  }
  int ans = 0;
  for(auto x: mp){
    ans = max(x.second,ans);
  }
  cout << n - ans << endl;
  return 0;
}


Measured memory_bytes: 10368
n = int(input())
A = list(map(int, input().split()))
for i in range(n):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(*A)



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

int main(){
	int n,m,x;
	cin>>n>>m>>x;
	int front=0,before=0;
	for(int i=1;i<=m;++i){
		int a;cin>>a;
		if(a<x){
			front++;
		}else if(x<a){
			before++;
		}
	}
	cout<<min(front,before)<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include <iomanip>
#include <iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include <random>
#include <chrono>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int p[50];
void swap(int i, int j) {
	int tmp = p[i];
	p[i] = p[j];
	p[j] = tmp;
}

int main() {
	int n;
	cin >> n;
	int cnt=0;
	rep(i, n) {
		cin >> p[i];
		if (p[i]!=i+1) {
			cnt++;
		}
	}
	if (cnt <= 2) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define LL long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
int n,m;
vector<PII> v[60];
int res=0,t;
bool visit[60];
void dfs(int x)
{
	//cout <<x<<" ##\n";
	visit[x]=1;
	for (int i=0;i<v[x].size();i++)
	{
		int xi=v[x][i].first;
		int yi=v[x][i].second;
		if (yi==t) continue;
		if (visit[xi]) continue;
		dfs(xi);
	}
}
int main()
{
	cin >>n>>m;
	for (int i=0;i<m;i++)
	{
		int x,y;
		cin >>x>>y;
		x--,y--;
		v[x].push_back(MP(y,i));
		v[y].push_back(MP(x,i));
	}
	for (int i=0;i<m;i++)
	{
		t=i;
		fill(visit,visit+n,0);
		//cout <<i<<" ############\n";
		dfs(0);
		if (count(visit,visit+n,0)) res++;
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

// ダイクストラ法
// 参照：蟻本　p97
// O(mlogn)
struct edge{int to,cost;};
typedef pair<int,int> P; // firstは最短距離、secondは頂点の番号

int n; // 頂点の数
vector<edge> G[100010];
int d[100010];

void dijkstra(int s){
    priority_queue<P,vector<P>, greater<P>> que;
    fill(d,d+n,INF);
    d[s]=0;
    que.push(P(0,s));

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

int main(){
    cin >> n;
    int m; // 辺の数
    cin >> m;
    int r;
    cin>>r;
    for (int i=0; i<m; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        edge e = {b, c};
        G[a].push_back(e);
    }
    dijkstra(r); // 頂点0からの距離を求める

    rep(i,n){
        if(d[i]==INF) cout<<"INF"<<endl;
        else cout<<d[i]<<endl;
    }
}


 


Measured memory_bytes: 13068
#include <stdio.h>

int main(void)
{
    int time,h,m,s;
    
    scanf("%d",&time);
    h=time/3600;
    time%=3600;
    
    m=time/60;
    time%=60;
    
    s=time;
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}


Measured memory_bytes: 2112
#include<queue>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k;
  int n,p;
  bool b[3][3][3][3][3][3][3][3][3][3];
  string s;
  queue<pair<string,int> > c;
  while(cin>>s&&s[0]!='0'){
    n=s.length();
    for(i=0;i<10-n;i++)
      s+=(char)0;
    memset(b,0,59049);
    while(c.empty()==0)
      c.pop();
    c.push(make_pair(s,0));
    while(c.empty()==0){
      s=c.front().first;
      p=c.front().second;
      for(i=0;i<n;i++)
	s[i]+=3;
      j=0;
      for(i=0;i<n;i++){
	if(s[i]>2){
	  for(k=i+1;k<n;k++){
	    if(s[k]==s[i])
	      s[k]=j;
	  }
	  s[i]=j;
	  j++;
	}
      }
      for(i=1;i<n&&s[i-1]==s[i];i++);
      if(i==n)
	break;
      c.pop();
      bool* q=&b[(int)s[0]][(int)s[1]][(int)s[2]][(int)s[3]][(int)s[4]][(int)s[5]][(int)s[6]][(int)s[7]][(int)s[8]][(int)s[9]];
      if(*q==0){
	*q=1;
	for(i=1;i<n;i++){
	  if(0){
	  }else if(s[i-1]<s[i]){
	    if(0){
	    }else if(s[i]-s[i-1]==1){
	      s[i-1]=(s[i-1]+2)%3;
	      s[i]=(s[i]+1)%3;
	      c.push(make_pair(s,p+1));
	      s[i-1]=s[i-1]-2+(s[i-1]-2<0?3:0);
	      s[i]=s[i]-1+(s[i]-1<0?3:0);
	    }else if(s[i]-s[i-1]==2){
	      s[i-1]=(s[i-1]+1)%3;
	      s[i]=(s[i]+2)%3;
	      c.push(make_pair(s,p+1));
	      s[i-1]=s[i-1]-1+(s[i-1]-1<0?3:0);
	      s[i]=s[i]-2+(s[i]-2<0?3:0);
	    }
	  }else if(s[i-1]>s[i]){
	    if(0){
	    }else if(s[i-1]-s[i]==1){
	      s[i]=(s[i]+2)%3;
	      s[i-1]=(s[i-1]+1)%3;
	      c.push(make_pair(s,p+1));
	      s[i]=s[i]-2+(s[i]-2<0?3:0);
	      s[i-1]=s[i-1]-1+(s[i-1]-1<0?3:0);
	    }else if(s[i-1]-s[i]==2){
	      s[i]=(s[i]+1)%3;
	      s[i-1]=(s[i-1]+2)%3;
	      c.push(make_pair(s,p+1));
	      s[i]=s[i]-1+(s[i]-1<0?3:0);
	      s[i-1]=s[i-1]-2+(s[i-1]-2<0?3:0);
	    }
	  }	    
	}
      }
    }
    if(c.empty())
      cout<<"NA"<<endl;
    else
      cout<<p<<endl;
  }
  return 0;
}

Measured memory_bytes: 1300
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);


void main() {
    int n = read();
    int[] a;
    foreach (i; 0..n)
        a ~= read();
    a.sort();
    writeln(a.sum - a[$ - 1] / 2);
}


Measured memory_bytes: 380
n = int(input())
L = []
for i in range(n):
    L.append(input())
    
from collections import Counter
L = Counter(L)
L =L.most_common()

li = []
for i in range(len(L)):
    if L[i][1] == L[0][1]:
        li.append(L[i][0])
li.sort()

for i in range(len(li)):
    print(li[i])

Measured memory_bytes: 43504
/**
   Solution by Abil
**/
# include <bits/stdc++.h>

# define fr first
# define sc second
# define pb push_back
# define mk make_pair
# define sz(s) s.size()
# define all(s) s.begin(),s.end()
# define int long long

using namespace std;

const long long N = (1e6 + 10);
const long long mod = (1e9 + 7);
const long long inf = (1e9 + 7);

int dp[2][N];
vector<int > v[N];
void dfs(int x,int pr){
    dp[1][x] = 1;
    dp[0][x] = 1;
    for(int i : v[x]){
      if(i != pr){
        dfs(i,x);
      }
      if(i != pr){
        dp[1][x] *= dp[0][i];
        dp[0][x] *= dp[0][i] + dp[1][i];
        dp[1][x] %= mod;
        dp[0][x] %= mod;
      }
    }
}
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n, x, y;
    cin >> n;
    for(int i = 1;i <= n - 1; i++){
      cin >> x >> y;
      v[x].pb(y);
      v[y].pb(x);
    }
    dfs(1, -1);
    if(n == 1){
      cout << 2;
      return 0;
    }
    cout << (dp[1][1] + dp[0][1]) % mod;
}


Measured memory_bytes: 36992
import heapq
n=int(input())
a=[int(i) for i in input().split()]
f=a[:n]
l=[-i for i in a[2*n:]]
heapq.heapify(f)
heapq.heapify(l)
fs=[0]*(n+1)
ls=[0]*(n+1)
fs[0]=sum(f)
ls[n]=-sum(l)

for i in range(n):
    c=a[n+i]
    m=heapq.heappushpop(f,c)
    fs[i+1]=fs[i]+c-m

for i in range(n):
    c=a[2*n-1-i]
    m=heapq.heappushpop(l,-c)
    ls[n-i-1]=ls[n-i]+c+m

ans=fs[0]-ls[0]
for k in range(n+1):
    ans=max(ans,fs[k]-ls[k])
print(ans)


Measured memory_bytes: 38292
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<57;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

ll n,m;
vl x,y;

int main(){
	cin>>n>>m;
	x=vl(n);
	y=vl(m);
	for(int i=0;i<n;i++) cin>>x[i];
	for(int i=0;i<m;i++) cin>>y[i];
	ll tmp1=0,tmp2=0;
	for(int i=1;i<n;i++){
		(tmp1+=i*(n-i)*(x[i]-x[i-1]))%=mod;
	}
	for(int i=1;i<m;i++){
		(tmp2+=i*(m-i)*(y[i]-y[i-1]))%=mod;
	}
	cout<<tmp1*tmp2%mod<<endl;
}

Measured memory_bytes: 1792
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a == b){
			System.out.println(c);
		} else if (b == c){
			System.out.println(a);
		} else {
			System.out.println(b);
		}

	}
}


Measured memory_bytes: 23764
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <inttypes.h>

int main(void){
	int a,b,c,k;
	int sum=0;
	int i;

	scanf("%d %d %d",&a,&b,&c);
	scanf("%d",&k);
	if(a>=b){
		if(a>=c){
			for(i=0;i<k;i++){
				a=a*2;
			}
		}else if(c>a){
			for(i=0;i<k;i++){
				c=c*2;
			}
		}
	}else{
		if(b>=c){
			for(i=0;i<k;i++){
				b=b*2;
			}
		}else if(c>b){
			for(i=0;i<k;i++){
				c=c*2;
			}
		}
	}
	sum=a+b+c;
	printf("%d",sum);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:



int main(void){
	int n;
	cin >> n;
	vector<string> s(n);
	rep(i, n) cin >> s[i];
	int ans = 0;

	int a = 0, ba = 0, b = 0;
	rep(i, n){
		const int m = s[i].size();
		rep(j, m - 1) if(s[i][j] == 'A' and s[i][j + 1] == 'B') ans++;

		int bit = 0;
		if(s[i].back() == 'A') bit|= 1;
		if(s[i].front() == 'B') bit |= 2;

		if(bit == 1) a++;
		if(bit == 2) b++;
		if(bit == 3) ba++;
	}

	if(a > 0 and b > 0){
		ans += min(a, b) + ba;
	} else if(a > 0){
		ans += max(0, ba);
	} else if(b > 0){
		ans += max(0, ba);
	} else {
		ans += max(0, ba - 1);
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N = int(input())
import math
n = math.sqrt(N)
n = int(n)+1
c = N
for i in range(1,n):
    if N % i == 0:
        c = int(N/i)

s = str(c)
print(len(s))





Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi; 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int mod = 1e9+7;
const int maxn = 2e5+10;
const int inf = 0x3f3f3f3f;
int book[maxn];
int pos[30],pre[30];
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	int n;
	cin>>n;
	rep(i,1,n) {
		cin>>book[i];
	}
	ll ans=0;
	rep(i,1,n) {
		int num=i;
		rep(j,0,20) {
			int xx=1<<j;
			if(xx&book[i]) {
				num=min(num,i-pos[j]);
				pre[j]=pos[j];
				pos[j]=i;
			}
			else {
				num=min(num,i-pre[j]);
			} 
		}
		ans+=num;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int32_t main()
{
	c_p_c();
	int n, x, y; cin >> n >> x >> y;
	vi ans(n, 0);
	int l = y - x + 1;

	for (int i = 1; i <= n; ++i)
	{
		for (int j = i + 1; j <= n; ++j)
		{
			int cur = j - i;

			cur = min(cur, abs(x - i) + abs(j - y) + 1);
			ans[cur]++;
		}
	}

	for (int i = 1; i < n; ++i)
		cout << ans[i] << '\n';
	//cout << '\n';

	return 0;
}

Measured memory_bytes: 256
n = int(input())
print(0, flush=True)
syo = 0
s = input()
if s == "Vacant":
  exit()
syos = s
dai = n-1
print(n-1, flush=True)
s = input()
dais = s
if s == "Vacant":
  exit()
for _ in range(18):
  mid = (dai+syo)//2
  print(mid, flush=True)
  s = input()
  if s == "Vacant":
    exit()
  if ((mid - syo)%2 == 0 and s != syos) or ((mid - syo)%2 == 1 and s == syos):
    dai = mid
    dais = s
  else:
    syo = mid
    syos = s

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
#define np basic_string::npos
int main(void){
    int n,in;
    vector<int> a;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>in;
        a.push_back(in);
    }
    ll ans=0,mm=INT_MAX;
    for(int i=-100;i<=100;i++){
        ans=0;
        for(int j=0;j<n;j++){
            ans+=(a[j]-i)*(a[j]-i);
        }
        mm=min(mm,ans);
    }
    cout<<mm<<endl;
}

Measured memory_bytes: 256