akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int, A: "List[int]"):
    s = sum(A)
    cnt = 0
    for i in range(N):
        if A[i] >= s / (4 * M):
            cnt += 1
    print(YES if cnt >= M else NO)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define f1(a,b,c) for(int c=a;c<=b;c++)
#define f2(a,b,c) for(int c=a;c>=b;c--)
#define f3(a,b,c) for(int c=a;c;c=b)
#define so1(a,n) sort(a+1,a+n+1,mycmp);
#define so2(a,n) sort(a+1,a+n+1);
#define ll long long
#define itn int
#define ubt int 
const int twx=3e5+100;
const int inf=0x7fffffff;
ll read()
{
    ll sum=0;
    ll flag=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            flag=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        sum=((sum*10)+c-'0');
        c=getchar();
    }
    return sum*flag;
}
ll n;
ll a[twx];
void init()
{
	n=read();
    vector<int> cnt(n+1),sum(n+1),ans(n);
    f1(0,n-1,i)
    {
        int  x=read();
        ++sum[cnt[x]++];
    }
    int it=0;
    int acc=0;
    f2(n,1,i)
    {
        while(acc>=it*i)
        {
            acc+=sum[it++];
        }
        ans[i-1]=it-1;
    }
    for(const int e:ans)
    {
        printf("%d\n",e);
    }
}
void work()
{
	
}
void print()
{
	
}
int main()
{
    init();
	return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

const int N = 1000;
const int INF = 100000000;

class State{
public:
  int y, x, t;
  State(int y, int x, int t) : y(y), x(x), t(t) {}
};

int w, h, n, x, y, data[N][N], vis[N][N], dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1}, ny, nx, gx, gy;
char mapd[N][N];

int solve(){
  fill(vis[0], vis[N], INF);
  vis[0][0] = 0;
  State u = State(0, 0, 0);
  queue<State> q;
  q.push(u);
  while(!q.empty()){
    u = q.front(); q.pop();
    for(int i=0;i<4;i++){
      ny = u.y + dy[i];
      nx = u.x + dx[i];
      if(0 <= ny && ny < h && 0 <= nx && nx < w){
        State v = State(ny, nx, u.t);
        if(mapd[ny][nx] == '#'){
          if(data[ny][nx] == 0) continue;
          if(data[ny][nx] > u.t) v.t = data[ny][nx];
        }
        if(vis[ny][nx] > v.t){
          vis[ny][nx] = v.t;
          q.push(v);
        }
      }
    }
  }
  return vis[gy][gx] == INF ? -1 : vis[gy][gx];
}

main(){
  cin >> w >> h;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> mapd[i][j];
      if(mapd[i][j] == 't'){
        gy = i;
        gx = j;
        mapd[i][j] = '.';
      }
    }
  }
  cin >> n;
  fill(data[0], data[N], 0);
  for(int i=1;i<=n;i++){
    cin >> x >> y;
    data[y][x] = i;
  }
  cout << solve() << endl;
}

Measured memory_bytes: 9672
/******* all required header files *******/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;

/*****All definitions*******/
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int>
#define vs vector<string>
#define vc vector<char>
#define mp make_pair
#define ll long long int
#define pb push_back
#define F first
#define S second
/***************************/

int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

	ios_base::sync_with_stdio(0);
	cin.tie(0);

    int n;
    cin>>n;
    vi v(n);
    for(int i = 0; i < n; i++)
    {
        cin>>v[i];
    }
    
    int cnt = 0;
    for(int i = 1; i < n-1; i++)
    {
        if((v[i] < v[i-1] && v[i+1] < v[i]) || (v[i] > v[i-1] && v[i+1] > v[i]))
        cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	mt := make([]int, 10)

	for i := 0; i < 10; i++ {
		fmt.Scan(&mt[i])
	}

	sort.Ints(mt)
	fmt.Printf("%d\n%d\n%d\n", mt[9], mt[8], mt[7])

}



Measured memory_bytes: 1100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    static int debt = 100000;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";

        while ((line = br.readLine()) != null && !line.isEmpty()) {
            int w = Integer.parseInt(line);
            for (int i = 0; i < w; i++) {
                debt *= 1.05;
                if (debt % 1000 > 0) {
                    debt = (debt / 1000 + 1) * 1000;
                }
            }
            System.out.println(debt);
        }
    }
}

Measured memory_bytes: 16864
//============================================================================
// Name        : training.cpp
// Author      : CoNKeR The Red Squirrel
//============================================================================
#include <bits/stdc++.h>

#define MAX_N 200005
#define INF 1000000000
#define bit(mask, i) (mask & (1<<i))

using namespace std;

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef long long ll;
typedef double lf;

lf PI = 2.0*acos(0.0);

int lis(vi &v) {
    set<int> p;
    for(int i = 0; i < (int)v.size(); ++i) {
        set<int>::iterator it = p.lower_bound(v[i]);
        if(it != p.end()) { p.erase(it); }
        p.insert(v[i]);
    }
    return p.size();
}

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

    //freopen("acmproject.in", "r", stdin);
    //freopen("acmproject.out", "w", stdout);

    ii a, b;
    int n;
    cin>>a.first>>a.second>>b.first>>b.second>>n;
    vii fountains(n);
    while(n--) {
        cin>>fountains[n].first>>fountains[n].second;
    }
    sort(fountains.begin(), fountains.end());
    vi interval;
    if(a > b) { swap(a, b); }
    int x1 = a.first, x2 = b.first;
    int y1 = min(a.second, b.second), y2 = max(a.second, b.second);
    int c = a.second > b.second ? -1 : 1;
    for(int i =0; i < (int)fountains.size(); ++i) {
        if(fountains[i].first >= x1 && fountains[i].second >= y1 && fountains[i].first <= x2 && fountains[i].second <= y2) {
            interval.push_back(c*fountains[i].second);
        }
    }
    int l = lis(interval), x = b.first - a.first, y = abs(b.second - a.second);
    lf sol = 100.0*(lf)(x + y);
    sol += 5.0*(PI - 4.0)*(lf)l;
    if(l == min(x, y) + 1) { sol += 5.0*PI; }

    cout<<setprecision(16)<<fixed<<sol<<"\n";

    return 0;
}

Measured memory_bytes: 12020
package main

import (
        "fmt"
)

func solution(n int) int {
        sum := 0
        for i := 1; i <= n; i++ {
                for j := 1; j <= n; j++ {
                        for k := 1; k <= n; k++ {
                                sum += threeGcd(i, j, k)
                        }
                }
        }
        return sum
}

func main() {
        var k int
        fmt.Scan(&k)
        fmt.Println(solution(k))
}

func threeGcd(a, b, c int) int {
        return gcd(gcd(a, b), c)
}
func gcd(a, b int) int {
        var tmp int
        for a%b != 0 {
                tmp = b
                b = a % b
                a = tmp
        }
        return b
}

Measured memory_bytes: 1780
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll X, A, B;
    scanf("%lld %lld %lld", &X, &A, &B);
    printf("%lld\n", (X-A)%B);
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 256
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<i64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut dp: Vec<i64> = vec![1 << 30; n + 2];
    dp[0] = 0;
    for i in 0..n - 1 {
        dp[i + 1] = std::cmp::min(dp[i + 1], dp[i] + (a[i + 1] - a[i]).abs());

        if i + 2 < n {
            dp[i + 2] = std::cmp::min(dp[i + 2], dp[i] + (a[i + 2] - a[i]).abs());
        }
    }
    println!("{}", dp[n - 1]);
}


Measured memory_bytes: 6396
#include <stdio.h>
  int main(){
	  int a[5];
     scanf("%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4]);
     int i,j;
      for(i=0;i<5;i++){
         for(j=0;j<4;j++){
             if(a[j]<a[j+1]){
                  int x=a[j+1];
                  a[j+1]=a[j];
                  a[j]=x;
             }
          }
       }
printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);
return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define int long long
using namespace std ;
int read() {
  int x = 0 , f = 1 ;
  char c = getchar() ;
  while(c < 48 || c > 57) {
    if(c == '-') f = -1 ;
    c = getchar() ;
  }
  while(c > 47 && c < 58) {
    x = (x << 1) + (x << 3) + (c & 15) ;
    c = getchar() ;
  }
  return x * f ;
}
void print(int x) {
  if(x < 0) x = -x , putchar('-') ;
  if(! x) { putchar('0') ; }
  static char st[30] ; int stp = 0 ;
  while(x) { st[++ stp] = x % 10 ^ 48 ; x /= 10 ;}
  while(stp) { putchar(st[stp --]) ; }
  putchar('\n') ;
}
int n ;
const int N = 200 + 10 ;
struct Node {
  int x , y ;
} b[N][N] ;
int a[N] ;
int ans = 0 , pd[N] ;
int c() {
  for(int i = 1 ; i <= n ; i ++) {
    if(! pd[i]) continue ;
    for(int j = 1 ; j<= a[i] ; j ++) {
      if(pd[b[i][j].x] != b[i][j].y)
      return 0 ;
    }
  }
  return 1 ;
}
void dfs(int x , int y) {
  if(x == n + 1) {
    if(y > ans && c()) ans = y ;
    return ;
  }
  pd[x] = 0 ;
  dfs(x + 1 , y) ;
  pd[x] = 1 ;
  dfs(x + 1 , y + 1) ;
  
}
signed main() {
  n = read() ;
  for(int i = 1 ; i <= n ; i ++) {
    a[i] = read() ;
    for(int j = 1 ; j <= a[i] ; j ++) {
      b[i][j].x = read() ; b[i][j].y = read() ;
    }

  }
  dfs(1 , 0) ;
  cout << ans << '\n' ;
  return 0 ;
}


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

int main() {
 
  long long x,a;
  cin >> x;
  
  a = 100;
  int count = 0;
  
  while ( a < x ){
    count++;
    a *= 1.01;
  }
  
  cout << count << endl;
    
    
  
  
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 100000000000000
class WarshallFloyed{
public:
	int V; //????????°
	ll D[256][256]; //i??????j???????????????D[i][j]
	WarshallFloyed(){}
	WarshallFloyed(int _V){
		V = _V;
	}
	void init(){
		for(int i = 0; i < V; ++i){
			for(int j = 0; j < V; ++j){
				if(i == j){
					D[i][j] = 0;
				}
				else{
					D[i][j] = INF;
				}
			}
		}
	}
	bool add_edge(int from,int to,ll cost){
		if(D[from][to] != INF)return false;
		D[from][to] = cost;
		return true;
	}
	bool getShortestPath(){
		for(int k = 0; k < V; ++k){
			for(int i = 0; i < V; ++i){
				for(int j = 0; j < V; ++j){
					D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
				}
			}
		}
		return true;
	}

	void print(){
		for(int i = 0; i < V; ++i){
			for(int j = 0; j < V; ++j){
				if(D[i][j] >= 1e9*2) printf("INF%c",j==V-1?'\n':' ');
				else printf("%lld%c",D[i][j],j==V-1?'\n':' ');
			}
		}
	}
};


int main(){
	int V,E;
	scanf("%d%d",&V,&E);
	WarshallFloyed W = WarshallFloyed(V);
	W.init();
	for(int i = 0; i < E; ++i){
		int a,b;
		ll c;
		scanf("%d%d%lld",&a,&b,&c);
		W.add_edge(a,b,c);
	}
	W.getShortestPath();
	for(int i = 0; i < V; ++i){
		if(W.D[i][i] < 0){
			puts("NEGATIVE CYCLE");
			return 0;
		}
	}
	W.print();
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int main() {
	int n;
	cin >> n;
	set<char> st;
	for (int i = 0; i < n; i++) {
		char c;
		cin >> c;
		st.insert(c);
	}
	cout << (st.size() == 3 ? "Three" : "Four") << endl;
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;

typedef long long ll;

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int a = 0;
	for (int i = 0; i < n; i++) {
		a += s[i] == 'R';
	}
	cout << (a > n - a ? "Yes" : "No") << endl;
	return 0;
}


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

using namespace std;

string s;

int check(int i) {
	if (i >= s.length() || (s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T')) {
		return i;
	}
	else {
		check(i + 1);
	}
}

int main()
{
	cin >> s;

	int res = 0;

	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			int j = check(i + 1) - i;
			res = (max)(j, res);
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (ll i = (f); i < (ll)(n); i++)
#define repe(i, f, n) for (ll i = (f); i <= (ll)(n); i++)
#define accum(x) accumulate((x).begin(), (x).end(), 0)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const ll MOD = 1e9 + 7;

int a[1001];

void f(int X) {
  int x = X;
  for (int i = 2; i * i <= X; i++) {
    if (x % i != 0) continue;
    while (x % i == 0) {
      a[i]++;
      x /= i;
    }
  }
  if (x != 1) a[x]++;
}

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

  repe(i, 2, n) f(i);

  ll ans = 1;
  repe(i, 2, n) {
    if (a[i] == 0) continue;
    ans *= a[i] + 1;
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}


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

long long n,a,m,b,c,qq;
string ss;
int main() {
    cin>>a>>b>>c;
    set<int>st;
    st.insert(a);
    st.insert(b);
    st.insert(c);
    if (st.size()==2){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}


Measured memory_bytes: 256
use num::Complex;
use proconio::input;
use std::f64::consts::PI;

fn main() {
    input! {
        a: f64,
        b: f64,
        h: f64,
        m: f64,
    }

    let p1 = Complex::from_polar(&a, &(h * PI / 6.0 + m * PI / 360.0));
    let p2 = Complex::from_polar(&b, &(m * PI / 30.0));
    let ans = (p1 - p2).norm();
    println!("{}", ans);
}


Measured memory_bytes: 2940
#include<stdio.h>

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


Measured memory_bytes: 2084
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
h,w,m=map(int,input().split())
l={}
u={}
hw=[list(map(int,input().split())) for _ in range(m)]
s=set()

for i in range(m):
    hr,wr=hw[i]
    if hr-1 in u:
        u[hr-1]+=1
    else:
        u[hr-1]=1
    if wr-1 in l:
        l[wr-1]+=1
    else:
        l[wr-1]=1
    s.add((hr-1)*w+wr-1)
resl=0
resu=0
cl=[]
cu=[]
for i in l:
    if resl<l[i]:
        resl=l[i]
        cl=[i]
    elif resl==l[i]:
        cl.append(i)
for i in u:
    if resu<u[i]:
        resu=u[i]
        cu=[i]
    elif resu==u[i]:
        cu.append(i)
ans=0
if resu==m or resl==m :
  print(m)
  exit()
if len(cu)*len(cl)>m:
    ans=resl+resu
else:
    for i in cu:
        for j in cl:
            if i*w+j in s:
                res=resl+resu-1
            else:
                res=resl+resu
            ans=max(res,ans)
print(ans)

Measured memory_bytes: 215948
let N = stdin.ReadLine()

stdin.ReadLine().Split(' ') |> Array.map int
|> Array.sortBy (fun x -> -x)
|> fun arr -> Array.zip [|1..(Array.length arr)|] arr
|> Array.partition (fun (id,x) -> id%2=1)
|> fun (arrAlice, arrBob) -> (Array.sumBy snd arrAlice) - (Array.sumBy snd arrBob)
|> printfn "%d"

Measured memory_bytes: 15056
# https://atcoder.jp/contests/abc064/tasks/abc064_c

N = int(input())
a_list = list(map(int, input().split()))

rate_count_list = [0] * 8   # 各色の人数
count_over_red = 0          # 赤色以上の人数

for a in a_list:

    # aの色を判定
    # 赤色以上の場合
    if a >= 3200:
        count_over_red += 1

    # 灰色から順に見ていく
    else:
        for i in range(8):
            if i == 0:
                min_in_rate = 1
            else:
                min_in_rate = 400 * i

            max_in_rate = 400 * (i + 1)

            if min_in_rate <= a < max_in_rate:
                rate_count_list[i] = 1
                break

ans_min = sum(rate_count_list)

ans_max = ans_min + count_over_red

print(str(max(ans_min, 1)) + ' ' + str(ans_max))



Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;

#define ul unsigned long 
#define ull unsigned long long
#define li long long int

int main()
{
  ul n,ct=0;
  cin >> n;

  for (ul i=1;i<=n;i++) {
    if (i >= 1 && i < 10) ct++;
    else if (i >= 100 && i < 1000) ct++;
    else if (i >= 10000 && i < 100000) ct++;
  }

  cout << ct<<endl;

  return 0;
}


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


int main(){
  int a;
  cin >> a;
  string s;
  s = to_string(a);
  if(s.at(1) == s.at(2) && (s.at(1)==s.at(0) || s.at(2)==s.at(3))){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define int long long
using namespace std;
int gcd(int x,int y){
	if(y==0) return x;
	return gcd(y,x%y);
}
signed main(){
	while(true){
		int H,h0,m0,s0;
		cin>>H>>h0>>m0>>s0;
		if(H==0) break;
		int h_=h0,m=m0;
		bool fst=1;
		while(true){
			bool en=0;
			for(int h=h_-H;h<=h_+H;h+=H){
				int sa=119*H-1;
				int sb=3600*h+60*(H+1)*m;
				if(sb<0||sb>=sa*60){
				}else if(fst&&sb<sa*s0){
				}else if( (60*sb*H-3600*h*sa+60*m*sa+sb)%(3600*H*sa)==0 ){
				}else{
					int g=gcd(sa,sb);
					cout<<h_<<" "<<m<<" "<<sb/g<<" "<<sa/g<<endl;
					en=1;
					break;
				}
			}
			if(en) break;
			fst=0;
			m++;
			if(m==60) m=0,h_++;
			if(h_==H) h_=0;
		}
	}
}

Measured memory_bytes: 1156
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(unused_macros)]
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()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, string).chars().collect::<vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, string).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("parse error")
    };
}

fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize
    }
    println!("{} {} {}", c, a, b);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
#define fst first
#define snd second
#define pb push_back
 
template<typename T> bool chkmin(T&a, T b) { return a > b ? a = b, 1 : 0; }
template<typename T> bool chkmax(T&a, T b) { return a < b ? a = b, 1 : 0; }
 
const LL mod = 1e9 + 7;
 
LL N, A, B;
LL a[100010], vis[100010];
LL fac[100010], ifac[100010];
 
 
LL fpm(LL base, LL exp) {
    LL ans = 1;
    for(; exp > 0; exp >>= 1) {
        if(exp & 1) 
            ans = ans * base % mod;
        base = base * base % mod;
    }return ans;
}
LL C(LL n, LL k) { 
    if(n < k) return 0;
    return fac[n] * ifac[k] % mod * ifac[n-k] % mod; }
 
int main() {
 
  //  freopen("out.txt", "w", stdout);
 
    cin >> N;
    fac[0] = ifac[0] = 1;
    for(LL i = 1; i <= N+1; i++) {
        fac[i] = fac[i-1] * i % mod;
        ifac[i] = fpm(fac[i], mod-2);
    }
 
    LL pos1, pos2;
    for(LL i = 1; i <= N+1; i++) {
        cin >> a[i];
        if(vis[a[i]]) {
            pos1 = vis[a[i]];
            pos2 = i;
        }
        vis[a[i]] = i;
    }
 
    for(LL i = 1; i <= N+1; i++) {
        LL ans = C(N+1, i);
        ans = (mod + ans - C(pos1-1+N+1-pos2, i-1)) % mod;
        cout << (ans + mod) % mod << endl;
    }
    return 0;
}

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

int main () {
  string s;
  cin >> s;
  
  map<char,int> x;
  for (int i = 0; i < s.size(); i++) {
    if (!x.count(s[i])) {
      x[s[i]] = 0;
    }
    if (x.size() == 26) {
      cout << "None" << endl;
      return 0;
    }
  }
  for (char i = 'a'; i <= 'z'; i++) {
    if (!x.count(i)) {
      cout << i << endl;
      return 0;
      
    }
  }
}

Measured memory_bytes: 3680
x, n = map(int, input().split())
p = list(map(int, input().split()))

flag = 0
i = 0
while (flag == 0):
    if (x - i) not in p:
        flag = 1
        print(x - i)
    elif (x + i) not in p:
        flag = 1
        print(x + i)
    else:
        i += 1

Measured memory_bytes: 9196
A, B = map(int, input().split())

def cumxor(P):
  x = P % 4
  if x == 0:
    return P
  elif x == 1:
    return 1
  elif x == 2:
    return P+1
  else:
    return 0

if A == B:
  print(A)
elif A == 0:
  print(cumxor(B))
else:
  print(cumxor(A-1) ^ cumxor(B))

# 試した
#def cumxor(P):
#  ret = 0
#  for i in range(0,P+1):
#    ret = ret ^ i
#  return ret 
#for i in range(0,130):
#  cx = cumxor(i)
#  print(i, cx, bin(i), bin(cx))



Measured memory_bytes: 9084
S = input()
result = 10**4
for c in set(S):
    work = []
    temp = 0
    for s in S:
        if s == c:
            work.append(temp)
            temp = 0
        else:
            temp += 1
    work.append(temp)
    result = min(result, max(work))
print(result)

Measured memory_bytes: 3060
n,w=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(n)]
dp=[[0]*(w+1) for _ in range(n+1)]
for i in range(n):
    for j in range(w+1):
        if j>=wv[i][0]:
            dp[i+1][j]=max(dp[i][j],dp[i][j-wv[i][0]]+wv[i][1])
        else:
            dp[i+1][j]=dp[i][j]
print(dp[-1][-1])

Measured memory_bytes: 150096
#include <stdio.h>
int N[]={ 6,10,18,14,  2,13,22,11,  3, 5,21,19,  1,17,23, 7,  0, 9,20,15,  4,12,16, 8};
int E[]={15, 7,11,19,  8, 3,14,23, 16, 0, 6,22,  4, 2,18,20, 12, 1,10,21,  9, 5,13,17};
int W[]={ 9,17,13, 5, 12,21,10, 1,  4,20,18, 2, 16,22, 6, 0,  8,23,14, 3, 15,19,11, 7};
int S[]={16,12, 4, 8, 20, 9, 0,15, 23,17, 1, 7, 21, 5, 3,19, 22,13, 2,11, 18,10, 6,14};
int R[]={ 1, 2, 3, 0,  5, 6, 7, 4,  9,10,11, 8, 13,14,15,12, 17,18,19,16, 21,22,23,20};
int L[]={ 3, 0, 1, 2,  7, 4, 5, 6, 11, 8, 9,10, 15,12,13,14, 19,16,17,18, 23,20,21,22};
n,a,d;
char s[9];
int main()
{
	for(;;)
	{
		scanf("%d",&n);
		if(!n)
			break;
		a=1;
		d=0;
		for(;n--;)
		{
			scanf("%s",s);
			if(*s=='N')d=N[d];
			if(*s=='E')d=E[d];
			if(*s=='W')d=W[d];
			if(*s=='S')d=S[d];
			if(*s=='R')d=R[d];
			if(*s=='L')d=L[d];
			a+=d/4+1;
		}
		printf("%d\n",a);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int cnt2 = 0, cnt4 = 0, odd = 0;
  rep(i,N){
    cin >> a[i];
    if(a[i] % 4 == 0) cnt4++;
    else if(a[i] % 2 == 0) cnt2++;
    else odd++;
  }

  odd += (cnt2 % 2);
  
  if(odd <= cnt4 + 1){
    cout << "Yes" << endl;
  }else{
    cout << "No"  << endl;
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vll v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  ll now = 0;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    now = max(now, v[i]);
    if (now <= v[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}


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


int main(){
	int n;
	cin>>n;
	double sum = 0;
	while(n--){
	double x;
	cin>>x;
	sum += (1/x);
	}
	cout << fixed << setprecision(7) << 1/sum << endl;

	return 0;
}

Measured memory_bytes: 888
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]
k=int(input())
print(a[k-1])

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] arrayIn = new int[N];

		for(int i=0;i<arrayIn.length;i++) {
			arrayIn[i] = sc.nextInt();
			if(i==N-1) {
				System.out.print(arrayIn[i]);
			}else {
				System.out.print(arrayIn[i]+" ");
			}
		}
		System.out.println();

		sort(arrayIn);

	}

	public static int[] sort(int[] arrayIn) {

		for(int i=1;i<arrayIn.length;i++) {
			int v = arrayIn[i];

			for(int j=i-1;j>=0;j--) {
				if(arrayIn[j] > v) {
					arrayIn[j+1] = arrayIn[j];
					arrayIn[j] = v;
				}
			}
			for(int k:arrayIn) {
				if(k==arrayIn[arrayIn.length-1]) {
					System.out.print(k);
				}else {
					System.out.print(k+" ");
				}
			}
			System.out.println();
		}
		return arrayIn;
	}
}



Measured memory_bytes: 31612
#include <iostream>

int main(void){
    int h1, m1, h2, m2, k;
    std::cin >> h1 >> m1 >> h2 >> m2 >> k;
    int m = (60 - m1) + m2;
    int h = h2 - h1;
    int wakeup_time = ((h-1) * 60) + m;
    int available_time = wakeup_time - k;
    std::cout << available_time << std::endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
  
 int main()
{
  int a,b;

    int i,j,Ya = 0;

int f, g, h;

  scanf("%d",&a);

  int array1[a];
  char array2[12];
 
  for(i = 0;i < a;i++){
    scanf("%s %d",array2,&b);
 
    if(array2[0] == 'i'){
      array1[i] = b;
    }
 
    else if(array2[6] == 'F'){
      i -= 2;
      a -= 2;
    }
 
    else if(array2[6]=='L'){
      i--;
      a--;
      Ya++;
    }
 
    else{
      i--;
      a--;
      f = 0;
      for(j = i; j >= 0;j--){
 
	if(f > 0)break;
 
	if(b == array1[j]){
	  h = 0;
	  g = i - j;
	  f++;
	  while(g != h++)array1[j + h - 1] = array1[j + 1 + h - 1];
	  i--;
	  a--;
	}
      }
    }
  }
  for(i = 0;i < a - Ya;i++){
    if(i == a - Ya - 1)
      printf("%d\n",array1[a - 1 - i]);
    else printf("%d ",array1[a - 1 - i]);
  }
  return 0;
}

Measured memory_bytes: 4664
n, m = map(int, input().split())
friend = [[] for i in range(n)]
for i in range(m):
    s, t = map(int, input().split())
    friend[s].append(t)
    friend[t].append(s)

group = [-1 for i in range(n)]
for u in range(n):
    if group[u] == -1:
        group[u] = u
        q = [u]
        while q:
            u1 = q.pop()
            for u2 in friend[u1]:
                if group[u2] == -1:
                    group[u2] = u
                    q.append(u2)

q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    if group[s] == group[t]:
        print('yes')
    else:
        print('no')

Measured memory_bytes: 26560
S = input()

N = int(S)

D = len(S)

if D == 1:
    print(N)
elif D == 2:
    print(9)
elif D == 3:
    print(N-90)
elif D == 4:
    print(909)
elif D == 5:
    print(N-9090)
elif D == 6:
    print(90909)


Measured memory_bytes: 2940
from __future__ import annotations

import itertools
from dataclasses import dataclass
from typing import List


@dataclass
class Cell:
    row_idx: int
    col_idx: int
    color: str

    def to_red(self) -> Cell:
        return Cell(self.row_idx, self.col_idx, color='R')


@dataclass
class Board:
    cells: List[Cell]

    @classmethod
    def create(cls, H: int, W: int, C: List[List[str]]) -> Board:
        cells = []

        for i in range(H):
            for j in range(W):
                cell = Cell(i + 1, j + 1, C[i][j])
                cells.append(cell)

        return Board(cells)

    def count_black_cells(self) -> int:
        return len([cell for cell in self.cells if cell.color == '#'])

    def paint_row(self, row_idx: int) -> Board:
        new_cells = []

        for cell in self.cells:
            if cell.row_idx == row_idx:
                new_cells.append(cell.to_red())
            else:
                new_cells.append(cell)

        return Board(new_cells)

    def paint_col(self, col_idx: int) -> Board:
        new_cells = []

        for cell in self.cells:
            if cell.col_idx == col_idx:
                new_cells.append(cell.to_red())
            else:
                new_cells.append(cell)

        return Board(new_cells)


def actual(H, W, K, C):
    count = 0

    # ある行や列を赤く塗るかどうかをビットパターンで表現する
    # ex: H=2, W=3 で、1行目と、2列目と3列目を塗る場合
    #     (0,  1, |  0,   1,   1)
    #     H=1 H=2 | W=1, W=2, W=3
    paint_patterns = list(itertools.product(range(2), repeat=H + W))

    for pattern in paint_patterns:
        board = Board.create(H, W, C)

        row_paint_pattern = pattern[:H]  # ex: (0, 1)
        col_paint_pattern = pattern[H:]  # ex: (0, 1, 1)

        for row_idx, will_paint_the_row in enumerate(row_paint_pattern, start=1):
            if will_paint_the_row == 1:
                board = board.paint_row(row_idx)

        for col_idx, will_paint_the_col in enumerate(col_paint_pattern, start=1):
            if will_paint_the_col == 1:
                board = board.paint_col(col_idx)

        if board.count_black_cells() == K:
            count += 1

    return count

H, W, K = map(int, input().split())
C = [input() for _ in range(H)]

print(actual(H, W, K, C))  

Measured memory_bytes: 11300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9 + 7;
const int INT_MOD=1e9+7;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 0; i <= n; i++)
#define rrep(i,n) for(int i=n;i>0;i--)
#define RREP(i,n) for(int i=n;i>=0;i--)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
using fint64 = int_fast64_t;
//dp[i][j]:i枚投げた時表がj枚出る確率
double dp[3001][3001];

int main() { 
	int n;cin>>n;
    double p[n];
    rep(i,n) cin>>p[i];
    REP(i,n)REP(j,n) dp[i][j]=0;
    dp[0][0]=1-p[0];
    dp[0][1]=p[0];
    for(int i=1;i<n;i++) dp[i][0]=dp[i-1][0]*(1-p[i]);
    for(int i=1;i<n+1;i++){
        for(int j=1;j<n+1;j++){
            dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
        }
    }
    double ans=0;
    if(n%2==0){
        for(int i=n/2;i<n+1;i++) ans+=dp[n-1][i];
    }else{
        for(int i=(n+1)/2;i<n+1;i++) ans+=dp[n-1][i];
    }
    printf("%.16f\n",ans);
    return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

struct BIT{
    // [1,n]
    int n; vector<ll> bit;
    // 初期化
    BIT(int _n){
        n = _n;
        bit = vector<ll>(n+1,0);
    }
    // sum of [1,i]
    ll sum(int i){
        ll s = 0;
        while(i>0){
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }
    // add x in i-th element
    void add(int i, ll x){
        while(i<=n){
            bit[i] += x;
            i += i & -i;
        }
    }
};

typedef pair<int,int> pi;
vector<pi> range[101010];

int main()
{
    int N,M;
    scanf(" %d %d", &N, &M);
    rep(i,N)
    {
        int l,r;
        scanf(" %d %d", &l, &r);
        range[r-l+1].pb(pi(l,r));
    }

    BIT bit(M+1);
    int up_d=N;
    for(int d=1; d<=M; ++d)
    {
        for(pi p:range[d])
        {
            bit.add(p.fi,1);
            bit.add(p.se+1,-1);
            --up_d;
        }

        int ct=0;
        for(int i=d; i<=M; i+=d) ct+=bit.sum(i);

        printf("%d\n", up_d + ct);
    }
    return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 3e3+5;

double p[maxn];

double dp[maxn][maxn];

bool cmp[maxn][maxn];

int n;

double solve(int u, int odd)
{
	if(u == n+1 && odd> n-odd) return 1.0;
	if(u == n+1) return 0.0;
	if(cmp[u][odd]) return dp[u][odd];
	double res = p[u]*solve(u+1, odd+1)+(1.0-p[u])*solve(u+1, odd);
	cmp[u][odd] = 1;
	return dp[u][odd] = res;
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i<= n; i++) scanf("%lf", &p[i]);
	printf("%.9lf\n", solve(1, 0));
}

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

int main() {
  string S;
  cin >> S;
  
  rep(i,S.size()) {
    if (S.at(i) == '1') 
      S.at(i) = '9';
    else 
      S.at(i) = '1';
  }
  
  cout << S << endl;
  
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;

    ll n,x;
    cin >> n >> x;
    ll m[n];
    ll sum = 0;
    F0R(i,n){  cin >> m[i] ; sum +=m[i];}
    x -=sum;
    sort(m,m+n);
    cout << n + x/m[0]<<endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
X = int(input())
DP=[0]*(X+1)

def dp(n):
  if n<100:
    return 0
  if 100<=n and n<=105:
    return 1
  res = 0
  for i in range(100,106):
    res |= DP[n-i]
  return res

for i in range(X+1):
  DP[i] = dp(i)
ans=DP[X]
#print(DP)
print(ans)

#print(*ans, sep='/n')

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5;
struct P{
	ll x,y;
};

P arr[N];
bool cmp(P a,P b){
	return atan2(a.y,a.x) < atan2(b.y,b.x);
}



int main(){
	ll n,x,y,j;
	ll MAX=0;
	scanf("%lld",&n);
	for(ll i=0;i<n;i++){
		scanf("%lld%lld",&arr[i].x,&arr[i].y);
	}
	sort(arr,arr+n,cmp);
	for(ll i=0;i<n;i++){
		x = arr[i].x, y = arr[i].y;
		j=(i+1)%n;
		MAX=max(x*x+y*y,MAX);
		while(j!=i){
			x+=arr[j].x;
			y+=arr[j].y;
			j=(j+1)%n;
			MAX=max(x*x+y*y,MAX);
		}
	}
	double ans=sqrt(MAX);
	printf("%.10lf\n",ans);	
	return 0;
}

Measured memory_bytes: 384
// This code writed by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
signed main(void)
{
	string s;
	cin>>s;
	for(int i=0;i<(int)s.length();++i)
	{
		if((i+1)&1)
		{
			if(s[i]!='R'&&s[i]!='U'&&s[i]!='D')
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
		else
		{
			if(s[i]!='L'&&s[i]!='U'&&s[i]!='D')
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;

namespace ConsoleApp1
{
    class Program
    {
  
        static void Main(string[] args)
        {
            int[] ND = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int N = ND[0];
            int D = ND[1];
            int[,] X = new int[N,D];
            //int A = 0;
            double d = 0;
            int cnt = 0;
            for (int i = 0; i < N; i++)
            {
                int[] tmp = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
                for (int j = 0; j < D; j++)
                {
                    X[i, j] = tmp[j];
                }
            }
            //if(D != 1)
            //{

                //3 3
                //1 2 1
                //5 5 2
                //-2 8 1
                // sqrt( (1-5)^2+(2-5)^2+(1-2)^2 )
                //3 3
                //1 2 
                //5 5 
                //-2 8
                // sqrt( (1-5)^2+(2-5)^2 )
            // 0 ~ N - 1までのループ
            for (int k = 0; k < N; k++)
            {
                // k + 1 ~ N-1までのループ
                for(int j = k + 1;j < N; j++)
                {
                    int A = 0;
                    for (int l = 0; l < D ; l++)
                    {
                        A += (int)Math.Pow((X[k, l] - X[j, l]), 2);
                        //A = ((X[k, l] - X[k + 1, l]) * (X[k, l] - X[k + 1, l])) + ((X[k, l + 1] - X[k + 1, l + 1]) * (X[k, l + 1] - X[k + 1, l + 1]));
                        //d = Math.Sqrt(A);
                        //if ((int)d == d)
                        //{
                        //    cnt++;
                        //}
                    }
                        
                    int sq = (int)Math.Sqrt(A);
                    int v = sq * sq;
                    if(v == A)
                    {
                        cnt++;
                    }

                }
            }
            //}
            //else
            //{
            //    for (int k = 0; k < N; k++)
            //    {
            //        for (int l = 0; l < D; l++)
            //        {
            //            A = ((X[k, l] - X[k + 1, l]) * (X[k, l] - X[k + 1, l])) + ((X[k, l + 1] - X[k + 1, l + 1]) * (X[k, l + 1] - X[k + 1, l + 1]));
            //            d = Math.Sqrt(A);
            //            if ((int)d == d)
            //            {
            //                cnt++;
            //            }
            //        }
            //    }

            //}
            
            Console.WriteLine(cnt);
        }
    }
}




//int n = int.Parse(Console.ReadLine());
//int[] N = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

Measured memory_bytes: 28364
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


// import here

LL solve(LL a, LL b){
    if(a > b) swap(a, b);
    // now a <= b
    if(b-a <= 1){
        return (a-1) * 2;
    }
    LL c = sqrt(a*b);
    if(c*c >= a*b) --c;
    if(c * (c+1) >= a*b){
        return c*2 - 2;
    }else{
        return c*2 - 1;
    }
}

int main(){
    LL q;
    cin >> q;
    vector<LL> a(q), b(q);
    for(LL i = 0; i < q; ++i){
        cin >> a[i] >> b[i];
        cout << solve(a[i], b[i]) << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX
#define eps LDBL_EPSILON
#define moder 100000
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
int n,k;
P t[100010];
set<int> st;
multiset<int> st2;
signed main(){
	cin>>n>>k;
	rep(i,n){
		cin>>t[i].second>>t[i].first;
		st.insert(t[i].second);
	}
	sort(t,t+n,greater<P>());
	int ma=st.size();
	st.erase(st.begin(),st.end());
	int cnt=0;
	rep(i,k){
		cnt+=t[i].first;
		st2.insert(t[i].second);
		st.insert(t[i].second);
	}
	int l=k-1,r=k;
	int ans=st.size()*st.size()+cnt;
	for(int i=st.size();i<min(k,ma);i++){
		while(st2.count(t[l].second)==1)l--;
		while(true){
			if(st2.find(t[r].second)==st2.end()){
				cnt-=t[l].first;
				st2.erase(st2.find(t[l].second));
				l--;
				cnt+=t[r].first;
				st2.insert(t[r].second);
				break;
			}
			r++;
		}
		ans=max(ans,(i+1)*(i+1)+cnt);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <cstdlib>
using namespace std;

int calc(vector<string> vecs){
	int result = 0;
	int size = vecs.size();
	//vector<string> stack;
    //stack.resize(size);
	//cout  << size<< endl;
    std::stack<int> st;
    for(int i=0; i<size; i++){    
       if('+' == vecs[i][0]){
            int a = st.top();
            st.pop();
            int b = st.top();
            st.pop();
            st.push(a+b);
        }else if('-'==vecs[i][0]){
            int a = st.top();
            st.pop();
            int b = st.top();
            st.pop();
            st.push(b-a);
        }else if('*'== vecs[i][0]){
            int a = st.top();
            st.pop();
            int b = st.top();
            st.pop();
            st.push(a*b);
            
        }else{
            int c = atoi(vecs[i].c_str());
            //cout << c << endl;
            st.push(c);
	    }
	    
	}
	result = st.top();
	
	return result;
}

int main(){

	vector<string> vecs;
	while(1){
	    string str="";
	    cin >> str;
	    if(cin.good() == false){
	        break;
	    }
	    vecs.push_back(str);
	}
	//for(int i =0; i<vecs.size();i++){
	//    cout << "vecs[" << i<< "]=" << vecs[i] << endl;
    //}
	int result = calc(vecs);
	
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 3232
#include<stdio.h>
#define N 500000
#define MAX 1000000000

void merge(int*,int,int,int);
void mergeSort(int*,int,int);
int n,count=0;


int main(){
  int i,S[N],l,r;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  
  l=0;
  r=n-1;

  mergeSort(S,0,n);

  for(i=0;i<n;i++){
    if(i>=1)printf(" ");
    printf("%d",S[i]);
  }
  printf("\n%d\n",count);
  
  return 0;
}
void mergeSort(int *s, int left, int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(s,left,mid);
    mergeSort(s,mid,right);
    merge(s,left,mid,right);
  }
}
void merge(int *s, int left, int mid, int right){
  int i,j,k,n1,n2;
  
  n1=mid-left;
  n2=right-mid;
  int L[n1+1],R[n2+1];
  for(i=0;i<n1;i++){
    L[i]=s[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=s[mid+i];
  }

  L[n1]=MAX;
  R[n2]=MAX;

  i=0;
  j=0;

  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      s[k]=L[i];
      i=i+1;
    }
    else{
      s[k]=R[j];
      j=j+1;
    }
  }
  count+=(i+j);
}

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

int main(){
  string s;
  cin>>s;
  int counter=0;
  if(s[0]=='1') counter++;
  if(s[1]=='1') counter++;
  if(s[2]=='1') counter++;
  cout<<counter<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int d = a + b + c;
  if (d >= 22) {
  cout << "bust" << endl;
  }
  else {
  cout << "win" << endl;
  }
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
	if(n==2 || n == 3) return true;
	if(n<=1) return false;
	if(n%2==0) return false;
	for(int i = 3; i<=sqrt(n);i+=2)
		if(n%i==0)
			return false;
	return true;
}
int main() {
	// your code goes here
	int n;
	cin>>n;
	while(1)
	{
		if(isPrime(n))
		{
			cout<<n<<endl;
			break;
		}
		n++;
	}
	
	return 0;
}

Measured memory_bytes: 256