akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class UnionFindTree
{
    vector<int> parent; // em[h
    vector<int> rank;   // ØÌ³ÌãÀ
    int find(int x){
        if(parent[x] == x)
            return x;
        return parent[x] = find(parent[x]);
    }
public:
    UnionFindTree(int n){ // RXgN^
        parent.resize(n);
        for(int i=0; i<n; ++i)
            parent[i] = i;
        rank.assign(n, 0);
    }
    void unite(int x, int y){ // xÆyÌO[vð¹
        if((x = find(x)) != (y = find(y))){
            if(rank[x] < rank[y])
                parent[x] = y;
            else{
                parent[y] = x;
                if(rank[x] == rank[y])
                    ++ rank[x];
            }
        }
    }
    bool same(int x, int y){ // xÆyÌO[vª¯¶©ð²×é
        return find(x) == find(y);
    }
    int num(){ // O[vÌðÔ·
        vector<bool> root(parent.size(), false);
        for(unsigned i=0; i<parent.size(); ++i)
            root[find(i)] = true;
        return count(root.begin(), root.end(), true);
    }
};

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<int> num(26, 0);
        UnionFindTree uft(26);
        vector<bool> check(26, false);

        for(int i=0; i<n; ++i){
            string s;
            cin >> s;
            int a = s[0] - 'a';
            int b = s[s.size()-1] - 'a';
            ++ num[a];
            -- num[b];
            uft.unite(a, b);
            check[a] = check[b] = true;
        }

        if(count(num.begin(), num.end(), 0) != 26)
            cout << "NG" << endl;
        else{
            int m = 0;
            for(int i=0; i<26; ++i){
                if(!check[i])
                    ++ m;
            }
            if(m + 1 == uft.num())
                cout << "OK" << endl;
            else
                cout << "NG" << endl;
        }
    }
}

Measured memory_bytes: 916
n = int(input())
e = [[i for i in input().split()] for i in range(n)]

# n = 2
# e = [['10000', 'JPY'], ['0.10000000', 'BTC']]

money = {'JPY': 1, 'BTC': 380000}

yen = 0
for row in e:
    yen += float(row[0]) * money[row[1]]

print(yen)


Measured memory_bytes: 2940
#include <stdio.h>

int main(){
    int a,b,c,emp;
    
    scanf("%d %d %d",&a,&b,&c);
    
    while(a>b || b>c){
        if(a>b){
            emp = a;
            a = b;
            b = emp;
        }else{
            emp = b;
            b = c;
            c = emp;
        }
    }
    printf("%d %d %d\n",a,b,c);
    
    return 0;
    
}


Measured memory_bytes: 2144
program div_game
  implicit none
  integer(8) :: n, i, m
  integer :: k, x = 0
  read(*,*) n
  m = n
  do i = 2_8, n
    if (i*i > n) exit
    k = 0
    do while (mod(m,i) == 0)
      m = m/i
      k = k+1
    end do
    x = x+calc(k)
  end do
  if (m /= 1) x = x+1
  write(*,'(i0)') x
contains
  integer function calc(k)
    integer, intent(in) :: k
    integer :: i
    do i = 0, k
      if (i*(i+1)/2 <= k) calc = i
    end do
  end
end program div_game

Measured memory_bytes: 2908
#include<iostream>
#include<stdio.h>

using namespace std;
int d[101];

int n;
int M[101][101];
int Q[101];
int head = 0;
int tail = 0;

void enqueue(int x) {
	Q[tail] = x;
	if (tail == (tail - head)) {
		tail = 1;
	}
	else {
		tail = tail + 1;
	}
}

void BFS(int s) {
	enqueue(s);
	d[s] = head;
	while (head != tail) {
		s = Q[head];
		head = head + 1;
		
		for (int j = 1; j < n + 1; j++) {
			if (M[s][j] == 1) {
				if(d[j] == -1){
					d[j] = d[s] + 1;
					enqueue(j);
				}

			}
		}

	}
}

int main() {
	int  u, k, v;//頂点数、頂点の番号、出次数、隣接する頂点の番号
	

	cin >> n;



	//初期化
	for (int i = 0; i < 101; i++) {
		d[i] = -1;
		
		for (int j = 0; j < 101; j++) {
			M[i][j] = 0;

		}
	}


	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v;
			M[u][v] = 1;
		}
	}


	BFS(1);
	
	for (int i = 1; i < n + 1; i++) {
		cout << i << " " << d[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3136
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Console;

namespace AOJ.ALDS 
{
    internal class ShellSort
    {
        public static void Main(string[] args)
        {
            var sw = new StreamWriter(OpenStandardOutput()){AutoFlush = false};
            var n = int.Parse(ReadLine());
            var inputs = new int[n];
            for (var i = 0; i < n; i++)
            {
                inputs[i] = (int.Parse(ReadLine()));
            }

            SetOut(sw);
            Shell(inputs, n);
            foreach (var i in inputs)
            {
                WriteLine(i);
            }

            Out.Flush();
        }

        public static int InsertionSort(int[] arr, int n, int gap, int cnt)
        {
            for (var i = gap; i < n ; i++)
            {
                var v = arr[i];
                var j = i - gap;
                while (j >= 0 && arr[j] > v)
                {
                    arr[j + gap] = arr[j];
                    j = j - gap;
                    cnt++;
                }

                arr[j + gap] = v;
            }
            return cnt;
        }
        
        public static void Shell(int[] arr, int n)
        {
               var cnt = 0;
               var gap = new List<int>();
               
               for (var h = 1;;)
               {
                   if (h > n) break;
                   gap.Add(h);
                   h = 3 * h + 1;
               }
               WriteLine(gap.Count);
               WriteLine(string.Join(" ", Enumerable.Reverse(gap)));
   
               for (var i = gap.Count - 1; i >= 0; i--)
               {
                   cnt = InsertionSort(arr, n, gap[i], cnt);
               }
               WriteLine(cnt);
           }
       }
   }


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

using namespace std;

#define all(x) begin(x), end(x)

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

constexpr int MAXN = 200005;
constexpr int MOD = 1e9 + 7;
int fact[MAXN], tcaf[MAXN];

inline int sum(int a, int b) {
    int c = (a + b);
    if (c >= MOD)
        c -= MOD;
    return c;
}

inline int prod(int a, int b) {
    return 1LL * a * b % MOD;
}

int modpow(int b, int e) {
    if (e == 0) return 1;
    if (e & 1) return prod(b, modpow(b, e ^ 1));
    else return modpow(prod(b, b), e >> 1);
}

inline int inv(int x) {
    return modpow(x, MOD - 2);
}

void gen_fact() {
    fact[0] = 1;
    for (int i = 1; i < MAXN; ++i) {
        fact[i] = prod(i, fact[i - 1]);
    }
    tcaf[MAXN - 1] = inv(fact[MAXN - 1]);
    for (int i = MAXN - 2; i >= 0; --i) {
        tcaf[i] = prod(tcaf[i + 1], i + 1);
    }
}

int choose(int n, int k) {
    return prod(fact[n], prod(tcaf[k], tcaf[n - k]));
}

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

    int n, m, k;
    cin >> n >> m >> k;

    gen_fact();

    // fix (x, y). What is the sum of distances to all other cells?
    // 01
    // 12 
    //
    // avg dist = 4/3
    //
    // dist = Ex + Ey
    // n^2 * sum i * (m - i)
    //
    // (n * m choose k) * (k choose 2) * e

    int ex = prod(prod(prod(n, n), choose(m + 1, 3)), inv(choose(n * m, 2)));
    int ey = prod(prod(prod(m, m), choose(n + 1, 3)), inv(choose(n * m, 2)));
    int e = sum(ex, ey);

    int ans = prod(prod(choose(n * m, k), choose(k, 2)), e);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1792
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
var A = input[1]
var B = input[2]
for c in readLine()!.characters {
  if c=="a" && A+B>0 {
    print("Yes")
    A>0 ?(A--):(B--)
  } else if c=="b" && B>0 {
    print("Yes")
    B--
  } else {
    print("No")
  }
}

Measured memory_bytes: 1408
#include <iostream>

int main() {
  long a, b, c, d;

  std::cin >> a;
  std::cin >> b;
  std::cin >> c;
  std::cin >> d;

  long ans = ((a < b ? a : b) + (c < d ? c : d));

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define MAX 100007
#define scn1(a) scanf("%d", &a);
#define scn2(a, b) scanf("%d %d", &a, &b);
#define scn3(a, b, c) scanf("%d %d %d", &a, &b, &c);
#define lscn1(a) scanf("%lli", &a);
#define lscn2(a, b) scanf("%lli %lli", &a, &b);
#define lscn3(a, b, c) scanf("%lli %lli %lli", &a, &b, &c);
#define prnt(a) printf("%d\n", a);
#define for0(i, n) for(i=0;i<n;i++)
#define for1(i, n) for(i=1;i<=n;i++)
typedef unsigned long long int ll;
using namespace std;


int main()
{
//	#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//	#endif
	int tt=1;
//	scn1(tt);
	while(tt--)
    {
        ll n;
        lscn1(n);
        ll x=sqrt(n);

        ll p=0, q=0;
        for(ll i=x; i>0; i--)
        {
            ll j=n/i;
            if(i*j==n)
            {
                p=i;
                q=j;
                break;
            }
        }
        printf("%lli\n", p+q-2);
    }
    return 0;
}



Measured memory_bytes: 384
c[1100000],n=1e6;main(i,j){for(i=2;i*i<n;++i)for(j=i;!c[i]&&j<n;c[j+=i]=1);for(i=1;++i<n;c[i]=c[i-1]+!c[i]);for(j=0;~scanf("%d",&n);printf("%d\n",c[n]));}

Measured memory_bytes: 0
import numpy as np

def solve(n, x, y):
    def dist(i, j):
        return min(abs(x[i]-x[j]), abs(y[i]-y[j]))
    que = []
    for p in map(np.argsort, [x, y]):
        for i in range(n-1):
            u, v = p[i], p[i+1]
            que.append((u, v, dist(u, v)))
    parent = [i for i in range(n)]
    def find(i):
        if parent[i] == i:
            return i
        else:
            j = find(parent[i])
            parent[i] = j
            return j
    ans = 0
    for u, v, d in sorted(que, key=lambda _: _[2]):
        u = find(u)
        v = find(v)
        if u != v:
            ans += d
            if u > v:
                u, v = v, u
            parent[v] = u
    return ans

n = int(input())
x = np.zeros(n, dtype=int)
y = np.zeros(n, dtype=int)
for i in range(n):
    x[i], y[i] = map(int, input().split())
print(solve(n, x, y))

Measured memory_bytes: 66432
// https://atcoder.jp/contests/abc140/tasks/abc140_e

//   4  1  5  2  3
// 4 -  14 45 45 45
// 1 -  -  15 25 35
// 5 -  -  -  25 35
// 2 -  -  -  -  23
// 3 -  -  -  -  -
//
//
//   7  8  6  2  1  4  3  5  9
// 7 -  78 78 78 78 78 78 78 89
// 8 -  -  68 68 68 68 68 68 89
// 6 -  -  -  26 26 46 46 56 69
// 2 -  -  -  -  12 24 34 45 59
// 1 -  -  -  -  -  14 34 45 59
// 4 -  -  -  -  -  -  34 45 59
// 3 -  -  -  -  -  -  -  35 59
// 5 -  -  -  -  -  -  -  -  59
// 9 -  -  -  -  -  -  -  -  -

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> PAIR;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define ITR(c,it)  for(auto it = c.begin(); it != c.end(); it++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;

int N;
int P[N_MAX];

int L1[N_MAX];
int L2[N_MAX];
int R1[N_MAX];
int R2[N_MAX];

set<PAIR, greater<PAIR>> rst, lst;

void solve() {
  fill(R1, R1 + N, N);
  fill(R2, R2 + N, N);
  fill(L1, L1 + N, -1);
  fill(L2, L2 + N, -1);
  REP(i, N) {
    PAIR p = make_pair(P[i], i);
    auto it = rst.lower_bound(p);
    while (it != rst.end()) {
      int k = it->second;
      if (R1[k] == N) {
        R1[k] = i;
        it++;
      } else {
        R2[k] = i;
        it = rst.erase(it);
      }
    }
    rst.insert(p);
  }
  for (int i = N - 1; i >= 0; i--) {
    PAIR p = make_pair(P[i], i);
    auto it = lst.lower_bound(p);
    while (it != lst.end()) {
      int k = it->second;
      if (L1[k] < 0) {
        L1[k] = i;
        it++;
      } else {
        L2[k] = i;
        it = lst.erase(it);
      }
    }
    lst.insert(p);
  }
  ll ans = 0;
  REP(i, N) {
    ll tmp = 0;
    tmp += (i - L1[i]) * (R2[i] - R1[i]);
    tmp += (L1[i] -L2[i]) * (R1[i] - i);
    // printf("%d %d %d %d %d => %lld\n", L2[i], L1[i], i, R1[i], R2[i], tmp);
    ans += tmp * P[i];
  }
  printf("%lld\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", P + i);
}

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


Measured memory_bytes: 6784
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	S := sc.Next()
	imos := make([]int, N)
	{
		A := make([]int, len(S))
		for i := 0; i < len(S)-1; i++ {
			if S[i] == 'E' {
				A[i+1]++
			}
		}
		sum := A[0]
		for i := 1; i < len(S); i++ {
			sum += A[i]
			imos[i] = sum
		}
	}
	//fmt.Printf("%+v\n", imos)

	mx := 0
	//	mxI := 0
	{
		A := make([]int, len(S))
		for i := 1; i < len(S); i++ {
			if S[i] == 'W' {
				A[i-1]++
			}
		}
		sum := 0
		for i := len(S) - 1; i >= 0; i-- {
			sum += A[i]
			imos[i] += sum
			if mx < imos[i] {
				mx = imos[i]
				//mxI = i
			}
		}
	}
	//fmt.Printf("%+v\n", imos)

	fmt.Println(len(S) - mx - 1)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;

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

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

    int n;
    map<string, int> mp;
    mp["N"] = 0;
    mp["E"] = 1;
    mp["W"] = 2;
    mp["S"] = 3;
    while (cin >> n, n) {
        vector<vector<bool>> exist(21, vector<bool>(21, false));
        rep(i, n) {
            int x, y;
            cin >> x >> y;
            exist[x][y] = true;
        }
        int m;
        cin >> m;
        int x = 10, y = 10;
        int num_done = 0;
        rep(i, m) {
            string c;
            int step;
            cin >> c >> step;
            int k = mp[c];
            rep(j, step) {
                x += dx[k], y += dy[k];
                if (exist[x][y]) {
                    exist[x][y] = false;
                    num_done++;
                }
            }
        }
        cout << (num_done == n ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 3212
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    string S;
    cin>>S;
    int cou=0;
    int maxcou=0;
    for(int i=0;i<3;i++){
        if(S[i]=='R')cou++;
        else cou=0;
        maxcou=max(cou,maxcou);
    }
    cout<<maxcou<<endl;
    return 0;
}


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

int main() {
    int N,D; cin >> N >> D;
     int ans=0;
    int B[N+10][D+10];
    rep(i,N){
        rep(j,D){
            cin >> B[i][j];
        }
    }
    rep(i,N-1){
        for(int j=i+1;j<N;j++){
            int sum=0;double A=0;
            rep(s,D){
                sum+=(B[i][s]-B[j][s])*(B[i][s]-B[j][s]);
            }
            A = sqrt(sum);
            if(ceil(A) == floor(A)){
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
s = input()
li = input().split()
li2 = []
for i in li:
    for j in li:
        s = int(i) -int(j) 
        if s >0:
            li2.append(s)
        else:
            li2.append(s * -1)

li2.sort()
ans = li2[-1]
print(ans)

Measured memory_bytes: 3444
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;
const int MAXN=1e4+1e2;

struct node{
	int nxt,to;
};

node edge[MAXN];
bool vis[MAXN];
int head[MAXN];
int w[MAXN];

int n,tot=0;

void addedge(int u,int v)
{

	edge[++tot]=(node){head[u],v};
	head[u]=tot;

	return;

}

bool dfs(int u)
{

	bool flag=false;

	for(int i=head[u];i;i=edge[i].nxt)
	{
		int v=edge[i].to;
		if(vis[v]||w[u]<=w[v]) continue;
		vis[v]=true;
		if(!dfs(v)) flag=true;
		vis[v]=false;
	}

	return flag;

}

int main(void)
{

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

	scanf("%d",&n);

	for(int i=1;i<=n;i++)
		w[i]=read<int>();

	for(int i=1;i<n;i++)
	{
		int u=read<int>();
		int v=read<int>();
		addedge(u,v);
		addedge(v,u);
	}

	for(int i=1;i<=n;i++)
		if(dfs(i)) printf("%d ",i);

	cout<<endl;

	return 0;

}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int a = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0 ; i < n ; i++) {
            h[i] = sc.nextInt();
        }
        double min = Double.MAX_VALUE;
        int ans = 0;
        for (int i = 0 ; i < n ; i++) {
           if (min > Math.abs(a - (t - 0.006 * h[i]))) {
               ans = i + 1;
               min = Math.abs(a - (t - 0.006 * h[i]));
           }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 22484
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
using namespace std;

int main() {
    int n, h;
    cin >> n;
    int ans = 0, active = 0;
    for (int i = 0;i < n; i++) {
        cin >> h;
        if (active >= h) {
            active = h;
        }
        else {
            ans += h - active;
            active = h;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  char s[13];

  scanf("%s",s);

  for(int i=0;s[i]!='\0';i++)
    if(i==3)
      printf("%c ",s[i]);
    else
      printf("%c",s[i]);

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


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>


using namespace std;

int main(){
  int n,m,xt;
  int a[200005],b[200005];
  cin >>n;
  int temp;
  for(int i=0;i < n; ++i){
    cin >> a[i];
    b[i]=a[i];
  }
  sort(b, b+n);
  int low = b[n/2-1], hi =b[n/2];
  for(int i=0;i < n; ++i){
     cout << (a[i] <= low ? hi: low) << endl;
  }
return 0;
}


Measured memory_bytes: 3712
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string S;
  ll K;
  cin >> S >> K;
  ll not_one_id;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] != '1') {
      not_one_id = i;
      break;
    }
  }
  if (K == 1) {
    cout << S[0] << endl;
  } else if (K < not_one_id + 1) {
    cout << 1 << endl;
  } else {
    cout << S[not_one_id] << endl;
  }
  return 0;
}

Measured memory_bytes: 3524
package main

import "fmt"

func main() {
	var H int
	EnemyCount := 1
	count := 0

	fmt.Scanf("%d", &H)

	for {
		if H > 1 {
			count += EnemyCount
			H /= 2
			EnemyCount *= 2
		} else {
			count += EnemyCount
			break
		}
	}

	fmt.Printf("%d", count)

}


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i = 0;i < n;i++)
#define PRN(n) printf("%d\n",n)
#define PRS(s) printf("%s\n",s)
int main(void){
  char s[4],c[4];
  scanf("%s %s",s,c);
  if(s[0]==c[2]&&s[1]==c[1]&&s[2]==c[0]){
    PRS("YES");
  }else{
    PRS("NO");
  }
  return 0;
}
/*
scanf("%d",&n);
scanf("%d %d",&a,&b);
*/

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


int main()
{
  int n,d,x,i;
  scanf("%d%d",&n,&d);
  x=d*2+1;
  //printf("x=%d\n",x);
  if(n%x!=0) i=n/x+1;
  else i=n/x;
  printf("%d",i);
  return 0;
}

Measured memory_bytes: 256
import sys, math

n = int(sys.stdin.readline().strip())

prev = ["a"]
cands = "abcdefghijklmnopqrstuvwxyz"
for i in range(1, n):
    current = []
    
    for one in prev:
        count = len(set(list(one)))
        for j in range(count+1):
            current.append(one + cands[j])
    prev = current

for one in prev:
    print(one)

Measured memory_bytes: 12988
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//inline int in() { int x; scanf("%d",&x); return x;}
inline ll in() { ll x; cin >> x; return x; }
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

// maxとmaxより後ろにあるminが2離れたらNo
int main() {
  int a = in(), b = in();
  int ans = a+b;
  if (ans < a-b) ans = a-b;
  if (ans < a*b) ans = a*b;
  cout << ans << endl;
  return 0;
}


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

        signed main() {
        int a,b;
        cin>>a>>b;
        char c[100][100];
        cout<<100<<' '<<100<<endl;
        for(int i=0;i<50;i++)for(int j=0;j<100;j++)c[i][j]='.';
        for(int i=50;i<100;i++)for(int j=0;j<100;j++)c[i][j]='#';
        a--;b--;
        for(int i=0;i<50;i++)for(int j=0;j<50;j++){
            if(b!=0){
                b--;
                c[2*i][2*j+ i%2]='#';
            }
        }
        for(int i=0;i<50;i++)for(int j=0;j<50;j++){
            if(a!=0){
                a--;
                c[99-2*i][2*j +i%2]='.';
            }
        }
        for(int i=0;i<100;i++){
            for(int j=0;j<100;j++)cout<<c[i][j];
            cout<<endl;
        }
        }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
   
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        string s;cin>>s;int ans=0;
        int n=sz(s);
        int dp[n][2];
        fill(dp,-1);
        reverse(all(s));
        dp[0][0]=(s[0]-'0');
        dp[0][1]=(10-(s[0]-'0'));
        for(int i=1;i<n;i++){
            dp[i][0]=dp[i-1][0]+(s[i]-'0');
            dp[i][0]=min(dp[i][0],dp[i-1][1]+(s[i]-'0')+1);
            dp[i][1]=dp[i-1][0]+(10-(s[i]-'0'));
            dp[i][1]=min(dp[i][1],dp[i-1][1]+(10-(s[i]+1-'0')));
            // dbg(dp[i][0],dp[i][1]);
        }
        dp[n-1][1]++;
        cout<<min(dp[n-1][0],dp[n-1][1]);
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 9116
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
//reason of WA:The same out edge should be combined. 
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n;
int ban[100005],used[100005];
vector<int>out[100005];
int pos[100005],cur;
bool check(vector<int>ans){
	for(int i=0;i+1<ans.size();i++){
		if(ban[ans[i]]==ans[i+1])return false;
	}
	return true;
}
map<int,int>cnt;
set<int>have;
vector<int>ans;
void del(int x){
	used[x]=1;cnt[ban[x]]--;if(!cnt[ban[x]])cnt.erase(ban[x]);
	have.erase(x);while(pos[ban[x]]<out[ban[x]].size()&&used[out[ban[x]][pos[ban[x]]]])pos[ban[x]]++;
	if(pos[ban[x]]!=out[ban[x]].size())have.insert(out[ban[x]][pos[ban[x]]]);
}
bool can_put(int x){
	if(ans.size()&&ban[ans.back()]==x)return false;
	have.erase(x);//cnt[ban[x]]--;if(!cnt[ban[x]])cnt.erase(ban[x]);
	bool ret=cnt.size()==2&&
	((cnt.begin()->second==1&&have.count(cnt.rbegin()->first))||
	((cnt.rbegin()->second==1&&have.count(cnt.begin()->first))));
	//cnt[ban[x]]++;
	have.insert(x);
	return 1^(ret);
}
int perm[6];
int main(){
	cin>>n;cur=n;
	for(int i=1;i<=n;i++)cin>>ban[i];
	for(int i=1;i<=n;i++)cnt[ban[i]]++,out[ban[i]].push_back(i);
	for(int i=1;i<=n;i++)have.insert(i);
	for(int i=1;i<=n;i++)pos[i]=out[i].size();
	for(int i=1;i<=n-5;i++){
		int ins=-1;
		if(cnt.size()==2){
			if(cnt.begin()->second==1)ins=cnt.rbegin()->first;
			else if(cnt.rbegin()->second==1)ins=cnt.begin()->first;
		}
		int hv=have.count(ins);
		if(~ins)if(!used[ins])have.insert(ins);
		auto itr=have.begin();
		while(itr!=have.end()&&!can_put(*itr)){itr++;}
		ans.push_back(*itr);del(*itr);
		if((!hv)&&have.count(ins))have.erase(ins);
		cur--;
	}
//	for(auto x:ans)cerr<<x<<" ";cerr<<endl;
	const int sz=min(n,5);
	const int base=max(0,n-5);
	for(int i=1;i<=sz;i++)perm[i]=i;
	vector<int>vec(have.begin(),have.end());
	for(int i=1;i<=n;i++)for(int j=pos[i]+1;j<out[i].size();j++)vec.push_back(out[i][j]);
	vector<int>pre=ans;for(int i=1;i<=sz;i++)ans.push_back(n+1);
	do{
		vector<int>tmp=pre;
		for(int i=1;i<=sz;i++)tmp.push_back(vec[perm[i]-1]);
		if(check(tmp))ans=min(ans,tmp);
	}while(next_permutation(perm+1,perm+sz+1));
	if(ans.back()==n+1){
		cout<<-1<<endl;
		return 0;
	}
	for(auto x:ans)cout<<x<<" ";cout<<endl;
	return 0;
}

Measured memory_bytes: 18412
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main() {
    double a, b, c;
    cin >> a >> b >> c;
    c *= (M_PI/180);
    printf("%.10lf\n", (1.0/2.0)*a*b*sin(c));
    printf("%.10lf\n", a+b+sqrt(a*a+b*b-2*a*b*cos(c)));
    printf("%.10lf\n", b*sin(c));
    return 0;
}


Measured memory_bytes: 3392
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
int main()
{
  int n; cin >> n;
  string s; cin >> s;
  int buf = 0;
  rep(i,n) {
    if(s[i] == '1') buf++;
  }
  if(buf == 0) {
    rep(i,n) cout << 1 << "\n";
    return 0;
  }
  
  
  ll sum1 = 0, sum2 = 0;
  ll pow2 = 1;
  vector<ll> pow21(n), pow22(n);
  reverse(s.begin(), s.end());
  rep(i,n) {
    if(s[i] == '1') {
      sum1 = (sum1 + pow2 % (buf + 1)) % (buf + 1);
    }
    pow21[i] = pow2;
    pow2 = (pow2 * 2) % (buf + 1);
  }
  pow2 = 1;
  if(buf != 1) {
    rep(i,n) {
      if(s[i] == '1') {
	sum2 = (sum2 + pow2 % (buf - 1)) % (buf - 1);
      }
      pow22[i] = pow2;    
      pow2 = (pow2 * 2) % (buf - 1);
    }
  }
  int M = 4e+5;
  vector<int> f(M+1);
  f[0] = 0;
  rep1(i,M) {
    int x = i;
    int cnt = 1;
    while(x % __builtin_popcount(x) != 0) {
      x = x % __builtin_popcount(x);
      cnt++;
    }
    f[i] = cnt;
  }
  
  
  vector<int> res(n);
  rep(i,n) {
    if(s[i] == '0') {
      int x = (sum1 + pow21[i]) % (buf + 1);
      res[i] = f[x] + 1;
    }
    else if(buf == 1) {
      res[i] = 0;
    }
    else {
      int x = (sum2 - pow22[i] + buf - 1) % (buf - 1);
      res[i] = f[x] + 1;      
    }
  }
  
  reverse(res.begin(), res.end());
  for(auto val: res) cout << val << "\n";

  
  return 0;
}


Measured memory_bytes: 9144
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solveB();
	}

	private void solveB() {
		int min = 0;
		int max = 0;

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int A[] = new int[M];
		for (int i = 0; i < M; i++) {
			A[i] = sc.nextInt();
		}



		for (int j = 0; j <= M - 1; j++) {
			if (X > A[j]) {
				min = min + 1;
			}
		}
		for (int k = M - 1; k >= 0; k--) {
			if (X < A[k]) {
				max = max + 1;
			}
		}

		if (min > max) {
			System.out.println(max);
		} else if (min < max) {
			System.out.println(min);
		} else {
			System.out.println(min);
		}

		return;
	}

}

Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define V vector<int>
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;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	V a(n); rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, n) {
		while (true) {
			if (a[i] % 2 != 0)break;
			a[i] /= 2; ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    __int128_t M = 1, INF = int64_t(1e18) + 1;
    while(N--){
        int64_t a;
        cin >> a;
        M = min(M*a, INF);
    }
    if(M == INF) M = -1;
    cout << int64_t(M) << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fup(i,a,b) for(int i=a;i<=b;++i)
#define fdw(i,a,b) for(int i=a;i>=b;--i)
#define sync ios::sync_with_stdio(false);cin.tie(0)
#define cl(a) memset(a,0,sizeof(a))
#define gcd __gcd
#define fi first
#define se second
#define pb push_back
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
//ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//ll ksm(ll a,ll b,ll mod){ll ans=1;a%=mod;for(;b;b>>=1){if(b&1) ans=ans*a%mod;a=a*a%mod;}return ans;}
//ll oula(ll n){ ll res=n;for(ll i=2;i*i<=n;i++){if(n%i==0){ res=res-res/i;while(n%i==0) n/=i;}}if(n>1) res=res-res/n;return res;}
//bool MRT(ll x){if(x==2)return true;fup(i,1,50){ll now=rand()%(x-2)+2;if(ksm(now,x-1,x)!=1)return false;}return true;}
//void shai(int n)fup(i,2,n){if(isprime[i]){v.push_back(i);for(int j=2*i;j<=10000;j+=i)isprime[j]=0;}}//"埃氏筛筛选素数"
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const double eps=1e-7;
const int N = 1e6 + 10;

int main()
{
    sync;
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b))
    {
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ((int)(x).size())

typedef map<int, int> M;
typedef pair<int, int> P;
typedef long long ll;

int main() {
  int N, X, T;
  cin >> N >> X >> T;
  if (N % X) {
    cout << T * (N / X + 1)<< endl;
  } else {
    cout << T * (N / X) << endl;
  }
  return 0;
}


Measured memory_bytes: 3596
n = int(input())
a = list(map(int,input().split()))

c = 0
for i in range(0,n):
  if a[i]%2==0:
    if a[i] %6 != 0 and a[i] %10 != 0:
      print('DENIED')
      c = 1
      break
      
if c == 0:
  print('APPROVED')


Measured memory_bytes: 2940
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
al=sorted(a)
bl=sorted(b)
cl=sorted(c)
 
abl=[0]*n
bcl=[0]*n
i=n-1
for j in range(n-1,-1,-1):
    if i==-1:
        abl[j]=0
        continue
    while al[i]>=bl[j]:
        i-=1
        if i==-1:
            break
    if i==-1:
        abl[j]=0
    else:
        abl[j]=i+1
j=0
bcl=[0]*n
k=0
for j in range(n):
    if k==n:
        bcl[j]=0
        continue
    while cl[k]<=bl[j]:
        k+=1
        if k==n:
            break
    if k==n:
        bcl[j]=0
    else:
        bcl[j]=(n-k)
ans=0
for s in range(n):
    ans+=abl[s]*bcl[s]
print(ans)

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int a = 0, b = 0;
  rep(i,n) if (s[i] == 'R') ++a;
  int ans = max(a,b);
  rep(i,n) {
    if (s[i] == 'R') --a;
    else ++b;
    int now = max(a,b);
    ans = min(ans, now);
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int a, b, k; cin >> a >> b >> k;
    int count = 0;
    for(int i = min(a, b); i > 0; i--) {
        if(a % i == 0 && b % i == 0) count++;
        if(count == k) {
            cout << i << endl;
            return 0;
        }
    }
}
   

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <cstdlib>

using namespace std;

int main()
{
	int x ,t;
	cin >> x >> t;
	if(x-t > 0) cout << (x - t) << endl;
	else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define INF 5000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans;

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

	int N;
	cin >> N;

	vector<int> a(N);
	int amax = 0, amax_index = 0;
	rep(i,N){
		cin >> a[i];
		if(amax < a[i]){
			amax = a[i];
			amax_index = i;
		}
	}

	sort(a.begin(),a.end(),greater<int>());

	rep(i,N){
		if(i != amax_index){
			cout << amax << endl;
		}
		else{
			cout << a[1] << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 2147483647
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, q;
vector<int> node;

void update(int x, int a) {
	x += (n - 1);
	node[x] = a;
	while (x > 0) {
		x = (x - 1) / 2;
		node[x] = min(node[2 * x + 1], node[2 * x + 2]);
	}
}
int find(int a, int b, int k = 0, int l = 0, int r = -1) {
	if (r < 0)r = n;
	if (r <= a || b <= l)return INF;
	if (a <= l && r <= b)return node[k];
	int vl = find(a, b, k * 2 + 1, l, (l + r) / 2);
	int vr = find(a, b, k * 2 + 2, (l + r) / 2, r);
	return min(vl, vr);
}

signed main() {
	cin >> n >> q;
	int m = n;
	n = 1;
	while (n < m)n *= 2;
	for (int i = 0; i < 2 * n - 1; i++)node.push_back(INF);
	for (int i = 0; i < q; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		if (!a)update(b, c);
		else cout << find(b, c + 1) << endl;
	}
}


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

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

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

  sort(l, l+n);
  tmp -= l[n-1];

  if (l[n-1] < tmp) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
//おまじない
//#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include<iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
#define pll pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 100000;

int main(){
    
    int n,k;
    string s;
    int cnt = 0;
    
    cin >> n>>k>>s;
    
    rep(i,n-1){
        if(s[i]=='R'&&s[i+1]=='L')cnt+=2;
    }
    int uh=cnt;
    if(s[0]=='L'&&s[n-1]=='R'){
        uh+=2;
        rep(i,min(k,cnt))uh-=2;
        uh = uh-min(max(0,k-cnt),2);
    }else if(s[0]=='L'||s[n-1]=='R'){
        uh+=1;
        rep(i,min(k,cnt))uh-=2;
        uh = uh-min(max(0,k-cnt),1);
    }else{
        rep(i,min(k,cnt))uh-=2;
    }
    cout << min(n-1,n-uh)<<endl;
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int X[100010];
bool seen[100010];
vector<tuple<int, int, int>> V;

class UFDS {
   public:
      vector<int> p, rank, bad;
      vector<LL> sz;
      UFDS(const int N) {
         p.assign(N, 0);
         rank.assign(N, 0);
         sz.assign(N, 0);
         bad.assign(N, 0);
         for (int i = 1; i < N; i++)
            p[i] = i, sz[i] = X[i];
      }//constructor
      int findSet(const int i) {
         return p[i] == i ? i : p[i] = findSet(p[i]);
      }//findSet
      LL getSize(const int i) {
         return sz[findSet(i)];
      }//getSize
      void clearBad(const int i) {
         bad[findSet(i)] = 0;
      }//clearBad
      void incBad(const int i) {
         bad[findSet(i)]++;
      }//incBad
      int getBad(const int i) {
         return bad[findSet(i)];
      }//getBad
      void unite(const int i, const int j) {
         int r1 = findSet(i), r2 = findSet(j);
         if (r1 == r2)
            return;
         rank[r1] >= rank[r2] ? (p[r2] = r1, sz[r1] += sz[r2], bad[r1] += bad[r2]) : (p[r1] = r2, sz[r2] += sz[r1], bad[r2] += bad[r1]);
         if (rank[r1] == rank[r2])
            rank[r1]++;
      }//unite
};

int main() {
   int N, M, A, B, Y;
   scanf("%d %d", &N, &M);
   for (int i = 1; i <= N; i++)
      scanf("%d", &X[i]);
   UFDS U(N + 5);
   while (M--) {
      scanf("%d %d %d", &A, &B, &Y);
      V.push_back(make_tuple(Y, A, B));
   }//while
   sort(V.begin(), V.end());
   for (int i = 0; i < (int)V.size(); i++) {
      int p1 = U.findSet(get<1>(V[i]));
      int p2 = U.findSet(get<2>(V[i]));
      U.unite(p1, p2);
      if (U.getSize(p1) < get<0>(V[i]))
         U.incBad(p1);
      else
         U.clearBad(p1);
   }//for
   int ans = 0;
   for (int i = 1; i <= N; i++)
      if (!seen[U.findSet(i)])
         seen[U.findSet(i)] = 1, ans += U.getBad(i);
   printf("%d\n", ans);
   return 0;
}//main


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << 100 << " " << 100 << "\n";
    string s[100];
    for (int i = 0; i < 50; i++) {
        s[i] = string(100, '#');
        s[i + 50] = string(100, '.');
    }
    for (int i = 0; i < a - 1; i++) {
        s[2 * (i / 50) + 1][2 * (i % 50)] = '.';
    }
    for (int i  = 0; i  < b - 1; i ++) {
        s[2 * (i / 50) + 51][2 * (i % 50)] = '#';
    }
    for (int i = 0; i < 100; i++) {
        cout << s[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#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<< "Balanced" <<endl;}
  else if(A+B<C+D){cout<< "Right" <<endl;}
}
 

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <memory.h>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <queue>
#include <stack>
#include <cstdio>
#include <bitset>

using namespace std;

#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define ll long long
#define ull unsigned long long
#define ld long double
#define ef else if
#define loc(x) (x).begin(),(x).end() 
#define locR(x) (x).rbegin(),(x).rend()
#define no puts("NO")
#define yes puts("YES")
#define ex puts("-1")
#define en puts("")
#define _ cout  
#define __ <<
#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';
#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';

const ld EPS = 1e-18;
const double DEPS = 1e-9;
const ld PI = 3.141592653589793238;
const ull MOD = 1e9 + 7;
const int N = (int)(5e5) + 1;


ll gcd(ll fx, ll fy)
{
	if (!fy) return fx;
	return gcd(fy, fx % fy);
}

inline void fill(int* ar, int sz, int val)
{
	for (int i = 0; i < sz; i++)
	{
		ar[i] = val;
	}
}

int n, k;
ll dp[N][101], w[101], v[101];

ll rec(int cur,int idx)
{
	if (cur < 0)return -1e9;
	if (idx == n) return (cur >= 0 ? 0 : -1e9);
	ll& dp = ::dp[cur][idx];
	if (~dp)return dp;

	dp = rec(cur - w[idx], idx + 1) + v[idx];
	dp = max(dp, rec(cur, idx + 1));
	return dp;
}

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

	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", w + i, v + i);
	}

	memset(dp, -1, sizeof(dp));

	printf("%lld", rec(k, 0));
}

Measured memory_bytes: 394752