akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  string A;
  int B;
  char C;
  cin >> A;
  B = A.size();
  C = A.at(B-1);
  if (C == '3') {
    cout << "bon" << endl;
  }
  else if (C == '0') {
    cout << "pon" << endl;
  }
  else if (C == '1') {
    cout << "pon" << endl;
  }
  else if (C == '6') {
    cout << "pon" << endl;
  }
  else if (C == '8') {
    cout << "pon" << endl;
  }
  else {
    cout << "hon" << endl;
  }
}


Measured memory_bytes: 3608
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  
  val nums = inputs.head.split(" ").map(_.toInt)

  println(solve(nums(0), nums(1)))

  private def solve(k: Int, s: Int): Int = {
    val max = 3 * k
    if (s == 0 || s == max) {
      return 1
    }

    var ans = 0
    (0 to k).foreach { i =>
      (0 to k).foreach { j =>
        val sum = i + j
        val dis = s - sum
        if (dis <= k && 0 <= dis) {
          ans = ans + 1
        }
      }
    }

    ans
  }
}

Measured memory_bytes: 25848
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
        	string N = Console.ReadLine();
            string target = "7";
            if(N.Contains(target))
            {
            	Console.WriteLine("Yes");
            }
            else
            {
            	Console.WriteLine("No");
            }
        }
    }
}

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

int32_t main()
{
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.size(); ++i)
    {
        cnt = (cnt + s[i] - '0') % 9;
    }
    if (cnt == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

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

#define MOD (1000000007LL)

using namespace std;

int main(void){
    int N, M;
    cin >> N >> M;
    vector<int> d(N + 1, -1);
    for(int i = 0; i < M; i++){
        int s, c;
        cin >> s >> c;
        if(d[s] == -1 || d[s] == c) d[s] = c;
        else{
            cout << -1 << endl;
            return 0;
        }
        if(N > 1 && s == 1 && c == 0){
            cout << -1 << endl;
            return 0;
        }
    }
    if(N > 1 && d[1] == -1) d[1] = 1;
    for(int i = 1; i <= N; i++){
        if(d[i] == -1) cout << 0;
        else cout << d[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#include<cstdio>
 
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
 
using namespace std;
 
double EPS = 1e-10;
const double PI = acos(-1);
 
double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}
 
struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}
  point operator + (point p){return point(add(x,p.x), add(y,p.y));}
  point operator - (point p){return point(add(x,-p.x), add(y,-p.y));}
  point operator * (double d){return point(x*d,y*d);}
};
 
#define Line pair<point,point>
 
double dot(point a, point b){return (a.x*b.x+a.y*b.y);}
double cross(point a, point b){return (a.x*b.y-a.y*b.x);}
double norm(point a){return sqrt(a.x*a.x+a.y*a.y);}
 
int ccw(point a, point b, point c) {
  b = b-a; c = c-a;
  if (cross(b, c) > 0)   return +1;
  if (cross(b, c) < 0)   return -1;
  if (dot(b, c) < 0)     return +2;
  if (norm(b) < norm(c)) return -2; 
  return 0;
}
 
point intersection_l(point a1, point a2, point b1, point b2) {
  return a1+(a2-a1)*(cross(b2-b1,b1-a1)/cross(b2-b1,a2-a1));
}
 
point symmetry(point p1, point p2, point Q){
  double xa,ya,xb,yb,t1,t2;
  point R;
 
  xa=Q.x-p1.x,ya=Q.y-p1.y;
  xb=p2.x-p1.x,yb=p2.y-p1.y;
 
  t1=xa*xb+ya*yb,t2=xb*xb+yb*yb;
 
  R.x=2*(p1.x+xb*t1/t2)-Q.x;
  R.y=2*(p1.y+yb*t1/t2)-Q.y;
  return R;
}
 
 Line parallel_line(point a,point b,double h){
    double t = atan((a.y-b.y)/(a.x-b.x));
 
    point a_(a.x + h*cos(t+PI/2), a.y + h*sin(t+PI/2));
    point b_(b.x + h*cos(t+PI/2), b.y + h*sin(t+PI/2));
 
    if(ccw(a,b,a_)==-1)a_=symmetry(a,b,a_),b_=symmetry(a,b,b_);
    return make_pair(a_,b_);
}
 
vector<point> convex_cut(vector<point>pol,point a,point b){
  vector<point>q;
  for (int i=0; i<pol.size();i++) {
    point A=curr(pol,i),B=next(pol, i);
    if (ccw(a,b,A)!=-1)q.push_back(A);
    if (ccw(a,b,A)*ccw(a,b,B)<0)
      q.push_back(intersection_l(A,B,a,b));
  }
  return q;
}
 
/*
テ・ツ、ツ堙ィツァツ津・ツスツ「テ」ツ?ョテ・ツ青?ィツセツコテ」ツつ壇テ」ツ??」ツ?妥・ツ??・ツ?エテ」ツ?ォテ」ツ?堙」ツつ嘉」ツ?療」ツ?淌ァツ崢エテァツキツ堙」ツ?ァテ」ツ??・ツ、ツ堙ィツァツ津・ツスツ「テ」ツつ津・ツ按?ヲツ鳴ュテ」ツ??
テ・ツ、ツ堙ィツァツ津・ツスツ「テ」ツ?古ヲツョツ凝」ツ?」テ」ツ?ヲテ」ツ??」ツつ古」ツ?ーtrue
テ」ツ?敕」ツつ古、ツサツ・テ・ツ、ツ姪」ツ?ェテ」ツつ映alseテ」ツつ津ィツソツ氾」ツ?凖」ツ??
*/
bool C(vector<point>pol,double d){
  vector<Line>L;
  for(int i=0;i<pol.size();i++){
    L.push_back(Line(curr(pol,i),next(pol,i)));
  }
 
  for(int i=0;i<L.size();i++){
    Line tmp=parallel_line(L[i].first,L[i].second,d);
    pol=convex_cut(pol,tmp.first,tmp.second);
  }
  return pol.size()>0;
}
 
/*
テ、ツコツ古・ツ按?ヲツ篠「テァツエツ「テ」ツ?ァテ」ツ??・ツ、ツ堙ィツァツ津・ツスツ「テ」ツ?ョテ・ツ青?ィツセツコテ」ツつ津」ツ?ゥテ」ツつ古」ツ??」ツ?妥・ツ??・ツ?エテ」ツ?ォテ」ツ?堙」ツつ嘉」ツ?崚」ツ?ー
テ」ツ?。テ」ツつ?」ツ??」ツ?ゥテ・ツ、ツ堙ィツァツ津・ツスツ「テ」ツ?古ヲツカツ暗」ツ?暗」ツつ凝」ツ?ョテ」ツ?凝」ツつ津ヲツアツづ」ツつ?」ツつ凝」ツ??
*/
double Binary_search(vector<point>pol){
  double l=0,r=10000,tc=86;
  while(tc--){
    double d=(l+r)/2;
    if(C(pol,d))l=d;
    else r=d;
  }
  return l;
}
 
int main(void){
 
  int n;
  while(cin >> n,n){
    vector<point>pol(n);
    for(int i=0;i<n;i++)cin >> pol[i].x >> pol[i].y;
 
    printf("%.6f",Binary_search(pol));
    cout << endl;
  }
  return 0;
}

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

int main() {
	string S, T;
	cin >> S >> T;
	int n = 0, max_n = 0;
	for (int i = 0; i <= (int)S.size() - T.size(); i++) {
		n = 0;
		for (int j = 0; j < (int)T.size(); j++) {
			if (T[j] == S[i + j]) n++;
		}
		max_n = max(n, max_n);
	}
	cout << T.size() - max_n << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
int main(void){
  char str[1000];
  //H とW と正解を格納する変数ans
  long h, w, ans;
  
  fgets(str, sizeof(str), stdin);
  sscanf(str, "%ld %ld", &h, &w);
  
  if(h == 1 || w== 1){
    ans = 1;
  }else if(h % 2 == 0 || w % 2 == 0){
    ans = w * h / 2;
  }else{
    ans = (w * h + 1)/ 2;
  }
  
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 2156
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int H, W;
int Ch, Cw, Dh, Dw;

vector<string> S;
vector<vector<int>> dist;

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

void bfs() {
    using pi = pair<int, pair<int, int>>;
    priority_queue<pi, vector<pi>, greater<pi>> Q;
    Q.push({0, {Ch, Cw}});

    while (!Q.empty()) {
        auto q = Q.top(); Q.pop();
        int d = q.first;
        int h = q.second.first;
        int w = q.second.second;
        if (d > dist[h][w]) continue;
        REP(i, 0, 4) {
            int ni = h + dx[i];
            int nj = w + dy[i];
            if (ni < 0 || ni >= H || nj < 0 || nj >= W) continue;
            if (S[ni][nj] == '#') continue;
            if (dist[ni][nj] > dist[h][w]) {
                dist[ni][nj] = dist[h][w];
                Q.push({dist[ni][nj], {ni, nj}});
            }
        }
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                int ni = h + i;
                int nj = w + j;
                if (ni < 0 || ni >= H || nj < 0 || nj >= W) continue;
                if (S[ni][nj] == '#') continue;
                if (dist[ni][nj] > dist[h][w] + 1) {
                    dist[ni][nj] = dist[h][w] + 1;
                    Q.push({dist[ni][nj], {ni, nj}});
                }
            }
        }
    }
}

int main() {
    cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
    S.resize(H);
    REP(i, 0, H) cin >> S[i];

    Ch--; Cw--; Dh--; Dw--;
    dist.resize(H, vector<int>(W, 1 << 28));
    dist[Ch][Cw] = 0;
    bfs();

    if (dist[Dh][Dw] < (1 << 28)) cout << dist[Dh][Dw] << endl;
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 9520
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define M 1000000007LL
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(v) ((ll)v.size())
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pii pair<ll,ll> 
#define mod 998244353LL
#define MAXN 300002
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
vector< pii > v;
int main() {
       ios::sync_with_stdio(false);
       cin.tie(0);
       cout.tie(0);
  ll n;
  cin>>n;
       string s;
       cin>>s;
       ll flg=0;
       for(auto it: s)
       {
        if(it=='R') flg++;
       }
       if(flg>sz(s)-flg) cout<<"Yes";
       else cout<<"No";
       return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
#define MAX 1000005
#define mod 1000000007



int main()
{
 //O_O ;
   string a="ABC",b="ARC",c;
   cin>>c;
   if(a==c)
    cout<<b<<nn;
   else
    cout<<a<<nn;




    return 0;
}


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

// traduções

// even -> par
// odd -> impar

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000
#define MOD 1000000007
#define EPS 1e-12
const double PI = acos(-1.0);

#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define FILL(a,v) memset(a, v, sizeof a)

// bitmask operations
#define SETBIT(S, j) S |= (1 << j)
#define CLEARBIT(S, j) S &= ~(1 << j)
#define ISSET(S, j) S & (1 << j)
#define FLIPBIT(S, j) S ^= (1 << j)
#define LSBIT(S) (S & (-S))

// debug
#define DEBUGSTR(S) cout << "(" << S << ")\n";

int main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    int A[3][3], N, bingo[3][3];

    REP(i, 0, 3)
        REP(j, 0, 3) {
            scanf(" %d", &A[i][j]);
            bingo[i][j] = 0;
        }

    scanf(" %d", &N);

    REP(i, 0, N) {
        int v;
        scanf(" %d", &v);

        REP(i, 0, 3)
            REP(j, 0, 3)
                if(A[i][j] == v)
                    bingo[i][j] = 1;
    }

    bool ok = false;

    if(bingo[0][0] && bingo[0][1] && bingo[0][2]) ok = true;
    if(bingo[1][0] && bingo[1][1] && bingo[1][2]) ok = true;
    if(bingo[2][0] && bingo[2][1] && bingo[2][2]) ok = true;

    if(bingo[0][0] && bingo[1][0] && bingo[2][0]) ok = true;
    if(bingo[0][1] && bingo[1][1] && bingo[2][1]) ok = true;
    if(bingo[0][2] && bingo[1][2] && bingo[2][2]) ok = true;

    if(bingo[0][0] && bingo[1][1] && bingo[2][2]) ok = true;
    if(bingo[0][2] && bingo[1][1] && bingo[2][0]) ok = true;    

    printf("%s\n", ok ? "Yes" : "No");

    return 0;
}


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

int san = 0;
int a[3];
int inu = 0;
int saru = 0;
int kiji = 0;

int main(){
	while (true){
		for (int i = 0; i < 3; i++){
			cin >> a[i];
		}
		sort(a, a + 3);
		if (a[2] * a[2] < a[1] * a[1] + a[0] * a[0] && a[2] < a[0] + a[1]){
			san = san + 1;
			saru = saru + 1;
		}if (a[2] * a[2] == a[1] * a[1] + a[0] * a[0] && a[2] < a[0] + a[1]){
			san = san + 1;
			inu = inu + 1;
		}if (a[2] * a[2] > a[1] * a[1] + a[0] * a[0] && a[2] < a[0] + a[1]){
			san = san + 1;
			kiji = kiji + 1;
		}if (a[2] >= a[0] + a[1]){
			break;
		}
	}
	cout << san << " " << inu << " " << saru << " " << kiji << endl;
}

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

using namespace std;

int N, M;

int self[1<<15];

int dp[1<<15][15];

int gph[15][15];

int l2[1<<15];

int sumc;

int main() {
#ifdef IN_MY_COMPUTER
  freopen("f.in", "r", stdin);
#endif

  scanf("%d%d", &N, &M);
  for(int i = 0; i < M; i++) {
    int a, b, c; scanf("%d%d%d", &a, &b, &c);
    a -= 1; b -= 1;
    gph[a][b] = gph[b][a] = c;
    sumc += c;
  }
  for(int i = 0; i < N; i++) {
    l2[1<<i] = i;
  }

  for(int mask = 1; mask < (1<<N); mask++) {
    int cost = 0;
    for(int u = 0; u < N; u++) if(((mask >> u) & 1) == 1) {
      for(int v = u+1; v < N; v++) if(((mask >> v) & 1) == 1) cost += gph[u][v];
    }
    self[mask] = cost;
  }
  for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) if(gph[i][j] == 0) gph[i][j] = -5e8;
  
  for(int mask = 0; mask < (1<<N); mask++) {
    for(int u = 0; u < N; u++) dp[mask][u] = -5e8;
  }

  dp[1][0] = 0;
  for(int mask = 3; mask < (1<<N); mask += 2) {
    dp[mask][0] = self[mask];
    for(int vmask_ = mask >> 1; vmask_ >= 0; vmask_ = (vmask_ - 1) & (mask >> 1)) {
      int vmask = (vmask_ << 1) | 1;
      assert((vmask & mask) == vmask);
      for(int u = 0; u < N; u++) if((vmask >> u) & 1) {
        for(int v = 1; v < N; v++) if(((mask ^ vmask) >> v) & 1) {
          dp[mask][v] = max(dp[mask][v], dp[vmask][u] + self[mask ^ vmask] + gph[u][v]);
        }
      }
      if(vmask == 1) {
        break;
      }
    }
//    for(int u = 0; u < N; u++) if((mask >> u) & 1) printf("dp[%d][%d] = %d\n", mask, u, dp[mask][u]);
  }

  printf("%d\n", sumc - dp[(1<<N)-1][N-1]);
  return 0;
}

Measured memory_bytes: 2304
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define ll long long

int main(void){
  string s;
  string s_;
  cin >> s_;
  cin >> s;
  cin >> s_;

  cout << "A" << s[0] << "C\r\n";

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

signed main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int n,m;
    cin >> n >> m;
    map<int, int> cards[m];
    vector<int> counts(m, 0);
    rep(n){
        int tmp;
        cin >> tmp;
        cards[tmp%m][tmp]++;
        counts[tmp%m]++;
    }

    int ans = counts[0] / 2;
    reppp(i, 1, (m-1)/2){
        if(counts[i] < counts[m-i]){
            swap(counts[i], counts[m-i]);
            swap(cards[i], cards[m-i]);
        }
        int diff = counts[i] - counts[m-i];
        if(diff >= 2){
            for(auto itr=cards[i].begin(); itr!=cards[i].end(); ++itr){
                if(itr->second >= 2){
                    int tmp = min(diff, itr->second)/2;
                    ans += tmp;
                    counts[i] -= tmp*2;
                    diff = counts[i] - counts[m-i];
                    if(diff == 0) break;
                }
            }
        }
        ans += min(counts[i], counts[m-i]);
        //cout << i << " " << ans << endl;

    }
    if(m % 2 == 0){
        ans += counts[m/2]/2;
    }
    cout << ans;
}


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

#define int long long

void solve() {
	int k;
	cin >> k;
	if (k % 7 == 0)
		k /= 7;
	if (__gcd((int)10, k) != 1) {
		cout << -1;
		return;
	}
	int v = 1 % k;
	int cnt = 1;
	while (v != 0) {
		v = (10 * v + 1) % k;
		cnt++;
	}
	cout << cnt;
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn=109;
string ss[maxn];
int main()
{
    int n,l;
    while(scanf("%d%d",&n,&l)!=EOF)
    {
        for(int i=0;i<n;i++)
        cin>>ss[i];
        sort(ss,ss+n);
        for(int i=0;i<n;i++)
        cout<<ss[i];
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

typedef long long int ll;
int main(){
	int N,W,i,j;
	cin>>N>>W;
	vector<int> wt(N);
	vector<int> val(N);
	for(i=0;i<N;i++){
		cin>>wt[i];
		cin>>val[i];
	}
	long long int ans;
	
	vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));
	for(i=1;i<=N;i++){
		for(j=1;j<=W;j++){
			if(wt[i-1]>j)
				dp[i][j]=dp[i-1][j];
			else{
				dp[i][j]=dp[i-1][j];
				dp[i][j]=max(dp[i][j],val[i-1]+dp[i-1][j-wt[i-1]]);
			}
		}
	}
	cout<<dp[N][W]<<endl;
	
	return 0;
}

Measured memory_bytes: 82752
// Let's bring the sky down :)
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e5 + 5;
float a[N];
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    double x, sum = 0;
    for(int i = 0; i < n; i++){
        cin >> x;
        sum += (1.0 / x);
    }
    cout << fixed << setprecision(10) << (1.0 / sum);
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int N,Y;
    cin>>N>>Y;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            int l=N-i-j;
            if(10000*i+5000*j+1000*l==Y && l>=0 && l<=N){
                printf("%d %d %d \n",i,j,l);
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;

}

Measured memory_bytes: 3764
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		int ans = 0;
		for (int i=0;i<N;i++) {
			int h = Integer.parseInt(sc.next());
			if (h>=K) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 45328
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        h: usize, w: usize,
        s: [Chars; h]
    }
    let vect = vec![(0, 1), (1, 0)];
    let mut pq = BinaryHeap::new();
    if s[0][0] == '.' { pq.push((0, (0, 0)))} else {pq.push((-1, (0, 0)))};
    let mut d = vec![vec![-1; w]; h];

    while let Some((dep, (x, y))) = pq.pop() {
        let dep = -dep;
        // if (x, y) == (h, w) {
        //     ans = dep; break;
        // }

        if d[y][x] >= 0 {
            continue;
        }

        d[y][x] = dep;

        for &(dx, dy) in vect.iter() {
            let cx = x as i64 + dx;
            let cy = y as i64 + dy;
            if cx >= 0 && cx < w as i64 && cy >= 0 && cy < h as i64 {
                let (cyu, cxu) = (cy as usize, cx as usize);
                if d[cyu][cxu] < 0 {
                    if s[cyu][cxu] == s[y][x] {
                        pq.push((-dep, (cxu, cyu)))
                    } else {
                        pq.push((-(dep+1), (cxu, cyu)))
                    }
                }
            }
        }
    }

    println!("{}", (d[h-1][w-1]+1)/2)
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 2224
#include <iostream>

using namespace std;

int main(){
  int m,f,r,test;
  while(1){
    cin >> m >> f >> r;
    if(m == -1 && f == -1 && r == -1) break;
    test =  m + f;
    if(m == -1 || f == -1) cout << 'F' << endl;//     中間試験、期末試験のいずれかを欠席した場合成績は F。
    else if(test >= 80) cout << 'A' << endl;   // 中間試験と期末試験の合計点数が 80 以上ならば成績は A 。
    else if(test >= 65) cout << 'B' << endl;   // 中間試験と期末試験の合計点数が 65 以上 80 未満ならば成績は B。
    else if(test >= 50) cout << 'C' << endl;// 中間試験と期末試験の合計点数が 50 以上 65 未満ならば成績は C。
    else if(test >= 30 && r < 50) cout << 'D' << endl;// 中間試験と期末試験の合計点数が 30 以上 50 未満ならば成績は D。
    else if(test >= 30 && r >=50) cout << 'C' << endl;//ただし、再試験の点数が 50 以上ならば成績は C。
    else cout << 'F' << endl;// 中間試験と期末試験の合計点数が 30 未満ならば成績は F。
  }
  return 0;
}



Measured memory_bytes: 3096
import math
n=int(input())
a=list(map(int,input().split()))
t=sum(a)/n
s=0
p=0
if t==int(t):
    for i in range(n):
        s += int(math.pow(t - a[i], 2))
    print(s)
else:
    for i in range(n):
        s += int(math.pow(int(t) - a[i], 2))
        p+= int(math.pow(int(t)+1 - a[i], 2))

    print(min(p,s))



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

int match[201];
bool used[201];
vector<int> v[201];

bool dfs(int k){
    used[k] = true;
    int l = v[k].size();
    for(int i = 0; i < l; i++){
        int next = match[v[k][i]];
        if(next < 0 || (!used[next] && dfs(next))){
            match[k] = v[k][i];
            match[v[k][i]] = k;
            return true;
        }
    }
    return false;
}

int main()
{
    int n;
    cin >> n;
    int a[101], b[101], c[101], d[101];
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    for(int i = 0; i < n; i++){
        cin >> c[i] >> d[i];
        c[i]--;
        d[i]--;
        for(int j = 0; j < n; j++){
            if(a[j] < c[i] && b[j] < d[i]){
                v[j].push_back(i + n);
                v[i + n].push_back(j);
            }
        }
    }
    fill(match, match + n * 2, -1);
    int ans = 0;
    for(int i = 0; i < n; i++){
        fill(used, used + n * 2, false);
        if(dfs(i)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int A,B,C,D;
  scanf("%d %d %d %d", &A, &B, &C, &D);
  
  int junban = 0; //0高橋、1青木で攻撃
  for(;;){
  	if(junban == 0){ //高橋の攻撃
    	C -= B;
      	junban = 1;
      	if(C <= 0){
          printf("Yes");
          break;
        }
    }else{            //青木の攻撃
      A -= D;
      junban = 0;
      if(A <= 0){
        printf("No");
        break;
      }
    }
  }
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

int V, E, r;
int V_MAX = 1e5, E_MAX=5e5;

using P = pair<int,int>;

struct edge{
    int to, d;
};

vector<vector<edge>> G(V_MAX);
vector<int> dist(V_MAX,INF);

int main() {
    cin >> V >> E >> r;
    REP(i,E){
        int s,t,d;
        cin >> s >> t >> d;
        G[s].push_back({t,d});
    }

    priority_queue< P, vector<P>, greater<P> > q;
    q.push(make_pair(0,r));//ある点までの、最短距離 最初を距離にすることで優先度を利用できる
    dist[r] = 0;
    while(!q.empty()){
        P p = q.top();
        q.pop();
        int v = p.second;
        if(dist[v] < p.first) continue; //更新できないならスルー
        for(auto e: G[v]){
            if(dist[e.to] > dist[v] + e.d){
                dist[e.to] = dist[v] + e.d;
                q.push(make_pair(dist[e.to], e.to));
            }
        }
    }

    REP(i,V){
        if (dist[i] == INF){
            cout << "INF" << endl;
        }else{
            cout << dist[i] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 12992
// C - A x B + C
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n; cin>>n; --n;
	int sqn = sqrt(n);
	int c = 0;
	for(int x=1; x<=sqn; ++x) c += (n / x - x) * 2 + 1;
	cout<< c <<endl;
}


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

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

  char mark = S[K-1];

  for (int i=0; i<N; i++){
    if (S[i] != mark){
      S[i] = '*';
    }
  }
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
li = []
for i in range(h):
    a = list(input())
    li.append(a)

dx = [0,0,1,1,1,-1,-1,-1]
dy = [1,-1,0,1,-1,0,1,-1]

for i in range(h):
    for j in range(w):
        n = 0
        if li[i][j] == "#":
            continue

        for d in range(8):
            y = i + dy[d]
            x = j + dx[d]
            if x<0 or w<=x:
                continue
            if y<0 or h<=y:
                continue
            if li[y][x] == "#":
                n += 1
        li[i][j] = str(n)
for i in range(h):
    print("".join(li[i]))

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

int main()
{
    int dice[6];
    int dice2[6];
    int chinge[6][6]={
        {1,2,3,4,5,6},
        {4,2,1,6,5,3},//E
        {3,2,6,1,5,4},//W
        {2,6,3,4,1,5},//N
        {5,1,3,4,6,2},//S
    };
    
    for(int i = 0;i<6;i++)
    {
        cin >> dice[i];
        dice2[i] = dice[i];
    }
    
    string s;
    cin >> s;
    int i,j;
    for(i = 0;i<s.size();i++)
    {
        if(s[i] == 'E')
        {
            for(int j = 0;j < 6;j++)
            {
                dice[j] = dice2[chinge[1][j]-1];
            }
            
        }
        
        if(s[i] == 'W')
        {
            for(j = 0;j < 6;j++)
            {
                dice[j] = dice2[chinge[2][j]-1];
            }
            
        }
        
        if(s[i] == 'N')
        {
            for(j = 0;j < 6;j++)
            {
                dice[j] = dice2[chinge[3][j]-1];
            }
            
        }
        
        if(s[i] == 'S')
        {
            for(j = 0;j < 6;j++)
            {
                dice[j] = dice2[chinge[4][j]-1];
            }
            
        }
        
            for(j = 0;j < 6;j++)
            {
                dice2[j] = dice[j];
            }
    }
    cout<<dice[0]<<endl;
    
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll N, M, L, S, T;

ll dp[1 << 16][16];
vector<ll> J, E;

void solve() {
    vector<vector<ll>> dist(N, vector<ll>(N, 1e9));
    for(int i = 0; i < N; i++) dist[i][i] = 0;
    for(int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            for(int k = 0; k < N; k++) {
                chmin(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
    J.resize(L);
    E.resize(L);
    for(int i = 0; i < L; i++) {
        cin >> J[i] >> E[i];
        J[i]--;
    }
    for(int bits = 0; bits < (1 << L); bits++) {
        for(int i = 0; i < L; i++) dp[bits][i] = 1e9;
        if(bits == 0) continue;
        if(__builtin_popcount(bits) == 1) {
            for(int i = 0; i < L; i++) {
                if(bits & (1 << i)) {
                    dp[bits][i] = dist[S][J[i]] + E[i];
                }
            }
            continue;
        }
        for(int i = 0; i < L; i++) {
            if(!(bits & (1 << i))) continue;
            int before = bits & (~(1 << i));
            for(int j = 0; j < L; j++) {
                if(!before & (1 << j)) continue;
                chmin(dp[bits][i], dp[before][j] + dist[J[j]][J[i]] + E[i]);
            }
        }
    }
    ll ans = 0;
    for(int bits = 0; bits < (1 << L); bits++) {
        for(int i = 0; i < L; i++) {
            ll TIME = dp[bits][i] + dist[S][J[i]];
            if(TIME <= T) chmax(ans, (ll)__builtin_popcount(bits));
        }
    }
    cout << ans << endl;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N >> M >> L >> S >> T) {
        if(N == 0) break;
        S--;
        solve();
    }
    return 0;
}


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

#define ll long long int
#define endl "\n"
#define mod 1000000007

int main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	{
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
#endif
	ll t;
	//cin >> t;
	t = 1;
	while (t--) {
		ll n;
		cin >> n;
		string y;
		set<string> s;
		for (ll i = 0; i < n; i++) {
			cin >> y;
			s.insert(y);
		}
		cout << s.size() << endl;
	}

	return 0;

}

Measured memory_bytes: 19292
from collections import deque
S = str(input())
Q = int(input())
Qy = list([input().split() for _ in range(Q)])
rev = False #反転チェック
ans = deque([S])
for t in Qy:
    if t[0] == '1':
        rev = not rev
    else:
        if (t[1]=='1' and rev == False) or (t[1]=='2' and rev == True):
            ans.appendleft(t[2])
        else:
            ans.append(t[2])
if rev == False:
    print(''.join(ans))
else:
    print(''.join(ans)[::-1])

Measured memory_bytes: 43096
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 5002

pii t[4] = {{-1,0},{0,-1},{1,0},{0,1}};
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n,m;cin>>n>>m;
	bool a[n][m];
	vector<pii> source;
	For(i,0,n){
		For(j,0,m){
			char c;cin>>c;
			a[i][j] = (c=='#');
			if(c=='#') source.pb({i,j});
		}
	}

	queue<pii> q;
	bool visited[n][m];
	memset(visited,0,sizeof(visited));
	ll dist[n][m];
	memset(dist,-1,sizeof(dist));
	for(pii x:source){
		q.push(x);
		visited[x.fi][x.se]=1;
		dist[x.fi][x.se]=0;
	}

	while(q.size()>0){
		pii c1 = q.front();q.pop();
		For(i,0,4){
			pii c2 = t[i];
			pii x(c1.fi+c2.fi,c1.se+c2.se);
			if(x.fi<0 || x.se<0 || x.fi>=n || x.se>=m || visited[x.fi][x.se]) continue;
			visited[x.fi][x.se]=1;
			q.push(x);
			dist[x.fi][x.se] = dist[c1.fi][c1.se]+1;
		}
	}

	ll ans=0;
	For(i,0,n) For(j,0,m) ans=max(ans,dist[i][j]);
	cout<<ans<<endl;









	
}

Measured memory_bytes: 42084
#include <cstdio>
#include <algorithm>
using namespace std;
int cost[20][20];
int main() {
	for(int i=0;i<20;i++) {
		for(int j=0;j<20;j++) {
			if(i!=j)cost[i][j]=cost[j][i]=1<<27;
			else cost[i][i]=0;
		}
	}
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++) {
		int a,b,c,d;
		scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		cost[a-1][b-1]=c;
		cost[b-1][a-1]=d;
	}
	for(int k=0;k<n;k++) {
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
			}
		}
	}
	int x1,x2,y1,y2;
	scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
	printf("%d\n",y1-y2-cost[x1-1][x2-1]-cost[x2-1][x1-1]);
}

Measured memory_bytes: 1032
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    //int t = 1; cin >> t; while(t--)
    {
        int a, b, m;
        cin >> a >> b >> m;



        int aa[a], ab[b];
        for(int i= 0; i  < a ; i++)
            cin >> aa[i];
        for(int i =0; i < b; i++)
            cin >> ab[i];

        vector<tuple<int, int, int >> v;
        for(int i = 0; i < m; i++) {
            int x, y, z;
            cin >> x >> y >> z;
            x--, y--;
            v.push_back(make_tuple(x, y, z));
        }

        int ans = INT_MAX;
        for(int i =0; i < v.size(); i++) {
            //cout << get<0>(v[i]) << ' ' << get<1>(v[i]) << ' ' << get<2>(v[i]) << '\n';
            ans = min(ans, aa[get<0>(v[i])] + ab[get<1>(v[i])] - get<2>(v[i]));
        }

        cout << min(ans, *min_element(aa, aa + a) + *min_element(ab, ab + b)) << '\n';
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



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

#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 int  n ;
 cin >> n ;
vector<int> A(n) ;
vector<int> B(n) ;
vector<int> C(n) ;
rep(i,n) cin>> A[i] ;
rep(i,n) cin >> B[i] ;
rep(i,n) cin >>C[i] ;
sort(A.begin(),A.end()) ;
sort(C.begin(),C.end()) ;
ll ans=0 ;
rep(i,n){
ll p= lower_bound(ALL(A),B[i])-A.begin() ;
ll q= upper_bound(ALL(C),B[i])-C.begin() ;
ans+= p*(n-q) ;
}
 
 cout <<ans<<endl ;
     return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<complex>
using namespace std;
typedef complex<double> Point;

int main() {
    int n;
    double x0, y0, x1, y1, x2, y2, x3, y3;
    cin >> n;
    while (n--)
    {
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >>y3;
        Point z1(x1 - x0, y1 - y0); 
        Point z2(x2 - x0, y2 - y0);
        Point z3(x3 - x0, y3 - y0);
        Point p1 = z2 * conj(z1);
        Point p2 = z3 * conj(z1);
        Point w1 = z3 - z2;
        Point w2 = -z2;
        Point w3 = z1 - z2;

        if (p1.imag() * p2.imag() > 0 
            || (w2 * conj(w1)).imag() * (w3 * conj(w1)).imag() > 0 
            || p1.imag() == 0 && p2.imag() == 0
               && p1.real() * p2.real() > 0
               && p1.real() * (p1.real() - abs(z1) * abs(z1)) > 0
               && p2.real() * (p2.real() - abs(z1) * abs(z1)) > 0)
            cout << "0\n";
        else cout << "1\n";
    }
    return 0;
}


Measured memory_bytes: 3208
r, d, x = map(int,input().split())
#n = int(input())
#ls = list(map(int,input().split()))
#s = input()

ls = [x]

for i in range(10):
  ls.append(ls[i] * r - d)
  
ls.remove(ls[0])
for i in ls:
  print(i)

Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <stack>
#include <sstream>
#include <list>
 
using namespace std;
 
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define PB push_back
#define PF push_front
#define MP make_pair
 
 
typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
 
 
const ll mod = 1e9+7;
const ll INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;
 
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}

string s;

int main(){
  cin >> s;
  int N = s.size();
  
  ll dp[100010][13];
  
  memset(dp,0,sizeof dp);
  dp[0][0] = 1;
  
  for(int i = 1;i < N + 1;i++){
    if(s[i-1] != '?'){
      int t = s[i-1] - '0';
      rep(j,13){
        dp[i][(10*j+t)%13] = dp[i-1][j];
        dp[i][(10*j+t)%13] %= mod;
      }
    }else{               //s[i]が'?'の時
      rep(k,13){ 
        rep(j,13){
          if((13 + k - (10*j)%13)%13 <10){
            dp[i][k] += dp[i-1][j];
            dp[i][k] %= mod;
          }
        }
      }
    }
  }

  cout << dp[N][5] << endl;
  

  
  
}
  
  

Measured memory_bytes: 10624
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let mut v: Vec<usize> = read_vec();
    let (n, k) = (v[0], v[1]);
    let mut s = read::<String>().chars().collect::<Vec<_>>();
    let mut one_starts = Vec::new();
    let mut zero_starts = Vec::new();
    let mut one_ends = Vec::new();
    let mut zero_ends = Vec::new();

    if s[0] == '0' {
        zero_starts.push(0i64);
    } else {
        one_starts.push(0i64);
    }
    for i in 1..n {
        if s[i] != s[i - 1] {
            if s[i] == '0' {
                zero_starts.push(i as i64);
                one_ends.push(i as i64);
            } else {
                one_starts.push(i as i64);
                zero_ends.push(i as i64);
            }
        }
    }
    if s[s.len() - 1] == '0' {
        zero_ends.push(s.len() as i64);
    } else {
        one_ends.push(s.len() as i64);
    }
    // println!("zero starts {:?}", &zero_starts);
    // println!("zero ends {:?}", &zero_ends);
    // println!("one starts {:?}", &one_starts);
    // println!("one ends {:?}", &one_ends);

    if zero_starts.len() <= k {
        println!("{}", s.len());
        return;
    }
    let inv_one_starts = one_starts.iter().rev().map(|x| -x).collect::<Vec<_>>();
    let mut ans = 0;
    for i in 0..zero_starts.len() - k + 1 {
        let mut start_pos;
        if zero_starts[i] == 0 {
            start_pos = 0;
        } else {
            start_pos = -inv_one_starts[inv_one_starts.lower_bound(&(-zero_starts[i]))];
        }
        let mut end_pos;
        if zero_ends[i + k - 1] == s.len() as i64 {
            end_pos = s.len() as i64;
        } else {
            end_pos = one_ends[one_ends.lower_bound(&(zero_ends[i + k - 1]))];
        }
        ans = max(ans, end_pos - start_pos);
    }
    println!("{}", ans);
}

use std::cmp::Ordering;

pub trait BinarySearch<T> {
    fn lower_bound(&self, &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}


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

int main() {
  int a,b,c=0;
  cin>>a>>b;
  double ans=0;
  //cin>>n;
  while(c<b-1)
  {
    c+=(a-1);
    ans++;
  }
    //int x;
    //cin>>x;
    //ans+=(1.0/double(x));

  
  //double ans2=1.0/double(ans);
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Point[] points = new Point[n];
		for (int i = 0; i < n; i++) {
			points[i] = new Point(i, sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(points, new Comparator<Point>() {
		public int compare(Point p1, Point p2) {
			return p1.x - p2.x;
		}
		});
		ArrayList<Road> list = new ArrayList<>();
		for (int i = 1; i < n; i++) {
			list.add(new Road(points[i - 1].idx, points[i].idx, points[i].x - points[i - 1].x));
		}
		Arrays.sort(points, new Comparator<Point>() {
		public int compare(Point p1, Point p2) {
			return p1.y - p2.y;
		}
		});
		for (int i = 1; i < n; i++) {
			list.add(new Road(points[i - 1].idx, points[i].idx, points[i].y - points[i - 1].y));
		}
		Collections.sort(list, new Comparator<Road>() {
		public int compare(Road r1, Road r2) {
			return r1.cost - r2.cost;
		}
		});
		UnionFindTree uft = new UnionFindTree(n);
		long total = 0;
		for (Road r : list) {
			if (uft.same(r.from, r.to)) {
				continue;
			}
			uft.unite(r.from, r.to);
			total += r.cost;
		}
		System.out.println(total);
	}
	
	static class UnionFindTree {
		int[] parents;
		
		public UnionFindTree(int size) {
			parents = new int[size];
			for (int i = 0; i < size; i++) {
				parents[i] = i;
			}
		}
		
		public int find(int x) {
			if (parents[x] == x) {
				return x;
			}
			int ans = find(parents[x]);
			parents[x] = ans;
			return ans;
		}
		
		public boolean same(int x, int y) {
			return find(x) == find(y);
		}
		
		public void unite(int x, int y) {
			int xx = find(x);
			int yy = find(y);
			if (xx == yy) {
				return;
			}
			parents[xx] = yy;
		}
	}
	
	static class Road {
		int from;
		int to;
		int cost;
		public Road(int from, int to, int cost) {
			this.from = from;
			this.to = to;
			this.cost = cost;
		}
	}
	
	static class Point {
		int idx;
		int x;
		int y;
		
		public Point(int idx, int x, int y) {
			this.idx = idx;
			this.x = x;
			this.y = y;
		}
	}
}


Measured memory_bytes: 99784
#include <iostream>

using namespace std;

int main() {
    int N, M, C, a;
    int B[20] = {0};
    int ans = 0;

    cin >> N >> M >> C;

    for(int i = 0; i < M; i++) {
        cin >> B[i];
    }

    for(int i = 0; i < N; i++) {
        int sum = C;
        for(int j = 0; j < M; j++) {
            cin >> a;
            sum += a * B[j];
        }
        if(sum > 0) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
ll mod=1000000007;
ll combi(ll N_, ll C_) {
    const int NUM_=400001;
    static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
    if (fact[0]==0) {
        inv[1]=fact[0]=factr[0]=1;
        for (int i=2;i<=NUM_;++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
        for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mod, factr[i]=factr[i-1]*inv[i]%mod;
    }
    if(C_<0 || C_>N_) return 0;
    return factr[C_]*fact[N_]%mod*factr[N_-C_]%mod;
}

int main(){
    ll h,w;
    ll a,b;
    cin >> h >> w >> a >> b;
    ll ans = 0;
    for(ll i = b+1; i <= w; i++){
        ans += combi(h-a-1+i-1,h-a-1)*combi(a-1+w-i,a-1);
        ans %= mod;
    }
    cout << ans << endl;
}

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

const ll INF = 1001001001;

const double PI=3.141592653;

const ll sosu = 1000000007;//大きい素数

//提出のときに言語がc＋＋似合っていることを確認する

//絶対値の関数
int z(int a,int b){
  if(a>b) return a-b;
  else return b-a;
}

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


Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>

int main(){
	int a,b,c;
	int ok[120];
	bool can = false;

	scanf("%d %d %d",&a,&b,&c);

	for(int i=0;i<120;i++) ok[i] = 0;

	for(int i=0;i<b;i++){
		int k = a*i;
		k %= b;
		//printf("%d\n",k);
		if(k>0) ok[k] = 1;
		if(k==0) ok[b] = 1;
	}

	for(int i=1;i<=b;i++){
		if(ok[i]==1&&c%i==0){
			can = true;
		}
	}

	if(can){
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;
}


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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main() {
    int n;
    cin >> n;
    map<ll,int,greater<int>> mp;
    REP(i,n){
        ll t;
        cin >> t;
        mp[t]++;
    }
    ll ans = 1,counter=0;
    for(const auto& i:mp){
        ll a = i.first;
        int count = i.second;
        if(counter==0&&count>=4){
            ans *= a*a;
            counter+=2;
        }
        else if(counter==1&&counter>=4){
            ans *= a;
            counter++;
        }
        else if(count>=2){
            ans *= a;
            counter++;
        }
        if(counter==2){
            COUT(ans);
            return 0;
        }
    }
    if(counter<=1)COUT(0);
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll n, m;
    cin >> n >> m;

    cout << (n-1)*(m-1) << endl;
    return 0;
}

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

int f(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int N;
    bool flg = false;
    std::cin >> N;
    if (N % f(N) == 0) flg = true;
    std::cout << (flg ? "Yes" : "No") << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
int n;
cin>>n;
string s;
cin>>s;
int ans=n;
for (int i = 0; i < n-1; i++)
{
    /* code */
    if (s[i]==s[i+1])
    {
        /* code */
        ans--;
    }
    
}
cout<<ans<<endl;


}

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

bool is_prime(int n){
	if(n == 2){
		return true;
	}

	for(int i = 2; i<n; i++){
		if(n%i == 0)
			return false;
	}
	return true;
}

int next_prime(int n){
	while (!is_prime(n)){
		n++;
	}
	return n;
}


int main() {
	int k;
	cin >> k;
	cout << next_prime(k) << endl;

}



Measured memory_bytes: 256