akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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



class unionfind
{
private:
    vector<long long> par;
    vector<long long> rank;
public:
    unionfind(long long n);
    long long find(long long x);
    void unite(long long x, long long y);
    bool same(long long x, long long y);
};

// 初期化
unionfind::unionfind(long long n){
    for (long long i = 0; i < n; i++) {
        par.push_back(i);
        rank.push_back(0);
    }
}

// 木の根を求める
long long unionfind::find(long long x) {
    if (par[x] == x) {
        return x;
    }
    else {
        return par[x] = find(par[x]);
    }
}

// xとyの属する集合を併合
void unionfind::unite(long long x, long long y) {
    x = find(x);
    y = find(y);
    if (x == y)return;
    
    if (rank[x] < rank[y]) {
        par[x] = y;
    }
    else {
        par[y] = x;
        if (rank[x] == rank[y]) {
            rank[x]++;
        }
    }
}

// xとyが同じ集合に属していたらtrue
bool unionfind::same(long long x, long long y) {
    return find(x) == find(y);
}


class kruskal
{
private:
    struct edge{
        long long cost, u, v;
        
        bool operator<(const edge& e1) const {
            return cost < e1.cost;
        }
    };
    vector<edge> es;
    long long vertex;    // vertexは頂点の数
public:
    kruskal(long long n);   // nは頂点数
    void add_edge(long long u, long long v, long long cost);    // 頂点uから頂点vにコストcostの辺を貼る
    long long run();
};

kruskal::kruskal(long long n){
    vertex = n;
}

void kruskal::add_edge(long long u, long long v, long long cost){
    es.push_back({cost, u, v});
    es.push_back({cost, v, u});
}

long long kruskal::run(){
    sort(es.begin(), es.end());
    
    unionfind uni(vertex);
    long long res = 0;
    
    for(auto e : es){
        if(!uni.same(e.u, e.v)){
            uni.unite(e.u, e.v);
            res += e.cost;
        }
    }
    
    return res;
}




int main() {
    ll n;
    cin >> n;
    
    vector<pair<ll, ll>> v1(n), v2(n);
    REP(i, n){
        ll x, y;
        cin >> x >> y;
        
        v1[i] = {x, i};
        v2[i] = {y, i};
    }
    
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    
    kruskal k(n);
    REP(i, n - 1){
        k.add_edge(v1[i].second, v1[i + 1].second, v1[i + 1].first - v1[i].first);
        k.add_edge(v2[i].second, v2[i + 1].second, v2[i + 1].first - v2[i].first);
    }
    
    cout << k.run() << endl;
}

Measured memory_bytes: 17772
n, k = [int(i) for i in input().split()]

odd_cnt, even_cnt = 0, 0
for i in range(1, n + 1):
    if i % k == 0:
        odd_cnt += 1
if k % 2 == 0:
    for i in range(1, n + 1):
        if i % k == k / 2:
            even_cnt += 1

print(odd_cnt ** 3 + even_cnt ** 3)

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

int main()
{
    string s1, s2;
    cin >> s1;
    cin >> s2;
    for (int i = 0; i < s1.length(); i++) {
        if (s2[i] == '\0') cout << s1[i];
        else cout << s1[i] << s2[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
#define PI 3.14159265359
typedef long long ll;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}

//素数判定 O(√n)
bool is_prime(int64_t n){
  for(int64_t i = 2; i*i<=n; i++){
    if(n%i==0) return false;
  }
  return n!=1;
}

//約数の列挙 O(√n)
vector<int64_t> dividor(int64_t n){
  vector<int64_t> res;
  for(int64_t i=1; i*i<=n; i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(i);
    }
  }
  return res;
}

//素因数分解 O(√n)
map<int64_t, int64_t> prime_factor(int64_t n){
  map<int64_t, int64_t> res;
  for(int64_t i=2; i*i<=n; i++){
    while(n%i==0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

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

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

int main(){ 
  int n;
  cin >> n;
  vector<int64_t> A(n);
  rep(i,n) cin >> A[i];
  Sort(A);
  int64_t m = 0;
  int i,j,k;
  if(n==1 || n==2) cout << 0 << endl;
  else {
    for(i=0; i<n-2; i++){
      for(j=i+1; j<n-1; j++){
        for(k=j+1; k<n; k++){
          if(A[i]==A[j] || A[j]==A[k]) continue;
          else if(A[i]+A[j]>A[k]) m++;
        }        
    }
  }
  cout << m << endl;
  }
  
}




Measured memory_bytes: 3656
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	double x1 = scan.nextDouble();
	double y1 = scan.nextDouble();
	double x2= scan.nextDouble();
	double y2 = scan.nextDouble();
	double distance = Math.sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
	System.out.println(distance);
    }
}

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

using namespace std;
using ll = long long;
#define mod 1000000007
int mypower(ll a, ll b)
{
    ll ans = 1;
    b = b%(mod-1);
    while(b)
    {
        if(b%2)
            ans = ans*a % mod;
        b=b/2;
        a = a*a % mod;
    }
    return ans;
}
ll sub(ll a, ll b)
{
    ll ans = a-b;
    if(ans < 0)
        ans+=mod;
    return ans;    
}
ll add(ll a, ll b)
{
    ll ans = a + b;
    if(ans >= mod)
        ans-=mod;
    return ans;    
}
ll mul(ll a, ll b)
{
    ll ans = a*b;
    if(ans >= mod)
        ans = ans%mod;
    return ans;    
}
int main() {
    ll n, k;
    cin >> n >> k;
    ll dp[k+1];
    ll ans = 0;
    for(int i=k;i>=1;i--)
    {
        dp[i] = mypower(k/i, n);
        int j = 2*i;
        while(j <= k)
            dp[i] = sub(dp[i], dp[j]), j = j + i;
        ans = add(ans, mul(i, dp[i]));    
    }
    cout << ans << '\n';
}

Measured memory_bytes: 4420
#include<stdio.h>

int main(){
    int m1, m2, d1, d2;
    
    scanf("%d", &m1);
    scanf("%d", &d1);
    scanf("%d", &m2);
    scanf("%d", &d2);

    if(m1 == m2){
        printf("0\n");
    }else{
        printf("1\n");
    }

    return 0;
}

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

signed main() {
    int n;
    cin >> n;
    vector<int> x(n);
    cin >> x;
    auto y = x;
    sort(ALL(y));
    int a = y[n / 2 - 1];
    int b = y[n / 2];
    REP(i, n) {
        if (x[i] <= a) {
            cout << b << endl;
        } else {
            cout << a << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 5376
# -*- coding: utf-8 -*-

import math
import itertools

x = []
y = []
N = int(input())
for i in range(N):
    xsub, ysub = map(int, input().split())
    x.append(xsub)
    y.append(ysub)

total = []
seq = list(itertools.permutations(range(len(x))))

for i in range(len(seq)):
    dist = 0
    seq_prev = None
    for j in seq[i]:
        if(seq_prev is not None):
            dist += (math.sqrt((x[j] - x[seq_prev]) ** 2 + (y[j] - y[seq_prev]) ** 2))
        seq_prev = j
    total.append(float(dist))

print(sum(total) / len(total))


Measured memory_bytes: 46320
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;

const int maxn=2e5+10;
int ans[maxn];
struct edge{
    int x,id;
}a[maxn];
bool cmp(const edge& a,const edge& b){return a.x<b.x;}
int main()
{
    int n;
    while (scanf("%d",&n)!=EOF) {
        for(int i=1;i<=n;i++)
            scanf("%d",&a[i].x),a[i].id=i;
        sort(a+1,a+n+1,cmp);
        int l=(1+n)/2;
        for(int i=1;i<=n/2;i++)
            ans[a[i].id]=a[l+1].x,ans[a[i+n/2].id]=a[l].x;
        for(int i=1;i<n;i++)printf("%d ",ans[i]);
        printf("%d\n",ans[n]);
    }
}

Measured memory_bytes: 4480
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
X = LIST()
sorted_X = sorted(X)
kouho1 = sorted_X[N//2-1]
kouho2 = sorted_X[N//2]
for i in range(N):
	if X[i] <= kouho1:
		print(kouho2)
	else:
		print(kouho1)


Measured memory_bytes: 27236
// CODE FESTIVAL 2016 qual A
// 

#include <cstdio>
#define MAX_N 100000
using namespace std;


int N;
int a[MAX_N];
int ans;

int main() {

  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a[i]);
    a[i]--;
  }

  ans = 0;
  for (int i = 0; i < N; i++) {
    if (a[a[i]] == i) {
      ans++;
    }
  }
  ans /= 2;

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

  return 0;

}




Measured memory_bytes: 512
n = input()
arr = []
for i in range(n):
    xi, yi, hi = map(int, raw_input().split())
    arr.append((xi, yi, hi))

for cx in range(101):
    for cy in range(101):
        for k in range(n):
            if arr[k][2] > 0:
                H = abs(arr[k][0]-cx)+abs(arr[k][1]-cy) + arr[k][2]
                break
        flag = 0
        for k in range(n):
            if arr[k][2] != max(H - abs(arr[k][0]-cx) - abs(arr[k][1]-cy), 0):
                flag = 1
                break
        if flag == 0:
            print cx, cy, H
        else:
            continue



Measured memory_bytes: 2692
def levelup(X,N):
    if N==0 and X!=0:
        return 1
    if X==0:
        return 0
    elif X<2**(N+1)-1:
        return levelup(X-1,N-1)
    elif X<2**(N+2)-3:
        return 2**N - 1 + levelup(X-2**(N+1)+1,N-1) + 1
    elif X==2**(N+2)-3:
        return 2**(N+1) - 1

N,X=list(map(int,input().split()))

print(levelup(X,N))

Measured memory_bytes: 3064
import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions
from operator import itemgetter


import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
D = list(map(int, input().split()))
if D[0] != 0:
	print(0)
	exit()


num_list = defaultdict(int)
max_num = max(D)
num_list[0] += 1

for i in range(1, N):
	if D[i] == 0:
		print(0)
		exit()
	num_list[D[i]] += 1

mod = 998244353
ans = 1
for i in range(max_num):
	ans *= pow(num_list[i], num_list[i + 1], mod)
	ans %= mod

print(ans)

Measured memory_bytes: 89512
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  string s;
  cin >> s;
  cout << (s == "ABC" ? "ARC" : "ABC" ) << endl;

  return 0;
}

Measured memory_bytes: 3652
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

a, b, c, d = map(int, input().split())
g = gcd(c, d)
l = int(c*d/g)

print((b - a + 1) - ((b//c - (a-1)//c) + (b//d - (a-1)//d) - (b//l - (a-1)//l)))

Measured memory_bytes: 3060
import math as m
A,B,C=map(int,input().split())
pw=A*7+B
w=C//pw
r=C%pw
d=0
if  0<r<7*A:
    if r%A==0:
        d=r//A
    else:
        d=(r//A)+1
    
elif 7*A<=r<7*A+B: 
    d=7
print(w*7+ d )       


Measured memory_bytes: 5656
#include<bits/stdc++.h>
using namespace std;
long long n,m,a,r,c,h;
string s;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>s;
    	if(s[0]=='M') m++;
    	if(s[0]=='A') a++;
    	if(s[0]=='R') r++;
    	if(s[0]=='C') c++;
    	if(s[0]=='H') h++;
	}
	cout<<m*a*r+m*a*c+m*a*h+a*r*c+a*r*h+r*c*h+m*r*c+m*r*h+m*c*h+a*c*h;
	return 0;
}
//68871358
//76140264
//25446011
//200841159

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

public class Main {

    void run() {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] ps = new int[50];
        List<Integer> primes = primes();

        for (int i = 2; i <= n; i++) {
            int tmp = i;
            for (int p: primes) if (p != 0 && p <= n) {
                int cnt = 0;
                while (tmp % p == 0) {
                    cnt++;
                    tmp /= p;
                }
                ps[p] += cnt;
            }
        }

        // 0: 0, 3: 1, 5: 2, 15: 3, 25: 4, 75: 5
        int[][] dp = new int[16][6];
        // 0 -> 3, 0 -> 5, 0 -> 15, 0 -> 25, 0 -> 75
        // 3 -> 15, 3 -> 75
        // 5 -> 15, 5 -> 25, 5 -> 75
        // 15 -> 75
        // 25 -> 75
        dp[0][0] = 1;
        for (int i = 1; i < 16; i++) {
            for (int j = 0; j < 6; j++) dp[i][j] += dp[i - 1][j];
            if (ps[primes.get(i)] >= 2) {
                dp[i][1] += dp[i - 1][0];
                dp[i][3] += dp[i - 1][2];
                dp[i][5] += dp[i - 1][4];
            }
            if (ps[primes.get(i)] >= 4) {
                dp[i][2] += dp[i - 1][0];
                dp[i][3] += dp[i - 1][1];
                dp[i][4] += dp[i - 1][2];
                dp[i][5] += dp[i - 1][3];
            }
            if (ps[primes.get(i)] >= 14) {
                dp[i][3] += dp[i - 1][0];
                dp[i][5] += dp[i - 1][2];
            }
            if (ps[primes.get(i)] >= 24) {
                dp[i][4] += dp[i - 1][0];
                dp[i][5] += dp[i - 1][1];
            }
            if (ps[primes.get(i)] >= 74) {
                dp[i][5] += dp[i - 1][0];
            }
            debug(dp[i]);
        }

        debug(ps);
        debug(dp[15][5]);
        System.out.println(dp[15][5]);
    }

    List<Integer> primes() {
        boolean[] used = new boolean[50];
        List<Integer> ret = new ArrayList<>();
        // sentinel
        ret.add(0);
        for (int i = 2; i < 50; i++) if (!used[i]) {
            used[i] = true;
            ret.add(i);
            for (int j = i * 2; j < 50; j+=i) used[j] = true;
        }
        return ret;
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int k = sc.nextInt();
        if (Math.abs(a - e) <= k) {
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }
    }
}

Measured memory_bytes: 22484
#include<iostream>

using namespace std;

int x[300],y[300];

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

int main()
{
	int N,n,d;
	while(cin >> N,N)
	{
			
		for(int i = 0;i < N-1;i++)
		{
			cin >> n >> d;
			x[i+1] = x[n] + dx[d];
			y[i+1] = y[n] + dy[d];
		}
		
		int xmin = 10000,xmax = -10000,ymin = 10000,ymax = -10000;
		for(int i = 0;i < N;i++)
		{
			xmin = min(xmin,x[i]);
			xmax = max(xmax,x[i]);
			ymin = min(ymin,y[i]);
			ymax = max(ymax,y[i]);
		}
		
		cout << xmax - xmin + 1 << ' ' << ymax - ymin + 1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3012
#include <bits/stdc++.h>
            using namespace std;
             
            int main() {
              int N;
              cin >> N; 
              double S= 0.0; 
              int A; 
              for(int i=0; i< N; i++){
                cin>> A;
                  S = S + 1.0/((double) A); 
              }
     
              cout<< 1/S << endl;
            }

Measured memory_bytes: 256
# 5858744

H,W = map(int,input().split())
S = [input() for _ in range(H)]
L,R,D,U = [[[0]*W for _ in range(H)] for i in range(4)]

for h in range(H):
    for w in range(W):
        if S[h][w] == '.':
            L[h][w] = L[h][w-1]+1
            U[h][w] = U[h-1][w]+1
        if S[h][W-1-w] == '.':
            R[h][-w-1] = R[h][-w]+1
        if S[H-1-h][w] == '.':
            D[-h-1][w] = D[-h][w]+1

ans = 0
for h in range(H):
    for w in range(W):
        if S[h][w] == '.':
            ans = max(ans,L[h][w]+U[h][w]+R[h][w]+D[h][w]-3)

print(ans)

Measured memory_bytes: 183640
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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 : u32,
        arr : [u32;n],
    );

    let mut arr: Vec<u32> = arr;
    arr.sort();
    let mut alice = 0;
    let mut bob = 0;
    for (i, &x) in arr.iter().rev().enumerate() {
        if i % 2 == 0 {
            alice += x;
        } else {
            bob += x;
        }
    }
    println!("{}",alice - bob);
}

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

struct tool {
    string name,sh;
    int ntime,stime;
    vector<int> edge;
    tool(string name,string sn,int ntime,int stime)
        : name(name), sh(sn), ntime(ntime), stime(stime) {edge.clear();}
};

bool seen[1001];

int dfs(vector<tool> &tv,int v) {
    seen[v] = true;
    int ret = 0;
    for(int i=0; i<tv[v].edge.size(); ++i) {
        if(seen[tv[v].edge[i]]) continue;
        ret += (tv[tv[v].edge[i]].ntime - tv[tv[v].edge[i]].stime);
        ret += dfs(tv,tv[v].edge[i]);
    }
    return ret;
}

void dfs2(vector<tool> &tv,int v) {
    seen[v] = true;
    for(int i=0; i<tv[v].edge.size(); ++i) {
        if(seen[tv[v].edge[i]]) continue;
        dfs2(tv,tv[v].edge[i]);
    }
}

int main() {
    int n;
    string s1,s2;
    int k1,k2;
    while(cin>>n, n) {
        map<string,int> idx;
        vector<tool> tv;

        int ans = 0;
        for(int i=0; i<n; ++i) {
            cin>>s1>>k1>>s2>>k2;
            idx[s1] = i;
            tv.push_back(tool(s1,s2,k1,k2));
            ans += k1;
        }

        for(int i=0; i<n; ++i) {
            if(idx.find(tv[i].sh) == idx.end()) continue;
            int id = idx[tv[i].sh];
            tv[id].edge.push_back(i);
        }

        vector<int> p(n,-1);
        for(int i=0; i<n; ++i) {
            memset(seen, false, sizeof(seen));
            p[i] = dfs(tv,i);
        }

        vector<pair<int,int> > ppv(n);
        for(int i=0; i<n; ++i) {
            ppv.push_back(make_pair(p[i],i));
        }
        sort(ppv.begin(), ppv.end());
        reverse(ppv.begin(), ppv.end());

        memset(seen, false, sizeof(seen));
        for(int i=0; i<ppv.size(); ++i) {
            int v = ppv[i].second;
            if(seen[v]) continue;
            ans -= ppv[i].first;
            dfs2(tv,v);
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1124
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>

using namespace std;





int main()
{
	int t, n, s, f, time;
	
	while (cin >> t)
	{
		if (t == 0) break;
		
		time = 0;
		cin >> n;
		for (int i=0; i<n; i++)
		{
			cin >> s >> f;
			time += f - s;
		}
		
		if (time - t >= 0)
		{
			cout << "OK" << endl;
		} else {
			cout << t - time << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#define N 15
using namespace std;
int jump(int,int);
int X,Y,data[N][N],dp[N][N];
int main(){
  bool q[N][N];
  while(1){
    cin >> X >> Y;
    if(X==0&&Y==0) break;
    for(int i=0;i<Y;i++)
      for(int j=0;j<X;j++) cin >> data[i][j],q[i][j]=false,dp[i][j]=0;
    for(int i=0;i<X;i++)
      if(data[0][i]==0) q[0][i]=true,dp[0][i]=1;
    for(int i=0;i<Y-1;i++){
      for(int j=0;j<X;j++){
	if(q[i][j]==true){
	  if(0<=j-1&&data[i+1][j-1]==0) dp[i+1][j-1]+=dp[i][j],q[i+1][j-1]=true;
	  if(j+1<X&&data[i+1][j+1]==0) dp[i+1][j+1]+=dp[i][j],q[i+1][j+1]=true;
	  if(data[i+1][j]==0) dp[i+1][j]+=dp[i][j],q[i+1][j]=true;
	  else if(data[i+1][j]==2){
	    int r=jump(i+1,j);
	    if(r==-1) dp[Y-1][j]+=dp[i][j];
	    else if(r!=-2) dp[r][j]+=dp[i][j],q[r][j]=true;
	  }
	}
      }
    }
    /*    cout << endl;
    for(int i=0;i<Y;i++){
      for(int j=0;j<X;j++){
	cout << q[i][j] << ' ';
      }
      cout << endl;
    }
    cout << endl;
    for(int i=0;i<Y;i++){
      for(int j=0;j<X;j++){
	cout << dp[i][j] << ' ';
      }
      cout << endl;
      }*/
    int cnt=0;
    for(int i=0;i<X;i++) cnt+=dp[Y-1][i];
    cout << cnt << endl;
  }
  return 0;
}
int jump(int y,int x){
  while(1){
    y+=2;
    if(y<Y&&data[y][x]==1) break;
    if(y>=Y-1) return -1;
    if(data[y][x]==0) return y;
  }
  return -2;
}

Measured memory_bytes: 1160
///                ..:: In The Name Of God ::..
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < n; i++)
#define endl '\n'
#define vi vector<int>
#define vii vector<pii>

using namespace std;

int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    if(K == 1){
        cout << 0 << endl;
    }
    else{
        cout << N-K << endl;
    }
    return 0;
}

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

using namespace std ;

int a[100] , b[100] ;
int n , m ;

int main ()
{
	int i , j , k , res=0 ;
	scanf("%d%d",&n,&m);
	for ( i=1 ; i<=n ; i++ ) scanf("%d",a+i);
	for ( i=0 ; i<=n ; i++ ) 
		for ( j=i+1 ; j<=n+1 ; j++ ) 
		{
			int s1=0 , op=m-i-n+j-1 , cnt=0 ;
			if ( op<0 ) continue;
			for ( k=1 ; k<=i ; k++ ) 
				if ( a[k]>0 ) s1+=a[k];
				else b[++cnt]=a[k];
			for ( k=j ; k<=n ; k++ ) 
				if ( a[k]>0 ) s1+=a[k];
				else b[++cnt]=a[k];
			if ( op>=cnt ) res=max(res,s1);
			else 
			{
				sort(b+1,b+cnt+1);
				// for ( k=1 ; k<=cnt ; k++ ) printf("%d ",b[k]); puts("");
				for ( k=1 ; k<=cnt ; k++ ) s1+=b[k];
				for ( k=1 ; k<=op ; k++ ) s1-=b[k];
				res=max(res,s1);
			}
			// printf("[1,%d] [%d,%d] %d\n",i,j,n,res);
		}
	printf("%d\n",res);
	return 0 ;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int key) {
    Node *x = root;
    Node *y = NIL;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = key;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) x = x->left;
        else x = x->right;
    }

    z->parent = y;

    if (y == NIL) root = z;
    else if (z->key < y->key) y->left = z;
    else y->right = z;

    return;
}

bool find(int key) {
    Node *u = root;
    while (u != NIL && u->key != key) {
        if (key < u->key) u = u->left;
        else u = u->right;
    }
    if (u != NIL) return true;
    else return false;
}

void preParse(Node *u) {
    if (u == NIL) return;
    cout << " " << u->key;
    preParse(u->left);
    preParse(u->right);
    return;
}

void inParse(Node *u) {
    if (u == NIL) return;
    inParse(u->left);
    cout << " " << u->key;
    inParse(u->right);
    return;
}

void print() {
    inParse(root);
    cout << "\n";
    preParse(root);
    cout << endl;
    return;
}

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

    string command;
    int key;
    for (int i = 0; i < m; i++) {
        cin >> command;
        if (command == "insert") {
            cin >> key;
            insert(key);
        } else if(command == "find") {
            cin >> key;
            bool exists = find(key);
            cout << (exists ? "yes" : "no") << endl;
        } else {
            print();
        }
    }

    return 0;
}


Measured memory_bytes: 21904
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int n, y;
  cin >> n >> y;
  rep(i, n+1) rep(j, n+1) {
    int k = n - i - j;
    if (k < 0) continue;
    if (y == 10000*i + 5000*j + 1000*k) {
      printf("%d %d %d\n", i, j, k);
      return 0;
    }
  }
  puts("-1 -1 -1");
  return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int; //任意長整数 
using Real32 = mp::number<mp::cpp_dec_float<32>>;
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
using Rat = boost::rational<Bint>;//有理数*/
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define size(v) (int)(v).size()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

int dp[3010][3010]={0};

signed main(){
    string s,t;
    cin>>s>>t;

    for(int i=1;i <= size(s);i++)
    {
        for(int j=1;j <= size(t);j++)
        {
            if(s.at(i-1)==t.at(j-1)) dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
            else{
                dp[i][j]=max(dp[i][j],dp[i][j-1]);
                dp[i][j]=max(dp[i][j],dp[i-1][j]);
            }
        }
    }
    

    string res="";
    int i=size(s),j=size(t);
    //cout << dp[i][j] << endl;
    
    while(dp[i][j]>0){
        if(dp[i][j]==dp[i][j-1]){
            j--;
        }else if(dp[i][j]==dp[i-1][j]){
            i--;
        }else{
            res = s.at(i-1)+res;
            i--;
            j--;
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 35584
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#define M 1000000007
typedef long long int ll;
#define INF 1000000000000000
int main()
{
    int n,i,j,k;
    cin>>n>>k;
    ll h[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>h[i];
    }
    if(n==2)
    {
        cout<<h[2]-h[1];

    }
    else
    {
    ll dp[n+1];
    for(i=1;i<=n;i++)
    {
        dp[i]=INF;
    }
    dp[1]=0;
    for(i=2;i<=min(k+1,n);i++)
    {
        dp[i]=abs(h[i]-h[1]);
    }
    for(i=2;i<=n;i++)
    {
        for(j=1;j<=k;j++)
        {
            if(i+j<=n)
            {
                dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
            }
        }
    }

    cout<<dp[n];
    }

}


Measured memory_bytes: 1792
def main():
    s = int(input())
    num = [s]

    ans = 1

    for i in range(1000000):
        if num[i] % 2 == 0:
            num.append(num[i]//2)
            if len(set(num)) == ans:
                print(ans+1)
                exit()
            else:
                ans = len(set(num))
        else:
            num.append(num[i]*3+1)
            if len(set(num)) == ans:
                print(ans+1)
                exit()
            else:
                ans = len(set(num))



main()

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

int main(){
    int N;
    cin >> N;
    long long a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    sort(a,a+N);
    long long r[2];
    int s=0;
    int count=0;
    for(int i=N-2;i>=0;i--){
        if(a[i]==a[i+1]) s++;
        if(a[i]!=a[i+1]||i==0){
            if(s==1||s==2){
                r[count]=a[i+1];
                count ++;
            }
            if(s>=3){
                r[count]=a[i+1];
                count++;
                r[count]=a[i+1];
                count ++;
            }
            if(count>=2){
                cout << r[0]*r[1] << endl;
                return 0;
            }
            s=0;
        }
    }
    cout << "0" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
const int inf = 1<<30;

int main() {
  int H, N; cin >> H >> N;
  vector<int> dp(H+1, inf);
  dp[0] = 0;
  for(int i = 0; i < N; i++) {
    int a, b; cin >> a >> b;
    for(int j = 0; j < H; j++) {
      int nj = min(j+a, H);
      dp[nj] = min(dp[nj], dp[j] + b);
    }
  }
  cout << dp[H] << endl;
  return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce

def gcd(nums):
    return reduce(math.gcd, nums)

N = int(input())
A = list(map(int, input().split()))
S = [0 for i in range(1000001)]

for i in range(N):
    S[ A[i] ] += 1

pairwise = True
for i in range(2, 1000001):
    cnt = sum(S[i*j] for j in range(1000000//i + 1))
    pairwise &= (cnt <= 1)

if pairwise:
    print("pairwise coprime")
elif gcd(A) == 1:
    print("setwise coprime")
else:
    print("not coprime")

    


Measured memory_bytes: 205912
#include <iostream>
#include <math.h>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#define int long long
inline int in() {int32_t x ; scanf("%d",&x) ; return x ; }
inline string getStr() {char ch[200000] ; scanf("%s",ch) ; return ch ; }
inline char getCh() {char ch ; scanf(" %c",&ch) ; return ch;}
template<class P, class Q> inline P smin(P &a, Q b) { if (b < a) a = b; return a; }
template<class P, class Q> inline P smax(P &a, Q b) { if (a < b) a = b; return a; }
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 10;
const int MA_LG = 21;
const int base = 29;
vector< pair<int,int> > g[MAX_N];
int res[MAX_N];
bool vis[MAX_N];
int mark[MAX_N];
inline bool dfs(int v , int cst = 0)
{
    
    mark[v] = 1;
    
    for (int pt = 0 ; pt < g[v].size() ; pt ++)
    {
        int u = g[v][pt].second , w = g[v][pt].first;
        if(!mark[u]) {if (dfs(u , w + cst)) return 1;}
        else if (mark[u] == 1 && w + cst < 0) return 1;
    }
    mark[v] ++;
    return 0;
}
int32_t main()
{
    int n = in() , m = in() , source = in();
    for (int i = 0 ; i < m ; i ++)
    {
        int v = in() , u = in() , w = in();
        g[v].push_back({u,w});
    }
    for (int v = 0 ; v < n ; v ++)
        res[v] = 1e18;
    res[source] = 0;
    /*
    if (dfs(0))
    {
        cout << "NEGATIVE CYCLE\n";
        exit(0);
    }
     */
    priority_queue<pair<int , int >> pq;
    pq.push({0,source});
    res[source] = 0;
    while (!pq.empty())
    {
        int v = pq.top().second;
        int di = -pq.top().first;
        pq.pop();
        if (vis[v] && res[v] <= di) continue;
        vis[v] = true;
        res[v] = di;
        for (int pt = 0 ; pt < g[v].size() ; pt ++)
        {
            int u = g[v][pt].first , w = g[v][pt].second;
            if (res[u] > w + di)
            {
                res[u] = w + di;
                pq.push({-w-di , u});
            }
        }
    }
    for (int i = 0 ; i < n ; i ++)
    {
        if (res[i] >= 1e18)
        {
            cout << "INF\n";
        }else
        cout << res[i] << "\n";
    }
    
}

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

using namespace std;

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

    vector<long long> csum_a(n + 1,0), csum_b(n + 1,0);
    for (int i = 1; i <= n; ++i) {
        long long tmp;
        cin >> tmp;
        csum_a[i] = csum_a[i - 1] + tmp;
        csum_b[i] = csum_b[i - 1] + max(tmp, 0LL);
    }

    long long ans = INT64_MIN;
    for (int i = 1; i + k - 1 <= n; ++i) {
        auto left = csum_b[i - 1];
        auto center = max(csum_a[i + k - 1] - csum_a[i - 1], 0LL);
        auto right = csum_b[n] - csum_b[i + k - 1];
        ans = max(ans, left + center + right);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define _CRT_SECURE_NO_WARNINGS
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
  int n,ans = 1;
  int flag = 0;
  cin >> n;
  vector<int> A(n);
  for(int i = 0;i < n;i++){
    cin >> A[i];
  }
  for(int i = 1;i < n;i++){
    int a = A[i]-A[i-1];
    if(flag == -1){
      if(a > 0){
	ans++;
	flag = 0;
      }
    }
    else if(flag == 1){
      if(a < 0){
	ans++;
	flag = 0;
      }
    }else if(flag == 0){ 
      if(a > 0){
	flag = 1;
      }else if(a < 0){
	flag = -1;
      }
    }
  }
  P(ans);
}

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


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

int main() {
    int n; cin >> n;
    long long ans = 0;
    for(int c=1; c<n; c++){
        int k = n -c;
        int cnt = 0;
        int m = sqrt(k);
        for(int i=1; i<=m; i++){
            if(k % i == 0) cnt++;
        }
        ans += cnt*2;
        if(k == m*m && cnt > 0) ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3680
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int taro = 0;
		int hanako = 0;
		int n = Integer.parseInt(s.next());
		for (int i = 0; i < n; ++i) {
			int c = s.next().compareTo(s.next());
			if (c > 0) {
				taro += 3;
			} else if (c == 0) {
				taro++;
				hanako++;
			} else {
				hanako += 3;
			}
		}
		System.out.printf("%d %d\n", taro, hanako);
	}
}

Measured memory_bytes: 20828
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll X,Y;
int main() {
	cin>>X>>Y;
	ll R=0;


	while(X<=Y){
		X*=2;
		R++;
	}
	cout<<R<<endl;
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<P> X(N);
    rep(i, N) {
        int x;
        cin >> x;
        X[i] = P(x, i);
    }
    sort(all(X));
    int cnt = 0, ans[N];
    for (auto v: X) {
        if (cnt >= N / 2) {
            ans[v.second] = X[N / 2 - 1].first;
        } else {
            ans[v.second] = X[N / 2].first;
        }
        cnt++;
    }
    rep(i, N) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 4480
n = int(input())
s = [input() for i in range(n)]
import collections
c = collections.Counter(s).most_common()
fin = [c[0][0]]
for j in range(1,len(c)):
    if c[j][1]==c[j-1][1]:
        fin.append(c[j][0])
        continue
    break
a = sorted(fin)
for kekka in a:
    print(kekka)

Measured memory_bytes: 45072
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long
set < ll> primes;
 
int n,m;

bool isvalid(int x,int y)
{
    return (x>=0 && x<n && y>=0 && y<m);
}
int dx[]={0,0,1,-1,-1,1,1,-1};
int dy[]={1,-1,0,0,-1,1,-1,1};
void Sieve(ll n) 
{ 
    bool prime[n+1];
	for(ll i=0;i<n+1;++i)
		prime[i]=true;
    for (ll p=2;p*p<=n;++p) 
    {
        if (prime[p] == true) 
        {  
            for (ll i=2*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
    for(ll p=2; p<=n; p++) 
       if (prime[p]) 
		primes.insert(p);  
}

ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
        return gcd(b % a, a); 
} 
ll powermod(ll x, ll y){
    if(y==0)
    return 1;
        
    if(y%2==0)
    return (powermod(x,y/2)*powermod(x,y/2))%mod;
    else
    return (((powermod(x,y/2)*powermod(x,y/2))%mod)*x)%mod;
}

void solve()
{
   int n;
   cin>>n;
  
    map<string,int>m;
    m["AC"]=0;
   
    m["WA"]=0;
    m["TLE"]=0;
     m["RE"]=0;
    
    while(n--)
    {
        string s;
        cin>>s;
        m[s]++;
    }
    
   cout<<"AC x "<<m["AC"]<<'\n';
    cout<<"WA x "<<m["WA"]<<'\n';
     cout<<"TLE x "<<m["TLE"]<<'\n';
      cout<<"RE x "<<m["RE"]<<'\n';
    
    
    
    
}

 

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
	int t=1;
//	cin>>t;
	while(t--)solve();
	    
   
}

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

using namespace std;

using ll = long long;

const int MX = 52;

bool can[MX];
int a[MX], b[MX];

bool dp[MX][MX];

void load() {
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < MX; i++) {
        dp[i][i] = true;
        queue<int> q;
        q.push(i);
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (int j = 1; j < MX; j++) {
                if (!can[j]) {
                    continue;
                }
                int x = v % j;
                if (!dp[i][x]) {
                    dp[i][x] = true;
                    q.push(x);
                }
            }
        }
    }
}

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < MX; i++) {
        can[i] = true;
    }
    ll ans = 0;
    for (int i = MX - 1; i >= 1; i--) {
        can[i] = false;
        load();
        bool fl = false;
        for (int j = 0; j < n; j++) {
            if (!dp[a[j]][b[j]]) {
                fl = true;
            }
        }
        if (fl && i == MX - 1) {
            cout << -1 << endl;
            return 0;
        }
        if (fl) {
            can[i] = true;
            ans += (1ll << i);
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        double n = scan.nextInt();
        if(n % 2 == 0){
            System.out.print((double) 1 / 2);
        }else{
            System.out.print(((n + 1.0) / 2) / n);
        }
    }
}

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

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

vector<vector<pair<ll, ll>>> tree;

const ll SZ = 32999;

ll dp[SZ], xr[SZ];

int main() {
	fastInp;

	ll n;
	cin >> n;
	tree.resize(n);

	vector<ll> vec;
	for (int i = 0; i < n - 1; i++) {
		ll u, v, c;
		cin >> u >> v >> c;

		tree[u].push_back({ v, c });
		tree[v].push_back({ u, c });
	}

	ll ans = 0;
	map<ll, ll> cnt;
	for (int i = 0; i < n; i++) {
		ll vl = 0;
		for (auto to : tree[i]) {
			vl ^= to.second;
		}
		cnt[vl]++;
	}

	for (auto cur : cnt) {
		if (cur.first == 0) {
			ans += cur.second;
			continue;
		}

		ans += (cur.second) / 2;
		if (cur.second % 2) vec.push_back(cur.first);
	}

	ll pw = (1ll << vec.size());

	for (int i = 1; i < pw; i++) {
		ll curVl = 0;
		for (int j = 0; j < vec.size(); j++) {
			if ((i >> j) & 1) {
				curVl ^= vec[j];
			}
		}
		xr[i] = curVl;
	}

	for (int i = 1; i < pw; i++) {
		if (xr[i] == 0) dp[i] = 1;
		for (auto m = i; ; m = (m - 1) & i) {
			if (m == i) continue;
			if (xr[m] == 0) dp[i] = max(dp[i], dp[m] + 1);
			if (m == 0) break;
		}
	}

	cout << n - ans - dp[pw - 1];

	return 0;
}

Measured memory_bytes: 10804
import java.util.*;

public class Main{
	public static void main(String args[]) {
		
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int N = s.length();
		int[] child = new int[N];
		Arrays.fill(child, 0);
		
		int[] R = new int[N];
		Arrays.fill(R, 1);
		int[] L = new int[N];
		Arrays.fill(L, 1);
		
		for(int i = 0; i < N - 2; i++) {
			if(s.charAt(i)=='R') {
				if(s.charAt(i + 1) == 'R') {
					if(s.charAt(i + 2) == 'R') {
						R[i + 2] += R[i];
						R[i] = 0;
					}
					else {
						child[i + 2] += R[i];
					}
				}
				else {
					child[i] += R[i];
				}
			}
			else {
				R[i] = 0;
			}
		}
		if(s.charAt(N - 2) == 'L') {
			R[N - 2] = 0;
		}
		else {
			child[N - 2] += R[N - 2];
		}
		
		for(int i = N - 1; i > 1; i--) {
			if(s.charAt(i)=='L') {
				if(s.charAt(i - 1) == 'L') {
					if(s.charAt(i - 2) == 'L') {
						L[i - 2] += L[i];
						L[i] = 0;
					}
					else {
						child[i - 2] += L[i];
					}
				}
				else {
					child[i] += L[i];
				}
			}
			else {
				L[i] = 0;
			}
		}
		if(s.charAt(1) == 'R')L[1] = 0;
		else {
			child[1] += L[1];
		}
		
		for(int i = 0; i < N; i++) {
			System.out.print(child[i]+((i != N-1)?" ":""));
		}
		System.out.println();
	}
}

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

int main(){
  int n,k;
  cin>>n>>k;
  int a=1;
  for(int i=1;i<1000000000;i++){
    a*=k;
    if(a>n){
      cout<<i<<endl;
      break;
    }
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <algorithm>  

using namespace std;

int main(){
    int a, b, k, i, g, ite=0;
    cin >> a;
    cin >> b;
    cin >> k;

    for (i=0; i<100; i++){
        g = 100-i;
        if (a%g==0 & b%g==0){
            ite++;
        }
        if (ite == k) break;
    }

    cout << g << '\n';
}

   

Measured memory_bytes: 256