akhauriyash/Code-Regression huggingface dataset:
function Main(input) {
    input = input.split("\n");
    var nm = input[0].split(" ");
    const n = parseInt(nm[0], 10);
    const m = parseInt(nm[1], 10);
    var series = input[1].split(" ");
    series = series.map(str => parseInt(str, 10));
    series.sort(function(a,b){
        return (a-b);
    });
    var ds = [];
    for(var i = 1;i<m;i++){
        ds.push(series[i] - series[i-1]);
    }
    ds.sort(function(a,b){
        return (b-a);
    });
    for(var k = 0; k < n-1; k++){
        ds[k] = 0;
    }
    var sum = ds.reduce(function(p,c){return p+c});
    console.log(sum);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 28304
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long int n,k;cin>>n>>k;
	if(k%2)
	{
		cout<<(n/k)*(n/k)*(n/k)<<endl;
		return 0;
	}
	else
	{
		long long int kk=k/2;
		cout<<(n/k)*(n/k)*(n/k)+(n/kk-n/k)*(n/kk-n/k)*(n/kk-n/k)<<endl;
		return 0;
	}
}


Measured memory_bytes: 888
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;

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

static class ABC179B {

	public void solve(int testNum, FastInput in, PrintWriter out) {
		
		int n = in.nextInt();
		int [][]a = in.nextInt2DArray(n, 2);
		
		int []sum = new int [n+1];
		
		for(int i = 0 ; i < n ;i++) {
			if(a[i][0] == a[i][1]) {
				sum[i+1] = sum[i] + 1; 
			}
			else {
				sum[i+1] = 0;
			}
		}
		
		boolean f = false;

		for(int i = 1; i <= n ; i++) {
			if(sum[i] >= 3) {
				f = true;
			}
		}
		
		if(f){
			out.println("Yes");
		}
		else {
			out.println("No");
		}
	}

}
static class FastInput{
	private final BufferedReader in;
	private String[] buff;
	private int index = 0;
	
	public FastInput(InputStream is) {
		in = new BufferedReader(new InputStreamReader(is));
	}
	String nextLine() {
		try {
			return in.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	String next() {
		while (buff == null || index >= buff.length) {
			buff = nextLine().split(" ");
			index = 0;
		}
		return buff[index++];
	}
	int nextInt() {
		return Integer.parseInt(next());
	}
	
	long nextLong() {
		return Long.parseLong(next());
	}
	
	Double nextDouble() {
		return Double.parseDouble(next());
	}
	
	BigInteger nextBigInteger() {
		return new BigInteger(next());
	}
	
	BigDecimal nextBigDecimal() {
		return new BigDecimal(next());
	}
	
	public int[] nextIntArray(final int n) {
		final int[] res = new int [n];
		
		for(int i = 0 ; i < n ;i++) {
			res[i] = nextInt();
		}
		return res;
	}
	
	public long[] nextLongArray(final int n) {
		final long[] res= new long [n];
		
		for(int i = 0 ; i < n ;i++) {
			res[i] = nextLong();
		}
		return res;
	}
	
	public double[] nextDoubleArray(final int n ) {
		final double[] res = new double [n];
		
		for(int i = 0 ; i < n ;i++) {
			res[i] = nextDouble();
		}
		return res;
	}
	
	
	public int[][] nextInt2DArray(final int n , final int m){
		int [][]res = new int [n][m];
		
		for(int i = 0 ; i < n ;i++) {
			for(int j = 0 ; j < m ;j++) {
				res[i][j] = nextInt();
			}
		}
		return res;
	}
	public long[][] nextLong2DArray(final int n , final int m){
		long [][]res = new long [n][m];
		
		for(int i = 0 ; i < n ;i++) {
			for(int j = 0 ; j < m ;j++) {
				res[i][j] = nextLong();
			}
		}
		return res;
	}
	
	public char[][] nextChar2DArray(final int n){
		char [][]res = new char [n][];
		
		for(int i = 0 ; i < n ;i++) {
			String s = next();
			res[i] = s.toCharArray();
		}
		
		return res;
	}
}
}




Measured memory_bytes: 33000
#include<iostream>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
using namespace std;
using ll=long long;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}





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

  int A, B; cin >> A >> B;
  if(A==B) cout<<2*A<<endl;
  else if(A>B) cout<<2*A-1<<endl;
  else cout<<2*B-1<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    char str[1200];
    int num[26];
    int i,j,x;
    for(i=0;i<26;i++) num[i]=0;
    i=0;
    while(scanf("%c",&str[i])!=EOF){
        i++;
    }
    
    for(j=0;j<i;j++){
        if(str[j]>='A'&&str[j]<='Z') {
            x=str[j]-'A';
            num[x]++;
        }
        else if(str[j]>='a'&&str[j]<='z') {
            x=str[j]-'a';
            num[x]++;
        }
    }
    for(i=0;i<26;i++){
        printf("%c : %d\n",'a'+i,num[i]);
    }

    return 0;
}


Measured memory_bytes: 2104
def gcd(a, b):
    if (b == 0):
        return a
    else:
        return gcd(b, a % b)


def divisor(n):
    l = []
    i = 1
    while True:
        if n % i == 0:
            l.append(i)
            if i * i != n:
                l.append(n / i)
        i += 1
        if i * i > n:
            break
    return sorted(l)


n = int(input())
a = list(map(int, input().split()))

gcd_of_all = gcd(a[0], a[1])
for i in range(2, n):
    gcd_of_all = gcd(gcd_of_all, a[i])

if gcd_of_all != 1:
    print("not coprime")
    exit()

s = set()

for i in range(n):
    l = divisor(a[i])
    for j in range(len(l)):
        if l[j] == 1:
            continue
        if l[j] in s:
            print("setwise coprime")
            exit()
        else:
            s.add(l[j])

print("pairwise coprime")


Measured memory_bytes: 181432
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vi money;
    money.push_back(1);
    
    //6
    int six = 6;
    while(six <= 100000){
        money.push_back(six);
        six *= 6;
    }

    //9
    int nine = 9;
    while(nine <= 100000){
        money.push_back(nine);
        nine *= 9;
    }

    money.push_back(INF);
    sort(money.begin(), money.end(), greater<int>());

    vvi dp(money.size(), vi(100100, INF));

    rep(i, money.size()) dp[i][0] = 0;

    //printf("%d\n", money.size());
    rrep(i, money.size()-1){//i: 1~12
        //printf("%d:%d\n", i-1, dp[i-1][99873]);
        rep(j, 100010){//j: 0~100000

            //自分と上を見比べて小さいほうにする
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            //到達できるところから足して100000を越えなければそこに元の値+1を書き込む
            //書き込むとき，もとからあるやつのほうが小さければ変えない
            if(dp[i][j]!=INF){
                int nj = j + money[i];
                if(nj > 100000) continue;
                dp[i][nj] = min(dp[i][nj], dp[i][j]+1);
                //cout << i << ":" << nj << ":"<< dp[i][nj] << endl;
                //if(nj == 99873) printf("abcdefg%d\n", dp[i][99873]);
            }

        }
    }

    /*
    rep(i, money.size()){
        cout << money[i] << endl;
    }
    */

    cout << dp[money.size()-1][n] << endl;

    return 0;
}

Measured memory_bytes: 5760
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace AtCoder.D
{
    internal static class CR
    {
        public static string GetText() { return Console.ReadLine(); }
        public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long GetLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
    }

    public class Program
    {
        public static long N { get; private set; }
        public static List<long> A { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            N = CR.GetLong();
            A = CR.GetLongs();

            var combinationDic = Enumerable.Range(0, 200000)
                .Select((x, i) => new { Value = (long)x * (x - 1) / 2, Index = i })
                .ToDictionary(x => x.Index, y => y.Value);

            var fullCount = 0L;
            var valueCountDic = new Dictionary<long, long>();
            //foreach (var a in A)
            //{
            //    if (valueCountDic.ContainsKey(a)) continue;
            //    var count = A.Count(x => x == a); // TODO
            //    valueCountDic.Add(a, count);
            //    //fullCount += combinationDic[count];
            //}

            foreach (var a in A)
            {
                if (!valueCountDic.ContainsKey(a))
                {
                    valueCountDic.Add(a, 0);
                }
                //var count = A.Count(x => x == a); // TODO
                valueCountDic[a]++;
            }

            fullCount = valueCountDic.Select(x => combinationDic[(int)x.Value]).Sum();

            var sb = new StringBuilder();
            foreach (var a in A)
            {
                var count = valueCountDic[a];
                if (count == 1)
                {
                    sb.AppendLine(fullCount.ToString());
                }
                else
                {
                    var c = fullCount
                        - combinationDic[(int)count]
                        + combinationDic[(int)count - 1];
                    sb.AppendLine(c.ToString());
                }
            }

            return sb.ToString().Trim();
        }
    }
}


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

vector<int> edge[100005];

int dfs(int u)
{
    vector<int> vt;
    for(int v : edge[u])
    {
        vt.push_back(dfs(v));
    }
    if(edge[u].empty()) return 0;
    sort(vt.rbegin(), vt.rend());
    if(vt.size()==1) return vt[0]+1;
    int ans = vt[0]+1;
    for(int i = 1; i<vt.size(); i++)
        ans = max(ans, vt[i] + i + 1);
    return ans;
}
int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 0; i<n-1; i++)
    {
        int p;
        scanf("%d", &p);
        edge[p].push_back(i+2);
    }
    cout << dfs(1);

    return 0;
}


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

void Main(void) {
  int a, b, c, k;

  cin >> a >> b >> c >> k;

  if (a >= k) {
    cout << k << endl;
  } else if (a + b >= k) {
    cout << a << endl;
  } else {
    cout << a - (k - b - a) << endl;
  }

  return;
}

int main() {
  Main();

  return 0;
}

Measured memory_bytes: 3636
using System.Linq;
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = Array.ConvertAll(line, int.Parse).ToList();
            if (!CheckTri(a.Sum())) { Console.WriteLine(-1);  goto next; }
            var ans = GetTri(a);
            Console.WriteLine(ans);
            next:;
        }
    }
    public static bool CheckTri (int a)
    {
        var x =(int) Math.Sqrt(8 * a + 1);
        var k = (x - 1) / 2;
        return k * (k + 1) / 2 == a;
    }
    public static int GetTri  (List<int> a)
    {
        var count = 0;
        while (count <= 10000)
        {
            if (CheckList(a)) return count;
            var ca = a.Count();
            for (int i = 0; i < ca; i++) a[i]--;
            a.Add(ca);
            a.RemoveAll(x => x == 0);
            count++;
        }
        return -1;
    }
    public static bool CheckList (List<int > a)
    {
        var ap  = a[0];
        if (ap != 1) return false;
        for (int i = 1; i < a.Count(); i++)
            if (a[i] != ap + 1) return false;
            else ap = a[i];
        return true;
    }
}

Measured memory_bytes: 9676
#[allow(unused_imports)]
use {
    itertools::Itertools,
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::io::Write,
    std::ops::*,
};

#[allow(unused_macros)]
macro_rules! dbg { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; }

#[fastout]
fn main() {
    input! {
        s: Chars,
    }
    print!("{}", s.iter().format(""));
    if s[s.len()-1] == 's' {
        println!("es");
    } else {
        println!("s");
    }
}


Measured memory_bytes: 2188
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<int, int>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
ll MOD = 1000000007;

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

  ll n;
  cin >> n;
  vector<ll> s(n), d(n), v(n);
  REP(i, n) cin >> s[i] >> d[i] >> v[i];

  vector<ll> weight(1<<n);
  REP(i, 1<<n) {
    REP(j, n) {
      if(i&1<<j) weight[i] += v[j] * 20;
    }
  }

  auto dp = make_v<double>(1<<n, n);
  fill_v(dp, LLINF);
  auto prev = make_v<ll>(1<<n, n);
  REP(i, n) {
    dp[1<<i][i] = 0;
    prev[1<<i][i] = -1;
  }
  REP(i, 1<<n) REP(j, n) {
    REP(k, n) {
      if(!(i&1<<k)) {
        double ndist = dp[i][j] + (70+weight[i]) / 2000.0 * abs(d[j]-d[k]);
        if(dp[i|1<<k][k] > ndist) {
          dp[i|1<<k][k] = ndist;
          prev[i|1<<k][k] = j;
        }
      }
    }
  }

  ll idx = -1;
  double mi = LLINF;
  REP(i, n) {
    if(mi > dp[(1<<n)-1][i]) {
      mi = dp[(1<<n)-1][i];
      idx = i;
    }
  }

  vector<ll> path;
  ll mask = (1<<n)-1, now = idx;
  while(now != -1) {
    path.push_back(now);
    ll tmp = now;
    now = prev[mask][now];
    mask ^= 1<<tmp;
  }
  reverse(ALL(path));

  REP(i, path.size()) {
    cout << s[path[i]];
    if(i != path.size()-1) cout << " ";
  }
  cout << endl;

  return 0;
}



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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int c[3][3];

int main(){
	int d[3] = {101,101,101};
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			cin >> c[i][j];
			d[i] = min(d[i], c[i][j]);
		}
	}
	
	bool b = 0;
	for(int i = 0; i <= d[0]; i++){
		for(int j = 0; j <= d[1]; j++){
			for(int k = 0; k <= d[2]; k++){
				if(c[0][0]-i == c[1][0]-j && c[2][0]-k == c[0][0]-i){
					if(c[0][1]-i == c[1][1]-j && c[2][1]-k == c[0][1]-i){
						if(c[0][2]-i == c[1][2]-j && c[2][2]-k == c[0][2]-i){
							b = 1;
						}
					}
				}
			}
		}
	}
	
	if(b) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

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

long long d[51][51];
long long num[51];

void combi(int n){

    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            if(i==j || j==0) d[i][j]=1;
            else d[i][j] = d[i-1][j-1] + d[i-1][j];
        }
    }
}

int main(int argc, const char * argv[]) {
   
    int n,a,b;
    
    scanf("%d %d %d",&n,&a,&b);
    
    for(int i=0;i<n;i++){
        scanf("%lld",&num[i]);
    }
    combi(n);
    sort(num,num+n);
    reverse(num, num+n);
    
    double sum = 0.0;
    double sum_average;
    for(int i=0;i<a;i++){
        sum+=num[i];
    }
    sum_average = sum/a;
    int same_cnt = 0;
    int need_cnt = 0;
    for(int i=0;i<n;i++){
        if(num[i] == num[a-1]){
            
            same_cnt++;
            if(i<a){
                need_cnt++;
            }
        }
    }
    long long ans = 0;
    if(need_cnt==a){
        for(int i=a;i<=b;i++) ans += d[same_cnt][i];
    }else{
        ans += d[same_cnt][need_cnt];
    }
    printf("%lf\n",(double)sum/a);
    //cout << fixed << sum_average << '\n';
    printf("%lld\n",ans);
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
template <class Q>
void clearQueue(Q & q) {
    q = Q();
}
const int INF=1e9;
void solve(){
    int n,k;cin>>n>>k;
	vector<int>h(n);
    for(int& x:h){
        cin>>x;
    }
    int dp[n];
    for(int i=0;i<n;i++) dp[i]=INF;
    dp[0]=0;
    for(int i=1;i<n;i++){
        for(int j=1;j<=min(i,k);j++){
            dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
        }
    }
    cout<<dp[n-1];
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 4752
#include <iostream>
#include <vector>

std::vector<std::vector<char>> turn_right(const std::vector<std::vector<char>> &vector) {
	std::vector<std::vector<char>> res(8, std::vector<char>(8));
	for (auto x = 0; x < 8; ++x) {
		for (auto y = 0; y < 8; ++y) {
			res.at(y).at(x) = vector.at(7 - x).at(y);
		}
	}
	return res;
}
int main() {
	std::vector<std::vector<char>> vector(8, std::vector<char>(8));
	for (auto i = 0; i < 8; ++i) {
		char arg[10];
		std::cin >> arg;
		for (auto j = 0; j < 8; ++j) {
			vector.at(i).at(j) = arg[j];
		}
	}
	for (auto i = 90; i <= 270; i += 90) {
		std::cout << i << '\n';
		vector = turn_right(vector);
		for (const auto &line : vector) {
			for (const auto &c : line) {
				std::cout << c;
			}
			std::cout << '\n';
		}
	}
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, k, x, y; cin >> n >> k >> x >> y;
  if(n < k) cout << n*x << "\n";
  else cout << k*x+(n-k)*y << "\n";
  return 0;
}


Measured memory_bytes: 3624
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N = int(input())
    a = list(map(int, input().split()))

    count = 0
    for i in range(N):
        if (i+1)%2 == 1 and a[i]%2 == 1:
            count += 1

    print(count)

main()


Measured memory_bytes: 9168
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n,m=map(int, input().split())
uf = UnionFind(n)

for i in range(m):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)

print(uf.group_count()-1)

Measured memory_bytes: 12892
n = int(input())
s = input()

c = list(s)

lw = 0
le = 0
rw = s[1:].count("W")
re = s[1:].count("E")

ans = lw + re

for i in range(1,n):
    lw = lw + bool(c[i-1] == "W")
    le = le + bool(c[i-1] == "E")
    rw = rw - bool(c[i] == "W")
    re = re - bool(c[i] == "E")
    
    ans = min(ans, lw+re)
    
print(ans)

Measured memory_bytes: 6052
N = int(input())
A = list(map(int, input().split()))

Alice = 0
Bob = 0

while len(A) != 0:
    Alice += max(A)
    A.remove(max(A))
    if len(A) == 0:
        break
    Bob += max(A)
    A.remove(max(A))

print("{}".format(Alice-Bob))


Measured memory_bytes: 3060
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N = int(readline())
    K = int((1 + (8 * N + 1) ** 0.5) / 2)
    if not N == K * (K - 1) // 2:
        print('No')
        return

    num = 1
    ans = [[0] * (K - 1) for _ in range(K - 1)]
    for i in range(K - 1):
        for j in range(i + 1):
            ans[i][j] = ans[j][i] = num
            num += 1

    ans.append([ans[i][i] for i in range(K - 1)])
    ans = ["{} {}".format(K - 1, ' '.join(map(str, row))) for row in ans]

    print('Yes')
    print(K)
    print('\n'.join(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9588
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()

a = LIST()

occ = defaultdict(int)

for el in a:
    occ[el]+=1

tot = 0

for key in occ:
    tot+=occ[key]*(occ[key] - 1)//2

for el in a:
    print(tot - occ[el] + 1)

Measured memory_bytes: 87884
#include <cstdio>

/// @brief Verifies Takahashi's information.
///
/// \f[
/// \exists \ (a_1, a_2, a_3, b_1, b_2, b_3) \ s.t. \ 
/// \begin{pmatrix} c_{11} & c_{12} & c_{13} \\ c_{21} & c_{22} & c_{23} \\ c_{31} & c_{32} & c_{33} \end{pmatrix}
/// = 
/// \begin{pmatrix} a_1 + b_1 & a_1 + b_2 & a_1 + b_3 \\ a_2 + b_1 & a_2 + b_2 & a_2 + b_3 \\ a_3 + b_1 & a_3 + b_2 & a_3 + b_3 \end{pmatrix}
/// \f]
int main() {
    bool failed = false;
    int a[4], b[4], c[4][4];

    for (int i = 1; i <= 3; ++i) {
        for (int j = 1; j <= 3; ++j) {
            scanf("%d", &c[i][j]);
        }
    }

    a[1] = 0;
    b[1] = c[1][1];
    b[2] = c[1][2];
    b[3] = c[1][3];
    a[2] = c[2][1] - b[1];
    a[3] = c[3][1] - b[1];

    for (int i = 1; i <= 3; ++i) {
        for (int j = 1; j <= 3; ++j) {
            if (c[i][j] != a[i] + b[j]) {
                failed = true;
            }
        }
    }

    puts(failed ? "No" : "Yes");
}


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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define ull unsigned long long
#define ll long long
#define sz(a) a.size()
#define all(s) s.begin(), s.end()
#define rall(s, n) s, s + n
#define x first
#define y second
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define pii pair <int, int>
#define pll pair <ll, ll>
#define INF 1000000000
#define mod 1000000007
#define reset(a, nilai) memset(a, nilai, sizeof(a))
using namespace std;

const int gope = 500;
const int lima = 5;
int X;
int main () {
	IOS;
	
	cin >> X;
	int ans = (X / gope);
	X -= ans * gope;
	int res = (X / lima);
	cout << ans * 1000 + res * 5 << '\n';
	return 0;
}


Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	ll ans=0,ans1=0;
	rep(i,0,s.size()){
		if(i%2==0){
			if(s[i]=='0') ans++;
			else ans1++;
		}
		else{
			if(s[i]=='1') ans++;
			else ans1++;
		}
	}
	cout << min(ans1,ans);
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 512
//ARC097C
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	string s, origs;
	cin >> origs;
	int k;
	cin >> k;
	s = origs;
	set<char> ss;
	for (int i = 0; i < origs.size(); i++) {
		ss.insert(origs[i]);
	}
	vector<string> strs;
	set<string> strsset;
	for (auto it = ss.begin(); it != ss.end(); it++) {
		for (int i = 0; i < origs.size(); i++) {
			if (origs[i] == *it) {
				for (int j = 0; j < k; j++) {
					if (i+j >= origs.size())
						break;
					string sub = origs.substr(i, j+1);
					//printf("sub: %s\n", sub.c_str());
					//if (strsset.find(sub) == strsset.end()) {
						strsset.insert(sub);
						//strs.push_back(sub);
					//}
				}
			}
		}
		if (strsset.size() >= k)
			break;
	}
end:
	int i = 0;
	for (auto sss : strsset) {
		i++;
		if (i == k) {
			cout << sss << endl;
			return 0;
		}
	}

	//sort(strs.begin(), strs.end());
	//cout << strs[k-1] << endl;
	return 0;
}

Measured memory_bytes: 3652
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

#include<bits/stdc++.h>
#include<iomanip>
#define inf  (int)1e18
#define EPS   1e-9
#define mod 1000000007
#define all(k) sort(k.begin(),k.end())
#define Pi 3.14159
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define repk(i,a,n) for(int i=a;i<=(n);i++)
#define ll unsigned long long
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vc vector<char>
#define vl vector<ll>
#define mi map<int,int>
#define ml map<ll,ll>
#define umap unordered_map<ll,int>
using namespace std;

ll int togglebit(ll int n)
{
	if (n == 0)
		return 1;


	ll int i = n;

	n |= n >> 1;


	n |= n >> 2;
	n |= n >> 4;
	n |= n >> 8;
	n |= n >> 16;

	return i ^ n;
}

void sol() {
	int n; cin >> n;
	string s;
	cin >> s;
	if (n % 2 != 0) {cout << "No\n"; return;}
	bool ok = 0;
	int i = 0, j = n / 2;
	while (i < j && j < n) {
		if (s[i] != s[j])
			ok = 1;


		i++, j++;
	}
	if (ok)
		cout << "No\n";
	else
		cout << "Yes\n";


}
int main() {


	int t = 1;
	// cin >> t;

	for (int i = 0; i < t; ++i)
		sol();


	return 0;
}


Measured memory_bytes: 3460
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
	string s = ReadLine();
	for (int i = 0; i < s.Length; i++)
	{
	    char c = s[i];
	    if ((i&1) == 0) // Odd 
	    {
		if (!(c == 'R' || c == 'U' || c == 'D'))
		{
		    WriteLine("No");
		    return;
		}
	    }
	    else
	    {
		if (!(c == 'L' || c == 'U' || c == 'D'))
		{
		    WriteLine("No");
		    return;
		}
	    }
	}
	WriteLine("Yes");
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
int main(void){
    int a[101][101],b,r,c,i,j,d,e,f,g,h;
    d=0;
    e=0;
    f=0;
    scanf("%d%d",&r,&c);
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
                scanf("%d",&b);
            a[i][j]=b;
        }
    }
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            printf("%d ",a[i][j]);
            d=d+a[i][j];
        }
        printf("%d\n",d);
        e=e+d;
        d=0;
    }
     for(i=0;i<c;i++){
        for(j=r-1;j>-1;j--){
            f=f+a[j][i];
        }
        printf("%d ",f);
        f=0;
     }
    printf("%d\n",e);

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    int w, a, b;
    int judge;
    
    cin >> w >> a >> b;
    
    if(b > a){
        judge = b - a - w;
        if(judge > 0){
            cout << judge << endl;
        }
        else{
            cout << "0\n";
        }
    }
    else{
        judge = a - b - w;
        if(judge > 0){
            cout << judge << endl;
        }
        else{
            cout << "0\n";
        }
    }
    
    return 0;
}


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

int main(){
  	int x,y,z,i = 1;
  	cin >> x >> y >> z;
  
  	while(1){
      if(!(z+i*(y+z)<= x)){
        cout << i-1 << endl;
        return 0;
      }
      i++;
    }
	return 0; 
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
const int mod = 1000000007;

int main(){
	int a,b;
	char c[2];
	scanf("%d%s%d",&a,c,&b);
	if (c[0] == '+') printf("%d\n",a+b);
	else printf("%d\n",a-b);
	return 0;
}

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

int main() {

    string s,t;
    bool flag=true;
    cin>>s>>t;
    int l=s.length();
    for (int i=0; i<l; i++) {
        if(s[i]!=t[i]) {
            flag=false;
            break;
        }
    }
    if(flag==false)
        printf("No\n");
    else
        printf("Yes\n");

    return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define ll long long
int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//ll tt;	cin>>tt;	while(tt--)
	{
		ll n,k,i,min_sum,max_sum,ways;
		cin>>n>>k;	
			ll sum[n+5];
		for(i=0;i<=n+5;i++)
		{
			if(i)	sum[i]=i+sum[i-1];
			else	sum[i]=0;
		}
			ways=0;
		for(i=k;i<=n;i++)
		{
			ways+=(sum[n]-sum[n-i])-sum[i-1]+1;
			ways%=1000000007;
		}
		
 		cout<<ways+1;
 	}
	cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
		
		
return 0;
}

Measured memory_bytes: 5328
#include<stdio.h>
#include<string.h>
int n[7],m[7],o[100][7];
int i,q,j,k,a=0,l,num,x=0;//xはサイコロがそろってるかの判定に用いる
void dice_S(){
  int tmp;
  tmp = n[2];
  n[2]=n[1];
  n[1]=n[5];
  n[5]=n[6];
  n[6]=tmp;
}
void dice_E()
{
  int tmp;
  tmp = n[6];
  n[6]=n[3];
  n[3]=n[1];
  n[1]=n[4];
  n[4]=tmp;
}
//縦方向，横方向で重複しないようS・Eのみ
int main()
{
  scanf("%d",&num);
  for(i=1; i<=6; i++) scanf("%d",&m[i]);//基準となるサイコロ
  for(i=1; i<=num-1; i++)
    for(j=1; j<=6; j++)
      scanf("%d",&o[i][j]);//他のサイコロ*個数
		    
  for(i=1; i<=num-1; i++){
    k=0;//if文の有無
    a=0;//回転をするタイミング
    
    for(j=1; j<=6; j++)
      n[j]=m[j];//配列の中身を固定
    if(n[1]==o[i][1]&&n[2]==o[i][2]&&n[3]==o[i][3]&&n[4]==o[i][4]&&n[5]==o[i][5]&&n[6]==o[i][6]){//初期で一つ以上そろってたらif文を抜けて出力
      k=1;
    }

   if(k==0){//初期でそろってない場合
      for(j=0; j<4; j++){
	for(l=0; l<4; l++){
	  //	  printf("%d %d %d %d %d %d\n",n[1],n[2],n[3],n[4],n[5],n[6]);
       	  dice_S();
	  a++;
	  if(n[1]==o[i][1]&&n[2]==o[i][2]&&n[3]==o[i][3]&&n[4]==o[i][4]&&n[5]==o[i][5]&&n[6]==o[i][6]){
	    k=1;
	    break;
	  }
	  if(a==4){
	    dice_E();
	    a=0;
	  }
	}
	if(k==1)
	  break;
      }
      //上記でひょうじされない場合（n[5])
      if(k==0){
	dice_S();
	dice_E();
	for(j=0; j<4; j++){
	  dice_S();
	  if(n[1]==o[i][1]&&n[2]==o[i][2]&&n[3]==o[i][3]&&n[4]==o[i][4]&&n[5]==o[i][5]&&n[6]==o[i][6]){
	    k=1;
	    break;
	  }
	}
      }
      //n[2]
      if(k==0){
	dice_E();
	dice_E();
	for(j=0; j<4; j++){
	  dice_S();
	  if(n[1]==o[i][1]&&n[2]==o[i][2]&&n[3]==o[i][3]&&n[4]==o[i][4]&&n[5]==o[i][5]&&n[6]==o[i][6]){
	    k=1;
	    break;
	  }
	}
      }
   }
      //最終的にそろわなかった場合
      if(k==1)
	x++;
  }
  if(x>=1)
    puts("No");
  if(x==0)
    puts("Yes");
  

return 0;
}


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

long double cbrt(ll a){
	long double left=0,right=1000000;
	for(int i=0;i<1000;i++){
		long double med=(left+right)/2.0;
		long double cal=med*med*med;
		if(cal<a)	left=med;
		else 	right=med;
	}
	return left;
}
long double sqrt(ll a){
	long double left=0,right=1000000;
	for(int i=0;i<1000;i++){
		long double med=(left+right)/2.0;
		long double cal=med*med;
		if(cal<a)	left=med;
		else 	right=med;
	}
	return left;
}
int main(){
	int n;	cin>>n;
	vector<ll> x(n),y(n);
	for(int i=0;i<n;i++)	cin>>x[i];
	for(int i=0;i<n;i++)	cin>>y[i];
	ll d1=0,d2=0,d3=0,d4=0;
	for(int i=0;i<n;i++){
		d1+=abs(x[i]-y[i]);
		d2+=(x[i]-y[i])*(x[i]-y[i]);
		d3+=abs(x[i]-y[i])*(x[i]-y[i])*(x[i]-y[i]);
		d4=max(d4,abs(x[i]-y[i]));
	}
	printf("%lld\n",d1);
	printf("%.15Lf\n",sqrt(d2));
	printf("%.15Lf\n",cbrt(d3));
	printf("%lld\n",d4);
	return 0;
}


Measured memory_bytes: 3228
#include <stdio.h>
long long l[87];
int main(void){
    int n,i;
    scanf("%d",&n);
    l[0]=2;l[1]=1;
    for(i=2;i<n+1;i++){
        l[i]=l[i-2]+l[i-1];
    }
    printf("%lld\n",l[n]);
}

Measured memory_bytes: 128
# coding: utf-8
# Your code here!

N = int(input())
X = list(map(int, input().rstrip().split(' ')))

count_minus = 0
for x in X:
    if x < 0:
        count_minus += 1
        
if count_minus % 2 == 0:
    print(sum(map(abs, X)))
else:
    print(sum(map(abs, X)) - 2 * min(map(abs, X)))

Measured memory_bytes: 14284
#include <iostream>
#include <vector>

using namespace std;

void solve()
{
	char oct[8] = {'0', '1', '2', '3', '5', '7', '8', '9'};
	int n;
	while(cin >> n, n)
	{
		vector<char> Vec;
		while(n)
		{
			Vec.push_back(oct[n % 8]);
			n /= 8;
		}
		for(int i = Vec.size() - 1; i >= 0; --i)
		{
			cout << Vec[i];
		}
		cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1204
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma") 
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1e9+7;
template <class Q>
void clearQueue(Q & q) {
    q=Q();
}
void solve(){
	string s;cin>>s;
	if(s[s.size()-1]=='s') cout<<s<<"es";
	else cout<<s<<"s";
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
  //#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
}

Measured memory_bytes: 3656
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		for(;;){
			if(!sc.hasNext())
				break;
			BigInteger a=sc.nextBigInteger();
			BigInteger b=sc.nextBigInteger();
			BigInteger gcd=a.gcd(b);
			BigInteger lcm=a.multiply(b).divide(gcd);
			println(gcd+" "+lcm);
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 11000
import java.util.Scanner;

public class Main {
	static String S;
	static String T;
	static int n;
	public static void main(String[]args) {
		Scanner sc= new Scanner(System.in);
		S=sc.next();
		T=sc.next();
		n=S.length();
		T=T.substring(0,n);
		if(S.equals(T)) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35676
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



int main() {
	int A, B;

	scanf("%d%d", &A, &B);

	int all = 0;

	if (B == 100) {
		all = A * 1000 + B;
	}
	else if (B >= 10) {
		all = A * 100 + B;
	}
	else {
		all = A * 10 + B;
	}

	if (all == (int)(sqrt(all) * (int)(sqrt(all)))) {
		printf("Yes");
	}
	else {
		printf("No");
	}


}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
	int n,k,x,y;
	cin>>n>>k>>x>>y;
	if(n<=k){
    	cout<<x*n;
    }else{
    	cout<<x*k+y*(n-k);
    }
	
}


Measured memory_bytes: 256
n, m = map(int,input().split())

ab = [list(map(int,input().split())) for i in range(n)]
cd = [list(map(int,input().split())) for i in range(m)]

for i in range(n):
  x=[]
  for j in range(m):
    x.append(abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]))
  print(x.index(min(x))+1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

int f(std::vector<std::vector<int> > a) {
    int cnt[50] = {0};
    for (int i = 0; i < a.size(); i++) {
        for (int j = 0; j < a[i].size(); j++) {
            cnt[a[i][j]]++;
        }
    }

    int result = 0;
    for (int i = 0; i < 50; i++) {
        if (cnt[i] == a.size()) {
            result++;
        }
    }

    return result;
}

int main() {

    int n, m;
    std::cin >> n >> m;

    std::vector<std::vector<int> > a;
    for (int i = 0; i < n; i++) {
        
        int k;
        std::cin >> k;

        std::vector<int> v;
        for (int j = 0; j < k; j++) {
            int tmp;
            std::cin >> tmp;
            v.push_back(tmp);
        }

        a.push_back(v);
    }

    int result = f(a);
    std::cout << result << std::endl;

    return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>):Unit {
        val dropCount = readLine()!!.trim().toInt()
        val cloth = Array(10){readLine()!!.trim().split(' ').map(String::toInt).toIntArray()}
        var drops = search(cloth, dropCount)!!
        while (drops is ImmutableList.Cons){
            println("${drops.head.center.x} ${drops.head.center.y} ${when(drops.head){
                is Drop.Small -> 1
                is Drop.Medium -> 2
                is Drop.Large -> 3
            }}")
            drops = drops.tail
        }
}
fun search(cloth:Array<IntArray>, dropCount:Int):ImmutableList<Drop>?{
    if (dropCount == 0) {
        return if (cloth.all{it.all{it == 0}}) ImmutableList.Nil
        else null
    }
    val point = (0 until cloth.size).flatMap{y -> (0 until cloth.size).map{Point(it, y)}}.find{cloth[it.y][it.x] != 0}
    return when(point){
        null -> null
        else -> {
            drop(point).filter{it.dropArea().all{it.x in 0 until cloth.size && it.y in 0 until cloth.size && cloth[it.y][it.x] > 0}}.forEach {
                it.dropArea().forEach { cloth[it.y][it.x]-- }
                val tail = search(cloth, dropCount - 1)
                when(tail){
                    null -> {
                        it.dropArea().forEach { cloth[it.y][it.x]++ }
                    }
                    else -> return ImmutableList.Cons(it, tail)
                }
            }
            return null
        }
    }
}
fun drop(point:Point):Iterable<Drop>{
    return listOf(Drop.Small(point + Point(0, 1)), Drop.Medium(point + Point(1, 1)), Drop.Large(point + Point(0, 2)))
}
data class Point(val x:Int, val y:Int){
    operator fun plus(that:Point):Point = Point(x + that.x, y + that.y)
}
sealed class Drop(val center:Point){
    protected abstract val relationalDropArea:Iterable<Point>
    fun dropArea():Iterable<Point> = relationalDropArea
    class Small(center:Point):Drop(center){
        override val relationalDropArea: Iterable<Point> = listOf(Point(0, -1), Point(0, 1), Point(-1, 0), Point(1, 0), Point(0, 0)).map{it + center}
    }
    class Medium(center:Point):Drop(center){
        override val relationalDropArea: Iterable<Point> = (-1 .. 1).flatMap{x -> (-1..1).map{Point(x, it)}}.map{it + center}
    }
    class Large(center:Point):Drop(center){
        override val relationalDropArea: Iterable<Point> = (listOf(Point(2, 0), Point(-2, 0), Point(0, 2), Point(0, -2)) + (-1 .. 1).flatMap { x -> (-1 .. 1).map{Point(x, it)} }).map{it + center}
    }
}
sealed class ImmutableList<out T>{
    object Nil:ImmutableList<Nothing>()
    data class Cons<out T>(val head:T, val tail:ImmutableList<T>):ImmutableList<T>()
}


Measured memory_bytes: 75224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        WriteLine(N * N);
    }
}

public class NextPermutation
{
    int[] perm;
    public int Length => perm.Length;

    public NextPermutation(int N)
    {
        perm = new int[N];
        for (int i = 0; i < perm.Length; i++)
        {
            perm[i] = i;
        }
    }

    public NextPermutation(int[] init)
    {
        perm = init;
    }

    public int this[int i]
    {
        get
        {
            return perm[i];
        }
    }

    public bool Next()
    {
        var l = 0;
        for (int i = perm.Length - 2; i >= 0; i--)
        {
            if (perm[i] < perm[i + 1])
            {
                l = i;
                break;
            }
        }

        var v = perm[l];
        var r = 0;
        for (int i = perm.Length - 1; i >= 0; i--)
        {
            if (perm[i] > v)
            {
                r = i;
                break;
            }
        }

        if (l == 0 && r == 0) return false;
        Swap(ref perm[l++], ref perm[r]);
        Array.Reverse(perm, l, perm.Length - l);
        return true;
    }

    static void Swap<T>(ref T l, ref T r)
    {
        var t = l;
        l = r;
        r = t;
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

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


Measured memory_bytes: 40264
n = int(input())
list = []
for i in range(n):
    list.append(input().split())
    list[i][0] =float(list[i][0])
money = 0
for i in range(n):
    if list[i][1] == "JPY":
        money += list[i][0]
    else:
        money += list[i][0]*380000.0
print(money)

Measured memory_bytes: 3060