akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
#define mod 1000000007
bool isPerfectSquare(int x) 
{   
    long double xx=(long double)x;
  long double sr = sqrt(xx); 
  
  // If square root is an integer 
  return ((sr - floor(sr)) == 0); 
} 
int main() 
{  
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    

   int n,d;
   cin>>n>>d;
   int arr[n][d];
   for(int i=0;i<n;i++)
   {
       for(int j=0;j<d;j++)
       {
           cin>>arr[i][j];
        //   cout<<arr[i][j]<<" ";
       }
   }
   int x=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+=(pow(abs(arr[i][k]-arr[j][k]),2));
             //  cout<<arr[i][k]<<" "<<arr[j][k]<<'\n';
         //    cout<<sum<<" ";
             
           }
             if(isPerfectSquare(sum))
               x++;
       }
   }
   cout<<x;



    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int A1 = getint();
	int B = getint();
	A1 -= B;
	int A2 = A1 - 1;
	int H[100000];
	rep(i, N) *(H + i) = getint();

	int L = 0, R = min((int)1e9, ((int)1e9 + A2 + B - 1) / B);

	while (L + 1 != R) {
		int half = (L + R) / 2;
		int damage = B * half - A2;
		int cnt = 0;
		rep(i, N) {
			int kari = *(H + i) - damage;
			if (kari > 0) {
				cnt += kari / A1;
			}
			if (cnt > half) break;
		}
		if (half >= cnt) R = half;
		else L = half;
	}

	co(R);

	Would you please return 0;
}

Measured memory_bytes: 768
process.stdin.resume();
process.stdin.setEncoding('ascii');

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on('data', function (data) {
    input_stdin += data;
});

process.on('SIGINT', function(){
    input_stdin_array = input_stdin.split("\n");
    main();
    process.exit();
});

process.stdin.on('end', function () {
    input_stdin_array = input_stdin.split("\n");
    main();    
});

function readLine() {
    return input_stdin_array[input_currentline++];
}

/////////////// ignore above this line ////////////////////

function main() {
	/*reading input*/
	var num = readLine();
	
	/* for avoiding \r at the end of the string */
	/*num = num.substr(0,num.length-1);*/
	var ans=0; 
	
	function backtrack(s, sum){
		if (s.length == 0){
			ans += sum;
			return;
		}
		for (var i=1; i <= s.length; i++){
			var s1 = s.substr(0,i);
			var s2 = s.substr(i);
			//console.log(s1 + " " + s2);
			backtrack(s2, sum+parseInt(s1));
		}
	}
	
	backtrack(num,0);
	console.log(ans.toString());
}


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

using namespace std;


int main()
{
    long long t,b,c,d,n,m,i,x,y;
  cin>>n;
  string s,a,aa;
  cin>>s;
  if(n%2){cout<<"No"<<endl;}
  else
  {
      x=n/2;
      for(i=0;i<x;i++)
      {
          a+=s[i];
      }
          for(i=x;i<n;i++)
      {
          aa+=s[i];
      }
      if(aa==a)cout<<"Yes"<<endl;
      else {cout<<"No"<<endl;}
  }

    return 0;
}


Measured memory_bytes: 3644
package main

import (
	"bufio"
	"fmt"
	"os"
	"unicode"
)

func main() {
	defer stdout.Flush()
	n := readInt()
	a := make(map[int]int)
	for i := 0; i < n; i++ {
		x := readInt()
		a[x-1]++
		a[x]++
		a[x+1]++
	}
	maxv := -1
	for _, v := range a {
		if v > maxv {
			maxv = v
		}
	}
	println(maxv)
}

var (
	stdin  *bufio.Reader
	stdout *bufio.Writer
)

func init() {
	stdin = bufio.NewReader(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func scanf(f string, args ...interface{}) (int, error) {
	n, err := fmt.Fscanf(stdin, f, args...)
	for {
		r, _, err := stdin.ReadRune()
		if err != nil || !unicode.IsSpace(r) {
			stdin.UnreadRune()
			break
		}
	}
	return n, err
}

func readInt() int {
	var n int
	scanf("%d", &n)
	return n
}

func readIntSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d", &a[i])
	}
	return a
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func readString() string {
	var s string
	scanf("%s", &s)
	return s
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}


Measured memory_bytes: 6912
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  while (cin >> N) {
    if (N == 3) {
      cout << "2 5 63" << endl;
      continue;
    }
    vector<int> a = {2, 3, 4, 9};
    vector<vector<int>> mods(6);
    mods[0].push_back(6);
    mods[2].push_back(8);
    for (int i = 10; i <= 30000; i++) {
      if (i % 2 == 0 || i % 3 == 0) {
        mods[i % 6].push_back(i);
      }
    }
    auto push = [&](int m) {
      a.push_back(mods[m].back());
      mods[m].pop_back();
    };
    for (int i = 4; i + 1 < N; i += 2) {
      if (mods[2].size() >= 1 && mods[4].size() >= 1) {
        push(2);
        push(4);
      } else if (mods[3].size() >= 2) {
        push(3);
        push(3);
      } else if (mods[0].size() >= 2) {
        push(0);
        push(0);
      } else {
        assert(false);
      }
    }
    if (N % 2 == 1) {
      push(0);
    }
    for (int x : a) {
      cout << x << " ";
    }
    cout << endl;
  }
  return 0;
}


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

int main(){

const int MAX_NO=100000;
int m[MAX_NO],f[MAX_NO],r[MAX_NO];
char hyouka[MAX_NO];
int a=0;
int b=0;

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

cin>>m[i]>>f[i]>>r[i];

a++;

for(int i=1;i<2000000000;i++){
b++;
b--;
b++;
b--;
}

if(m[i]==-1 && f[i]==-1 && r[i]==-1){
goto aa;
}

if(m[i]==-1 || f[i]==-1){
hyouka[i]='F';
}

else if((m[i]+f[i])>=80){
hyouka[i]='A';
}
else if((m[i]+f[i])>=65){
hyouka[i]='B';
}

else if((m[i]+f[i])>=50){
hyouka[i]='C';
}

else if((m[i]+f[i])>=30 && r[i]<50){
hyouka[i]='D';
}
else if((m[i]+f[i])>=30 && r[i]>=50){
hyouka[i]='C';
}

else if((m[i]+f[i])<30){
hyouka[i]='F';
}

}

aa:;

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

cout<<hyouka[i]<<endl;

}

return 0;
}

Measured memory_bytes: 1168
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //int n=Readint();
            //string[] str = Console.ReadLine().Split(' ');

            int d= int.Parse(Console.ReadLine());
            var c = new int[26];
            c = ReadArray(26);
            int sumc = c.Sum();
            var lastd = new int[26];


            for(int i = 1; i <= d; i++)
            {
                string[] str = Console.ReadLine().Split(' ');

                int max = -sumc*i;
                int maxn = 1;
                for(int j = 0; j < 26; j++)
                {
                    int temp = int.Parse(str[j]) + c[j] * (i - lastd[j]);
                    if (max < temp)
                    {
                        max = temp;
                        maxn = j;
                    }

                }
                Cout(maxn + 1);
                lastd[maxn] = i;
            }



            //ここまで
        }

        static void Cout(string s)
        {
            Console.WriteLine(s);
            return;
        }

        static void Cout(int n)
        {
            Console.WriteLine(n);
            return;
        }

        static void Cout(long n)
        {
            Console.WriteLine(n);
            return;
        }

        static int Readint()
        {
            return int.Parse(Console.ReadLine());
        }

        static int[] ReadArray(int n)
        {
            string[] str = Console.ReadLine().Split(' ');
            int[] a = new int[n];
            for (int i=0; i < n; i++){ a[i] = int.Parse(str[i]); }
            return a;
        }
        static long[] ReadArray(long n)
        {
            string[] str = Console.ReadLine().Split(' ');
           long[] a = new long[n];
            for (long i = 0; i < n; i++) { a[i] = long.Parse(str[i]); }
            return a;
        }

        static long Readlong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int Min(int a, int b)
        {
            if (a < b) return a;
            return b;
        }

        static int Max(int a, int b)
        {
            if (a > b) return a;
            return b;
        }


    }

}


Measured memory_bytes: 28436
count_500 = int(input())
count_100 = int(input())
count_50 = int(input())
target = int(input())

count=0
for i in range(count_500+1):
  for j in range(count_100+1):
    for k in range(count_50+1):
      if target==500*i+100*j+50*k:
        count+=1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

template<typename T>
void say(vector<T> s, char r) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << r << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T>& v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

std::string revString(std::string s) {
	string ret;
	auto it = s.rend();
	while (it != s.rbegin()) {
		ret.push_back(*it);
		++it;
	}
	return ret;
}

vector<vvi> init() {
	vi v;
	rep(10)v.push_back(0);
	vvi vv;
	rep(3)vv.push_back(v);
	vector<vvi> vvv;
	rep(4)vvv.push_back(vv);
	return vvv;
}

signed main() {
	vector<vvi> vvv = init();
	makei(n);
	rep(n) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		vvv[a - 1][b - 1][c - 1] += d;
	}
	string s;
	rep(20)s.push_back('#');
	rep(4) {
		for (vi v : vvv[i]) {
			for (int i : v) {
				cout << " " << i;
			}
			cout << endl;
		}
		if (i == 3)return 0;
		say(s);
	}
}


Measured memory_bytes: 3140
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let m: usize = sc.read();
    let child = {
        let mut child = vec![vec![]; n];
        for _ in 0..m {
            let v: usize = sc.read();
            let w: usize = sc.read();
            child[v - 1].push(w - 1);
        }
        child
    };
    let mut ans = 1000.;
    for stop in 0..n - 1 {
        let mut to_n: Vec<Option<f64>> = vec![None; n];
        to_n[n-1] = Some(0.);
        for i in (0..n - 1).rev() {
            let mut c_to_n = vec![];
            for &j in &child[i] {
                if let Some(to_n) = to_n[j] {
                    c_to_n.push(to_n + 1.);
                }
            }
            let ctnl = c_to_n.len();
            if ctnl > 0 {
                let s: &f64 = &c_to_n.iter().sum();
                to_n[i] = Some(if i == stop && ctnl > 1 {
                    let m = &c_to_n.iter().fold(0., |m, &v| if m < v { v } else { m });
                    (s - m) / (ctnl as f64 - 1.)
                } else {
                    s / ctnl as f64
                });
            }
        }
        if ans > to_n[0].unwrap() {
            ans = to_n[0].unwrap();
        }
    }

    format!("{}\n", ans)
}
#[test]
fn test_solve() {
    assert_eq!(solve("4 6\n1 4\n2 3\n1 3\n1 2\n3 4\n2 4\n"),"1.5\n");
    assert_eq!(solve("3 2\n1 2\n2 3\n"), "2\n");
    assert_eq!(solve("10 33\n3 7\n5 10\n8 9\n1 10\n4 6\n2 5\n1 7\n6 10\n1 4\n1 3\n8 10\n1 5\n2 6\n6 9\n5 6\n5 8\n3 6\n4 8\n2 7\n2 9\n6 7\n1 2\n5 9\n6 8\n9 10\n3 9\n7 8\n4 5\n2 10\n5 7\n3 5\n4 7\n4 9\n"), "3.0133333333\n");
}
fn main() {
    let mut buf = String::new();
    use std::io::Read;
    std::io::stdin().read_to_string(&mut buf).unwrap();
    use std::io::Write;
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<I> {
    src: I,
}
impl<'a> Scanner<std::str::SplitWhitespace<'a>> {
    fn from_str(src: &'a str) -> Self {
        Scanner {
            src: src.split_whitespace(),
        }
    }
}
#[allow(dead_code)]
impl<'a, I> Scanner<I>
where
    I: std::iter::Iterator<Item = &'a str>,
{
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.src.next().unwrap().parse().ok().expect("Parse error")
    }
    fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    fn chars(&mut self) -> Vec<char> {
        self.src.next().unwrap().chars().collect()
    }
}


Measured memory_bytes: 8444
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  char S[11],T[11],U[11];
  int A,B;
    
    scanf("%s",S);
  	scanf("%s",T);	
  scanf("%d %d",&A,&B);
  scanf("%s",U);
  if(strcmp(S,U)==0){
    A--;
    printf("%d %d\n",A,B);
    return 0;
  }
  else if(strcmp(T,U)==0){
    B--;
    printf("%d %d\n",A,B);
    return 0;
  }
  
}

Measured memory_bytes: 128
#include<stdio.h>

int main(int argc, char* argv[])
{
  char c;
  int i, j, h, w;
  scanf("%d %d", &h, &w);

  while((h != 0)||(w != 0)){
    for(i = 0; i < h; i++){
      if((i == 0)||(i == h - 1)){
        c = '#';
      }else{
        c = '.';
      }
      for(j = 0; j < w; j++){
        if((j == 0)||(j == w - 1)){
          printf("#");
        }else{
          printf("%c", c);
        }
      }
      printf("\n");
    }
    printf("\n");
    scanf("%d %d", &h, &w);
  }
  return(0);
}

Measured memory_bytes: 572
#include <vector>
#include <algorithm>
#include <iostream>

int main() {
    std::cin.tie(0);
     std::ios_base::sync_with_stdio(false);
    
    int N;
    std::cin >> N;
    std::vector<int> v(N), xs(N);
    
    for (int i{}, tmp; i < N; ++i) {
        std::cin >> tmp;
        xs[i] = tmp;
        v[i] = tmp;
    };
    std::sort( begin(v), end(v) );
    
    for (int i{}; i < N; ++i) {
        if (xs[i] <= v[N/2-1]) std::cout << v[N/2] << "\n";
        else std::cout << v[N/2-1] << "\n";
    };
}

Measured memory_bytes: 3840
def parent(i):
    return(i // 2)

def left(i):
    return(i * 2)

def right(i):
    return(i * 2 + 1)

H = int(input())
A_list = list(map(int, input().split()))
A_list.insert(0, 0)
for i in range(1, H+1):
    print("node ", i, ": key = ", A_list[i], ", ", sep="", end="")
    if parent(i) >= 1:
        print("parent key = ", A_list[parent(i)], ", ", sep="", end="")
    if left(i) <= H:
        print("left key = ", A_list[left(i)], ", ", sep="", end="")
    if right(i) <= H:
        print("right key = ", A_list[right(i)], ", ", sep="", end="")
    print("")


Measured memory_bytes: 5784
#include <stdio.h>
int main() {int a,b,j,k=0;while (1) {scanf("%d %d",&a,&b);if (!a && !b) return 0;if (k++) puts("");for (j=0;a<=b;a++) if ((a%4==0 && a%100) || a%400==0) printf("%d\n",a),j++; if (!j) puts("NA");}}

Measured memory_bytes: 0
/* original submission at https://atcoder.jp/contests/abc134/submissions/6473772 
   code by kayaryou */

#include<stdio.h>
int main(void){
    int n, a[200001], b[200001], sum=0;
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        scanf("%d", &a[i]);
        if(i>n/2){
            b[i]=a[i];
        }
    }
    if(n>2){
        b[1]=-1;
    }
    int m, s;
    for(int i=n/2; i>0; i--){
        m=2*i;
        s=0;
        while(m<=n){
            s+=b[m];
            m=m+i;
        }
        if(s%2==a[i]){
            b[i]=0;
        }else{
            b[i]=1;
        }
    }
    for(int i=1; i<=n; i++){
        sum+=b[i];
    }
    printf("%d\n", sum);
        for(int i=1; i<=n; i++){
            if(b[i]==1){
                printf("%d ", i);
            }
        }
    return 0;

}


Measured memory_bytes: 2432
x1,y1,x2,y2 = map(int,input().split())
MoveX,MoveY = x2 - x1,y2 - y1
x3,y3 = x2 - MoveY,y2 + MoveX
x4,y4 = x3 - MoveX,y3 - MoveY
print('{} {} {} {}'.format(x3,y3,x4,y4))

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

int b[30]={0};

int main(void){
	int n, m, k, ans=0;
	cin >> n >> m;
	for(int i=0; i<n; i++){
		cin >> k;
		for(int j=0; j<k; j++){
			int a;
			cin >> a;
			b[a-1]++;
		}
	}
	for(int i=0; i<m; i++){
		if(b[i]==n) ans++;
	}
	cout << ans << endl;
		
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let a = sc.read_vec::<i64>(n);
    const MOD: i64 = 1e9 as i64 + 7;

    let mut cum = vec![0; n + 1];
    for i in 0..n {
        cum[i + 1] = cum[i] + a[i];
    }

    let mut ans = 0;
    for i in 0..n {
        ans += a[i] * ((cum[n] - cum[i + 1]) % MOD);
        ans %= MOD;
    }
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 3992
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Echizen
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String str = in.next();
            char[] chars = str.toCharArray();
            HashSet<Object> set = new HashSet<>();
            for (int i = 0; i < chars.length; i++) {
                set.add(chars[i]);
            }
            if (set.size() == chars.length) {
                out.println("yes");
            } else {
                out.println("no");
            }
        }

    }
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n; //odd
    cin>>n;
    vector<double> p(n);
    REP(i,n) cin>>p[i];

    constexpr int N = 3005;
    vector<vector<double>> dp(N, vector<double>(N, 0.0f));
    dp[0][0] = 1.0f; //[表が出た枚数][0枚目のコインを投げた確率]
    REP(i,n) REP(j,n){
        //1-p[i] == 裏が出る確率
        dp[i][j+1] += dp[i][j] * (1-p[j]);
        dp[i+1][j+1] += dp[i][j] * p[j];
    }
    
    // REP(i,n+1){
    //     REP(j,n+1){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // } 

    double ans=0.0;
    FOR(i,n/2+1,n+1){
        ans += dp[i][n];
    }
    cout << setprecision(12) << ans << endl;
    return 0;
}

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


void solve(long long N, long long M, std::vector<long long> L, std::vector<long long> R){
    long long maxL = *max_element(L.begin(), L.end());
    long long minR = *min_element(R.begin(), R.end());
    cout << max(0LL, minR - maxL + 1) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> L(M);
    std::vector<long long> R(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&L[i]);
        scanf("%lld",&R[i]);
    }
    solve(N, M, std::move(L), std::move(R));
    return 0;
}


Measured memory_bytes: 4832
#include <iostream>
     #include <string>
     #include <vector>
     #include <algorithm>
     #include <utility>
     #include <map>
     using namespace std;
     typedef long long ll;
     #define rep(i, n) for (int i=0;i < (int)(n);i++)


     class union_find {
     public:
     vector<int> par,rank,lsize;
     union_find(int n): par(n),rank(n),lsize(n){
     for (int i=0;i < n;i++){
          par[i]=i;
          rank[i]=0;
          lsize[i]=1;
     }
     }

     int find(int x){
     if (par[x]==x){
          return x;
     }
     else{
          par[x] = find(par[x]);
          return par[x]; 
     }
     }

     void unite(int x ,int y){
     x=find(x);
     y=find(y);
     if (x==y) return;
     if (rank[x] < rank[y]){
          lsize[y] += lsize[x];
          lsize[x] = -1;
          par[x] = y;
     }else{
          lsize[x] += lsize[y];
          lsize[y] = -1;
          par[y]=x;
          if (rank[x]==rank[y]) rank[x]++;
     }   
     }

     bool same(int x, int y){
     return find(x) == find(y);
     }

     int size(int x){
     if (lsize[x] == -1){
          x=find(x);
     }
     return lsize[x];
     }
     };

     int main(){
          int n,k,l;
          cin >> n >> k >> l;
          //vector<int> anss(n,0);
          union_find road(n);
          union_find rail(n);
          using pint = pair<int,int>;
          map<pint,int> mp;

          rep(i,k){
               int x,y;
               cin >> x >> y;
               x--;y--;
               road.unite(x,y);
          }
          rep(i,l){
               int x,y;
               cin >> x >> y;
               x--;y--;
               rail.unite(x,y);
          }
          rep(i,n){
               pint p=make_pair(road.find(i),rail.find(i));
               mp[p]++;
          }
          rep(i,n){
               pint p=make_pair(road.find(i),rail.find(i));
               cout << mp[p] << " ";
          }
          cout << endl;
          
          return 0;
     
     }


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
int main()
{
    ll t;
    cin>>t;
    ll tle=0,wa=0,re=0,ac=0;
    while(t--)
    {
        string s;
        cin>>s;
        if(s=="AC")ac++;
        else if(s=="TLE")tle++;
        else if(s=="WA")wa++;
        else re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int H, W; cin >> H >> W;
  VS vs(H);
  REP(i,H) cin >> vs[i];

  VS rs(H, string(W, '.'));
  auto bs = rs;
  REP(y,H) rs[y][0] = '#';
  REP(y,H) bs[y][W-1] = '#';

  FOR(y,1,H-1) FOR(x,1,W-1){
	if(vs[y][x] == '#') bs[y][x] = rs[y][x] = '#';
	if(y%2 == 0)
	  bs[y][x] = '#';
	else
	  rs[y][x] = '#';
  }

  REP(y,H) cout << rs[y] << endl;
  cout << endl;
  REP(y,H) cout << bs[y] << endl;
  /*
  cout<<endl;
  REP(y,H){
	REP(x,W)if(rs[y][x]==bs[y][x]&&bs[y][x]=='#')cout<<"#";else cout<<".";
	cout << endl;
  }
  */  
  return 0;
}


Measured memory_bytes: 1536
#include <cstdio>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main(void) {
  int a, b, c;
  cin >> a >> b >> c;
  puts(a+b == c || b+c == a || c+a == b ? "Yes" : "No");
  return 0;
}


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

using namespace std;
#define LL long long

int main() {
    int n;
    cin >> n;
    double ans = 0;
    for(int i=0; i<n; i++){
        string x,y;
        cin >> x >> y;
        if(y=="JPY")ans += stod(x);
        else ans += stod(x) * 380000.0;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);

int main(){
	IOS;
	int n,a,b;
	while(cin>>n>>a>>b){
		if((a-b)%2==0){
			cout<<"Alice"<<endl;
		}
		else{
			cout<<"Borys"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, ans = 0;
  cin >> N;
  if (N % 2 == 1) {
    cout << 0 << endl;
    return 0;
    //    for (int i = 1; i <= 18; i++) {
    //      ans += N / pow(5, i);
  }

  else {
    N = N / 2;
    for (int i = 1; i <= 28; i++) {
      ans += N / (ll)pow(5, i);

    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int64_t N,K,ans=-1*INF; cin>>N>>K;
  vector<int64_t> P(N);
  rep(i,N) cin>>P.at(i);
  rep(i,N) P.at(i)--;
  vector<int64_t> C(N);
  rep(i,N) cin>>C.at(i);

  rep(i,N){
    vector<bool> seen(N,true);
    vector<int64_t> S,T;
    int64_t k=i,sum=0;
    while(seen.at(k)){
      seen.at(k)=false;
      S.push_back(C.at(k));
      sum+=C.at(k);
      k=P.at(k);
    }
    int64_t t=S.size(),r=K/t,q=K%t,MAX=-1*INF,NMAX,MAX2=-1*INF;
    rep(i,t){
      T.push_back(S.at(i));
      if(i>0) T.at(i)+=T.at(i-1);
      if(T.at(i)>MAX){
        MAX=T.at(i);
        NMAX=i+1;
      }
    }
    if(q==0) ans=max(ans,MAX+sum*(r-1));
    else{
      if(q<NMAX){
        rep(i,q) MAX2=max(MAX2,T.at(i));
        if(r==0) ans=max(ans,MAX2);
        else if(sum<0) ans=max(ans,MAX);
        else{
          auto temp=max(MAX+sum*(r-1),MAX2+sum*r);
          ans=max(ans,temp);
        }
      }
      else{
        if(sum<0) ans=max(ans,MAX);
        else ans=max(ans,MAX+sum*r);
      }
    }
  }
  cout<<ans;
}


Measured memory_bytes: 3764
#include <stdio.h>
#include <algorithm>
using namespace std;
int val, size_, heap[2097168]; char c[9];
inline void insert(int x) {
	int ptr = size_++; heap[ptr] = x;
	while (ptr > 1) {
		if (heap[ptr >> 1] < heap[ptr]) swap(heap[ptr], heap[ptr >> 1]);
		ptr >>= 1;
	}
}
inline int extract() {
	int ret = heap[1], ptr = 1;
	while ((ptr << 1) + 1 < size_) {
		ptr <<= 1;
		if (heap[ptr] > heap[ptr + 1]) swap(heap[ptr >> 1], heap[ptr]);
		else swap(heap[ptr + 1], heap[ptr >> 1]), ptr++;
	}
	heap[ptr] = heap[--size_], heap[size_] = 0;
	while (ptr > 1) {
		if (heap[ptr >> 1] < heap[ptr]) swap(heap[ptr], heap[ptr >> 1]);
		ptr >>= 1;
	}
	return ret;
}
int main() {
	size_ = 1;
	while (scanf("%s", c), c[3]) {
		if (c[0] == 'i') scanf("%d", &val), insert(val);
		else printf("%d\n", extract());
	}
	return 0;
}

Measured memory_bytes: 6636
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}


long long mod_pow(long long x, long long n, long long mod) {
    if (n == 0) return 1;
    long long res = mod_pow(x * x % mod, n / 2, mod);
    if (n & 1) res = res * x % mod;
    return res; 
}


// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


const int MOD = 1000000007;


void solve() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    map<long long, long long> mp;
    for (int i = 0; i < N; i++) {
        auto pf = prime_factorize(A[i]);
        for (auto p : pf) {
            mp[p.first] = max(mp[p.first], p.second);
        } 
    }

    long long lcm = 1;
    for (auto m : mp) {
        lcm *= mod_pow(m.first, m.second, MOD);
        lcm %= MOD;
    }

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        ans += lcm * modinv(A[i], MOD) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}


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

Measured memory_bytes: 4084
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
int a = inp.nextInt();
int b = inp.nextInt();
int c = inp.nextInt();
int d;
 
if (a>c){
d = c;
c = a;
a = d;
}
if (b>c){
d = c;
c = b;
b = d;
}
if (a>b){
d = a;
a = b;
b = d;
}
 
System.out.println(a+" "+b+" "+c);
}
}


Measured memory_bytes: 26208
import java.util.*;
public class Main {
	static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
    }
    static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
    }  
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long T = sc.nextLong();
		for(int i = 0; i < N-1; i++){
			long S = sc.nextLong();
			T = lcm(T, S);
		}
		System.out.println(T);
	}
}

Measured memory_bytes: 23636
#include <iostream>

using namespace std;

void out (string s, int num) {
  cout << s << " x " << num << endl;
}

int main () {
  int count;
  cin >> count;
  int ac= 0,wa =0,tle =0,re=0;
  for (int i = 0; i < count ; ++i) {
    string s;
    cin >> s;
    if (s =="AC") {
    	++ac;
    }
    else if (s == "WA") {
      ++wa;
    }
    else if (s =="TLE") {
      ++tle;
    }
    else if (s =="RE") {
      ++re;
    }
  }
  out("AC",ac);
  out("WA",wa);
  out("TLE",tle);
  out("RE",re);
  
}

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

typedef struct TREE{
	int id;
	int depth;
	int k;
	struct TREE *parent;
	struct TREE **child;
}Tree;

Tree tree[100000];

void setDepth(Tree *nt, int depth){
	int i;
	if( nt == NULL ){ return; }
	nt->depth = depth;
	for( i = 0; i < nt->k; i++ ){
		setDepth(nt->child[i], depth+1);
	}
	return;
}

void print(Tree *p){
	int parent, nodetype, i;
	char *nodename[] = {"root", "internal node", "leaf"};
	if( p == NULL ){ return; }
	if( p->parent == NULL ){
		parent = -1;
	}else{
		parent = p->parent->id;
	}
	if( parent == -1 ){
		nodetype = 0;
	}else if( p->k > 0 ){
		nodetype = 1;
	}else{
		nodetype = 2;
	}
	printf("node %d: parent = %d, depth = %d, ", p->id, parent, p->depth);
	printf("%s, ", nodename[nodetype]);
	printf("[");
	if( p->k > 0 ){
		printf("%d", p->child[0]->id);
		for( i = 1; i < p->k; i++ ){
			printf(", %d", p->child[i]->id);
		}
	}
	printf("]\n");
	return;
}

int main(){
	int n, id, id2, i, j;
	scanf("%d", &n);
	Tree *root = NULL;
	for( i = 0; i < n; i++ ){
		tree[i].id = i;
		tree[i].parent = NULL;
		tree[i].child = NULL;
		tree[i].k = -1;
		tree[i].depth = -1;
	}
	for( i = 0; i < n; i++ ){
		scanf("%d", &id);
		scanf("%d", &tree[id].k);
		tree[id].child = (Tree**)malloc(sizeof(Tree*)*tree[id].k);
		for( j = 0; j < tree[id].k; j++ ){
			scanf("%d", &id2);
			tree[id].child[j] = &tree[id2];
			tree[id2].parent = &tree[id];
		}
	}
	//???????±??????????
	for( i = 0; i < n; i++ ){
		if( tree[i].parent == NULL ){
			root = &tree[i];
			break;
		}
	}
	//??±???????±??????????
	setDepth(root, 0);
	//???????????????
	for( i = 0; i < n; i++ ){ print(&tree[i]); }
	return 0;
}

Measured memory_bytes: 7648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define ff first
#define ss second
//#define p pair<ll,ll>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define iof  freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define pi acos(-1)
const int mxn=1e9+5;
int main()
{
    fast;
    ll n,k;
    cin>>n>>k;
    vector<ll>p(n);
    vector<ll>cost(n);
    for(auto &i:p)
    {
        cin>>i;
        i--;
    }
    for(auto &i:cost)
    {
        cin>>i;
    }
   // vector<int>visited(n);
   ll mx=-1e18-5;
   ll ans=-1e18-5;
    for(ll i=0;i<n;i++)
    {
        vector<ll>vec;
        ll sum=0;
        ll x=i;
        while(true)
        {
            x=p[x];
            sum+=cost[x];
            vec.pb(sum);
            if(x==i)break;
        }
        ll loop=k/vec.size();
        ll r=k%vec.size();
        if(vec.back()>0&&k>vec.size())
        {
            ll mx1=-1e18-5;
            for(auto i:vec)
            {
                mx1=max(mx1,i);
            }
            ans=max(ans,(loop-1)*vec.back()+mx1);
            mx1=-1e9-5;
            for(int i=0;i<(ll)r;i++)
            {
                mx1=max(mx1,vec[i]);
            }
            ans=max(ans,loop*vec.back()+mx1);
        }
        else
        {
            for(int i=0;i<(ll)min((ll)vec.size(),k);i++)
            {
                ans=max(ans,vec[i]);
            }
        }
    }
    cout<<ans<<endl;
}



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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 200000

int N;
long long D;
long long A[MAX + 1];

typedef pair<int, int> P;
typedef pair<long long, P> Edge;
vector<Edge> edges;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void rec(int left, int right)
{
    if (right - left <= 1) return;
    int mid = (left + right) / 2;
    
    long long leftmin = 1LL<<60;
    int leftminp = -1;
    for (int i = left; i < mid; ++i) if (chmin(leftmin, A[i]-D*i)) leftminp = i;
    long long rightmin = 1LL<<60;
    int rightminp = -1;
    for (int i = mid; i < right; ++i) if (chmin(rightmin, A[i]+D*i)) rightminp = i;
    
    for (int i = left; i < mid; ++i)
        edges.push_back(make_pair(A[rightminp] + A[i] + D * (rightminp - i), make_pair(i, rightminp)));
    for (int i = mid; i < right; ++i)
        edges.push_back(make_pair(A[leftminp] + A[i] + D * (i - leftminp), make_pair(leftminp, i)));
    
    rec(left, mid);
    rec(mid, right);
}

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

	rec( 0, N );
	sort( edges.begin(), edges.end() );
	UnionFind uf( N );
	long long ans = 0;
	for( int i = 0; i < edges.size(); i++ ) {
		Edge e = edges[i];
		if( !uf.issame( e.second.first, e.second.second ) ) {
			uf.merge( e.second.first, e.second.second );
			ans += e.first;
		}
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    vector<int> id(n);
    iota(id.begin(), id.end(),0);
    sort(id.begin(), id.end(), [&](auto& u, auto& v){
        return a[u] < a[v];
    });
    vector<int> res(n);
    for (int k = 0; k < n; k++) {
        int i = id[k];
        if (k < n/2) res[i] = a[id[n/2]];
        else res[i] = a[id[n/2 -1]];
    }
    for (auto& x: res) {
        cout << x << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 4608
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

template <class T> istream& operator>>(istream& input, vector<T>& v);
template <class T> ostream& operator<<(ostream& output, const vector<T>& v);

int main() {
    ll N, ans = 0;
    cin >> N;
    vector<ll> a(3 * N);
    cin >> a;
    sort(a.begin(), a.end(), greater<ll>());
    for (int i = 1; i < 2 * N; i += 2) ans += a[i];
    cout << ans << endl;
}


template <class T>
istream& operator>>(istream& input, vector<T>& v) {
    for (T& i : v) cin >> i;
    return input;
}
template <class T>
ostream& operator<<(ostream& output, const vector<T>& v) {
    output << "[";
    for (auto itr = v.begin(); itr != v.end() - 1; ++itr) output << *itr << ", ";
    output << v.back() << "]";
    return output;
}

Measured memory_bytes: 2560
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
--import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
--import Data.Array
--import Data.Array.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
import System.IO
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete



main = do
    [a, b, k] <- getInts
    mapM_ print $ map head $ group $ sort $ take k [a..b] ++ take k [b,b-1..a]

Measured memory_bytes: 764
import math

n = int(input())
a_list = list(map(int,input().split()))
num = [0]*(n+1)
for a in a_list:
  num[a] += 1
c = 0
for n in num:
  if n != 0:
    c += n*(n-1)//2
for a in a_list:
  print(c-num[a]+1)

Measured memory_bytes: 26140
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pa pair<int,int>
#define ld long double
#define BOOST ios_base::sync_with_stdio(false)
#define pb push_back
using namespace std;
const int MAX=1e5+5;
int dp[MAX][3];
int a[MAX];
int b[MAX];
int c[MAX];
int main()
{
    int n;
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
    }

    for (int i=1;i<=n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    int maximum=0;
    for (int i=0;i<3;i++)
    {
       maximum=max(maximum,dp[n][i]);
    }
    printf("%d",maximum);
    return 0;
}




Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
int C;
vector<i64> A,B;

int dp[31][1 << 16];

int solve(){

  rep(i,0,30){
    rep(j,0,(1 << 16) - 1) dp[i][j] = -1e9;
  }
  dp[0][0] = 0;
  cin >> N >> C;
  if(N == 0 && C == 0){
    return 0;
  }
  A.assign(N,0);
  B.assign(C,0);
  rep(i,0,N - 1){
    rep(j,0,15){
      int a;
      cin >> a;
      A[i] += a * (1LL << j);
    }
  }
  rep(i,0,C - 1){
    rep(j,0,15){
      int a;
      cin >> a;
      B[i] += a * (1LL << j);
    }
  }

  rep(i,0,N - 1){
    rep(s,0,(1 << 16) - 1){
      rep(j,0,C - 1){
        auto & to = dp[i + 1][(s | A[i]) & ~(B[j])];
        to = max(to , dp[i][s] + __builtin_popcount((s | A[i]) & B[j]));
      }
    }
  }

  int ans = 0;
  rep(s,0,(1 << 16) - 1){
    ans = max(ans,dp[N][s]);
  }

  cout << ans << endl;
  return 1;
}

int main(){
  while(solve());
}



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

int main(){
	int n,k;
	cin>>n>>k;
	int sum=1;
	for(int i=0;i<n;i++){
		if(sum<=k){
			sum*=2;
		}
		else{
			sum+=k;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

a = I()
s = str(input())

if a>=3200:
    print(s)
else:
    print('red')

Measured memory_bytes: 38492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
constexpr ll INF = 1LL<<60;

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

    ll ans = 0;
    FOR(i, 1, n+1) {
        if(i%3==0 || i%5==0) continue;
        ans += i;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652