akhauriyash/Code-Regression huggingface dataset:
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m=sc.nextInt();
		String gomi = sc.nextLine();
		for(int i=0;i<m;++i){
			String data = sc.nextLine();
			int size = data.length();
			HashSet<String> set = new HashSet<String>();
			for(int j=0;j<size-1;++j){
				StringBuffer a = new StringBuffer(data.substring(0,j+1));
				StringBuffer b = new StringBuffer(data.substring(j+1,size));
				set.add(a.toString()+b.toString());
				set.add(a.toString()+b.reverse().toString());
				set.add(a.reverse().toString()+b.toString());
				set.add(a.toString()+b.reverse().toString());
				
				set.add(b.toString()+a.toString());
				set.add(b.toString()+a.reverse().toString());
				set.add(b.reverse().toString()+a.toString());
				set.add(b.toString()+a.reverse().toString());
			}
			System.out.println(set.size());
		}
	}
}



Measured memory_bytes: 61044
N = int(input())
S = list(input())
ans = 0
for i in range(1,N):
    if S[i] == 'E':
        ans += 1
tmp = ans
for i in range(1,N):
    if S[i-1] == 'W':
        tmp += 1
    if S[i] == 'E':
        tmp -= 1
    if tmp < ans:
        ans = tmp
    #print(tmp)
print(ans) 

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

int a[200000];
int main() {

    int n;
    cin >> n;
    rep(i, n)
        cin >> a[i];

    std::qsort(a, n, sizeof(int),
            [](const void* a, const void* b){
                int x = *(int*)a;
                int y = *(int*)b;

                if (x<y) return -1;
                if (y<x) return 1;
                return 0;
            }
            );

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

    }
    cout<< "YES";
    
    return 0;
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int  main(){
  int a;
  cin >> a;
  int count = 0;
  int b[a];
  int c[a];
  rep(i,a){
    cin >> b[i];
  }
  rep(i,a){
    c[i]=0;
  }
  rep(i,a){
     if(b[i]%2==0){
       c[i]=b[i];
     }
    }
  rep(i,a){
    if(c[i]%3!=0&&c[i]%5!=0){
      count ++;
      break;
    }
  }
  if(count){
    cout << "DENIED" << endl;
  }else{
    cout << "APPROVED" << endl;
  }
 return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
k_s = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))
ans=0
for i in range(2**N):
    for u in range(M):
        t=True
        num=0
        for y in range(1,len(k_s[u])):
            #print(bin(i),u,y-1,bin(i >> (y-1)))
            if ((i >> (k_s[u][y]-1)) & 1):
                num+=1
        if not num%2==p[u]:
            t=False
        if not t :
            break
    else:
        #print(bin(i))
        ans+=1
print(ans) 

Measured memory_bytes: 82960
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


void f(int n){
  string s[100];
  int a[7]={5,7,5,7,7};
  rep(i,n){
    cin>>s[i];
  }
  rep(i,n){
    int p=0;
    int m=0;
    FOR(j,i,n){
      m += (int)s[j].length();
      if(m==a[p]){
        m=0;
        p++;
      }
    }
    if(p==5){
      cout<<i+1<<endl;
      break;
    }
  }
}



int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0) break;
    f(n);
  }

  return 0;
}


Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class CLowElements {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vc<int> P(N);
        REP(i, N) in>>P[i];
        int mn = N + 1, ans = 0;
        for(auto& p : P){
            if(p<mn){
                ++ans;
                mn = p;
            }
        }
        out<<ans<<'\n';
    }
};


int main() {
	CLowElements solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3972
package main

import (
	"bufio"
	_ "container/heap"
	"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
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// 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 MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	x, y, z := sc.nextInt(), sc.nextInt(), sc.nextInt()

	fmt.Fprintln(wtr, z, x, y)
}


Measured memory_bytes: 640
import sys
import math
import bisect

def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = [0] * n
    for i in range(n):
        while A[i] % 2 == 0:
            A[i] //= 2
            B[i] += 1
    print(min(B))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
 
using namespace std;

int main()
{
    int a, b;
    string str, op;
    
    cin >> str;
    a = atoi(str.c_str());
    
    cin >> op;
    
    cin >> str;
    b = atoi(str.c_str());
    
    printf("%d\n", op == "+" ? a + b : a - b);
    
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int a,n,slen,tlen;
  string s,t;
  string *u;
  cin>>n;
  u=new string[n];
  for(i=0;i<n;i++){
    cin>>s>>t;
    slen=s.length();
    tlen=t.length();
    if(slen>80||tlen>80)
      u[i]="overflow";
    else{
      u[i]="00000000000000000000000000000000000000000000000000000000000000000000000000000000";
      a=0;
      for(j=0;j< (slen>tlen?slen:tlen) ;j++){
	if((j<slen?s[slen-j-1]:'0')+(j<tlen?t[tlen-j-1]:'0')+a-'0'-'0'>9){
	  u[i][79-j]=(j<slen?s[slen-j-1]:'0')+(j<tlen?t[tlen-j-1]:'0')+a-'0'-10;
	  a=1;
	}else{
	  u[i][79-j]=(j<slen?s[slen-j-1]:'0')+(j<tlen?t[tlen-j-1]:'0')+a-'0';
	  a=0;
	}  
      }
      if(j==80&&a)
	u[i]="overflow";
      else
	u[i][79-j]=a+'0';
    }
  }
  for(i=0;i<n;i++){
    if(u[i]=="overflow")
      cout<<u[i]<<endl;
    else{
      for(j=0;j<79&&u[i][j]=='0';j++);
      for(;j<80;j++)
	cout<<u[i][j];
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
x = int(input())
y = x
d = {}
d[x] = 0
while x > 0:
    x = x // 2
    d[x] = 0
d[1] = 1
for k in sorted(d.keys()):
    if k == 0:
        d[k] = 0
    else:
        d[k] = 1 + 2 * d[k // 2]
print(d[y])

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

int main() {
  int N, E, F, p=0;
  cin >> N;
  vector<int> D(N);
  
  for (int i=0; i<N; i++) {
    cin >> D.at(i);
  }
  
  while (p<N) {
    if (D.at(p)%2==0) {
      E=D.at(p)%3;
      F=D.at(p)%5;
      if (E!=0 && F!=0) {
        cout << "DENIED" << endl;
        p=N;
      }
    }
    p++;
  }
  if (p==N) {
    cout << "APPROVED" << endl;
  }
}

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

int main(){
	int n,b,f,r,v;
int daigaku[5][4][11]={};
	cin>>n;
	for(int q=0;q<n;q++){
		cin>>b>>f>>r>>v;
		daigaku[b-1][f-1][r-1]+=v;
	}
	
	for(int B=0;B<=3;B++){
		for(int F=0;F<=2;F++){
			for(int R=0;R<=9;R++){
				cout<<" "<<daigaku[B][F][R];
			}
			cout<<endl;
		}
		if(B!=3){
		cout<<"####################"<<endl;
		}
	}
					
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

long long int INF = (1e15), mod = 1e9 + 7;
#define int long long

struct Edge{
  int cost, from, to;
  Edge(int cost, int from, int to):
    cost(cost), from(from), to(to) {}
};

bool operator<(const Edge& a, const Edge& b){
  return a.cost != b.cost ? a.cost < b.cost : a.from != b.from ? a.from < b.from : a.to < b.to;
}

int solve(vector< vector< pair<int,int> > > &G, int s, int t){
  int n = G.size();
  vector<int> D(n,INF), C(n,0), D_rev(n,INF), C_rev(n,0);
  C[s] = 1;
  C_rev[t] = 1;
  priority_queue< Edge > wait;
  wait.emplace(0,s,s);
  while(!wait.empty()){
    int d = -wait.top().cost, v = wait.top().to, from = wait.top().from;
    wait.pop();
    if(d > D[v]) continue;
    if(d == D[v]){
      C[v] += C[from];
      C[v] %= mod;
      continue;
    }else{
      C[v] = C[from];
      D[v] = d;
    }
    for(int i = 0; i < G[v].size(); ++i){
      int d_ = G[v][i].first, v_ = G[v][i].second;
      if(d + d_ <= D[v_]) wait.emplace(-(d+d_),v,v_);
    }
  }
  wait.emplace(0,t,t);
  while(!wait.empty()){
    int d = -wait.top().cost, v = wait.top().to, from = wait.top().from;
    wait.pop();
    if(d > D_rev[v]) continue;
    if(d == D_rev[v]){
      C_rev[v] += C_rev[from];
      C_rev[v] %= mod;
      continue;
    }else{
      C_rev[v] = C_rev[from];
      D_rev[v] = d;
    }
    for(int i = 0; i < G[v].size(); ++i){
      int d_ = G[v][i].first, v_ = G[v][i].second;
      if(d + d_ <= D_rev[v_]) wait.emplace(-(d+d_),v,v_);
    }
  }
  /*
  for(int i = 0; i < n; ++i) cout << D[i] << " " ;
  cout << endl;
  for(int i = 0; i < n; ++i) cout << D_rev[i] << " " ;
  cout << endl;
  for(int i = 0; i < n; ++i) cout << C[i] << " " ;
  cout << endl;
  for(int i = 0; i < n; ++i) cout << C_rev[i] << " " ;
  cout << endl;
  */

  int ans = (C[t]*C[t])%mod;
  //cout << ans << endl;
  int min_time = D[t];
  for(int i = 0; i < n; ++i){
    if(2*D[i] == min_time && D[i] == D_rev[i]){
      ans -= (((C[i]*C_rev[i])%mod)*((C[i]*C_rev[i])%mod))%mod;
      ans += mod;
      ans %= mod;
    }
  }
  for(int i = 0; i < n; ++i){
    if(2*D[i] >= min_time) continue;
    for(int j = 0; j < G[i].size(); ++j){
      int v = G[i][j].second, d = G[i][j].first;
      if(D[i]+D_rev[v]+d == min_time &&
         2*D[i] < min_time && 2*D_rev[v] < min_time){
        ans -= (((C[i]*C_rev[v])%mod)*((C[i]*C_rev[v])%mod))%mod;
        //cout << i << " " << v << endl;
        ans += mod;
        ans %= mod;
      }
    }
  }
  return ans;
}

signed main(){
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  --s;--t;
  vector< vector< pair<int,int> > > G(n);
  int u, v, d;
  for(int i = 0; i < m; ++i){
    cin >> u >> v >> d;
    --u;--v;
    G[u].emplace_back(d,v);
    G[v].emplace_back(d,u);
  }
  cout << solve(G,s,t) << endl;
  return 0;
}


Measured memory_bytes: 20084
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

double dp[305][305][305];

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

    int N, a=0, b=0, c=0;;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int p;
        cin >> p;
        if (p == 1) a++;
        if (p == 2) b++;
        if (p == 3) c++;
    }

    for (int k = 0; k <= 300; k++) {
        for (int j = 0; j <= 300; j++) {
            for (int i = 0; i <= 300; i++) {
                if (i + j + k == 0) continue;
                dp[i][j][k] = N;
                if (i) dp[i][j][k] += dp[i-1][j][k] * (double)i;
                if (j) dp[i][j][k] += dp[i+1][j-1][k] * (double)j;
                if (k) dp[i][j][k] += dp[i][j+1][k-1] * (double)k;
                dp[i][j][k] /= (double)(i + j + k);
            }
        }
    }

    cout << fixed << setprecision(15) << dp[a][b][c] << "\n";
    return 0;
}

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

int main() {
  unsigned long N;
  std::cin >> N;

  std::vector<long> x(N), y(N);
  std::vector<long> h(N);
  for (unsigned long i = 0; i < N; i++) {
    std::cin >> x.at(i) >> y.at(i) >> h.at(i);
  }

  long H = 0;
  for (long cx = 0; cx <= 100; cx++) {
    for (long cy = 0; cy <= 100; cy++) {

      for (unsigned long i = 0; i < N; i++) {
        if (h.at(i) >= 1) {
          H = h.at(i) + std::abs(x.at(i) - cx) + std::abs(y.at(i) - cy);
          break;
        }
      }

      bool r = true;
      for (unsigned long i = 0; i < N; i++) {
        long h_ =
            std::max(0L, H - std::abs(x.at(i) - cx) - std::abs(y.at(i) - cy));
        if (h_ != h.at(i)) {
          r = false;
          break;
        }

        if (h.at(i) != 0) {
          long H_ = h.at(i) + std::abs(x.at(i) - cx) + std::abs(y.at(i) - cy);
          if (H_ != H) {
            r = false;
            break;
          }
        }
      }
      if (r) {
        std::cout << cx << ' ' << cy << ' ' << H << std::endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#define ll long long
#define ldd long double
#define mpp make_pair
#define pb push_back
#define ff first
#define ss second
#include<bits/stdc++.h>
using namespace std;
int main(){
    ll n,m,y,x,z,h,t,i,j,k;
    ll cnt=0,cnt1=0,sum=0,sum1=0,flag=0,flag1=0,maxi=LLONG_MIN,mini=LLONG_MAX,temp=0,ans=0;
    //freopen("input.txt","r", stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    map<ll,ll> mp;
    for(i=0;i<n-1;i++){
        cin>>temp;
        mp[temp]++;
    }
    for(i=1;i<n+1;i++){
        cout<<mp[i]<<endl;
    }
return 0;
}


Measured memory_bytes: 16164
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define INF 1000000000000000000LL
#define MOD 1000000007LL

using namespace std;
typedef long long int ll;

int main()
{
	int q;
	scanf("%d", &q);
	vector<ll> fib;
	fib.push_back(0);
	fib.push_back(1);
	while(fib.back()<=INF){
		int i=fib.size();
		fib.push_back(fib[i-1]+fib[i-2]);
	}
	int max=fib.size(); // max=89
	ll prod[100][100];
	for(int k=2; k<max; k++){
		for(int i=1; i<k; i++){
			prod[k][i]=fib[i]*fib[k-i];
		}
	}

	for(int i=0; i<q; i++){
		ll x, y;
		scanf("%lld %lld", &x, &y);
		if(x>y) swap(x, y);
		if(x==1){
			printf("%d %lld\n", 1, y%MOD);
			continue;
		}else if(x==2){
			if(y==2){
				printf("%d %d\n", 1, 4);
			}else{
				printf("%d %lld\n", 2, (y-1)/2%MOD);
			}
			continue;
		}
		int n1=upper_bound(fib.begin(), fib.end(), x)-fib.begin()-1;
		int n2=upper_bound(fib.begin(), fib.end(), y)-fib.begin()-1;
		int n=min(n1, n2-1);
		ll ans=0;
		ans+=((y-fib[n+1])/fib[n]+1);
		ans%=MOD;
		for(int i=1; i<n; i++){
			ll x1=fib[n]+prod[n][i], y1=fib[n+1]+prod[n+1][i+1];
			if(x1>x || y1>y) continue;
			ans+=((y-y1)/x1+1);
			ans%=MOD;
		}
		if(x<fib[n+1] || y<fib[n]){
			printf("%d %lld\n", n-1, ans);
			continue;
		}
		ans+=((x-fib[n+1])/fib[n]+1);
		ans%=MOD;
		for(int i=1; i<n; i++){
			ll x1=fib[n]+prod[n][i], y1=fib[n+1]+prod[n+1][i+1];
			if(x1>y || y1>x) continue;
			ans+=((x-y1)/x1+1);
			ans%=MOD;
		}
		printf("%d %lld\n", n-1, ans);
	}
	return 0;
}

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

#define int    long long

void fast()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
//a^n O(log(n))

int power(int a, int n)
{
	int result = 1;
	while (n > 0)
	{
		if (n & 1)
		{
			result = result * a;
		}
		a = a * a;
		n = n >> 1;

	}
	return result;
}


bool compare(string &s1, string &s2)
{
	return s1.size() < s2.size();
}

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

	int c0 = 0, c1 = 0, c2 = 0, c3 = 0;

	while (n--)
	{
		string s;
		cin >> s;

		if (s == "AC")
			++c0;
		else if (s == "WA")
			++c1;
		else if (s == "TLE")
			++c2;
		else if (s == "RE")
			++c3;
	}

	cout << "AC" << " x " << c0 << '\n';
	cout << "WA" << " x " << c1 << '\n';
	cout << "TLE" << " x " << c2 << '\n';
	cout << "RE" << " x " << c3 << '\n';

	return 0;
}


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

using namespace std;

const int INF = (int) 1e9;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), dp(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    int len = 0;
    for (int i = 0; i < n; ++i) {
        dp[a[i]] = dp[a[i] - 1] + 1;
        len = max(len, dp[a[i]]);
    }

    cout << n - len << endl;


    return 0;

}

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

int main() {
  int A ,B;
  char op ;
  cin >> A >> op >> B ;
  
  if(op == '+'){
    cout << A+B <<endl ;
  }
  else {
    cout << A-B << endl ;
  }

  
      // ここにプログラムを追記
}


Measured memory_bytes: 256
S = input()
if S[0] == 'R' and S[1] == 'R' and S[2] == 'R':
    print(3)
elif (S[0] == 'R' and S[1] == 'R') or (S[1] == 'R' and S[2] == 'R'):
    print(2)
elif S[0] == 'S' and S[1] == 'S' and S[2] == 'S':
    print(0)
else:
    print(1)


Measured memory_bytes: 61640
n = int(input())
t = [int(i) for i in input().split()]
v = [int(i) for i in input().split()]
time = sum(t)

speed = [10 ** 9] * (2 * time + 1)
limit = [10 ** 9] * (2 * time + 1)

i = 0
for j, k in zip(t, v):
    for _ in range(j * 2):
        limit[i] = min(limit[i], k)
        i += 1
    limit[i] = min(limit[i], k)

s = 0
for i in range(2 * time + 1):
    s = min(s, limit[i])
    speed[i] = min(speed[i], s)
    s += 0.5
s = 0
for i in reversed(range(2 * time + 1)):
    s = min(s, limit[i])
    speed[i] = min(speed[i], s)
    s += 0.5

dist = 0
for i in range(2 * time):
    dist += (speed[i] + speed[i + 1]) / 4
print(dist)


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    string s,t; cin>>s>>t;
    if(s==t){
        cout<<"EQUAL"<<endl;
        return 0;
    }else{
        if(s.size()<t.size()){
            cout<<"LESS"<<endl;
            return 0;
        }else if(s.size()>t.size()){
            cout<<"GREATER"<<endl;
            return 0;
        }else{
            for(int i=0;i<s.size();i++){
                if(s[i]-'0'<t[i]-'0'){
                    cout<<"LESS"<<endl;
                    return 0;
                }
                if(s[i]-'0'>t[i]-'0'){
                    cout<<"GREATER"<<endl;
                    return 0;
                }
            }
        }
    }
    
}


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

int main()
{
  int N ;
  string S;
  cin>>N>>S ;
  
  int num_W=0,num_E=0 ;
  for(int i=0;i<N;i++) if(S.at(i)=='E') num_E++ ;
  
  int min=1e9 ;
  for(int i=0;i<N;i++){
    if(S.at(i)=='E') num_E-- ;
    if(min>num_E+num_W) min=num_E+num_W ;
    if(S.at(i)=='W') num_W++ ;
  }
  cout<<min<<endl ;
  
  return 0 ;
}

Measured memory_bytes: 900
#include<stdio.h>
int main(){
    int i,u,t,n,x,count,sum2 = 0,sum3 = 0;
    for(;;){
        scanf("%d %d",&n,&x);
        count = 0;
        if( n == 0 && x == 0){
            break;
        }
        for( i = 1 ; i <= n ; i += 1){
            for( u = 1 ; u <= n ; u += 1){
                sum2 = i + u;
                if( i == u ){
                    continue;
                }
                else{
                    for( t = 1 ; t <= n ; t += 1){
                        sum3 = sum2 + t;
                        if( i == t || u == t){
                            continue;
                        }
                        else if( sum3 == x){
                            count += 1;
                        }
                    }
                }
            }
        }
        printf("%d\n",count / 6);
    }
    return 0;
}

Measured memory_bytes: 600
N=int(input())
A=['3','5','7']
i=0
while 1:
    now=A[i]
    if int(now+'3')<=N:A.append(now+'3')
    if int(now+'5')<=N:A.append(now+'5')
    if int(now+'7')<=N:A.append(now+'7')
    else:break
    i+=1

ans=0
B={'3','5','7'}
for a in A:
    if set(list(a))&B==B:
        ans+=1
print(ans)

Measured memory_bytes: 11064
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int a;
    cin>>a;
    cout<<3*a*a<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a ,b ,c;
  scanf( "%d %d %d" ,&a ,&b ,&c );

  if( a == 1 && b == 0 && c == 0 ){
    printf( "Close\n" );
  }

  if( a == 0 && b == 1 && c == 0 ){
    printf( "Close\n" );
  }

  if( a == 1 && b == 1 && c == 0 ){
    printf( "Open\n" );
  }

  if( a == 0 && b == 0 && c == 1 ){
    printf( "Open\n" );
  }

  if( a == 0 && b == 0 && c == 0 ){
    printf( "Close\n" );
  }

  return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_MAX / 2;

int main(){
    int N; cin >> N;
    int M = N/2;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    vector<vector<vector<ll>>> dp(N+1, vector<vector<ll>>(2, vector<ll>(3, -INF)));
    dp[0][1][0] = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 2; j++)
        { 
            for (int k = 0; k < 3; k++){
                if(k+j<3) dp[i+1][1][k+j] = max(dp[i+1][1][k+j], dp[i][j][k]);
                if(j==1)  dp[i+1][0][k]   = max(dp[i+1][0][k],   dp[i][1][k] + A[i]);
            }
        }
    }
    if(N%2==0) cout << max(dp[N][1][0],dp[N][0][1]) << endl;
    else cout << max(dp[N][0][2], dp[N][1][1]) << endl;
}

Measured memory_bytes: 33616
import sys
sys.setrecursionlimit(1000000)

n,m=map(int,input().split())

par=[i for i in range(n)]

def find(x):
  if x==par[x]:
    return x
  else:
    par[x]=find(par[x])
    return par[x]

def union(x,y):
  x=find(x)
  y=find(y)
  if x!=y:
    par[x]=y
 
f=lambda x:int(x)-1
for i in range(m):
  x,y=map(f,input().split())
  union(x,y)
  
for j in range(n):
  find(j)
from collections import Counter
c=Counter(par)
cv=c.values()
print(max(cv))


Measured memory_bytes: 174196
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    long long ans=1;
    long long mx=1e18;
    int N;
    cin>>N;

    vector<long long>A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }

    for(int i=0;i<N;i++){
        if(A[i]==0){
            cout<<"0"<<endl;
            return 0;
        }
    }

    for(int i=0;i<N;i++){
        if(mx/ans<A[i]){
            cout<<"-1"<<endl;
            return 0;
        }
        ans*=A[i];
    }

    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4056
#include<stdio.h>

int main(){
  int x, y, z, data, sum;
  sum = 1;


  while(scanf("%d %d",&x,&y) != EOF){
    while(1){


      if(sum == 1){
	z = x + y;
      }
      data = z / 10;
      if(data == 0){
	break;
      }
      z = z /10;
  
	sum += 1;
      
    }
    printf("%d\n",sum);
    sum = 1;
  }
  return 0;
}

Measured memory_bytes: 0
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        n: u64,
        k: u64,
        h:[u64;n]
    }
    let mut x = h.clone();
    x.sort_by(|a, b| a.cmp(&b));
    let sum : u64 = h.iter().sum::<u64>();
    let mut maxs: u64 = 0;
    for i in 0..k{
        match x.pop() {
            Some(a) => {maxs += a;}
            None    => {maxs += 0;}
        }
    }
    println!("{}", sum - maxs)
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

string K = "keyence";

int main()
{
    string S;
    cin >> S;
    string ans = "NO";
    REP(i, S.length())
    {
        //! iからL-7文字取り除く
        if (i - 8 >= 0)
            break;
        string s = "";
        REP(j, S.length())
        {
            if (j >= i && j <= i + (S.length() - 8))
                continue;
            s += S[j];
        }
        if (s == K)
        {
            ans = "YES";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int md = 1e9+7;
const int sz = 2e5;
// int A[sz+1];
// int F[sz+1];

int A[sz+1];
int dp[sz+2][2];

void solve(){
    int n;cin>>n;
    int a,b;
    int cnt = 0;
    int flag = 0;
    for (int i = 0; i < n; ++i)
    {
        cin>>a>>b;
        if(a==b){
            cnt++;
            if(cnt==3)
                flag = 1;
        }else{
            cnt = 0;
        }
    }

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


return;
}



int32_t main()
{
    IOS;
    // A[0] = 0;
    // F[0] = 1;

    // for (int i = 1; i <= sz; ++i)
    // {
    // 	A[i] = A[i-1]+i;
    // 	F[i] = F[i-1]*i;
    // }

    // for(int i=0;i<10;i++){
    // 	cout<<A[i]<<" ";
    // }
    // cout<<endl;
    // for(int i=0;i<10;i++){
    // 	cout<<F[i]<<" ";
    // }
    // cout<<endl;    
    // coust<<"A and F is filled"<<endl;
    // int t;
    // cin >> t;
    // while (t--) 
        solve();
    return 0;
        

    
}



Measured memory_bytes: 3624
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    int a, b, h;
   
    int s = 0;
   
      
    scanf("%d%d%d", &a, &b, &h );
      

    printf("%d\n", ( a + b ) * h / 2 );


    return 0;
                                                          
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

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

    vector<int> v(n);
    for(auto &it: v) cin>>it;

    int mini = 2e5+5;
    int count = 0;

    for(int i=0; i<n; i++) {
        if(v[i]<=mini) {
            count++;
            mini = v[i];
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl

int main() {
    string s;
    bool a_flg = false;
    bool b_flg = false;
    bool c_flg = false;

    cin >> s;
    
    for(int i=0; i<s.size(); i++) {
        if(s[i] == 'a') a_flg=true;
        if(s[i] == 'b') b_flg=true;
        if(s[i] == 'c') c_flg=true;
    }

    if(a_flg && b_flg && c_flg) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int max=0,i,j,k,a[100010][5],dp[100010][5],n;
  scanf("%d\n",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d %d\n",&a[i][0],&a[i][1],&a[i][2]);
  }
  for(i=0;i<=n;i++){
    for(j=0;j<3;j++){
      dp[i][j]=0;
    }
  }
  for(i=1;i<=n;i++){
    for(j=0;j<3;j++){
      for(k=0;k<3;k++){
          if(j!=k && dp[i-1][k]+a[i][j]>dp[i][j]){
            dp[i][j]=dp[i-1][k]+a[i][j];
          }
      }
    }
  }
  for(i=0;i<3;i++){
    if(dp[n][i]>max){
      max=dp[n][i];
    }
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 4096
/*
  AOJ 2070
  Title:First Experience
  @kankichi573
*/
#include <stdio.h>
char expr[81];

int calc(int r1,int r2,char op)
{
  if(op=='+')
    return(r1+r2);
  if(op=='-')
    return(r1-r2);
  if(op=='*')
    return(r1*r2);
  if(op==' ')
    return(r2);
}


main()
{
  int R1,R2,i;
  char R3,c,err;
  
  while(EOF!=scanf("%s",expr))
    {
      R1=R2=0,R3=' ',err=0;
      for(i=0;expr[i];i++)
	{
	  c=expr[i];
	  if(isdigit(c))
	    {
	      R2 *= 10;
	      R2 += (c-'0');
	      if(R2>=10000)
		{
		  err=1;
		  break;
		}
	    }
	  else if(c=='+'||c=='-'||c=='*'||c=='=')
	    {
	      R1=calc(R1,R2,R3);
	      if(R1>=10000 || R1 < 0)
		{
		  err=1;
		  break;
		}
	      R2=0;
	      R3=c;
	    }
	}
      if(err)
	printf("E\n");
      else
	printf("%d\n",R1);
    }
  return(0);
}

Measured memory_bytes: 556
import java.util.ArrayList;
import java.util.Scanner;

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

        int r = sc.nextInt();
        int D = sc.nextInt();
        int x = sc.nextInt();

        int tmp = r * x - D;
        for (int i = 0; i < 10; i++) {
            System.out.println(tmp);
            tmp = r * tmp - D;
        }
    }
}


Measured memory_bytes: 20948
N = int(input())
As = list(map(int, input().split()))

As.sort()

Ss = [As[0]]

for i in range(1,N):
  Ss.append(Ss[-1] + As[i])
  
cnt = 0
for i in range(N-1):
  if 2*Ss[i] < As[i+1]:
    cnt = i+1
    
print(N-cnt)

Measured memory_bytes: 91480
#include <bits/stdc++.h>
using namespace std;
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define fill(x, y)     memset(x, y, sizeof(y))
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
const   int            inf = 0;
const   double         eps = 0;
const   int            ms  = 0;
const   int            md  = 0;

std::unordered_map<ll, ll> memo;


ll Solve(ll N, ll A, ll B, ll C, ll D)
{

	if(N == 0) return 0;
	if(N == 1) return D;
	if(memo.find(N) != memo.end()) return memo[N];

	ll result = LONG_MAX;
	if(N < result/D)
		result = N*D;

	if(N%3 == 0)
		result = min(result, Solve(N/3, A, B, C, D) + B);
	else
	{
		result = min(result, B + (D*(N%3)) + Solve((N-(N%3)) / 3, A, B, C, D));
		result = min(result, B + (D*(3- N%3)) + Solve((N+(3 - N%3)) / 3, A, B, C, D));
	}

	if(N%5 == 0)
		result = min(result, Solve(N/5, A, B, C, D) + C);
	else
	{
		result = min(result, C + (D*(N%5)) + Solve((N-(N%5)) / 5, A, B, C, D));
		result = min(result, C + (D*(5- N%5)) + Solve((N+5-N%5) / 5, A, B, C, D));
	}


	if(N%2 == 0)
		result = min(result, Solve(N/2, A, B, C, D) + A);
	else
	{
		result = min(result, A + D + Solve((N+1)/2, A, B, C, D));
		result = min(result, A + D + Solve((N-1)/2, A, B, C, D));
	}


	return memo[N] = result;
}

void StateResult(ll result)
{
	std::cout << result << "\n";
}

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

    int testcases;
    cin >> testcases;
    while(testcases--)
    {
    	ll N, A, B, C, D;
    	cin >> N >> A >> B >> C >> D;
    	if(N == 0)
    	{
    		StateResult(N);
    		continue;
    	}
    	memo.clear();

    	ll result = Solve(N, A, B, C, D);
    	StateResult(result);
    }

	return 0;

}

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

int main() {

    int a, b;

    std::cin >> a >> b;

    std::cout << std::fixed << std::setprecision(5);

    std::cout <<      a / b << " "
              <<      a % b << " "
              << 1. * a / b << std::endl;

    return 0;
}



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

int main()
{
    int n;
    cin >> n;
    vector<ll> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end());
    // vector<ll> org_l(l);
    // l.erase(std::unique(l.begin(), l.end()), l.end());
    int ans = 0;
    for(int i=0; i<l.size(); i++){
        ll a = l[i];
        for(int j=i+1; j<l.size(); j++){
            ll b = l[j];    
            if(a==b) continue;
            for(int k=j+1;k<l.size(); k++){
                ll c = l[k];
                if(b==c || a==c) continue;
                if(a+b>c&&a+c>b&&b+c>a) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
A,B,M = map(int,input().split())
Ai = list(map(int,input().split()))
Bi = list(map(int,input().split()))
amin = min(Ai)
bmin= min(Bi)
min = amin+bmin
for i in range(M):
	xi,yi,ci = map(int,input().split())
	if Ai[xi-1] + Bi[yi-1] - ci < min:
		min = Ai[xi-1] + Bi[yi-1] - ci
print(min)


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

int main(){
	string s;
	cin>>s;
	int l=s.size();
	int a;
	for(int i=0;i<l;i++){
		if(s[i]=='A'){
			a=i;
			break;
		}
	}
	int z;
	for(int i=l-1;i>=0;i--){
		if(s[i]=='Z'){
			z=i;
			break;
		}
	}
	cout<<z-a+1;
	return 0;
}

Measured memory_bytes: 640
n = int(input())
choice = [1]
for i in range(1,7):
    choice.append(6**i)
    choice.append(9**i)
dp = [float('INF')]*(10**5+1)
dp[0] = 0
for i in range(1,10**5+1):
    for j in choice:
        if i<j:
            continue
        else:
            dp[i] = min(dp[i],dp[i-j]+1)
print(dp[n])

Measured memory_bytes: 3828
k = int(input())

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

res = 0

for a in range(1, k + 1):
    for b in range(1, a + 1):
        for c in range(1, b + 1):
            tmp = gcd(a, b, c)
            if len(set([a, b, c])) == 1:
                res += tmp
            elif len(set([a, b, c])) == 2:
                res += 3 * tmp
            else:
                res += 6 * tmp

print(int(res))

Measured memory_bytes: 9632
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d,e,k;
    int g,w,s,r,t,y,u,m,n,v;
    cin>>a>>b>>c>>d>>e>>k;
    g=b-a; w=c-a; s=d-a; r=e-a; t=c-b;
    y=d-b; u=e-b; m=d-c; n=e-c; v=e-d;
    if(g>k or w>k or s>k or r>k or t>k or y>k or u>k or m>k or n>k or v>k)
    {
        cout<<":(";
    }
    else 
     cout<<"Yay!";
    
    return 0;
}

Measured memory_bytes: 256
import static java.math.BigDecimal.ROUND_HALF_DOWN;

import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = Integer.parseInt(sc.next());
    }
    BigDecimal ans = IntStream.of(a)
      .mapToObj(
        i -> BigDecimal.valueOf(1, 10).divide(BigDecimal.valueOf(i, 10), 10, ROUND_HALF_DOWN))
      .reduce(BigDecimal::add).map(decimal -> BigDecimal.ONE.divide(decimal, 10, ROUND_HALF_DOWN))
      .get();
    pw.println(ans.doubleValue());
  }
}


Measured memory_bytes: 27348
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;


int main(){
    int k, n;
    cin >> k >> n;
    vector<int> v(n);
    int ai;
    for(int i=0; i<n; i++){
        cin >> ai;
        v[i] = ai;
    }
    vector<int> s(n);
    s[0] = v[0] + (k-v[n-1]);

    for(int i=1; i<n; i++){
        s[i] = v[i]-v[i-1];
    }

    vector<int>::iterator it = max_element(s.begin(), s.end());
    cout << k-*it << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define debug(x) cerr << #x << ": " << x << endl
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef DEBUG
  freopen("in", "r", stdin);
#endif

  ll a, b, c;
  cin >> a >> b >> c;
  if (c - a - b >= 0 && 4 * a * b < (c - a - b) * (c - a - b)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }

  return 0;
}




Measured memory_bytes: 256
H, W, K = map(int, input().split())
S = [[f for f in input()]for _ in range(H)]
Ans = [[0] * W for _ in range(H)]
num = 1
Flag = True
first = -1
for i in range(H):
    flag = False
    for j in range(W):
        if (S[i][j] == '#') and flag:
            num += 1
        if (S[i][j] == '#') and Flag:
            first = i
        if S[i][j] == '#':
            flag = True
            Flag = False
        Ans[i][j] = num
    if not flag:
        Ans[i] = Ans[i-1]
    else:
        num += 1

while first > 0:
    Ans[first - 1] = Ans[first]
    first -= 1

for ans in Ans:
    for i, a in enumerate(ans):
        if i == W-1:
            print(a)
        else:
            print(a, end=' ')








Measured memory_bytes: 79752
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;

int64_t mod = 998244353 ;

vector<int> getprime(int n){
    vector<int> p(0) ;
    vector<bool> table(n+1,0) ;
    for (int i = 2; i <= n; i++)
    {
        if (table.at(i) == 0)
        {
            p.push_back(i) ;
            for (size_t j = 2; j < n/i ; j++)
            {
                table.at(i*j) = 1 ;
            }
            
        }
        
    }
    return p ;
}

int d(int64_t n){
    int re = 1 ;
    while (1)
    {
        n /= 10 ;
        if (n > 0)
        {
            re ++ ;
        }else
        {
            return re ;
        }
        
        
    }
    
}

int main(){
    int n,l ;
    cin >> n >> l ;
    int a ;
    int back ;
    cin >> back ;
    for (int i = 0; i < n-1; i++)
    {
        cin >> a ;
        if (back + a >= l)
        {
            cout << "Possible" << endl ;
            for (int j = 1; j < i+1 ; j++)
            {
                cout << j << endl ;
            }
            for (int j = 0; j < n-1-i; j++)
            {
                cout << n-1-j << endl ;
            }
            return 0 ;
            
        }else
        {
            back = a ;
        }
        
        
    }
    
    cout << "Impossible" << endl ;
    
    
    
}

Measured memory_bytes: 3600
S = list(map(int, list(input())))

def sum_of_digit(d, l, s): #d: その位の数が何か l: 桁の数 s:下から何桁目か 下に置ける+は2^(s-1)通り 上に置ける+は2^(l-s)通り
    # 2^(s-2) * 10^0 | 2^(s-3) * 10^1 | ... | 2^0 * 10^(s-2) | 1 * 10^(s-1)
    if s == 0:
        return d * (2 ** (l - s))
    else:
        digits = [(2 ** (s - 2 - i)) * (10 ** i) for i in range(s - 1)] + [10 ** (s - 1)]
        return d * (2 ** (l - s)) * sum(digits)

ans = 0
for i in range(len(S)):
    ans += sum_of_digit(S[i], len(S), len(S) - i)
    
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++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(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;

    ll answer = 0;
    FOR(i,1,n+1){
        if(i%3 != 0 && i%5 != 0)answer+=(ll)i;
    }
    cout << answer << endl;
    return 0;
}

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

int main(void) {
    int n,l;
    cin>>n>>l;
    vector<string> str;
    fill(str.begin(),str.end(),"\0");
    for(int i=0;i<n;i++) {
        string sub;
        cin>>sub;
        str.push_back(sub);
    }
    sort(str.begin(),str.end());
    for(int i=0;i<n;i++) {
        cout<<str[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

string component(const string& s) {
	string C="00000000000000000000000000";
	for (char c : s) C[c - 'a']++;
	return C;
}

int main() {
	int N;
	cin >> N;
	unordered_map<string, int> types;
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		types[component(S)]++;
	}
	long long ans = 0;
	for (auto& t : types) ans += (long long)t.second * (t.second - 1) / 2;
	cout << ans << endl;
}


Measured memory_bytes: 12196
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N;
    cin >> N;
    vector<ll> Ais;
    for (ll i = 0; i < N; i++) {
        ll Ai;
        cin >> Ai;
        Ais.push_back(Ai);
    }
    ll mx = 0;
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ll buy = (Ais[i] % (mx + 1) != 0) ? Ais[i] / (mx + 1) : Ais[i] / (mx + 1) - 1;
        ans += buy;
        Ais[i] -= buy * (mx + 1);
        if (Ais[i] >= 2 && buy >= 1) {
            Ais[i]--;
        }
        mx = max(mx, Ais[i]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 1400
#!/usr/bin/env python3
import sys
# import random

# tc_1 = "".join([random.choice("ACGT") for x in range(100)])
# tc_q = sorted([random.choice(range(100)) for _ in range(2)])
# print(tc_1[tc_q[0]-1:tc_q[1]])
# print(tc_1[tc_q[0]-1:tc_q[1]].count("AC"))
# print(solve(1, 1, tc_1, [tc_q[0]], [tc_q[1]]))


def solve(N: int, Q: int, S: str, l: "List[int]", r: "List[int]"):
    # ACがある場所を記録する
    buf = None
    mem = []
    tot = 0
    for i, c in enumerate(S):
        if c == 'A':
            buf = 'A'
        elif buf == 'A' and c == 'C':
            tot += 1
            buf = None
        elif buf == 'A':
            buf = None
        mem.append(tot)
    # print(mem)
    for i in range(Q):
        print(mem[r[i]-1]-mem[l[i]-1])

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    l = [int()] * (Q)  # type: "List[int]"
    r = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(N, Q, S, l, r)


if __name__ == '__main__':
    main()


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



int main() {

    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int n,m;
    cin>>n>>m;
    vector<vector<int>> edges(n+1);

    for(int i = 0; i < m; i++) {
    	int u,v;
    	cin>>u>>v;
    	edges[u].push_back(v);
    	edges[v].push_back(u);
    }

    for(int i = 1; i <= n; i++) {
    	cout<<edges[i].size()<<endl;
    }



	return 0;		
}


//1011




Measured memory_bytes: 3624