akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(T a){
	cout << a << '\n';
}
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
string a[3];
bool ok[3][3][5005];
int main(){
	rep(i,3) g(a[i]);
	rep(i,3)rep(j,3){
		if(i >= j) continue;
		rep(x,a[i].size()) rep(y,a[j].size()){
			if(a[i][x] != a[j][y] && a[i][x] != '?' && a[j][y] != '?'){
				if(x >= y){
					ok[i][j][x-y] = 1;
				}
				if(x <= y){
					ok[j][i][y-x] = 1;
				}
			}
		}
	}
	int p[3]={0,1,2},ans=INF;
	do{
		rep(i,2005){
			rep(j,2005){
				if(ok[p[0]][p[1]][i]  || ok[p[1]][p[2]][j] || ok[p[0]][p[2]][i+j]);
				else{
					int v = 0;
					if(v < a[p[0]].size()) v = a[p[0]].size();
					if(v < a[p[1]].size()+i) v = a[p[1]].size()+i;
					if(v < a[p[2]].size()+i+j) v = a[p[2]].size()+i+j;
					chmin(ans, v);
				}
			}
		}
	}while(next_permutation(p,p+3));
	cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define IOS                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
typedef long long ll;
using namespace std;
int main()
{

    int n, k;
    cin >> n >> k;
    int arr[n];
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    vector<ll> dp(n, INT_MAX);
    dp[0] = 0;
    //dp[1] = abs(arr[1] - arr[0]);
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j <= i + k; j++)
        {
            if (j < n)
                dp[j] = min((dp[i] + abs(arr[j] - arr[i])), dp[j]);
        }
    }
    cout << dp[n - 1];
}

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

static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int M[N][N] = {0}, color[N] = {0}, d[N], f[N], tt = 0, n;

void dfs_visit(int u) {
  int v;
  color[u] = GRAY;
  d[u] = ++tt;
  for (v = 0; v < n; v++) {
    if (M[u][v] == 0) continue;
    if (color[v] == WHITE) {
      dfs_visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs() {
  int u;
  for (u = 0; u < n; u++) {
    if (color[u] == WHITE) {
      dfs_visit(u);
    }
  }

  for (u = 0; u < n; u++) {
    cout << u + 1 << " " << d[u] << " " << f[u] << endl;
  }
}

int main(void) {
  int u, v, k, i, j;

  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> u >> k;
    u--;
    for (j = 0; j < k; j++) {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }
  dfs();

  return 0;
}

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

const int MAX = 1e5 + 5;

#define dbg(a) cout << "-> " << __LINE__ << ": " << #a << " = " << a << endl

int main() {
	long long a, x, y;
	scanf("%lld %lld.%lld", &a, &x, &y);
	x = x * 100 + y;
	printf("%lld\n", (x * a) / 100);
	return 0;
}


Measured memory_bytes: 3868
#include<stdio.h>
#include<limits.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

int main(){
  int i, j, n, e;
  int d[MAX], M[MAX][MAX], ans=0, v, p[MAX];

  scanf("%d", &n);

  for ( i = 1; i<= n; i++ ){
    for ( j = 1; j <= n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }
  
  for(i=1; i<=n; i++){
    d[i] = INT_MAX;
    p[i] = 0;
    d[i] = M[1][i];
  }
  p[1] = 1;
  d[0] = 0;

  while(1){
    v = 0;
    for(i=1; i<=n; i++){
      if(!p[i] && (v == 0 || d[i] < d[v]))
	v = i;
    }
    if(v == 0) break;
    p[v] = 1;
    ans += d[v];
    for(i=1; i<=n; i++){
      if(d[i] > M[v][i]){
	d[i] = M[v][i]; 
      }
    }
  }

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

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

int main(){
  string s;
  cin>>s;
  string keyenece="keyence";
  if(s==keyenece){
    cout<<"YES"<<endl;
    return 0;
  }
  for(int i=0;i<s.size();i++){
    for(int j=i;j<s.size();j++){
      string S="";
      for(int k=0;k<s.size();++k){
        if(i<=k && k<=j) continue;
        else S.push_back(s[k]);
      }
      if(S==keyenece){
        cout<<"YES"<<endl;
        return 0;
      }
    }
  }
  cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 3632
x, y = map(int, raw_input().split())

def f(a):
    if a in [1,3,5,7,8,10,12]:
        return 1
    if a in [4,6,9,11]:
        return 2
    if a == 2:
        return 3
    return None

if f(x) == f(y):
    print "Yes"
else:
    print "No"


Measured memory_bytes: 2568
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var x = o.a();
  var a = o.a();
  return x<a?0:10;
}

Measured memory_bytes: 21956
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LI long int
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
    int n,a; cin>>n;
    int sum=0;
    bitset<4000000> b;
    b[0]=1;
    FOR(i,0,n){
        cin>>a;
        sum+=a;
        b|=(b<<a);
    }
    int ans;
    FOR(i,(sum+1)/2,sum+1){
        if(b[i]==1){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1664
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MAX = int(1e+6) + 1
const MOD = int(1e+9) + 7

var fac [MAX]int
var finv [MAX]int
var inv [MAX]int

func COMinit() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for i := 2; i < MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = modInv(i, MOD)
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

func modInv(a, mod int) int {
	b := mod
	u := 1
	v := 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= mod
	if u < 0 {
		u += mod
	}
	return u
}

func COM(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, K := sc.nextInt(), sc.nextInt()
	A := sc.nextIntSlice(N)
	sort.Ints(A)
	COMinit()
	mx, mn := 0, 0
	for i := 0; i <= N-K; i++ {
		mn += A[i] * COM(N-1-i, K-1)
		mn %= MOD
	}
	for i := K - 1; i < N; i++ {
		mx += A[i] * COM(i, K-1)
		mx %= MOD
	}
	ans := mx - mn
	ans %= MOD
	if ans < 0 {
		ans += MOD
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 26496
n,k=gets.split.map(&:to_i)
h=gets.split.map(&:to_i)
ll=h.length

sum=0
h=h.sort.reverse

if k>=ll
    puts 0
    exit
end

h=h[k..-1]

i=0
h.length.times {
    sum+=h[i]
    i+=1
}

puts sum

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

int main() {
  string S;
  int K;
  cin >> S >> K;
  for(int i = 0; i < int(S.length()); i++) {
    if(S[i] != '1') {
      cout << S[i]; break;
    }
    else if(K == i + 1){
      cout << 1; break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#include <numeric>
#include <stdio.h>
#include <map>
#include <iomanip>
#include <sstream>
//#include <boost/math/common_factor_rt.hpp>
#include<fstream>
#define EPS (1e-7)
using namespace std;
#define ll long long

class Node
{
public:
	int number;
	vector<int> children;
	int counter;
	Node(int n) {
		number = n;
		counter = 0;
	}

	void addchild(int n) {
		children.push_back(n);
	}
	void addcount(int n) {
		counter += n;
	}

};

class City {
public:
	int number;
	int parent;
	int year;
	string id;

	City() {
		number = 0;
		parent = 0;
		year = 0;
		id = "";
	}

	City(int city_num,int parentn, int yearn) {
		number = city_num;
		parent = parentn;
		year = yearn;
		id = "";
	}

};



int main() {

	int N, M;
	cin >> N >> M;
	vector<City> cities(M);
	int temp1, temp2;
	for (int i = 0; i < M; i++)
	{
		cin >> temp1 >> temp2;
		City tcity(i, temp1, temp2);
		cities[i] = tcity;
	}

	sort(cities.begin(), cities.end(), [](const City& a, const City& b) { return a.year < b.year; });
	stable_sort(cities.begin(), cities.end(), [](const City& a, const City& b) { return a.parent < b.parent; });

	int prepre = -1;
	int under = 1;

	for (auto i = 0; i < M; i++)
	{
		std::ostringstream ss;
		if (prepre != cities[i].parent) {
			 under = 1;
			 ss << std::setfill('0') << std::right << std::setw(6) << cities[i].parent << std::setfill('0') << std::right << std::setw(6) << under;
			 cities[i].id = ss.str();
		}
		else {
			under += 1;
			ss << std::setfill('0') << std::right << std::setw(6) << cities[i].parent << std::setfill('0') << std::right << std::setw(6) << under;
			cities[i].id = ss.str();

		}
		prepre = cities[i].parent;
		
	}
	sort(cities.begin(), cities.end(), [](const City& a, const City& b) { return a.number < b.number; });

	for (const auto& city : cities) {
		cout << city.id << endl;
	}

	return 0;
}

Measured memory_bytes: 8544
#include<iostream>
#define MAX_N 1000000
using namespace std;

static bool prime[MAX_N];
 static int num[MAX_N] = { 0 };

void ini()
{
	for (int i = 2; i < MAX_N; i++)
		prime[i] = true;
	for (int i = 2; i < MAX_N; i++)
	{
		if (!prime[i])
		{
			num[i] = num[i - 1] + prime[i];
			continue;
		}
		else
		{
			for (int j = i * 2; j < MAX_N; j += i)
			{
				if (prime[j] && j%i == 0)
					prime[j] = false;
			}
		}
		num[i] = num[i - 1] + prime[i];
	}
}

void solve()
{
	int n;
	while (cin >> n)
		cout << num[n] << endl;
}

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

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

int main() {
  int d, n;
  cin >> d >> n;
  if(!d)
    cout << (n == 100 ? 101 : n) << endl;
  else if(d == 1)
    cout << (n == 100 ? 101 : n) * 100 << endl;
  else
    cout << (n == 100 ? 101 : n) * 10000 << endl;
}

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

int main(){
    vector<int> d(5);
    for(int i=0; i<5; i++){
        cin >> d[i];
    }
    int k;
    cin >> k;

    if(d[4]-d[0] > k){
        cout << ":(" << endl;
    }else{
        cout <<  "Yay!" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}



int main()
{
  int N,M;
  cin>>N;
  REP(i,50000)
  {
    M=1.08*i;
    if(M==N)
    {
      cout<<i<<endl;
      return 0;
    }

  }
  cout<<":("<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        String[] in = str.split(" ",0);
        int a = Integer.valueOf(in[0]);
        int b = Integer.valueOf(in[1]);
        int c = Integer.valueOf(in[2]);
        int k = Integer.valueOf(in[3]);
        int out;
        if(k <= (a + b + c) && (a + b + c) <= 2*Math.pow(10 , 9)){
            if(k - a >= 0){
                out = a;
                k = k - a;
                if(k - b >= 0){
                    out = out - (k-b);
                }
            }else {
                out = k;
            }
            System.out.println(out);
        }
    }
}


Measured memory_bytes: 35800
/*
 * atcoder/abc167/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX = 12;
const ll INF = 100000000000000000;
ll N, M, X;
vector<ll> C, A[MAX];

int nth(ll s, int d) {
  return (s>>d)&1;
}

void solve() {
  cin >> N >> M >> X;
  C.resize(N);
  ll a;
  loop(n,0,N) {
    cin >> C[n];
    loop(m,0,M) {
      cin >> a;
      A[n].push_back(a);
    }
  }

  ll min_c = INF;
  for (ll S=1; S<(1<<N); S++) {
    ll cost = 0;
    vector<ll> Y(M, 0);
    for (int d=0; d<N; d++) {
      if (nth(S, d)) {
        cost += C[d];
        for (int i=0; i<M; i++) Y[i] += A[d][i];
      }
    }
    bool all = true;
    for (auto&&y: Y) all &= y >= X;
    if (all) chmin(min_c, cost);
  }

  if (min_c == INF) cout << -1 << endl;
  else cout << min_c << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(void){
ios_base::sync_with_stdio(false);
cin.tie(NULL);

int n,k,c=0;       cin>>n>>k;
int x[n];
for(int i=0;i<n;i++)
{
    cin>>x[i];
}
sort(x,x+n);
for(int i=0;i<k;i++)
{
  c+=x[i];
}

cout<<c<<endl;






return 0;}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long N,L,T; cin >> N >> L >> T;
    vector<pair<long long,int>> X(N);
    vector<long long> ans(N),ans1(N);
    long long x,w,z;
    pair<long long,int> ant;
    for (int i=0;i<N;i++)
    {
        cin >> x >> w;
        ant=make_pair(x,w);
        X[i]=ant;
        if (w==1)
        {
            ans[i]=(x+T)%L;
            ans1[i]=(x+T)%L;
        }
        else
        {
            ans[i]=((x-T)%L>=0?(x-T)%L:L+(x-T)%L);
            ans1[i]=((x-T)%L>=0?(x-T)%L:L+(x-T)%L);
        }
    }
    long long time=0;
    int index=0,index2;
    if (X[0].second==1)
    {
        for (int i=0;i<N;i++)
        {
            if (X[i].second==2)
            {
                time+=T/L*2;
                if (T%L>=(X[i].first-X[index].first)/2+(X[i].first-X[index].first)%2) time++;
                if (T%L>=(L+X[i].first-X[index].first)/2+(L+X[i].first-X[index].first)%2) time++;
            }
        }
        z=ans[0];
        sort(ans1.begin(),ans1.end());
        for (int i=0;i<N;i++)
        {
            if (ans1[i]==z)
            {
                if ((ans1[(i+1)%N]!=z) & (ans1[i-1>=0?i-1:N-1]!=z)) index=i;
                else
                {
                    if (ans1[i-1>=0?i-1:N-1]==z) index=i;
                }
            }
        }
        index2=(index-time%N>=0?index-time%N:N+index-time%N);
        for (int i=0;i<N;i++) cout << ans1[(index2+i)%N] << endl;
    }
    else
    {
        for (int i=0;i<N;i++)
        {
            if (X[i].second==1)
            {
                   time+=T/L*2;
                if (T%L>=(L-X[i].first+X[0].first)/2+(L-X[i].first+X[0].first)%2) time++;
                if (T%L>=(2*L-X[i].first+X[0].first)/2+(2*L-X[i].first+X[0].first)%2) time++;
            }
        }
        z=ans[0];
        sort(ans1.begin(),ans1.end());
        for (int i=0;i<N;i++)
        {
            if (ans1[i]==z)
            {
                if ((ans1[(i+1)%N]!=z) & (ans1[i-1>=0?i-1:N-1]!=z)) index=i;
                else
                {
                    if (ans1[(i+1)%N]==z) index=i;
                }
            }
        }
        index2=((index-N+time%N)%N>=0?(index-N+time%N)%N:(N+index-N+time%N)%N);
        for (int i=0;i<N;i++) cout << ans1[(index2+i)%N] << endl;
        
    }
   return 0; 
}


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

#define INF INT_MAX/2
#define MOD 1000000007

using namespace std;

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

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

   int A,B;
   cin>>A>>B;
   if(A<=8&&B<=8)cout<<"Yay!"<<endl;
   else cout<<":("<<endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
using ll=long long;
int main(){

  ll N;
  cin>>N;
  ll x=0;
  ll y=0;
  ll ans=-1;
  for(ll i=1;i<=(ll)sqrt(N);i++){
  
    if(N%i==0){
    
      x=i;
      y=N/i;
      if(ans==-1||ans>x-1+y-1){
      
        ans=x-1+y-1;
      }
    }
  }
  cout<<ans;
}

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

using namespace std;

typedef pair<int, int> pii;

vector<int> b;
vector<int> ans;
vector<bool> used;

int N;

int main() {
    cin >> N;
    b.resize(N);
    used.resize(N);
    ans.reserve(N);
    for (int i = 0; i < N; i++) {
        cin >> b[i];
    }
    for(int run = true; run;) {
        run = false;
        for (int i = N - 1; i >= 0; --i) {
            int k = 0; 
            for (int j = 0; j < i; j++) {
                if (used[j]) {
                    k += 1;
                }
            }
            if (k + 1 == b[i] && !used[i]) {
                ans.push_back(b[i]);
                used[i] = true;
                run = true;
                break;
            }
        }
    }
    if (ans.size() < N) {
        cout << -1 << endl;
    }
    else {
        for (int i : ans) {
            cout << i << endl;
        }
    }
}

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

def resolve():
    def main():
        n=int(input())
        l=list(map(int,input().split()))
        prev=0
        for i in range(n):
            if l[i]>prev:
                l[i]-=1
                prev=l[i]
            elif l[i]<prev:
                return 'No'
        return 'Yes'
    print(main())
resolve()

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

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

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

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

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

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    int n; scanf("%d", &n);
    vi a(n),b(n);
    rep(i,n) scanf("%d", &a[i]);
    rep(i,n) scanf("%d", &b[i]);
    int ans=0;
    rep(i,29){
        vi A(n), B(n);
        ll T = 1<<i;
        rep(j,n) A[j]=a[j]%(2*T);
        rep(j,n) B[j]=b[j]%(2*T);
        sort(all(A));
        sort(all(B));
        int cnt=0, s=n-1,t=n-1,u=n-1;
        rep(j,n){
            while(s>=0 && B[s]>=T-A[j]) s--;
            while(t>=0 && B[t]>=2*T-A[j]) t--;
            while(u>=0 && B[u]>=3*T-A[j]) u--;
            cnt+=n; cnt+=t+1;
            cnt-=s+1; cnt-=u+1;
        }
        if (cnt&1) ans|=T;
    }
    printf("%d\n", ans);
    return 0;
}


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

void solve(long long X, long long N, std::vector<long long> p)
{
    int f[(X + 1) * 2] = {};
    for (auto &&i : p)
        if (i < (X+1)*2)
            ++f[i];

    for (int i = 0; i <= X + 1; i++)
    {
        if (X - i == -1)
        {
            cout << -1 << endl;
            return;
        }
        else if (f[X - i] == 0)
        {
            cout << X - i << endl;
            return;
        }
        else if (f[X + i] == 0)
        {
            cout << X + i << endl;
            return;
        }
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long X;
    scanf("%lld", &X);
    long long N;
    scanf("%lld", &N);
    std::vector<long long> p(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &p[i]);
    }
    solve(X, N, std::move(p));
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  int n = (int)s.size();

  int ans=0,cnt=0;
  for (int i = 0; i < n; i++)
  {
    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T') cnt++;
    else cnt=0;
    ans = max(ans,cnt);
  }
  cout << ans << endl;
}

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

#define int long long

//signed main(signed argc, char* argv[])
signed main()
{
    // N,M
    int N, M;
    cin >> N >> M;
    // k,s
    int k[M];
    int s[M];
    for (int i = 0; i < M; i++) {
        cin >> k[i];
        s[i] = 0;
        for (int j = 0; j < k[i]; j++) {
            int sij;
            cin >> sij;
            s[i] |= (1 << (sij - 1));
        }
    }
    // p
    int p[M];
    for (int i = 0; i < M; i++) {
        cin >> p[i];
    }

    int ans = 0;
    for (int bits = 0; bits < (1 << N); bits++) {
        bool ok = true;
        for (int i = 0; i < M; i++) {
            ok &= (__builtin_popcount(bits & s[i]) % 2 == p[i]);
        }
        if (ok) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for(int i = 0;i < n;i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		sc.close();

		long sum = 0;
		long cnt1 = 0;
		long cnt2 = 0;
		long flg = 1;
		for(int i = 0;i < n;i++) {
			sum += a[i];
			if(sum * flg <= 0) {
				cnt1 += Math.abs(sum) + 1;
				sum = flg;
			}
			flg *= -1;
		}
		flg = -1;
		sum = 0;
		for(int i = 0;i < n;i++) {
			sum += a[i];
			if(sum * flg <= 0) {
				cnt2 += Math.abs(sum) + 1;
				sum = flg;
			}
			flg *= -1;
		}
		System.out.println(Math.min(cnt1,cnt2));
	}
}

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

int n;
int t[100001], x[100001], y[100001];

int main() {
	int i;
	
	cin >> n;
	for (i = 1; i <= n; i++) { cin >> t[i] >> x[i] >> y[i]; }
	n++;
	
	for (i = 0; i < n - 1; i++) {
		int ts = t[i + 1] - t[i];
		int ds = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
		if (ds > ts || ds % 2 != ts % 2) { cout << "No" << endl; return 0; }
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
//#pragma GCC optimize(3)
//sort(st.begin(),st.end());
using namespace std;
int n,m;
char ch[60][60];
int dx[10]={0,-1,-1,-1,0,1,1,1};
int dy[10]={-1,-1,0,1,1,1,0,-1};
int main()
{
	cin>>n>>m;
	for(int i=1; i<=n; i++)
	for(int j=1; j<=m; j++)
	    cin>>ch[i][j];
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=m; j++)
		{
			if(ch[i][j]=='.')
			{
				for(int k=0; k<8; k++)
				{
					if(ch[i+dx[k]][j+dy[k]]=='#')
					{
						if(ch[i][j]=='.')ch[i][j]='1';
						else ch[i][j]++;
					}
				}
				if(ch[i][j]=='.')ch[i][j]='0';
			}
		}
	}
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=m; j++)
		    cout<<ch[i][j];
		cout<<endl;
	}
    return 0;
}




Measured memory_bytes: 256
def light(l,i):
    k=1<<(i-1)
    if l&k:
        return 1
    else:
        return 0

N, M = map(int,input().split())
s=list()
for j in range(0,M):
    s.append(0)
for j in range(0,M):
    s[j]=list(map(int,input().split()))
p=list(map(int,input().split()))

a=0
for l in range(0,1<<N):
    b=0
    for j in range(0,M):
        c=0
        for i in range(1,s[j][0]+1):
            c+=light(l,s[j][i])
        if c%2==p[j]:
            b+=1
    if b==M:
        a+=1
print(a)

Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double h_kakudo=h*60.0;
    double m_kakudo=m;
    double kakudo=((h_kakudo+m_kakudo)*5.5);
    kakudo=fmod(kakudo,360);
    if(kakudo==180.0){
        cout << a+b;
        return 0;
    }
    double pi     = 2.0 * asin(1.0);            /* πの値 */
	double unit   = pi / 180.0;
    double deg =kakudo*unit;
    double c_2jou=pow(a,2)+pow(b,2)-2*a*b*cos(deg);
    cout << fixed << setprecision(15) << pow(c_2jou,0.5);
}

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

vector<int> string_to_int(string s)
{
  vector<int> v;
  int k = (int)s.size();
  for (int i = 0; i < k; i++)
  {
    char tmp = (char)s[i];
    int x = tmp - '0';
    v.push_back(x);
  }
  return v;
}

string int_to_string(vector<int> v)
{
  int k = (int)v.size();
  string s;
  for (int i = 0; i < k; i++)
  {
    char tmp = '0' + v[i];
    s+=tmp;
  }
  return s;
}

string string_sort(string s)
{
  vector<int> v;
  v = string_to_int(s);
  sort(v.begin(),v.end());
  string t = int_to_string(v);
  return t;
}

int main()
{
  ll n;
  cin >> n;
  vector<string> s(n);
  rep(n)
  {
    string tmp;
    cin >> tmp;
    s[i] = string_sort(tmp);
  }
  sort(s.begin(),s.end());

  ll left = 0;
  ll right = 0;
  ll tmp = 0;
  while(right < n)
  {
    while(s[right]==s[left]){
      right++;
      if(right==n) break;
    }
    ll k = right - left;
    tmp += k*(k-1)/2;
    left = right;
  }
  cout << tmp << endl;
  return 0;
}

Measured memory_bytes: 7296
//10
#include<iostream>
#include<vector>
#include<utility>
#include<cmath>
#include<algorithm>

using namespace std;

long double fact(int x){
  long double r=1;
  while(x){
    r*=x--;
  }
  return r;
}

int main(){
  int n,m,l;
  cin>>n>>m>>l;
  double ap[100][51],acp[100][52]={{}};
  double at[100][51];
  for(int i=0;i<n;i++){
    double p,t,v;
    cin>>p>>t>>v;
    for(int j=0;j<=m;j++){
      at[i][j]=l/v+t*j;
      ap[i][j]=pow(p/100,j)*pow(1-p/100,m-j)*fact(m)/fact(j)/fact(m-j);
      acp[i][j+1]=acp[i][j]+ap[i][j];
    }
  }
  for(int i=0;i<n;i++){
    double a=0;
    for(int j=0;j<=m;j++){
      double c=ap[i][j];
      for(int k=0;k<n;k++){
	if(i!=k){
	  int x=upper_bound(at[k],at[k]+m+1,at[i][j]+1e-9)-at[k];
	  c*=1-acp[k][x];
	}
      }
      a+=c;
    }
    cout<<fixed<<a<<endl;	  
  }
  return 0;
}

Measured memory_bytes: 1420
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(){
    int n;
    cin >> n;
    int a[n],b[n],c[n-1];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        cin >> b[i];
    }
    for(int i=0; i<n-1; i++){
        cin >> c[i];
    }
    int sum=0;
    for(int i=0; i<n; i++){
        sum+=b[a[i]-1];
        //cout << sum << endl;
    }
    for(int i=0; i<n-1; i++){
        if(a[i+1]-a[i]==1)sum+=c[a[i]-1];
        //cout << sum << endl;
    }
    cout << sum << endl;
}

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

using namespace std;

typedef long long ll;

int main(){
  int n; cin >> n;
  int a[n], b[n], c[n];
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n;i++) cin >> b[i];
  for(int i=0;i<n;i++) cin >> c[i];
  sort(a, a+n);
  sort(b, b+n);
  sort(c, c+n);
  ll ans=0;
  for(int i=0;i<n;i++){
    auto it_a = lower_bound(a, a+n, b[i]);
    ll cnt_a = it_a - a;
    auto it_c = upper_bound(c, c+n, b[i]);
    ll cnt_c = (c+n) - it_c;
    ans = ans + cnt_a*cnt_c;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
from itertools import accumulate
N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse = True)

B = list(accumulate(A))

def pnum(X,N,A,B):
    l = 0
    r = N-1
    num = 0
    s = 0
    while l != N and r != -1:
        if A[l] + A[r] >= X:
            num += r+1
            s += (A[l] * (r+1)) + B[r] 
            l += 1
        else:
            r -= 1
    return num, s


l = 0
r = A[0] * 2 + 1

while r-l > 1:
    m = (r + l) // 2
    a, b = pnum(m, N, A, B)
    if a < M:
        r = m
    else:
        l = m
        num = a
        ans = b

if num > M:
    ans -= l * (num - M)
print(ans)

Measured memory_bytes: 14260
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long N = scanner.nextLong(); scanner.nextLine();
        String S = scanner.nextLine();

        long ans = 0;
        char prev = ',';
        for(int i = 0; i < S.length(); i++) {
            char cur = S.charAt(i);
            if(prev != cur) ans++;
            prev = cur;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 28228
N = int(input())
P = [int(input()) for _ in range(N)]
hist = [0 for _ in range(N+1)]
A = {i:0 for i in range(1,N+1)}
for i in range(N):
    a = P[i]
    if hist[a-1]==0:
        A[a] = a
    else:
        A[a] = A[a-1]
    hist[a] = 1
cmax = 0
for i in range(1,N+1):
    cmax = max(cmax,i-A[i]+1)
print(N-cmax)

Measured memory_bytes: 85412
#include<iostream>
using namespace std;
int main()
{
          double a,b,c,d;
          while(cin>>a)
          {
                    b=a/9.8;
                    c=b*b*4.9;
                    int d=(c+5)/5;
                    cout<<d+1<<endl;
          }
return 0;
}



Measured memory_bytes: 3172
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> A;
    rep(i, m) {
        int a, b; cin >> a >> b;
        A.push_back({b, a});
    }
    sort(A.begin(), A.end());
    int ans = 0;
    rep(i, m) {
        int j = i;
        while(j + 1 < m && A[j + 1].second < A[i].first) j++;
        ans++;
        //cout << j << " " << i << endl;
        i = j;
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  int n,m; ll k;
  cin >> n >> m >> k;
  vector<ll> a(n);
  vector<ll> b(m);
  rep(i,0,n) cin >> a[i];
  rep(i,0,m) cin >> b[i];
  vector<ll> aa(n + 1, 0);
  vector<ll> bb(m + 1, 0);
  rep(i,1,n + 1) aa[i] = aa[i-1] + a[i-1];
  rep(i,1,m + 1) bb[i] = bb[i-1] + b[i-1];
  int j = m;
  int ans = 0;
  rep(i,0,n + 1) {
    if (aa[i] > k) break;
    while (bb[j] > k - aa[i]) {
      j--;
    }
    ans = max(ans, i + j);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9572
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 400020
const int mod=1e9+7;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,p[N],a[N],cnt[N],ans;
void dfs(int u,int l,int r){
	if(l==r)return;
	int mid=(l+r)>>1;
	dfs(u<<1,l,mid),dfs(u<<1|1,mid+1,r);
	for(int i=l;i<=mid;++i){
		a[i]=1LL*a[i]*u%mod;
	}
	for(int i=l;i<=mid;++i){
		int v=(1<<n-1)+p[i]-1;
		int num=a[i];
		do{
			num=1LL*num*v%mod;
			cnt[v]=(cnt[v]+num)%mod;
			v>>=1;
		}while(v);
	} 
	int las=ans;
	for(int i=mid+1;i<=r;++i){
		int v=(1<<n-1)+p[i]-1;
		int num=a[i];
		int las=0;
		do{
			las=1LL*las*v%mod;
			ans=(ans+1LL*num*(cnt[v]-las))%mod;
			las=cnt[v];
			num=1LL*num*v%mod;
			v>>=1;
		}while(v);
	}
	for(int i=l;i<=mid;++i){
		int v=(1<<n-1)+p[i]-1;
		do{
			cnt[v]=0;
			v>>=1;
		}while(v);
	} 
	for(int i=mid+1;i<=r;++i){
		a[i]=1LL*a[i]*u%mod;
	}
}
int main(){
	n=read();
	for(int i=1;i<=(1<<n-1);++i){
		p[i]=read();
		a[i]=(1<<n-1)+i-1;
	}
	dfs(1,1,1<<n-1);
	printf("%d\n",(ans+mod)%mod);
	return 0;
}



Measured memory_bytes: 5820
#include <stdio.h>
#include <string.h>
typedef struct {
  char mark;
  int value;
  int prev;
}Card;
   
void swap(Card *in,Card *out)
{
  Card temp;
  int i,j;
  temp.mark = out->mark;
  temp.value = out->value;
  temp.prev = out->prev;
  out->mark = in->mark;
  out->value = in->value;
  out->prev = in->prev;
  in->mark = temp.mark;
  in->value = temp.value;
  in->prev = temp.prev;
}
   
void Print(Card *in,int num)
{
  int i;
  for(i=0;i<num;i++)
    {
      printf("%c%d",in[i].mark,in[i].value);
      //     printf("%d",in[i].prev);
      if (i<num-1) printf(" ");
    }
  printf("\n");
}
int hantei(Card *kai,int num) 
{
  int i;
  for (i=0;i<num;i++)
    {
      if(kai[i].value == kai[i+1].value)
        {
	  if (kai[i].prev < kai[i+1].prev) continue;
	  else return 1;
	}
    }
  return 0;
}
  
int main()
{
  int i,j;
  int num,mini;
  int stable=0;
  Card A[36],B[36],C[36];
   
  scanf("%d",&num);
  for (i=0;i<num;i++)
    {
      scanf(" %c%d",&A[i].mark,&A[i].value);
      B[i].mark = A[i].mark;
      B[i].value = A[i].value;
      C[i].mark = A[i].mark;
      C[i].value = A[i].value;
      A[i].prev = i;
      B[i].prev = i;
      C[i].prev = i;
    }

  /*bubble sort*/
  for (i=0;i<num;i++)
    {
      for (j=num-1;j>i;j--)
	{
	  if ( A[j].value < A[j-1].value) swap(&A[j],&A[j-1]);
	}
    }
  Print(A,num);
  stable=hantei(A,num);
  if(stable == 1) printf("Not stable\n");
  else printf("Stable\n");
   
  /*select sort*/
  for(i=0;i<num;i++)
    {
      mini=i;
      for(j=i;j<num;j++)
	{
	  if (B[j].value < B[mini].value ) mini=j;
	}
      swap(&B[i],&B[mini]);
    }
  Print(B,num);
  stable = hantei(B,num);
  if(stable == 1) printf("Not stable\n");
  else printf("Stable\n");
  return 0;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

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

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	map<ll,bool> mp;
	FOR(i,0,n){
		ll a;
		cin >> a;
		auto itr = mp.find(a);
		if(itr != mp.end()){
			mp.erase(itr);
		}else{
			mp[a] = true;
		}
	}
	ANS(mp.size());
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl; 
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a,LL b){LL s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
int dr[2][4] = {1,-1,0,0,0,0,-1,1};
typedef pair<int,int> P;
const int maxn = 1e5+10;
int main(void)
{
    int n;cin>>n;
    double ans = 0;
    for(int i = 0;i < n; ++i){
        double a;
        cin>>a;
        ans += 1/a;
    }    
    cout<<1.0/ans<<endl;

   return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.*;
 
class Main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] dx = {-1, 0, 1, 0, -1, 1, 1, -1, 0};
    public static int[] dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
    public static int INF = 0x3f3f3f3f;
    public static int MOD = 1000000007;
    public static long LINF = 0x3f3f3f3f3f3f3f3fL;

    public static long[][] memo;
    public static int L;
    public static int[] A;

    public static long solve(int index, int stage) {
        if (index == L){
            return 0;
        }
        if (memo[index][stage] != -1) {
            return memo[index][stage];
        }

        long ans = LINF;
        for (int i = stage; i < 5; i++) {
            long cost = 0;
            if (i == 0 || i == 4) {
                cost = A[index];
            } else if (i == 1 || i == 3) {
                if (A[index] == 0) {
                    cost = 2;
                } else {
                    cost = A[index] % 2;
                }
            } else {
                cost = (A[index] + 1) % 2;
            }
            ans = Math.min(ans, cost + solve(index+1, i));
        }

        return memo[index][stage] = ans;
    }

    public static void main(String[] args) throws Exception {
        L = Integer.parseInt(br.readLine());
        A = new int[L];
        for (int i = 0; i < L; i++) {
            A[i] = Integer.parseInt(br.readLine());
        }

        memo = new long[L][5];
        for (int i = 0; i < L; i++) {
            Arrays.fill(memo[i], -1);
        }

        pw.println(solve(0, 0));

        pw.close(); 
        br.close();
    }
}

class Pair implements Comparable<Pair>{
    public long x;
    public int y;
 
    Pair(long _x, int _y){
        x = _x;
        y = _y;
    }
 
    public String toString(){
        return x + " " + y;
    }

    public int compareTo(Pair p){
        if (x != p.x) return x < p.x ? -1 : 1;
        if (y != p.y) return y < p.y ? -1 : 1;
        return 0;
    }
} 

Measured memory_bytes: 68676
#include <iostream>
#include <fstream>
#include <cstring>
#include <queue>
//#define cin fin
#define MAXN 200
using namespace std;

queue <int> q[20];
int a[MAXN][MAXN];
long long cost;
int m,c,n,len;

int check(int begin, int end)
{
    int i;
    for (i=begin;i<=end;i++)
        if (q[i].size()<c) return i;

    return m+1;
}
int find( int num, int begin ,int end )
{
    int i;
    for (i=begin;i<=end;i++)
    {
        q[0] = q[i];
        while (!q[0].empty())
        {
            if (q[0].front()==num) return i;
            q[0].pop();
        }
    }
    return m+1;
}
void erase( int num, int k)
{
    while (!q[0].empty()) q[0].pop();
    int i,j,x;
    while (!q[k].empty())
    {
        x = q[k].front();
        if (x!=num)
        {
            q[0].push(x);
        }
        q[k].pop();
    }
    q[k] = q[0];
}
int main()
{
    ifstream fin("B.in");
    int i,j,k,kk,num;
    cin >> m >> c >> n;
    while ( !( m==0 && c==0 && n==0 ))
    {
        len = 0;
        memset(a,0,sizeof(a));
        cost = 0;
        for (i=1;i<=m;i++)
            while (!q[i].empty()) q[i].pop();


        for (i=1;i<=n;i++)
        {
            cin >> a[i][0];
            if (a[i][0]>len) len = a[i][0];
            for (j=1;j<=a[i][0];j++)
                cin >> a[i][j];
        }


        for (j=1;j<=len;j++)
            for (i=1;i<=n;i++)
                if (a[i][j]!=0)
                {
                    k = find(a[i][j],1,m);
                    if (k!=m+1)
                    {
                        erase(a[i][j],k);
                    }
                    cost += k;

                    //諡ソ荵ヲ螳梧ッ?
                    k = check(1,m);
                    q[k].push(a[i][j]);
                    cost += k;
                    //證よ慮蟄俶叛
                    if (k!=1)
                    {
                        num = q[1].front();
                        q[1].pop();
                        cost += 1;

                        kk=check(2,m);
                        if (kk!=m+1)
                        {
                            q[kk].push(num);
                        }
                        cost += kk;
                        //霓ャ遘サ螳梧ッ?
                        erase(a[i][j],k);
                        cost += k;

                        q[1].push(a[i][j]);
                        cost += 1;

                    }

                }

        cout << cost << endl;
        cin >> m >> c >> n;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
  ll N;
  cin >> N;
  ll a[60010]={};
  
    FOR(x,1,100){
      FOR(y,1,100){
        FOR(z,1,100){
          a[x*x+y*y+z*z+x*y+y*z+z*x]++;
        }
      }
    }
  
  FOR(i, 1, N+1){
    cout << a[i] << endl;
  }
  
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string S;
    cin >> S;
    ll ans = 0;
    ll cnt = 0;
    bool flag = true;
    REP(i, S.length()) {
        if(S[i] == 'B' and flag) {
            //はじめてBになる
            cnt = i;
            flag = false;
        }
        if(S[i] == 'W' and flag == false) {

            // BになったあとのW
            ans += i - cnt;
            cnt++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN           PIC X(13).
01 N            PIC 9(10).
01 K            PIC 9(2).
01 cnt          PIC 9(2).
01 ans          PIC Z9.

PROCEDURE DIVISION.
  ACCEPT LN.
  UNSTRING LN DELIMITED BY SPACE INTO N K.
  MOVE 1 TO cnt.
  PERFORM UNTIL N < K ** cnt
     ADD 1 TO cnt
  END-PERFORM.
  MOVE cnt TO ans.
  DISPLAY ans.
  STOP RUN.


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

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

  ll N; cin >> N;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];
  vector<ll> cnt(N + 5, 0);
  for (ll i = 0; i < N; i++) cnt[A[i]]++;

  ll sum = 0;
  for (ll i = 0; i < N + 5; i++) {
    ll x = cnt[i];
    sum += x * (x - 1) / 2;
  }

  for (ll i = 0; i < N; i++) {
    ll x = cnt[A[i]];
    ll ans = sum;
    if (x > 1) {
      ans -= x * (x - 1) / 2;
      ans += (x - 1) * (x - 2) / 2;
    }
    cout << ans << '\n';
  }
  return 0;
}

Measured memory_bytes: 5760