akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"os"
	"strconv"
)

type task struct {
	Current int
	Parent int
}

func main() {
	n := readInt()
	q := readInt()

	results := make([]int, n)
	links := make([][]int, n)

	for i := 0; i < n-1; i++ {
		a := readInt() - 1
		b := readInt() - 1
		links[a] = append(links[a], b)
		links[b] = append(links[b], a)
	}

	for i := 0; i < q; i++ {
		p := readInt() - 1
		x := readInt()
		results[p] += x
	}

	queue := make([]task, 0)
	queue = append(queue, task{0, -1})
	for len(queue) != 0 {
		t := queue[0]
		queue = queue[1:]
		for _, j := range(links[t.Current]) {
			if t.Parent == j {
				continue
			}
			results[j] += results[t.Current]
			queue = append(queue, task{j, t.Current})
		}
	}

	for i := 0; i < n; i++ {
		writeInt(results[i])
		if i != n {
			writeString(" ")
		}
	}
	writeNewLineAndFlush()
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

var stdoutWriter = bufio.NewWriter(os.Stdout)

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, _ := strconv.Atoi(readString())
	return result
}

func writeString(s string) {
	stdoutWriter.WriteString(s)
}

func writeInt(i int) {
	writeString(strconv.Itoa(i))
}

func writeNewLineAndFlush() {
	stdoutWriter.WriteString("\n")
	stdoutWriter.Flush()
}


Measured memory_bytes: 33408
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    if(a>0)cout<<"Positive";
    else if(a==0||(a<0&&b>0)) cout<<"Zero";
    else if((abs(b)-abs(a))%2!=0) cout<<"Positive";
    else cout<<"Negative";
    return 0;
}

Measured memory_bytes: 256
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
LL ans;
LL n,m,q;
void solve()
{
    cin>>m;
    map<ll,ll>mp;
    for(ll i=1;i<=m;i++)
    {
        ll a;cin>>a;mp[a]=i;
    }
    for(auto it:mp)
        cout<<it.second<<" ";
    //cout<<ans<<endl;
}   

int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
   // int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 7040
import sys
import collections
n = int(input())
que = collections.deque()

for _ in range(n):
    command = sys.stdin.readline()
    if 'i' == command[0]:
        command, num = command.split()
        que.appendleft(num)
    elif 'deleteFirst\n' == command:
        que.popleft()
    elif 'deleteLast\n' == command:
        que.pop()
    else:
        command, num = command.split()
        try:
            que.remove(num)
        except ValueError:
            pass
print(' '.join(map(str, que)))

Measured memory_bytes: 103332
#include <stdio.h>
int main()
{
    int h, w, i, j;
    while (1) {
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0) {
            break;
        }
        else if (h != 0 && w != 0) {
            for (i = 0; i < h; i++) {
                for (j = 0; j < w; j++) {
                    if (i != 0 && i != (h-1) && j != 0 && j != (w-1)) {
                        printf(".");
                    } else {
                        printf("#");
                    }
                }
                printf("\n");
            }
        }
        printf("\n");
    }
    return 0;
}

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

int main(){
    int K,S;
    cin>>K>>S;
    int ans=0;
    for(int X=0;X<=K&&X<=S;X++){
        for(int Y=0;Y<=K&&X+Y<=S;Y++){
            int Z=S-X-Y;
            if(0<=Z&&Z<=K)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,D;
    cin >> N >> D;
    vector<vector<int>>X(N,vector<int>(D));
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < D; j++) {
            cin >> X[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        for(int j = i+1; j < N; j++) {
            int cnt = 0;
            for(int k = 0; k < D; k++) {
                cnt+=abs(X[i][k]-X[j][k])*abs(X[i][k]-X[j][k]);
            }
            bool ok = false;
            for(int k = 0; k <= 300; k++) {
                if(k*k == cnt) {
                    ok = true;
                }
            }
            if(ok) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  string a, b;
  bool answer = true;
  vector<string> data(n);
  for(int i = 0; i < n; i++){
    string x;
    cin >> x;
    if(i == 0){
      a = x;
      data.at(i) = x;
      continue;
    }
    b = x;
    if(a.at(a.size() - 1) != b.at(0)){
      answer = false;
    }
    a = x;
    b = "non";
    data.at(i) = x;
  }
  if(answer){
    for(int i = 0; i < n; i++){
      if(answer == false){
        break;
      }
      for(int j = 0; j < n; j++){
        if(i == j){
          continue;
        }
        if(data.at(i) == data.at(j)){
          answer = false;
          break;
        }
      }
    }
  }
  if(answer){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

namespace _099_SurfSmeltFishingContest2
{
	class Program
	{
		static void Main ( string[] args )
		{
			//input
			int[] inputNum = Console.ReadLine ().Split (' ').Select (str => int.Parse (str)).ToArray ();

			//process
			int[] fishCount = new int[inputNum[0]];
			int maxIndex = 0;

			for (int lp = 0; lp < inputNum[1]; lp++)
			{
				int[] result = Console.ReadLine ().Split (' ').Select (str => int.Parse (str)).ToArray ();

				int index = result[0] - 1;
				int count = result[1];

				fishCount[index] += count;

				//?¶???????
				if (0 < count)
				{
					if (fishCount[maxIndex] < fishCount[index])
					{
						maxIndex = index;
					}
					else if (fishCount[maxIndex] == fishCount[index])
					{
						maxIndex = Math.Min (index, maxIndex);
					}
				}
				//?????????
				else
				{
					//?????§????????´??°???????????´???
					if (index == maxIndex)
					{
						int max = fishCount.Max ();
						maxIndex = Array.IndexOf (fishCount, max);
					}
				}

				//output
				Console.WriteLine ((maxIndex + 1).ToString () + " " + fishCount[maxIndex]);
			}
		}
	}
}

Measured memory_bytes: 16980
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    println(problem047c(s))
}

fun problem047c(s: String): Int {
    var count = 0
    var prev = s[0]
    for (i in 1 until s.length) {
        val si = s[i]
        if (prev != s[i]) count++
        prev = si
    }
    return count
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef int64_t ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

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

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

  cout << ret << endl;
  return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), ar(n), au(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ar[i] = a[i] - 1;
    au[i] = a[i] + 1;
  }

  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    mp[a[i]]++;
    mp[ar[i]]++;
    mp[au[i]]++;
  }

  int ans=0;
  for (auto x : mp) {
    if (ans < x.second) {
      ans = x.second;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5888
n = int(input())
Ratio = [list(map(int,input().split())) for _ in range(n)]
t,a = Ratio[0][0],Ratio[0][1]

for i in range(1,n):
    x = max((t+Ratio[i][0]-1)//Ratio[i][0],(a+Ratio[i][1]-1)//Ratio[i][1])
    t,a = Ratio[i][0]*x,Ratio[i][1]*x
print(int(t+a))

Measured memory_bytes: 3188
// "static void main" must be defined in a public class.
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        //要素数
        long n = str.length()-1;
        //最終的な合計を格納する値
        long total = 0;
        String hi = new String();
        
        //ビット全探索で探索を行う
        for(long i = 0; i < Math.pow(2,n); i++){
            String ans = new String();
            for(int j = 0; j <= n; j++){
                ans += Character.toString(str.charAt(j));
                //+を挟むタイミングでans文字列に格納してある数だけ合計に足す
                if((1 & i >> j) == 1){
                    total += Long.parseLong(ans);
                    ans = new String();
                }
            }
        total += Long.parseLong(ans);
        }
        System.out.println(total);
    }     
}

Measured memory_bytes: 24016
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    vector<vector<long long>> dp(s.size() + 1, vector<long long>(4, 0));
    dp[0][0] = 1;

    for (int i = 0; i < static_cast<int>(s.size()); i++) {
        dp[i + 1][0] += (s[i] == '?' ? 3 : 1) * dp[i][0];
        dp[i + 1][1] += (s[i] == '?' ? 3 : 1) * dp[i][1];
        dp[i + 1][2] += (s[i] == '?' ? 3 : 1) * dp[i][2];
        dp[i + 1][3] += (s[i] == '?' ? 3 : 1) * dp[i][3];

        if (s[i] == 'A' || s[i] == '?') {
            dp[i + 1][1] += dp[i][0];
        }

        if (s[i] == 'B' || s[i] == '?') {
            dp[i + 1][2] += dp[i][1];
        }

        if (s[i] == 'C' || s[i] == '?') {
            dp[i + 1][3] += dp[i][2];
        }

        dp[i + 1][0] %= 1000000007;
        dp[i + 1][1] %= 1000000007;
        dp[i + 1][2] %= 1000000007;
        dp[i + 1][3] %= 1000000007;
    }

    cout << dp[s.size()][3] << endl;
}


Measured memory_bytes: 7424
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
int main(){
    int n,m; cin>>n>>m;
    if(m>n)return puts("No")*0;
    vector<string>a(n); vector<string>b(m);
    rep(i,n)cin>>a[i]; rep(i,m)cin>>b[i];
    rep(i,n){
        rep(j,n){
            bool flag=true;
            rep(k,m)rep(l,m){
                if(((i+k)>n-1||(j+l)>n-1))flag=false;
                else if(a[i+k][j+l]!=b[k][l])flag=false;
            }
        if(flag)return puts("Yes") *0;
        }
    }
    puts("No");
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  int n,m,x; cin>>n>>m>>x;
  int cost[n]; int a[n][m];
  rep(i,n){
    cin>>cost[i];
    rep(j,m){
      cin>>a[i][j];
    }
  }
  int powerof2[n];
  powerof2[0]=1;
  rep1(i,n){
    powerof2[i]=2*powerof2[i-1];
  }
  int ans=10000000;
  for(int y=0;y<2*powerof2[n-1];y++){
    int rikai[m]={}; int money=0;
    rep(i,n){
      if((y&powerof2[i])!=0){
        money+=cost[i];
        rep(j,m){
          rikai[j]+=a[i][j];
        }
      }
    }
    int f=1;
    rep(i,m){
      if(rikai[i]<x){
        f=0;
      }
    }
    if(f==1){
      ans=min(ans,money);
    }
  }
  if(ans==10000000){
    cout<<-1;
  }else{
    cout<<ans;
  }
}


Measured memory_bytes: 3636
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
const ll mod  = 1e9+7;
int n,m,v,i;

ll pow_n(ll a , ll n){
  if(n==1) return a;
  if(n==0){
    return 1;
  } else {
    ll ans = (pow_n(a,n/2))%mod;
    if(n%2==1) return ans * ans %mod * a %mod;
    else return ans * ans %mod;
  }
}
void solve(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>m;
  double ans = 0,cnt = 1;
  cout<<(1900*m+100*(n-m))*pow(2,m)<<endl;

}

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


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
q = int(input())

tmp = 0
l = [0 for i in range(10**5 +1)]
for i in a:
    tmp += i
    l[i] += 1

for i in range(q):
    b,c = map(int,input().split())
    tmp += c*l[b] - b*l[b]
    print(tmp)
    l[c] += l[b]
    l[b] = 0

Measured memory_bytes: 20932
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

a,b,c,d=gi

puts ((a-b).abs <= d && (b-c).abs <= d || (a-c).abs <= d) ? 'Yes' : 'No'


Measured memory_bytes: 2300
N = int(input().strip())
A = [int(v) for v in input().strip().split(" ")]

total_height = 0

pre = A[0]
for i in range(1, len(A)):
    if A[i] < pre:
        total_height += pre - A[i]
    else:
        pre = A[i]

print(total_height)

Measured memory_bytes: 32136
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n, k;
  string s;
  cin >> n >> k >> s;
  s[k - 1] = s[k - 1] - 'A' + 'a';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    if(n==111)
    printf("999\n");
    if(n==119)
    printf("991\n");
    if(n==199)
    printf("911\n");
    if(n==999)
    printf("111\n");
    if(n==991)
    printf("119\n");
    if(n==911)
    printf("199\n");
    if(n==919)
    printf("191\n");
    if(n==191)
    printf("919\n");
    return 0;
   
   
    }

Measured memory_bytes: 128
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);

        int c = Integer.parseInt(scan.next());
        scan.nextLine();
        double yourfortune = 0;
        double btcprice = 380000.0;

        for(int i = 0;i<c;i++){
            double a = 0;
            a = Double.parseDouble(scan.next());
            String b = null;
            if(scan.hasNext()){
                 b = scan.next();
            }else{
                 b = "";
            }
                if(b.equals("JPY")){
                yourfortune += a;
            }else{
                yourfortune += (a*btcprice);
            }
        }
//        Double a = Double.parseDouble(scan.next());
////        int b = Integer.parseInt(scan.next());
//        String b = scan.next();
        String ans = null;
        PrintWriter out = new PrintWriter(System.out);
        out.println(yourfortune);
        out.flush();
        scan.close();
    }
}

Measured memory_bytes: 23508
# D - RGB Triplets
from collections import defaultdict


def main():
    _, S = open(0).read().split()
    indices, doubled_indices = defaultdict(list), defaultdict(set)
    for i, c in enumerate(S):
        indices[c].append(i)
        doubled_indices[c].add(2 * i)
    cnt = len(indices["R"]) * len(indices["G"]) * len(indices["B"])
    for x, y, z in ["RGB", "GBR", "BRG"]:
        cnt -= sum(i + j in doubled_indices[z] for i in indices[x] for j in indices[y])
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9708
#abc062 a 
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]

def func(x):
    if x in a:
        return 0
    if x in b:
        return 1
    if x in c:
        return 2
y,z=map(int,input().split())
if func(y)==func(z):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <functional>
#include <utility>
#include <numeric>
#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<valarray>
using namespace std;


int main(){
	bool check;
	string S,T;
	cin>>S>>T;
	
int 	sz1=S.size(),sz2=T.size();
if(sz1!=sz2)
{
	cout<<"No"<<endl;
}
else
{
for(int i=0;i<=sz1;i++)
{
	rotate(T.begin(),T.begin()+1,T.end());
	if(T==S){
		check=true;
		break;
	}
	else{
			check=false;
		continue;
	}
	
}
if(check)
	cout<<"Yes"<<endl;

else
cout<<"No"<<endl;

}
return 0;







}

Measured memory_bytes: 256
N, *XY = map(int, open(0).read().split())

XY = [(x, y) for x, y in zip(*[iter(XY)] * 2)]
XY = list(set(XY))

Ax, Ay = max(XY, key=lambda t: t[0] + t[1])
Bx, By = max(XY, key=lambda t: -t[0] + t[1])
Cx, Cy = max(XY, key=lambda t: t[0] - t[1])
Dx, Dy = max(XY, key=lambda t: -t[0] - t[1])

ans = 0
for x, y in XY:
    ans = max(
        ans,
        abs(x - Ax) + abs(y - Ay),
        abs(x - Bx) + abs(y - By),
        abs(x - Cx) + abs(y - Cy),
        abs(x - Dx) + abs(y - Dy),
    )

print(ans)

Measured memory_bytes: 175736
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let n = s.trim().parse().unwrap();

    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let x: Vec<f64> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect::<_>();

    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let y: Vec<f64> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect::<_>();

    let mut a: f64 = 0.;
    for i in 0..n{
        a += (x[i] - y[i]).abs();
    }

    let mut b: f64 = 0.;
    for i in 0..n{
        b += (x[i] - y[i]).powi(2);
    }

    let mut c: f64 = 0.;
    for i in 0..n{
        c += (x[i] - y[i]).abs().powi(3);
    }

    let mut d: f64 = 0.;
    for i in 0..n{
        if d < (x[i] - y[i]).abs(){
            d = (x[i] - y[i]).abs();
        }
    }

    println!("{}\n{}\n{}\n{}", a, b.sqrt(), c.powf(1 as f64 / 3 as f64), d);
}


Measured memory_bytes: 5176
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( " " ).map( Number );
  var d = Math.sqrt( Math.pow( data[0]-data[2], 2 )+Math.pow( data[1]-data[3], 2 ) );
  console.log( d );
});

Measured memory_bytes: 15868
"""
区間スケジューリング
終端で降順にソートすれば良い
最適解は，貪欲法で，1つ次の区間を通るように串刺すこと
終端で降順にソートしているので，1本で区間を刺せる条件はi<jのとき，a[i]<b[j]
さらにその後，刺せる範囲が狭まる場合(a[i]>b[i])は，狭めて次の区間に行く
"""
n, m=map(int, input().split())
hope=[]
for i in range(m):
    a, b=map(int, input().split())
    hope.append((a, b))
hope.sort(reverse=True, key=lambda x: x[1])
ans=0
for i in range(m-1):
    if i==0:
        target=hope[i][0]
    if target<hope[i+1][1]:
        if target<hope[i+1][0]:
            target=hope[i+1][0]
    else:
        ans=ans+1
        target=hope[i+1][0]
print(ans+1)


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

int main(){
	int n,m,k;
	cin >> n >> m >> k;
	bool flag = false;
	for(int a=0;a<=m;a++){
		for(int b=0;b<=n;b++){
			if(b*(m-a)+a*(n-b) == k){
				flag = true;
			}
		}
	}
	if(flag){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


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

const int MAXN = 200005;
const int MAX = 100000000;

int tree[4 * MAXN], flag[4 * MAXN];

void push(int i, int L, int R){
	if(flag[i] == -1)return;
	
	if(L < R){
		flag[2 * i] = flag[i];
		flag[2 * i + 1] = flag[i];
	}
	
	tree[i] = flag[i] + L;
	flag[i] = -1;
}
void update(int i, int L, int R, int u, int v, int val){
	push(i, L, R);
	
	if(v < L || R < u)return;
	if(u <= L && R <= v){
		flag[i] = val;
		push(i, L, R);
		
		return;
	}
	
	int mid = (L + R) / 2;
	
	update(2 * i, L, mid, u, v, val);
	update(2 * i + 1, mid + 1, R, u, v, val);
	
	tree[i] = min(tree[2 * i], tree[2 * i + 1]);
}
int search(int i, int L, int R, int u){
	push(i, L, R);
	
	if(L == R){
		return tree[i];
	}
	
	int mid = (L + R) / 2;
	if(u <= mid)return search(2 * i, L, mid, u);
	else return search(2 * i + 1, mid + 1, R, u);
}

int h, w, a[MAXN], b[MAXN];

int main(){
	scanf("%d %d", &h, &w);
	
	memset(flag, -1, sizeof flag);
	
	for(int i = 0; i < h; i++){
		scanf("%d %d", &a[i], &b[i]);
		a[i]--, b[i]--;
		
		if(a[i] == 0){
			update(1, 0, w - 1, a[i], b[i], MAX);
		}else{
			int r = search(1, 0, w - 1, a[i] - 1);
			update(1, 0, w - 1, a[i], b[i], r - (a[i] - 1));
		}
		
		if(tree[1] >= MAX)printf("-1\n");
		else printf("%d\n", tree[1] + i + 1);
	}
	
	return 0;
}


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

int n, a[1005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    sort(a + 1, a + n + 1);
    cout << a[n] - a[1];
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	static int[] mountain;
	static int total=0;

	public static void main(String[] args){
      	Scanner sc = new Scanner(System.in);
      	mountain=new int[sc.nextInt()];
      	for(int i=0;i<mountain.length;i++) {
      		mountain[i]=sc.nextInt();
      	}

      	for(int i=0;i<mountain.length;i++) {
      		cansee(i);
      	}

		System.out.println(total);
	}

	public static void cansee(int num) {
		int tall=mountain[num];
		for(num--;num>=0;num--) {
			if(mountain[num]>tall)
				return;
		}
		total++;
	}
}

Measured memory_bytes: 23764
N = int(input())
city_score = [[i for i in input().split()] for i in range(N)]
city = list()
score = list()
all = list()
for i in range(N):
    city.append(city_score[i][0])
    score.append(city_score[i][1])
    all.append([city_score[i][0], int(city_score[i][1]), i+1])
    
while(True):
    min_word = "zzzzzzzzzz"
    max_score = -1
    ans = 0
    index = 0
    for i in range(len(all)):
        if((all[i][0] < min_word) or (all[i][0] == min_word and all[i][1] > max_score)):
                max_score = all[i][1]
                min_word = all[i][0]
                ans = all[i][2]
                index = i
    print(ans)
    all.pop(index)
    #print(all)
    if(len(all) == 0):
        break


Measured memory_bytes: 3064
import sys
def get_min_no_of_coins(p, coins):
	dp = [sys.maxsize-1] * (p+1)
	dp[0] = 0
	for coin in coins:
		for i in range(coin, p+1):
			dp[i] = min(dp[i], dp[i-coin]+1)
	return dp[p]

p, n = map(int, input().split())
coins = list(map(int, input().split()))

ans = get_min_no_of_coins(p, coins)
print(ans)



Measured memory_bytes: 7520
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>

using namespace std;
using lint = long long;
#define pii = pair<lint, lint>;
#define vec = vector<lint>;
#define pq priority_queue<lint>
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define repr(i, n) for (lint i = (n); i > 0; i--)
#define rep1(i, n) for (lint i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define mp(x, y) make_pair((x), (y))

constexpr lint MOD = 1e9 + 7;
// int A, B, C, F, H, I, J, K, L, M, N, S, T, U, W, X, Y;
lint A, B, F, H, I, J, K, L, M, N, S, T, U, W, X, Y;
// string A, B;
lint ans = 0;
// string ans;
pq a;

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

	cin >> N >> M;
    rep(i, N) {
        cin >> A;
		a.push(A);
    }

	rep(i, M) {
		lint t = a.top();
		a.pop();
		a.push(t / 2);
	}
	rep(i, N) {
		ans += a.top();
		a.pop();
	}

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

Measured memory_bytes: 1400
# -*- Coding:utf-8 -*-
import sys

def split_with_func(string, func):
    return [func(x) for x in string.split()]

def get_line(func=None):
    string = sys.stdin.readline().rstrip()
    if func is not None:
        return split_with_func(string, func)
    else:
        return string

N, M = get_line(int)
data = sorted(list(set(get_line(int))))

M = len(data)
if M - N <= 0:
    print(0)
    exit()
ans = sum(sorted([data[i+1] - data[i] for i in range(M-1)])[:M-N])

print(ans)

Measured memory_bytes: 14976
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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


    //start from here

   	readb(a, b) print(a*b)


    return 0;
}


Measured memory_bytes: 3636
from collections import Counter 
n,m=map(int,input().split())
a=[0]+list(map(int,input().split()))
for i in range(n):
  a[i+1]+=a[i]
  a[i+1]%=m
a=list(Counter(a).values())
ans=0
for i in a:
  ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 94140
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let (a,b) = {
        let t = read_vec::<i64>();
        (t[0],t[1])
    };
    for i in 1..4{
        if (a * b  *i) % 2  !=  0{
            println!("Yes");
            return;
        }
    }
    println!("No");
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
        #define ll long long
        #define f   first
        #define s   second
        #define pb          push_back
        #define mod        1000000007
        #define mod1       1000000009
        #define hell        998244353
        #define inf         1000000000000000000LL
        #define pi          3.14159265358979323
        #define N           1000005
        using namespace std;
        ll n,k,sum,q,res,m,val,ans;
        ll x,y;
        ll xx[]={1,0,-1,0};
        ll yy[]={0,1,0,-1};
        void solve()    
        {   ll a,b;
            cin>>n;
            map<string,ll> hm;
            for(int i=0;i<n;i++)
            {
                string s1;cin>>s1;
                hm[s1]++;
            }
            cout<<"AC x "<<hm["AC"]<<"\n";
            cout<<"WA x "<<hm["WA"]<<"\n";
            cout<<"TLE x "<<hm["TLE"]<<"\n";
            cout<<"RE x "<<hm["RE"]<<"\n";

        }
        int main()
        {   ios_base::sync_with_stdio(false);
            cin.tie(0);cout.tie(0);
            ll t=1;
            //cin>>t;
            while(t--)
                solve();
            

        }            

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

const int N=18;
int a[(1<<N)+5];
int main() {
	int n;
	scanf("%d", &n);
	for(int i=0;i<(1<<n);i++) scanf("%d", &a[i]);
	sort(a,a+(1<<n));
	multiset<int> s;
	for(int i=0; i<(1<<n)-1; i++) s.insert(a[i]);
	vector<int> v;
	v.push_back(a[(1<<n)-1]);
	for(int i=0; i<n; i++) {
		auto temp=v;
		for(auto j:v) {
			// find element smaller than j
			auto it=s.lower_bound(j);
			if(it==s.begin()) {
				puts("No");
				return 0;
			}
			--it;
			temp.push_back(*it);
			s.erase(it);
		}
		sort(temp.begin(), temp.end());
		reverse(temp.begin(), temp.end());
		swap(temp,v);
	}
	puts("Yes");
	return 0;
}


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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};




int main(){
	int a, b;
	cin >> a >> b;
	cout << ((a%2 && b%2)?"Yes":"No")<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;

int main() {
	ll X, K, D;
	cin >> X >> K >> D;
	X = abs(X);
	ll a = min(K, X / D);
	K -= a;
	X -= D * a;
	if (K % 2 == 0) cout << X << endl;
	else cout << D - X << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
#define rep(i,n) for(int i=1; i<=n; i++)

int Keta(int number){
    int digit=0;
    while(number!=0){
        number = number / 10;
        ++digit;
    }
    return digit;
}

int main() {
    long long N,B;
    cin >> N;
    int min=Keta(N);
    rep(i,sqrt(N)){
        if(N%i==0){
            B=N/i;
            if(min>max(Keta(i),Keta(B))){
                min=max(Keta(i),Keta(B));
            }
        }
    }
	printf("%d\n", min);
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll h,w,k;
ll x1,y_1,x2,y2;
v2 c;
v3 vis;
priority_queue<v1, vector<v1>, greater<v1>> pq;
ll dx[] = {0, 1, 0, -1};
ll dy[] = {1, 0, -1, 0};
ll ans = -1;


int main(){
    cin >> h >> w >> k;
    cin >> x1 >> y_1 >> x2 >> y2;
    c = v2(h+2, v1(w+2, 1));
    for(ll i = 1;i <= h;i++){
        string s;
        cin >> s;
        for(ll j = 1;j <= w;j++){
            c[i][j] = (s[j-1] == '@');
        }
    }
    vis = v3(4, v2(h+2, v1(w+2, 0)));
    pq.push(v1({0, 0, x1, y_1}));
    while(!pq.empty()){
        ll cost = pq.top()[0];
        ll d = pq.top()[1];
        ll x = pq.top()[2];
        ll y = pq.top()[3];
        pq.pop();
        if(vis[d][x][y]) continue;
        vis[d][x][y] = 1;
        if(x == x2 && y == y2){
            ans = (cost + k - 1) / k;
            break;
        }
        ll next_x = x + dx[d];
        ll next_y = y + dy[d];
        if(c[next_x][next_y] == 0 && vis[d][next_x][next_y] == 0){

            pq.push(v1({cost+1, d, next_x, next_y}));
        }
        for(ll i = 0;i < 4;i++){
            ll next_cost = ((cost + k - 1) / k) * k;
            if(vis[i][x][y] == 0){
                pq.push(v1({next_cost, i, x, y}));
            }
        }


    }
    cout << ans << endl;

}


Measured memory_bytes: 151708
N,a,b,c,d=map(int, input().split())
N-=1
a,b=0,abs(b-a)
#上下をn回とすると、0<=n<=N//2
if d*N<b:
  print('NO')
  exit()
  
for i in range(N//2+1):
  e=b-(N-i*2)*d
  f=b-(N-i*2)*c
  if e<=(d-c)*i and (c-d)*i<=f:
    print('YES')
    exit()
print('NO')

Measured memory_bytes: 9108
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()
l = IL()
l_abs = []

l.sort()

for i in range(M-1):
    a = l[i+1] - l[i]
    l_abs.append(a)

l_abs.sort()

if N >= M:
    print(0)
else:
    for i in range(N-1):
        del l_abs[-1]
    print(sum(l_abs))

Measured memory_bytes: 23032
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
class DIJ{
	public:
	struct edge{
		int to,cost;
	};
	vector<vector<edge> >G;
	int n;
	vi d;//distance
	DIJ(int size){
		n=size;
		G=vector<vector<edge> >(n);
		d=vi(n,inf);
	}
	void add_edge(int a,int b,int c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);
		G[b].pb(ee);
	}
	void dij(int s){
		d[s]=0;
		priority_queue<pii>q;
		q.push(pii(0,s));
		while(!q.empty()){
			pii p=q.top();
			q.pop();
			int pos=p.second,cost=-p.first;
			if(cost>d[pos])continue;
			rep(i,G[pos].size()){
				edge e=G[pos][i];
				int to=e.to;
				int nowcost=cost+e.cost;
				if(nowcost<d[to]){
					d[to]=nowcost;
					q.push(pii(-d[to],to));
				}
			}
		}
	}
};
int main(){
	int n,m,s;
	scanf("%d%d%d",&n,&m,&s);
	DIJ dij(n);
	while(m--){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		a--;b--;
		dij.add_edge(a,b,c);
	}
	while(s--){
		int a;
		scanf("%d",&a);
		a--;
		dij.dij(a);
	}
	int out=0;
	rep(i,n)rep(j,dij.G[i].size()){
		int a=dij.d[i],b=dij.d[dij.G[i][j].to],c=dij.G[i][j].cost;
		out=max(out,(int)(0.5+(a+b+c)/2.));
	}
	cout<<out<<endl;
}

Measured memory_bytes: 4208
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<set>
#include<bitset>
#include<map>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#define INF 0x3f3f3f3f
#define inf 100000000000000000
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int a,b,temp;
int gcd(int a,int b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return a/gcd(a,b)*b;
}
int main()
{
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        if(a<b)
        {
            temp=a;a=b;b=temp;
        }
        printf("%d %d\n",gcd(a,b),lcm(a,b));
    }
    return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 300 + 5;
double dp[N][N][N];
bool check[N][N][N];

int n;
double res(int a, int b, int c){
    if(a < 0 || b < 0 || c < 0)return 0;
    if(a == 0 && b == 0 && c == 0)return 0;
    if(check[a][b][c])return dp[a][b][c];
    check[a][b][c] = 1;
    dp[a][b][c] = n + a*res(a - 1, b, c) + b*res(a + 1, b - 1, c) + c*res(a, b + 1, c - 1);
    dp[a][b][c] /= (a+b+c);
    return dp[a][b][c];
}
int32_t main(){
      
    cin >> n;
    int a, b, c;
    a = 0; b = 0; c = 0;
    int m = n;
    while(m--){
        int x; cin >> x;
        if(x == 1)a++;
        if(x == 2)b++;
        if(x == 3)c++;
    }
    cout << setprecision(10) << fixed << res(a, b, c);
}

Measured memory_bytes: 246016
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;

vector<vector<ll>> field(3, vector<ll>(3, 0));
vector<ll> coord1 = {0, 4, 8};
vector<ll> coord2 = {2, 4, 6};
void Main(){
    string S, T;
    cin >> S;
    cin >> T;
    ll N = S.size();
    ll ans = 0;
    rep(i, N){
        ans += (ll)(S[i] != T[i]);
    }

    cout << ans <<endl;

}

int main(){
    Main();
}

Measured memory_bytes: 3468
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

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

int main(){
  string a,b;
  int x;
  cin>>a>>b;
  a+=b;
  x=stoi(a);
  for(int i=1;i<1000;i++){
    if(x==i*i){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> x(n),y(n);
	for(int i=0;i<n;i++)
		cin >> x[i] >> y[i];
	long long ans=0;
	long long mx=-20000000000,mn=20000000000;
	for(int i=0;i<n;i++)
	{
		long long tmp=x[i]-y[i];
		mx=max(mx,tmp);
		mn=min(mn,tmp);
	}
	ans=mx-mn;


	mx=-20000000000;
	mn=20000000000;
	for(int i=0;i<n;i++)
	{
		long long tmp=x[i]+y[i];
		mx=max(mx,tmp);
		mn=min(mn,tmp);
	}
	ans=max(ans,mx-mn);


	cout << ans << endl;

}

Measured memory_bytes: 4840
use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::cmp::{max, min};

fn main() {
    input! {
        n: i128,
        T: [i128; n],
    }
    let mut now_lcm = T[0];
    for i in T.iter() {
        now_lcm = lcm(now_lcm, *i);
    }
    println!("{}", now_lcm);
}

fn gcd(m: i128, n: i128) -> i128 {
    let r = m % n;
    if r >= 1 {
        gcd(n, r)
    } else {
        n
    }
}

fn lcm(m: i128, n: i128) -> i128 {
    (m*n + gcd(m, n)-1) / gcd(m, n)
}

Measured memory_bytes: 2160
def factorial(a):
    result = 1
    for i in range(1,a+1):
        result *= i
        result %= 1000000007
    return result
N, M = map(int, input().split())
if N == M:
    ans = 2*(factorial(N)**2) %1000000007
elif abs(N-M) == 1:
    ans = max(N,M)*(factorial(min(N,M))**2) %1000000007
else:
    ans =0
print(ans)

Measured memory_bytes: 9040
#include<stdio.h>
#include<stdlib.h>

int main(){
  int i,*A,j,minj,n,hozon,count=0;
  scanf("%d",&n);

  A= (int *)malloc(n*sizeof(int));

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

  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if (A[j]<A[minj]) minj=j;
    
    }
    if(i!=minj)    count++;
    hozon=A[i];
    A[i]=A[minj];
    A[minj]=hozon;
     
    
  }

  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i!=n-1) printf(" ");
    else printf("\n");
  }

  printf("%d\n",count);
  return 0;
}



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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
fn is_palindrome(v : &usize) -> bool {
    let s:Vec<char> = v.to_string().chars().collect();
    let mut res = true;
    for i in 0..s.len()/2 {
        if s[i] != s[s.len()-i-1] {
            res = false;
            break
        }
    }
    res
}
fn main() {
    input! {
        a: usize,
        b: usize,
    }
    let res = (a..(b+1)).filter(is_palindrome).count();

    println!("{}", res);
}


Measured memory_bytes: 4352
blue_dict = {}
red_dict = {}

N = int(input())
for i in range(N):
    s = input()
    if s in blue_dict:
        blue_dict[s] = blue_dict[s] + 1
    else:
        blue_dict[s] = 1

M = int(input())
for i in range(M):
    s = input()
    if s in red_dict:
        red_dict[s] = red_dict[s] + 1
    else:
        red_dict[s] = 1

point_max = 0
for s in blue_dict:
    point = blue_dict[s] - red_dict.get(s, 0)
    point_max = max(point_max, point)
print(point_max)


Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.Scanner;

//Soccer
public class Main{

	class R implements Comparable<R>{
		int id, p;
		public R(int id) {
			this.id = id;
		}
		public int compareTo(R o) {
			return o.p-p;
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] res = new int[n];
		R[] r = new R[n];
		for(int i=0;i<n;i++)r[i]=new R(i);
		for(int i=0;i<n*(n-1)/2;i++){
			int s = sc.nextInt()-1, t = sc.nextInt()-1, ps = sc.nextInt(), pt = sc.nextInt();
			if(ps<pt)r[t].p+=3;
			else if(pt<ps)r[s].p+=3;
			else{
				r[s].p++; r[t].p++;
			}
		}
		Arrays.sort(r);
		int v = 1;
		res[r[0].id] = 1;
		for(int i=1;i<n;i++){
			if(r[i].p!=r[i-1].p)v=i+1;
			res[r[i].id] = v;
		}
		for(int x:res)System.out.println(x);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        String[] S = stdR.readLine().split(" ");
        int N = Integer.parseInt(S[0]);
        int L = Integer.parseInt(S[1]);
        int min = Integer.MAX_VALUE;
        int minvalue = Integer.MAX_VALUE;
        int sum = 0;
        for(int i = 0 ; i < N ; i++) {
            sum += (L + i);
        }
        
        for(int i = 0 ; i < N ; i++) {
            if(Math.abs(L + i) < min) {
                minvalue = sum - (L + i);
                min = Math.abs(L + i);
            }
        }
        System.out.println(minvalue);
    }
}

Measured memory_bytes: 23124
#![allow(non_snake_case)]
use proconio::input;

#[rustfmt::skip]
fn main() { std::thread::Builder::new().stack_size(128 * 1024 * 1024).spawn(solve).unwrap().join().unwrap(); }

static MOD: i64 = 1_000_000_007;

#[proconio::fastout]
fn solve() {
    input! {
        N: i64, K:usize
    }

    let mut dp = vec![0; K + 1];
    for k in (1..=K).rev() {
        dp[k] = modpow((K / k) as i64, N, MOD);
        for x in (2 * k..=K).step_by(k) {
            dp[k] -= dp[x]
        }
        dp[k] %= MOD;
        dp[k] += MOD;
        dp[k] %= MOD;
    }

    println!(
        "{}",
        dp.iter()
            .enumerate()
            .map(|(i, &x)| i as i64 * x % MOD)
            .sum::<i64>()
            % MOD
    );
}

fn modpow(a: i64, b: i64, m: i64) -> i64 {
    if b == 0 {
        1
    } else if b % 2 == 0 {
        let x = modpow(a, b / 2, m);
        x * x % m
    } else {
        a * modpow(a, b - 1, m) % m
    }
}


Measured memory_bytes: 2256