akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC080_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int numX = int.Parse(input);
            int numFX = 0;

            for (int i = 0; i < input.Length; i++)
            {
                numFX += int.Parse(input[i].ToString());
            }

            if (numX % numFX == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

string s,t;

void solve()
{
	set<char> have;
	for(auto ch : s) have.insert(ch);
	bool ok = true;
	for(auto ch : t){
		if(!have.count(ch)){
			ok = false;
			break;
		}
	}
	if(!ok){
		cout << -1 << "\n";
		return;
	}
	ll ans = 0, cur_idx = 0;
	const int N = t.length();
	for(int i=0;i<N;){
		const char cur = t[i];
		auto nex_idx = s.find(cur, cur_idx);
		if(nex_idx != string::npos){
			ans += nex_idx-cur_idx+1;
			cur_idx = nex_idx+1;
			i++;
		}else{
			ans += s.length()-cur_idx;
			cur_idx = 0;
		}
	}
	cout << ans << endl;
}

int main()
{
	cin >> s >> t;
	solve();
	return 0;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N, C int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d", &N, &C)

	xs := make([]int, N+2)
	vs := make([]int, N+2)
	sumv := make([]int, N+2)
	for i := 1; i < N+1; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d %d", &xs[i], &vs[i])
		sumv[i] = sumv[i-1] + vs[i]
	}
	xs[N+1] = C
	vs[N+1] = 0
	sumv[N+1] = sumv[N]

	leftMax := make([]int, N+2)
	left2Max := make([]int, N+2)
	for left := 1; left < N+1; left++ {
		v := sumv[left]
		d := xs[left]
		leftMax[left] = max(leftMax[left-1], v-d)
		left2Max[left] = max(left2Max[left-1], v-2*d)
	}
	rightMax := make([]int, N+2)
	right2Max := make([]int, N+2)
	for right := N; right > 0; right-- {
		v := sumv[N] - sumv[right-1]
		d := C - xs[right]
		rightMax[right] = max(rightMax[right-1], v-d)
		right2Max[right] = max(right2Max[right-1], v-2*d)
	}

	ans := 0
	for i := 0; i <= N; i++ {
		c1 := left2Max[i] + rightMax[i+1]
		c2 := leftMax[i] + right2Max[i+1]
		ans = max(ans, c1, c2)
	}
	fmt.Println(ans)
}

func max(ns ...int) int {
	ret := math.MinInt64
	for _, n := range ns {
		if n > ret {
			ret = n
		}
	}
	return ret
}


Measured memory_bytes: 8704
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
int main(void)
{
    string s;
    string t;

    cin>>s>>t;

    rep(i,s.size())
    {
        if(s[i]!=t[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;

}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  string A;
  cin >> A;
  char B, C;
  if(A.size() == 2) {
    cout << A << endl;
  }
  else {
    B = A.at(0);
    C = A.at(2);
    A.at(0) = C;
    A.at(2) = B;
    cout << A << endl;
  }
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
int main(){
string a,b,c;
char x,y,z;
cin>>a>>b>>c;
x=a.at(0);
y=b.at(0);
z=c.at(0);	
cout<<(char)toupper(x)<<(char)toupper(y)<<(char)toupper(z);
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  if(!(n % 2)) {
    char s1[n / 2 + 1] = {}, s2[n / 2 + 1] = {};
    s.copy(s1, n / 2);
    s.copy(s2, n / 2, n / 2);
    if(!strcmp(s1, s2)) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr
aa,bb=factorization(a),factorization(b)
cnt=0
for i in aa:
  if i in bb:
    cnt+=1
if a==1 and b==1:
  print(1)
else:
  print(cnt+1)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define N 16 
using namespace std;
int m,n;
double neko[N][N];
double dfs(int pos,int k,int bit);
double calc(int pos,int bit){
  static int used[N][1<<N]={};
  static double mem[N][1<<N];
  if(used[pos][bit]++) return mem[pos][bit];
  double mx = 0;
  for(int i=0;i<m;i++)if(((bit>>i)&1)==0)mx=max(mx,dfs(pos,i,bit));
  return mem[pos][bit] = mx;
}

double dfs(int pos,int k,int bit){
  if(pos==n) return 1;
  double p = neko[k][pos];
  return p*dfs(pos+1,k,bit) + (1-p)*calc(pos,bit|(1<<k));
}


int main(){
  cin>>m>>n;
  for(int i=0;i<m;i++)
    for(int j=0;j<n;j++)cin>>neko[i][j];
  
  double ans=0;
  for(int i=0;i<m;i++) ans=max(ans,dfs(0,i,0));
  printf("%.10f\n",ans);
  return 0;
}

Measured memory_bytes: 15480
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[100001];

LL ans = 0;

void solve(){
	//Aの大小関係をもとに順列みたいにする
	//例えばA = {10,8,3,5,2}みたいな数列なら{5,4,2,3,1}みたいに変換
	map<LL,int> ind;//数xがAの何番めにあるかをind[x]とする
	for(int i=1;i<=N;i++) ind[A[i]] = i;
	int counter = 1;
	for(auto iter=ind.begin();iter!=ind.end();iter++){
		A[iter->second] = counter;
		counter++;
	}
	//インデックスが偶数番目同士、奇数番目同士は好きなだけ入れ替えられるので
	//偶数番目⇄奇数番目の入れ替えの最小回数を求めればそれが答え
	for(int i=1;i<=N;i++){
		if(i%2!=A[i]%2) ans++;
	}
	ans /= 2;
}

int main(){
    cin >> N;
    for(int i=1;i<=N;i++) cin >> A[i];

    solve();

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

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

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;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

template<typename Monoid,typename F>
struct SegmentTree{
	int sz;
	vector<Monoid> node;
	const F op;//演算
	const Monoid e;//単位元
	SegmentTree(int n,const F op,const Monoid &e):op(op),e(e){
		sz=1;
		while(sz<n) sz*=2;
		node.assign(2*sz,e);
	}
	void build(const vector<Monoid> &v){
		int n=v.size();
		for(int i=0;i<n;i++) node[i+sz-1]=v[i];
		for(int i=sz-2;i>=0;i--) node[i]=op(node[2*i+1],node[2*i+2]);
	}
	void update(int k,const Monoid &x){
		k+=sz-1;
		node[k]=x;
		while(k>0){
			k=(k-1)/2;
			node[k]=op(node[2*k+1],node[2*k+2]);
		}
	}
	Monoid query(int a,int b,int k=0,int l=0,int r=-1){
		if(r<0) r=sz;
		if(r<=a || b<=l) return e;
		if(a<=l && r<=b) return node[k];
		else{
			Monoid vl=query(a,b,2*k+1,l,(l+r)/2);
			Monoid vr=query(a,b,2*k+2,(l+r)/2,r);
			return op(vl,vr);
		}
	}
	Monoid operator[](const int &k)const{
		return node[k+sz-1];
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<ll> a(n);
	rep(i,n){
		ll now=(ll)s[i]-'a';
		a[i]=1ll<<now;
	}
	auto op=[](ll a,ll b){
		ll ret=a|b;
		return ret;
	};
	ll e=0;
	SegmentTree<ll,decltype(op)> seg(n+10,op,e);
	seg.build(a);
	int q;
	cin>>q;
	while(q--){
		int a;
		cin>>a;
		if(a==1){
			int b;
			char c;
			cin>>b>>c;
			int now=c-'a';
			ll x=1ll<<now;
			seg.update(b-1,x);
		}else{
			int b,c;
			cin>>b>>c;
			ll ret=seg.query(b-1,c);
			cout<<__builtin_popcountll(ret)<<endl;
		}
	}
}

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

int main() {
    int h, w;
    cin >> h >> w;

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

    vector<bool> row(h, false);
    vector<bool> col(w, false);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (A[i][j] == '#') {
                row[i] = true;
                col[j] = true;
            }
        }
    }

    for (int i = 0; i < h; i++) {
        if (row[i]){
            for (int j = 0; j < w; j++) {
                if (col[j]) {
                    cout << A[i][j];
                }
            }
            cout << endl;
        }
    }
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	int currH;
	int max = 0;
	int current = 0;
	cin >> currH;
	for(int i = 0; i < n - 1; i++){
		int h;
		cin >> h;
		if(currH >= h){
			currH = h;
			current++;
		}else{
			currH = h;
			if(current > max){
				max = current;
			}
			current = 0;
		}
	}

	if(current > max){
		max = current;
	}
	
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    ll n, m; cin >> n >> m;
    ll ans = 0;
    if(n >= m/2) ans = m/2;
    else {
        ans = n;
        m -= 2 * n;
        ans += m / 4;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()

def calc_dp(st):
    len_st = len(st)
    dp = [[0] * 3 for _ in range(len_st + 1)]
    for ind, i in enumerate(st, 1):
        dp[ind][0] = max(dp[ind-1][1],dp[ind-1][2])
        dp[ind][1] = max(dp[ind-1][0],dp[ind-1][2])
        dp[ind][2] = max(dp[ind-1][0],dp[ind-1][1])
        if(i=='r'):
            dp[ind][2] += p
        elif(i=='s'):
            dp[ind][0] += r
        else:
            dp[ind][1] += s

    return max(dp[-1])

ans = 0
for i in range( k ):
    if( i >= n ):
        break
    st = t[i::k]
    ans += calc_dp(st)

print(ans)

Measured memory_bytes: 57584
st = input()
q = int(input())

for x in range(q):
    ip = list(input().split())

    if ip[0] == "print":
        print(st[int(ip[1]):int(ip[2])+1])
    elif ip[0] == "replace":
        ip[1] = int(ip[1])
        ip[2] = int(ip[2])
        temp = st[0:ip[1]] + ip[3] + st[ip[2]+1:]
        st = temp
    elif ip[0] == "reverse":
        ip[1] = int(ip[1])
        ip[2] = int(ip[2])
        temp = st[0:ip[1]] + st[ip[1]:ip[2]+1][::-1] + st[ip[2]+1:]
        st = temp






Measured memory_bytes: 5616
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>
#include <climits>

using namespace std;


int main(){
  int n,*R,maxv=INT_MIN,minv;

  scanf("%d\n",&n);

  R=(int *)malloc(n*sizeof(int));

  for(int i=0;i<n;i++){
    scanf("%d\n",&R[i]);
  }
  minv=R[0];
  for(int j=1;j<n;j++){
    maxv=max(maxv,R[j]-minv);
    minv=min(minv,R[j]);
    //printf("R[j] %d maxv %d,minv %d\n",R[j],maxv,minv);
  }
  printf("%d\n",maxv);
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===

const int INF = int(1e9 + 7);

int main() {

	int N, M;
	cin >> N >> M;
	vector<Vi> to(N);
	for (int i = 0; i < M; ++i) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		to[u].push_back(v);
	}
	int S, T;
	cin >> S >> T;
	--S; --T;

	int (*dist)[3] = new int[N][3];
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			dist[i][j] = INF;
		}
	}

	queue<Pii> q;
	q.emplace(S,0);
	dist[S][0] = 0;
	while (!q.empty()) {
		int v = q.front().first;
		int l = q.front().second;
		q.pop();
		for (const auto& u : to[v]) {
			int nl = (l + 1) % 3;
			if (dist[u][nl] != INF) continue;
			dist[u][nl] = dist[v][l] + 1;
			q.emplace(u, nl);
		}
	}

	int ans = dist[T][0];
	delete[] dist;

	if (ans == INF) ans = -1;
	else ans /= 3;
	cout << ans << endl;
}


Measured memory_bytes: 6912
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<typeinfo>
#include<cassert>
#include<functional>
#include<algorithm>
#include<climits>
#include<map>

using namespace std;

int main(){

   int N,D,X;

   cin >> N >> D >> X;

   int a[N+1];

   for(int i = 1;i <= N;i++){
	   int A;
	   cin >> A;
	   a[i] = A;
   }

   int count = 0;

   for(int i = 1;i <= N;i++){

	   int b = 1;

	   while(b <= D){
		   count++;
		   b += a[i];
	   }

   }

   cout << count + X << endl;

  return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;
#define NIL NULL

void inorder(Node);
void prerder(Node);
void insert(int);
Node treeSearch(Node, int);

Node root = NIL;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ){
    y = x;
    if( z->key < x->key ) x = x->left;
    else x = x->right;
  }

  z->parent = y;
  if( y == NIL ){
    root = z;
  }
  else if( z->key < y->key ){
    y->left = z;
  }
  else y->right = z;
}

void inorder(Node u){
  if( u->left != NIL ){
    inorder(u->left);
  }
  printf(" %d",u->key);
  if( u->right != NIL ){
    inorder(u->right);
  }
}

void preorder(Node u){
  printf(" %d",u->key);
  if( u->left != NIL ){
    preorder(u->left);
  }
  if( u->right != NIL ){
    preorder(u->right);
  }
}

Node treeSearch(Node u, int k){
  while( u != NIL && k != u->key ){
    if( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

int main(void){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d",&x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }

    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }
  return 0;
}

Measured memory_bytes: 9840
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n, parent[100009], x, y;
ll ans;
struct Edge
{
	int from, to, cost;
};
vector<pair<pair<int, int>, int> > a;
vector<Edge> edges;
int find_set(int v)
{
	if (v == parent[v])
		return v;
	return parent[v] = find_set(parent[v]);
}
void union_sets(int a, int b)
{
	a = find_set(a);
	b = find_set(b);
	if (a != b)
		parent[b] = a;
}
bool sortx(pair<pair<int, int>, int>  aa, pair<pair<int, int>, int>  bb)
{
	return aa.f.f<bb.f.f;
}
bool sorty(pair<pair<int, int>, int>  aa, pair<pair<int, int>, int>  bb)
{
	return aa.f.s<bb.f.s;
}
bool sortedges(Edge aa, Edge bb)
{
	return aa.cost<bb.cost;
}
int main()
{
	IO;
	cin>>n;
	for (int i=0; i<n; i++)
	{
		parent[i]=i;
		cin>>x>>y;
		a.push_back(make_pair(make_pair(x,y), i));
	}
	sort(a.begin(), a.end(), sortx);
	for (int i=1; i<a.size(); i++)
	{
		x=a[i].s, y=a[i-1].s;
		int dx=abs(a[i].f.f-a[i-1].f.f);
		int dy=abs(a[i].f.s-a[i-1].f.s);
		Edge e;
		e.from=x;
		e.to=y;
		e.cost=min(dx, dy);
		edges.push_back(e);
	}
	sort(a.begin(), a.end(), sorty);
	for (int i=1; i<a.size(); i++)
	{
		x=a[i].s, y=a[i-1].s;
		int dx=abs(a[i].f.f-a[i-1].f.f);
		int dy=abs(a[i].f.s-a[i-1].f.s);
		Edge e;
		e.from=x;
		e.to=y;
		e.cost=min(dx, dy);
		edges.push_back(e);
	}
	sort(edges.begin(),edges.end(),sortedges);
	for (Edge e : edges)
	{
		if (find_set(e.from) != find_set(e.to))
		{
			ans += e.cost;
			union_sets(e.from, e.to);
		}
	}
	cout<<ans;
}


Measured memory_bytes: 6516
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}
int t[30];
signed main() {
	string s;
	cin>>s;
	rep(i,s.size()){
		t[s[i]]++;
		if(t[s[i]]>1){
			cout<<"no"<<endl;
			return 0;
		}
	}
	cout<<"yes"<<endl;
}


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

ll n,a[100000],ans=0;

int main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
        if(a[ans]>a[i])ans=i;
    }
    cout<<ans+1<<endl;
}


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

int main(){
  string s;
  cin>>s;
  int l=s.size();
  bool a[l];
  for(int i=0;i<l;i++){
    a[i] = false;
    if(s[i] == 'A' ||s[i] == 'T' ||s[i] == 'C' ||s[i] == 'G'){
      a[i] = true;
    }
  }
  bool f1= false;
  int ans=0,c=0;
  for(int i=0;i<l;i++){
    if(a[i]){
      c++;
    }
    else{
      ans=max(ans,c);
      c=0;
    }
  }
  ans =max(ans,c);
  cout<<ans<< endl;
}
      

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
template<class F>
auto  minimize_bsearch(int imin,int imax,F &f){ //(imin,imax]
    /*
     return minimum index such that v[index] >= value
     auto f(int mid) {return v[mid] >= value;}
     */
    while(imax - imin > 1){
        int mid = imin + (imax - imin)/2;
        if(f(mid)) imax = mid;
        else imin = mid;
    }
    return imax; //imax is ans
}

template<class F>
auto  maximize_bsearch(int imin,int imax,F &f){ //[imin,imax)
    /*
     return maximum index such that v[index] <= value
     auto f(int mid) {return v[mid] <= value;}
     */
    while(imax - imin > 1){
        int mid = imin + (imax - imin)/2;
        if(f(mid)) imin = mid;
        else imax = mid;
    }
    return imin; //imin is ans
}
signed main(){
    int n,A,B;
    cin >> n >> A >> B;
    vector<int>h(n);
    for(auto  & e  : h) cin >> e;
    sort(all(h),greater<>());
    function<bool(int)>comp = [&](int mid) -> bool{
        int margin = (A - B) * mid;
        for(auto e : h){
            if(e  <= B*mid){
                
            } else {
                int dif = e - B*mid;
                margin -= (dif/(A-B) + (dif % (A-B) ? 1:0)) * (A-B);
                if(margin < 0 )return false;
            }
        }
        return true;
    };
    cout << minimize_bsearch(0,1000000000, comp) << endl;
}



Measured memory_bytes: 1024
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=500001;
P a[maxn],b[maxn];
vector<ll> divisor(ll x){
  vector<ll> res;
  for(ll i=1LL;i*i<=x;i++){
    if(x%i==0){
      res.push_back(i);
      if(i!=x/i)res.push_back(x/i);
    }
  }
  return res;
}

int main(){
  int ax,ay,bx,by;
  cin>>ax>>ay>>bx>>by;
  if(ax<=bx)for(int i=0;i<abs(ax-bx);i++)cout<<'R';
  else for(int i=0;i<abs(ax-bx);i++)cout<<'L';

  if(ay<=by)for(int i=0;i<abs(ay-by);i++)cout<<'U';
  else for(int i=0;i<abs(ay-by);i++)cout<<'D';

  if(ax<=bx)for(int i=0;i<abs(ax-bx);i++)cout<<'L';
  else for(int i=0;i<abs(ax-bx);i++)cout<<'R';

  if(ay<=by)for(int i=0;i<abs(ay-by);i++)cout<<'D';
  else for(int i=0;i<abs(ay-by);i++)cout<<'U';
  
  if(ax<=bx){
    if(ay<=by)cout<<"D";
    else cout<<"U";
    for(int i=0;i<abs(ax-bx)+1;i++)cout<<'R';
    if(ay<=by)for(int i=0;i<abs(ay-by)+1;i++)cout<<'U';
    else for(int i=0;i<abs(ay-by)+1;i++)cout<<'D';
    cout<<"L";

    if(ay<=by)cout<<"U";
    else cout<<"D";
    for(int i=0;i<abs(ax-bx)+1;i++)cout<<'L';
    if(ay<=by)for(int i=0;i<abs(ay-by)+1;i++)cout<<'D';
    else for(int i=0;i<abs(ay-by)+1;i++)cout<<'U';
    cout<<"R";
  }
  else{
    if(ay<=by)cout<<"D";
    else cout<<"U";
    for(int i=0;i<abs(ax-bx)+1;i++)cout<<'L';
    if(ay<=by)for(int i=0;i<abs(ay-by)+1;i++)cout<<'U';
    else for(int i=0;i<abs(ay-by)+1;i++)cout<<'D';
    cout<<"L";

    if(ay<=by)cout<<"U";
    else cout<<"D";
    for(int i=0;i<abs(ax-bx)+1;i++)cout<<'R';
    if(ay<=by)for(int i=0;i<abs(ay-by)+1;i++)cout<<'D';
    else for(int i=0;i<abs(ay-by)+1;i++)cout<<'U';
    cout<<"L";
  }
    
  





cout<<endl;
}


Measured memory_bytes: 256
import math

def ABC137C(i):
    if i!=1:
        return math.factorial(i)//math.factorial(i-2)//2
    else:
        return 0

n,*a=open(0).read().split()
a=[''.join(sorted(i)) for i in a]
d=dict()
p=0
for i in a:
    if i not in d:
        d[i]=1
    else:
        d[i]+=1
for i in d.values():
    p+=ABC137C(i)
print(p)

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

void dfs(vector<vector<int>> &g, int v, int p, vector<int> &c) {
	for(auto next_v: g[v]) {
		if(next_v == p) continue;
		c[next_v] += c[v];
		dfs(g, next_v, v, c);
	}
}

int main() {
	int n, q;
	cin >> n >> q;
	vector<vector<int>> g(n);
	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> p(q), x(q), c(n);
	rep(i, q) {
		cin >> p[i] >> x[i];
		p[i]--;
	}
	rep(i, q) {
		c[p[i]] += x[i];
	}
	dfs(g, 0, -1, c);
	rep(i, n) printf("%d%c", c[i], (i == n-1) ? '\n' : ' ');
	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

const int INF = 1001001001;
int dist[100005][3];

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> to[n];
  rep(i, m) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    to[u].push_back(v);
  }
  int sv, tv;
  cin >> sv >> tv;
  --sv, --tv;

  rep(i, n) rep(j, 3) dist[i][j] = INF;

  queue<P> q;
  q.push({sv, 0});
  dist[sv][0] = 0;
  while (!q.empty()) {
    int v = q.front().first;
    int l = q.front().second;
    q.pop();

    for (auto u : to[v]) {
      int nl = (l + 1) % 3;
      if (dist[u][nl] != INF) continue;
      dist[u][nl] = dist[v][l] + 1;
      q.push({u, nl});
    }
  }

  int ans = dist[tv][0];
  cout << (ans == INF ? -1 : ans / 3) << endl;
  return 0;
}


Measured memory_bytes: 10204
#include <iostream>
#include <string>

using namespace std;

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

    for(int i = 0; i < S.size(); ++i){
        for(int j = 0; j < N; ++j){
            if(S[i] == 'Z'){
                S[i] = 'A';
            }else{
                ++S[i];
            }
        }
    }
    cout << S << endl;

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 200000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,a[MN+5],num[MN+5],mx;
int main()
{
    n=read();
    for(int i=1;i<=n;++i) a[i]=read(),mx=max(mx,a[i]),++num[a[i]];
    if(mx==1)
    {
        if(n>2) return 0*puts("Impossible");
        else return 0*puts("Possible");
    }
    int mnlen=(mx+1)/2;
    for(int j=1;j<mnlen;++j) if(num[j]) return 0*puts("Impossible");
    for(int j=mnlen;j<=mx;++j) if(num[j]<2-(j*2==mx)) return 0*puts("Impossible");
    if(mx%2==0&&num[mx/2]>1) return 0*puts("Impossible");
    if(mx%2==1&&num[mx/2+1]>2) return 0*puts("Impossible");
    puts("Possible");
    return 0;
}


Measured memory_bytes: 256
# ??????????????????????????????????????????????????????
def can_load? baggages, track_size, max_weight
  baggages = baggages.dup
  track_count = 1

  #puts "?????§??????????????°???#{track_size}?????¨????????°?????????????????????#{max_weight}"
  baggages.reduce(0) {|last, item|
    #puts "?????????: #{last}"
    weight = last + item
    # ????????????????????£???????¬????????????????????????????
    if weight > max_weight
      track_count += 1
      #puts "??????????????°?????? #{track_count}"
      next item
    end

    # ????????????????????????????¬??????????????????????
    weight
  }

  track_count <= track_size
end

def search baggages, track_size
  min = baggages.max
  max = baggages.reduce(0) {|sum, item| sum + item}
  #(min..max).each {|min_weight|
  #  can_load = can_load? baggages, track_size, min_weight
  #  #puts "????????????#{can_load}"
  #  return min_weight if can_load
  #}
  (min..max).bsearch{|min_weight| can_load? baggages, track_size, min_weight}
end

# ????°?????????????????????????????????????????????§???

# ?????§????????¨?????????

def main
  array = STDIN.read.split(/\n/)
  baggage_size, track_size = array.shift.split(' ').map{|s|s.to_i}
  baggages = array.map{|s|s.to_i}
  puts search baggages, track_size
end

main

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

ll n;
vector<vector<ll>> graph(1e5);
vector<vector<ll>> dp(1e5,vector<ll>(2,-1));
const ll MOD = 1e9+7;

ll dfs(ll now, ll pre, ll c)
{
    ll i;
    if(dp.at(now).at(c) != -1) return dp.at(now).at(c);
    ll res = 1;
    if(c == 0){
        for(auto next:graph.at(now)){
            if(next == pre) continue;
            res *= dfs(next, now, 1);
            res %= MOD;
        }
        return dp.at(now).at(c) = res;
    }else{
        for(auto next:graph.at(now)){
            if(next == pre) continue;
            res *= dfs(next, now, 1) + dfs(next, now, 0);
            res %= MOD;
        }
        return dp.at(now).at(c) = res;
    }
}


int main()
{
    ll i,j;
    cin >> n;
    const ll MOD = 1e9+7;
    for(i = 0;i < n-1;++i){
        ll x,y;
        cin >> x >> y;
        --x;    --y;
        graph.at(x).push_back(y);
        graph.at(y).push_back(x);
    }
    ll ans = dfs(0,1e9,0) + dfs(0,1e9,1);
    cout << ans%MOD << endl;

    return 0;
}

Measured memory_bytes: 19584
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    boolean[] isP = new boolean[55556];
    for(int i = 2; i <= 55555; i++) {
      isP[i] = true;
    }
    for(int i = 2; i <= 55555; i++) {
      if(isP[i]) {
        for(int j = (2 * i); j <= 55555; j += i) {
          isP[j] = false;
        }
      }
    }
    ArrayList<Integer> list1 = new ArrayList<Integer>();
    ArrayList<Integer> list2 = new ArrayList<Integer>();
    ArrayList<Integer> list3 = new ArrayList<Integer>();
    ArrayList<Integer> list4 = new ArrayList<Integer>();
    for(int i = 2; i <= 55555; i++) {
      if(isP[i]) {
        if((i % 5) == 1) list1.add(i);
        if((i % 5) == 2) list2.add(i);
        if((i % 5) == 3) list3.add(i);
        if((i % 5) == 4) list4.add(i);
      }
    }
    ArrayList<Integer> ans = new ArrayList<Integer>();
    if(list1.size() >= n) {
      for(int i = 0; i < n; i++) { 
        ans.add(list1.get(i));
      }
    } else if(list2.size() >= n) {
      for(int i = 0; i < n; i++) { 
        ans.add(list2.get(i));
      }
    } else if(list3.size() >= n) {
      for(int i = 0; i < n; i++) { 
        ans.add(list3.get(i));
      }
    } else {
      for(int i = 0; i < n; i++) { 
        ans.add(list4.get(i));
      }
    }
    for(int i = 0; i < n; i++) { 
      System.out.println(ans.get(i));
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    int ans=0;
    for(int i=a; i<=b; i++){
        string s1 = to_string(i);
        string s2 = s1;
        reverse(s1.begin(), s1.end());
        if(s1==s2){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
W, H, N = map(int, input().split())
x_min = 0
x_max = W
y_min = 0
y_max = H
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1 and x > x_min:
        x_min = x
    elif a == 2 and x < x_max:
        x_max = x
    elif a == 3 and y > y_min:
        y_min = y
    elif a == 4 and y < y_max:
        y_max = y

x_l = x_max - x_min
y_l = y_max - y_min

if x_l > 0 and y_l > 0:
    S = (x_max - x_min) * (y_max - y_min)
else:
    S = 0
print(S)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	array<int,200000>ar;
	int i,j;
	int MAX;
	int MIN;
	cin>>n;
	for(i=0;i<n;i++)	cin>>ar[i];
	MAX=INT_MIN;
	MIN=ar[0];
	for(i=1;i<n;i++)	MAX=max(MAX,ar[i]-MIN),MIN=min(MIN,ar[i]);
	
	cout<<MAX<<endl;
	return 0;
}


Measured memory_bytes: 3868
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int n;
vector<pair<ll,int> > a;

ll calc(ll x) {return x*x*x*x*x;}

void init()
{
    rep(i,1,n)
    {
        if ((i>1) && (calc(i)-calc(i-1)>n)) break;
        a.pb(mkp(calc(i),i));
    }
    rep(i,1,n)
    {
        if ((i>1) && (calc(-i+1)-calc(-i)>n)) break;
        a.pb(mkp(calc(-i),-i));
    }
    a.pb(mkp(0,0));
}

int main()
{
    n=read();
    init();
    int len=a.size();
    rep(i,0,len-1) rep(j,0,len-1)
    {
        if (a[i].fir-a[j].fir==n)
        {
            cout << a[i].sec << " " << a[j].sec << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	ll g=1;
	for(ll i=1;i<n;i++){
		if(s[i-1]!=s[i]){
			g++;
		}
//		cout <<g;
	}
	ll ans=n-g;
	ll no=min(k,(g-1)/2);
	ans+=no*2;
	k-=no;
	g-=no*2;
	if(k>=1&&g>=2){
		ans++;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

const int MAXN = 100005;

int N;
int a[MAXN], b[MAXN];
map <int, int> cnt;
map <int, int> dad, rnk;
set <int> S;
int sol;

void load() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
		scanf("%d", a + i);
	for (int i = 0; i < N; i++)
		scanf("%d", b + i);
}

int find(int x) {
	return dad[x] == x ? x : dad[x] = find(dad[x]);
}

void join(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)
		return;
	if (rnk[x] > rnk[y])
		swap(x, y);
	dad[x] = y;
	rnk[y] += rnk[x] == rnk[y];
	sol--;
}

int solve() {
	for (int i = 0; i < N; i++) {
		a[N] ^= a[i];
		b[N] ^= b[i];
	}
	
	for (int i = 0; i <= N; i++) {
		dad[a[i]] = a[i];
		dad[b[i]] = b[i];
		if (a[i] != b[i] || i == N) {
			S.insert(a[i]);
			S.insert(b[i]);
		}
	}
	
	if (S.empty())
		return 0;
	
	for (int i = 0; i <= N; i++) {
		cnt[a[i]]++;
		cnt[b[i]]--;
	}
	
	for (auto it : cnt)
		if (it.second)
			return -1;
	
	sol += (int)S.size() - 1;
	for (int i = 0; i < N; i++)
		if (a[i] != b[i]) {
			join(a[i], b[i]);
			sol++;
		}
		
	return sol;
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 19712
def factorize(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr

a, b = list(map(int, input().split()))
fa = set(factorize(a))
fb = set(factorize(b))
if a == 1 and b == 1:
    print(1)
else:
    print(len(fa & fb) + 1)


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9



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

    if(N < 1000) cout << "ABC" << endl;
    else cout << "ABD" << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    a,b,c = I2()
    for i in range(a,a*b+1,a):
        if i%b == c:
            print("YES")
            exit()
    print("NO")

Measured memory_bytes: 9176
import java.awt.*;
import java.awt.geom.*;
import java.io.*;

import java.util.*;
class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(a * b +" " + (a * 2 + b * 2));
	}
}

Measured memory_bytes: 17320
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<double> As(N);
    for (int i = 0; i < N; ++i) cin >> As[i];
    double sum = 0.0;
    for (const auto A : As) {
        sum += 1.0 / A;
    }
    cout << 1.0 / sum << endl;
}


Measured memory_bytes: 256
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int a, b;
  cin >> a >> b;
  for (int i = 0; i <= a; i++) {
    int k = i * 2 + (a - i) * 4;
    if (k == b) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,ans = 0;
	string s;
	char prev = '!';
	cin >> n >> s;
	for(int i = 0;i < n;i++){
		if(s[i] != prev) ans++;
		prev = s[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
n = int(input())
#n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]

if n == 1:
    print(a[0])
    exit()

up = True
ans = 0
for i in range(n-1):
    if a[i] <= a[i+1]:
        if up == False:
            ans -= a[i]
        up = True
    else:
        if up == True:
            ans += a[i]
        up = False

if a[-2] <= a[-1]:
    ans += a[-1]

print(ans)


Measured memory_bytes: 38384
import java.util.*;
import java.math.*;
import java.io.*;
import java.text.*;

class Main {
    static class Node implements Comparable<Node>{
        int id;
        int p;
        int t;
        public Node(int id,int p,int t){
            this.p=p;
            this.t=t;
            this.id=id;
        }
        public int compareTo(Node c){
            return this.p-c.p;
        }
    }
    //public static PrintWriter pw;
    public static PrintWriter pw = new PrintWriter(System.out);

    public static void solve() throws IOException {
//	pw=new PrintWriter(new FileWriter("C:\\Users\\shree\\Downloads\\small_output_in"));
        FastReader sc = new FastReader();
        int n=sc.I();
        int ans=0;
        for(int i=1;i<=n;i++){
            int l=sc.I(); int r=sc.I();
            ans=ans+Math.abs(l-r)+1;
        }
        pw.println(ans);
        pw.close();

    }


    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                try {

                    solve();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, "1", 1 << 26).start();

    }

    static BufferedReader br;
    static long M = (long) 1e9 + 7;

    static class FastReader {

        StringTokenizer st;

        public FastReader() throws FileNotFoundException {
            //br=new BufferedReader(new FileReader("C:\\Users\\shree\\Downloads\\B-small-practice.in"));
            br = new BufferedReader(new InputStreamReader(System.in));

        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int I() {
            return Integer.parseInt(next());
        }

        long L() {
            return Long.parseLong(next());
        }

        double D() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public boolean hasNext() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return false;
                }
                st = new StringTokenizer(s);
            }
            return true;
        }

    }
}

Measured memory_bytes: 23764
n = int(input())
a=[0]*n
b=list(map(int,input().split()))
a[n-1]=b[n-2]
for i in reversed(range(n-1)):
    if i!=0:
        if b[i]>=b[i-1]:
            a[i]=b[i-1]
        else:
            a[i]=b[i]
    else:
        a[i]=b[i]
        
ans=sum(a)
print(ans)

Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [n, k] <- getIntList
  ps <- getIntVec n
  cs <- getIntVec n

  d <- VM.new n
  VM.set d (0::Int)

  let getSeq :: Int -> [Int] -> IO [Int]
      getSeq i xs = do
        let j = ps V.! i - 1
        t <- VM.read d j
        if t == 1
          then return $ reverse xs
          else do VM.write d j 1
                  let c = cs V.! j
                  getSeq j (c:xs)

      maxSubSum len ss = let t = V.fromList ss
                             siz = V.length t
                             ss' = t V.++ t
                             loop i j s res
                               | i >= siz = res
                               | j >= len = loop (i+1) 0 0 res
                               | otherwise =
                                   let s' = s + ss' V.! (i + j)
                                       res' = max res s'
                                   in loop i (j+1) s' res'
                         in loop 0 0 0 (-inf)

      solve1 :: Int -> IO Int
      solve1 i = do
        xs <- getSeq i []
        if null xs
          then return (-inf)
          else do
          let tot = sum xs
              len = length xs
              q = k `div` len
              r = k `mod` len

              ans | tot > 0 = let x1 = q * tot + maxSubSum r xs
                                  x2 = (q-1) * tot + maxSubSum len xs
                              in max x1 x2
                  | otherwise = maxSubSum (min len k) xs
          return ans

      solve :: Int -> Int -> IO Int
      solve i res | i >= n = return res
                  | otherwise = do r <- solve1 i
                                   let res' = max res r
                                   solve (i+1) res'

  ans <- solve 0 (-inf)
  print ans


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

int main() {
	int N;
	cin >> N;
	vector<int> p(N);
	rep(i, N) cin >> p[i];
	vector<int> q(N);
	q = p;
	sort(q.begin(), q.end());
	int cnt = 0;
	rep(i, N){
		if (p[i] != q[i]) cnt++;
	}
	string ans;
	if (cnt == 2 || cnt == 0) ans = "YES";
	else ans = "NO";
	cout << ans << endl;
	return 0;
}


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

using namespace std;

long long h,c,t;
long long f(long long mid){
  return mid*(h+c-2*t) +h -t;
}
void solve()
{
  char name[23];
  cin >> name;
  cout << name[0]<<name[1]<<name[2]<<endl;
}
int main()
{
  int t;
  t =1;
  while(t--)
  {
    solve();
  }
}


Measured memory_bytes: 3592