akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int p(int a, int b, int c, int d) {
  return a * 10 + b * 50 + c * 100 + d * 500;
}

int main(void) {
  int price;
  bool flag = false;

  while (cin >> price, price) {
    if (flag) cout << endl;

    vector<int> c(4);
    for (int i = 0; i < 4; i++) {
      cin >> c[i];
    }

    int minc = (int)1e9, coin[] = {500, 100, 50, 10, 1};
    vector<int> v;
    for (int i = 0; i <= c[0]; i++) {
      for (int j = 0; j <= c[1]; j++) {
        for (int k = 0; k <= c[2]; k++) {
          for (int l = 0; l <= c[3]; l++) {
            int diff = p(i, j, k, l) - price, ci = 0, cnt = 0;
            if (diff < 0) continue;

            while (diff && ci < 5) {
              cnt += diff / coin[ci];
              diff %= coin[ci++];
            }
            cnt += c[0] + c[1] + c[2] + c[3] - i - j - k - l;
            if (cnt < minc) {
              v.clear();
              v.push_back(i);
              v.push_back(j);
              v.push_back(k);
              v.push_back(l);
              minc = cnt;
            }
          }
        }
      }
    }

    for (int i = 1; i < 5; i++) {
      if (!v[i - 1]) continue;
      cout << coin[4 - i] << " " << v[i - 1] << endl;
    }
    flag = true;
  }

  return 0;
}


Measured memory_bytes: 3048
def addbit(i):
    i += 1
    while i <= N:
        BIT[i] += 1
        i += i & (-i)
def getsum(i):
    ret = 0
    i += 1
    while i != 0:
        ret += BIT[i]
        i -= i&(-i)
    return ret
def bit(L):
    global BIT
    BIT=[0] * (N+1)
    re = 0
    for l in L:
        re += getsum(l)
        addbit(l)
    return N*(N-1)//2 - re
def calc(Z):
    Z.sort()
    l, r, lc, rc = -1<<28, 1<<28, N*(N-1)//4+1, N*(N-1)//4+1
    while (r - l) / max(abs(l), 1) > 0.000000001:
        m = (l * rc + r * lc) / (lc + rc)
        A = [a&((1<<16)-1) for a in sorted([(int((s*m+t)*2**40)<<16)+i for i, (s, t) in enumerate(Z)])]
        c = bit(A)
        if c > N*(N-1)//4:
            l = m
            lc = (c - N*(N-1)//4) * 2
        else:
            r = m
            rc = (N*(N-1)//4 - c) * 2 + 1
    return l

N = int(input())
X, Y = [], []
for _ in range(N):
    a, b, c = map(int, input().split())
    X.append((-a/b, c/b))
    Y.append((-b/a, c/a))
print(calc(X), calc(Y))

Measured memory_bytes: 133508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int s=S.size();
    rep(i,s){
        if (!(i&1)&&S[i]=='L'){
            cout << "No" << endl;
            return 0;
        }
        if ((i&1)&&S[i]=='R'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int n;
vector<vector<int> > to;
ll dp[100010][2];
void dfs(int v,int p=-1){
  for(auto nv:to[v]){
    if(nv==p) continue;
    dfs(nv,v);
    dp[v][0]*=dp[nv][0]+dp[nv][1];
    dp[v][1]*=dp[nv][0];
    dp[v][0]%=mod; dp[v][1]%=mod;
  }
  return ;
}

int main(){
  cin >> n;
  to.resize(n);
  rep(i,n)rep(j,2) dp[i][j]=1;
  rep(i,n-1){
    int x,y;
    cin >> x >> y;
    x--; y--;
    to[x].push_back(y);
    to[y].push_back(x);
  }
  dfs(0);
  cout << (dp[0][1]+dp[0][0])%mod << endl;
}

Measured memory_bytes: 74368
# coding=UTF-8
from collections import deque
from collections import Counter
from operator import itemgetter
from bisect import bisect_left, bisect
from decimal import *
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)


def main():
    n = int(input())
    arr = []
    for i in range(n):
        arr.append(list(map(int, input().split())))
    arr_sorted = sorted(arr, key=lambda x: x[1])

    now = 0

    for i in range(n):
        if now + arr_sorted[i][0] > arr_sorted[i][1]:
            print("No")
            return
        else:
            now += arr_sorted[i][0]
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 66148
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

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

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

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

    long long res = 0, l = 0, r = 0;
    for (int i = 1, j = n - 1; i <= j; ) {
        long long li = abs(a[l] - a[i]);
        long long lj = abs(a[l] - a[j]);
        long long ri = abs(a[r] - a[i]);
        long long rj = abs(a[r] - a[j]);
        long long m = max({ li, lj, ri, rj });

        if (li == m) {
            l = i;
            i++;
        } else if (lj == m) {
            l = j;
            j--;
        } else if (ri == m) {
            r = i;
            i++;
        } else {
            r = j;
            j--;
        }

        res += m;
    }

    cout << res << endl;
}


Measured memory_bytes: 4032
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String[] ss = s.split("");
		int count = 0;
		for(int i=1; i<ss.length; i++) {
			if(ss[i].equals(ss[i-1])) {
				count++;
				if(ss[i].equals("0"))
					ss[i] = "1";
				else
					ss[i]  = "0";

			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 34736
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a, cc = b; i <= cc; ++i)
#define PER(i, a, b) for (int i = a, cc = b; i >= cc; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
 
typedef unsigned long long LL;
typedef vector<int> VI;
typedef pair<int, int> pii;
 
inline int read(){
    int x = 0, ch = getchar(), f = 1;
    while (!isdigit(ch)){if (ch == '-') f = -1; ch = getchar();}
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    return x * f;
}

int n, m, tot, sum[200005], ans[100005], tp, stk[100005];

struct Event{
	int x, p, id, r;
} E[5000005];

bool cmp(Event a, Event b){
	if (a.x != b.x) return a.x < b.x;
	return a.p < b.p;
}

void modify(int x){
	for (; x <= m; x += x & -x) sum[x]++;
}

int query(int x){
	x = min(x, m);
	int res = 0;
	for (; x; x -= x & -x) res += sum[x];
	return res;
}

int main(){
	n = read(), m = read();
	REP(i, 1, n){
		int l = read(), r = read();
		E[++tot] = (Event){l, 0, 0, r};
	}
	for (int d = 1; d <= m; ++d){
		tp = 0;
		for (int i = 0; i * d <= m; ++i)
			stk[++tp] = i * d;
		if (stk[tp] != m) stk[++tp] = m + 1;
		REP(i, 2, tp) {
			int l = stk[i - 1], r = stk[i] - 1;
			if (l + 1 > r) continue;
			E[++tot] = (Event){l, 1, d, r};
			E[++tot] = (Event){r, 2, d, r};
		}
	}
	sort(E + 1, E + tot + 1, cmp);
	//REP(i, 1, tot) debug("E[%d] = (%d, %d, %d)\n", i, E[i].x, E[i].p, E[i].id);
	REP(i, 1, tot){
		if (E[i].p == 0) modify(E[i].r);
		if (E[i].p == 1) ans[E[i].id] -= query(E[i].r);
		if (E[i].p == 2) ans[E[i].id] += query(E[i].r);
		//debug("%d: ", i);
		//REP(j, 1, m) debug("%d ", ans[j]);
		//debug("\n");
	}
	//printf("%d\n", n);
	REP(i, 1, m) printf("%d\n", n - ans[i]);
	return 0;
}

Measured memory_bytes: 43264
def main():
    input()
    array = sorted(int(x) for x in input().split())
    maximum = array[-1] + 1
    counter = [0] * maximum

    for x in array:
        if counter[x] != 0:
            counter[x] = 2
            continue
        else:
            for multiple in range(x, maximum, x):
                counter[multiple] += 1
    ans = sum(counter[x] == 1 for x in array)
    print(ans)


main()


Measured memory_bytes: 32248
#include <stdio.h>

int c[200000];
int table[200000] = {0};

int main(void){
  int N, M;
  scanf("%d %d", &N, &M);

  int a, b;
  int i, count=0;

  for(i=0;i<M;i++){
    scanf("%d %d", &a, &b);
    if(b == N)
      table[a] = 1;
    if(a == 1){
      c[count] = b;
      count++;
    }
  }

  int possible=0;
  for(i=0;i<count;i++){
    if(table[c[i]] == 1){
      possible = 1;
      break;
    }
  }

  if(possible == 1)
    printf("POSSIBLE\n");
  else
    printf("IMPOSSIBLE\n");

  return 0;
}


Measured memory_bytes: 1280
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class CRemainderMinimization2019 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long l = in.nextLong();
            long r = in.nextLong();
            long ans = Integer.MAX_VALUE;
            long s = l % 2019;
            long t = r % 2019;
            if (t <= s) {
                out.println(0);
                return;
            }
            if ((r - l) / 2019 >= 1) {
                out.println(0);
                return;
            }
            for (long i = s; i <= t; i++) {
                for (long j = i + 1; j <= t; j++) {
                    ans = Math.min(ans, (i * j) % 2019);
                }
            }
            out.println(ans);


        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 23380
D=int(input())
c=list(map(int,input().split()))
s = [list(map(int,input().split())) for l in range(D)]
#print(s)

last=[0 for i in range(26)]

for i in range(D):#i日目
  best=0
  sat=0
  for j in range(26):#jを開催
    tempsat=0
    tempsat+=s[i][j]
    templast=last[j]
    last[j]=i
    for k in range(26):
      tempsat-=c[k]*(i-last[k])
    if(sat<=tempsat):
      sat=tempsat
      best=j
    last[j]=templast
  print(best+1)

Measured memory_bytes: 9392
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <numeric>

//#include <map>

using namespace std;

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

	vector<int> vb;
	vector<vector<int>> vva;

	for (int i = 0; i < n; i++)
	{
		vector<int> vt;

		for (int j = 0; j < m; j++)
		{
			int a;
			cin >> a;
			vt.push_back(a);
		}
		vva.push_back(vt);
	}

	for (int i = 0; i < m; i++)
	{
		int b;
		cin >> b;
		vb.push_back(b);
	}

	vector<int> vans;

	for (int i = 0; i < n; i++)
	{
		int ans = 0;
		for (int j = 0; j < m; j++)
		{
			ans += vva.at(i).at(j) * vb.at(j);
		}
		vans.push_back(ans);
	}

	for (int i = 0; i < vans.size(); i++)
	{
		cout << vans.at(i) << endl;
	}

	return 0;
}

Measured memory_bytes: 3224
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        a: [usize; n + 1],
        b: [usize; n],
    }
    let mut x = a.iter().map(|&ai| ai).collect::<Vec<_>>();
    let mut left_count = 0;
    for i in 0..n {
        if b[i] >= x[i] {
            let r = b[i] - x[i];
            left_count += x[i];
            x[i] = 0;
            x[i + 1] = if r >= x[i + 1] {
                left_count += x[i + 1];
                0
            } else {
                left_count += r;
                x[i + 1] - r
            }
        } else {
            left_count += b[i];
            x[i] -= b[i];
        }
    }
    let mut y = a.iter().map(|&ai| ai).collect::<Vec<_>>();
    let mut right_count = 0;
    for i in (1..n + 1).rev() {
        if b[i - 1] >= y[i] {
            let r = b[i - 1] - y[i];
            right_count += y[i];
            y[i] = 0;
            y[i - 1] = if r >= y[i - 1] {
                right_count += y[i - 1];
                0
            } else {
                right_count += r;
                y[i - 1] - r
            }
        } else {
            right_count += b[i - 1];
            y[i] -= b[i - 1];
        }
    }
    if left_count > right_count {
        println!("{}", left_count);
    } else {
        println!("{}", right_count);
    }
}


Measured memory_bytes: 8444
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,m,n;
    cin>>a>>b;
    n = min(a,b);
    m = max(a,b);
    char ch = 48+n;
    string s;
    for(int i =1;i<=m;++i)
        s+=ch;
    
    cout<<s<<endl;
    s.clear();
    //printf("%c",48);
    //system("pause"); 
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <utility>

using namespace std;

const int MAX_N=100000,MAX_R=1000000;

typedef pair<int,int> P;

int N,R,L;
int d[MAX_R],t[MAX_R+1],x[MAX_R];

int scean[MAX_N];	//?????£?????????
int point[MAX_N];	//??????

int main(){
	scanf("%d %d %d",&N,&R,&L);
	for (int i=0;i<R;i++){
		scanf("%d %d %d",&d[i],&t[i],&x[i]);
		d[i]--;
	}
	t[R]=L;	//??????
	scean[0]=t[0];
	priority_queue<P> pq;
	for (int i=0;i<N;i++){
		pq.push(make_pair(0,-i));	//first=??????,second=-???????????????
	}
	for (int i=0;i<R;i++){
		point[d[i]]+=x[i];
		pq.push(make_pair(point[d[i]],-d[i]));
		while(point[-pq.top().second]!=pq.top().first){
			pq.pop();
		}
		scean[-pq.top().second]+=t[i+1]-t[i];
	}
	int res=0;	//?????????????????£????????????
	for (int i=1;i<N;i++){
		if (scean[res]<scean[i]) res=i;
	}
	printf("%d\n",res+1);
	return 0;
}

Measured memory_bytes: 22640
use proconio::input;
use proconio::fastout;

// abc177 / A - Don't be late
// https://atcoder.jp/contests/abc177/tasks/abc177_a

#[fastout]
fn main() {
    input! {
        d: usize,
        t: usize,
        s: usize,
    }

    println!("{}", if ((t * s) >= d) { "Yes" } else { "No" });
}


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

int main() {
  int n,m,x;
  cin >> n >> m;
  vector<int> v(n);
  for (int i=0;i<2*m;i++) {
    cin >> x;
    v.at(x-1) +=1;
  }
  for (int i=0;i<n;i++) {
    cout << v.at(i) << endl;
  }
}

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

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

    long long sum = 0;
    for (int i = 1; i < n; i++){
        if (v[i] < v[i-1]){
            sum += abs(v[i] - v[i-1]);
            v[i] = v[i-1];
        }
    }
    
    cout << sum << "\n";
}


Measured memory_bytes: 4036
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define regsiter register
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
int p0[111],p1[111],pp0,pp1;
int main()
{
	int n=io::F(),q=io::F();
	while(q--)
	{
		int u=io::F(),v=io::F();
		if(n==1){printf("%d\n",dmin(u,v));continue;}
		pp0=pp1=0;
		for(register int i=u;i;i=(i+n-2)/n)p0[++pp0]=i;
		for(register int i=v;i;i=(i+n-2)/n)p1[++pp1]=i;
		register int x,y;
		for(x=pp0,y=pp1;x&&y&&p0[x]==p1[y];--x,--y);
		printf("%d\n",p0[x+1]);
	}
	return 0;
}




Measured memory_bytes: 1152
#!/usr/bin/env python3

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

fst = 0
lst = N
ans = 0
mod = 10**9+7

for i in range(1,K):
    fst += i
    lst += N-i
# print(i,fst,lst,ans)

for i in range(K,N+2):
    ans += lst-fst+1
    ans %= mod
    fst += i
    lst += N-i
    # print(i,fst,lst,ans)
print(ans)







Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+100;


int n,m;

int vis[N];

void A()
{
    for(int i=2;i<=1e5;i++){
        for(int j=2;j*j<=i;j++){
            if(i%j==0 ) {
                vis[i]=1;
                break;
            }
        }
    }
}

int sum[N];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    A();
    vis[1]=1;

    for(int i=1e5;i>=1;i--){
         if(vis[i]==0 && vis[(i+1)/2]==1) vis[i]=1;
    }
    vis[2]=1;
    for(int i=1;i<=1e5;i++){
          sum[i]=sum[i-1];
          if(vis[i]==0) sum[i]++;
      //   cout<<sum[i]<<" ";
    }
  // cout<<endl;
    int q;cin>>q;
    while(q--){
        int l,r;
        cin>>l>>r;
        cout<<sum[r]-sum[l-1]<<endl;
    }

    return 0;
}


Measured memory_bytes: 4396
#include   <stdio.h>

int   main(void)

{

   int W,H,x,y,r;

   scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

   if(x>=W||y<=0){

      printf("No\n");

   }

   else if(y>=H||y<=0){

      printf("No\n");

   }

   else if(x+r>W||x-r<0){

      printf("No\n");

   }

   else if(y+r>H||y-r<0){

      printf("No\n");

   }

   else

      printf("Yes\n");

   return 0;

}

Measured memory_bytes: 584
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
class UnionFind():
    def __init__(self, n):
        self.n=n
        self.parents=[-1]*n # 親(uf.find()で経路圧縮して根)の番号。根の場合は-(そのグループの要素数)
    def find(self,x):
        #グループの根を返す
        if self.parents[x]<0:return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    #def members(self, x):
    #    root = self.find(x)
    #    return [i for i in range(self.n) if self.find(i) == root]
    def unite(self,x,y):
        #要素x,yのグループを併合
        x,y=self.find(x),self.find(y)
        if x==y:return
        if self.parents[x]>self.parents[y]:#要素数の大きい方をxに
            x,y=y,x
        self.parents[x]+=self.parents[y]
        self.parents[y]=x #要素数が大きい方に併合
    def roots(self):
        #全ての根の要素のリスト
        return [i for i, x in enumerate(self.parents) if x<0]
    def group_count(self):
        #グループの数
        return len(self.roots())
    def members(self, x):
        root = self.find(x)
        return len([i for i in range(self.n) if self.find(i) == root])
    #def __str__(self):
    #   return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=reads()
uf=UnionFind(n)
a,b=[0 for i in range(m)],[0 for i in range(m)]
for i in range(m):
    a,b=reads()
    uf.unite(a-1,b-1)
ls=uf.roots()
dic=defaultdict(int)
max=0
y=0
for i in range(n):
    dic[uf.find(i)]+=1
#print(dic)
for num in dic.values():
    if num>max:
        max=num
print(max)


Measured memory_bytes: 114732
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vvl G;
vl dp;  // dp[v] : vを根とするトーナメントの深さの最小値

void dfs(ll v, ll p = -1) {
    // 行きの処理はこのへんに書く
    vl vec;
    for(auto u : G[v]) {
        if(u == p) {
            continue;
        }
        dfs(u, v);
        // 帰りの処理はこのへんに書く
        vec.pb(dp[u]);
    }
    sort(rall(vec));
    ll i = 1;
    ll y = 0;
    for(auto x : vec) {
        chmax(y, x+i);
        i++;
    }
    dp[v] = y;
}

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

    G.resize(n);
    exrep(i, 1, n-1) {
        ll a;
        cin >> a;
        a--;
        G[a].pb(i);
        G[i].pb(a);
    }

    dp.resize(n);
    dfs(0);

    out(dp[0]);
    re0;
}

Measured memory_bytes: 17408
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		while(true){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W ==0)
				break;

			for(int i = 0;i < H;i++){
				for(int j = 1;j < W;j++){
					System.out.print("#");
				}
				System.out.println("#");
			}
		System.out.println();
		}
	}
}

Measured memory_bytes: 36832
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
	double x[21], y[21], a, b, c, z, s;
	char ch;
	int cnt = 1;
	s = 0;
	while (cin>>x[cnt]>>ch>>y[cnt])
	{
		cnt++;
	}

	for (int i = 1; i < cnt-1; i++)
	{
		a = sqrt((x[i] - x[1])*(x[i] - x[1]) + (y[i] - y[1])*(y[i] - y[1]));
		b = sqrt((x[i+1] - x[i])*(x[i+1] - x[i]) + (y[i+1] - y[i])*(y[i+1] - y[i]));
		c = sqrt((x[i+1] - x[1])*(x[i+1] - x[1]) + (y[i+1] - y[1])*(y[i+1] - y[1]));
		z = (a + b + c) / 2;
		s += sqrt(z*(z - a)*(z - b)*(z - c));
	}

	cout << fixed << setprecision(6) << s << endl;

	return 0;
}

Measured memory_bytes: 1284
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

int main(){
  ll N;
  cin >> N;
  string S;
  cin >> S;
  
  if(N>=3200) cout << S << endl;
  else cout << "red" << endl;
  //cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> dp(n + 1, M);
    dp[0] = 0;
    for (int i = 0; i < n + 1; ++i) {
        for (int j = 1; j <= i; j *= 6)
            dp[i] = min(dp[i], dp[i - j] + 1);
        for (int j = 1; j <= i; j *= 9)
            dp[i] = min(dp[i], dp[i - j] + 1);
    }
    cout << dp[n] << "\n";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int N = 5e3+7 , mz = 1e9+7;
char s[N];
set<string> ans;

int main(){
    int k;
    cin>>s>>k;
    int len = strlen(s);
    for(int i = 0 ; i < len ; i++){
        string y = "";
        for(int j = 0 ; j < 5 && i+j < len ; j++){
            y += s[i+j];
            ans.insert(y);
        }
    }
    int cnt = 0;
    string p;
    for(set<string>::iterator it = ans.begin() ; it != ans.end() && ++cnt <= k ; it++){
        p = *it;
    }
    cout<<p<<endl;
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

const ll MOD=1e9+7;

int N,M;

int a[100100];

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

  cin>>N>>M;
  for(int i=0;i<N;i++) cin>>a[i];
  sort(a,a+N);

  vector<pii> v;
  for(int i=0;i<M;i++) {
    int b,c;cin>>b>>c;
    v.pb({c,b});
  }

  sort(v.rbegin(),v.rend());

  int j=0;
  ll res=0;
  for(int i=0;i<N;i++) {
    while(j<M && v[j].snd==0) j++;
    if (j<M && v[j].fst>a[i]) a[i]=v[j].fst,v[j].snd--;
    res += a[i];
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1784
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)



int main() {
	ll n, m, a, ans = 0;
	pair<ll, ll> s;
	in(n);
	in(m);

	priority_queue<ll> pq;


	rep(i, 0, n) {
		in(a);
		pq.push(a);
	}


	rep(i, 0, m) {
		a = pq.top();
		pq.pop();
		pq.push(a / 2);
	}
	while (!pq.empty()) {
		ans += pq.top();
		pq.pop();
	}


	out(ans);

	return 0;

}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 998244353
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll h,w; cin >> h >> w;
    if(h%3==0 || w%3==0) puts("0");
    else{
        ll ans = h*w;
        ll mn = 0;
        ll mid = 0;
        ll mx = h*w;
        rep(i,w){
            mx -= h;
            mn += h/2;
            mid += (h+1)/2;
            ans = min(ans,max({mid-mn,abs(mx-mn),abs(mx-mid)}));
            //cout << ans << endl;
        }
        mn = 0;
        mid = 0;
        mx = h*w;
        rep(i,h){
            mx -= w;
            mn += w/2;
            mid += (w+1)/2;
            ans = min(ans,max({mid-mn,abs(mx-mn),abs(mx-mid)}));
            //cout << ans << endl;
        }
        ans = min({h,w,ans});
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        while(A > 0 && C > 0){
            C -= B;
            if(C <= 0){
                System.out.println("Yes");
                return;
            }
            A -= D;
            if(A<=0){
                System.out.println("No");
                return;
            }
        }
        return;
    }

}


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

#define N_MAX 200002

using namespace std;

int n, a, b;

int colorA[N_MAX], colorB[N_MAX];

int cntA, cntB;

vector <int> edgesA[N_MAX], edgesB[N_MAX];

void dfsA (int node, int color)
{
    colorA[node] = color;
    for(int u : edgesA[node])
        if(colorA[u] == 0)
            dfsA(u, color);
}

void dfsB (int node, int color)
{
    colorB[node] = color;
    for(int u : edgesB[node])
        if(colorB[u] == 0)
            dfsB(u, color);
}

map <pair <int, int>, int> mp;

int main()
{
    cin >> n >> a >> b;
    for(int i = 1; i <= a; i++)
    {
        int u, v;
        cin >> u >> v;
        edgesA[u].push_back(v);
        edgesA[v].push_back(u);
    }
    for(int i = 1; i <= b; i++)
    {
        int u, v;
        cin >> u >> v;
        edgesB[u].push_back(v);
        edgesB[v].push_back(u);
    }
    for(int i = 1; i <= n; i++)
        if(colorA[i] == 0)
            dfsA(i, ++cntA);
    for(int i = 1; i <= n; i++)
        if(colorB[i] == 0)
            dfsB(i, ++cntB);
    for(int i = 1; i <= n; i++)
        mp[make_pair(colorA[i], colorB[i])]++;
    for(int i = 1; i <= n; i++)
        cout << mp[make_pair(colorA[i], colorB[i])] << " ";
    cout << "\n";
    return 0;
}


Measured memory_bytes: 27904
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vl vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N;
  std::cin >> N;
  std::vector<int> d(N);
  for(int i=0;i<N;i++) std::cin >> d[i];
  ll S = 0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      S += d[i] * d[j];
    }
  }
  std::cout << S << '\n';
  return 0;
}


Measured memory_bytes: 888
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let S = read_String_Vec();
    let mut v = vec![0; 26];
    for i in 0..S.len() {
        v[(S[i] as u8) as usize - 97] += 1;
    }
    let mut ind = 30;
    for i in 0..26 {
        if v[i] == 0 {
            ind = i;
            break;
        };
    }
    if ind == 30 {
        println!("None");
    } else {
        println!("{}", (97 + ind as u8) as char);
    }
}


Measured memory_bytes: 4352
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
//#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
//#include <array>
#include <valarray>
#include <stdio.h>
//#include <random>
//#include <windows.h>
//#pragma comment(lib, "winmm.lib")
#include <algorithm>

using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

long long  int nCm(long long int n, long long int m) {
	if (m == 1) {
		return n;
	}
	else {
		return n*nCm(n - 1, m - 1) / m;
	}
}

long long int npm(long long int n, long long int m) {
	if (m == 1) {
		return n;
	}
	else
		if (m == 0) {
			return 1;
		}
		else {
			return n*npm(n, m - 1);
		}
}



llint ketasu(llint a) {//桁数
	llint k = 1;
	while (true) {

		if ((a - a % 10) / 10 == 0) { break; }
		++k;
		a = (a - a % 10) / 10;
	}
	return k;
}


llint keta(llint a) {//最上位
	llint b = a;
	while (true) {

		if ((a - a % 10) / 10 == 0) { break; }
		a = (a - a % 10) / 10;
		b = a;
	}
	return b;
}

llint keta2(llint a, llint c) {//桁数目の桁
	llint b = a;
	for (llint i = 1; i<c; ++i) {

		if ((a - a % 10) / 10 == 0) { break; }
		a = (a - a % 10) / 10;
		b = a;
	}
	return b % 10;
}

llint pow10n(llint a) {//10^n
	llint s = 1;
	for (llint i = 0; i < a; ++i) {
		s *= 10;
	}
	return s;
}


int main()
{
	llint W, H;
	cin >> W >> H;
	vector<llint> Wc(W);
	vector<llint> sumWc(W+9999);
	vector<llint> Hc(H);
	vector<llint> sumHc(H);

	for (llint i = 0; i < W; ++i) {
		cin >> Wc[i];
	}
	sort(Wc.begin(), Wc.end());
	sumWc[0] = Wc[0];
	for (llint i = 1; i < W; ++i) {
	sumWc[i] = Wc[i] + sumWc[i - 1];
	}

	for (llint i = 0; i < H; ++i) {
		cin >> Hc[i];
	}
	sort(Hc.begin(), Hc.end());
	sumHc[0] = Hc[0];
	for (llint i = 1; i < H; ++i) {
		sumHc[i] = Hc[i] + sumHc[i - 1];
	}

	llint cost = sumWc[W - 1]+sumHc[H-1];
	llint now = 0;

	for (llint i = 0; i < H; ++i) {
		while (now < W) {
			if (Wc[now] >= Hc[i]) {
				break;
			}
			else {
				now++;
			}
		}
		if (now == 0) {
			cost += W*Hc[i];
		}
		else {
			cost += sumWc[now - 1] + (W - now)*Hc[i];
		}
	
	}
	cout << cost << endl;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int n,m;
  cin>>n>>m;
  int a[m], b[m];
  int ans[n];
  rep(i,n) {
    ans[i] = 0;
  }
  rep(i,m) {
    cin>>a[i]>>b[i];
    ans[a[i] - 1]++;
    ans[b[i] - 1]++;
  }
  rep(i,n) {
    cout << ans[i] << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
using namespace std;

void trans(vector<char> l, vector<char> r);

set<vector<char>> st;
int main(){
  int n;
  
  cin >> n;

  for(int i=0; i<n; ++i){
    string str;
    vector<char> v;
   

    cin >> str;
    v.assign(str.begin(), str.end());
    //cout << "clear" << endl;
    for(int j=0; j<v.size()-1; ++j){
      vector<char> lhs;
      vector<char> rhs;
      lhs.assign(&v[0], &v[j+1]);
      rhs.assign(&v[j+1], &v[v.size()]);
      // for(auto i:lhs){
      // cout << i;
      //}
      //cout << " is lhs" << endl;
      //for(auto i:rhs){
      // cout << i;
      ///}
      //cout << " is rhs" << endl;
      // cout << "clear" << endl;
      trans(lhs,rhs);
      trans(rhs,lhs);
      //cout << "clear" << endl;
    }
    //cout << "clear" << endl;
    cout << st.size() <<endl;
    //for(auto j:st){
    //for(auto k:j){
    //cout << k;
    //}
    //cout << endl;
    //}
    st.clear();
  }
  return 0;
}

void trans(vector<char> l, vector<char> r){
  vector<char> v;

  v.assign(l.begin(),l.end());
  v.insert(v.end(), r.begin(), r.end());
  st.insert(v);
  
  reverse(l.begin(), l.end());
  
  v.assign(l.begin(),l.end());
  v.insert(v.end(), r.begin(), r.end());
  st.insert(v);
  
  reverse(r.begin(), r.end());

  v.assign(l.begin(),l.end());
  v.insert(v.end(), r.begin(), r.end());
  st.insert(v);
  
  reverse(l.begin(), l.end());
  
  v.assign(l.begin(),l.end());
  v.insert(v.end(), r.begin(), r.end());
  st.insert(v);
  //cout << "loop" << endl;
}

Measured memory_bytes: 3180
N, M = map(int, input().split())

mod = 10 ** 9 + 7

fac = [1]
for i in range(1, N + M + 10) :
  fac.append(fac[-1] * i % mod)
inv = [pow(fac[-1], mod - 2, mod)]
for i in range(N + M + 9, 0, -1) :
  inv.append(inv[-1] * i % mod)
inv = inv[::-1]

def comb(n, r) :
  if n >= r and r >= 0 :
    return fac[n] * inv[n - r] * inv[r] % mod
  return 1
  
ret = 0
for i in range(N + 1) :
  if i % 2 == 1 :
    sign = -1
  else :
    sign = 1
  x = sign * comb(M, i) * comb(N, i) * fac[i] % mod
  x *= (fac[M - i] ** 2) * (inv[M - N] ** 2) % mod
  ret += x % mod
  ret %= mod
print(ret)

Measured memory_bytes: 163892
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


def comb(n, r):
    fact = 1
    for i in range(n - r + 1, n + 1):
        fact = fact * i
    divisor = 1
    for j in range(1, r + 1):
        divisor = divisor * j


    return fact // divisor



n, a, b = LI()
value = sorted(LI(), reverse=True)
m = value[a-1]
ans = 0
print(sum(value[:a]) / a)
left_cnt = value[:a].count(m)
total_cnt = value.count(m)
if left_cnt != a:
    print(comb(total_cnt, left_cnt))
else:
    for k in range(a, min(total_cnt, b) + 1):
        ans += comb(total_cnt, k)
    print(ans)

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

using namespace std;


void solve() {
    int n; cin >> n;
    string s; cin >> s;
    if (s.size() > n) {
        s = string(s.begin(), s.begin()+n) + "...";
    }
    cout << s;
}

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


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

void bubbleSort( int* a, double* b, int n )
{
    for( int i = 0; i < n; i++ )
        for( int j = n - 1; j >= i + 1; j-- )
        {
            if( b[j] < b[j-1] )
            {
                double temp1 = b[j];
                b[j] = b[j-1];
                b[j-1] = temp1;
                
                int temp2 = a[j];
                a[j] = a[j-1];
                a[j-1] = temp2;
            }
        }
}

int main()
{
    int a[8], c[18];
    double b[8], d[18];

    for( int j = 0; j < 3; j++ )
    {
        for( int i = 0; i < 8; i++ )
            cin >> a[i] >> b[i];

        bubbleSort( a, b, 8 );
        cout << fixed << setprecision(2) << a[0] << " " << b[0] << endl;
        cout << fixed << setprecision(2) << a[1] << " " << b[1] << endl;
        for( int i = 2; i < 8; i++ )
        {
            c[i+j*6-2] = a[i];
            d[i+j*6-2] = b[i];
        }
    }

    bubbleSort( c, d, 18 );
    cout << fixed << setprecision(2) << c[0] << " " << d[0] << endl;
    cout << fixed << setprecision(2) << c[1] << " " << d[1] << endl;

    return 0;
}


Measured memory_bytes: 3244
#!/usr/bin/env python3


def main():
    N = int(input())
    x = [None] * N
    y = [None] * N
    h = [None] * N
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
    
    # Cx, Cyを全探索する
    for i in range(101):
        for j in range(101):
            flag = True
            maxH = 10**12
            H = set()
            for k in range(N):
                if h[k] == 0:
                    maxH = min(maxH, abs(x[k]-i) + abs(y[k]-j))
                else:
                    tmpH = h[k] + abs(x[k]-i) + abs(y[k]-j)
                    H.add(tmpH)
                    if len(H) > 1:
                        flag = False
                        break
            if flag and list(H)[0] <= maxH:
                print(i,j,list(H)[0])

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int r = sc.nextInt();
			if(n >= 10) {
				System.out.println(r);
			} else {
				System.out.println(r + (100 * (10 - n)));
			}
		}

	}

}


Measured memory_bytes: 22732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
int main()
{
    ll N;
    ll ans = 0;
    cin >> N;
    for(int i = 1; i <= N; ++i)
        for(int j = 1; j <= N; ++j)
            for(int k = 1; k <= N; ++k)
    {
        ans +=  (__gcd((__gcd(i, j)), k));
    }
    cout << ans << endl;
 }


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

void bfs(vector<int>& cntDist, int s, int X, int Y) 
{
    int N = cntDist.size();
    vector<bool> visited(N, false);
    queue<pair<int,int>> q;
    q.emplace(s, 0);
    while (!q.empty()) {
        auto cur = q.front(); q.pop(); 
        if (!visited[cur.first]) {
            visited[cur.first] = true;
            
            ++cntDist[cur.second];
            if (cur.first > 0)
                q.emplace(cur.first-1, cur.second + 1);
            if (cur.first != N-1)
                q.emplace(cur.first+1, cur.second + 1);
            if (cur.first == X)
                q.emplace(Y, cur.second + 1);
            if (cur.first == Y)
                q.emplace(X, cur.second + 1);
        }
    }
}

int main(int, char**) {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    int N, X, Y;
    cin >> N >> X >> Y;
    
    vector<int> cntDist(N, 0);
    for (int i = 0; i < N; ++i)
        bfs(cntDist, i, X-1, Y-1);
 
    for (int i = 1; i < N; ++i)
        cout << cntDist[i]/2 << endl;              
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    vector<vector<ll>> cnt(N+1,vector<ll>(60,0));
    rep(i,N){
        rep(j,60){
            cnt[i+1][j]=cnt[i][j];
            if (A[i]&(1LL<<j)) ++cnt[i+1][j];
        }
    }
    ll ans=0;
    rep(i,N){
        rep(j,60){
            if (A[i]&(1LL<<j)) ans=(ans+(i-cnt[i][j])*((1LL<<j)%MOD))%MOD;
            else ans=(ans+cnt[i][j]*((1LL<<j)%MOD))%MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 154880
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
vl a(51),p(51);
ll solve(ll N,ll K,vl a=a,vl p=p){
    if(N==0)return 1;
    if(K==1)return 0;
    if(K<=a[N-1]+1)return solve(N-1,K-1);
    if(K==a[N-1]+2)return p[N-1]+1;
    if(K<=2*a[N-1]+2)return p[N-1]+1+solve(N-1,K-a[N-1]-2);
    return 2*p[N-1]+1;
}
int main(){
    a[0]=1,p[0]=1;
    rep(i,50)a[i+1]=2*a[i]+3;
    rep(i,50)p[i+1]=2*p[i]+1;
    ll N,K;cin>>N>>K;
    cout<<solve(N,K)<<endl;
    return 0;
}

Measured memory_bytes: 256