akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	

	public static void main(String[] args) throws FileNotFoundException {
	
	
 /*File file =new File("input.txt");
 Scanner scan=new Scanner(new FileInputStream(file));
 PrintWriter out=new PrintWriter("output.txt");
 */
FastReader scan=new FastReader();
 int n=scan.nextInt();
 int count=0;
 int max=0;
 while(n-->0){
	 int a=scan.nextInt();
	 int b=scan.nextInt();
	 if(a==b){
++count;
	 }
	 else{
		 count=0;
	 }
	 max=Math.max(count,max);
	 
 }

 if(max>=3){
	 System.out.println("Yes");
 }
 else
 System.out.println("No");

	}
}




Measured memory_bytes: 32796
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

string t="TLURD",b="aiueo",str="w!kstnhmyr";

signed main() {
	string s, ans="";
	cin >> s;
	rep(i, 0, s.size() / 2){
		int d=t.find(s[i*2+1]);
		if(s[i*2]=='1') ans+=b[d];
		else if(s[i*2]=='0' && d==2) ans+="nn";
		else ans=ans+str[(int)(s[i*2]-'0')]+b[d];
	}
	cout << ans <<endl;
}

Measured memory_bytes: 1208
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  ll N, H;
  cin >> N >> H;
  vector<ll> A, B, B_greater;
  ll a_max = 0;
  ll b_sum = 0;
  for(int i=0; i<N; i++){
    ll a, b;
    cin >> a >> b;
    A.push_back(a);
    if(a_max < a)
      a_max = a;
    B.push_back(b);
    B_greater.push_back(b);
    b_sum += b;
  }
  sort(B_greater.begin(), B_greater.end(), greater<ll>());
  int it = 0;
  while(it < B_greater.size() && B_greater[it] > a_max){
    it++;
  }
  for(int i=it; i<B_greater.size(); i++){
    b_sum -= B_greater[i];
  }
  if(b_sum > H){
    int ret = 0;
    ll sum = 0;
    while(sum < H){
      sum += B_greater[ret];
      ret++;
    }
    cout << ret << endl;
  } else {
    H -= b_sum;
    cout << N-(B_greater.size()-it) + (ll)ceil((H / (double)a_max)) << endl;
  }
  return 0;
}


Measured memory_bytes: 2912
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{
    int p;
    int l;
    int r;
};
struct Node np[MAX];
int depth = 0;
int hileft = 0;
int hiright = 0;


int get_depth(int u){

    if(np[u].p == NIL) return 0;
    if(np[u].p != NIL){
        depth++;
        get_depth(np[u].p);
    }
    return depth;
}

int degree(int u){
    if (np[u].l == NIL && np[u].r == NIL) return 0;
    else if(np[u].l != NIL && np[u].r != NIL)  return 2;
    else  return 1;
}

int sibling(int u){

    if(np[u].p == NIL) {
        return NIL;
    }
    else if(np[np[u].p].l == u) {
        return np[np[u].p].r;
    }
    else {
        return np[np[u].p].l;
    }
}

int hight(int u){

    int hileft = 0;
    int hiright = 0;

    if(np[u].l != -1) {
        hileft = hight(np[u].l) + 1;
    }
    if(np[u].r != -1){
        hiright = hight(np[u].r) + 1;
    }
    if(hileft < hiright){
        return hiright;
    }
    else {
        return hileft;
    }
}

void print(int u){

    printf("node %d: ",u);
    printf("parent = %d, ",np[u].p);
    printf("sibling = %d, ",sibling(u));
    printf("degree = %d, ",degree(u));

    depth = 0;

    printf("depth = %d, ",get_depth(u));
    printf("height = %d, ",hight(u));

    if(np[u].p == NIL)printf("root\n");
    else if(np[u].l == NIL && np[u].r == NIL) {
        printf("leaf\n"); 
    }
    else { 
        printf("internal node\n");
    }
}


int main(){
    int i, j;
    int d, v, c, l;
    int n,tmp;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        np[i].p = np[i].l = np[i].r = NIL;      // 初期化
    }
    for (i = 0; i <n ; i++){
        scanf("%d %d %d", &v, &d, &c);
        np[d].p = np[c].p = v;
        np[v].l = d;
        np[v].r = c;
    }

    for (i = 0; i < n; i++ ) {
        print(i);
    }
    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    int A, B;
    if(N == 1) {
        cout << "Hello World" << endl;
    } else {
        cin >> A >> B;
        cout << A + B << endl;
    }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, alice, bob int
	fmt.Scan(&n)
	cards := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&cards[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(cards)))
	for i := 0; i < n; i += 2 {
		alice += cards[i]
		if i+1 < n {
			bob += cards[i+1]
		}
	}
	fmt.Println(alice - bob)
}

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

using namespace std;

int vec[123456];
int dp[123456];

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

    for (int i =0; i < n; i++) {
        cin >> vec[i];
    }

    dp[0] = 0;

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

        dp[i] = dp[i-1] + abs(vec[i]-vec[i-1]);
        for (int j = 2; j<=k; j++) {
            if (i-j >= 0){
                dp[i] = min(dp[i], dp[i-j] + abs(vec[i]-vec[i-j]));
            }
        }
    }
    cout << dp[n-1] << endl;

   return 0;
}


Measured memory_bytes: 1024
n = int(input())
 
shiritori = []
tmp = 0
for i in range(n):
    shiritori.append(input())
    if i > 0:
        if not shiritori[i-1][-1] == shiritori[i][0]:
            tmp += 1
        if not tmp > 0:
            for j in range(i):
                if shiritori[i] == shiritori[j]:
                    tmp += 1
                    break;
if(tmp > 0):
    print('No')
else:
    print('Yes')
 


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

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

    N %= K;
    if (abs(N - K) < N) {
        N = abs(N - K);
    }

    cout << N << endl;

    return 0;
}


Measured memory_bytes: 3572
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		 BufferedReader r =
            new BufferedReader(new InputStreamReader(System.in), 1);
		String s = r.readLine();
		int a = Integer.parseInt(s);
		System.out.println(a*a*a);
	}
}

Measured memory_bytes: 16984
#include<bits/stdc++.h>
using namespace std;
int dist[2010][2010];
int cnt[2009];
int main()
{
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			dist[i][j] = abs(i-j);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			{
				int dis = dist[i][j];
				int dne = dist[i][x]+1+dist[j][y];
				int dne1 = dist[i][y]+1+dist[j][x];
				dist[i][j] = min(dis,min(dne,dne1));
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
			cnt[dist[i][j]]++;
	}
	for(int i=1;i<n;i++)
		cout<<cnt[i]/2<<endl;
	return 0;
}

Measured memory_bytes: 16000
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int test[321][321];
int main() {
	long long n, ans = 0; string s, t; cin >> n >> s;
	for (int h = 0; h < n; h++) {
		cin >> t; 
		for (int i = 0; i < t.size(); i++) {
			for (int j = 1; j <= 100; j++) {
				int sum = 0;
				for (int k = 0; k < s.size(); k++) {
					if (i + (j * k) < t.size()) {
						if (t[i + (j * k)] == s[k]) {
							sum++;
						}
					}
				}
				if (sum == s.size()) {
					ans++; i = t.size(); j = 100;
				}
			}
		}
	}
	cout << ans << endl;
	cin >> n;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//最大公約数
ll gcd(ll a, ll b) {
  if (a < b) swap(a, b);
  ll r = a % b;
  while (r) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

//セグメント木
//全て添字で扱うこと
template<typename T>
struct segment_tree {
  ll n; //vの要素数
  ll m; //葉の数
  vector<T> v;
  T id_e; //単位元

  //二項演算
  T seg_func(T a, T b) {
    if (a == 0) return b;
    if (b == 0) return a;
    return gcd(a, b);
  }

  //初期化関数
  void init(vector<T> a, T b) {
    id_e = b;
    m = 1;
    while (m < a.size()) m *= 2;
    n = 2 * m - 1;
    v.resize(n);
    for (ll i = 0; i < a.size(); i++) v[m - 1 + i] = a[i];
    for (ll i = a.size(); i < m; i++) v[m - 1 + i] = id_e;
    for (ll i = m - 2; i >= 0; i--) {
      v[i] = seg_func(v[2 * i + 1], v[2 * i + 2]);
    }
  }

  //v[a]をbに更新
  void update(ll a, T b) {
    a += m - 1;
    v[a] = b;
    while ((a - 1) / 2 != a) {
      a = (a - 1) / 2;
      v[a] = seg_func(v[2 * a + 1], v[2 * a + 2]);
    }
  }

  //区間和の補助関数
  T subsub(ll a, ll b, ll cur, ll l, ll r) {
    if (a <= l && r <= b) return v[cur];
    if (r < a || b < l) return id_e;
    if (l < r) {
      return seg_func(
        subsub(a, b, 2 * cur + 1, l, (l + r) / 2),
        subsub(a, b, 2 * cur + 2, (l + r) / 2 + 1, r)
      );
    }
  }

  //区間[a, b]の和
  T partial_sum(ll a, ll b) {return subsub(a, b, 0, 0, m - 1);}
};

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

  vll a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];

  segment_tree<ll> seg;
  seg.init(a, 0);
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    seg.update(i, 0);
    ans = max(ans, seg.partial_sum(0, seg.m - 1));
    seg.update(i, a[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3840
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    D = int(input())
    c = [int(a) for a in input().split()]
    s = [
        [int(a) for a in input().split()]
        for _ in range(D)
    ]
    t = [
        int(input())
        for _ in range(D)
    ]

    score = 0
    last = [0] * len(c)

    for d, ti in enumerate(t):
        sdi = s[d][ti - 1]
        score += sdi
        last[ti - 1] = d + 1
        for i, ci in enumerate(c):
            score -= ci * ((d + 1) - last[i])
        print(score)


if __name__ == "__main__":
    main()


Measured memory_bytes: 70008
def main():
    from collections import Counter

    N, K = map(int, input().split())
    *a, = map(int, input().split())

    ctr = Counter(a)

    ans = 0
    rest = max(0, len(ctr.keys()) - K)
    for cnt in sorted(ctr.values()):
        if rest == 0: break
        ans += cnt
        rest -= 1
    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()


Measured memory_bytes: 32660
a = input().split()
n = int(a[0])
k = int(a[1])
s = input()

ans = ''
for i in range(n):
  if i == k-1:
    if s[i] == 'A':
      ans += 'a'
    elif s[i] == 'B':
      ans += 'b'
    else:
      ans += 'c'
  else:
    ans += s[i]
print(ans)

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

int main () {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  int ans = 1;
  int p = 0;
  rep(i, n) {
    p += l[i];
    if(p <= x) ans++;
  }
  cout << ans << endl;
}

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

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let l: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    if *l.iter().max().unwrap() < l.iter().sum::<usize>() - *l.iter().max().unwrap() {
        "Yes".to_string()
    } else {
        "No".to_string()
    }
}


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

using namespace std;

typedef long long ll;

int main() {
    int n, k; cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++)
        cin >> h[i];
    sort(h.begin(), h.end());
    int mn = 1e9 + 1;
    for (int i = 0; i < n - k + 1; i++) {
        mn = min(mn, h[i + k - 1] - h[i]);
    }
    cout << mn;
    return 0;
}


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

#define INF 100000000000000
using namespace std;
//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

int main() {

    string S, P;
    long long len;
    unsigned char flg;
    getline(cin, S);
    getline(cin, P);
    len = S.size();
    S = S + S;

    for(int i=0; i<len; i++){
        flg = 0;
        for(int j=0; j<P.size(); j++){
            if(P.at(j)!=S.at(i+j)){
                flg = 1;
                break;
            }
        }
        if(flg==0){
            cout << "Yes" << endl;
            exit(0);
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3236
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}

fn main() {
    let a = read::<i64>();
    let b = read::<i64>();
    let mut v = gcd(a, b);
    let mut ans = 1;
    for i in 2..v {
        if v % i == 0 {
            ans += 1;
            while v % i == 0 {
                v /= i;
            }
        }
        if i * i > v {
            break;
        }
    }
    if v != 1 {
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2168
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#define int long 
using namespace std;

signed main() {
	char A;
	cin >> A;
	if(A == 'a' || A == 'i' || A == 'u' || A == 'e' || A == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;











int main(){
    ll n;
    cin>>n;
    vector<ll> a(n),b(n);
    ll mi=E;
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
        mi=min(mi,a[i]);
    }
    sort(b.begin(),b.end());
    map<ll,ll> M;
    for(int i=0;i<n;i++){
        M[b[i]]=i;
    }
    vector<bool> used(n,false);
    ll cost=0;
    for(int i=0;i<n;i++){
        if(used[i] || a[i]==b[i]){continue;}
        ll sum=0;
        ll MIN=E;
        ll w=i;
        ll L=0;
        while(!used[w]){
            MIN=min(MIN,a[w]);
            sum+=a[w];
            used[w]=true;
            w=M[a[w]];
            L++;
        }
        ll D=sum;
        sum-=MIN;
        sum+=(L-1)*MIN;
        D-=MIN;
        D+=MIN*2+mi*2;
        D+=(L-1)*mi;
        cost+=min(sum,D);
    }
    cout<<cost<<endl;
    
    
    
    return 0;
}



Measured memory_bytes: 3228
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void) {
	int n, i, color=-1, count=1, all = 0;
	//int a[100];
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		int now;
		scanf("%d", &now);
		if (color == now) {
			count++;
		}
		else {
			if (count > 1) {
				all += count / 2;
				count = 1;
			}
		}
		color = now;
	}
	if (count > 1)all += count / 2;
	printf("%d\n", all);
	return 0;
}

Measured memory_bytes: 128
// Confessions of a Dangerous Mind

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 2e3 + 5;
const long long T = 5e3;
const int logN = 22, BL = 400;
const double EPS = 3e-16;

/*
	Keep moving forward. Take the Leap of Faith
*/

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
	
	long long x; cin >> x;
	
	for(long long i = -1000; i <= 1000; i++){
		for(long long j = -1000; j <= 1000; j++){
			if(pow(i, 5) - pow(j, 5) == x){
				return cout << i << " " << j, 0;
			}
		}
	}
	
    return 0;
}

Measured memory_bytes: 3948
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long d = sc.nextLong();
		long n = sc.nextLong();
		
		long a = 0;
		if (n == 100) {
			a = (long) Math.pow(100, d) * (n + 1);
		} else {
			a = (long) Math.pow(100, d) * n;
			
		}
		
		System.out.println(a);
		
	}
}

Measured memory_bytes: 21972
#include <stdio.h>

#define MAX 25

void Depth(int,int);
int Height(int);
int Sibling(int);
int degree(int);

struct Node{
  int parent;
  int left;
  int right;
};

struct Node T[MAX];
int Dep[MAX];
int High[MAX];

int main(){
  int i=0;
  int n=0;
  int id=0;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].parent=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d%d",&T[id].left,&T[id].right);
    if(T[id].left!=-1)T[T[id].left].parent=id;
    if(T[id].right!=-1)T[T[id].right].parent=id;
  }

  for(i=0;i<n;i++) if(T[i].parent==-1)break;
  Depth(i,0);
  Height(i);

  for(i=0;i<n;i++){
    printf("node %d: ",i);
    printf("parent = %d, ",T[i].parent);
    printf("sibling = %d, ",Sibling(i));
    printf("degree = %d, ", degree(i));
    printf("depth = %d, ", Dep[i]);
    printf("height = %d, ",High[i]);

    if(T[i].parent==-1) printf("root");
    else if(T[i].left==-1 && T[i].right==-1) printf("leaf");
    else printf("internal node");
    printf("\n");
  }
  
}

void Depth(int id,int d){
  Dep[id]=d;
  if(T[id].right!=-1) Depth(T[id].right,d+1);
  if(T[id].left!=-1)Depth(T[id].left,d+1);
}

int Height(int id){
  int h_left=0;
  int h_right=0;
  if(T[id].left!=-1) h_left=Height(T[id].left)+1;
  if(T[id].right!=-1) h_right=Height(T[id].right)+1;
  if(h_left>h_right) High[id]=h_left;
  else High[id]=h_right;
  return High[id];
}

int Sibling(int id){
  if(T[id].parent==-1) return -1;
  if(T[T[id].parent].left!=id && T[T[id].parent].left!=-1)
    return T[T[id].parent].left;
  else if(T[T[id].parent].right!=id && T[T[id].parent].right!=-1)
    return T[T[id].parent].right;
  else return -1;
}

int degree(int id){
  int deg=0;
  if(T[id].left!=-1)deg++;
  if(T[id].right!=-1)deg++;
  return deg;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A, B; cin >> A >> B;
    cout << A * B / __gcd(A, B) << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;

int main() {

    ios::sync_with_stdio(0);
    cin.tie(0);
    
    vector<int> v(3);
    rep(i, 0, 3) cin >> v[i];
    sort(v.rbegin(), v.rend());
    string a = to_string(v[0]) + to_string(v[1]);
    int sum = stoi(a) + v[2];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
string S;

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

  cin >> N >> S;
  char current = S[0];
  int cnt = 1;
  rep(i, N) {
    if (S[i] != current) {
      cnt++;
      current = S[i];
    }
  }

  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 512
//14:07:00 

#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
#define INF (ll)(1e18)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

struct town
{
	int id;
	int x,y;
};
inline int d(town a,town b){return min(abs(a.x-b.x),abs(a.y-b.y));}

struct Edge
{
	int v1,v2;
	int wei;
	Edge(town a,town b)
	{
		v1=a.id;
		v2=b.id;
		wei=d(a,b);
	}
};


bool sortX (town a,town b){return a.x  <b.x  ;}
bool sortY (town a,town b){return a.y  <b.y  ;}
bool sortID(town a,town b){return a.id <b.id ;}
bool sortE (Edge a,Edge b){return a.wei<b.wei;}

struct disjoint
{
	vector<int> node;
	disjoint(int n)
	{
		node.resize(n);
		For(i,0,n-1) node[i]=i;
	}
	int find(int n)
	{
		if(node[n]==n) return n;
		return node[n]=find(node[n]);
	}
	bool add(int a,int b)
	{
		a=find(a); b=find(b);
		if(a==b) return false;
		node[a]=b;
		return true;
	}
	bool ask(int a,int b)
	{
		return find(a)==find(b);
	}
};

int span(int n,vector<Edge> &edge)
{
	disjoint dis(n);
	
	int ecnt=0;
	int ans=0;
	for(int i=0;ecnt<n-1;i++)
	{
		Edge &e=edge[i];
		//cout<<i<<"\n";
		if(dis.ask(e.v1,e.v2)) continue;
		else
		{
			dis.add(e.v1,e.v2);
			ans+=e.wei;
			ecnt++;
		}
	}
	return ans;
}

int32_t main()
{
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	
	int n; cin>>n;
	vector<town> to(n);
	vector<Edge> edge;
	For(i,0,n-1)
	{
		to[i].id=i;
		cin>>to[i].x>>to[i].y;
	}
	
	sort(all(to),sortX);
	For(i,0,n-2) edge.emplace_back(to[i],to[i+1]);
	sort(all(to),sortY);
	For(i,0,n-2) edge.emplace_back(to[i],to[i+1]);
	sort(all(edge),sortE);
	cout<<span(n,edge)<<"\n";
	return 0;
}











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

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        String[] s = new String[n];
        for (int i = 0 ; i < n ; i++) {
            s[i] = sc.next();
        }
        Arrays.sort(s);
        for (int i = 0 ; i < n ; i++) {
            System.out.print(s[i]);
            if (i == n - 1) {
                System.out.print("\n");
            }
        }
    }

}


Measured memory_bytes: 22356
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <math.h>
using namespace std;
int main()
{
	int i, j;
	int n, d, x;
	int a[105];
	int vis;
	int count = 0;
	int ans = 0;
	scanf("%d",&n);
	scanf("%d %d", &d, &x);
	for(i = 1 ; i <= n ; i++)
	{
		scanf("%d", &a[i]);
	}
	for(i = 1 ; i <= n ; i++)
	{
		vis = 1;
		count = 1;
		for(j = 1 ; j <= 100 ; j++)
		{
			vis = 1 + a[i] * j;
			if(vis > d)break;
			count++;
		}
		ans = ans + count;
	}
	printf("%d\n",ans + x);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int max_length = 0;
    rep(i, n) {
        loop(j, 1, n + 1) {
            string sub = s.substr(i, j);
            bool ok = true;
            for (auto x : sub) {
                if (x != 'A' and x != 'C' and x != 'G' and x != 'T') {
                    ok = false;
                }
            }
            if (ok) {
                max_length = max(max_length, (int)sub.size());
            }
        }
    }
    cout << max_length << endl;
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repin(Array,n) for(int i=0;i<n;i++){cin>>Array[i];}
using namespace std;

using ll = long long;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;
using Graph = vector<vector<int>>;

int main() {

	int N;
	cin >> N;

	map<char, int>m;

	rep(i, N) {
		char c;
		cin >> c;
		m[c]++;
	}

	if (m.size() == 3)
		cout << "Three" << endl;
	else if (m.size() == 4)
		cout << "Four" << endl;

	return 0;
}

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

using namespace std;

int main(void) {

	int as, bs;

	string a, b, c;

	cin >> a >> b >> c;

	as = a.size();
	bs = b.size();

//	cout << a.back() << b.front() << b.back() << c.front() << "\n";

	if (a.back()==b.front()&&b.back()==c.front()) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}

	return 0;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    bool ban[n+1];
    ll dp[n+1];
    memset(ban, false, sizeof ban);
    for(int i=0;i<m;i++){
        int a; cin >> a;
        ban[a] = true;
    }
    dp[0] = 1;
    dp[1] = 1;
    for(int i=2;i<=n;i++){
        if(ban[i-1] && ban[i-2]){
            cout << 0 << endl;
            return 0;
        }else if(ban[i-1]){
            dp[i] = dp[i-2];
        }else if(ban[i-2]){
            dp[i] = dp[i-1];
        }else{
            dp[i] = (dp[i-1] + dp[i-2]) % MOD;
        }
        // cout << dp[i] << endl;
    }
    cout << dp[n] << endl;
}

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

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

const int lim = 55555;
bool num[(lim+1)*5];

bool addible(vector<int> nums, int next){
    bool fl = true;
    for(int i=0; i<nums.size();i++ ){
        for(int j=i+1; j<nums.size(); j++){
            for(int k=j+1; k<nums.size(); k++){
                for(int l=k+1; l<nums.size(); l++){
                    int sum = nums[i] + nums[j] + nums[k] + nums[l];
                    if(num[sum+next]) fl = false;
                }
            }
        }
    }
    return fl;
}

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

    fill(num, num+lim, true);
    num[0] = false;
    num[1] = false;

    vector<int> p;
    for(int i=2; i<=lim*5; i++){
        int t = 2;        
        while(i*t<=lim){
            num[i*t] = false;
            t++;
        }
        if(num[i] && i<=lim) p.push_back(i);
    }

    vector<int> ans;
    for(auto m : p){
        if(ans.size() == N) break;
        if(m % 5 == 1) ans.push_back(m);
    }

    for(auto m : ans){
        cout << m << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,cnt=0,aa[220000],k;
pair<int,int> p[110000];
string s;
char c;
signed main(){
    cin>>n>>m;
    rep(i,n+1){
        aa[i]=INF;
    }
    rep(i,m){
        cin>>p[i].first>>p[i].second;
    }
    aa[0]=0;
    rep(i,n){
        if(aa[i]!=INF){
            rep(j,m){
                if(i+p[j].first>n){
                    aa[n]=min(aa[i]+p[j].second,aa[n]);
                }else{
                    aa[i+p[j].first]=min(aa[i]+p[j].second,aa[i+p[j].first]);
                }
            }
        }
    }
    cout<<aa[n];
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

using namespace std;

class Node {
public:
	int key;
	Node* prev;
	Node* next;
	Node(int _key, Node* _prev, Node* _next) {
		key = _key;
		prev = _prev;
		next = _next;
	}
};

class List {
public:
	Node* head;
	Node* last;
	List() {
		head = NULL;
		last = NULL;
	}
	void insert(int key) {
		auto node = head;
		head = new Node(key, NULL, node);
		if (node)
			node->prev = head;
		else
			last = head;
	}
	void deleteNode(Node* node) {
		if (! node)
			return;
		
		if (node == head)
			head = node->next;
		else
			node->prev->next = node->next;
		if (node == last)
			last = node->prev;
		else
			node->next->prev = node->prev;
		delete node;
	}
	Node* find(int key) {
		Node* current = head;
		while (current) {
			if (current->key == key) {
				break;
			} else {
				current = current->next;
			}
		}
		return current;
	}
	void deleteFirst() {
		deleteNode(head);
	}
	void deleteLast() {
		deleteNode(last);
	}
};

int main() {
	int n;
	scanf("%d", &n);
	
	auto list = List();
	char name[100];
	int key;
	for (int i=0; i<n; i++) {
		scanf("%s", name);
		if (! strcmp(name, "insert")) {
			scanf("%d", &key);
			list.insert(key);
		} else if (! strcmp(name, "delete")) {
			scanf("%d", &key);
			list.deleteNode(list.find(key));
		} else if (! strcmp(name, "deleteFirst")) {
			list.deleteFirst();
		} else if (! strcmp(name, "deleteLast")) {
			list.deleteLast();
		}
	}
	
	auto current = list.head;
	while (current) {
		if (current != list.head)
			printf(" ");
		printf("%d", current->key);
		current = current->next;
	}
	printf("\n");
}

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

int sx,sy,tx,ty;
//UUURRRDDDLLLLUUUURRRRDRDDDDLLLLU
//UURRURRDDDLLDLLULUUURRURRDDDLLDL

void solve()
{
	string ans;
	for(int i=0;i<ty-sy;++i)ans+='U';
	for(int i=0;i<tx-sx;++i)ans+='R';
	for(int i=0;i<ty-sy;++i)ans+='D';
	for(int i=0;i<tx-sx;++i)ans+='L';
	ans+='L';
	for(int i=0;i<ty-sy+1;++i)ans+='U';
	for(int i=0;i<tx-sx+1;++i)ans+='R';
	ans+='D';
	ans+='R';
	for(int i=0;i<ty-sy+1;++i)ans+='D';
	for(int i=0;i<tx-sx+1;++i)ans+='L';
	ans+='U';
	cout << ans << '\n';
}

int main()
{
	cin >> sx >> sy >> tx >> ty;
	solve();
	return 0;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll s;
    cin >> s;

    auto f = [](int a) {
        if (a % 2 == 0) {
            return a / 2;
        } else {
            return 3 * a + 1;
        }
    };

    map<ll, int> used;
    used[s] = 1;
    REP(i, 2, 1000010) {
        s = f(s);
        if (used.count(s)) {
            cout << i << endl;
            return 0;
        }
        used[s] = i;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n, c, s, I;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        c = 0;
        s = 0;
        I = i;
        if (i % 3 == 0 && c == 0) {
            cout << " " << i;
            c++;
        }
        if (i % 10 == 3 && c == 0) {
            cout << " " << i;
            c++;
        }
        if (c == 0){
            while (I / 10 != 0) {
                I /= 10;
                if (I == 3 || I % 10 == 3) {
                    cout << " " << i;
                    I = 0;
                }
            }
        }
    }
    cout << endl;
    return 0;
}




Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>

unsigned long gcd(unsigned long a, unsigned long b)
{
	return (a % b == 0) ? b : gcd(b, a % b);
}

unsigned long lcm(unsigned long a, unsigned long b)
{
	return a / gcd(a, b) * b;
}

int main()
{
	unsigned long a, b;
	while (std::cin >> a >> b) {
		std::cout << gcd(a, b) << " " << lcm(a, b) << "\n";
	}

	return 0;
}

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

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s; cin >> s;
	int N = atoi(s.c_str());
	int l = 0;
	for(int i=0; i<s.size(); i++){
		char c[2] = {0};
		c[0] = s[i];
		l += atoi(c);
	}
	if(N % l == 0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define EACH(i,c) for(decltype((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) whole(sort, c)
#define RSORT(c) rwhole(sort, c)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

template<class T,class U> void chmax(T&a,U b){if(a<b)a=b;}
template<class T,class U> void chmin(T&a,U b){if(b<a)a=b;}

//main code

int main(int argc, char *argv[])
{
	int k,x;
	cin >> k >> x;
	if (k*500 >= x) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


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

using namespace std;

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

int jou, yae;

void dfs(string str, int a, int b) {
	if (a > 6 || b > 6) return;
	
	if (a == jou && b == yae) {
		cout << str << endl;
		return;
	}
	if (a <= 3 && b >= 5 || b <= 3 && a >= 5) return;
	if (a >= 5 && b >= 5) return;
	
	dfs(str + "A", a + 1, b);
	dfs(str + "B", a, b + 1);
}

int main() {
	cin >> jou >> yae;
	dfs("", 0, 0);
	return 0;
}

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

using namespace std;

int n;
long long a[100005];
bool ex = false;
multiset<long long> s, ss;
map<long long, int> f;

int spf[100005];

const int MAXN = 100001;

void sieve() {
    spf[1] = 1;
    for (int i=2; i<=100000; i++)
        spf[i] = i;
 	for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;
    for (int i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (int j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}


long long get(long long x) {
	long long ou = 1;
	set<int> vis;
	while (x != 1) {
		if (vis.find(spf[x]) == vis.end()) {
			ou *= spf[x];
			vis.insert(spf[x]);
		}
		x /= spf[x];
	}
	return ou;
}

long long p(long long n, long long k) {
	return n*n*n;
}

signed main() {
	sieve();
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		s.insert(a[i]);
	}
	for (int i = 1; 1ll*i*i*i <= 10000000000; i ++) {
		if (s.find(1ll*i*i*i) != s.end()) {
			ex = true;
			s.erase(1ll*i*i*i);
			ss.insert(1ll*i*i*i);
		}
	}
	//cout << s.size() << endl;
	int res = 0;
	if (ex) res++;
	for (int i = 1; i <= n; i++) {
		if (ss.find(a[i]) != ss.end()) continue;
		for (int j = 2154; j >= 1; j--) {
			if (a[i] % (1ll*j*j*j) == 0) {
				a[i] /= 1ll*j*j*j;
			}
		}
		f[a[i]]++;
	}
	sort(a+1, a+1+n);
	for (int i = 1; i <= n; i++) {
		if (ss.find(a[i]) != ss.end()) continue;
		//cout << a[i] << endl;
		if (a[i] > 100000) {res += f[a[i]]; f[a[i]] = 0;}
		else {
			long long op = p(get(a[i]), 3)/a[i];
			res += max(f[a[i]], f[op]);
			f[op] = 0;
			f[a[i]] = 0;
		}
	}	
	cout << res;
}

Measured memory_bytes: 16384
import java.util.Scanner;

public class Main {    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int d = scanner.nextInt();

        final int[][] point = new int[n][d];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j++) {
                point[i][j] = scanner.nextInt();
            }
        }

        int result = 0;
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                int sum = 0;
                for (int k = 0; k < d; k++) {
                    sum += (point[i][k] - point[j][k]) * (point[i][k] - point[j][k]);
                }
                if (isIntSqrt(sum)) {
                    result++;
                }
            }
        }

        System.out.println(result);
    }

    private static boolean isIntSqrt(final int a) {
        final double sqrt = Math.sqrt(a);
        return Math.floor(sqrt) == sqrt;
    }
}


Measured memory_bytes: 21460
<?PHP
	$n=fgets(STDIN);
	$t=0;
	for($i=0;$i<$n;$i++){
		$a=fgets(STDIN);
		if(substr($a,-2,1)=='C'){$t+=$a*38e4;}
		else{$t+=$a;}
	}
	echo $t;

Measured memory_bytes: 3576
import heapq

def solve():
    X=[0]*3
    X[0],X[1],X[2],K=map(int,input().split())
    A=[[] for i in range(3)]
    for i in range(3):
        A[i]=list(map(int,input().split()))
        A[i].sort(reverse=True)
    q = []
    heapq.heappush(q, (-A[0][0]-A[1][0]-A[2][0],0,0,0))
    m = [0 for i in range(3)]
    n = [0 for i in range(3)]
    done = set()
    done.add((0,0,0))
    for k in range(K):
        sc, n[0], n[1], n[2] = heapq.heappop(q)
        print(-sc)
        extend=False
        for i in range(3):
            if m[i] <= n[i] and m[i] < X[i] - 1:
                m[i] += 1
                extend=True
        #print(m,extend)
        if extend:
            for i0 in range(m[0]+1):
                for i1 in range(m[1]+1):
                    for i2 in range(m[2]+1):
                        if (i0,i1,i2) not in done:
                            done.add((i0,i1,i2))
                            heapq.heappush(q, (-A[0][i0]-A[1][i1]-A[2][i2],i0,i1,i2))
        #print(done)

solve()


Measured memory_bytes: 59484
import sys
input = sys.stdin.readline
def shinsu(n,k):#nをk進数で
    if n==0:
        return 0
    bi=''
    while n!=0:
        r=n%abs(k)
        n=(n-r)//k
        bi+=str(r)
    return (bi[::-1])
n,k=map(int,input().split())
s=shinsu(n,k)
print(len(s))


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,a,b;
    cin>>n>>a>>b;
    if(n>1&&b>=a||n==1&&a==b)
        cout<<(n-2)*(b-a)+1<<endl;
    else
        cout<<0<<endl;
    return 0;
 } 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		System.out.println(Math.max(Math.max(a * b, a + b), a - b));

		sc.close();
	}
}

Measured memory_bytes: 25044
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N;
int f(vector<int>A)
{
	sort(A.begin(),A.end());
	return A[A.size()-1]-A[0];
}
main()
{
	cin>>N;
	vector<int>X(N),Y(N);
	for(int i=0;i<N;i++)
	{
		int x,y;cin>>x>>y;
		X[i]=x+y;
		Y[i]=x-y;
	}
	cout<<max(f(X),f(Y))<<endl;
}


Measured memory_bytes: 6368
#include<iostream>
using namespace std;
int cal(int a,int n,int x){
	int r = 0;
	for(int b=a;++b<n;){
		int c=x-a-b;
		if(c>b&&c<=n){
			++r;
		}
		else{
			continue;
		}
	}
	return r;
}
int c(int n,int x){
    int r=0;
    for(int i=0;++i<n;){
    	r += cal(i,n,x);
    }
    return r;
}
int main(){
	int n,x;
	while(true){
		cin>>n>>x;
		if(n==0&&x==0){
			return 0;
		}
		cout<<c(n,x)<<endl;
	}
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n;
    cin>>n;
    double a,s=0;
    for(ll i=0;i<n;i++){
        cin>>a;
        s+=1/a;
    }
    printf("%.5lf\n",1/s);
    return 0;
}

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

int main() {
  int n, bangou, kaisu; bool a=false;
  cin>>n; vector<int> nums(n);
  for(int i=0; i<n; i++){
    cin>>nums.at(i);
  }
  for(int i=0; i<n; i++){
    if(i==0){bangou=nums.at(i);}else{bangou=nums.at(bangou-1);} kaisu++;
    if(bangou==2){a=true; cout<<kaisu<<endl; break;}
  }
  if(a==false){cout<<"-1"<<endl;}
}

Measured memory_bytes: 3724
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long 
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}
map<int, int> mp;
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    fact();
    int N, M;
    cin >> N >> M;
    int j = 2;
    while(M > 1 && j * j <= 2000000000) {
        while(M % j == 0) {
            mp[j]++;
            M /= j;
        }
        j++;
    }
    if(M > 1) mp[M]++;
    int ans = 1;
    for(auto& e: mp) {
        int c = e.second;
        ans = Mul(ans, Div(F[c + N - 1], Mul(F[c], F[N - 1])));
    }
    cout << ans << endl;


    return 0;
}
// 

Measured memory_bytes: 20036
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


int main() {
  
  string S,T;
  cin >> S >> T;

  int ans = 0;
  for(int i = 0;i < S.size();i++) {
    if(S[i] != T[i]) ans++;
  }

  cout << ans << endl;
  
}


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

int main() {
 int H,W;
  cin >> H >> W;
  vector<vector<char>> gazou(H,vector<char>(W));
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      cin >> gazou.at(i).at(j);
    }
  }
  
  for (int i=0; i<W+2; i++){
    if (i!=W+1){
      cout << "#";
    }
    else cout << "#" <<endl;
  }
  
  for (int i=0; i<H; i++){
    for (int j=0; j<W+2; j++){
      if (j==0) cout << "#";
      else if (j!=W+1){
        cout << gazou.at(i).at(j-1);
      }
      else cout<<"#"<<endl;
    }
  }
  
   for (int i=0; i<W+2; i++){
    cout << "#";
   }
}

Measured memory_bytes: 256