akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.util.Arrays;
import java.util.Set;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        int C=A+B;
        if(C>=24){
            C=C-24;
        }
        System.out.println(C);
}
        
        
    }


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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;





int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);


	ll N, A, B;

	cin >> N >> A >> B;

	if (A % 2 == B % 2)
		cout << (B - A) / 2 << '\n';
	else
		cout << min(A + (B - A - 1) / 2, N - B + 1 + (N - (A +  (N - B + 1))) / 2) << '\n';
//		cout << min(B - 1, N - A) << '\n';


	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
    return 0;
}


Measured memory_bytes: 256
H,W = [int(i) for i in input().split()]
if H != 1 and W != 1:
    N = H*W
    if N % 2 == 1:
        N-=1
        print(N//2 + 1)
        exit()
    if N%2 ==0:
        print(N//2)
else:
    print(1)

Measured memory_bytes: 2940
#include <stdio.h>

int main(void){
  for(int i = 0; i < 50; i++){
    int n,count = 0;
    scanf("%d",&n);
    for(int i2 = 0; i2 < 10; i2++)for(int i3 = 0; i3 < 10; i3++){
      for(int i4 = 0; i4 < 10; i4++)for(int i5 = 0; i5 < 10; i5++){
        if(i2 + i3 + i4 + i5 == n)count++;
      }
    }
    printf("%d\n",count);
  }
  return 0;
}


Measured memory_bytes: 2000
//65 - A 90 - Z 97 - a 122 - z
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

unordered_map<int, int> mp;
int mx1, mx2;

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

    int n; cin >> n;
    for(int i = 0; i < n; i++)
    {
        int a; cin >> a;
        mp[a] ++;
    }
    for(auto x: mp)
    {
        if(x.second == 2 || x.second == 3)
        {
            if(x.first > mx1)
            {
                mx2 = mx1;
                mx1 = x.first;
            }
            else if(x.first > mx2) mx2 = x.first;
        }
        if(x.second > 3)
        {
            if(x.first > mx1)
                mx1 = x.first, mx2 = x.first;
            else if(x.first > mx2) mx2 = x.first;
        }
    }
    LL res = (LL)mx1 * (LL)mx2;
    cout << res;
    return 0;
}


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

using namespace std;
int main()
{
	set<string> s;
	int n;
	cin >> n; cin.ignore();
	for (int i = 0; i < n; i++)
	{
		string x;
		cin >> x; cin.ignore();
		s.insert(x);
	}
	cout << s.size();
	system("pause");
}

Measured memory_bytes: 19244
let () =
  let a,b = Scanf.scanf "%d %d " (fun a b -> a,b) in
  let s = Scanf.scanf "%s " (fun a -> a) in

  let fl = String.sub s 0 a in
  let hl = String.sub s a 1 in
  let ll = String.sub s (a+1) ((a+b+1)-(a+1)) in

  let int_of_string_opt s =
    try Some (int_of_string s)
    with Failure _ -> None
  in
  let f_fl = match int_of_string_opt fl with
      Some x -> true 
    | None -> false
  in
  let f_ll = match int_of_string_opt ll with
      Some x -> true 
    | None -> false
  in

  Printf.printf "%s\n" (if f_fl && f_ll && hl = "-" then "Yes" else "No")
  


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

int main(){
  int N;
  bool flag=false;

  cin >> N;
  
  for(int a=0;a<=N/4;a++)
    if((N - 4 * a) >= 0 && (N-4*a)%7 == 0)
      flag=true;

  if(flag) cout << "Yes" << endl;
  else     cout << "No"  << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char a,b,c;
  int i;
  while(1){
    a=getchar();
    if(a==EOF) break;
    if(a=='@'){
      b=getchar();
      c=getchar();
      for(i=0;i<(b-'0');i++){
        putchar(c);
      }
    }
    else putchar(a);
  }
  return 0;
}

Measured memory_bytes: 524
#include<iostream>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
int a[m];
long long int s=0;
for(int i=0;i<m;i++){
cin>>a[i];
s=s+a[i];
}
if(s>n)
cout<<"-1";
else
cout<<n-s;
return 0;
}


Measured memory_bytes: 3560
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
const int MAX=1e5;
int a[MAX];
int gcd(int a,int b){
    int t=a%b;
    while(t){
        a=b;
        b=t;
        t=a%b;
    }
    return b;
}
int main() {
    int n;
    cin >> n;
    for(int i = 0;i < n; i ++){
        cin >> a[i];
    }
    int g = a[0];
    for(int i = 1;i < n; i++){
        g = gcd(g, a[i]);
        if(g == 1) break;
    }
    cout << g << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;


//x^5-1 = (x^4+x^3+x^2+x+1)(x-1)
//a^5-b^5のaを固定した時に差が一番小さくなるのはb-a-1のとき
//このときa^5-b^5は(a^4+a^3b+a^2b^2+ab^3+b^4)になる
//ここでa^4が出てくるため10^9の4乗根までのaを見れば良い
int main(){
    ll x;
    cin >> x;
    for(int a=1; a<1000; a++){
        ll a5=1;
        rep(i,5) a5 *= a;
        for(int b=-1000; b<1000; b++){
            ll b5=1;
            rep(i,5) b5 *= b;
            if(a5-b5 == x){
                printf("%d %d\n",a,b);
                return 0;
            }
        }
    }


   

}

Measured memory_bytes: 3764
import sys
import numpy as np

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N, W = map(int, input().split())
    w = [0]
    v = [0]
    for i in range(N):
        weight, value = map(int, input().split())
        w.append(weight)
        v.append(value)

    # dp = [[0] * (W + 1) for _ in range(N + 1)]
    dp = np.zeros(W + 1, dtype=np.int64)


    for i in range(1, N + 1):
        dp[w[i] :] = np.maximum(dp[w[i] :], dp[: -w[i]] + v[i])

    # print(w, v, dp)
    print(dp.max())


if __name__ == "__main__":
    main()


Measured memory_bytes: 15464
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
	long long a,b,i,k,f;
	f=0;
	long double j,x,y;
	cin>>a>>b;
	x=a*1.0;
	y=b*1.0;
	for (i=0;i<100000;i++)
	{
		j=i*1.0;
		if (floor(j/(12.5))==x && floor(j/(10.0))==y)
		{
			f=1;
			break;
		}
	}
	if (f==1)
	{
		cout<<i<<endl;
	}
	else
	{
		cout<<-1<<endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string str;
  cin >> str;
  int q,i;
  cin >> q;
  string s1,s2;
  int a,b;
  for(i=0;i<q;i++){
    //cout << str << endl;
    cin >> s1 >> a >> b;
    if(s1=="print"){
      cout << str.substr(a,b-a+1) << endl;
    }else if(s1=="reverse"){
      string s3=str.substr(a,b-a+1);
      reverse(s3.begin(),s3.end());
      str=str.substr(0,a)+s3+str.substr(b+1,str.size()-a-1);
    }else{
      cin >> s2;
      str=str.substr(0,a)+s2+str.substr(b+1,str.size()-a-1);
    }
  }
}

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

int N;
int x[210];
int s = 0;
int main(){
    int ms = 1000000000;
    int t = 1;
    cin >> N;
    for (int u = 0; u < N; ++u)cin >> x[u];
        for (int j = -100; j <= 100; ++j){
        s = 0;
             for (int i = 0; i < N; ++i){
            int p =0 ;
            p = x[i] - j;
            //cout << p << endl;
            s += p * p;
        }
        //cout << s << endl;
        if (s < ms){
            ms = s;
            t = j;
        }
    }
    cout << ms << endl;
}


Measured memory_bytes: 256
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n):
  for j in range(i + 1, n):
    dist = 0
    for k in range(d):
      dist += (x[i][k] - x[j][k])**2
    dd = int(dist**0.5)
    for k in range(dd - 1, dd + 2):
      	if k * k == dist:
        	ans += 1
print(ans)

Measured memory_bytes: 3064
import sys
#input = sys.stdin.readline

def main():
    inp = lambda: list(map(int, input().split())) 
    h,w=inp()
    a=[inp() for _ in range(h)]
    b=[inp() for _ in range(h)]
    d=[[0]*w for _ in range(h)]
    for i in range(h):
        for j in range(w):
            d[i][j]=abs(a[i][j]-b[i][j])
    zero=80*(h+w)+2
    dp=[[0]*w for _ in range(h)]
    dp[0][0]=1<<(zero+d[0][0])|1<<(zero-d[0][0])
    for i in range(h):
        for j in range(w):
            if i==0:
                if j==0:
                    continue
                else:
                    dp[i][j]=dp[i][j-1]<<d[i][j]|dp[i][j-1]>>d[i][j]
            else:
                if j==0:
                    dp[i][j]=dp[i-1][j]<<d[i][j]|dp[i-1][j]>>d[i][j]
                else:
                    dp[i][j]=dp[i-1][j]<<d[i][j]|dp[i-1][j]>>d[i][j]
                    dp[i][j]=dp[i][j]|(dp[i][j-1]<<d[i][j]|dp[i][j-1]>>d[i][j])
    ans=dp[-1][-1]
    for i in range(zero):
        if ans>>(zero+i)&1 or ans>>(zero-i)&1:
            print(i)
            exit()

if __name__ == '__main__':
    main()

Measured memory_bytes: 19700
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C: Cat Snuke and a Voyage
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

/* global variables */

bool sts[MAX_N], gls[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  for (int i = 0; i < m; i++) {
    int ai, bi;
    scanf("%d%d", &ai, &bi);
    ai--, bi--;
    if (ai == 0) sts[bi] = true;
    else if (bi == n - 1) gls[ai] = true;
  }

  bool ok = false;
  for (int i = 0; i < n; i++)
    if (sts[i] && gls[i]) {
      ok = true;
      break;
    }

  if (ok) puts("POSSIBLE");
  else puts("IMPOSSIBLE");
  return 0;
}


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

int main() {
    int l, r, d;
    cin >> l >> r >> d;
    int i;
    int ans = 0;
    for(i = l; i <= r; i++) {
        if (i % d == 0) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
n,k=map(int,input().split())
mod=10**9+7
f=[1]
for i in range(2*n):f+=[f[-1]*(i+1)%mod]
def comb(a,b):return f[a]*pow(f[b],mod-2,mod)*pow(f[a-b],mod-2,mod)%mod
ans=comb(2*n-1,n-1)
for i in range(n-1,k,-1):ans=(ans-comb(n,n-i)*comb(n-1,i))%mod
print(ans)


Measured memory_bytes: 60396
/******************************************
* AUTHOR : GURUTEJA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

void debug(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 

}

  int main() {
    debug();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    bool flag=true;
    while(true){
    	for(int i=2; i*i<=n; i++){
    		if(n%i==0){
    			flag=false;
    			break;
    		}
    	}
    	if(flag){
    		cout<<n<<endl;
    		return 0;
    	}
    	flag=true;
    	n++;
    }

    return 0;
  }

Measured memory_bytes: 3644
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();

    public static void main(String[]$) throws IOException {
        int a = scanner.nextInt();
        String s = scanner.next();
        System.out.println(a >= 3200 ? s : "red");
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() throws IOException {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
            return tokenizer.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	char x,y; cin>>x>>y;
	if (x>y) cout<<">\n";
	else if (x<y) cout<<"<\n";
	else cout<<"=\n";
	return 0;
}


Measured memory_bytes: 256
K = int(input())
numbers = set([])
q = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
# print(f'{q=}')

while len(numbers) <= 100000:  # 10**8:
    # print('test')
    qq = set([])
    for i in q:
        # print(f'{i=}')
        if i % 10 != 0:
            n = i * 10 + (i % 10) - 1
            qq.add(n)
        if i % 10 != 9:
            n = i * 10 + (i % 10) + 1
            qq.add(n)
        n = i * 10 + (i % 10)
        qq.add(n)
    numbers |= q
    # print(f'{numbers=}')
    # print(f'{len(numbers)=}')
    q = qq

numbers = sorted(map(int, numbers))
# print(f'{numbers[:30]=}')
ans = numbers[K - 1]
print(ans)


Measured memory_bytes: 65632
#include"bits/stdc++.h"
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    auto B = A;
    sort(B.begin(), B.end());

    for (int i = 0; i < N; i++) {
        if (A[i] < B[N / 2]) {
            cout << B[N / 2] << endl;
        } else {
            cout << B[N / 2 - 1] << endl;
        }
    }
}

Measured memory_bytes: 5376
import java.util.*;

public class Main {

  public static void main(String args[]) {
    int rep = 1;
    if( args.length > 0 ) { rep = Integer.parseInt(args[0]); }
    (new Main()).__solve(rep);
  }

  void __solve(int rep) {

    try (
      Scanner cin = new Scanner(System.in);
    ) {

      for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      }

    }

  }

  int MOD = 1000 * 1000 * 1000 + 7;

  long rev(long K) {
	  return pow(K, MOD - 2);
  }
  
  long pow(long base, int times) {
	  if( times == 0 ) { return 1; }
	  if( times % 2 == 1 ) {
		  return pow(base * base % MOD, times / 2) * base % MOD;
	  }
	  return pow(base * base % MOD, times / 2);
  }
  
  void __solve(Scanner cin) {
	  int R = cin.nextInt();
	  int C = cin.nextInt();
	  int K = cin.nextInt();
	  long sum = R;
	  sum = sum * C - 2;
	  long ans = count(R, C) * rev(2) % MOD;
	  com(ans, sum, K - 2);
  }
  
  long count(int R, int C) {
	  long total = 0;
	  for( int i = 0; i < R; ++i ) {
		  total += (sum(i) + sum(R - i - 1)) * C * C % MOD;
	  }
	  for( int i = 0; i < C; ++i ) {
		  total += (sum(i) + sum(C - i - 1)) * R * R % MOD;
	  }
	  return total % MOD;
  }
  
  long sum(int i) {
	  return i * (i + 1L) / 2;
  }
  
  void com(long ans, long total, long K) {
	  K = Math.min(K, total - K);
	  //System.err.println(total + " " + K);
	  for( int i = 0; i < K; ++i ) {
		  ans = ans * (total - i) % MOD;
	  }
	  for( int i = 1; i <= K; ++i ) {
		  ans = ans * rev(i) % MOD;
	  }
	  System.out.println(ans);
  }
  

}


Measured memory_bytes: 23892
n, c = map(int, input().split())

x = [None] * (n + 2)
v = [None] * (n + 2)
for i in range(1, n + 1):
    x[i], v[i] = map(int, input().split())
x[0] = 0
x[n + 1] = c

dp = [[0] * (n + 2) for _ in range(2)]

cal = 0
for i in range(1, n + 1):
    cal -= x[i] - x[i - 1]
    cal += v[i]
    dp[0][i] = max(dp[0][i - 1], cal)

cal = 0
for i in range(n, 0, -1):
    cal -= x[i + 1] - x[i]
    cal += v[i]
    dp[1][i] = max(dp[1][i + 1], cal)

maxcal = 0
for i in range(n + 1):
    maxcal = max(maxcal, dp[0][i] + dp[1][i + 1] - x[i])
    maxcal = max(maxcal, dp[0][i] + dp[1][i + 1] - c + x[i + 1])

print(maxcal)

Measured memory_bytes: 20044
in_str = raw_input()
q = input()

for i in xrange(q):
    order = raw_input().split()
    a = int(order[1])
    b = int(order[2])+1

    if order[0] == "print":
        print in_str[a:b]
    if order[0] == "reverse":
        temp_str    = in_str[a:b]
        in_str = in_str[:a] + temp_str[::-1] + in_str[b:]
    if order[0] == "replace":
        in_str = in_str[:a] + order[3] + in_str[b:]

Measured memory_bytes: 6436
nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]
h = list()
for i in range(n):
    h.append(int(input()))
h.sort()
min_h = 10 ** 10
for i in range(n - k + 1):
    dis_h = h[i + k - 1] - h[i]
    if dis_h < min_h:
        min_h = dis_h
print(min_h)


Measured memory_bytes: 7384
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N,K = LMIIS()
    ans = 0
    while N > 0:
        N //= K
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38484
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, p;
    long odd = 0, even = 0;
    cin >> n >> p;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(x % 2 == 0) even++;
        else odd++;
    }
    if(odd == 0 && p == 1){
        cout << 0 << endl;
        return 0;
    }
    even = pow(2, even);
    odd = max((double)1, pow(2, odd-1));
    cout << odd * even << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl h,w,n;
    cin >> h >> w >> n;
    intl a[n];
    rep(i,n)cin >> a[i];
    intl c[h][w];
    m0(c);
    intl cnt = 0;
    intl idx = 0;
    rep(i,h){
        rep(j,w){
            c[i][j] = idx + 1;
            if(++cnt >= a[idx]){
                idx++;
                cnt = 0;
            }
        }
        if(i % 2)reverse(c[i], c[i] + w);
    }
    rep(i,h){
        rep(j,w){
            cout << c[i][j] << " "; 
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
// sync

#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 1e3;

int n, m, x[N], y[N], c[2];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", x + i, y + i);
		c[(x[i] + y[i]) & 1]++;
	}
	if (c[0] && c[1]) return puts("-1"), 0;
	printf(c[0] ? "32\n1 " : "31\n");
	for (int i = 30; i >= 0; i--) printf("%d%c", 1 << i, " \n"[!i]);
	for (int i = 1; i <= n; i++) {
		if (c[0]) putchar('R'), x[i]--;
		for (int j = 30; j >= 0; j--)
			if (abs(x[i]) > abs(y[i])) {
				if (x[i] > 0)
					x[i] -= 1 << j, putchar('R');
				else
					x[i] += 1 << j, putchar('L');
			} else {
				if (y[i] > 0)
					y[i] -= 1 << j, putchar('U');
				else
					y[i] += 1 << j, putchar('D');
			}
		puts("");
	}
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
  int n;
  scanf("%d", &n);
  vector<int> tako(n);
  REP(i, n) scanf("%d", &tako.at(i));
  
  int sum = 0;
  REP(i, n){
    REP(j, n){
      if(i != j) sum += tako.at(i) * tako.at(j);
    }
  }
  printf("%d\n", sum/2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  int A,B,C;cin>>A>>B>>C;
  if(A==B&&B==C)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

int main(){
	int A, B ,C;
	cin >> A >> B;
	int sum = A + B ;
	int minus = A- B; 
	int times = A * B;

	int ans = max(sum,minus);
	ans = max(ans,times);

	cout << ans << endl;
}


Measured memory_bytes: 256
#define DEBUG 0
/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 2019/8/18 20:54:21
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
using ll = long long;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return x ? MOD - x : 0; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a)
  {
    mint b{a};
    return *this *= b.power(MOD - 2);
  }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
class combination
{
public:
  vector<mint> inv, fact, factinv;
  static int MAX_SIZE;
  combination() : inv(MAX_SIZE), fact(MAX_SIZE), factinv(MAX_SIZE)
  {
    inv[1] = 1;
    for (auto i = 2; i < MAX_SIZE; i++)
    {
      inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
    }
    fact[0] = factinv[0] = 1;
    for (auto i = 1; i < MAX_SIZE; i++)
    {
      fact[i] = mint(i) * fact[i - 1];
      factinv[i] = inv[i] * factinv[i - 1];
    }
  }
  mint operator()(int n, int k)
  {
    if (n >= 0 && k >= 0 && n - k >= 0)
    {
      return fact[n] * factinv[k] * factinv[n - k];
    }
    return 0;
  }
};
int combination::MAX_SIZE = 3000010;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// constexpr double epsilon = 1e-10;
// constexpr ll infty = 1000000000000000LL;
// constexpr int dx[4] = {1, 0, -1, 0};
// constexpr int dy[4] = {0, 1, 0, -1};
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long k,a,b,t;
int main(){
	cin>>k>>a>>b;
	if(b>=a and a<k)cout<<-1<<endl;
	else if(k<=a)cout<<1<<endl;
	else if((k-a)%(a-b)==0)cout<<(k-a)/(a-b)*2+1<<endl;
	else cout<<(k-a)/(a-b)*2+3<<endl;
}

Measured memory_bytes: 256
# 品物数を決めると合計金額は100*個数～105*個数の範囲となる
# xが範囲内にあれば買い方が存在する。なければしない。
x = int(input())

for i in range(1, 1000001):
    if 100*i <= x <= 105*i:
        print(1)
        break
else:
    print(0)


Measured memory_bytes: 2940
N = int(input())

if N%2==1:
    print("First")
    exit()
elif N==2:
    print("Second")
    exit()

E = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)

E_dim = [len(e) for e in E]
E_set = [set(e) for e in E]
q = []
for v, (dim, e) in enumerate(zip(E_dim, E)):
    if dim==1:
        for u in e:
            if E_dim[u] == 2:
                q.append(v)
                
while q:
    v = q.pop()
    u = E_set[v].pop()
    if E_dim[u] == 1:
        print("Second")
        exit()
    E_set[u].remove(v)
    w = E_set[u].pop()
    E_set[w].remove(u)
    E_dim[w] -= 1
    if E_dim[w] == 1:
        x = E_set[w].copy().pop()
        if E_dim[x] == 2:
            q.append(w)
    elif E_dim[w] == 2:
        for x in E_set[w]:
            if E_dim[x] == 1:
                q.append(x)
print("First")



Measured memory_bytes: 47424
#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x=i;
        if ( x % 3 == 0 )cout << " " << i;
        else{ while(x){
                 if ( x % 10 == 3 ){
                     cout << " " << i;
                     break;
                 }
                 x /= 10;
            }
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3108
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define st first
#define nd second
using namespace std;
 
const int maxN = 1 << 18, INF = 1 << 30, maxTS = maxN * 2;

struct Tree
{
	int offset, qbegin, qend;
	int T[maxTS], res;
	
	void qpriv(int v, int left, int right)
	{
		if (left >= qend or right <= qbegin)	
			return;
		if (left >= qbegin and right <= qend)
		{
			res = min(res, T[v]);
			return;
		}
		qpriv(v * 2, left, (left + right) / 2);
		qpriv(v*2+1, (left + right) / 2, right);
	}
	
	void init(int n)
	{
		for (offset = 1; offset < n; offset *= 2);
		FOR(i, 1, offset*2)
			T[i] = INF;
	}
	
	void updt(int v, int val)
	{
		v += offset;
		T[v] = val;
		for (v /= 2; v != 0; v /= 2)
			T[v] = min(T[v * 2], T[v*2+1]);
	}
	
	int query(int a, int b)
	{
		qbegin = a + offset;
		qend = b + offset + 1;
		res = INF;
		qpriv(1, offset, offset * 2);
		return res;
	}
}tree;

char T[maxN];
int dp[maxN];

void solve()
{
	int n, m;
	scanf ("%d%d", &n, &m);
	scanf ("%s", T);
	tree.init(n + m + 10);
	tree.updt(n, 0);
	dp[n] = 0;
	
	for (int i=n-1; i>=0; i--)
	{
		dp[i] = T[i] == '1' ? INF : tree.query(i+1, i+m) + 1;
		tree.updt(i, dp[i]);
	}
	
	if (T[0] == '1' or T[n] == '1' or dp[0] >= INF)
	{
		printf("-1\n");
		return;
	}
	
	int v = 0;
	while (v != n)
	{
		int u = v;
		while (dp[u] != dp[v]-1)	
			u++;
		printf("%d ", u-v);
		v = u;
	}
	
	printf("\n");
}
 
int main()
{
	int t;
	t=1;//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}


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

using namespace std;

typedef long long int64;
const int64 mod = 1e9 + 7;

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

  int64 fact = 1;
  for(int i = 1; i <= N; i++) (fact *= i) %= mod;
  cout << fact << endl;
}

Measured memory_bytes: 256
'''
最小となる問題数のケースは2通り。
1. 得点の大きい問題から順に解いていく
2. コンプリートボーナスの大きい問題から解いていく
どちらのケースでも解いた問題の組み合わせは以下となる
(a)コンプリートボーナスを獲得した問題 * n + (b)一部だけ解いている問題
'''

D, G = map(int, input().split())

# (Pi, Pi個の問題を説いた場合のボーナスポイント込の得点, 1問あたりの得点)
PC = [0] * D
for i in range(D):
    P, C = map(int, input().split())
    PC[i] = [P, 100 * (i + 1) * P + C, 100 * (i + 1)]

# print(PC)

# 各問題で全問解くか解かないかをbit全探索
ans = 10 * 100
for i in range(2 ** D):
    bit = format(i, '0' + str(D) + 'b') # 完答有無
    score = 0 # 得点
    solve = 0

    # print("==========bit: " + bit + " =============")

    # 完答分の得点
    for j in range(D):
        if bit[j] == "1":
            score += PC[j][1]
            solve += PC[j][0]
            # print(j, score, solve)

    # 完答分の得点で足りない場合、解かれていない問題の得点(1つのみ選び、完答しない)で足りるか
    if score < G:
        for k in range(D):
            # print("-(k+1): " + str(-(k+1)), "bit[-(k+1)]: " + str(bit[-(k+1)]))
            if bit[-(k+1)] == "0":
                sol = min((G - score) // PC[-(k+1)][2], PC[-(k+1)][0] - 1) # 解いた数
                if sol == 0:
                    sol = 1
                score += PC[-(k+1)][2] * sol
                solve += sol
                # print(sol, score, solve)
                break

    # 総合スコアがG以上となる場合、問題数が最小であれば答えを更新する
    if score >= G:
        ans = min(ans, solve)
    # print(bit, score, solve, ans)

print(ans)


Measured memory_bytes: 3064
r = int(input())
A = list(map(int, input().split()))

cnt = 0
for a in A:
    for i in range(r - 1, 0, -1):
        if A[i] < A[i-1]:
            A[i-1], A[i] = A[i], A[i-1]
            cnt+=1
print(" ".join(map(str, A)))
print(cnt)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[114514];
int main(){
	ll n;
	cin>>n;
	map<ll,ll>mp;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	if(mp[0]==n)cout<<"Yes";
	else if(n%3)cout<<"No";
	else{
		sort(a,a+n);
		if((mp[0]==n/3&&mp[a[n/3]]==2*n/3)||(mp[a[0]]==n/3&&mp[a[n/3]]==n/3&&mp[a[2*n/3]]==n/3&&((a[0]^a[n/3]^a[2*n/3])==0)))cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 8904
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<n/(a+b)*a+min(a,n%(a+b))<<endl;
}

 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    solve();


    return 0;
}

Measured memory_bytes: 256
def solve():
	n = int(input())
	if n%2 == 0 or n%5 == 0:
		return -1
	if n % 7 == 0:
		n//=7
	n*=9
	cnt = 1
	cur = 10
	while cur % n != 1:
		cur = (cur * 10)%n
		cnt+=1
	return cnt




print(solve())

Measured memory_bytes: 9116
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=3e5+5;


int main()
{ 

IOS;

vl f(101);

ll a,b,c,d;
cin>>a>>b>>c>>d;

for(int i=a;i<=b;i++)f[i]++;

  for(int i=c;i<=d;i++)f[i]++;

    ll cnt=0;

  for(int i=0;i<=100;i++)if(f[i]==2)cnt++;

    if(cnt)cnt--;

d1(cnt);

return 0;
 
}



Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
const ld R=380000,r=1800,s=100,t1=2500000,t2=7200;
bool judge(ld a,ld b,ld c){
/*  ld a=(R*X-(r+s)*Y)*(R*X+(r+s)*Y)+1-X*X-Y*Y;
  ld b=-2*(R*R*X*X-R*(r+s)*X*Y+Y*Y);
  ld c=(R*R-1)*X*X+1-r*r; */

  ld d=b*b-4*a*c;
  if(d<0) return true;
  ld ans=(-b-sqrt(d))/(a*2);
  if(ans>1) return true;
  return false;
}
int main(){
  int m,t_;
  cin>>m>>t_;
  ld m2=(ld)m;
  //return 0;
  ld ans=0;
  for(int i=0;i<t_*60;i++){
    ld t=(ld)i;
    ld xm=R*cos(2*M_PI*((t/t1)+(m2/360)));
    ld ym=R*sin(2*M_PI*((t/t1)+(m2/360)));
    ld zm=0;

    ld xk=-(r+s)*sin(2*M_PI*(t/t2))+xm;
    ld yk=ym;
    ld zk=(r+s)*cos(2*M_PI*(t/t2));

    //if(i==0) cout<<xm<<" "<<ym<<" "<<zm<<" "<<xk<<" "<<yk<<" "<<zk<<endl;

    ld a=xk*xk+yk*yk+zk*zk;
    ld b=-2*(xk*xm+yk*ym);
    ld c=R*R-r*r;
    if(!judge(a,b,c)) ans+=1;
  }
  cout<<(ans/60)<<endl;
}



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

int main()
{
	long long L, R;
	cin >> L >> R;

	long long ans = 2019;
	if( R - L + 1 >= 2019 ) ans = 0;
	else {
		for( long long l = L; l < R; l++ ) {
			for( long long r = l + 1; r <= R; r++ ) {
				ans = min( ans, l * r % 2019 );
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3576
# ARC095C - Many Medians (ABC094C)
def main():
    n = int(input())
    x = list(map(int, input().rstrip().split()))
    l, h = sorted(x)[n // 2 - 1 : n // 2 + 1]
    for i in x:
        if i <= l:
            print(h)
        else:
            print(l)


if __name__ == "__main__":
    main()

Measured memory_bytes: 25220
from math import gcd

N, M = map(int, input().split())
S = input()
T = input()

L = N*M // gcd(N, M)

for i in range(N):
    if M*i % N == 0:
        j = M*i // N
        if S[i] != T[j]:
            print(-1)
            exit()

print(L)


Measured memory_bytes: 9016
#include<stdio.h>
#include<string.h>

int main(){
	char s[100010];
	scanf("%s",s);
	int length = strlen(s);
	int sakaime=0;
	char temp=s[0];// 'B' or 'W'
	int i;
	
	for(i=1;i<length;i++){
		if(temp!=s[i]){
			temp=s[i];
			sakaime++;
		}
	}
	
	printf("%d\n",sakaime);
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>


#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define vint vector<int>
#define INF 1e9

using namespace std;
typedef long long  ll;

int main(){
    int n;
    cin >> n;
    vector<double> a(n);
    REP(i, 0, n){
        cin >> a[i];
    }

    double ans = 0;
    REP(i, 0, n){
        ans += 1/a[i];
    }

    cout << fixed << setprecision(20) << 1/ans << endl;

    return 0;
}


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N;
  cin >> N;
  long double tmp = 0;
  long double sum = 0;
  for(int i = 0; i < N; i++){
    cin >> tmp;
    sum += 1/tmp;
  }
  cout << 1/sum << endl;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  for (int i = 0; i < M; i++){
    cin >> a.at(i);
    N -= a.at(i);
  }
  if (N < 0){
    cout << -1 << endl;
  }
  else{
    cout << N << endl;
  }
}

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

int main(){
    string S;
    cin >> S;
    string T = "CODEFESTIVAL2016";
    int count=0;
    rep(i,16) if(S[i] != T[i]) count++;
    cout << count << endl;
    return 0;
}

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

using namespace std;

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

    int n, x;
    cin >> n >> x;
    int pre, cur;
    cin >> pre;
    n--;
    long long total = 0;
    while (n--) {
        cin >> cur;
        int diff = pre + cur - x;
        if (diff > 0) {
            total += diff;
            cur -= min(cur, diff);
        }
        pre = cur;
    }

    printf("%lld\n", total);

    return 0;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    string s;
    string ans;
    cin >> s;
    for(auto &c: s) {
        switch(c) {
            case '0':
            ans.push_back('0');
            break;
            case '1':
            ans.push_back('1');
            break;
            case 'B':
            if(ans.size()) ans.pop_back();
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

#define ll long long
#define INF 100000000000000

using namespace std;

int main() {
  ll N, M;
  cin >> N >> M;

  ll a[1005], b[1005], c[1005];
  ll dist[105][105];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dist[i][j] = INF;
    }
    dist[i][i] = 0;
  }
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    dist[a[i]][b[i]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
    }
  }

  ll ans = M;
  for (int i = 0; i < M; i++) {
    bool flag = false;
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        if (dist[j][k] == dist[j][a[i]] + c[i] + dist[b[i]][k]) {
          flag = true;
        }
      }
    }
    if (flag) {
      ans--;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 384
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int main() {
    int N;
    cin >> N;
    string P, Q, S;
    for(int i = 1; i <= N; i++) {
        string tmp;
        cin >> tmp;
        P += tmp;
        S += to_string(i);
    }
    for(int i = 0; i < N; i++) {
        string tmp;
        cin >> tmp;
        Q += tmp;
    }
    int i = 0;
    int p, q;
    do {
        i++;
        if(S == P)
            p = i;
        if(S == Q)
            q = i;
    } while(next_permutation(S.begin(), S.end()));
    cout << abs(p-q) << endl;

    return 0;
}

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

int main(){
  int K,S,ans;
  cin>>K>>S;
  ans = 0;

  for(int i=0;i<K+1;i++){
    if(S-i<=2*K){
      for(int j=0;j<K+1;j++){
        if(S-i-j<=K&&S-i-j>=0){
          ans++;
          //cout<<i<<" "<<j<<" "<<S-i-j<<endl;
        }
      }
    }
  }
  cout<<ans<<endl;
}


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

public class Main {

	private static List<Long> getStrings(Scanner sc, int num) {
		List<Long> stringList = new ArrayList<>();
		while(num>0) {
			long nextInt = sc.nextLong();
			stringList.add(nextInt);
			num--;
		}
		return stringList;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Long> array = getStrings(sc, n);
		int count = 0;
		for (int i = 0; i < n; i+=2) {
			if (array.get(i) % 2 ==1) {
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 35632
#include <bits/stdc++.h>
using namespace std;
	
int main(){
  int i,j;
  int N;
  cin>>N;
  int a[N],b[N];
  for(i=0;i<N;i++) {
	cin>>a[i];
	b[i]=a[i];
  }
  sort(a,a+N);
	int p=a[N/2];
  for(i=0;i<N;i++){
	if(b[i]>=p) cout<<a[N/2-1]<<endl;
	else cout<<p<<endl;
  }
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int ,int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N, M;
	cin >> N >> M;
	if (N == M)
		cout << "Yes\n";
	else
	cout <<"No\n";
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256