akhauriyash/Code-Regression huggingface dataset:
use std::io::stdin;

fn main() {
    let mut personal_data: Vec<Vec<i32>> = Vec::new();

    loop {
        let mut buf = String::new();
        stdin().read_line(&mut buf).unwrap();
        if buf == "-1 -1 -1\n".to_string() {
            break;
        }
        let mut elements = buf.trim().split_whitespace();
        personal_data.push(
            (0..3)
                .map(|_| elements.next().unwrap().parse::<i32>().unwrap())
                .collect(),
        );
    }
    print!("{}", solve(personal_data));
}

fn solve(personal_data: Vec<Vec<i32>>) -> String {
    let mut result = String::new();
    for iter in personal_data.iter() {
        let a = iter[0];
        let b = iter[1];
        let c = iter[2];
        if a == -1 || b == -1 {
            result.push_str("F\n")
        } else if a + b >= 80 {
            result.push_str("A\n")
        } else if a + b >= 65 {
            result.push_str("B\n")
        } else if a + b >= 50 {
            result.push_str("C\n")
        } else if a + b < 30 {
            result.push_str("F\n")
        } else if c >= 50 {
            result.push_str("C\n")
        } else {
            result.push_str("D\n")
        }
    }
    result
}



Measured memory_bytes: 5036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
struct node{
	int money;
	int a[15];
}c[15];

int main(){
	ios::sync_with_stdio(false),cin.tie(0);
	int n,m,x;
	cin >> n >> m >> x;
	for(int i=0;i<n;i++){
		cin >> c[i].money;
		for(int j=0;j<m;j++){
			cin >> c[i].a[j];
		}
	}
	int minn=0x3f3f3f3f;
	for(int i=0;i<(1<<n);i++){
		node p;
		p.money=0;
		for(int j=0;j<m;j++)p.a[j]=0;
		for(int j=0;j<n;j++){
			if(i&(1<<j)){
				p.money+=c[j].money;
				for(int k=0;k<m;k++){
					p.a[k]+=c[j].a[k];
				}
			}
		}
		int f=0;
		for(int j=0;j<m;j++){
			if(p.a[j]<x) f=1;
		}
		if(f==0){
			minn=min(minn,p.money);
		}
	}
	if(minn==0x3f3f3f3f)minn=-1;
	cout << minn << endl;
	return 0;	
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int k = sc.nextInt();
        boolean[][] a = new boolean[h][w];
        for (int i = 0; i < h; i++) {
            char[] s = sc.next().toCharArray();
            for (int j = 0; j < w; j++) {
                if(s[j] == '#') a[i][j] = true;
            }
        }
        int idx = 0;
        int[][] ans = new int[h][w];
        int l = 0;
        for (int r = 0; r < w; r++) {
            boolean start = false;
            int t = 0;
            for (int b = 0; b < h; b++) {
                if(a[b][r]){
                    if(start){
                        for (int i = t; i < b; i++) {
                            for (int j = l; j <= r; j++) {
                                ans[i][j] = idx;
                            }
                        }
                        t = b;
                    }else{
                        start = true;
                    }
                    idx++;
                }
            }
            if(start){
                for (int i = t; i < h; i++) {
                    for (int j = l; j <= r; j++) {
                        ans[i][j] = idx;
                    }
                }
                l = r+1;
            }else if(0 < l){
                for (int i = 0; i < h; i++) {
                    ans[i][l] = ans[i][l-1];
                }
                l = r+1;
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                sb.append(ans[i][j] + " ");
            }
            sb.append("\n");
        }
        System.out.print(sb.toString());
        sc.close();

    }

}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


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

    // dp[i][j]: S[i:] と S[j:] (i < j) の最長接頭文字列
    vector<vector<int>> dp(N+1, vector<int>(N+1));
    for(int i = N-1; i >= 0; --i){
        for(int j = N-1; j > i; --j){
            if(S[i] != S[j]) dp[i][j] = 0;
            else dp[i][j] = dp[i+1][j+1]+1;
        }
    }

    int ans = 0;
    REP(i, N){
        FOR(j, i+1, N){
            if(dp[i][j] > j-i) ans = max(ans, j-i);
            else ans = max(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 98176
n = int(input())
v = [0] + list(map(int, input().split()))

odd = [v[i] for i in range(1, n+1, 2)]
even = [v[i] for i in range(2, n+1, 2)]

from collections import Counter
counter_odd = dict(Counter(odd))
counter_even = dict(Counter(even))

counter_odd[0] = 0
counter_even[0] = 0

counter_odd = list(counter_odd.items())
counter_even = list(counter_even.items())

counter_odd.sort(reverse=True, key=lambda x: x[1])
counter_even.sort(reverse=True, key=lambda x: x[1])

max_odd = counter_odd[0]
max_even = counter_even[0]

if max_odd[0] != max_even[0]:
    ans = len(odd) - max_odd[1] + len(even) - max_even[1]
    print(ans)
else: 
    semi_max_odd = counter_odd[1]
    semi_max_even = counter_even[1]
    loss_odd = max_odd[1] - semi_max_odd[1]
    loss_even = max_even[1] - semi_max_even[1]
    if loss_odd < loss_even:
        ans = len(odd) - semi_max_odd[1] + len(even) - max_even[1]
    else:
        ans = len(odd) - max_odd[1] + len(even) - semi_max_even[1]
    print(ans)


Measured memory_bytes: 112032
#include<bits/stdc++.h>			
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;
const ll maxsize = 100000009;

 
void solve() {			
	ll a, b, ans;
	cin >> a >> b;
	for(int 	i = 1; i <= 1000; ++i) {
		if((ll)(i * 0.08) == a && (ll)(i * 0.1) == b) {
			cout << i << endl;
			return;
			}
		}
		cout << -1 << endl;
}


	

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve();
	return 0;
}






Measured memory_bytes: 3652
N, A = gets.chomp.split(" ").map(&:to_i)
x = gets.chomp.split(" ").map(&:to_i)
y = [0] + x.map{|x| x - A}
K_MAX = (x + [A]).max

dp = Array.new(N+1){Array.new(2*N*K_MAX+1, 0)}

(N+1).times do |i|
  (2*N*K_MAX+1).times do |j|
    if i == 0 && j == N * K_MAX then
      dp[i][j] = 1
    elsif i > 0 && (j - y[i] < 0 || j - y[i] > 2 * N * K_MAX) then
      dp[i][j] = dp[i - 1][j]
    elsif i > 0 && j - y[i] >= 0 && j - y[i] <= 2 * N * K_MAX then
      dp[i][j] = dp[i - 1][j] + dp[i - 1][j - y[i]]
    end
  end
end

puts dp[N][N * K_MAX] - 1

Measured memory_bytes: 3836
#include <stdio.h>
#include <math.h>

int main(void){
    // Your code here!
    long long N;
    int min = 99999999;
    
    scanf("%lld",&N);
    
    for(int i = 1; i <= sqrt(N); i++){
        if(N % i == 0){
            long long tmp;
            if(N / i > i){
                tmp = N / i;
            }
            else{
                tmp = i;
            }
            
            int len = 0;
            while(tmp > 0){
                tmp /= 10;
                len++;
            }
            
            if(len < min){
                min = len;
            }
        }
    }
    
    printf("%d\n",min);
}


Measured memory_bytes: 2048
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val n, x = sc.nextInt()
    val as = Array.fill(n)(sc.nextLong())

    val temp = as.map(a => if (a > x) x else a)
    debug(temp.mkString(" "))
    val sum = as.sum - temp.sum
    debug(sum)

    var tmp = 0L

    for (i <- temp.indices) {
      if (i != 0) {
        if (temp(i) + temp(i - 1) > x) {
          val over = temp(i) + temp(i - 1) - x
          tmp += over
          temp(i) -= over
        }
      }
    }

    println(sum + tmp)
    debug(temp.mkString(" "))

  }

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }
}


Measured memory_bytes: 70764
#include <bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define int long long
#include "string"

int32_t main(){
	boost;
	int n;
	cin>>n;
	int a[n];
	int sum = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum ^= a[i];
	}

	for(int i=0;i<n;i++)
		cout<<(sum^a[i])<<endl;				
}

Measured memory_bytes: 5104
#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
import heapq
import fractions
L = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [n*(-1) for n in A]
heapq.heapify(A)
for _ in range(L[1]):
    mx = heapq.heappop(A)*(-1)
    heapq.heappush(A, (mx//2)*(-1))

print(sum(A)*(-1))


Measured memory_bytes: 16248
#include<stdio.h>

int main()
{
    int N, X, D1 = 0, D2=1, L;

    scanf("%d %d", &N, &X);

    for(int i=1; i<=N; i++)
    {
        scanf("%d", &L);

        D1 = D1 + L;

        if(D1 <= X)D2++;
    }

    printf("%d", D2);

    return 0;

}

Measured memory_bytes: 1676
K, N = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

B = []

for i in range(N-1):
    b = A[i+1] - A[i]
    B.append(b)
B.append(K-A[-1]+A[0])


print(K-max(B))

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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
  	cin >> A.at(i);
  }
  
  int now = 1;
  int count = 0;
  while (true) {
  	if (now == 2){
      cout << count << endl;
      break;
    }
    else if (count >=N) {
    	cout << "-1" << endl;
      	break;
    }
    
    now = A.at(now-1);
    count++;
  }
}

Measured memory_bytes: 640
import java.io.*;
import java.util.ArrayList;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] input;
        int i, j;
        
        int n = Integer.parseInt(br.readLine());
        int[] s = new int[n];
        input = br.readLine().split(" ");
        for (i = 0; i < n; i++) {
            s[i] = Integer.parseInt(input[i]);
        }

        int q = Integer.parseInt(br.readLine());
        int[] t = new int[q];
        input = br.readLine().split(" ");
        for (i = 0; i < q; i++) {
            t[i] = Integer.parseInt(input[i]);
        }
        

        int count = 0;
        ArrayList<Integer> checked = new ArrayList<Integer>();
        int target;
        for (i = 0; i < n; i++) {
            target = s[i];
            if (checked.contains(target)) continue;
            checked.add(target);
            for (j = 0; j < t.length; j++) {
                if (t[j] == target) {
                    count++;
                    break;
                }
            }
        }

        System.out.println(count);
    }
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int>x(n);
    vector<int>y(n);
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    double total=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            total+=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
        }
    }
    printf("%.10lf\n",total*2/n);
}


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

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

	vector<string> data(N);
    for(int i = 0; i < N; i++){
        cin >> data[i];
        sort(data[i].begin(), data[i].end());
    }

    sort(data.begin(), data.end());

    long long ans = 0;
    long long continues = 0;
	for(int i = 1; i < N; i++){
        if(data[i-1] == data[i]){
            continues++;
            ans += continues;
        }else{
            continues = 0;
        }
    }
	
    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define fi first
#define sec second
#define pr priority_queue
ll mod = 1000000007;
ll find(vector<ll> &v, ll n)
{
	if (v[n] == n)
		return n;
	return v[n] = find(v, v[n]);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n, m; cin >> n >> m;
	vector<ll> prt(n), sz(n, 1);
	for (ll i = 0; i < n; i++) prt[i] = i;
	for (ll i = 0; i < m; i++)
	{
		ll x, y; cin >> x >> y;
		x--; y--;
		ll a = find(prt, x);
		ll b = find(prt, y);
		if (a != b)
		{
			if (sz[a] >= sz[b])
			{
				prt[b] = a;
				sz[a] += sz[b];
			}
			else
			{
				prt[a] = b;
				sz[b] += sz[a];
			}
		}
	}
	ll ans = 0;
	for (ll i = 0; i < n; i++)
		ans = max(ans, sz[i]);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 6336
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    ll ans=0;
    if(n*2<=m){
        ans+=n;
        m-=n*2;
        ans+=m/4;
    }
    else{
        ans+=m/2;
    }
    cout<<ans<<endl;
}

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

const int INF_M = 1000000001;

int countI = 0;

int lArr[250001];
int rArr[250001];

void marge(int* a, int start,int end,int mid){
	int n1 = mid - start;
	int n2 = end - mid;
	for(int i = 0; i < n1;i++){
		lArr[i] = a[start + i];
	}
	lArr[n1] = INF_M;
	for(int i = 0;i < n2;i++){
		rArr[i] = a[mid + i];
	}
	rArr[n2] = INF_M;

	int iL = 0;
	int iR = 0;
	for(int i = start; i < end;i++){
		countI++;
		if(lArr[iL] <= rArr[iR]){
			a[i] = lArr[iL];
			iL++;
		}else{
			a[i] = rArr[iR];
			iR++;
		}	
	}
}

void margeSort(int* a,int start,int end){
	if(start + 1 < end){
		int mid = (start +  end) / 2;
		margeSort(a,start,mid);
		margeSort(a,mid,end);
		marge(a,start,end,mid);
	}
}

int main(){
	int n;
	cin >> n;
	int a[500000];
	for(int i = 0; i < n;i++){
		cin >> a[i];
	}
	margeSort(a,0,n);
	for(int i = 0;i < n;i++){
		cout << a[i] << ((i != n -1) ? " " : "") << flush;
	}
	cout << endl;
	cout << countI << endl;
}


Measured memory_bytes: 6988
N = int(input())
Ts = list(map(int, input().split()))
M = int(input())
Ds = []
for i in range(M):
    Ds.append(list(map(int, input().split())))


for d in Ds:
    print(sum(Ts) - Ts[d[0] - 1] + d[1])

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    string o,e;	cin >> o >> e;
    rep(i, o.size()+e.size()){
	if(i%2==0){
	    printf("%c", o[i/2]);
	}else{
	    printf("%c", e[i/2]);
	}
    }
    printf("\n");
}


Measured memory_bytes: 256
import std.stdio,std.string,std.conv,std.array,std.range;

int main()
{
	string s;
	while((s = readln.chomp).length != 0)
	{
		string[] _s = s.split(" ");
		double[] stack;
		foreach(i;0.._s.length)
		{
			if(_s[i] == "+")
			{
				double temp = stack.back;
				stack.popBack;
				double temp2 = stack.back;
				stack.popBack;
				stack ~= temp2 + temp;
			}
			else if(_s[i] == "-")
			{
				double temp = stack.back;
				stack.popBack;
				double temp2 = stack.back;
				stack.popBack;
				stack ~= temp2 - temp;
			}
			else if(_s[i] == "*")
			{
				double temp = stack.back;
				stack.popBack;
				double temp2 = stack.back;
				stack.popBack;
				stack ~= temp2 * temp;
			}
			else if(_s[i] == "/")
			{
				double temp = stack.back;
				stack.popBack;
				double temp2 = stack.back;
				stack.popBack;
				stack ~= temp2 / temp;
			}
			else
			{
				stack ~= _s[i].to!double;
			}
		}
		writefln("%.6f",stack.back);
	}
	return 0;
}

Measured memory_bytes: 1144
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())

    ans = 10 ** N - 2 * 9 ** N + 8 ** N
    print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10896
n,m = map(int,input().split())
d={}
for i in range(n):
    d[i+1] = int(input())
for l in range(m):
    k = l+1
    for j in range(n):
        i = j+1
        if i == n:
            break
        if d[i]%k > d[i+1]%k:
            t = d[i]
            d[i] = d[i+1]
            d[i+1] = t
for i in range(n):
    print(d[i+1])

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll m,d;
  cin >> m >> d;

  ll ans = 0;
  for(ll i = 1; i <= m; i++){
    for(ll j = 1; j <= d; j++){
      ll d1 = j % 10;
      ll d10 = j / 10;
      if(d1 * d10 == i && d1 >= 2 && d10 >= 2){
        ans++;
      }
    }
  }

  cout << ans << endl;
  
  
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    val s = readLine()!!

    fun containsDup(s: String) : Boolean {
        val map = hashMapOf<Char, Int>()
        s.forEach {
            map[it] = map.getOrElse(it, { 0 }) + 1
            if (map[it]!! > s.length / 2) {
                return true
            }
        }
        return false
    }

    var size = 2
    for (i in 0 until s.length - 1) {
        if (containsDup(
                        s.substring(i, i + size)
                )) {
            print(i + 1)
            print(' ')
            print(i + size)
            return
        }
    }

    size = 3
    for (i in 0 until s.length - 2) {
        if (containsDup(
                        s.substring(i, i + size)
                )) {
            print(i + 1)
            print(' ')
            print(i + size)
            return
        }
    }
    println("-1 -1")
}

Measured memory_bytes: 48096
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-04-27 14:27
# @url:https://atcoder.jp/contests/abc164/tasks/abc164_d
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
# (a*b)%p=(a%p*b%p)%p
# (a+b)%p=(a%p+b%p)%p
def main():
    k=2019
    s=str(input())[::-1]
    mod10=[1]
    for i in range(1,len(s)):
        mod10.append((mod10[i-1]%k*10%k)%k)
    inverse=[]
    for i in range(0,len(s)):
        n=int(s[i])
        if n!=0:
            if len(inverse)>0:
                mod=((n%k*mod10[i])%k+inverse[-1])%k
            else:
                mod=((n%k*mod10[i])%k)%k
            inverse.append(mod)
    res=[x for x in list(collections.Counter(inverse).items()) if x[0]==0 or x[1]>1]
    # print (inverse)
    # print (res)
    ans=0
    for r in res:
        if r[0]==0:
            ans+=(r[1]+1)*r[1]//2
        else:
            ans+=(r[1]-1)*r[1]//2
    print (ans)    
    # 181718171
    # print ((1111111117*10+1)%2019,((1111111117%2019*10%2019)%2019%2019+1%2019)%2019)
    # print (8171%2019,((10**3%2019*10%2019)%2019%2019+8171%2019)%2019)
    # print ((11111111171-965)%2019)
if __name__ == "__main__":
    main()

Measured memory_bytes: 84692
import bisect
a,b,q=map(int,input().split())
inf=10**18
s=[-1*inf]+[int(input()) for i in range(a)]+[inf]
t=[-1*inf]+[int(input()) for i in range(b)]+[inf]
for i in range(q):
  q=int(input())
  x=bisect.bisect_right(s,q)
  y=bisect.bisect_right(t,q)
  res=inf
  for S in [s[x-1],s[x]]:
    for T in [t[y-1],t[y]]:
      d1, d2 = abs(S - q) + abs(T - S), abs(T - q) + abs(S - T) 
      res = min(res, d1, d2)
  print(res)

Measured memory_bytes: 13864
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        n: u64,
        m: u64
    }
    println!("{}", n*m);
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
#include <vector>
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

using namespace std;
#define int long long
using ll = long long;
const int MX = 1e6;
const ll inf = 1e13;
const int mod = 1e9+7;

signed main() {
    int a,b,m;
    cin >> a >> b >> m;
    vector<int> aa(a);
    vector<int> bb(b);
    int mia = inf;
    int mib = inf;
    rep(i,a) {
        cin >> aa[i];
        mia = min(mia,aa[i]);
    }
    rep(i,b) {
        cin >> bb[i];
        mib = min(mib,bb[i]);
    }
    int ans = mia+mib;
    rep(i,m) {
        int x,y,c;
        cin >> x >> y>> c;
        x--; y--;
        ans = min(ans, aa[x]+bb[y]-c);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4820
n=int(input())
if(n>=64):
  print(64)
elif(n>=32):
  print(32)
elif(n>=16):
  print(16)
elif(n>=8):
  print(8)
elif(n>=4):
  print(4)
elif(n>=2):
  print(2)
else:
  print(1)



Measured memory_bytes: 2940
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

type drink struct {
	taste int
}

type drinkList []drink

func (d drinkList) Len() int {
	return len(d)
}

func (d drinkList) Swap(i, j int) {
	d[i], d[j] = d[j], d[i]
}

func (d drinkList) Less(i, j int) bool {
	return d[i].taste > d[j].taste
}

func dif(dList drinkList, index int) int {
	return dList[index].taste - dList[index+1].taste
}

func min(a, b int) int {
	if a > b {
		return b
	}

	return a
}

func main() {
	io := NewIo()
	defer io.Flush()

	X := io.NextInt()
	Y := io.NextInt()
	Z := io.NextInt()
	K := io.NextInt()

	listA := make(drinkList, X)
	for i := range listA {
		listA[i].taste = io.NextInt()
	}
	listB := make(drinkList, Y)
	for i := range listB {
		listB[i].taste = io.NextInt()
	}
	listC := make(drinkList, Z)
	for i := range listC {
		listC[i].taste = io.NextInt()
	}

	sort.Sort(listA)
	sort.Sort(listB)
	sort.Sort(listC)

	XY := make(drinkList, X*Y)
	for i := 0; i < X; i++ {
		for j := 0; j < Y; j++ {
			XY[i*Y+j].taste = listA[i].taste + listB[j].taste
		}
	}

	sort.Sort(XY)

	XYZ := make(drinkList, K*Z)

	for i := 0; i < min(K, X*Y); i++ {
		for j := 0; j < Z; j++ {
			XYZ[i*Z+j].taste = XY[i].taste + listC[j].taste
		}
	}

	sort.Sort(XYZ)

	for i := 0; i < min(K, X*Y*Z); i++ {
		io.PrintLn(XYZ[i].taste)
	}
}

Measured memory_bytes: 35260
import java.io.*;

class Main{
  public static void main(String[] args){
    try{
    InputStreamReader is = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(is);
    String s = br.readLine();
    String[] sp = s.split(" ");
    int x = Integer.parseInt(sp[0]);
    int y = Integer.parseInt(sp[1]);
    System.out.println((x-1)*(y-1));
    }catch(IOException e){
      System.out.println(e);
    }
  }
}

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

using namespace std;

typedef long long ll;

int main()
{
    int N;
    int result = 0, cache = 0;
    int a, b;
    cin >> N;
    for(a = 1; a <= N; a += 2) {
        for(b = 1; b <= a; ++b) {
            if(a % b == 0) {
                cache++;
            }
        }
        if(cache == 8) {
            result++;
        }
        cache = 0;
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A;
  unsigned long long int p=1;
    cin>>A;
	unsigned long long int B=1000000007;
  for(int i=1;i<=A;i++){
    p=p*i;
    p=p%B;
  }
  cout<<p<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i = 0; i < (a); i++)
#define reps(i, a, b) for(int i = (a); i < (b); i++)
#define INF 1e9
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
void output(pdi d) {
	printf("%d %.2lf\n", d.second, d.first);
}
int main() {
	vector<vector<pdi>> input = vector<vector<pdi>>(3, vector<pdi>(8, make_pair(0,0)));
	vector<pdi> h;
	rep(i, 3) {
		rep(j, 8) cin >> input[i][j].second >> input[i][j].first;
		sort(input[i].begin(), input[i].end(), greater<pdi>());
		rep(j, 2) {
			output(input[i].back());
			input[i].pop_back();
		}
		rep(j, input[i].size()) h.push_back(input[i][j]);
	}
	sort(h.begin(), h.end(), greater<pdi>());
	rep(i, 2) {
		output(h.back());
		h.pop_back();
	}
	
	return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main(){
	long long int m;
	int n;
	long long int a;
	a = 1;
	cin >> m;
	cin >> n;
	while (n > 0){
		
		if (n & 1){
			a *= m;
			a %= 1000000007;
		}
		n >>= 1;
		m *= m;
		m %= 1000000007;
	}
	cout << a << endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
		int N;
		cin >> N;
		
		int A[N];
		for (int i = 0; i < N; i++) cin >> A[i];
		sort(A, A+N);

		int ans = 0, ptr = 0;
		while(ptr < N) {
				int x = A[ptr], cnt = 0;
				while (ptr < N && A[ptr] == x) { 
						ptr++; cnt++;
				}
				ans += cnt % 2;
		}
		cout << ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void)
{
  int i,n,m,cnt,total;
  double t;
  total=0;
  cnt=0;
  scanf("%d",&n);
  scanf("%d",&m);
  int a[n];
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  for(i=0;i<n;i++)
  {
    total=total+a[i];
  }
  t=4*m;
  for(i=0;i<n;i++)
  {
  if(a[i]>=total/t)
    cnt++;
  }
  if(cnt>=m)
    printf("Yes");
  else
    printf("No");
return 0;
}

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

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int MAX = 1e9;

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

    int n, k, s;
    cin >> n >> k >> s;

    if (s == MAX) {
        for (int i = 0; i < k; i++)
            cout << s << " ";
        for (int i = 0; i < n - k; i++) {
            cout << "1 ";
        }
    }
    else {
        for (int i = 0; i < k; i++)
            cout << s << " ";
        for (int i = 0; i < n - k; i++)
            cout << MAX << " ";
    }

    return 0;
}   

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

int main() {
  int x,y;
  cin >> x >> y;
  if(y>4*x || y<2*x || (y-2*x)%2==1)
  cout << "No" << endl;
  else
  cout << "Yes" << endl;
}


Measured memory_bytes: 3596
import Control.Monad

myfold (a:as) (b:bs) =
  a*b + myfold as bs
myfold [] [] = 0


main = do
  [n, m, c] <- (map read) . words <$> getLine
  b <- (map read) . words <$> getLine
  a <- replicateM n ((map read . words) <$> getLine)
  let 
    ret = length $ filter (\l -> myfold b l + c > 0) a
  putStrLn $ show ret


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define Si size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define Em empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define Fi first
#define Se second
#define Pi acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>

void FAST();
LL big_mod(LL val,LL pow,LL mod);
LL mod_inverse(LL val,LL mod);









int main()
{
//    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int a,b;
    S("%d %d",&a,&b);
    P("%d",max(a+b,max(a,b)+(max(a,b)-1)));
    return 0;
}







void FAST()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

LL big_mod(LL val,LL pow,LL mod)
{
    LL res = 1;
    val = val % mod;
    while(pow > 0)
    {
        if(pow & 1)
        {
            res = (res*val) % mod;
        }
        pow = pow >> 1;
        val = (val*val) % mod;
    }
    return res;
}

LL mod_inverse(LL val,LL mod)
{
    LL mod1 = mod;
    if(mod == 1)
    {
        return 0;
    }
    LL y = 0;
    LL x = 1;
    LL quotient,temp;
    while(val > 1)
    {
        quotient = val / mod;
        temp = mod;
        mod = val % mod;
        val = temp;
        temp = y;
        y = x - quotient * y;
        x = temp;
    }
    if(x < 0)
    {
        x += mod1;
    }
    return x;
}


Measured memory_bytes: 256
using System; 
using System.Text; 
using System.Collections.Generic;
using System.Linq; 
using E = System.Linq.Enumerable; 

class Program {
     static int R;
     static int C;
     static int[] S;
     static int[] G;
     static int[,] map;
     
     static void Main(string[] args) {
     //入力を受け取る
     var N  = int.Parse(Console.ReadLine());
     var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
     
     var twice = 0;
     var forth = 0;
     var other = 0;
     
     for(int i = 0;i < N ; i++){
         var num = A[i];
         if(num%4 == 0){
             forth++;
         }else if(num%2 == 0){
             twice++;
         }else{
             other++;
         }
     }
     
     var flag = true;
     if((other > forth) ){
         flag = false;
         if(other-forth ==1 && twice == 0){
             flag = true; 
         }
     }
     
     if(flag){
         Console.WriteLine("Yes");
     }else{
         Console.WriteLine("No");
     }
        
     }
     
     
}
     
     
     
     
     


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

int main() {
  string s;
  cin >>s;
  int a=s[0]-'0', b=s[1]-'0', c=s[2]-'0', d=s[3]-'0';
  if(a+b+c+d==7) cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
  else if(a-b+c+d==7) cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
  else if(a+b+c-d==7) cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
  else if(a+b-c+d==7) cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
  else if(a-b-c+d==7) cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
  else if(a-b+c-d==7) cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
  else if(a+b-c-d==7) cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
  else if(a-b-c-d==7) cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,x,p[120],vis[120];
bool ok(int val){
	if(val>100) return true;
	if(val<=0) return true;
	if(!vis[val]) return true;
	return false;
}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>x>>n;
	for(int i=1;i<=n;i++) cin>>p[i],vis[p[i]]++;
	for(int delta=0;;delta++){
		if(ok(x-delta)){
			cout<<x-delta<<endl;
			return 0;
		}
		if(ok(x+delta)){
			cout<<x+delta<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
#include <math.h>
int ans;
int main(int argc, char* argv[]){
  long int a,b,c;
  scanf("%ld %ld %ld",&a,&b,&c);
  if (b-c>=0) {
    printf("delicious");
    return 0;
  }
  if(a+(b-c)>=0){
    printf("safe");
    return 0;
  }else{
    printf("dangerous");
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n;
  cin>>n;
  cout<<a[n-1];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int n;
    cin >> n;
    vector<long long> A(n);
    REP(i, n) { cin >> A[i]; }
    long long m = *max_element(A.begin(), A.end());
    vector<long long> B(n);
    REP(i, n) { B[i] = min(m - A[i], A[i]); }
    long long r = A[max_element(B.begin(), B.end()) - B.begin()];
    if(r == m) {
        r = 0;
    }
    cout << m << " " << r << endl;
}

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

typedef long long ll;

using namespace std;

int main()
{
    ll n;
    cin >> n;

    vector<string> s;

    for(ll i=0; i<n; i++)
    {
        string tmp;
        cin >> tmp, s.push_back(tmp);
    }

    vector<vector<ll>> hash(n, vector<ll>(27, 0));

    for (ll i=0; i<n; i++)
    {
        for (ll j=0; j<10; j++)
        {
            //cout << s[i][j] << ' ';  
            hash[i][s[i][j]-97]++;  
        }
        //cout << endl;
    }

    multiset<string> mset;

    for (ll i=0; i<n; i++)
    {
        string buf;
        for (ll j=0; j<27; j++)
        {
            buf += hash[i][j] + 48;
        }
        mset.insert(buf);
    }

    ll count(0);

    while (!mset.empty())
    {
        auto it = mset.begin();

        ll inc = mset.count(*it);
        count += inc * (inc-1) / 2;

        mset.erase(*it);
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 44020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll mod = 1e9+7;
ll INF = 1e17;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
/*ll power(ll a,ll b,ll p)
{
	ll res=1;
	a%=p;
	while(b>0)
	{
		if(b&1)
		res=res*a%p;
		a=a*a%p;
		b>>=1;
	}
	return(res);
}*/
/*void dfs(ll x)
{
	vis[x]=true;
	for(ll i=0;i<v[x].size();i++)
	{
		if(vis[v[x][i]]==false)
		dfs(v[x][i]);
	}
}*/
/*ll b_search(ll arr[],ll n,ll s)
{
	ll l=0,r=n-1;
	while(l<=r)
	{
		ll mid=l+(r-l)/2;
		if(arr[mid]==s)
		return(mid);
		if(arr[mid]<s)
		l=mid+1;
		else
		r=mid-1;
	}
	return(-1);
}*/
 
void solve()
{
	ll n;
	cin>>n;
	ll c=n;
	n--;
	ll ans=0;
	for(ll i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			//cout<<i<<" "<<n/i<<endl;
			if(i!=1)
			ans++;
			if(i!=n/i)
			ans++;
		}
	}
	for(ll i=1;i*i<=c;i++)
	{
		if(c%i==0)
		{
			if(i==1)
			{
				ans++;
				continue;
			}
			else
			{
				ll c1=i;
				ll c2=c/i;
				while(c2%c1==0)
				{
					c2/=c1;
				}
				if(c2%c1==1)
				ans++;
			}
		}
	}
	cout<<ans<<endl;
}
 
int main()
{
	IOS
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
    return(0);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair
#define mod 1000000007
#define qmod 998244353
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll LINF = LLONG_MAX;

int main(){
	int a,b;
	cin>>a>>b;
	string x,y;
	x = to_string(a);
	y = to_string(b);
	string res = x+y;
	int boi = stoi(res);
	int ok = sqrt(boi);
	if(ok*ok==boi){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}

	


}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for( int i = 0;i<values.length;i++){
			values[i] = i + 1;
		}
		for(int i = 0; i< n ;i++){
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0])-1;
			int b = Integer.parseInt(ab[1])-1;
			int c;
			c = values[a];	
			values[a] = values[b];
			values[b] = c;
		}
		for(int i = 0;i<values.length;i++){
			System.out.println(values[i]);		
		}
	}
}

Measured memory_bytes: 17392
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
#define MOD 100000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
int rec(int h,int m,int s){
      return h*3600+m*60+s;
}
int cnt[60*60*24+1];
int main(){
      int n;
      while(cin>>n&&n){
            memset(cnt,0,sizeof(cnt));
            int h1,m1,s1,h2,m2,s2;
            REP(i,n){
                  scanf("%d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);
                  cnt[rec(h1,m1,s1)]++;
                  cnt[rec(h2,m2,s2)]--;
            }
            int ans=0;
            REP(i,60*60*24+1){
                  if(i==0)continue;
                  cnt[i]+=cnt[i-1];
                  ans=max(cnt[i],ans);
            }
            cout<<ans<<endl;
      }
}

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

int main() {
  int N;
  string S, T;
  cin >> N;
  cin >> S >> T;
  string ans;
  
  for (int i = 0; i < N; i++) {
    ans += S[i];
    ans += T[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define trav(var, container) for(auto& var: container)
#define all(container) begin(container), end(container)
using namespace std;
using ld = long double; 
using ll = long long;
const int N = (int)1e5;

ll arr[N];
ll gcdRight[N], gcdLeft[N];
int main() {
  int n; cin >> n;
  for(int i = 0; i < n; ++i) cin >> arr[i];
  gcdLeft[0] = arr[0];
  for(int i = 1; i < n; ++i) {
    gcdLeft[i] = __gcd(gcdLeft[i-1], arr[i]);
  }
  gcdRight[n-1] = arr[n-1];
  for(int i = n - 2; i >= 0; --i) {
    gcdRight[i] = __gcd(gcdRight[i+1], arr[i]);
  }
  ll ans = max(gcdRight[1], gcdLeft[n - 2]);
  for(int i = 1; i <= n - 2; ++i) {
    ans = max(ans, __gcd(gcdLeft[i-1], gcdRight[i+1]));
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 2560
N = int(input())
h = [int(i) for i in input().split()]

cost1 = abs(h[0] - h[1])
if N==2:
    print(cost1)
    exit()
cost2 = abs(h[0] - h[2])

for i in range(3, N):
    cost = min(cost1 + abs(h[i] - h[i-2]), cost2 + abs(h[i] - h[i-1]))
    cost1 = cost2
    cost2 = cost

print(cost)


Measured memory_bytes: 13928
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main()
{
    cin.tie(0);

    int n;
    cin >> n;

    int pt = 0, px = 0, py = 0;
    for (int i = 0; i < n; i++) {
        int nt, nx, ny;
        cin >> nt >> nx >> ny;

        bool ok = [&]() -> bool {
            int dt = nt - pt;
            int dx = abs(px - nx);
            int dy = abs(py - ny);

            // cout << dt << ", " << dx << ", " << dy << endl;

            if ((dx + dy) % 2 != dt % 2) {
                // cout << "1" << endl;
                return false;
            }
            if (dx + dy > dt) {
                // cout << "2" << endl;
                return false;
            }
            return true;
        }();

        if (!ok) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i = 0; i < N; i++){
    cin >> L[i];
  }
  sort(L.begin(),L.end());
  int sum = 0;
  bool ok = false;

  for(int i = 0; i < N-1; i++){
    sum += L[i];
  }
  if(sum > L[N-1]) ok = true;
  if(ok){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n,m=map(int,input().split())
bridge=[[] for i in range(m)]
leader=[i for i in range(n+1)]
member=[1 for i in range(n+1)]
for i in range(m):
    bridge[i]=list(map(int,input().split()))
ans=[0 for i in range(m+1)]
ans[0]=int((n-1)*n/2)
k=1
for i in reversed(bridge):
    le0=leader[i[0]]
    le1=leader[i[1]]
    while le0!=leader[le0]:
        le0=leader[le0]
        leader[i[0]]=le0
        
    while le1!=leader[le1]:
        le1=leader[le1]
        leader[i[1]]=le1
        
    if le0!=le1:
        ans[k]=ans[k-1]-member[le0]*member[le1]
        if member[le0]>=member[le1]:
            member[le0]+=member[le1]
            leader[le1]=le0
        else:
            member[le1]+=member[le0]
            leader[le0]=le1
    else:
        ans[k]=ans[k-1]
    if ans[k]==0:
        ans[k:]=[0 for l in range(m-k)]
        break
    k+=1
for i in range(m):
    print(ans[m-1-i])

Measured memory_bytes: 35024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    string s;
    cin >> s;
    int cnt[128] = {};
    for (char c : s) cnt[c]++;
    for (int i = 'a'; i <= 'z'; ++i) {
        if (cnt[i] > 1) {
            cout << "no\n";
            return 0;
        }
    }
    cout << "yes\n";
    return 0;
}

Measured memory_bytes: 760
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<limits>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;

	cout << H * W - h * W - w * H + h * w << endl;
	return 0;
}

Measured memory_bytes: 256