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

class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String[] args){
    int  n = sc.nextInt();
    List<Xy> l = new ArrayList<>(n);
    for(int i=0;i<n;i++){
      l.add(new Xy(sc.nextInt(),sc.nextInt()));
    }
    Collections.sort(l);
//    for(Xy xy:l){
//      System.out.println(xy);
//    }
    double max=0;
    for(int i=0;i<n;i++){
      int rx=0;
      int ry=0;
      for(int j=0;j<n;j++){
        rx+=l.get(j).x;
        ry+=l.get(j).y;
        max=Math.max(Math.hypot(rx,ry),max);
      }
      Xy r=l.remove(0);
      l.add(r);
    }
    System.out.println(max);
  }
  static class Xy implements Comparable{
    int x;
    int y;
    Xy(int x,int y){
      this.x=x;
      this.y=y;
    }
    public String toString(){
      return "["+x+","+y+"]";
    }
    static int hencom(Xy s1,Xy s2){
      return (int)Math.signum(Math.atan2(s1.y,s1.x)-Math.atan2(s2.y,s1.x));
    }
    public int compareTo(Object o){
      return (int)Math.signum(Math.atan2(y,x)-Math.atan2(((Xy)o).y,((Xy)o).x));
    }
  }
}


Measured memory_bytes: 21972
N,M = map(int,input().split())
X = list(map(int, input().split()))

if N>=M: print(0)
else:
  X.sort()
  delta_X = [X[i]-X[i-1] for i in range(1,M)]
  delta_X.sort()
  print(sum(delta_X[0:M-N]))

Measured memory_bytes: 20432
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    ll N;
    cin >> N;
    vector<ll>v(N + 1, 0);
    for(ll i = 1; i <= N; i++)cin >> v[i];
    vector<ll>ans(N + 1, 0);
    for(ll i = N; i >= 1; i--){
        ll tmp = v[i];
        for(ll j = i + i; j <= N; j += i)tmp ^= ans[j];
        ans[i] = tmp;
    }
    vector<ll>hoge;
    for(ll i = 1; i <= N; i++)if(ans[i])hoge.push_back(i);
    cout << hoge.size() << endl;
    if(hoge.size()){
        for(ll i = 0; i < hoge.size(); i++){
            if(i)cout << " ";
            cout << hoge[i];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 4980
#include "bits/stdc++.h"

using namespace std;

#define all(v)          v.begin(), v.end()
#define pb              push_back
#define sz(x)          (int) (x.size())
#define endl            "\n"
#define isOdd(n)       (n&1)
#define pow(n, m)      (ll)powl(n, m)
#define clr(x, val)     memset(x, val, sizeof(x))

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


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, d; cin >> n >> d;
    int c  = 0;
    while(n--){
        ll x, y; cin >> x >> y;
        ld di = sqrt(x * x + y * y);
        if(!isgreater(di, d)) c++;
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 3660
N, Q = [int(v) for v in input().split()]

class Node:
    def __init__(self):
        self.list = []
        self.score = 0

    def add(self, node):
        self.list.append(node)

nodes = []
score = [0] * N

for i in range(0, N):
    nodes.append([])

for i in range(0, N - 1):
    a, b = [int(v) - 1 for v in input().split()]
    nodes[a].append(b)

for i in range(0, Q):
    p, x = [int(v) for v in input().split()]
    score[p-1] += x

l = [0]

i = 0
while i < len(l):
    node = l[i]
    for child in nodes[node]:
        score[child] += score[l[i]]
        l.append(child)
    i += 1

print(' '.join(map(str, score)))


Measured memory_bytes: 60520
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

class UnionFind {
	vector<int>parent;
	vector<int>rank;
public:
	UnionFind(int num) {
		num++;
		parent.resize(num);
		rank.resize(num);
		for (int i = 0; i < num; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}
	int Find(int node) {
		if (parent[node] == node)return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v) {
		u = Find(u);
		v = Find(v);
		if (u == v)return;
		if (rank[u] < rank[v])parent[u] = v;
		else {
			parent[v] = u;
			if (rank[u] == rank[v])rank[u]++;
		}
	}
	bool Check_Same(int u, int v) {
		return Find(u) == Find(v);
	}
};

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

	cin >> N >> M;
	UnionFind uf(N);
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		uf.Unite(L - 1, R - 1);
	}
	vector<int>num(N);
	for (int i = 0; i < N; i++) {
		num[uf.Find(i)]++;
	}
	cout << *max_element(num.begin(), num.end()) << endl;
}

Measured memory_bytes: 5568
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main(){
       int n,l,order[100];
       char line[100][100];
       scanf("%d%d",&n,&l);
       for(int i=0;i<n;i++){
              order[i]=i;
              scanf("%s",&line[i]);
       }
       for(int i=0;i<n-1;i++){
              for(int j=0;j<n-i-1;j++){
                     if(strcmp(line[order[j]],line[order[j+1]])>0){
                            order[j]=order[j]^order[j+1];
                            order[j+1]=order[j]^order[j+1];
                            order[j]=order[j]^order[j+1];
                     }
              }
       }
       for(int i=0;i<n;i++){
                     for(int j=0;j<l;j++)
              printf("%c",line[order[i]][j]);
       }
       return 0;
}


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

int main(){
  int n,k;
  cin >> n >> k;
  int ninzu = n;
  vector<int> hantei(n);
  for(int i=0;i<k;i++){
    int a;
    cin >> a;
    for(int j=0; j<a; j++){
      int motinusi;
      cin >> motinusi;
      for(int k=0; k<n; k++){
      if(motinusi==k+1 && hantei[k]==0){
        ninzu--;
        hantei[k]++;
      }
      }
    }
  }
  cout << ninzu << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();sc.nextLine();
        String str = sc.nextLine();
        StringBuilder sb = new StringBuilder();
        int rp = 0;
        for (int i = str.length()-1; i >= 0; i--) {
            if (str.charAt(i) == ')')
                rp++;
            else if(rp != 0)
                rp--;
        }
        for (int i = 0; i < rp; i++)
            sb.append('(');
        sb.append(str);
        int lp = 0;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == '(')
                lp++;
            else if(lp != 0)
                lp--;
        }
        for (int i = 0; i < lp; i++)
            sb.append(')');
        System.out.println(sb.toString());
    }

    static boolean check(String s) {
        if (s.length() % 2 != 0)
            return false;
        int n = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '(')
                n++;
            else
                n--;
            if (n < 0)
                return false;
        }
        return true;
    }
}


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

#define MAX_VERTEX  100
#define INF         1000000

int vertex_num;                   // ???????????°

int cost[MAX_VERTEX][MAX_VERTEX]; // ????????????cost[?§????][??????]??§?§?????????????????????????????????¨???
int d[MAX_VERTEX];                // ????????????d[u]??§?§??????¨u??????????????¢?????¨??????
bool used[MAX_VERTEX];            // ????????????????????£????????¢????±???????????????????

void Input() {
	cin >> vertex_num;

	// (a1) ??\???????????¶??§?????????

	// d??¨cost?????¨???INF
	// used????????????false
  for (int i = 0; i < vertex_num; i++) {
    d[i] = INF;
    used[i] = false;
    for (int j = 0; j < vertex_num; j++) {
      cost[i][j] = INF;
    }
  }

	for (int i = 0; i < vertex_num; i++) {
		int from, out_num;
		cin >> from >> out_num;
		for (int j = 0; j < out_num; j++) {
			int to, c;
			cin >> to >> c;
			cost[from][to] = c;
		}
	}
}

void Dijkstra() {

	// (b1) ?§????????????????
  d[0]    = 0;

	while (true) {
		// ????????????????????¨???
		int vertex = -1;

		// (b2) ????????????????????£????????¢????±??????????????????????
		// ?????????????????????????????????????????§????????¢???????°???????????????¢???
    for(int u = 0; u < vertex_num; u++) {
      if(!used[u] && (vertex == -1 || d[u] < d[vertex])) {
        vertex = u;
      }
    }

		// ??¨????????????????????????????¨?????????????????????´????????????????????????
		if (vertex == -1) {
      break;
    }

		used[vertex] = true;

		// ???????????¢????¨????????????????
    for(int u = 0; u < vertex_num; u++) {
      d[u] = min(d[u], d[vertex] + cost[vertex][u]);
    }

	}

}

void Output() {
	for (int i = 0; i < vertex_num; i++) {
		cout << i << " " << d[i] << endl;
	}
}

int main() {

	Input();
	Dijkstra();
	Output();

	return 0;
}

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

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")
}


fn main() {
    let s: String = read();
    let ret = match s.as_str() {
        "SAT" => 1,
        "FRI" => 2,
        "THU" => 3,
        "WED" => 4,
        "TUE" => 5,
        "MON" => 6,
        "SUN" => 7,
        _ => 0
    };
    println!("{}", ret);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<iostream>
using namespace std;
int n,k;
int a[300010];
int main() {
	scanf("%d%d",&k,&n);
	if(k&1) {
		for(int i=1; i<=n; i++)
			a[i]=(k+1)/2;
		int last=n;
		for(int i=1; i<=n/2; i++)
			if(a[last]==1) last--;
			else {
				a[last]--;
				for(int j=last+1; j<=n; j++)
					a[j]=k;
				last=n;
			}
		for(int i=1; i<=last; i++)
			printf("%d ",a[i]);
	} else {
		printf("%d ",k/2);
		for(int i=2; i<=n; i++)
			printf("%d ",k);
	}
	return 0;
}//gg

Measured memory_bytes: 3456
#----グローバル変数----
INF = 10**10 #無限大（最小化問題の場合）
dp=[]       #DPテーブル

h=[]   #足場の高さ
#----------------------

#----関数----

#DPテーブル更新関数　最小化用＆最大化用
def chmin(dp, idx, new_val):
    if dp[idx] > new_val:
        dp[idx] = new_val
        return True
    return False

def chmax(dp, idx, new_val):
    if dp[idx] < new_val:
        dp[idx] = new_val
        return True
    return False
#------------


#----実行開始----
# 入力
n,k = map(int, input().split())

s = input()
h = [int(x) for x in s.split()]

# DPテーブル初期化 (最小化問題なので INF に初期化)
for i in range(n+k-1):
    dp.append(INF)

#配るタイプなので、hをk-1分延長しておく
for i in range(k-1):
    h.append(0)

# 初期条件
dp[0] = 0;

# ジャンプのループ
for i in range(0,n-1):
    for j in range(1,k+1):
        # jp check    
        jpcost = abs(h[i]-h[i+j])
        chmin(dp,i+j,dp[i]+jpcost)

# 出力
print(dp[n-1])

#---------------


Measured memory_bytes: 56544
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        String ans[]={"sat","sun","mon","tue","wed","thu","fri"};
        int x=sc.nextInt();
        int n=0;

        int a=Math.abs(x-9);

        if (x<9)
        {
            int b=a%7;
            if (b==0) {n=0;}
            else {n=ans.length-b;}
        }
        else { n=a%7; }

        System.out.println(ans[n]);
    }
}


Measured memory_bytes: 26328
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n;
cin >> n;
int a[n];
int ma=mINF,mi=INF;
REP(i,n) {
  cin >> a[i];
  ma=max(ma,a[i]);
  mi=min(mi,a[i]);
}
cout << ma-mi << endl;
return 0;
}


Measured memory_bytes: 256
//*******Abhijit Burman***********//
//Jalpaiguri Government Engineering College//

// Taken From Striver_79
// Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts 
// Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure. 


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define MAXX (1000000000000000000+7)
#define mod 1000000007
#define endl "\n"
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
void input(ll a[], ll sz) {for(ll i=0;i<sz;i++) cin >> a[i];}
void print(ll a[], ll sz) {for(ll i=0;i<sz;i++) {if (i == sz - 1) cout << a[i] << "\n"; else cout << a[i] << " ";}}
ll dx1[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll dy1[] = {0, 1, 1, 1, 0, -1, -1, -1};

ll dx2[] = {1, 0, -1, 0};
ll dy2[] = {0, 1, 0, -1};

ll mul(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
ll power(ll x,ll y,ll p = mod) 
{ 
    ll res = 1;
    x = x % p;
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p;
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p = mod)
{
    return power(n, p - 2, p);
}
ll ncrMod(ll n, ll r, ll p = mod)
{
    if (r == 0)
        return 1;
    ll fac[n + 1];
    fac[0] = 1;
    for (ll i = 1 ; i <= n; i++)
        fac[i] = fac[i - 1] * i % p;
    return (fac[n] * modInverse(fac[r], p) % p *
            modInverse(fac[n - r], p) % p) % p;
}
// a+b=xor(a,b)+2*(a&b)//

bool isPrime(ll n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}


void solve()
{
    ll n;
    cin>>n;
    
    ll a[n];
    input(a,n);
    ll temp = a[0],cnt=0;
    for(int i=1;i<n;i++){
        if(a[i]<temp){
            cnt+=(temp-a[i]);
        }
        else{
            temp = a[i];
        }
    }
    cout<<cnt<<endl;
}


int main()
{
	fio;
// 	#ifndef ONLINE_JUDGE
//     // for getting input from input.txt
//     freopen("input.txt", "r", stdin);
//     // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
// 	#endif
 

	ll t=1;
// 	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 5180
import fractions


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


N = int(input())
A = list(map(int, input().split()))
l = A[0]
mod = 10**9+7
ans = 0
for i in range(1, N):
    l = lcm(l, A[i])
for i in range(N):
    ans += l // A[i]
print(ans % mod)


Measured memory_bytes: 6112
#include <stdio.h>

#define MAX 100

int main(void)
{
    int i = 0, j = 0;

    int data[MAX];
    while (scanf("%d", &data[i]) != EOF) {
        i++;
    }
    int data_num = i;

    int cnt[101] = {0};
    int datum;
    for (i = 0; i < data_num; i++) {
        datum = data[i];
        cnt[datum]++;
    }

    int mode = 0;
    for (i = 0; i < data_num; i++) {
        if (cnt[i] > mode) {
            mode = cnt[i];
        }
    }

    int mode_list[101];
    for (i = 0; i < data_num; i++) {
        if (cnt[i] == mode) {
            mode_list[j++] = i;
        }
    }
    int mode_num = j;

    for (i = 0; i < mode_num; i++) {
        printf("%d\n", mode_list[i]);
    }

    return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <cstring>

using namespace std;

int main() {
    char s[100010]={};
    scanf("%s", s);

    for (int i=-1; s[++i];)
        for (int j=i+1; j<=i+2; ++j)
            if (s[i] == s[j]) {
                printf("%d %d\n", i+1, j+1);
                return 0;
            }

    printf("-1 -1\n");
    return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  } else if (A + B < C + D) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}


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

using namespace std;


int main() {

    string s;

    cin >> s;

    int index = 0;
    while(index < s.size() / 2) {

        if(s[index] != s[s.size() - index - 1])
            break;
        index++;

    }

    if(index != s.size() / 2) {
        cout << "No" << endl;
        return 0;
    }

    int endI = s.size() / 2 - 1;
    index = 0;
    while(index < endI) {

        if(s[index] != s[endI])
            break;

        index++;
        endI--;

    }

    if(index < endI) {
        cout << "No" << endl;
        return 0;
    }

    endI = s.size() - 1;
    index = s.size() + 1;

    while(index < endI) {

        if(s[index] != s[endI])
            break;

        index++;
        endI--;
        
    }

    if(index < endI) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;

}

Measured memory_bytes: 256
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	q := getNextInt(scanner)
	m := map[string]int{}
	for i := 0; i < q; i++ {
		t := getNextInt(scanner)
		k := getNextString(scanner)
		switch t {
		case 0:
			m[k] = getNextInt(scanner)
		case 1:
			fmt.Fprintln(writer, m[k])
		}
	}
}



Measured memory_bytes: 20224
// D - Moving Piece
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int N, K; cin>>N>>K;
	vi P(N); rep(i, N) cin>>P[i], P[i]--;
	vi C(N); rep(i, N) cin>>C[i];

	ll INF = 1e18;
	ll score = -INF;
	rep(st, N){
		ll lap_sc = 0;
		int lap_cn = 0;
		int nx = st;
		while(true){
			lap_cn++;
			lap_sc += C[nx];
			nx = P[nx];
			if(nx == st) break;
		}
		lap_sc = max(0LL, lap_sc);

		ll sum_sc = 0;
		int k_cn = 0;
		while(true){
			k_cn++;
			if(K < k_cn) break;
			sum_sc += C[nx];
			score = max(score, sum_sc + lap_sc * ((K - k_cn) / lap_cn));
			nx = P[nx];
			if(nx == st) break;
		}
	}
	cout<< score <<endl;
}


Measured memory_bytes: 3688
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MAX = 3000000;
const ll MOD = 1000000007;
ll n, m, k;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main() {
    cin >> n >> m >> k;
    UnionFind team(n);
    ll hands[n];
    ll members[n];
    for(ll i=0; i<n; i++){
        members[i] = 0;
        hands[i] = 0;
    }
    for(ll i=0; i<m; i++){
        ll a;
        ll b;
        cin >> a >> b;
        hands[a-1]++;
        hands[b-1]++;
        team.unite(a-1,b-1);
    }
    for(ll i=0; i<k; i++){
        ll c;
        ll d;
        cin >> c >> d;
        if(team.same(c-1,d-1)){
            hands[c-1]++;
            hands[d-1]++;
        }
    }
    for(ll i=0; i<n; i++){
        members[team.root(i)]++;
    }
    for(ll i=0; i<n; i++){
        cout << members[team.root(i)] - hands[i] - 1 << " " ;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3200
N = int(input())
H = list(map(int,input().split()))

ans = 0
tmp = 0
for i in range(1,N):
    if  H[i-1] >= H[i]:
        tmp += 1
    else:
        if tmp > ans:
            ans = tmp
        tmp = 0
if tmp > ans:
    ans = tmp
    
print(ans)

Measured memory_bytes: 63856
#include<stdio.h>

int main(void) {
	int n, i;
	int a;
	double sum = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a);
		sum += 1.0 / (double)a;
	}
	printf("%lf", (1.0 / sum));
	return 0;
}

Measured memory_bytes: 128
n,m=(map(int,input().split()))

l=[]
for a in [int(i) for i in input().split()]:
  l.append(a)

ans_list=[1]*n  
  
for _ in range(m):
  a,b=(map(int,input().split()))
  if l[a-1]<l[b-1]:
    ans_list[a-1]=0
  elif l[a-1]==l[b-1]:
    ans_list[a-1]=0
    ans_list[b-1]=0
  else:
    ans_list[b-1]=0
  
#print(ans_list)
print(sum(ans_list))

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=0;i<=(n);i++)

int main(){
	int N, i, ans=0;

	cin>>N>>i;

	ans = N-i+1;

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int A,B,C;
  cin >> A >> B >> C;
  if(A*B*C == 175){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
    
 
}

Measured memory_bytes: 256
H,W=map(int,input().split())
S=([chr(ord('a') + i) for i in range(26)])
L=[]
for i in range(H):
	L.append(input().split())
for i in range(H):
	for j in range(W):
		if L[i][j]=="snuke":
			print(str.upper(S[j]),end="")
			print(i+1)

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

int main() {
	int n,k;
	cin>>n>>k;
	vector<int> res(n,0);
	for(int i=0;i<n;i++)
	cin>>res[i];
	long long int sum=0;
	sort(res.begin(),res.end());
	for(int i=0;i<k && i<n;i++)
	{
	    sum+=res[i];
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3628
package main

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

const (
	BUFSIZE   = 10000000
	MOD       = 1000000007
	INF_INT   = math.MaxInt32
	INF_INT64 = math.MaxInt64
)

var rdr = bufio.NewReaderSize(os.Stdin, BUFSIZE)

func main() {
	solve()
}

func solve() {
	var S, T string
	fmt.Scanf("%s %s", &S, &T)
	fmt.Println(T + S)
}

func ReadLineInt64() []int64 {
	buf := make([]byte, 0, BUFSIZE)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			fmt.Println(e.Error())
			panic(e)
		}

		buf = append(buf, l...)

		if !p {
			break
		}
	}
	str := strings.Split(string(buf), " ")
	l := len(str)

	ret := make([]int64, l)

	for i, s := range str {
		ret[i] = s2i64(s)
	}
	return ret
}

func ReadLineInt() []int {
	values := ReadLineInt64()
	ret := make([]int, len(values))
	for i, v := range values {
		ret[i] = int(v)
	}
	return ret
}

func ReadInt() int {
	v := ReadLineInt()
	return v[0]
}
func ReadInt2() (int, int) {
	v := ReadLineInt()
	return v[0], v[1]
}
func ReadInt3() (int, int, int) {
	v := ReadLineInt()
	return v[0], v[1], v[2]
}
func ReadInt4() (int, int, int, int) {
	v := ReadLineInt()
	return v[0], v[1], v[2], v[3]
}

func ReadInt64() int64 {
	v := ReadLineInt64()
	return v[0]
}
func ReadInt64_2() (int64, int64) {
	v := ReadLineInt64()
	return v[0], v[1]
}
func ReadInt64_3() (int64, int64, int64) {
	v := ReadLineInt64()
	return v[0], v[1], v[2]
}
func ReadInt64_4() (int64, int64, int64, int64) {
	v := ReadLineInt64()
	return v[0], v[1], v[2], v[3]
}

func s2i64(s string) int64 {
	v, ok := strconv.ParseInt(s, 10, 64)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int64")
	}
	return v
}

// For int64
func Bool2Int64(b bool) int64 {
	if b {
		return 1
	} else {
		return 0
	}
}

func Abs64(v int64) int64 {
	if v < 0 {
		return -v
	}
	return v
}

func Min64(a, b int64) int64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func Max64(a, b int64) int64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func Distance64(a, b int64) int64 {
	return Abs64(a - b)
}

// For int
func Bool2Int(b bool) int {
	if b {
		return 1
	} else {
		return 0
	}
}

func Abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

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

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

func Distance(a, b int) int {
	return Abs(a - b)
}


Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int dfs(int p, vvi &edges) {
    int nc = edges[p].size();
    vi ch(nc);
    for (int i = 0; i < nc; ++i) {
        ch[i] = dfs(edges[p][i], edges);
    }
    sort(ch.begin(), ch.end(), greater<int>());
    int ret = 0;
    for (int i = 0; i < nc; ++i) {
        chmax(ret, ch[i] + i + 1);
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    vvi edges(n);
    for (int i = 0; i < n - 1; ++i) {
        int a;
        cin >> a;
        a--;
        edges[a].push_back(i + 1);
    }
    cout << dfs(0, edges) << "\n";
    return 0;
}

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

void solve () {
    int k;
    cin >> k;
    long long ans = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            int x = __gcd(i, j);
            for (int l = 1; l <= k; l++) {
                ans += __gcd(x, l);
            }
        }
    }
    cout << ans;

}

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


Measured memory_bytes: 3616
def resolve():
    N = int(input())
    S = input()
    rem = 0
    for i in range(N):
        for j in range(i, N):
            k = 2*j - i
            if k < N and S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                rem += 1
    print(S.count("R")*S.count("G")*S.count("B") - rem)


if '__main__' == __name__:
    resolve()


Measured memory_bytes: 73016
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int n,i,j,k;
    scanf("%d",&n);
    k=n/4;
    for(i=0;i<=k;i++)
    {
        j=n-i*4;
        if(j%7==0)
        {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


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

int main()
{
    int n;
    string s, t, ans;
    cin >> n >> s >> t;
    for (int i = 0; i < n; i++)
    {
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(n**0.5) + 1):
        if n % k == 0:
            return False

    return True

like = []
for i in range(1,100000,2):
    if is_prime(i) and is_prime((i+1)//2):
        like.append(i)
like_set  = set(like)
q = int(input())
import bisect
for _ in range(q):
    l,r = map(int,input().split())
    a = bisect.bisect_left(like,l)
    b = bisect.bisect_right(like,r)
    print(b-a)




Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;


int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int l, k; cin >> l >> k;
	ll dp[110][2] = {}, ans = 0;
	dp[0][0] = 1;
	rep(i, l) rep(j, 2) if(dp[i][j]){
		dp[i + 1][j ^ 1] += dp[i][j];
		if(!j) dp[i + k][j ^ 1] += dp[i][j];
	}
	rep(i, l) ans += dp[i+1][1];
	//rep(i, l) dbg(i+1, dp[i+1][1]);
	cout << ans << endl;
	return 0;
}

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

int main() {
  string s,ans="AC";
  bool c=false;
  cin >> s;
  if(s[0]!='A') ans="WA";
  for(long i=1;i<s.size();i++) {
    if(s[i]=='C') {
      if((i==1||i==s.size()-1)||c) ans="WA";
      c=true;
    } else if(s[i]<'a') {
      ans="WA";
    }
  }
  if(!c) ans="WA";
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  int n, k;
  cin >> n >> k;
  if(k == 0){
    cout << (ll)n * n << endl;
    return 0;
  }
  ll res = 0;
  for(int b = k + 1; b <= n; b++){
    res += (n / b) * (b - k) + max(n % b - k + 1, 0);
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int x,y,z;

    scanf("%d %d",&x, &y);

    if(y > x){

    z = x;
    x = y;
    y = z;

    }

    if(x > y){

    z = x % y;

    do{

        x = y;
        y = z;
        z = x % y;

    }while(z != 0);

    printf("%d\n",y);

    }

    else{

    printf("%d\n",y);

    }
    return 0;
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
#include <map>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int>a(n);
    vector<int>cnt(n,0);
    for(int i=1;i<n;i++)cin >> a[i];
    
    for(int i=1;i<n;){
        cnt[a[i]-1]++;
        i++;
    }
    
    for(int i=0;i<n;i++) cout << cnt[i] << endl;
    
    return 0;
}


Measured memory_bytes: 4848
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main(void){
 int n,m;
 cin>>n;
 map<string,int>r;
 for(int i=0;i<n;i++){
    string s;
    cin>>s;
    r[s]++;
 }
 cin>>m;
 int ans=0;
 for(int i=0;i<m;i++){
     string s;
     cin>>s;
     r[s]--;
 }
 for (auto i=r.begin();i!=r.end();i++){
     if(i->second>ans){
         ans=i->second;
     }
 }
 cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const int INF = INT_MAX;
const ll inf = 1e18;
const ll mod = 998244353;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x, ll y){ if(x>y) swap(x, y);while(x!=0){ y%=x; swap(x, y); }return y; }
ll mpow(ll x, ll r){if(r==0) return 1;if(r%2==1){ return x*mpow(x, r-1)%mod; }else{ ll aa = mpow(x, r/2); return aa*aa%mod; }}

const int MAX = 300002;

// fac[]・・・a! finv[]・・・(a!)^(-1) inv[]・・・a^(-1)

long long fac[MAX], finv[MAX], inv[MAX];

void pre_comb(void){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<MAX; i++){
		fac[i] = fac[i-1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod/i) % mod;
		finv[i] = finv[i-1] * inv[i] % mod;
	}
}

long long comb(int n, int k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}


int main(){
	pre_comb();
	ll N, M, K; cin >> N >> M >> K;
	ll ans = 0;
	rep(i, K+1){
		ans = (ans + (comb(N-1, i)*M%mod)*mpow(M-1, N-i-1))%mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int a,b;
  cin >> a >> b;
  cout << a * b << endl;
}

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

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

	unordered_map<string, bool> map;
	for (int i = 0; i < N; ++i)
	{
		string S;
		cin >> S;

		if (map.find(S) == map.end())
		{
			map[S] = true;
		}
	}

	cout << map.size() << endl;

	return 0;
}

Measured memory_bytes: 17676
import java.util.*;



class Main{
  public static void main(String[] args){
    
    
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    if (str.equals("ABC")) {
    	System.out.println("ARC");
    }else {
    	System.out.println("ABC");
    }
    
  }
}

Measured memory_bytes: 35696
#include <stdio.h>
int bin(int *s, int l, int v, int r) {
	int f = 0, t = l, m;
	while(t - f) {
		m = (f + t) / 2;
		if(s[m] == v)
			return m;
		else if(s[m] > v)
			t = m;
		else
			f = m + 1;
	}
	return f - r;
}
int main() {
	char s[100001];
	int m[50000], ml = 0, p = -1, q, l, r;
	scanf("%*d %d %s", &q, s);
	while(s[++p])
		if(s[p] == 'A' && s[p + 1] == 'C') {
			m[ml++] = p + 1;
			p++;
		}
	while(q--) {
		scanf("%d %d", &l, &r);
		l = bin(m, ml, l, 0);
		r = bin(m, ml, r - 1, 1);
		printf("%d\n", r - l + 1);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct { template <typename T> operator T() { T x; cin >> x; return x; } } IN;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int X=IN,Y=IN;
    cout<<(abs(X-Y)<=1?"Brown":"Alice")<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }

vector<vector<int>> adj;
vector<ll> rnk, par;

int dfs(int n=0, int p=-1) {
  int result = 1;
  par[n] = p;
  for (auto x: adj[n]) {
    if (x==p) continue;
    result += dfs(x,n);
  }
  return rnk[n] = result;
}

int main() {
  int N; cin >> N;
  adj.resize(N); rnk.resize(N); par.resize(N);
  rep(i,N-1) {
    int A, B; cin >> A >> B; A--; B--;
    adj[A].push_back(B);
    adj[B].push_back(A);
  }
  dfs();

  int nm = 2*pow(10,5)+10;
  ll p2[nm] = {}; rep(i,nm) p2[i] = i ? (p2[i-1]*2)%MOD : 1;

  ll result = 0;
  rep(i,N) {
    ll r_tmp = p2[N-1]-1;
    for (auto x: adj[i]) {
      if (x==par[i]) r_tmp -= p2[N-rnk[i]]-1;
      else r_tmp -= p2[rnk[x]]-1;
      r_tmp = (r_tmp%MOD+MOD)%MOD;
    }
    // cout << i << ": " << r_tmp << endl;
    result += r_tmp; result %= MOD;
  }
  result *= inv(p2[N]); result %= MOD;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 23168
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String o = sc.next();
		String e = sc.next();
		
		// 計算
		String result = "";
		StringBuilder sb = new StringBuilder();
		int n = o.length() + e.length();
		for(int i = 0; i < n; i++){
		    int index = i/2;
		    if(i%2 == 0) sb.append(o.charAt(index));
		    if(i%2 != 0) sb.append(e.charAt(index));
		}
		result = sb.toString();
		
		// 出力
		System.out.println(result);
	}
}



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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

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

    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    sort(all(a));
    cout << a[0] + a[1] << endl;
    return 0;
}

Measured memory_bytes: 256
#if defined(__GNUC__)
#include <bits/stdc++.h>
#define __int32 __int32_t
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) std::sort(ALL(x))
#define RSORT(x, T) std::sort(ALL(x), greater<T>())
#define REVERCE(x) std::reverce(ALL(x))
#define ACM(x, y) std::accumulate(ALL(x), y)

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)

itn main() {
	std::ios::sync_with_stdio(false);

	int n;

	cin >> n;

	vector<pair<pair<string, int>, int>> a(n);

	REP(i, n) {
		cin >> a[i].first.first >> a[i].first.second;
		a[i].first.second *= -1;
		a[i].second = i + 1;
	}

	SORT(a);

	REP(i, n) {
		cout << a[i].second << '\n';
	}

	return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] A = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int N = A[0];
            int K = A[1];
            int cnt = 0;
            while (true)
            {
                if (N != 0)
                {
                    N /= K;
                    cnt++;
                }
                else
                {
                    break;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int MAX = 300000+1;
vector<int> sosuu(MAX,1);
vector<int> sosuu_list;
int check(int num){
  if(num%7 == 1 || num%7 == 6)return 1;
  return 0;
}
void make_sosuu(){
  sosuu[1] = 0;
  sosuu[0] = 0;
  for(int i = 2;i <= MAX;i++){
    if(check(i) && sosuu[i]){
      sosuu_list.push_back(i);
      for(int j = i*2;j <= MAX;j+=i){
	sosuu[j] = 0;
      }
    }
  }
    
}
int main(){
  int a;
  make_sosuu();
  /*  for(int i =0 ;i < sosuu_list.size();i++){
    cout << sosuu_list[i] << " ";
  }
  cout << endl;*/
  while(cin >> a,a != 1){
    cout << a << ":"; 

    for(int i =0;i < sosuu_list.size();i++){
      if(a % sosuu_list[i] == 0){
	cout << " " << sosuu_list[i];
      }
    }
    
    cout  << endl;
  }

  return 0;
}

Measured memory_bytes: 2592
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let S = get!(String);
    let w = get!(usize);

    let T = S.chars().collect::<Vec<_>>();
    let ans = (0..((T.len() - 1) / w + 1)).map(|i| T[i * w])
        .collect::<String>();

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


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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = reader.readLine();
		String[] str = line.split(" ");
		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		if (a >=13) {
			System.out.println(b);
		}
		else if (a >= 6 && a<= 12) {
			System.out.println(b / 2);
		}
		else {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 21332
#include<stdio.h>


int is_prime( int n )
{
	if( n < 4 )
	{
		return 1 ;
	}

	if( n % 2 == 0 || n % 3 == 0 )
	{
		return 0 ;
	}

	int i ;
	for( i = 5 ; i < n ; i += 2 )
	{
		if( n % i == 0 )
		{
			return 0 ;
		}
	}

	return 1 ;
}

int main()
{
	int n ;

	while( 1 )
	{
		scanf( "%d" ,&n ) ;

		if( n == 0 )
		{
			return 0 ;
		}
		else if( n < 4 )
		{
			continue ;
		}

		while( n > 4 )
		{
			while( is_prime( n ) == 0 )
			{
				n-- ;
			}

			if( is_prime( n - 2 ) == 1 )
			{
				printf( "%d %d\n" ,n - 2 ,n ) ;

				break ;
			}
			else
			{
				n -= 2 ;
			}
		}

	}
}

Measured memory_bytes: 600
#include <stdio.h>
#include <string.h>
int main(void){
	int i,n;
	int hanako=0,tarou=0;
	int result;
	char str1[1000];
	char str2[1000];

	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%s %s",str1,str2);
		result = strcmp(str1,str2);
		
		if(result > 0){
			tarou += 3;
		} else if(result < 0)
			hanako += 3;
		else{
			tarou++;
			hanako++;
		}
	}
	printf("%d %d\n",tarou, hanako);

	return 0;
}

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

int main(){
  int N,X;
  cin>>N;
  X=0;
  for(int i=1; i<=N; i++){
    int S=i*1.08;
    if(S==N){
      X=i;
      break;}
  }
  if(X==0){cout<<":("<<endl;}
  else{cout<<X<<endl;}
}

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

#define pb push_back
#define ff first
#define ss second

const int MAXN = 1e5 + 21;

int n, k, ans;
int a[MAXN];
vector <int> adj[MAXN];
int g[MAXN];
bool mark[MAXN], b[MAXN];

void dfs(int v) {
	mark[v] = true;
	g[v] = 1;
	for (auto u : adj[v]) {
		if (!mark[u]) {
			dfs(u);
			g[v] = max(g[v], g[u] + 1);
		}
	}
	if (g[v] == k && !b[v]) {
		ans++;
		g[v] = 0;
	}
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> k;
	b[1] = true;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		adj[a[i]].pb(i);
		if (a[i] == 1)
			b[i] = true;
	}

	dfs(1);
	
    if (a[1] ^ 1)
		ans++;
	
    cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 11264