akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=10005,INF=1<<29;
typedef vector<vector<int>> mat;
vector<int> dh={0,1,0,-1},dw={1,0,-1,0};
int H,W;

int BFS(mat &q){
    queue<pair<int,mat>> Q;
    Q.push({0,q});
    int ans=-1;
    
    while(!Q.empty()){
        int d=Q.front().first;
        mat S=Q.front().second;
        Q.pop();
        //if(d>=10) continue;
        
        int sh=-1,sw=-1;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(S[i][j]==2){
                    sh=i;
                    sw=j;
                }
            }
        }
        
        for(int k=0;k<4;k++){
            int h=sh+dh[k],w=sw+dw[k];
            
            if(h<0||h>=H||w<0||w>=W) continue;
            if(S[h][w]==1) continue;
            
            while(!(h<0||h>=H||w<0||w>=W)&&S[h][w]==0){
                h+=dh[k];
                w+=dw[k];
            }
            
            if(h<0||h>=H||w<0||w>=W) continue;
            
            if(S[h][w]==1){
                S[h][w]=0;
                S[h-dh[k]][w-dw[k]]=2;
                S[sh][sw]=0;
                
                if(d+1<=9) Q.push({d+1,S});
                
                S[h][w]=1;
                S[h-dh[k]][w-dw[k]]=0;
                S[sh][sw]=2;
            }else{
                ans=d+1;
                break;
            }
        }
        
        if(ans!=-1) break;
    }
    
    return ans;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        cin>>W>>H;
        if(H+W==0) break;
        mat S(H,vector<int>(W));
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cin>>S[i][j];
            }
        }
        
        cout<<BFS(S)<<endl;
        
    }
}




Measured memory_bytes: 65108
/// time is tough.....so don't stop ...keep learning ...keep growing :)

#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double ld ;
const int N = 1e5+5 ;
const int K = 50 ;
const ll mod =  1e9+7 ;
#define pb push_back
#define ft first 
#define sd second 
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll poww(ll a,ll b){ll res=1;while(b){if(b&1){res*=a;}a=a*a;b>>=1;}return res;}
ll poww(ll a,ll b,ll mod){ll res=1;while(b){if(b&1){res*=a;res%=mod;}a=a*a;a%=mod;b>>=1;}return res;}
const int INF = 2e9 ;
int n, m, u, v, k;
int dp[2][N];// pre[105][N];
int a[105];
int f(int turn, int k){
    if(k < a[1]){
        return dp[turn][k] = turn ^ 1;
    }
    int &res = dp[turn][k];
    if(~res) return res;
    int temp = -1;
    for(int i=1;i<=n;i++){
        if(k >= a[i]){
            temp = f(turn ^1, k - a[i]);
            if(temp == turn) {
                res = turn ;
                return res;
            }
        }
    }
    return res = turn ^ 1;
}
int main(){
    cin >> n >> k;
    for(int i=1;i<=n;i++) {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    memset(dp, -1, sizeof dp);
    cout << (f(0, k)?"Second\n":"First\n");
    return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<stdio.h>
#include<vector>

using namespace std;
int main() {
	int n, q;
	scanf("%d %d", &n, &q);
	
	vector <int> a;
	//初期値の設定
	for (int i = 0; i < n+1; i++) {
		a.push_back(0);
	}

	int com, x, y;
	for (int i = 0; i < q; i++) {
		scanf("%d %d %d",&com, &x, &y);

		if (com == 0) {
			a[x] += y;
		}
		else {

			int sum = 0;
			int j = x;
			while (1) {
				sum += a[j];				
				
				if (j == y)break;
				j++;
			}
			printf("%d\n", sum);
		}
	}return 0;
}


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

int main(){
//  青＞緑＞赤
  string s("No");
  int r,g,b;
  int k;

  cin >> r >> g >> b;
  cin >> k;
  
  do{
    for(;r>=g;--k){
      g=g*2;    
    }
    for(;g>=b;--k){
      b=b*2;
    }
  }
  while(0);
  if(k>=0)s="Yes";
  cout << s <<endl;
  return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<deque>
using namespace std;
using ulli = unsigned long long int;

ulli result[3]={0,0,0};

void make_lunlun(ulli n){
  int m;
  
  m = (int) n % 10;
  
  if(m-1>=0){
    result[0] = n * 10 + (m-1);
  }else{
    result[0] = 0;
  }

  result[1] = n * 10 + m;

  if(m+1<=9){
    result[2] = n * 10 + (m+1);
  }else{
    result[2] = 0;
  }
  
}



int main(){
  deque<ulli> Q{1,2,3,4,5,6,7,8,9};
  int K,count=0,i;
  ulli made[3];
  ulli next;
  cin >> K;
  
  while(count != K){
    count ++;
    next = Q.front();
    Q.pop_front();
    make_lunlun(next);
    for(i=0;i<3;i++){
      if(result[i] != 0){
	Q.push_back(result[i]);
      }
    }
    //cout << next << endl;
  }
  cout << next << endl;
  return 0;
}
  


Measured memory_bytes: 1664
def divisor(num)
    num_sqrt = Math.sqrt(num).floor
    (1..num_sqrt).select{ |i| num % i == 0 }
end

num = gets.to_i

divisions = divisor(num)

distance_lists = []

for d in divisions do
  width_count = (d - 1)
  vertical_count = ((num / d) - 1)
  distance_lists << (width_count + vertical_count)
end

ans = distance_lists.min 
puts(ans)


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

using namespace std;

int main(void) {
	string s, t, u;
	cin >> s >> t >> u;
	s[0] -= 32;
	t[0] -= 32;
	u[0] -= 32;
	cout << s[0] << t[0] << u[0] << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int K = int.Parse(Console.ReadLine());
        int res = 1;

        for (int i = 0; i < N;i++)
        {
            if(res < K)
            {
                res *= 2;
            }
            else
            {
                res += K;
            }
        }

        Console.WriteLine(res);
    }
}

Measured memory_bytes: 11092
n, T = map(int, input().split())
c, t = [], []

for i in range(n):
    a, b = map(int, input().split())
    c.append(a)
    t.append(b)
#%%
# n, T = 3, 70
# c = list([0,0,0])
# t = list([0,0,0])
# c[0], t[0] =  7, 60
# c[1], t[1] = 1, 80
# c[2], t[2] = 4, 50


#%%
costs = []
min_time  = T
for i in range(n):
    if t[i] <= T:
        costs.append(c[i])

if costs == []:
    print("TLE")
else:
    print(min(costs))   

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

int main() {
  int n;
  cin >> n;
  if (25 - n == 0) {
    cout << "Christmas" << endl;
  }
  else {
    cout << "Christmas";
    for (int i = 0; i < 25 - n; i++) {
      cout << " " << "Eve";
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1000000007;
const int nmax=100005;
vector<vector<int>> g(nmax);
vector<bool> vis(nmax);
int k;
ll dfs(int s){
  ll res=k;
  stack<int> st;
  st.push(s);
  vis[s]=true;
  while(!st.empty()){
    int p=st.top();
    st.pop();
    int cnt=0;
    for(auto x:g[p]){
      if(!vis[x]){
        if(p==s){
          res*=(k-1-cnt);
        }
        else{
          res*=(k-2-cnt);
        }
        res%=mod;
        vis[x]=true;
        cnt++;
        st.push(x);
      }
    }
  }
  return res;
}
int main(){
  int n;cin >> n >> k;
  for(int i=0;i<n-1;i++){
    int a,b;cin >> a >> b;
    a--,b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  cout << dfs(0) << endl;
}

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

long long max = 1e12;
long long max_sqrt = 1e6;

int main(){
    long long N;
    std::cin >> N;
    
    std::vector< int > Pn;
    std::vector< bool > Pn_list(max_sqrt + 1, true);
    for(int i=2; i<max_sqrt + 1; i++){
        if(Pn_list[i]){
            Pn.push_back(i);
            for(int j=i+i; j<max_sqrt + 1; j+=i){
                Pn_list[j] = false;
            }
        }
    }
    
    std::map< int, int > Pn_cnt;
    for(int j=0; j<Pn.size(); j++){
        int cnt = 0;
        while(N % Pn[j] == 0){
            cnt++;
            N /= Pn[j];
        }
        if(cnt){
            Pn_cnt[Pn[j]] = cnt;
        }
    }
    if(N != 1){
        Pn_cnt[N] = 1;
    }
    
    long long cnt = 0;
    for(auto itr = Pn_cnt.begin(); itr != Pn_cnt.end(); ++itr) {
        long long cnt_tmp = 1;
        while(itr->second >= cnt_tmp){
            cnt++;
            itr->second -= cnt_tmp;
            cnt_tmp++;
        }
    }
    
    std::cout << cnt << std::endl;
    
    return 0;
}



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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<int >;
using P = pair<int,int>;

int main()
{
    int a,b;cin >>a>>b;
    int sum=a+b;
    if(sum>=10)puts("error");
    else cout <<sum<< endl;
    return 0;
}


Measured memory_bytes: 256
alpha=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
word=input()
T=True
for i in alpha:
  if word.count(i)%2==1:
    T=False
    break
if T==True:
  print("Yes")
else:
  print("No")
       
       

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int N, D;

    cin >> D >> N;
    if (N <= 99) {
        cout  << N  * pow(100, D) << endl;
    } else {
        cout << 101 * (int)pow(100, D) << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

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

        int X = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        if(A>=B){
            System.out.println("delicious");
        }
        else if(A<B && A+X>=B){
            System.out.println("safe");
        }
        else{
            System.out.println("dangerous");
        }
    }
}

Measured memory_bytes: 21844
import java.util.*;

import static java.lang.System.*;

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

        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        int[] rate = new int[]{400, 800, 1200, 1600, 2000, 2400, 2800, 3200};
        boolean[] exist = new boolean[8];
        int master = 0; //3200以上の人数

        for (int i = 0; i < N; i++) {
            if (a[i] >= 3200) {
                master++;
                continue;
            }

            for (int j = 0; j < rate.length; j++) {
                if (a[i] < rate[j]) {
                    exist[j] = true;
                    break;
                }
            }
        }

        int min = 0;
        for (int i = 0; i < exist.length; i++) {
            if (exist[i]) {
                min++;
            }
        }
        int max = min + master;

        if (min == 0) { //全員master
            min = 1;
        }

        out.print(min + " " + max);
    }
}

Measured memory_bytes: 23124
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Debug = System.Diagnostics.Debug;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        memo[1] = new int[][] { new int[] { 1 } };
        int n = int.Parse(Console.ReadLine());
        Console.Write(string.Join("\n", Solve(n).Select((x, y) => string.Join(" ", x.Skip(y + 1)))));
    }

    static int[][][] memo = new int[501][][];

    static int[][] Solve(int n)
    {
        if (memo[n] != null) return memo[n];
        if (n % 2 == 1) return memo[n] = Solve(n + 1).Take(n).Select(x => x.Take(n).ToArray()).ToArray();
        int[][] res = Enumerable.Repeat(0, n).Select(_ => new int[n]).ToArray();
        for (int i = 0; i < n; i++)
        {
            for (int j = i + 1; j < n; j += 2)
            {
                res[i][j] = 1;
                res[j][i] = 1;
            }
        }
        var inner = Solve(n / 2);
        for (int i = 0; i < n / 2; i++)
        {
            for (int j = 0; j < n / 2; j++)
            {
                res[i * 2][j * 2] = inner[i][j] + 1;
                res[i * 2 + 1][j * 2 + 1] = inner[i][j] + 1;
            }
        }
        return memo[n] = res;
    }
}


Measured memory_bytes: 20444
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
int a[50005],b[50005],c[50005]; 
int main()
{
	ll n,a,b;cin>>n>>a>>b;
	ll sum=0,ans=0;
	sum=(n/(a+b))*a;
	n%=(a+b);
	if(n>a)
	n=a;
	sum+=n;
	cout<<sum<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        long a=sc.nextLong();
        double x=100;
        for (int i = 0; i < 10000; i++) {
        	if(a<=x)ret(i);
			x=(long)(x*101/100);
		}
        out.println();
     	out.flush();
    }

    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,c;long s;
//	P(int  x, int c, long s) {
//	  this.x=x;
//	  this.c=c;
//	  this.s=s;
//	}
//}


class P implements Comparable<P>{
	int x,c;long s;
	P(int  x, int c, long s) {
	  this.x=x;
	  this.c=c;
	  this.s=s;
	}

    public int compareTo(P p){
        return Long.signum(s-p.s);
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 33128
int main () {
  
    int i,j,l,c=0,num,min,arr[100];

    scanf("%d",&l);

    for(i=0;i<l;i++){
      scanf("%d",&arr[i]);
    }
  
    
    for(i=0;i<l;i++){
      min = i;
      for(j=i;j<l;j++){
        if(arr[j] < arr[min]){
          min = j;
        }
      }
      if(arr[i] > arr[min])
        c++;
      num = arr[i];
      arr[i] = arr[min];
      arr[min] = num;
    }

    for(i=0 ; i<l ; i++){
      if(i==l-1)
        printf("%d",arr[i]);
      else
        printf("%d ",arr[i]);
    }
      printf("\n%d\n",c);
         
  return 0;
  }

Measured memory_bytes: 600
#!/usr/bin/env python3

a = input()

l = ["A","T","G","C"]
count  = 0
max = 0
t = 0
for i in range(len(a)):
    for j in range(i,len(a)):
        if(a[j] not in l):
            count = 0
            break;
        else:
            count += 1
            if(max < count):
                max = count
    count = 0
print(max)


Measured memory_bytes: 3060
#include <iostream>
#include <array>
#include <algorithm>
 
using namespace std;
 
int main()
{
array<int, 3> a;
 
cin >>a[0] >>a[1] >>a[2];

sort(a.begin(), a.end());

cout <<a[0] <<" " <<a[1] <<" " <<a[2] <<endl;
 
return 0;
}

Measured memory_bytes: 3116
#include<iostream>
using namespace std;
#include<vector>
#include<map>
#include<algorithm>
#define int long long int
int32_t main()
{
     int n;
     cin>>n;
     int m;
     cin>>m;
     vector<int> v1(n);
     int j;
     for(j=0;j<n;j++)
         cin>>v1[j];
     multimap<int,int> mp;
     for(j=0;j<m;j++)
     {
		 int x,y;
		 cin>>x>>y;
		 mp.insert({y,x});
	 } 
	 mp.insert({n,0});
	 vector<int> v2;
	 int p=n;
	 auto it=mp.end();
	 it--;
	 while(p!=0)
	 {
		 while(it->second!=0&&p!=0)
		 {
			 v2.push_back(it->first);
			 it->second--;
			 p--;
		 }
		 if(it->second==0)
		 {
			 if(it==mp.begin())
			    break;
			 it--;
		 }
	 }
	 while(p!=0)
	 {
		 v2.push_back(0);
		 p--;
	 }
	 sort(v2.begin(),v2.end());
	 reverse(v2.begin(),v2.end());
	 sort(v1.begin(),v1.end());
	 int answer=0;
	 for(j=0;j<n;j++)
	 {
		 answer+=(max(v2[j],v1[j]));
	 }
	 cout<<answer<<endl;
}


Measured memory_bytes: 8444
//09-1 ??????????????????
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
using namespace std;
int main(){
    for(int i=0; i<3; i++){
        int h1,m1,s1;
        cin >> h1 >> m1 >> s1;
        int time1 = h1*60*60 + m1*60 + s1;
        int h2,m2,s2;
        cin >> h2 >> m2 >> s2;
        int time2 = h2*60*60 + m2*60 + s2;
        
        int ans = time2 - time1;
        int h3 = 0;
        int m3 = 0;
        int s3 = 0;
        
        bool change = true;
        while(change){
            change = false;
            if(ans>=3600){
                ans -= 3600;
                h3++;
                change = true;
            }
        }
        change = true;
        while(change){
            change = false;
            if(ans>=60){
                ans -= 60;
                m3++;
                change = true;
            }
        }
        s3 = ans;

        //cout << h3 << " " << m3 << " " < << s3 << endl;
        cout << h3;
        cout << " ";
        cout << m3;
        cout << " ";
        cout << s3 << endl;;
    }
    return 0;
}


Measured memory_bytes: 3096
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}
static const ll INF = 1e18;

int main() {
  int n, m; cin >> n >> m;
  ll k; cin >> k;
  vector<ll> a(n+1, 0), b(m+1);
  rep(i, n) {
    ll x; cin >> x;
    a[i+1] = a[i] + x;
  }
  rep(i, m) {
    ll x; cin >> x;
    b[i+1] = b[i] + x;
  }

  ll best = m, ans = 0;
  rep(i, n+1) {
    if(k < a[i]) break;
    while(a[i] + b[best] > k){
      --best;
    }
    chmax(ans, i + best);
  }

  cout << ans << endl;
}


Measured memory_bytes: 6420
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using namespace std;
const int maxn=1e6+3;
const int M=998244353;
typedef long long ll;
typedef pair<int,int> pi;
void add(int &x,int y){x+=y;if(x>=M)x-=M;}
void sub(int &x,int y){x-=y;if(x<0) x+=M;}
int n,c[100][100];
ll ans;
int main(){
    scanf("%d",&n);
    for (int i=1;i<=n;i++){
        double x; scanf("%lf",&x);
        ll y=(long long)(x*1000000000+0.5);
        int p2=0,p5=0;
        while (y%2==0) p2++,y/=2;
        while (y%5==0) p5++,y/=5;
        p2=min(p2,18); p5=min(p5,18);
        for (int j=18-p2;j<=18;j++)
            for (int k=18-p5;k<=18;k++)
                ans+=c[j][k];
        c[p2][p5]++;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3832
import sys
input = lambda: sys.stdin.readline().rstrip()

h, w = map(int, input().split())
field = [None] * h
for i in range(h):
    field[i] = list(map(lambda x: int(x) % 2, input().split()))

outs = []

for i in range(h-1):
    for j in range(w):
        if not field[i][j]: continue
        field[i+1][j] = int(field[i+1][j] ^ 1)
        outs.append((i+1, j+1, i+2, j+1))

for i in range(w-1):
    if not field[h-1][i]: continue
    field[h-1][i+1] = int(field[h-1][i+1] ^ 1)
    outs.append((h, i+1, h, i+2))

print(len(outs))
for x in outs: print(*x)


Measured memory_bytes: 26672
#define _CRT_SECURE_NO_WARNINGS

#pragma GCC optimize("O3")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cstring>
#include <numeric>
#include <set>
#include <queue>
#include <deque>
#include <array>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <map>
#include <functional>
#include <bitset>
#include <complex>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using ld = long double;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int h, a;
	cin >> h >> a;
	cout << (h + a - 1) / a;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,y;
int main() {
  cin >> n >> y;
  y /= 1000;
  bool f = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      if (i + j > n) continue;
      int k = n - i - j;
      if (10 * i + 5 * j + k == y) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

/*　【提出前に確認すること】
・コンパイルできるか
・テストケース試したか
・オーバーフローあるか
*/

Measured memory_bytes: 256
n = int(input())
s_rec = []
t_rec = []
for sub_n in range(n):
    s, t = input().split()
    s_rec.append(s)
    t_rec.append(int(t))
x = input()
for i in range(n):
    if x == s_rec[i]:
        print(sum(t_rec[i+1:]))
        break

Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,mini=0,cnt=0; string s; cin>>n>>s;
    rep(i,s.size()){
        if(s[i]=='('){
            cnt++;
        }
        else{
            cnt--; mini=min(mini,cnt);
        }
    }
    for(int i=mini;i<0;i++) cout<<'(';
    rep(i,s.size()) cout<<s[i];
    for(int i=cnt-mini;i>0;i--) cout<<')';
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define ll long long
#define pb push_back
#define PII pair<int,int>
#define X first
#define Y second
#define MP make_pair
#define PI acos(-1.0)
#define eps 1e-8
const int maxn=5e4+10;
const int maxm=1.5e7+10;
const int mod=998244353;
using namespace std;
 



int main()
{
    int a,b,c;
    scanf("%d",&a);
    int ans=0;
    for(int i=1;i<=a;i++)
        for(int j=1;j<=a;j++)
            for(int k=1;k<=a;k++)
                ans+=__gcd(i,__gcd(j,k));
    printf("%d",ans);
    // system("pause");
    return 0;
}

Measured memory_bytes: 3828
#include <stdio.h>

int main()
{

int a[10000], min, max, n, i;
long long sum = 0;
scanf("%d", &n);//1以上が入力されるものとします
for(i = 0; i < n; i++){
scanf("%d", &a[i]);
sum += a[i];
}
max = min = a[0];//とりあえず最初の要素をセットしておく
for(i = 1; i < n; i++){//2番目以降の要素と比較
if(a[i] > max)max = a[i];
if(a[i] < min)min = a[i];
}
printf("%d %d %lld\n", min, max, sum);

return 0;
}
    


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

int main(){
    int n;
    int ans=0;
    cin >> n;
    int count=0;
    int a[110];
    for(int i=0;i<n;i++){
        cin>>a[i];
        count++;
        if(count==2){
            if(a[i] == a[i-1]){
                ans++;
                count--;
            }
            count--;
            
        }
    }
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
long int N,k=0,i;
scanf("%ld",&N);
for(i=1 ; i <= N && i <= 9; i++)
k++;

for(i=100 ; i <= N && i <= 999;i++)
k++;

for(i=10000 ; i <= N && i <= 99999;i++)
k++;

printf("%ld\n",k);
return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))

INF = float('inf')
dp = [[-INF]*2 for _ in range(N+1)]
dp[0][0] = 0
for i,a in enumerate(A):
    dp[i+1][0] = max(dp[i+1][0], dp[i][0]+a, dp[i][1]-a)
    dp[i+1][1] = max(dp[i+1][1], dp[i][0]-a, dp[i][1]+a)
print(dp[-1][0])

Measured memory_bytes: 31460
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x;
    cin >> n >> x;
    int mn = 100000;
    REP(i,n){
        int m;
        cin >> m;
        x-=m;
        mn = min(mn,m);
    }
    cout << n + x/mn << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int ll
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    ll s, c; cin >> s >> c;
    ll ans = 0;
    if(s * 2 <= c) {
        ans += s;
        c -= 2 * s;
        ans += c / 4;
    } else {
        ans += c / 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
count = 0

B = [0]*100001

for i in range (0, N):
	if A[i] <= 100000:
		B[A[i]]+=1
	else:
		count+=1

for i in range (1, 100001):
	if B[i] < i:
		count+=B[i]
	if B[i] > i:
		count+=(B[i]-i)

print(count)

Measured memory_bytes: 20672
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
int N, a[2001], G[2001][2001], q[2002], ue[2002], ref[2002], v[2001], L, d[2001];
std::vector < int > E[2001];
int gcd(int a, int b)
{
	int r;
	while (b)
	{
		r = a % b;
		a = b;
		b = r;
	}
	return a;
}
int main()
{
	scanf("%d", &N);
	for (int i = 1; i <= N; i++)
		scanf("%d", a + i);
	std::sort(a + 1, a + N + 1);
	for (int i = 1; i < N; i++)
		for (int j = i + 1; j <= N; j++)
			if (gcd(a[i], a[j]) != 1)
				G[i][j] = G[j][i] = 1;
	for (int i = 1; i <= N; i++)
		G[0][i] = G[i][0] = 1;
	int D = 1;
	q[1] = 0;
	ue[1] = 0;
	v[0] = 1;
	ref[L = 1] = 0;
	while (D)
	{
		while (ue[D] <= N && (!G[q[D]][ue[D]] || v[ue[D]]))
			ue[D]++;
		if (ue[D] <= N)
		{
			int To = ue[D]++;
			E[q[D]].push_back(To);
			d[To]++;
			q[++D] = To;
			ue[D] = 0;
			v[ref[++L] = To] = 1;
		}
		else
			D--;
	}
	std::vector < int > O;
	std::set < int > S;
	for (int i = 0; i <= N; i++)
		if (!d[i])
			S.insert(i);
	while (!S.empty())
	{
		auto it = S.end();
		int u = *--it;
		S.erase(it);
		O.push_back(u);
		for (int v : E[u])
			if (!--d[v])
				S.insert(v);
	}
	for (int i : O)
		if (i)
			printf("%d ", a[i]);
	puts("");
	return 0;
}


Measured memory_bytes: 16128
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int L = sc.nextInt();
        int R = sc.nextInt();
        R = Math.min(R,L+2019);
        long ans = Long.MAX_VALUE;
        for(int i = L; i <= R; i++){
            for(int j = i+1; j <= R; j++){
                long ii = i%2019;
                long jj = j%2019;
                ans = Math.min(ans,(ii*jj)%2019L);
            }
        }
        System.out.println(ans);
    }
    
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	long long n;
	cin>>n;
	string s="";
	//cout<<n<<endl;
	char xx;
	//bool val=false;
	/*if(n%26==0){
		while(n>0){
			int x = n%26;
		     s ='z'+s;
		     n/=26;

		}
		cout<<s.substr(1,s.size())<<endl;
		return 0;
	}
	   int y = n%26; 
	if(y>=0&&y<=26){
		int x2 = n/26;
	   while(x2>0){
	  s = 'z'+s;
	  	x2/=26;
	}
	cout<<s.substr(1,s.size())<<endl;
	return 0;
}    */
	while(n>0){
		int x = n%26;
		//cout<<x<<endl;
		//  xc = x;
		 if(x==0){
           s ='z'+s;
		   n=n/26-1;
		   continue;
		 }else{
		 xx= 96+x;
          s =xx+s;
      }
          n/=26;
	}
	
	cout<<s<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N,Q;
int a[200010];
int front[200010];
int cover[200010];
int covered;
 
void add(int x){
	int n = front[x]-1;
	if(n>0){
		if(cover[n]==0) covered++;
		cover[n]++;
	}
	front[x]--;
}
void erase(int x){
	int n = front[x];
	if(n>0){
		cover[n]--;
		if(cover[n]==0) covered--;
	}
	front[x]++;
}
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	cin>>N>>Q;
	rep1(i,N) front[i] = i+1;
	rep(i,N){
		cin>>a[i];
		add(a[i]);
	}
	rep(t,Q){
		int x,v;
		cin>>x>>v;
		x--;
		int pv = a[x];
		erase(pv);
		add(v);
		a[x] = v;
		cout<<N-covered<<endl;
	}
}

Measured memory_bytes: 3840
/*Author: Gautam*/
 
 
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define MOD 1000000007
#define ull unsigned long long int
#define newline cout<<endl
 
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<int,int>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
void solve()
{
    int a,b;
    cin>>a>>b;
    int ans=a-(2*b);
    if(ans<0)ans=0;
    cout<<ans<<endl;
}
int main()
{
 
    FastIO;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 256
import sys 

temp=input().split(" ")
n=int(temp[0])
k=int(temp[1])
count=0
for b in range(k+1,n+1):
    temp=int(n/b)
    count+=temp*(b-k)

    temp=n%b
    if (temp-k+1)>0:
        count+=(temp-k+1)
if k==0:
    count-=n


print(count)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;
//stoi(s) : string→int stoll(s) :string→longlong
int n,k;
vector<char> D;
vector<char> P;

bool judge(string x,vector<char> v){
    bool ok = true;
    int n = x.size();
    for(int i=0;i<n;i++){
        for(auto m:v){
            if(x[i] == m) return false;
        }
    }
    return true;
}

int main(){
    cin >> n;
    cin >> k;
    for(int i=0;i<k;i++){
        char d;
        cin >> d;
        D.push_back(d);
    }
    for(int i=1;i<100000;i++){
        if(i>=n){
            string j = to_string(i);
            if(judge(j,D)) {
                cout << j << endl;
                return 0;
            }
        }
    }


}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {

	public void how() {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();

		int b = sc.nextInt();

		int c = sc.nextInt();

		int z = 0;

		for(int I = a ; I <= b ; I++) {

			int x = c % I;

			if(x == 0) {

				z++;
 
			}

		}

		System.out.println(z);

	}

	public static void main(String[] args) {

		new Main().how();

	}

}

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

int n,m;
int t[22][22];

int main(void){
	memset(t,-1,sizeof(t));
	cin>>n>>m;
	for(int i=0;i<m;i++){
		char ch;
		int a,b,c,d;
		cin>>a>>ch>>b>>ch>>c>>ch>>d;
		a--;
		b--;
		t[a][b] = c;
		t[b][a] = d;
	}
	char ch;
	int s,d,x,y;
	cin>>s>>ch>>d>>ch>>x>>ch>>y;
	s--;
	d--;

	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i == j || t[i][k] == -1 || t[k][j] == -1){
					continue;
				}
				if(t[i][j] == -1 || t[i][j] > t[i][k] + t[k][j]){
					t[i][j] = t[i][k] + t[k][j];
				}
			}
		}
	}

	cout<<x - y - t[s][d] - t[d][s]<<endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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

	int N;
	cin >> N;
	VI T(N);
	VI A(N);
	REP(i, N) {
		cin >> T[i];
	}
	REP(i, N) {
		cin >> A[i];
	}
	
	VI mt(N);
	mt[0] = 1;
	int ma=T[0];
	if (ma > A[0]) {
		cout << 0 << endl;
		return 0;
	}

	FOR(i,1, N) {
		if (T[i - 1] != T[i]) {
			mt[i] = 1;
			ma = T[i];
			if (ma > A[i]) {
				cout << 0 << endl;
				return 0;
			}
		}
		else {
			mt[i] = ma;
		}
	}
	
	mt[N - 1] = 1;
	ma = A[N - 1];
	if (ma > T[N-1]) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = N - 2; i >= 0; i--) {
		if (A[i] != A[i + 1]) {
			mt[i] = 1;
			ma = A[i];
			if (ma > T[i]) {
				cout << 0 << endl;
				return 0;
			}
		}
		else {
			mt[i] = min(ma, mt[i]);
		}
	}
	
	int ans = 1;
	REP(i, N) {
		ans = ans*mt[i] % mod;
	}
	if (N == 2 || N == 1) {
		cout << 1 << endl;
		return 0;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 2560
n = int(input())
a = list(map(int,input().split()))

ones , twos, threes = 0,0,0

for i in a:
  if i ==1:
    ones+=1
  elif i ==2:
    twos+=1
  else:
    threes+=1

max_ones = ones+twos+threes
max_twos = twos+threes
max_threes = threes
# dp[n][n][n]
dp = [[[0.0]*(n+1) for i in range(n+1)] for j in range(n+1)]

for k in range(max_threes+1):
  for j in range(max_twos+1-k):
    for i in range(max_ones+1-j-k):
      if i+j+k==0:
        continue
      else:
        dp[i][j][k] = n/(i+j+k)
        if i>0:
          dp[i][j][k] += (dp[i-1][j][k]*i)/(i+j+k)
        if j>0:
          dp[i][j][k] += (dp[i+1][j-1][k]*j)/(i+j+k)
        if k>0:
          dp[i][j][k] += (dp[i][j+1][k-1]*k)/(i+j+k)
          
          
print(dp[i][j][k])
        
        
        


Measured memory_bytes: 256264
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    s = input()[:-1].decode()
    c1 = 0
    c2 = 0
    for i in range(n):
        if s[i] == '(':
            c1 += 1
        elif s[i] == ')':
            c1 -= 1
        if c1 < 0:
            c1 = 0
            c2 += 1
    print('(' * c2, s, ')' * c1, sep='')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}


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

    int n; cin >> n;
    vector<double> a(n);
    for(int i=0; i<n; ++i) cin >> a[i];

    double sita = 0;
    for(int i=0; i<n; ++i) sita += 1/a[i];

    printf("%.10lf\n", 1/sita);
    
    return 0;
}



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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    map<int, int> m1;
    map<int, int> m2;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (i % 2 == 0)
            m1[a]++;
        else
            m2[a]++;
    }
    pair<int, int> ma(0, 0);
    pair<int, int> ma1(0, 0);
    for (auto e : m1)
    {
        if (e.second >= ma.second)
        {
            ma1.first = ma.first;
            ma1.second = ma.second;
            ma.first = e.first;
            ma.second = e.second;
        }
        else if (e.second > ma1.second)
        {
            ma1.first = e.first;
            ma1.second = e.second;
        }
    }
    pair<int, int> rma(0, 0);
    pair<int, int> rma1(0, 0);
    for (auto e : m2)
    {
        if (e.second >= rma.second)
        {
            rma1.first = rma.first;
            rma1.second = rma.second;
            rma.first = e.first;
            rma.second = e.second;
        }
        else if (e.second > rma1.second)
        {
            rma1.first = e.first;
            rma1.second = e.second;
        }
    }
    if (ma.first != rma.first)
        cout << n - (ma.second + rma.second);
    else
        cout << min(n - (ma.second + rma1.second), n - (ma1.second + rma.second));
    return 0;
}

Measured memory_bytes: 4992
import collections
n = int(input())
a = list(map(int,input().split()))
lst = collections.defaultdict(int)
for i in a:
  lst[i] += 1
  lst[i-1] += 1
  lst[i+1] += 1
  
lst = sorted(lst.items(),reverse=True,key=lambda x:x[1])
print(lst[0][1])

Measured memory_bytes: 27876
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
//i64 mod = 1000000007;
i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;


int main(int argc, char **argv) {
    i64 a,v, b, w, t;
    cin >> a>>v>>b>>w>>t;

    i64 diff = abs(a-b);
    i64 diff_spd =v-w;

    if (diff_spd<=0) {
        cout <<"NO" << endl;
        return 0;
    }
    i64 time_to_cache = diff / diff_spd;
    if (diff%diff_spd != 0) ++time_to_cache;


    cout << ((time_to_cache<=t) ? "YES" : "NO")<<endl;

    return 0;
}


Measured memory_bytes: 3632
/*
ID: thanhvq1
LANG: C++14
PROB: namenum
*/

#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
//#define int long long
#define double long double
#define vec vector
#define vi vector<int>
#define vvi vector<vector<int>>
#define FZ(n) memset((n),0,sizeof())
#define FMO(n) memset((n),-1,sizeof(n))
#define unset unordered_set
#define ii pair<int, int>
#define vii vector<ii>
#define F first
#define S second
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)(x).size())
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first, l.second+r.second};
}
typedef void (*callback_function)(void); // type for conciseness
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
typedef long long ll;

void FILEIO() {  freopen("in.txt", "r", stdin);  freopen("out.txt", "w", stdout); }
//void FILEIO() {  freopen("namenum.in", "r", stdin);  freopen("namenum.out", "w", stdout); }
void input() {   }

// global parameters here:
int n, d;
int x[12][12];

int dist(int i, int j) {
	int sum = 0;
	FOR(k, 0, d) {
		sum += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
	}
	return sum;
}

bool sq(int k) {
	if (k==0 or k==1 or k==4) return true;
	int t = (int)sqrt(k);
	FORE(i, -1, 1) {
		if((t+i)*(t+i)==k) return true;
	}
	return false;
}

void solve() {
	cin >> n >> d;
	FOR(i, 0, n) FOR(j, 0, d) cin >> x[i][j];
	int cnt=0;
	FOR(i, 0, n) FOR(j, i+1, n) {

//		cout << "i=" << i << ", j=" << j << ", dist(i, j)=" << dist(i,j) << endl;

		if(sq(dist(i, j))) cnt++;
	}
	cout << cnt << endl;
}


signed main() {
  ios_base::sync_with_stdio(false); cin.tie();
//  FILEIO();
//auto beginProgram = chrono::steady_clock::now();

// int t, test=0; cin >> t;
//  while(t--)
  {
		solve();
  }

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}


Measured memory_bytes: 256
xa,ya,xb,yb=map(int,input().split())
dx,dy=xa-xb,ya-yb
if dx>0:
	if dy>0:
		x3,y3=xb+dy,yb-dx
		x4,y4=xa+dy,ya-dx
	else:
		x3,y3=xb+dy,yb-dx
		x4,y4=xa+dy,ya-dx
else:
	if dy>0:
		x3,y3=xb+dy,yb-dx
		x4,y4=xa+dy,ya-dx
	else:
		x3,y3=xb+dy,yb-dx
		x4,y4=xa+dy,ya-dx


print('{0} {1} {2} {3}'.format(x3,y3,x4,y4))

Measured memory_bytes: 3064
/*
 _     _    ___  ___  __ __ 
| |   | |  |__ \|__ \/_ /_ |
| |__ | |__   ) |  ) || || |
| '_ \| '_ \ / /  / / | || |
| |_) | |_) / /_ / /_ | || |
|_.__/|_.__/____|____||_||_|

*/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

#define N  100005

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        string s;
        cin>>s;
        string t,p;
        ll ans=0;
        ll n=s.size();
        rep(i,0,n)
        {
            t+=s[i];
            if(t!=p)
            {
                ans++;
                p=t;
                t="";
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repR(i, n) for(int i = n; i >= 0; ++i)
#define FDS(i, n) for(int i = 0; i < n; ++i)
#define FDSR(i, n) for(int i = n; i >= 0; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main(){
	ll A,B,C,X,Y;
	cin>>A>>B>>C>>X>>Y;
	if(X==Y){
		cout<<min((C*2*X),((A+B)*X))<<endl;
	}
	else{
	    ll sum=0;
		int t=min(X,Y);
		sum+=(min({(C*2),(A+B)}))*t;
		if(X>Y){
			sum+=min({(C*2),A})*(X-t);
		}
		else{
			sum+=min(C*2,B)*(Y-t);
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 256