akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long int
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define inf 1000000000000000001
#define all(x) (x).begin(),(x).end()
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vec(dt) vector<dt>
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v)) 
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || click to see test details "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(auto i=s;i<n;i++)
using namespace std;



signed main()
{
	fastio(0);
	int x,y,z;
	cin>>x>>y>>z;
	swap(x,y);
	swap(x,z);
	cout<<x<<" "<<y<<" "<<z<<endl;
	return 0;		
} 

Measured memory_bytes: 256
program ABC155_B
  integer,allocatable::A(:)
  read(*,*)N
  allocate(A(N))
  read(*,*)A
  k=0
  do i=1,N
     if(A(i)/2*2==A(i)) then
        if(mod(A(i),3)/=0 .and. mod(A(i),5)/=0) then
           k=k+1
           exit
        end if
     end if
  end do
  if(k==0) then
     write(*,*)'APPROVED'
  else
     write(*,*)'DENIED'
  end if
end program ABC155_B

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 2222;
int t[MN];
int main() {
    ll n,x;
    cin>>n>>x;
    for(int i = 0; i < n; ++i) {
        cin>>t[i];
    }
    ll ans = 1e18;
    for(int i = 0; i < n; ++i) {
        multiset<int> st;
        for(int j = 1; j <= i; ++j) {
            st.insert(t[n-j]);
        }
        ll qwe = i*x;
        for(int j = 0; j < n; ++j) {
            st.insert(t[j]);
            qwe += *st.begin();
            st.erase(st.find(t[(j-i+n)%n]));
        }
        ans = min(ans, qwe);
    }
    cout<<ans<<'\n';
}



Measured memory_bytes: 384
'use strict'

const inArray = (needle, haystack) => haystack.some(item => item === needle)

const div = (num) => {
    let res = []
    for(let i = 1; i <= num; i++){
        if(num % i === 0){
            res.push(i)
        }
    }
    return res
}

const ans = (div1, div2) => {
    let res = []

    div1.forEach(v => {
        if (inArray(v, div1) && inArray(v, div2)) {
            res.push(v)
        }
    })
    return res
}

const main = (input) => {
    input = input.split(' ').map(v => Number(v))
    const a = input[0]
    const b = input[1]
    const k = input[2]

    const aDiv = div(a)
    const bDiv = div(b)

    const answer = ans(aDiv, bDiv)
    console.log(answer.reverse()[k - 1])
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
# -*- coding: utf-8 -*-
def solve():
    N = int(input())
    Z = [tuple(map(int, input().split())) for _ in [None]*N]
    p = set(z%2 for z in map(sum,Z))
    if len(p) == 2:
        res = '-1'
    else:
        res = ''
        mode, *_ = p
        mode = 1-mode
        D = [2**i for i in range(30,-1,-1)]
        res += str(31+mode)
        res += '\n' + ' '.join(str(d) for d in D+[1]*mode)
        wdict = {(True, True):('R', (1,0)), (True, False):('U', (0,1)), (False, False):('L',(-1,0)), (False, True):('D',(0,-1))}
        for x, y in Z:
            x -= mode
            W = '\n'
            for d in D:
                w, (a, b) = wdict[x+y>0, x-y>0]
                W += w
                x -= a*d
                y -= b*d
            W += 'R'*mode
            res += W
    return str(res)

if __name__ == '__main__':
    print(solve())

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

int main(){
    int R, G, B, N;
    scanf("%d%d%d%d", &R, &G, &B, &N);
    long long ans = 0;
    for(int r = 0; r < N / R + 1; r++){
        for(int g = 0; g < N / G + 1; g++){
            int b = N - r * R - g * G;
            if(b >= 0 && b % B == 0)ans++;
        }
    }
    printf("%lld\n", ans);
    return 0;
}



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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b;
  cin >> a >> b;
  if(a >= 13) {
    cout << b << '\n';
  } else if (a >= 6 && a < 13) {
    cout << b / 2 << '\n';
  } else {
    cout << 0 << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
x = [-1]*n
for i in range(n):
    x[i] = list(map(int, input().split()))

ans = [[0]*3 for i in range(n)]
ans[0] = x[0]

for k in range(1,n):
    for j in range(3):
        ans[k][j] = max(ans[k-1][(j+1)%3], ans[k-1][(j+2)%3]) + x[k][j]

print(max(ans[n-1]))


Measured memory_bytes: 50176
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt(), k = sc.nextInt();
        int[] x = new int[n];
        List<Integer> l = new ArrayList<>();
        List<Integer> r = new ArrayList<>();
        r.add(0);
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            if (x[i] >= 0) {
                r.add(x[i]);
            } else {
                l.add(x[i]);
            }
        }
        l.add(0);
        Collections.reverse(l);

        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < k; i++) {
            int tmpr = Integer.MAX_VALUE, tmpl = Integer.MAX_VALUE;
            try {
                tmpr = r.get(i) * 2 + Math.abs(l.get(k - i));
            } catch (IndexOutOfBoundsException ignored) {
            }
            try {
                tmpl = Math.abs(l.get(i)) * 2 + r.get(k - i);
            } catch (IndexOutOfBoundsException ignored) {
            }
            ans = Math.min(Math.min(tmpr, tmpl), ans);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 96912
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(X); sll(Y); sll(Z); sll(K);
	VLL As, Bs, Cs;
	rep(i, 0, X)	As.push_back(scanLong());
	rep(i, 0, Y)	Bs.push_back(scanLong());
	rep(i, 0, Z)	Cs.push_back(scanLong());
	sort(As.begin(), As.end(), greater<LL>());
	sort(Bs.begin(), Bs.end(), greater<LL>());
	sort(Cs.begin(), Cs.end(), greater<LL>());
	VLL ans;
	rep(i, 0, X) {
		rep(j, 0, Y) {
			rep(k, 0, Z) {
				if((i+1)*(j+1)*(k+1) <= K)	ans.push_back(As[i] + Bs[j] + Cs[k]);
				else	break;
			}
		}
	}
	sort(ans.begin(), ans.end(), greater<LL>());
	rep(i, 0, K)	pll(ans[i]), nl;
}


Measured memory_bytes: 1412
'use strict'

const main = arg => {
    const input = arg.trim().split("\n");
    const rectangle = [];
    input.some(str => {
        if(str === "0 0"){ return true; } //break;
        const num = str.split(" ");
        const height = parseInt(num[0], 10);
        const width = parseInt(num[1], 10);

        [...Array(height)].forEach((obj, h) => {
            var len = "";
            [...Array(width)].forEach((obj,w) => {
                if([0, height-1].includes(h)){
                    len += "#";
                } else {
                    len += [0, width-1].includes(w) ? "#" : ".";
                }
            });
            rectangle.push(len);
        });
        rectangle.push("");
    });

    console.log(rectangle.join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 20724
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N,tp;

int main(){
    cin >> N;
    set<int> st;
    int ct = 0;
    rep(i,N){
        cin >> tp;
        if(tp >= 3200) ct++;
        else st.insert(tp/400);
    } 
    int s = sz(st);
    if(sz(st) == 0) s = 1;
    
    cout << s << " " << ct+sz(st) << '\n';
    
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <vector>
#include <algorithm>

#define int64 long long int
using namespace std;

int main()
{
	int a, b;
	bool line, flag, year[3000]={0};
	for(int i=1; i<3000; i++){
		if(i % 4 == 0){
			if(i % 100 == 0){
				if(i % 400 == 0) year[i] = true;
				else year[i] = false;
			}else year[i] = true;
		}
	}

	line = false;
	while(1){
		cin >> a >> b;
		if(a == 0) break;

		if(line)
			cout << endl;
		line = true;

		flag = false;
		for(int i=a; i<=b; i++){
			if(year[i]){
				flag = true;
				cout << i << endl;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <set>
#include <deque>
#include <climits>

using namespace std;

int c = 0;

void merge(deque<int>& A, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;

    // L[0...n1], R[0...n2] を生成
    deque<int> L;
    deque<int> R;
    for (int i = 0; i < n1; ++i) {
        L.push_back(A[left + i]);
    }
    for (int i = 0; i < n2; ++i) {
        R.push_back(A[mid + i]);

    }
    L.push_back(INT_MAX);
    R.push_back(INT_MAX);

    int i = 0;
    int j = 0;
    for (int k = left; k < right; ++k) {
        ++c;
        if (L[i] <= R[j]) {
            A[k] = L[i];
            ++i;
        }
        else {
            A[k] = R[j];
            ++j;
        }

    }
}

    void mergeSort(deque<int>& A, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main(int argc, char* argv[]) {
    int n;
    cin >> n;
    deque<int> a;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        a.push_back(x);
    }

    mergeSort(a, 0, n);
    cout << a[0];
    for (int i = 1; i < n; ++i) {
        cout << " " << a[i];
    }
    cout << endl << c << endl;

    return 0;
}



Measured memory_bytes: 7040
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <string>
typedef long long ll;
const int N=500005;
int n;
ll ans=0,dp[20][20];
using namespace std;

string S;
ll get(string a,string b)
{
	int i,j,k,la=a.size(),lb=b.size();
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for (i=1;i<=n;i++)
	for (j=0;j<=i;j++)
	{
		k=i-j;
		if (j>la || k>lb) continue;
		if (j && S[n+i-1]==a[j-1]) dp[j][k]+=dp[j-1][k];
		if (k && S[n+i-1]==b[k-1]) dp[j][k]+=dp[j][k-1];
	}
	return dp[la][lb];
}
void dfs(int i,string a,string b)
{
	if (i>n){ans+=get(a,b);return;}
	dfs(i+1,a+S[i-1],b);
	dfs(i+1,a,b+S[i-1]);
}
int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	cin>>n;cin>>S;
	int i,j;
	for (i=n+1,j=n+n;i<j;i++,j--) swap(S[i-1],S[j-1]);
	dfs(1,"","");
	printf ("%lld",ans);
	return 0;
}


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

vector<int> prime_in_range(int N){
  // return prime num under N
  vector<int> natural(N+1);
  vector<bool> p(N+1);
  for(int i = 0; i < N+1; ++i){
    natural.at(i) = i;
    p.at(i) = 1;
  }
  p.at(0) = 0;
  p.at(1) = 0;
  int n,m;
  for(int i = 0; i < sqrt(N); ++i){
    if(p.at(i)){
      n = natural.at(i);
      m = 2;
      while(n*m<=N){
        p.at(n*m) = 0;
        ++m;
      }
    }
  }
  vector<int> ret;
  for(int i = 0; i < N+1; ++i){
    if(p.at(i)) ret.push_back(natural.at(i));
  }
  return ret;
}

int main(){
  int Q;
  cin >> Q;
  vector<int> l(Q),r(Q);
  int M=0;
  for(int i = 0; i < Q; ++i){
    cin >> l.at(i) >> r.at(i);
    M = max(M,r.at(i));
  }
  vector<int> primes = prime_in_range(M);
  vector<int> like2017;
  for(int i = 0; i < primes.size(); ++i){
    if(binary_search(primes.begin(),primes.end(),(primes.at(i)+1)/2)) like2017.push_back(primes.at(i));
  }
  for(int i = 0; i < Q; ++i){
    cout << upper_bound(like2017.begin(),like2017.end(),r.at(i))-lower_bound(like2017.begin(),like2017.end(),l.at(i)) << endl;;
  }
}

Measured memory_bytes: 1536
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int main(){
	int N,M;
	cin >> N >> M;
	int ans[50] = {};
	for(int i=0; i<M; i++){
		int a,b;
		cin >> a >> b;
		ans[a-1]++;
		ans[b-1]++;
	}
	for(int i=0; i<N; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pa(a,b,c) make_pair(make_pair(a,b),c)
using namespace std;
set<pair<pair<long long,long long>,long long> >mp;
int main()
{
	long long a,b,c;cin>>a>>b>>c;
	for (int i=0;;i++)
	{
		if ((a&1)||(b&1)||(c&1)) {printf("%d\n",i);return 0;}
		if (mp.count(pa(a,b,c))) {printf("-1\n");return 0;}
		mp.insert(pa(a,b,c));
		long long pa=b+c,pb=c+a,pc=a+b;
		a=pa/2;b=pb/2;c=pc/2;
	}
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = []
for i in range(n):
    r,t = map(int,input().split())
    a.append((t,r))
a.sort(reverse = True)
d = {}
cd = []
dp = 0
x = 0

for i in range(m):
    z,c = a[i]
    dp += z
    if c in d:
        cd.append(z)
    else:
        d[c] = z
        x += 1
cd.sort(reverse = True)
ans = dp + x**2
c = ans

for i in range(m,n):
    if len(cd) == 0:
        break
    z,v = a[i]
    if v in d:
        continue
    d[v] = z
    x += 1
    c = c - cd.pop()+z+2*x-1
    if c > ans:
        ans = c
print(ans)

Measured memory_bytes: 60200
#include<cstring>
#include<sstream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<string.h>
#include<math.h>
#include<iostream>
using namespace std;
int main()
{
	long long a;
	cin >> a;
	long long i;
	for (i = 2; i <= a; i *= 2);
	cout <<i- 1;
}

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

LL = []
for i in range(M):
    a,b = map(int, input().split())
    if H[a-1] > H[b-1]:
        LL.append(b)
    elif H[a-1] < H[b-1]:
        LL.append(a)
    elif H[a-1] == H[b-1]:
        LL.append(a)
        LL.append(b)

LLS = set(LL)
print(N-len(LLS))

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

typedef int i32;
typedef long long i64;
typedef unsigned int u32;
typedef unsigned long long u64;


template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};


#define debug(x)  cerr<<x<<"\n";
#define loop(i,n) for(i32 i = 0; i < n; ++i)
#define pi  pair<i32,i32>
#define ti  triple<i32,i32,i32>
#define mk  make_pair
#define vi  vector<i32>
#define vll vector<i64>
#define fastInOut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pr(a) for(auto x:a) cout<<x<<" ";
#define prmap(m) for(auto x:m) cout<<x.first<<" "<<x.second<<"\n";
using namespace std;

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

vi V;
const i32 N=7e7+9;
bool prime[N]; 
void SieveOfEratosthenes() 
{
    for (int  p=2; p*p<=N; p++){ 
        if (prime[p] == false){ 
            for (int  i=p*p; i<=N; i += p) 
                prime[i] = true; 
        } 
    } 
    int u=0,mx=0;
    for (int p=2; p<=N; p++) 
      if (!prime[p]) {
          V.push_back(p);
    }
   
}

i64 q,x,t;
i64 a,b,w;
void solve(){
    cin>>w;
    i64 sum=0,count=0;
    i64 i=1;
    while(true){
         count++;
         sum+=i++;
         if(sum>=w)
            break;
    }
    cout<<count;
}

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


Measured memory_bytes: 256
#include <stdio.h>

//iが7つの約数を持つかどうかの判定
int hantei(int i){
    int result = 1;
    int counter = 0;
    for(int n = 2; i > 1; n++){
        counter = 1;
        while((i % n) == 0){
            counter++;
            i /= n;
        }
        result *= counter;
    }
    if(result == 8){
        return 1;
    }else{
        return 0;
    }

}

int main(void){
    int n,counter = 0;
    scanf("%d",&n);
    for(int i = 1; i <= n; i += 2){
        if(hantei(i) == 1){
            counter++;
        }
    }
    printf("%d",counter);
}

Measured memory_bytes: 128
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    long a,b,c;
    scanf("%ld %ld %ld", &a, &b, &c);
    if(a + b > c){
        printf("No");
    } else if ((a + b - c) * (a + b - c) > 4 * a * b){
        printf("Yes");
    } else {
        printf("No");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
    string s;
    cin >> s;
    ll k;
    cin >> k;

    bool flg = true;
    REP(i,s.size())
    {
        if(s[0] != s[i])flg = false;
    }
    if(flg)
    {
        cout << s.size() * k / 2  << endl;
        return 0;
    }

    char cur = '-';

    bool matsu = false;
    ll cnt = 0;
    for(ll i = 0; i < s.size(); ++ i)
    {
        if(cur == s[i])
        {
            if(i == s.size()-1)
            {
                matsu = true;
            }
            ++cnt;
            cur = '-';
        }
        else
        {
            cur = s[i];
        }
    }
    ll res = 0;

    if(matsu || s[0] != s[s.size() - 1])
    {
        res = cnt * k;
        cout << res << endl;
        return 0;
    }

    ll cnt2 = 1;
    //2 -> 1文字目を変更した程でやる
    bool matsu2 = false;
    cur = '-';
    for(ll i = 1; i < s.size(); ++i)
        {
        if(cur == s[i])
        {
            if(i == s.size()-1)
            {
                matsu2 = true;
            }
            ++cnt2;
            cur = '-';
        }
        else
        {
            cur = s[i];
        }
    }

    if(matsu2)
    {
        res = (cnt+cnt2) * k / 2;
        res += (k%2) * cnt;
    }
    else
    {
        res = cnt + (k-1) * cnt2;
    }

    cout << res << endl;
    return 0;    
}


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

public class Program
{
  public static void Main()
  {
    var n = int.Parse(Console.ReadLine());
    var numbers = Console.ReadLine().Split().Select(int.Parse);

    double sum = 0;
    numbers.ToList().ForEach(a => sum +=  (double)1 / a);
    Console.WriteLine(1 / sum);
  }
}


Measured memory_bytes: 13396
s = input()
q = int(input())

inv = False
mae = ''
usiro = ''

for _ in range(q):
    tmp = input()
    if tmp[0] == '1':
        inv = not inv

    else:
        _,f,c = tmp.split()

        if f == '1' and not inv:
            mae += c
        elif f == '2' and not inv:
            usiro += c
        elif f == '1' and inv:
            usiro += c
        elif f == '2' and inv:
            mae += c

    # print(mae,s,usiro)

ans = mae[::-1] + s + usiro

if inv:
    ans = ans[::-1]

print(ans)

Measured memory_bytes: 4284
# coding:utf-8

import sys
from collections import Counter


input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7


def inpl(): return list(map(int, input().split()))


S = input()

ans = 999
for i in range(len(S) - 3):
    tmp = abs(753 - int(S[i:i+3]))
    if ans > tmp:
        ans = tmp

print(ans)


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll l,r; cin>>l>>r;
  if(r-l+1>=2019) {
    cout<<0<<endl;
    return 0;
  }
  
  ll ans=2019;
  for(ll i=l;i<=r;i++){
    for(ll j=i+1;j<=r;j++){
      ans=min(ans,i*j%2019);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
N,W = map(int,input().split())
w, v = zip(*(map(int, input().split()) for _ in range(N)))

dp = [0] * (W+1)

for i in range(N):
    for j in range(W,0,-1):
        if j - w[i] >= 0 and dp[j] < dp[j - w[i]] + v[i]:
            dp[j] = dp[j - w[i]] + v[i] #jは重さ、w[i]も重さ、dp[j]は重さjの時の価値、v[i]は重さw[i]の時の価値
    if dp[w[i]] == 0 or dp[w[i]] < v[i]:
        dp[w[i]] = v[i]
print(max(dp))
            



Measured memory_bytes: 70864
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int a,b;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b;
	print1(a*b%2?"Yes":"No");
	return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    int N;
    cin >> N;
    std::vector<ll> x(N), y(N), h(N);

    ll xt = 0, yt = 0, ht = 0;
    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] != 0) {
            xt = x[i];
            yt = y[i];
            ht = h[i];
        }
    }

    for (int cx = 0; cx <= 100; ++cx) {
        for (int cy = 0; cy <= 100; ++cy) {
            const auto height = ht + std::abs(cx - xt) + std::abs(cy - yt);
            bool is_ok = true;
            for (int i = 0; i < N; ++i) {
                if (h[i] != std::max(height - std::abs(cx - x[i]) - std::abs(cy - y[i]), 0ll)) {
                    is_ok = false;
                }
            }
            if (is_ok) {
                cout << cx << " " << cy << " " << height << endl;
                return 0;
            }
        }
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

// 約数を求める
vl divisor(ll n){
  vl res;
  for(ll i=1; i*i<=n; ++i){
    if(n%i==0){
      res.push_back(i);
      if(i!=n/i){
        res.push_back(n/i);
      }
    }
  }
  return res;
}

bool used[1252521];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n;
  ll a[1252521];
  cin>>n;
  REP(i, n){
    cin>>a[i];
  }
  ll allgcd=a[0];
  FOR(i, 1, n){
    allgcd=gcd(allgcd, a[i]);
  }
  bool pair=true;
  REP(i, n){
    vl res=divisor(a[i]);
    for(auto& x : res){
      if(x==1){
        continue;
      }
      if(used[x]){
        pair=false;
        break;
      }
      used[x]=true;
    }
    if(!pair){
      break;
    }
  }
  if(pair && allgcd==1){
    cout<<"pairwise ";
  }
  else if(allgcd==1){
    cout<<"setwise ";
  }
  else{
    cout<<"not ";
  }
  cout<<"coprime"<<'\n';
  return 0;
}


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

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

  vector<int> a(n,0);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());

  int alice = 0;
  int bob = 0; 
  while(1){

    if (a.size() == 0) break;    
    alice += a.back();
    a.pop_back();

    if (a.size() == 0) break;
    bob += a.back();
    a.pop_back();
  }

  cout << alice - bob << endl;

}


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

int main(){
  int x;
  cin >> x;
  int rate = 400;
  int count = 8;
  for(int i = 0; i < 8; i++){
    if(x >= rate && x <= rate + 199){
      cout << count << endl;
      break;
    }
      rate += 200;
      count --;
  }
}

Measured memory_bytes: 3628
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
pair<int, int> vp[N];
int lans[N];
int rans[N];
const LL MOD = 998244353;
class BIT
{
public:
	int a[N];
	void init()
	{
		MEM(a, 0);
	}
	void add(int x, int val)
	{
		while (x < N)
		{
			a[x] += val;
			x += x & -x;
		}
	}
	int sum(int x)
	{
		int ret = 0;
		while (x)
		{
			ret += a[x];
			x -= x & -x;
		}
		return ret;
	}
} b;
LL p2[N];
void refrain(int n)
{
	vector<int> v1, v2;
	for (int i = 1; i <= n; i++)
	{
		v1.push_back(vp[i].first);
		v2.push_back(vp[i].second);
	}
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	for (int i = 1; i <= n; i++)
	{
		vp[i].first = lower_bound(v1.begin(), v1.end(), vp[i].first) - v1.begin() + 1;
		vp[i].second = lower_bound(v2.begin(), v2.end(), vp[i].second) - v2.begin() + 1;
	}
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		cin >> vp[i].first >> vp[i].second;
	}
	p2[0] = 1;
	for (int i = 1; i <= n; i++)
	{
		p2[i] = p2[i - 1] * 2 % MOD;
	}
	refrain(n);
	sort(vp + 1, vp + n + 1);
	b.init();
	for (int i = 1; i <= n; i++)
	{
		lans[i] = b.sum(vp[i].second);
		b.add(vp[i].second, 1);
	}
	b.init();
	for (int i = n; i >= 1; i--)
	{
		rans[i] = b.sum(vp[i].second);
		b.add(vp[i].second, 1);
	}
	LL ans = 0;
	for (int i = 1; i <= n; i++)
	{
		LL x = p2[lans[i]] - 1;
		LL y = p2[i - 1 - lans[i]] - 1;
		LL z = p2[rans[i]] - 1;
		LL w = p2[n - i - rans[i]] - 1;
		ans += x * y % MOD * z % MOD * w % MOD
			+ x * y % MOD * z % MOD
			+ x * y % MOD * w % MOD
			+ x * z % MOD * w % MOD
			+ y * z % MOD * w % MOD
			+ x * w % MOD
			+ y * z % MOD
			+ p2[n - 1];
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7028
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
from bisect import bisect_right
input = lambda: sys.stdin.readline().rstrip()


def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return


def main():
    n = int(input())
    Ls = list(map(int, input().split()))
    Ls.sort()
    cnt = 0
    for i in range(0,n-2):
        for j in range(i+1,n-1):
            #k以下なら良い
            k =  Ls[i] + Ls[j] -1
            # bisect_right(Ls, k)個の要素が左にある
            # 答え: bisect_right(Ls, k) - j
            cnt += max(bisect_right(Ls, k) - j-1, 0)
            # print(Ls, Ls[i],Ls[j],k, bisect_right(Ls,k)-j-1)
    print(cnt)
            

if __name__ == '__main__':
    main()

Measured memory_bytes: 69372
#include<stdio.h>
int main(void)
{
	char s[3];

	for (int i = 0; i < 3; i++) {
		scanf("%c", &s[i]);
	}
	if (s[0] == s[2])
		printf("Yes");
	else
		printf("No");
	/*int count = 0;
	for (int i = 0; i < 3; i++) {
		//printf("%c", s[i]);
		if (s[i] == 'o') {
			count++;
		}
	}
	int sum;

	sum = 700 + count * 100;

	printf("%d", sum);*/

	return 0;
}

Measured memory_bytes: 128
#include <ext/pb_ds/assoc_container.hpp> 	// Common file
#include <ext/pb_ds/tree_policy.hpp> 		// Including tree_order_statistics_node_update
#include<bits/stdc++.h>
#define int            		long long
#define x              		first
#define y              		second
#define all(aaa)       		(aaa).begin(),(aaa).end()
#define REP(i,sss,eee) 		for(int i=sss;i<=eee;++i)
#define pb             		push_back
#define pii            		pair<int,int>
#define vi             		vector<int>
#define speed          		ios_base::sync_with_stdio(0);cin.tie(0);
#define N              		1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
int solve()
{
	int n,m;cin>>n>>m;
	std::vector<int> v(m+1,0);
	REP(i,0,n-1)
	{
		int k;cin>>k;
		REP(j,0,k-1)
		{
			int tmp;
			cin>>tmp;++v[tmp];
		}
	}
	int ans =0 ;
	for(auto it:v){if(it==n){++ans;}}
	cout<<ans<<"\n";
}
signed main(){
	speed
	int tt=1;
	//cin>>tt;
	while(tt--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::option::Option;
use std::str::FromStr;

fn get_grade(m: i32, f: i32, r: i32) -> Option<char> {
    match (m, f, r) {
        (-1, -1, -1) => None,
        (-1, _, _) | (_, -1, _) => Some('F'),
        _ if m + f >= 80 => Some('A'),
        _ if m + f >= 65 => Some('B'),
        _ if m + f >= 50 => Some('C'),
        _ if m + f >= 30 && r >= 50 => Some('C'),
        _ if m + f >= 30 => Some('D'),
        _ => Some('F'),
    }
}

fn main() {
    let cin = stdin();
    let mut sc = Scanner::new(cin.lock());

    loop {
        let m = sc.next();
        let f = sc.next();
        let r = sc.next();

        if let Some(grade) = get_grade(m, f, r) {
            println!("{}", grade);
        } else {
            break;
        }
    }
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect()
    }

    fn char(&mut self) -> char {
        self.chars()[0]
    }
}



Measured memory_bytes: 5036
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 99999999
 
 
int m,n;
int b[110];
 
bool solve(int v){
    int l=0;
    int x=v;
    rep(i,n){
        while(x<b[i]&&l<m){
            x=v;
            l++;
        }
        if(l>=m)return false;
        if(x>=b[i]){
            x-=b[i];
        }
    }
    return true;
}
 
int main(){
    while(cin>>m>>n){
        if(m==0&&m==0)break;
        rep(i,n)cin>>b[i];
         
        int left=0;
        int right=1500000-1;
        while(right>left+1){
//            cout<<left<<" "<<right<<endl;
            int cent=(left+right)/2;
            bool res = solve(cent);
            if(res) right=cent;
            else left=cent;
        }
        cout<<right<<endl;
    }
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
   ll a, b; cin >> a >> b;
   cout << ((b % a == 0) ? a+b : b-a) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <stack>
#include <cstring>
#include <cmath>
#include <vector>
#include <ctime>
#include <bitset>
using namespace std;
#define pb push_back
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d%d",&n,&m)
#define sddd(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define sld(n) scanf("%lld",&n)
#define sldd(n,m) scanf("%lld%lld",&n,&m)
#define slddd(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define sf(n) scanf("%lf",&n)
#define sff(n,m) scanf("%lf%lf",&n,&m)
#define sfff(n,m,k) scanf("%lf%lf%lf",&n,&m,&k)
#define ss(str) scanf("%s",str)
#define ans() printf("%d",ans)
#define ansn() printf("%d\n",ans)
#define anss() printf("%d ",ans)
#define lans() printf("%lld",ans)
#define lanss() printf("%lld ",ans)
#define lansn() printf("%lld\n",ans)
#define fansn() printf("%.10f\n",ans)
#define r0(i,n) for(int i=0;i<(n);++i)
#define r1(i,e) for(int i=1;i<=e;++i)
#define rn(i,e) for(int i=e;i>=1;--i)
#define rsz(i,v) for(int i=0;i<(int)v.size();++i)
#define szz(x) ((int)x.size())
#define mst(abc,bca) memset(abc,bca,sizeof abc)
#define lowbit(a) (a&(-a))
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pli pair<ll,int>
#define mp make_pair
#define lrt rt<<1
#define rrt rt<<1|1
#define X first
#define Y second
#define PI (acos(-1.0))
#define sqr(a) ((a)*(a))
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1000000000+7;
const double eps=1e-9;
const int inf=0x3f3f3f3f;
const ll infl = 10000000000000000;
const int maxn=  1000+10;
const int maxm = maxn*21+10;
//Pretests passed
int in(int &ret)
{
    char c;
    int sgn ;
    if(c=getchar(),c==EOF)return -1;
    while(c!='-'&&(c<'0'||c>'9'))c=getchar();
    sgn = (c=='-')?-1:1;
    ret = (c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9')ret = ret*10+(c-'0');
    ret *=sgn;
    return 1;
}


int main()
{
#ifdef LOCAL
    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
#endif // LOCAL
    int n;
    sd(n);
    int a = n/10 , b = n%10;
    puts( (a==9||b==9 ) ? "Yes":"No");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	double x, h;
	while (cin >> x >> h, !(x == 0 && h == 0)) {
		double a = sqrt(h * h + x * x / 2);
		double b = sqrt(a * a - x * x / 4);
		cout << fixed << setprecision(20) << x * x + 2 * x * b << endl;
	}
}


Measured memory_bytes: 3240
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;

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

int main() {

    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll R = 0;
    ll G = 0;
    ll B = 0;
    rep(i,N){
        if(S[i]=='R') R++;
        else if(S[i]=='G') G++;
        else if(S[i]=='B') B++;
    }
    ll out = R*G*B;
    rep(i,N){
        rep(j,N){
            if(i>j&&i+i-j<N){
                if((S[i]!=S[j])&&(S[j]!=S[i+i-j])&&(S[i]!=S[i+i-j])) out--;
            }
        }
    }
    if(out<0) out = 0;
    cout << out << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, q; cin>>n>>q;
	vector<vll> adj(n+1);
	vector<bool> use(n+1);

	rep(i, n-1){
		ll u, v; cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}

	vll count(n+1, 0);
	rep(i, q){
		ll p, x; cin>>p>>x;
		count[p] += x;
	}

	queue<pll> que;
	que.push(mp(1, 0));

	while(que.size()){
		pll p = que.front(); que.pop();
		use[p.fi] = true;
		count[p.fi] += count[p.se];
		for(auto e : adj[p.fi]){
			if (use[e] == false) que.push(mp(e, p.fi));
		}
	}

	bool first = true;
	rep(i, n){
		if (first)
			first = false;
		else
			cout << " ";
		cout << count[i+1];
	}

	return 0;
}

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

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll X,A,B;

void solve(){
    if(abs(X-A) < abs(X - B))
        cout << "A" << endl;
    else
        cout << "B" << endl;
}

int main(){
    cin >> X >> A >> B;

    solve();
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)


int main() {


	long a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	long long ans1, ans2, ans3;

	ans1 = a*x + b*y;
	long cc = min(x, y) * 2;
	ans2 = cc * c + (x - cc/2)*a + (y - cc/2)*b;
	ans3 = 2 * max(x, y)*c;

	vector<long long> v(3);
	v[0] = ans1;
	v[1] = ans2;
	v[2] = ans3;

	SORT(v);

	ANS(v[0]);


	return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 2e9+7;



int main() {
    int d, g;
    cin >> d >> g;
    vi p(d), c(d);
    rep(i, d) cin >> p[i] >> c[i];
    int ans = INF;
    rep(mask, (1 << d)) {
        int val = 0;
        int kaisu = 0;
        int nokori_max;
        rep(i, d) {
            if (mask >> i & 1) {
                val += 100 * (i + 1) * p[i] + c[i];
                kaisu += p[i];
            } else {
                nokori_max = i;
            }
        }
        if (val < g) {
            int tarinai = g - val;
            int hituyo = tarinai / (100 * (nokori_max + 1));
            if (tarinai % (100 * (nokori_max + 1)) != 0) hituyo++;
            if (hituyo > p[nokori_max]) continue;
            kaisu += hituyo;
        }
        ans = min(ans, kaisu);
    }
    cout << ans << endl;
}

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

template<class T> inline vector<pair<T, T> > primeFactorize(T n) {
    vector<pair<T, T> > res;
    for (T a = 2; a * a <= n; a++) {
        if (n % a != 0) continue ;
        T ex = 0;
        while (n % a == 0) {
            ++ex;
            n /= a;
        }
        res.push_back({a, ex});
    }
    if (n != 1) res.push_back({n, 1});
    return res;
}

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

    ll n;
    cin >> n;

    auto pf = primeFactorize(n);

    int count = 0;
    for (auto i : pf) {
        ll p = i.second;
        ll b = 1;
        while (b <= p) {
            p -= b;
            b++;
            count++;
        }
    }
    cout << count << '\n';
    return 0;
}


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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  vector<int> c;
  for (int i = 1; i <= min(A, B); ++i) {
    if (A % i == 0 && B % i == 0) c.push_back(i);
  }
  reverse(c.begin(), c.end());
  cout << c[K-1] << endl;
}

Measured memory_bytes: 3548
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define INF 1000000000
 
int main() {
  int N;
  cin >> N;
  int min = INF;
  int max = 0;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (min > A[i]) min = A[i];
    if (max < A[i]) max = A[i];
  }
 
  cout << max - min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    float a;
    int b;
    cin>>a;
    a/=2;
    b=a;
    if(a==b)
    {
        cout<<b<<endl;
    }
    else
    {
        cout<<b+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
int main()
{ 
    cool;
    ll int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a){
    	cout<<k;
	}
	else if(k>a&&k<=(a+b)){
		cout<<a;
	}
	else if(k>(a+b)&&k<=(a+b+c)){
		cout<<(a+((k-(a+b))*(-1)));
	}
    return 0;
}


Measured memory_bytes: 3612
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$a =$key->A[0];
$b =$key->A[1];
if ($a == $b) {
  printf("Draw\n");
  exit;
}
if ($a == 1) $a = 14;
if ($b == 1) $b = 14;
if ($a > $b) {
  printf("Alice\n");
}
else {
  printf("Bob\n");
}


Measured memory_bytes: 3828