akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <time.h>
#include <random>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define LONG_INF 10000000000000000
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int hoge[1000] = {};
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	for (int i = 0;i < s.length();++i) {
		hoge[s[i]]++;
	}
	REP(i, n-1) {
		string sa;
		cin >> sa;
		int gya[1000] = {};
		for (int q = 0;q < sa.length();++q) {
			gya[sa[q]]++;
		}
		for (int q = 0;q < 1000;++q) {
			hoge[q] = min(hoge[q], gya[q]);
		}
	}
	for (int i = 'a';i <= 'z';++i) {
		for (int q = 0;q < hoge[i];++q) {
			cout << (char)i;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int ans = 0;
  for (int i = 0; i*r <= n; i++) {
    for (int j = 0; i*r+j*g <= n; j++) {
      int rem = n-i*r-j*g;
      if (!(rem%b))
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        boolean key = false;
        for (int i = A; i <= B; i++) {
        	if (i%K == 0) {
        		key = true;
        		break;
        	}
        }
        System.out.println(key ? "OK" : "NG");
    }
}

Measured memory_bytes: 35804
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,k,ans=1;
string s;
signed main(){
	cin>>n>>s;
	int cnt[26]={0};
	rep(i,n){
		cnt[s[i]-'a']++;
	}
	rep(i,26){
		ans*=(cnt[i]+1);
		ans%=MOD;
	}
	cout<<(ans-1+MOD)%MOD<<endl;
}

Measured memory_bytes: 512
import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def check(l):
  for i in l:
    if i >= X:
      continue
    else:
      return False
  else:
    return True

N,M,X = IL()
ca = [IL() for i in range(N)]

ans = MAX_INT
for i in range(1 << N):
  x = 0
  rikaido = [0]*M
  for j in range(N):
    if (i >> j) & 1 == 1:
      x += ca[j][0]
      for k in range(1,M+1):
        rikaido[k-1] += ca[j][k]
  else:
    if check(rikaido):
      ans = min(ans, x)
if ans == MAX_INT:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 68912
#include <stdio.h>
#include <stdlib.h>
int main(){
int n,t,a,ho=10000000,mm=0,i;
scanf ("%d%d%d",&n,&t,&a);
int h[n];
int k[n];

for (i=0;i<n;i++){
scanf ("%d",&h[i]);
  k[i]=abs(1000*t-(h[i]*6)-1000*a);
  if (ho>k[i]){
    ho=k[i];
    mm=i;
  }
}

printf ("%d",mm+1);
  return 0;
}


Measured memory_bytes: 128
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	x := sc.ReadInt()
	m := sc.ReadInt()

	visitedTime := make([]int, m)
	visitedTime[x] = 1

	ai := x
	i := 2
	for ; i <= m+1; i++ {
		ai = ai * ai % m
		if visitedTime[ai] > 0 {
			break
		}
		visitedTime[ai] = i
	}
	iLoopEnd := i - 1
	iLoopStart := visitedTime[ai]
	loopSpan := iLoopEnd - iLoopStart + 1

	total := 0
	ai = x
	if n <= iLoopStart {
		for i = 1; i <= n; i++ {
			total += ai
			ai = ai * ai % m
		}
		fmt.Println(total)
		return
	}
	for i = 1; i < iLoopStart; i++ {
		total += ai
		ai = ai * ai % m
	}

	loopTotal := 0
	for ; i <= iLoopEnd; i++ {
		loopTotal += ai
		ai = ai * ai % m
	}

	loopCount := (n - iLoopStart + 1) / loopSpan
	restCount := (n - iLoopStart + 1) % loopSpan

	total += loopTotal * loopCount

	for i = iLoopStart; i < iLoopStart+restCount; i++ {
		total += ai
		ai = ai * ai % m
	}

	fmt.Println(total)
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadFloat() float64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseFloat(text, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 2580
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int N,M,Q;
vector<int> a,b,c,d;
ll ans;
//参考:解説放送
void dfs(vector<int>A){

if(A.size()==N+1)//([0]を1にしてi-indexedにしているため)
{
  //calc ans
  ll ans2=0;
   rep(j,Q)//それぞれのクエリについて
   {
    if(A.at(b[j]-1)-A.at(a[j]-1)==c[j]) ans2+=d[j];
   }
   ans=max(ans,ans2);
  return;
}
A.push_back(A.back());
while(A.back()<=M)
{
  dfs(A);
  A.back()++;
}

}
int main() {
cin>>N>>M>>Q;
a=b=c=d=vector<int>(Q);

rep(i,Q)
{
  cin>>a[i]>>b[i]>>c[i]>>d[i];
}

dfs(vector<int>(1,1));

cout << ans<<endl;

}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A, N, S;
    cin >> N >> A;
    S = N%500;
    if (S<=A){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

const unsigned long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

long long arr[50];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    long long k; cin >> k;

    cout << "50\n";

    for(int i = 0; i < 50; ++i)
        arr[i] = k / 50 + 49;

    k = 50 - k % 50;

    for(int i = 0; i < 50; ++i){
        if(i < k)
            cout << arr[i] - 50 + k << " ";
        else
            cout << arr[i] + k << " ";
    }

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

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

int main() {
    list<int> l;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        char tmp[100];
        int a;
        scanf("%s", &tmp);
        string s = tmp;
        if (s != "deleteLast" && s != "deleteFirst") {
            scanf("%d", &a);
        }

        if (s == "insert") {
            l.push_front(a);
        } else if (s == "delete") {
            for (auto it = l.begin(); it != l.end(); it++) {
                if (*it == a) {
                    l.erase(it);
                    break;
                }
            }
        } else if (s == "deleteFirst") {
            l.pop_front();
        } else if (s == "deleteLast") {
            l.pop_back();
        }
    }

    for (auto it = l.begin(); it != l.end(); it++) {
        cout << *it;
        if (next(it, 1) != l.end()) cout << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 34520
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;

int main() {
	
	string s;
	cin >> s;
	
	int a = -1, z = 0;
	rep(i, s.size()){
		if(s[i] == 'A' && a == -1) a = i;
		else if(s[i] == 'Z') z = i;
	}
	
	cout << z - a + 1 << endl;
	
	return 0;
}

Measured memory_bytes: 640
/**
 *  author: Behradm
 *  Created: 2020.08.02 16:24:10
 *  In The Name Of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cout << (n >= 30 ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 3652
import itertools

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

num = dict()

for a in A:
    if a not in num:
        num[a] = 0
    num[a] += 1

m1 = 0
m2 = 0

for a in sorted(num.keys(), reverse=True):
    if num[a] >= 2:
        m1 = a
        num[a] = num[a] - 2
        break
for a in sorted(num.keys(), reverse=True):
    if num[a] >= 2:
        m2 = a
        num[a] = num[a] - 2
        break
print(m1*m2)

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

int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  string S;
  cin >> S;

  int max = 0;
  int x = 0;
  for(int i=0; i<N; i++){
    if(S.at(i) == 'I')
      x++;
    else if(S.at(i) == 'D')
      x--;
    if(max < x)
      max = x;
  }
  cout << max;
  return 0;
}


Measured memory_bytes: 256
'''
Created on 2020/08/22

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,X,T=map(int,pin().split())
  if N%X==0:
    print((N//X)*T)
  else:
    print((N//X+1)*T)
  return 
main()

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

 
int main(){
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  rep(i,n){
    int k; cin>>k;
    x = max(x,k);
  }
  rep(i,m){
    int k; cin>>k;
    y = min(y,k);
  }
  if(x<y){ cout << "No War" << endl; return 0;}
  cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int t[60];

int main() {
	int N;
	cin >> N;
	vector<string> S(N);
	for(int i=0; i<N; ++i) cin >> S[i] >> t[i];
	string X;
	cin >> X;
	int ans=0, now=0;
	for(int i=0; i<N; ++i){
		ans += t[i]*now;
		if(S[i]==X) now=1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int N = 100;
int merg(int x,int y);
int Find(int x);
int a[N][N];
const int inf = 0x3f3f3f3f;

int main()
{
    int n;
    while(scanf("%d", &n),n!=0)
    {
        for(int i=0;i<=15;i++)
        {
            for(int j=0;j<15;j++)
            {
                if(i==j)
                {
                    a[i][j]=0;
                }
                else
                {
                    a[i][j]=inf;
                }

            }
        }
        for(int i=0;i<n;i++)
        {
            int x, y, z;
            scanf("%d %d %d", &x, &y, &z);
            a[x][y]=min(a[x][y],z);
            a[y][x]=a[x][y];
        }
        for(int i=0;i<=15;i++)
        {
            for(int j=0;j<=15;j++)
            {
                for(int k=0;k<=15;k++)
                {
                    if(a[j][k]>a[j][i]+a[i][k]&&a[i][k]!=inf&&a[j][i]!=inf)
                    {
                        a[j][k]=a[j][i]+a[i][k];
                    }
                }
            }
        }
        int sum=inf, u;
        for(int i=0;i<=15;i++)
        {
            int tmp=0;
            for(int j=0;j<=15;j++)
            {
                if(a[i][j]!=inf)
                {
                    tmp+=a[i][j];
                }
            }
            if(tmp==0)
            {
                continue;
            }
            if(tmp<sum)
            {
                sum=tmp;
                u=i;
            }
        }
        printf("%d %d\n", u, sum);
    }
    return 0;
}

Measured memory_bytes: 1192
a,b,c = map(int, input().split())

# 約数
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

c_div = sorted(make_divisors(c))
cnt = 0
for d in c_div:
    if a <= d and d <= b:
        cnt += 1
print(cnt)


Measured memory_bytes: 5640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

vector<long long> dijkstra(int n, int s, const vector<vector<pair<long long, int>>> &G) {
    priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>>
        que;
    vector<long long> d(n, 1LL << 60);
    d[s] = 0;
    que.push(pair<long long, int>(0, s));
    while (!que.empty()) {
        pair<long long, int> p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
            pair<long long, int> e = G[v][i];
            if (d[e.second] > d[v] + e.first) {
                d[e.second] = d[v] + e.first;
                que.push(pair<long long, int>(d[e.second], e.second));
            }
        }
    }
    return d;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<pair<long long, int>>> G(N);
    for(int i=0; i<N-1; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back(make_pair(c, b));
        G[b].push_back(make_pair(c, a));
    }
    int Q, K;
    cin >> Q >> K;
    K--;
    vector<long long> d = dijkstra(N, K, G);
    for(int i=0; i<Q; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << d[x] + d[y] << endl;
    }

    return 0;
}


Measured memory_bytes: 11120
import sys

s = list(input())

for i in range(len(s)):
    if (i + 1) % 2 == 0:
        if s[i] != 'L' and s[i] != 'U' and s[i] != 'D':
            print('No')
            sys.exit()
    else:
        if s[i] != 'R' and s[i] != 'U' and s[i] != 'D':
            print('No')
            sys.exit()

print('Yes')


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

max_cnt = 0
for i in range(2, N):
    first_half = set(S[0:i])
    latter_half = set(S[i:N+1])

    intersect = first_half & latter_half

    max_cnt = max(max_cnt, len(intersect))

print(max_cnt)
    




Measured memory_bytes: 2940
n,q = gets.split.map(&:to_i)
ss = gets.split('')
lrs = q.times.map{ gets.split.map(&:to_i) }

counts = []
ss.each.with_index do |str, i|
  if i == 0
    counts[i] = 0
  elsif ss[i-1]=='A' && ss[i]=='C'
    counts[i] = counts[i-1] + 1
  else
    counts[i] = counts[i-1]
  end
end

lrs.each do |lr|
  l, r = lr
  puts counts[r-1] - counts[l-1]
end

Measured memory_bytes: 25544
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int c=0,ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
        {
            if(i%j==0&&i%2==1)c++;
        }
       // printf("%d\n",c);
        if(c==8)ans++;

        c=0;

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


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second


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

    ll w,h,x,y,ar,ans=0,c=0;
    cin >> w >> h >> x >> y;

    /*
    ar = w*h;
    if (x != 0 && x<w)
    {
        ll tmp = h*x;
        ans = min(tmp , ar-tmp);
    }

    if (y != 0 && y < h)
    {
        ll tmp = w*y;
        if (min(tmp,ar-tmp) == ans) c=1;
        ans = max(ans , min(tmp,ar-tmp));
    }

    if (ans==0) cout << fixed << setprecision(10) << (ld)ar/2 << ' ' << 0 << '\n';
    else
    cout << fixed << setprecision(10) << (ld)ans << ' ' << c << '\n';
     */

    ar = w*h;
    cout << fixed << setprecision(10) << (ld)ar/2 << ' ' << (x*2==w && y*2==h) << '\n';


    return 0;
}

Measured memory_bytes: 3772
#include <cstring>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        ll n;
        cin >> n;
        vector<ll> b;
        rep(i, n) {
            ll temp;
            cin >> temp;
            b.emplace_back(temp);
        }

        vector<ll> ans;
        for (ll i = n; i >= 1; i--) {
            vector<ll> a;
            bool has = false;
            ll elem = 0, idx = 0;
            repr(j, b.size()) {
                if (b[j] <= i && b[j] == (j + 1)) {
                    if (b[j] >= elem) {
                        elem = b[j];
                        idx = j;
                    }
                    has = true;
                }
            }

            if (!has) {
                cout << -1 << endl;
                return 0;
            }
            rep(j, b.size()) {
                if (j != idx) a.emplace_back(b[j]);
                else ans.emplace_back(b[j]);
            }
            b = a;
        }

        repr(i, n) printf("%lli ", ans[i]);

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))

const int inf = 999999999;
const int mod = 1000000007;

int main(){
	int n, Ma, Mb; cin >> n >> Ma >> Mb;
	int a[n + 1], b[n + 1], c[n + 1], A = 0, B = 0;
	Rep(i, n){
		cin >> a[i + 1] >> b[i + 1] >> c[i + 1];
		A += a[i + 1]; B += b[i + 1];
	}
	int dp[A + 1][B + 1][n + 1];
	Rep(i, n + 1) Rep(j, A + 1) Rep(k, B + 1) dp[j][k][i] = inf;
	dp[0][0][0] = 0;
	Rep(i, n) Rep(j, A + 1) Rep(k, B + 1){
		if(j >= a[i + 1] && k >= b[i + 1]){
			dp[j][k][i + 1] = min(dp[j - a[i + 1]][k - b[i + 1]][i] + c[i + 1], dp[j][k][i]);
		}else{
			dp[j][k][i + 1] = dp[j][k][i];
		}
	}
	int ans = inf;
	bool flag = true;
	int t = min(A / Ma, B / Mb);
	For(i, 1, t + 1){
		int s = dp[Ma * i][Mb * i][n];
		if(s != 0 && s != inf){
			ans = min(ans, s);
			flag = false;
		}
	}
	if(flag){
		cout << -1 << endl;
	}else{
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 9472
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
	long int N;
	string S;
	cin >> N >> S;
	map<char, long int> mp;
	string::iterator itr = S.begin();
	vector<long int> A(26,0);
	for(int i=0;i<N;i++){
		A[*(itr + i)-'a']++;
	}
	long int count = 1;
	for(int i=0;i<26;i++){
		count = count * (A[i] + 1);
		count = count % 1000000007;
	}
	count =count - 1;
	cout << count  << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    ll pref[n+1];
    ll fg=0;
    while(k--)
    {
        for (int i = 0; i < n+1; ++i)
        {
            pref[i]=0;
        }
        for (int i = 0; i < n; ++i)
        {
            ll l = max(0, i-a[i]);
            ll r = min(n-1, i+a[i]);
            pref[l]=pref[l]+1;
            pref[r+1]=pref[r+1]-1;
        }
        for (int i = 1; i < n+1; ++i)
        {
            pref[i]=pref[i-1]+pref[i];
        }
        for (int i = 0; i < n; ++i)
        {
            a[i]=pref[i];
        }
        fg=0;
        for (int i = 0; i < n; ++i)
        {
            if(a[i]!=n){
                fg=1;
                break;
            }
        }
        if(fg==0){
            break;
        }
    }

    for (int i = 0; i < n; ++i)
    {
        cout<<a[i]<<" ";
    }
    
    return 0;
}

Measured memory_bytes: 6788
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
using namespace std;

#define ll long long

#define MOD 1000000007

int main()
{
    int n;
    ll k;

    ll* a;
    a = new ll[n];
    ll* counter;
    counter = new ll[n];
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >>a[i];
    }

    ll counter1 = 0;

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < i; j++)
        {
            if (a[i]<a[j])
            {
                counter1++;
            }

        }
    }


    ll counter2 = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j= 0; j < n; j++)
        {
            if(a[i]<a[j]){
                counter2++;
            }
        }
    }

    ll answer = 0;
    counter1 %=MOD;
    counter2 %=MOD;
    ll number;
    number = ((k-1)*k/2)%MOD;

    ll temp = 0;

  
    temp = (number*counter2)%MOD;
    answer = temp+ answer + counter1*k;
    answer %=MOD;

    cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    vector<int> Y(N);
    for (int i = 0; i < N; i++){
        cin >> X.at(i);
        Y.at(i) = X.at(i);
    }
    sort (Y.begin(), Y.end());
    int mid_1 = Y.at(N/2 - 1), mid_2 = Y.at(N/2);
    for (int i = 0; i < N; i++){
        if (X.at(i) <= mid_1) cout << mid_2 << endl;
        else if (X.at(i) >= mid_2) cout << mid_1 << endl;
    }
}

Measured memory_bytes: 3712
n=gets.to_i
t=gets.split.map &:to_i
v=gets.split.map &:to_i

a=[]
s=0
t.zip(v) do |x, y|
    for i in 0...2*x
        a<<s
        s=[s+0.5, y].min
    end
end

b=[]
s=0
t.reverse.zip(v.reverse) do |x, y|
    for i in 0...2*x
        s=[s+0.5, y].min
        b<<s
    end
end

p a.zip(b.reverse).each_cons(2).map{|x, y| (x.min+y.min)*0.5}.inject(0.25, :+)/2


Measured memory_bytes: 6976
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
 
int main(){
    vector<int>x,y,d;
    static int zx[1000000+2],zy[1000000+2],zd[1000000+2],p[50][6],n,k,sea[102][102][102];
    long long int ans=0,a;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        for(int j=0;j<6;j++){
            scanf("%d",&p[i][j]);
        }
        x.push_back(p[i][0]);
        x.push_back(p[i][3]);
        y.push_back(p[i][1]);
        y.push_back(p[i][4]);
        d.push_back(p[i][2]);
        d.push_back(p[i][5]);
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    sort(d.begin(),d.end());
    int N=2*n+1;
    for(int i=0;i<N-1;i++){
        zx[x[i]]=i;
        zy[y[i]]=i;
        zd[d[i]]=i;
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int l=0;l<N;l++){
                sea[i][j][l]=0;
            }
        }
    }
     
    for(int i=0;i<n;i++){
        sea[zx[p[i][0]]][zy[p[i][1]]][zd[p[i][2]]]++;
        sea[zx[p[i][0]]][zy[p[i][1]]][zd[p[i][5]]]--;
        sea[zx[p[i][0]]][zy[p[i][4]]][zd[p[i][2]]]--;
        sea[zx[p[i][0]]][zy[p[i][4]]][zd[p[i][5]]]++;
        sea[zx[p[i][3]]][zy[p[i][1]]][zd[p[i][2]]]--;
        sea[zx[p[i][3]]][zy[p[i][1]]][zd[p[i][5]]]++;
        sea[zx[p[i][3]]][zy[p[i][4]]][zd[p[i][2]]]++;
        sea[zx[p[i][3]]][zy[p[i][4]]][zd[p[i][5]]]--;
    }
    for(int i=1;i<N;i++){
        for(int j=0;j<N;j++){
            for(int l=0;l<N;l++){
                sea[i][j][l]+=sea[i-1][j][l];
            }
        }
    }
    for(int i=0;i<N;i++){
        for(int j=1;j<N;j++){
            for(int l=0;l<N;l++){
                sea[i][j][l]+=sea[i][j-1][l];
            }
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int l=0;l<N;l++){
                if(l!=0)sea[i][j][l]+=sea[i][j][l-1];
                if(sea[i][j][l]>=k){
                    a=1;
                    a*=x[i+1]-x[i];
                    a*=y[j+1]-y[j];
                    a*=d[l+1]-d[l];
                    ans+=a;
                }
            }
        }
    }
    printf("%lld\n",ans);
}

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

int main()
{
  int a[3][3];
  rep(i, 3){
    rep(j, 3) cin >> a[i][j];
  }
  int x[3], y[3];
  string s = "Yes";
  x[0] = 0;
  rep(i, 3) y[i] = a[0][i] - x[0];
  rep(i, 3) x[i] = a[i][0] - y[0];
  rep(i, 3){
    rep(j, 3){
      if(x[i] + y[j] != a[i][j]) s = "No";
    }
  }
  cout << s << endl;
       

  return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  int ans = 0;
  rep(i, n){
    int a;
    cin >> a;
    if(i & 1) continue;
    if(a & 1) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
    int H, W, i, j;

    while(1){
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0){
            break;
        }
        for(i = 0; i < H; i++){
            for(j = 0; j < W; j++){
                if(i > 0 && i < H - 1 && j > 0 && j < W - 1){
                    printf(".");
                    continue;
                }
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2112
//ABC93_C Main

import java.util.Scanner;

public class Main{

	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();

		int max = 0;
		int mid = 0;
		int min = 0;



		if (A>=C && A>=B) {

			if(B>=C) {

				max = A;
				mid = B;
				min = C;

				//System.out.println("typeA");


			}
			else {

				max = A;
				mid = C;
				min = B;

				//System.out.println("typeB");


			}

		}
		else if (B>=A && B>=C) {

			if(A>=C) {

				max = B;
				mid = A;
				min = C;

				//System.out.println("typeC");


			}
			else {

				max = B;
				mid = C;
				min = A;

				//System.out.println("typeD");


			}

		}
		else{

			if(A>=B) {

				max = C;
				mid = A;
				min = B;

				//System.out.println("typeE");


			}
			else {

				max = C;
				mid = B;
				min = A;

				//System.out.println("typeF");


			}

		}

		int d1 = max - mid;
		int d2 = mid - min;

		//System.out.println("d1:" + d1);
		//System.out.println("d2:" + d2);


		int N =0;


		if(d1%2 == 0 && d2%2 == 0) {

			N = (d1*2+d2)/2;

			//System.out.println("typeA");

		}
		else if(d1%2 == 1 && d2%2 == 0){

			N = 1 + ((d1-1)*2 + d2)/2;

			//System.out.println("typeB");


		}
		else if(d1%2 == 0 && d2%2 == 1) {

			N = 1 + (d1*2 + (d2+1))/2;

			//System.out.println("typeC");


		}
		else {

			N =  2 + ((d1-1)*2+(d2+1))/2; //  2 + ((d1-1)+(d2+1))/2;

			//System.out.println("typeD");


		}

		System.out.println(N);

	}
}

Measured memory_bytes: 23764
N=int(input())
S=list(map(int,input().split()))

K=int(input())
T=list(map(int,input().split()))

#def binary_search()
count=0
for i in range(K):
    tmp=T[i]
    left=0
    right=N-1
    flag=False
    while left<=right:
        mid=(left+right)//2
        if S[mid]==T[i]:
            count+=1
            break
        elif S[mid]>T[i]:
            right=mid-1
        elif S[mid]<T[i]:
            left=mid+1
        else:
            print("イレギュラーな例につかまりました")
            exit()
        
print(count)


Measured memory_bytes: 16708
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}

signed main() {
  int N;
  cin >> N;
  vector<int> light(N);
  vector<int> maxi_num_R(N);
  vector<int> maxi_num_L(N);

  rep(i, N) cin >> light[i];
  int maxi = 0;
  int L    = 0;
  int R    = 0;
  while (true) {
    maxi_num_R[R] = max(maxi_num_R[R], R - L + 1);
    maxi_num_L[L] = max(maxi_num_L[L], R - L + 1);
    if (R == N-1) break;
    if (light[R] != light[R + 1]) {
      R++;
    } else if (R == L) {
      R++;
      L++;
    } else {
      L++;
    }
  }
  maxi_num_R[N-1] = max(maxi_num_R[N-1], R-L+1);
  rep(i, N-1) maxi_num_L[i+1] = max(maxi_num_L[i+1], maxi_num_L[i]-1);
  R = L = 0;
  while (R != N - 1) {
    if (L != 0 and R != N - 1) maxi = max(maxi, R - L + 1 + maxi_num_R[L - 1] + maxi_num_L[R + 1]);
    if (L != 0) maxi = max(maxi, R - L + 1 + maxi_num_R[L - 1]);
    if (R != N - 1) maxi = max(maxi, R - L + 1 + maxi_num_L[R + 1]);
    if (light[R] != light[R + 1]) {
      R++;
    } else if (R == L) {
      R++;
      L++;
    } else {
      L++;
    }
  }
  cout << maxi << endl;
}



Measured memory_bytes: 5116
#include<bits/stdc++.h>
using namespace std;
 
#define 	pi 				3.1415926536
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define     len             length()
#define 	F 				first
#define 	S 				second
#define 	PB 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vll             vector<ll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
 
/*############################# DSU ##############################*/
vll parent(1e5), Size(1e5), Rank(1e5);
 
void make_set(ll v){
    parent[v]=v;
    Size[v] = 1;
    // Rank[v] = 0;
}
 
int find_set(ll v){
    return (parent[v]==v) ?  v : parent[v] = find_set(parent[v]);
}
 
void union_sets(ll a, ll b){
    a = find_set(a);
    b = find_set(b);
    if(a != b){
        if(Size[a] < Size[b])
            swap(a, b);
        // if(Rank[a] < Rank[b])
        //     swap(a, b);
        parent[b] = a;
        Size[a] += Size[b];
        // if(Rank[a] == Rank[b])
        //     Rank[a]++;
    }
}
/*############################# DSU ##############################*/
 
// ostringstream str1;
//             str1 << n;
//             string tmp = str1.str();
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
 
vll pwx(32);
void cal(ll x){ pwx[0] = 1; rep(i, 1, 32)pwx[i] = x*pwx[i-1]; }
 
/* ################################################################ */
 
 
void solve()
{
    string s; cin>>s;
    ll n = s.len;
    // cout<<s[1]-'0'<<nl;
    if(s[n-1] == '2' || s[n-1] == '4' || s[n-1] == '5' || s[n-1] == '7' || s[n-1] == '9'){
        cout<<"hon"<<nl;
    }
    else if(s[n-1] == '8' || s[n-1] == '6' || s[n-1] == '1' || s[n-1] == '0'){
        cout<<"pon\n";
    }
    else
        cout<<"bon\n";
}
 
 
int main(){
    // boost;
    // cal(2);
    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}

Measured memory_bytes: 5444
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define ll long long
#define Test int t;cin>>t;while(t--)
using namespace std;
const int dx[]={-1,-1,-1,0,0,0,1,1,1};
const int dy[]={-1,0,1,-1,0,1,-1,0,1};
void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int a[200001];
int main()
{
    fast();
    ll n,m;
    cin>>n>>m;
    ll sum=0,k;
    for(int i=0;i<m;i++){
        cin>>k;
        sum+=k;
    }
    n-=sum;
    if(n<0){cout<<-1;}
    else {
        cout<<n;
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
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;}
ll ceilll(ll a, ll b) {return (a + b-1) / b;}
ll get_digit(ll a) {ll digit = 0; while(a != 0){a /= 10; digit++;} return digit;} // a != 0

// 0 false, 1 true 
// string number to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll x, k, d; cin >> x >> k >> d;

    x = abs(x);
        if(x >= d){
            ll tmp = x / d;
            if(tmp > k){
                cout << x - (d * k) << endl;
                return 0;
            }

            k -= tmp;
            ll now = x - (d * tmp);
            if(k % 2 == 0){
                cout << abs(now) << endl;
            }else{
                if(now < 0){
                    cout << abs(now + d) << endl;
                }else{
                    cout << abs(now - d) << endl;
                }
            }
        }else{
            k -= 1;
            ll now = x - d;
            if(k % 2 == 0){
                cout << abs(now) << endl;
            }else{
                if(now < 0){
                    cout << abs(now + d) << endl;
                }else{
                    cout << abs(now - d) << endl;
                }
                
            }
        }

}

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

int main() {
  int N;
  cin >> N;
  vector<int> T(N);
  int A;
  A = 0;
  for(int i = 0; i < N; i++) {
    cin >> T[i];
    A += T[i];
  }
  
  int M;
  cin >> M;
  
  vector<int> P(M);
  vector<int> X(M);
  
  for(int i = 0; i < M; i++) {
    cin >> P[i] >> X[i];
    cout << A + X[i] - T[P[i] - 1] << endl;
  }
  return 0;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n;
    cin >> n;
    double ans=0;
    REP(i,n){
        double a;
        cin >> a;
        ans+=1/a;
    }
    printf("%.7f\n",1/ans);

    return 0;
}

Measured memory_bytes: 3788
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 998244353L;
template<class T> inline void chmin(T& a, T b) { if (a > b) a = b; }
template<class T> inline void chmax(T& a, T b) { if (a < b) a = b; }
template<class T> inline T MaxE(vector<T>& v, ll S, ll E) { T m = v[S]; for (ll i = S; i <= E; i++)chmax(m, v[i]); return m; }//v[S]～v[E]の最大値
template<class T> inline T MinE(vector<T>& v, ll S, ll E) { T m = v[S]; for (ll i = S; i <= E; i++)chmin(m, v[i]); return m; }
template<class T> inline T MaxE(vector<T>& v, ll N) { return MaxE(v, 0, N - 1); } //先頭N個中の最大値
template<class T> inline T MinE(vector<T>& v, ll N) { return MinE(v, 0, N - 1); } //先頭N個中の最小値
template<class T> inline T MaxE(vector<T>& v) { T m = v[0]; for (T e : v)chmax(m, e); return m; }
template<class T> inline T MinE(vector<T>& v) { T m = v[0]; for (T e : v)chmin(m, e); return m; }


void cinv(lls& llVec, ll n, bool to_0_origin = false) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		if (to_0_origin) val--;
		llVec.push_back(val);
	}
}

int main()
{
	std::string s, t;
	cin >> s >> t;
	ll sLen = s.length();
	ll tLen = t.length();

	//テーブル初期化
	ll i_ = 1, j_ = 1; //offset
	std::vector<lls> tbl(tLen + i_, lls(sLen + j_, 0));

	//DP計算
	for (ll i = 0; i < tLen; i++) {
		for (ll j = 0; j < sLen; j++) {
			if (t[i] == s[j]) {
				tbl[i+i_][j+j_] = tbl[i - 1+i_][j - 1+j_] + 1;
			}
			else {
				tbl[i + i_][j + j_] = std::max(tbl[i - 1+i_][j+j_], tbl[i+i_][j-1+j_]);
			}
		}
	}

	//復元
	ll ii = tLen - 1;
	ll jj = sLen - 1;
	std::string retStr = "";
	while (ii >= 0 && jj >= 0) {
		if (t[ii] == s[jj]) {
			retStr = t[ii] + retStr;
			ii--; jj--;
		}
		else {
			if (tbl[ii + i_][jj + j_] == tbl[ii + i_][jj - 1 + j_]) {
				jj--;
			}
			else {
				ii--;
			}
		}
	}

	cout << retStr << '\n';

	return 0;
}


Measured memory_bytes: 70784
import java.math.BigDecimal;
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        BigDecimal A = sc.nextBigDecimal();
        BigDecimal B = sc.nextBigDecimal();
        
        System.out.println(A.multiply(B).setScale(0, BigDecimal.ROUND_DOWN));
    }
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  int n, m;
  cin >> n >> m;
  vector<int64> hs(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> hs[i];
  }

  auto dp = Make2DVector<int64>(n + 1, n + 1, INT64_MAX);
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int l = 0; l < i; l++) {
      for (int k = 0; k < i; k++) {
        if (dp[l][k] < INT64_MAX) {
          UpdateMin(dp[i][k + 1], dp[l][k] + max(hs[i] - hs[l], 0LL));
        }
      }
    }
  }

  int64 ans = INT64_MAX;
  for (int l = 0; l <= n; l++) {
    UpdateMin(ans, dp[l][n - m]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

ans = 0
temp = 0
for ai in a:
    temp += ai
    if temp <= x:
        ans += 1
    else:
        break

if ans == N:
    if sum(a) != x:
        ans -= 1

print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

const int n = 1001;

int main()
{
    vector<int> a(n+1);
    a[0] = 1;
    a[1] = 2;
    for(int i=2; i<=n; ++i)
        a[i] = (a[i-1] + a[i-2]) % n;

    for(;;){
        int v, d;
        if(!(cin >> v >> d))
            return 0;

        UnionFindTree uft(v);
        for(int i=1; i<=v; ++i){
            for(int j=i+1; j<=v; ++j){
                if(abs(a[i] - a[j]) < d)
                    uft.unite(i-1, j-1);
            }
        }

        cout << uft.getNum() << endl;
    }
}

Measured memory_bytes: 0
/**
 * @author Video Vocabulary
 * @date 2020-08-02 18:32:17
 */
#include <bits/stdc++.h>

using namespace std;

void solve() {
    
}

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

    long long n, d, ans = 0;
    cin >> n >> d;
    for (int i=0; i<n; i++) {
        long long x, y;
        cin >> x >> y;
        if (d*d >= x*x + y*y) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
from collections import deque

N,M = map(int,input().split())
G = [None] + [[] for i in range(N)]
dist = [None]+[-1]*N
ans = [None]+[10**6]*N

for _ in range(M):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)

deq = deque()

dist[1] = 0
deq.append(1)

while len(deq) != 0:
    v = deq.popleft()
    
    for i in G[v]:
        if dist[i] != -1:
            if dist[v]-dist[i] == 1:
                ans[v] = i
            continue
        dist[i] = dist[v]+1
        deq.append(i)

print("Yes")

for i in range(2,N+1):
    print(ans[i])

Measured memory_bytes: 108688