akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int dist(double a[], int n, int d){
    double s = 0;
    if ( d == 0 ) {
        for (int i = 0; i < n; i++){
            s = max(s, a[i]);
        }
    }
    else{
        for (int i = 0; i < n; i++){
            s += pow(a[i],d);
        }
        s = pow(s,1.0/d);
    }
    printf( "%.10f\n" , s );
    return 0;
    
}

int main(){
    int n, tmp;
    cin >> n;
    double a[n];
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    for (int i = 0; i < n; i++){
        cin >> tmp;
        a[i] = abs(tmp-a[i]);
    }
    dist(a, n, 1);
    dist(a, n, 2);
    dist(a, n, 3);
    dist(a, n, 0);
    return 0;
}



Measured memory_bytes: 3416
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX_N = 100;
int n;
bool cards[2][MAX_N * 2 + 1];
int rem[2];
int points[2];

int main () {
	while (cin >> n, n) {
		fill(cards[0], cards[0] + 2 * n + 1, false);
		points[0] = points[1] = 0;
		rem[0] = rem[1] = n;
		for (int i = 0; i < n; i++) {
			int x;
			cin >> x;
			cards[0][x] = true;
		}
		for (int i = 1; i <= 2 * n; i++) {
			cards[1][i] = !cards[0][i];
		}
		int field = 0;
		for (int turn = 0; rem[0] != 0 && rem[1] != 0; turn = (turn + 1) % 2) {
			int i = field + 1;
			for (; i <= 2 * n; i++) {
				if (cards[turn][i]) {
					field = i;
					cards[turn][i] = false;
					rem[turn]--;
					break;
				}
			}
			if (i == 2 * n + 1) {
				field = 0;
			}
		}
		cout << rem[1] << endl;
		cout << rem[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
N, M = list(map(int, input().split()))
Ls, Rs = [], []
for i in range(M):
    n, m = list(map(int, input().split()))
    Ls.append(n)
    Rs.append(m)

# ll = Ls[0]
# rr  =Rs[0]
# for i in range(M):
#     ll = max(ll, Ls[i])
#     rr = min(rr, Rs[i])
#
# print(rr - ll + 1)
print(max(0, min(Rs) - max(Ls) + 1))



Measured memory_bytes: 11028
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

int main(void){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int ans = 0;
  if((n - 1) % (k - 1) == 0) cout << (n - 1) / (k - 1) << endl;
  else cout << (n - 1) / (k - 1) + 1 << endl;

  return 0;
}


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

int main() {
	int n;
	int num1=0;
	int num2=0;
	int i;
	
	cin >> n;
	
	int array[n];
	for(i=0;i<n;i++){
		cin >> array[i];
	}
	
	for(i=0; i<n; i++){
	    if(num1 < array[i]){
	        num2=num1;
	        num1=array[i];
	    }else if(num2 < array[i]){
	        num2=array[i];
	    }
	}
	
	for(i=0; i<n; i++){
		if(array[i] != num1){
			cout << num1 << endl;
		}
		else{
			cout << num2 << endl;
		}
	}
	
	
	return 0;
}

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

using namespace std;

const int Nmax = 1e5 + 5;
int N,S,Max,p;
int a[Nmax][3],dp[Nmax][3];

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> N;
    for(int i = 1; i <= N; ++i)
    {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
        for(int j = 0; j < 3; ++j)
        {
            for(int k = 0; k < 3; ++k)
                if(j != k)
                    dp[i][j] = max(dp[i - 1][k],dp[i][j]);
            dp[i][j] += a[i][j];
        }
    }
    cout << max({dp[N][0],dp[N][1],dp[N][2]});
    /// cout << dp[N][0] << " " << dp[N][1] << " " << dp[N][2];
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, s, n) for(int i=(s); i<(n); i++)
#define INT_MAX (1<<31) - 1

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> mat;

const int MAX_N = 1 << 17;

class SegTree{
private:
    int dat[2*MAX_N - 1];
public:
    int n;
    SegTree(int n);
    void update(int k, int a);
    int query(int a, int b, int k, int l, int r);
};

SegTree::SegTree(int n_){
    n = 1;
    // 葉の数 n を2のべき乗にする
    while(n < n_) n *= 2;
    REP(i, 2*n-1) dat[i] = INT_MAX;
}

// 配列arrのk番目の値をaに変更
void SegTree::update(int k, int a){
    // arr[k]に対応する葉の節点
    k += n - 1;
    // 葉をaに更新
    dat[k] = a;
    // 木を登りながら各節点の最小値を更新
    while (k > 0){
        k = (k - 1) / 2;
        dat[k] = min(dat[2*k+1], dat[2*k+2]);
    }
}

// [a, b) の最小値を求める
int SegTree::query(int a, int b, int k, int l, int r){
    if (r <= a || b <= l) return INT_MAX;
    if (a <= l && r <= b) return dat[k];
    else{
        // vl:左の子の値, vr:右の子の値 をそれぞれ再帰的に求める
        int vl = query(a, b, 2*k+1, l, (l+r)/2);
        int vr = query(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
}

int main(){
    int n, q; cin >> n >> q;
    vi ans;
    SegTree s(n);
    for(int i=0; i<q; i++){
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0){
            s.update(x, y);
        }else{
            ans.push_back(s.query(x, y+1, 0, 0, s.n));
        }
    }
    REP(i, ans.size()) cout << ans[i] << endl;

}



Measured memory_bytes: 4276
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[18];
int B[18];

int dp[1<<18][18];
int val[1<<18][18];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);
    REP (i, N) scanf("%d", B+i);

    memset(dp, 0x3f, sizeof dp);
    memset(val, 0x3f, sizeof val);
    const int INF = dp[0][0];
    dp[0][0] = 0;
    val[0][0] = -1;

    REP (s, 1<<N) {
	REP (i, N) if (~s>>i&1) {
	    int cost = 0;
	    int face = i;
	    REP (j, i) if (s>>j&1) {
		face--;
	    }
	    for (int j=i+1; j<N; j++) if (s>>j&1) {
		cost++;
		face++;
	    }
	    int v = (face%2? B[i]: A[i]);

	    if (s == 0) {
		val[1<<i][i] = v;
		dp[1<<i][i] = cost;
	    } else {
		REP (j, N) if (s>>j&1) {
		    if (val[s][j] <= v) {
			val[s|(1<<i)][i] = v;
			amin(dp[s|(1<<i)][i], dp[s][j] + cost);
		    }
		}
	    }
	}
    }

    int mask = (1<<N)-1;
    int ans = INF;
    REP (i, N) amin(ans, dp[mask][i]);
    if (ans == INF) puts("-1");
    else printf("%d\n", ans);

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 37120
import java.util.regex.*;
import java.util.*;
public class Main {
    public static void main(String[] args) throws java.io.IOException{
        Scanner scan = new Scanner(System.in);
     while(scan.hasNext()){
    	 String line =scan.nextLine();
    	 Pattern p = Pattern.compile("@(\\d)(.)");
    	 Matcher m = p.matcher(line);
    	while(m.find()){
    		line = m.replaceFirst(repeat("$2",Integer.parseInt(m.group(1))));
    		m = p.matcher(line);
    		 }
    	 System.out.println(line);
     }
    }
    public static String repeat(String s,int n){
    	String str ="";
    	for(int i=0;i<n;i++){
    		str=str.concat(s);
    	}
    	return str;
    }
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    int a,b,n;
    int sum;
    while(cin >> a >> b >> n){
        a%= b;
        sum = 0;
        rep(i,n){
            a*= 10;
            sum += a / b;
            a%= b;
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 1160
N, K = gets.chomp.split.map(&:to_i)
S = gets.chomp.chars
# A, B, C = gets.chomp.split.map(&:to_i)

# TODO(south37) Fix this
init_val = 0
# Count R
0.upto(N-2).each do |i|
  if (S[i] == 'R') && (S[i+1] == 'R')
    init_val += 1
  end
end
# Count L
(N-1).downto(1).each do |i|
  if (S[i] == 'L') && (S[i-1] == 'L')
    init_val += 1
  end
end

rls = []
0.upto(N-2).each do |i|  # Check RL
  if (S[i] == 'R') && (S[i+1] == 'L')
    rls << i
  end
end
lrs = []
0.upto(N-2).each do |i|  # Check LR
  if (S[i] == 'L') && (S[i+1] == 'R')
    lrs << i
  end
end

# p rls
# p lrs

if (K <= lrs.size) && (K <= rls.size)
  r = init_val + 2 * K
else
  # lrs or rls is smaller than K
  if lrs.size == rls.size
    r = init_val + 2 * lrs.size
  else
    min_len = [lrs.size, rls.size].min
    r = init_val + 2 * min_len + 1
  end
end

p r

Measured memory_bytes: 11668
# https://atcoder.jp/contests/abc139/tasks/abc139_c
# めちゃ簡単では

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

ans = 0
cnt = 0
pre = -1
for h in H:
    if h <= pre:
        cnt += 1
    else:
        cnt = 0
    pre = h
    ans = max(ans, cnt)

print(ans)


Measured memory_bytes: 15020
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"
//----------------------------------------------------------------

int main(void) {
  string s;
  cin >> s;

  int n=s.size();
  int ans=1000;
  rep(i,n-2){
    int tmp = (s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
    chmin(ans, abs(tmp-753));
  }
  prt(ans);
}


Measured memory_bytes: 256
#include<stdio.h>
//int A[MAX];
#define MAX 2000001
#define VMAX 10000
void Countingsort(int[],int);
void Countingsort(int A[],int n){
  int i,j,k=0;

  int C[VMAX];
  for(i=0;i<VMAX;i++){
    C[i]=0;
  }
  for(i=0;i<n;i++){
    C[A[i]]++;
  }
  for(i=0;i<VMAX;i++){
    for(j=C[i];j>0;j--){
A[k++]=i;
    }

}
}
int main(){
  int n,i;
  int A[MAX];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  Countingsort(A,n);
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1){
      printf(" ");
  }

}

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

Measured memory_bytes: 8452
import java.util.*;

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

	class Pair{
		int to;
		int w;
		Pair(int to, int w){
			this.to=to;
			this.w=w;
		}
	}

	int N;
	ArrayList<ArrayList<Pair>> g;
	public void run() {
		Scanner sc = new Scanner(System.in);
		N=sc.nextInt();
		g = new ArrayList<>();
		for(int i=0; i<N; i++) {
			g.add(new ArrayList<Pair>());
		}
		for(int i=0; i<N-1; i++) {
			int v1 = sc.nextInt();
			int v2 = sc.nextInt();
			v1--;
			v2--;
			int w = sc.nextInt();
			g.get(v1).add(new Pair(v2, w));
			g.get(v2).add(new Pair(v1, w));
		}
		bfs(0);
		sc.close();
	}

	private void bfs(int r) {
		boolean used[] = new boolean[N];
		int color[] = new int[N];
		ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		q.add(r);
		used[r]=true;
		color[r]=1;
		long ans[] = new long[N];
		ans[r]=0;

		while(!q.isEmpty()) {
			int u = q.poll();
			for(int i=0; i<g.get(u).size(); i++) {
				Pair p = g.get(u).get(i);
				if(used[p.to]) continue;
				ans[p.to]=ans[u]+p.w;
				used[p.to]=true;
				q.add(p.to);
			}
		}

		for(int i=0; i<N; i++) {
			System.out.println(ans[i]%2);
		}
	}
}


Measured memory_bytes: 106528
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] p = new int[M];
		int[] c = new int[N];
		int[] b = new int[N];
		int s = 0;
		int n = 0;
		for(int i=0; i<M; i++) {
			p[i] = (sc.nextInt()-1);
			String a = sc.next();
			if(b[p[i]] == 0) {
				if(a.equals("WA") ){
					c[p[i]]++;
				}else{
					b[p[i]]=1;
				}
			}
		}
		sc.close();
		for(int i=0; i<N; i++) {
			if(b[i]==1) {
				s++;
				n += c[i];
			}
		}
		if(n<0) n=0;
		System.out.println(s + " " + n);
	}

}

Measured memory_bytes: 64876
import queue


def integer_cards(N: int, M: int, A: list, queries: list)->int:
    que = queue.PriorityQueue()

    for a in A:
        que.put(a)

    queries.sort(key=lambda x: -x[1])

    for B, C in queries:
        x = que.get()
        que.put(x)

        if C <= x:
            break

        for _ in range(B):
            x = que.get()

            que.put(max(x, C))

            if C <= x:
                break

    res = 0
    for _ in range(N):
        res += que.get()
    return res


if __name__ == "__main__":
    M = 0

    N, M = map(int, input().split())
    A = [int(s) for s in input().split()]
    queries = [tuple(int(s) for s in input().split()) for _ in range(M)]

    ans = integer_cards(N, M, A, queries)
    print(ans)


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

using namespace std;

int main()
{
	int a,b;
	cin >> a >> b;

	// B is an even number 

	if (a > 12)
	{
		/* tam fiyat */
		cout << b;
	}
	else if (a > 5)
	{
		/* yarı fiyat */
		cout << b / 2;
	}
	else
	{
		/* bedava */
		cout << "0";
	}

    return 0;
}

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

int main(){
    int N;
    long double A;
    long double ans=0;
    cin >>N;
    for(int i=0;i<N;i++){
      cin >>A;
      ans+=1/A;
    }
    ans=1/ans;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N, A, B, C = gets.split.map(&:to_i)
Q = N.times.map{ gets.chomp }

ABC = {'A' => A, 'B' => B, 'C' => C}

result = true
choose = []

until Q.empty?
  q = Q.shift
  h = Q.first
  
  l = q[0]
  r = q[1]
  
  if ABC[l].zero? && ABC[r].zero?
    result = false
    break
  elsif ABC[l] < ABC[r]
    ABC[l] += 1
    ABC[r] -= 1
    choose << l
  elsif ABC[l] > ABC[r]
    ABC[r] += 1
    ABC[l] -= 1
    choose << r
  else
    # After ABC[l] == ABC[r]
    if h.nil? || h.include?(l)
      ABC[l] += 1
      ABC[r] -= 1
      choose << l
    else
      ABC[r] += 1
      ABC[l] -= 1
      choose << r
    end
  end
end

if result
  puts 'Yes'
  puts choose
else
  puts 'No'
end

Measured memory_bytes: 25384
N = int(input())
A = input().split()
A = [int(i) for i in A]

#listの要素を出力
def print_list_val(A):
    s = ''
    for i in range(len(A)):
        s = s + str(A[i])
        if i != len(A) - 1:
            s += " "
    print(s)
    
for i in range(N):
    v = A[i]
    j = i - 1
    while( j >= 0 and A[j] > v):
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print_list_val(A)


Measured memory_bytes: 5604
#include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
#define N 100100
#define LL long long
using namespace std;
int prime[2200],len,n,m,ans;
LL l[N],r[N];
map<LL,int>ma;
int main(){
	for(int i=2;i<2200;i++){
		int flag=1;
		for(int j=2;j<i;j++)
			if(i%j==0) flag=0;
		if(flag) prime[len++]=i;
	}
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		LL a,flag=1,f=1;
		cin>>a;
		for(int j=0;j<len;j++){
			int t=0;
			while(a%prime[j]==0) a/=prime[j],t++;
			t%=3;
			if(t){
				for(int i=t;i<3;i++){
					flag*=prime[j];
					if(flag>1e10) flag=0;
				}
				while(t) f*=prime[j],t--;
			}
		}
		ma[f*a]++,l[i]=f*a,r[i]=flag;
		LL w=(LL)sqrt(a);
		if(w*w!=a){
			if(a*r[i]<=1e10) r[i]*=a; else r[i]=0;
			if(a*r[i]<=1e10) r[i]*=a; else r[i]=0;
		}
		else{
			if(r[i]*w<=1e10) r[i]*=w;
			else r[i]=0;
		}
	}
	for(int i=0;i<n;i++){
		if(l[i]==1) continue;
		ans+=max(ma[l[i]],ma[r[i]]);
		ma[l[i]]=ma[r[i]]=0;
	}
	if(ma[1]) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 12032
#include<iostream>
#include <math.h>       /* sin */
using namespace std;


int main() {
	int n;
	int t;
	cin>>n;
	n = n %10;
	if(n== 2 || n== 4 || n == 5 || n == 7 || n == 9)
		cout<<"hon"<<endl;
	else if (n == 3)
		cout<<"bon"<<endl;
	else 
		cout<<"pon"<<endl;
	
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int                     long long   
#define double                  long double
#define endl                    "\n"
#define pb                      push_back
#define PI                      3.1415926535897932384626433832795l
#define F                       first
#define S                       second
#define mp                      make_pair
#define f(i,n)                  for(int i=0;i<n;i++)
#define fastio                  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)                  (v).begin(),(v).end()
#define rall(v)                 (v).rbegin(),(v).rend()
#define gcd(a,b)                __gcd((a),(b))
#define fill(a,value)           memset(a,value,sizeof(a));
#define minn(v)                 *min_element(v.begin(), v.end());
#define maxx(v)                 *max_element(v.begin(), v.end());
#define print(x)                cout<<(x)<<endl;
#define sum(v)+x                accumulate(v.begin(), v.end(),x);
#define debug(x)                cout<<#x<<'='<<(x)<<endl;
typedef pair<int,int>           pii;
typedef vector<int>             vi;
const int mod=1e9+7; 

signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int n;
    cin>>n;
    vi a(n);
    f(i,n)cin>>a[i];
    vi suf(n,0);
    suf[n-1]=a[n-1];
    suf[n-1]%=mod;
    int mod=1e9+7;
    for(int i=n-2;i>=0;i--)
    {
        suf[i]=suf[i+1]+a[i];
        suf[i]%=mod;
    }
    int ans=0;
    for(int i=0;i<n-1;i++)
    {
        ans+=((a[i]*suf[i+1])%mod);
    }
    cout<<ans%mod;
    
    
    return 0;
}

Measured memory_bytes: 6280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int x;
    cin >> x;
    if(x >= 400 && x <= 599) cout << 8 << endl;
    else if(x >= 600 && x <= 799)cout << 7 << endl;
    else if(x >= 800 && x <= 999)cout << 6 << endl;
    else if(x >= 1000 && x <= 1199)cout << 5 << endl;
    else if(x >= 1200 && x <= 1399)cout << 4 << endl;
    else if(x >= 1400 && x <= 1599)cout << 3 << endl;
    else if(x >= 1600 && x <= 1799)cout << 2 << endl;
    else if(x >= 1800 && x <= 1999)cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int main(){
    string s,t; cin >> s >> t;
    map <char,char> mp1,mp2;
    rep(i,s.size()){
        mp1.insert(make_pair(s[i],t[i]));
        mp2.insert(make_pair(t[i],s[i]));
    }
    rep(i,s.size()){
        if(mp1.at(s[i]) != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i,s.size()){
        if(mp2.at(t[i]) != s[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmin(x,y) x = min(x,y)


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

  if (N % 2 == 0) cout << N / 2 << endl;
  else cout << N / 2 + 1 << endl;


  return 0;
}

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

string s;
int ans0,ans1;

int main()
{
    cin>>s;
    for (size_t i=0;i<s.size();i++)
    {
        if (i&1)
        {
            if (s[i]=='0') ans0++;
            else ans1++;
        }
        else
        {
            if (s[i]=='0') ans1++;
            else ans0++;
        }
        
    }
    cout<<min(ans0,ans1);
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double N,D,X,Y,d,count=0;
    cin>>N>>D;
    for(int i=0;i<N;i++)
    {
        cin>>X>>Y;
        d=sqrt((X*X)+(Y*Y));
        if(d<=D){
           count++;
        }

    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3836
//Radhe Radhe
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//using namespace boost::multiprecision;
//#include<boost/math/common_factor.hpp>
#include <ext/numeric>
using namespace __gnu_cxx;
using namespace std;
#define int long long
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define array(a,n) int a[n]; for(int i=0;i<n;i++) cin>>a[i];
#define loop(i,a,b,x) for(int i=a;i<b;i+=x)
const int MOD = 1000000007;

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        int n, a[25][25] = {}, dp[1 << 22] = {};
        cin >> n;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                cin >> a[i][j];
            }
        }
        dp[0] = 1;
        for (int i = 0; i < (1 << n); i++) {
            int cnt = __builtin_popcount(i);
            for (int j = 0; j < n; j++) {
                if ((i & (1 << j)) && a[cnt - 1][j]) {
                    (dp[i] += dp[i ^ (1 << j)]) %= MOD;
                }
            }
        }
        cout << dp[(1 << n) - 1] << endl;
    }
    return 0;

}



Measured memory_bytes: 33024
#include <bits/stdc++.h>
typedef long long ll;
int main(int argc, char const *argv[]) {
    ll a, b, x;
    std::cin >> a >> b >> x;
    if (a % x == 0) {
        std::cout << (b - a - b % x) / x + 1 << '\n';
    } else {
        std::cout << (b - a - x + a % x - b % x) / x + 1 << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n = ni()
    a = nl()
    m = 10**5 + 5
    l = [0]*m
    s = 0
    for x in a:
        l[x] += 1
        s += x
    q = ni()
    for _ in range(q):
        b, c = nm()
        v = l[b]
        s += (c - b)*v
        l[b] = 0
        l[c] += v
        print(s)
    return

solve()


Measured memory_bytes: 20472
#include<bits/stdc++.h>
//#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1000000007;
const int INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
 
signed main(){
    int n, k, x = 1;
    cin >> n >> k;
    for(int i = n; i > 0; i--){
        x = min(x + k, x * 2);
    }
    cout << x << endl;
}

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

using namespace std;

#define int long long 
#define M 1000000007

signed main(){
//	int t;
//	cin >> t;
//	while(t--){
		int n;
		cin >> n;
		int a[n];
		int ans=0;
		for(int i=0;i<n;i++){
			cin >> a[i];
			if(i!=0){
				if(a[i]<a[i-1]){
					ans+=(a[i-1]-a[i]);
					a[i]=a[i-1];
				}
			}
		}
		cout << ans << endl;
//	}
}
 

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

int main() {
  int n;
  cin >> n;
  int a[n], b[n];

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

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

  int count = 0;
  for (int j = 0; j < n; j++ ) {
    int tmp_count = 0;
    for (int i = 0; i <= j; i++) {
      tmp_count += a[i];
    }
    for (int i = j; i < n; i++) {
      tmp_count += b[i];
    }
    count = max(count, tmp_count);
  }

  cout << count << endl;

}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;
const long long inf = 1e15;

vector<pair<int, int>> g[N];
long long D[N];

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int l, r, c; scanf("%d%d%d", &l, &r, &c);
    g[l-1].emplace_back(r-1, c);
  }
  for (int i = 1; i < n; ++i) {
    g[i].emplace_back(i-1, 0);
    D[i] = inf;
  }
  priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq;
  pq.emplace(0, 0);
  D[0] = 0;
  while (!pq.empty()) {
    long long d = pq.top().first, u = pq.top().second;
    pq.pop();
    if (d > D[u]) continue;
    for (const auto &p: g[u]) {
      if (D[p.first] <= D[u]+p.second) continue;
      pq.emplace(D[u]+p.second, p.first);
      D[p.first] = D[u]+p.second;
    }
  }
  if (D[n-1] == inf) D[n-1] = -1;
  printf("%lld", D[n-1]);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 10892
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin>>x;
    ll ans=x/500;
    ans*=1000;
    x%=500;
    x/=5;
    x*=5;
    cout << ans+x<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int m=1e9+7;
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    fastio
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<n;++i){
    	if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
    		++cnt;
    		i+=2;
    	}
    }
    cout<<cnt;
    return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int maxx=x,miny=y,xd,yd;
    rep(i,n){
        cin>>xd;
        maxx=max(maxx,xd);
    }
    rep(i,m){
        cin>>yd;
        miny=min(miny,yd);
    }
    if(maxx<miny) cout<<"No War";
    else cout<<"War";
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int A;
    double sum = 0; //逆数の和
    for(int i = 0; i < N; i++){
        cin >> A;
        sum += (double)1/A;
    
    }
    cout << 1/sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int ha,ma,hb,mb,k;
  cin>>ha>>ma>>hb>>mb>>k;

  int a=ha*60+ma, b=hb*60+mb;
  cout<<max(0, b-a-k)<<endl;

  return 0;
}




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

int n, k;
vector<pair<int, int>> ans;

void solve();

int main() {
  cin >> n >> k;
  solve();
  if(ans.size() == 0)
    cout << -1 << endl;
  else
    cout << ans.size() << endl;
  for(int i = 0; i < ans.size(); ++i)
    cout << ans[i].first + 1 << " " << ans[i].second + 1
         << endl;
  return 0;
}

void solve() {
  int num = (n - 1) * (n - 2) / 2;
  if(num < k) return;
  for(int i = 1; i < n; ++i) ans.push_back({0, i});
  if(k == num) return;
  int cnt = 0;
  for(int i = 1; i < n; ++i)
    for(int j = i + 1; j < n; ++j) {
      ans.push_back({i, j});
      if(++cnt + k == num) return;
    }
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#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;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];

    vector<ll> sum(N, 0);
    vector<ll> diff(N, 0);

    sum[0] = a[0];
    rep(i, N) { sum[i + 1] = sum[i] + a[i + 1]; }

    diff[N - 1] = a[N - 1];
    for (ll i = N - 1; i >= 1; i--) {
        diff[i - 1] = diff[i] + a[i - 1];
    }

    // repv(sum) { cout << *it << "\t"; }
    // cout << endl;

    // repv(diff) { cout << *it << "\t"; }
    // cout << endl;

    ll ans = INF;

    rep(i, N - 1) { chmin(ans, abs(sum[i] - diff[i + 1])); }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7940
A,B=map(int,input().split())

print(A*B)

##B
#A,B,C,K = map(int,input().split())

#if A >= K:
#	print(K)
#else:
#	if B >= K - A:
#		print(A)
#	else:
#		print(A - (K - A - B))




##A
#S = input()
#T = input()


Measured memory_bytes: 9144
#include <bits/stdc++.h>
#include <unordered_map> 
using namespace std; 
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI1 3.14159265358979311599796346854418516159057617187500
 
typedef long long int ll;  
 
 
int main() 
{ 
    FIO
    int t;
    t=1;
 
    while(t--)
    {
        string s,t;
        cin >> s >> t;
 
        bool f=0;
        for(int i=0;i<(int)s.length();i++)
        {
            if(s[i]!=t[i])
            {
                f=1;
                break;
            }
        }
 
        if((int)s.length()+1==(int)t.length() && !f)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
 
    return 0; 
} 

Measured memory_bytes: 3556
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define LL long long 
#define LD long double
int tot,pr[1000005],ivmind[1000005];
void es()
{
	for(int i=2;i<=1000000;i++)
	{
		if(!ivmind[i])pr[++tot]=i;
		for(int j=1;j<=tot&&pr[j]*i<=1000000;j++)
		{
			ivmind[i*pr[j]]=1;
			if(!(i%pr[j]))break;
		}
	}
}
int n;
int main()
{
	es();
	cin>>n;
	for(int i=1;i<=tot;i++)
		if(pr[i]>=n)
		{
			cout<<pr[i];
			return 0;
		}
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

typedef long double Real;
#define EPS 1e-13
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

#define INF 1145141919
#define MP make_pair<int,int>

int score[1141919];
set<pii> S;
int main(){
  int n,q;
  cin>>n>>q;
  REP(i,n){
    S.insert(MP(0,INF-(i+1)));
  }
  REP(_,q){
    int a,v;
    cin>>a>>v;
    S.erase(MP(score[a],INF-a));
    score[a] += v;
    S.insert(MP(score[a],INF-a));
    pii top = *S.rbegin();
    printf("%d %d\n",INF-top.second, top.first);
  }
  return 0;
}

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

int main(){
  long i,j,N,K,M;
  cin>>N>>K;
  M=(N-2)*(N-1)/2;
  if(M<K){
    printf("-1\n");
    return 0;
  }
  M=N+M-K-1;
  printf("%ld\n",M);
  for(i=1;i<=N;i++){
    for(j=i+1;j<=N;j++){
      printf("%ld %ld\n",i,j);
      if(--M==0)return 0;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int a[1000000] ;

int main ( ) {
    int n , x ;

    int i , k , sign ;

    while ( ~scanf ( "%d" , &n ) ) {
        k = 1 , sign = 1 ;
        for ( i = 0 ; i < n ; i++ ) {
            scanf ( "%d" , &x ) ;
            if ( i == 0 ) {
                a[n/2] = x ;
            }
            if ( i != 0 && n % 2 == 0 && sign )  {
                a[n/2-k] = x ;
                sign = 0 ;
            }

            else if ( i != 0 && n % 2 == 0 && sign == 0 ) {
                a[n/2+k] = x ;
                sign = 1 ;
                k++ ;
            }

            if ( i != 0 && n % 2 != 0 && sign )  {
                a[n/2+k] = x ;
                sign = 0 ;
            }

            else if ( i != 0 && n % 2 != 0 && sign == 0 ) {
                a[n/2-k] = x ;
                sign = 1 ;
                k++ ;
            }

        }

        for ( i = 0 ; i < n ; i++ ) {
            printf ( "%d" , a[i] ) ;
            if ( i == n - 1 ) {
                printf ( "\n" ) ;
            }
            else {
                printf ( " " ) ;
            }
        }
    }

    return 0 ;
}


Measured memory_bytes: 3576
use std::io::{self};
use std::iter::FromIterator;

fn main(){
    let a = read_arr();
    if a.get(0) <= Some(&8) && a.get(1) <= Some(&8) {
        println!("Yay!");
    } else {
        println!(":(");
    }
}

fn read_arr() -> Vec<i32>{
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    let splited = s.split(" ").map(|x| x.trim().parse::<i32>().unwrap());
    Vec::from_iter(splited)
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdlib>
#include<vector>
using namespace std;

void makeSet(vector<int>* set, int size);
int find(vector<int> *v, int x);
void unite(vector<int> *v, int root1, int root2);
void printV(vector<int>* v);

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

    vector<int> set;
    makeSet(&set, n);

    int com, x, y;
    for(int i=0; i<q; i++){
        cin >> com >> x >> y;

        switch(com){
        case 0 :
            unite(&set, find(&set, x), find(&set, y));
            break; 
        case 1 :
            find(&set, x) == find(&set, y) ? cout << "1" : cout << "0";
            cout << endl;
            break;
        }
        // printV(&set);
    }
    
    return 0;
}

void makeSet(vector<int>* set, int size)
{
    for(int i=0; i<size; i++) set->push_back(i);
}

int find(vector<int> *v, int x)
{
    if( !(x >= 0 && x < v->size()) ) exit(1);

    while( v->at(x) != x ){
        x = v->at(x);
    }
    return x;
}

void unite(vector<int> *v, int root1, int root2)
{
    if( find(v, root1) == find(v, root2) ) return;
    if( !( (root1>=0 && root1<v->size()) && (root2>=0 && root2<v->size()) ) ) return;

    v->at(root1) = root2;
}

void printV(vector<int>* v)
{
    for(int i=0; i<v->size(); i++) cout << v->at(i) << " ";
    cout << endl;
}

Measured memory_bytes: 1320
#include<stdio.h>
int main()
{char a[50],p;
int s,i,j,k;
while(~scanf("%s",a))
 {if(a[0]==a[1]&&a[1]==a[2]&&a[2]==a[3])
   printf("No\n");
   else
 {
 if(a[0]==a[1]&&a[2]==a[3]||a[0]==a[2]&&a[1]==a[3]||a[0]==a[3]&&a[1]==a[2])
   printf("Yes\n");
   else printf("No\n");}
  
  
    
}
}

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

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

Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use proconio::fastout;
use proconio::input;
//use proconio::marker::*;
//use std::collections::HashSet;
// use std::cmp::*;
//use std::collections::VecDeque;

fn main() {
    input! {
       A:i32,B:i32,C:i32
    }
    if A == B && B != C || A == C && A != B || B == C && A != B {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

using namespace std;

int dp[205][205][205];

int gcd(int a, int b, int c)
{
    //greatest common divisor

    if (dp[a][b][c] != 0)
        return dp[a][b][c];

    int x = min(a, b);
    x = min(x, c);

    while(a%x != 0 || b%x != 0 || c%x != 0)
    {
        x--;
    }

     dp[a][b][c] = x;
     dp[b][a][c] = x;
     dp[b][c][a] = x;
     dp[a][c][b] = x;
     dp[c][a][b] = x;
     dp[c][b][a] = x;

    return x;
}

int main()
{
    int k; cin >> k;
    long long sum = 0;
    for (int i = 1; i <= k; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            for (int z = 1; z <= k; z++)
            {
                sum += gcd(i, j, z);
            }
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 36276
import java.util.Scanner;

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

    int a = sc.nextInt();
    String b = sc.next();
    String c = sc.next();

    char[] bC = b.toCharArray();
    char[] cC = c.toCharArray();

    String result = "";
    for (int i = 0; i < a; i++) {
      result = result + bC[i] + cC[i];
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 22608
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,a[10000],i,j,sum=0;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    if(sum>n)
    {
        cout<<-1<<endl;
    }
    else{
        cout<<n-sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll n;
ll a[1005];
int main(){FAST;
	dofloat;
cin>>n;
for(ll i=1;i<=n;i++)cin>>a[i];
	ld core=0;
for(ll i=1;i<=n;i++){
	ld val = (ld)1/a[i];
	core+=val;
}
cout<<1/core;
return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.IntSummaryStatistics;

public class Main {

    public static void main(String[] args) throws NumberFormatException, IOException{
        IntSummaryStatistics iss;
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            br.readLine(); //1行目は捨てる
            iss = Arrays.stream(br.readLine().split(" "))
                    .mapToInt(Integer::parseInt)
                    .summaryStatistics();
        }

        System.out.printf("%d %d %d%n", iss.getMin(), iss.getMax(), iss.getSum());
    }
}



Measured memory_bytes: 32844
#include <bits/stdc++.h>
 
using namespace std;
 
#define NOTFOUND -1
typedef vector<int> Vec;
 
bool check(Vec &p){
    int t = p[0];
    for(int i = 0 ; i < 8 ; i++){
	if(t != p[i+1]) return false;
    }
    if(p[9] != p[10] || p[9] != p[11] || p[10] != p[11]) return false;
    if(p[12] != p[13] || p[12] != p[14] || p[13] != p[14]) return false;
    if(p[15] != p[16] || p[15] != p[17] || p[16] != p[17]) return false;
    if(p[18] != p[19] || p[18] != p[20] || p[19] != p[20]) return false;
    t = p[21];
    for(int i = 0 ; i < 8 ; i++){
	if(t != p[22+i]) return false;
    }
    return true;
}
 
void roll(int N,Vec &v){
    if(N == 0){
	swap(v[0],v[23]);
	swap(v[3],v[26]);
	swap(v[6],v[29]);
	swap(v[9],v[20]);
	swap(v[15],v[17]);
    }else if(N == 1){
	swap(v[2],v[21]);
	swap(v[5],v[24]);
	swap(v[8],v[27]);
	swap(v[11],v[18]);
	swap(v[12],v[14]);
    }else if(N == 2){
	swap(v[0],v[27]);
	swap(v[1],v[28]);
	swap(v[2],v[29]);
	swap(v[14],v[15]);
	swap(v[18],v[20]);
    }else if(N == 3){
	swap(v[6],v[21]);
	swap(v[7],v[22]);
	swap(v[8],v[23]);
	swap(v[12],v[17]);
	swap(v[9],v[11]);
    }
}
 
int solve(Vec &puzzle){
    map<Vec,int> cost;
    queue<Vec> Q;
    cost[puzzle] = 0;
    Q.push(puzzle);
    while(!Q.empty()){
	Vec now = Q.front(); Q.pop();
	if(check(now)) return cost[now];
	for(int i = 0 ; i < 4 ; i++){
	    Vec next = now;
	    roll(i,next);
	    if(!cost.count(next)){
		cost[next] = cost[now] + 1;
		Q.push(next);
	    }
	}
    }
    return NOTFOUND;
}
 
int main(){
    int Tc;
    cin >> Tc;
    while(Tc--){
	Vec puzzle(30);
	for(int i = 0 ; i < 30 ; i++){
	    cin >> puzzle[i];
	}
	cout << solve(puzzle) << endl;
    }
    return 0;
}

Measured memory_bytes: 3196
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
//int p = 998244353;
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int num_lp(int a, vel &nex) {
	unordered_set<int> se;
	int ans = 0;
	while (true) {
		if (se.find(a) != se.end()) {
			break;
		}
		se.insert(a);
		a = nex[a];
		ans++;
	}
	return ans;
}
int find_cr(int a, vel &nex) {
	unordered_set<int> se;
	while (true) {
		if (se.find(a) != se.end()) {break;}
		se.insert(a);
		a = nex[a];
	}
	return num_lp(a, nex);
}
int inf = 2000000000;
vvel dp;
int solve(vvel &sum, int i, int j, bool is_f) {
	int h = sum.size(); h--;
	int w = sum[0].size();
	if (i == h || j == w) { return 0; }
	if (dp[i][j] == inf) {
		int ans1 = solve(sum, i + 1, j, !is_f);
		int ans2 = solve(sum, i, j + 1, !is_f);
		ans2 += sum[i][j];
		if (is_f) {
			dp[i][j] = min(ans1, ans2);
		}
		else {
			dp[i][j] = max(ans1, ans2);
		}
	}
	return dp[i][j];
}
int rui10(int a) {
	if (a == 0) { return 1; }
	return 10 * rui10(a - 1);
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	if (b == 0) { return a; }
	return gcd(b, a%b);
}
vel mul(vel &a, vel &b) {
	int n = a.size();
	vel c(n,-1);
	rep(i, n) {
		rep(j, n) {
			if (a[i] >= 0 && b[j] >= 0) {
				mmax(c[(i + j) % n], a[i] + b[j]);
			}
		}
	}
	return c;
}
vel rui(vel &a, int n) {
	if (n == 1) { return a; }
	vel b = rui(a, n / 2);
	b = mul(b, b);
	if (n % 2 == 1) {
		b = mul(b, a);
	}
	return b;
}
signed main(){
	int d, c; cin >> d >> c;
	cout << c * d << endl;
	return 0;
}


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

int main() {

  int n,a,b,c,k;
  cin >> n;
  for ( int i = 0; i < n; i++ ) {

    cin >> a >> b >> c;

    bool flag = false;
    for ( int j = 0; j < 3; j++ ) {

      if ( a*a == b*b + c*c && a < b+c ) {
	flag = true;
	break;
      }

      k = a;
      a = b;
      b = c;
      c = k;

    }

    if ( flag ) {
      cout << "YES" << endl;
    }else {
      cout << "NO" << endl;
    }

  }

  return 0;

}

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

int main(){
    string S;
    cin >> S;
    int len = 0, ans = 0;
    for(char c : S){
        if(c == 'R'){
            len++;
            ans = max(len, ans);
        }else{
            len = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620