akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[200005];
long long s[200005];
long long cal(long long s[], int nn) {
    if (nn == 1) return 0;
    long long s1[nn/2+2], s2[nn/2+2];
    for(int i = 1; i <= nn/2; ++i) s1[i] = s[i];
    for(int i = nn/2+1; i <= nn; ++i) s2[i-nn/2] = s[i];
    long long ans1 = cal(s1, nn/2);
    long long ans2 = cal(s2, nn-nn/2);
    long long ans3 = 0;
    int j = 0;
    s1[0] = s2[1];
    for(int i = 1; i <= nn-nn/2; ++i) {
        while (j <= nn/2 && s1[j] <= s2[i]) ++j; --j;
        ans3 += j;
    }
    merge(s1+1, s1+1+nn/2, s2+1, s2+1+nn-nn/2, s+1);
    return ans1 + ans2 + ans3;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie();
    cin >> n >> k;
    long long sum =0;
    long long ans = 0;
    s[1] = 0;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        sum = sum + a[i];
        long long t = sum - 1LL*k*i;
        s[i+1] = t;
    }
    ans = cal(s, n+1);
    cout << ans << endl;
}


Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <string.h>

using namespace std;

const int maxn=4005;
typedef long long ll;

string s;
int pref[maxn][3];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	cin >> s;
	for(int i=0; i<n; i++){
		pref[i+1][0]=pref[i][0];
		pref[i+1][1]=pref[i][1];
		pref[i+1][2]=pref[i][2];
		if(s[i]=='R'){
			pref[i+1][0]++;
		}
		else if(s[i]=='G'){
			pref[i+1][1]++;
		}
		else{
			pref[i+1][2]++;
		}
	}
	ll uk=0;
	for(int i=0; i<n-2; i++){
		for(int j=i; j<n-1; j++){
			if(s[i]!=s[j]){
				if(s[i]!='R' && s[j]!='R'){
					uk+=pref[n][0]-pref[j][0];
					if(j*2-i<n){
						if(s[j*2-i]=='R'){
							uk--;
						}
					}
				}
				else if(s[i]!='G' && s[j]!='G'){
					uk+=pref[n][1]-pref[j][1];
					if(j*2-i<n){
						if(s[j*2-i]=='G'){
							uk--;
						}
					}
				}
				else{
					uk+=pref[n][2]-pref[j][2];
					if(j*2-i<n){
						if(s[j*2-i]=='B'){
							uk--;
						}
					}
				}
			}
		}
	}
	cout << uk << '\n';
	return 0;
}

Measured memory_bytes: 3692
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
using namespace std;
const int maxn=1e5+5;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=n-1;i>0;i--){
		cout<<m-i<<" ";
	}
	cout<<m<<" ";
	for(int i=1;i<=n-1;i++){
		cout<<m+i<<" ";
	}
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	map<string, ll>mp;
	for (int i = 0; i < n; i++){
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]++;
	}
	ll ans = 0;
	for (auto i = mp.begin(); i != mp.end(); i++){
		ans += i->second*(i->second - 1) / 2;

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

Measured memory_bytes: 8064
h, w = gets.split.map(&:to_i)
n = gets.to_i
puts gets.split.map(&:to_i).zip((1..n).to_a).flat_map{|a, i| [i] * a}.each_slice(w).each_with_index.map{|a, i| i%2==0 ? a : a.reverse }.map{|a| a.join(' ')}


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

int sum[100002];
int main(){
    int n,t,l,r;
    cin>>n>>t;
    rep(i,n){
        cin>>l>>r;
        ++sum[l],--sum[r];
    }
    int mx=sum[0];
    rep(i,t){
        sum[i+1]+=sum[i];
        mx=max(mx,sum[i+1]);
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
const ll bg = 1000000007;
#define ff(i,n) for(i=0;i<n;i++)
#define vv vector<vector<ll> >
vector<vector<ll> >master [31]; 
int main() 
{
	ll t;
	t=1;
	while(t--)
	{
		ll i,n,d,ans=0;
		cin>>n>>d;	
		ff(i,n)
		{
			ll a,b;
			cin>>a>>b;
			a = abs(a);
			b = abs(b);
			if((a*a+b*b)<=d*d)
			ans++;
		}
		cout<<ans;
	}
    return 0;
}

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

int main() {
	int N,K;
  	cin >> N >> K;
  
  	vector<int> vec(N);
  
  	for(int i = 0; i < N; i++) {
    	cin >> vec.at(i);
    }
  
  	sort(vec.begin(),vec.end());
  	int ans = 0;
  
  	for(int i = N - 1; i > N - 1 - K; i--) {
    	ans += vec.at(i);
    }
  
  	cout << ans << endl;
}

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



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,tem=10,num,k;
    cin>>a>>b;
    while(b>=tem)
    {
        tem*=10;
    }
    num=a*tem+b;
    k=sqrt(num);
    if(k*k==num)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}




Measured memory_bytes: 256
import collections
n = int(input())
h = list(map(int,input().split()))
cnt = [0]
tmp = 0
for i in range(1, n):
  if h[i-1]<h[i]:
    tmp+=1

  cnt.append(tmp)
c = collections.Counter(cnt)
print(c.most_common()[0][1]-1)

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

int w, d;

int main() {
	while (cin >> w >> d) {
		if (!w) break;
		int cnt[2][21] = {0};
		int i, val;
		
		for (i = 0; i < w; i++) { cin >> val; cnt[0][val]++; }
		for (i = 0; i < d; i++) { cin >> val; cnt[1][val]++; }
		
		int ans = 0;
		for (i = 1; i <= 20; i++) {
			ans += i * max(cnt[0][i], cnt[1][i]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <iostream>

using namespace std;

int main() {
  string s, t;
  bool can_match = false;
  cin >> s >> t;
  if (s == t) {
    can_match = true;
    cout << "Yes" << endl;
    return 0;
  }
  int m = s.size();
  // m回の回転を行う
  for (int i = 0; i < 102; i++) {

    // // 一回の回転
    char tmp = s[m - 1];
    for (int j = m - 2; j >= 0; j--) {
      s[j+1] = s[j];
    }
    s[0] = tmp;
    //cout << s << endl;
    if (s == t) {
      cout << "Yes" << endl;
      can_match = true;
      return 0;
    }
  }
  if (!can_match) {
    cout << "No" << endl;
  }
}


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

int main() {
  string a;
  cin>>a;
  if(a=="RRR")cout<<3<<endl;
  else if(a=="RRS"||a=="SRR")cout<<2<<endl;
  else if(a=="RSS"||a=="SRS"||a=="SSR"||a=="RSR")cout<<1<<endl;
  else if(a=="SSS")cout<<0<<endl;
}

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

lli a[404];
lli dp[404][404];
lli s[404];

lli func(lli l,lli r){
    if(dp[l][r]!=-1) return dp[l][r];
    if(l==r) return dp[l][r]=0;
    if(l>r) return 0;
    lli res = 100000000000000;
    for(lli i=l;i<r;i++){
        lli j = func(l,i);
        j = j + func(i+1,r);
        if(l>0) j = j + s[r] - s[l-1];
        else j=j + s[r];
        res = min(res, j);
    }
    return dp[l][r] = res;
}

int main() {
    lli n,i,j,l;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(i=0;i<n;i++){
        cin>>a[i];
        s[i]=0;
        if(i>0) s[i]=s[i-1]+a[i];
        else s[i]=a[i];
    }
    lli ans=100000000000000;
    for(i=0;i<n-1;i++){
        j = func(0,i);
        j = j + func(i+1,n-1);
        j = j + s[n-1];
        ans = min(ans, j);
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1536
object Main extends App {
  type Point = (Int, Int)
  type Cost = Int
  type Path = Seq[(Int, Int)]
  val Array(h, w) = io.StdIn.readLine().split(' ').map(_.toInt)
  val field = Array.fill(h)(io.StdIn.readLine().toCharArray)
  val taken = Array.fill(h)(Array.fill(w)(Int.MaxValue))
  val heap = scala.collection.mutable.PriorityQueue.empty[(Point, Cost, Path)](Ordering.by(-_._2))
  heap.enqueue(((0,0), 0, Seq((0, 0))))
  def loop(): Cost = {
    if (heap.isEmpty) -1
    else {
      val ((x, y), cost, path) = heap.dequeue()
      if (x == w-1 && y == h-1) {
        var score = 0
        for (j <- 0 until h; i <- 0 until w; if !path.contains(i, j) && field(j)(i) == '.') score += 1
        score
      } else {
        val nextCost = cost + 1
        Seq((x,y-1),(x,y+1),(x-1,y),(x+1,y))
          .withFilter(p => p._1 >= 0 && p._1 < w && p._2 >= 0 && p._2 < h)
          .withFilter(p => (field(p._2)(p._1) != '#') && nextCost < taken(p._2)(p._1))
          .foreach{p => taken(p._2)(p._1) = nextCost; heap.enqueue((p, nextCost, p +: path))}
        loop()
      }
    }
  }
  println(loop())
}

Measured memory_bytes: 29288
#include <cstdio>
using namespace std;
int main(){
  char a[101]={};
  scanf("%s",a);
  int ans=0;
  for(int i=0;a[i]!=0;i++){
    if(a[i]=='C'&&ans==0)ans++;
    if(a[i]=='F'&&ans==1)ans++;
  }
  if(ans==2)printf("Yes");
  else printf("No");
}


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

using namespace std;
const int N=2e3+5,mod=1e9+7;
#define ll long long
bool vis[N];
int a[N][N];
string g[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>g[i];
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int cnt;
        for(int j=0;j<m;j++){
            cnt=0;
            while(j<m&&g[i][j]=='.')
            {
                cnt++;
                a[i][j]+=cnt;
                ans=max(ans,a[i][j]);
                j++;
            }
        }
        for(int j=m-1;j>=0;j--){
            cnt=0;
            while(j>=0&&g[i][j]=='.')
            {
                cnt++;
                a[i][j]+=cnt;
                ans=max(ans,a[i][j]);
                j--;
            }
        }
    }
    for(int j=0;j<m;j++)
    {
        int cnt;
        for(int i=0;i<n;i++){
            cnt=0;
            while(i<n&&g[i][j]=='.')
            {
                cnt++;
                a[i][j]+=cnt;
                ans=max(ans,a[i][j]);
                i++;
            }
        }
        for(int i=n-1;i>=0;i--){
            cnt=0;
            while(i>=0&&g[i][j]=='.')
            {
                cnt++;
                a[i][j]+=cnt;
                ans=max(ans,a[i][j]);
                i--;
            }
        }
    }
    cout<<ans-3<<endl;
    return 0;
}


Measured memory_bytes: 20224
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;
int main() {
	int n=0;
	string src;

	vector<char> ch;

	vector<int> renum, rwnum;
	vector<int> lenum, lwnum;

	cin >> n;
	cin >> src;



	int max=0;
	int h = 0;
	string s1, s2;

	int he=0,hw=0;
	for (auto e : src) {
		if (e == 'E') {
			he++;

		}
		else if(e == 'W') {
			hw++;
		}
		renum.push_back(he);
		rwnum.push_back(hw); //

	}

	he = 0;
	hw = 0;

	for (auto i = src.rbegin(), e = src.rend(); i != e; ++i) {
		if (*i == 'E') {
			he++;

		}
		else if (*i == 'W') {
			hw++;
		}
		lenum.push_back(he); //
		lwnum.push_back(hw);
	}


	int hog = 0;
	int min = 4000000;
	for (int i = 0; i < n-1; i++) {
		hog = rwnum[i] + lenum[n-2-i];
		if (hog < min) {
			min = hog;
		}

	}

	if (lenum.back() < min) {
		min = lenum.back();
	}

	if (rwnum.back() < min) {
		min = rwnum.back();
	}

	printf("%d",min);
	
	return 0;
}

Measured memory_bytes: 7536
import sys

n, a, *x = map(int, sys.stdin.read().split())

def main():
    for i in range(n):
        x[i] -= a
    x.sort()

    res = [[0] * 99*n for _ in range(n+1)]
    # res[i][49*n]を中心とする。
    res[0][49*n] = 1
    for i in range(n):
        for j in range(99*n):
            res[i+1][j] += res[i][j]
            cur = x[i]
            if cur >= 0:
                if j >= cur:
                    res[i+1][j] += res[i][j-cur]
            else:
                if j - cur <= 99 * n - 1:
                    res[i+1][j] += res[i][j-cur]
    
    ans = res[n][49*n] - 1
    return ans
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 5604
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
    int n, S[14], H[14], C[14], D[14];
    cin >> n;
    char mark[2];
    int num;
    for (int i = 0; i < 14; i++) S[i] = H[i] = C[i] = D[i] = 0;
    for (int i = 0; i < n; i++) {
        scanf("%s %d", mark, &num);
        switch (mark[0]) {
        case 'S':
            S[num] = 1;
            break;
        case 'H':
            H[num] = 1;
            break;
        case 'C':
            C[num] = 1;
            break;
        case 'D':
            D[num] = 1;
            break;
        }
    }

    for (int i = 1; i <= 13; i++) {
        if (S[i] == 0) cout << "S " << i << endl;
    }

    for (int i = 1; i <= 13; i++) {
        if (H[i] == 0) cout << "H " << i << endl;
    }

    for (int i = 1; i <= 13; i++) {
        if (C[i] == 0) cout << "C " << i << endl;
    }

    for (int i = 1; i <= 13; i++) {
        if (D[i] == 0) cout << "D " << i << endl;
    }

}


Measured memory_bytes: 3224
import java.io.{InputStream, OutputStream, PrintStream}
import java.util.Scanner

object Main {

  def main(args: Array[String]): Unit = {
    val solver = new Solver(System.in, System.out)
    solver.solve()
  }

  class Solver(in: InputStream, out: OutputStream) {
    lazy val input = new Scanner(in)

    lazy val output = new PrintStream(out)

    def solve(): Unit = {
      val n  = input.nextLine().toInt
      val vs = input.nextLine().split(" ").map(_.toInt)

      val (tops, bottoms) = vs.zipWithIndex.partition { case (v, i) => i % 2 == 0 }

      val results = for {
        (topVal, topCount) <- tops
          .map(_._1)
          .groupBy(identity)
          .map { case (v, vs) => (v, vs.size) }
          .toSeq
          .sortBy(-_._2)
          .take(2)
        (bottomVal, bottomCount) <- bottoms
          .map(_._1)
          .groupBy(identity)
          .map { case (v, vs) => (v, vs.size) }
          .toSeq
          .sortBy(-_._2)
          .take(2)
        if topVal != bottomVal
      } yield n - topCount - bottomCount

      if (results.isEmpty) {
        println(n/2)
      } else {
        println(results.min)
      }

    }

  }

}


Measured memory_bytes: 136172
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define MAX 200005
#define INF 1001001001

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  string s;
  cin >> s;
  int n=s.length();
  int rnum=1, lnum=0, rin, lin;
  vector<int> ans(n);
  bool rsuc=true, lsuc=false;
  repo(i, n-1){
    if(s[i]=='R' && rsuc){
      rnum++;
    } else if(s[i]=='L' && rsuc){
      lsuc=true;
      rsuc=false;
      lnum=1;
      rin=i-1;
      lin=i;
    } else if(s[i]=='R' && lsuc){
      ans[rin]=(rnum+1)/2+lnum/2;
      ans[lin]=rnum/2+(lnum+1)/2;
      rsuc=true;
      lsuc=false;
      rnum=1;
    } else {
      lnum++;
    }
  }
  ans[rin]=(rnum+1)/2+lnum/2;
  ans[lin]=rnum/2+(lnum+1)/2;
  rep(i, n){
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}



void solve(long long A, long long B, long long C, long long D, long long E){
    int hoge = (A+9)/10 + (B+9)/10 + (C+9)/10 + (D + 9) / 10 + (E+9)/10;
    hoge *= 10;
    vector<int> geko;
    geko.push_back(A%10);
    geko.push_back(B%10);
    geko.push_back(C%10);
    geko.push_back(D%10);
    geko.push_back(E% 10);
    sort(geko.begin(),geko.end());
    for(int i = 0;i < geko.size();++i){
        if(geko[i] != 0){
            hoge -= 10 - geko[i];
            cout << hoge << endl;
            return;
        }
    }
    cout << hoge << endl;
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    long long E;
    scanf("%lld",&E);
    solve(A, B, C, D, E);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

bool f(string& s){
  for(int i = 1; i < s.length(); i++){
    if(s[i] != s[0]) return false;
  }
  return true;
}

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

  int n;
  cin >> n;

  int ans = n;
  while(true){
    string t = to_string(ans);
    if(f(t)) break;
    ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 504
import sys

def postordered_tree_walk(preordered, inordered, route):
    def work(pos, l_in, r_in):
        if (l_in >= r_in): return

        root_id = preordered[pos]
        split_point = inordered.index(root_id, l_in, r_in)

        work(pos + 1, l_in, split_point)
        work(pos + (split_point - l_in) + 1, split_point + 1, r_in)
        route.append(root_id)

    work(0, 0, len(inordered))

n = int(input())
preordered_route = list(map(int, sys.stdin.readline().split()))
inordered_route = list(map(int, sys.stdin.readline().split()))

postordered = []
postordered_tree_walk(preordered_route, inordered_route, postordered)

print(*postordered)


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

int main() {
	int n; cin >> n;
	vector<double> a(n); rep(i, 0, n) cin >> a[i];

	vector<double> b(n);
	rep(i, 0, n) {
		b[i] = (double)1 / a[i];
	}
	double sum = 0;
	rep(i, 0, n) {
		sum += b[i];
	}

	cout << fixed << setp(6) << (double) 1 / sum << endl;

	return 0;
}

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

int main()
{ 
  string s = "", t = "", x;
  char c;
  int sn, tn;

  cin >> x;
  s += x[0];
  s += x[1];
  t += x[2];
  t += x[3];
  sn = stoi(s);
  tn = stoi(t);
  cout << (sn <= 12 && sn != 0 && tn <= 12 && tn != 0? "AMBIGUOUS" : sn <= 12 && sn != 0 ? "MMYY" : tn <= 12 && tn != 0 ? "YYMM" : "NA") << endl;
}

Measured memory_bytes: 256
s=input()
l=len(s)
se=dict()
k=0
for i in range(l-1,-1,-1):
    k+=(pow(10,l-1-i,2019)*int(s[i]))
    k%=2019
    if k in se:
        se[k]+=1
    else:
        se[k]=1

ans=0
for j in se:
    i=se[j]
    if i>1:
        ans+=(i*(i-1)//2)
    if j==0:
        ans+=i
print(ans)

Measured memory_bytes: 68868
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;

ll divisors[1000005]={0};
ll vis[1000005]={0};
/***************/
 #define amin main
/***************/

ll exp(ll x, ll n)
{if(n==0) return 1;if(n==1) return x%INF;if(n%2==0) return exp((x*x)%INF,n/2); else return(x*exp((x*x)%INF,n/2))%INF;}

  

int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j;
	ll n;
	cin>>n;
	ll arr[n];
	ll gi=0;
	ll cnt= 0;
	ll flag =0;
	ll we =0;
	for(i=0;i<n;i++)
		{
			cin>>arr[i];
			if(arr[i]==1)
				we=1;
			//vis[arr[i]]=1;
			if(vis[arr[i]]>=1)
				vis[arr[i]]++;
			else
				vis[arr[i]]=1;
			gi = max(gi,arr[i]);
		}
		if(n==1)
			cout<<1<<endl;
		else if(we==1 && vis[1]==1)
			cout<<1<<endl;
		else{
	for(i=0;i<n;i++)
	{
		flag =0;
		for(j=1;j<=(ll)sqrt(arr[i]);j++)
		{
			//cout<<"hey"<<endl;
			if(arr[i]%j==0)
				{
					//cout<<"hey1"<<endl;
					if(vis[j]>=1)
						{
							//cout<<"hey"<<endl;
							flag=1;
							break;
						}
					
				
			  if (j != arr[i] / j) 
                   {

                   		if(vis[arr[i]/j]>=1 && j!=1)
                   		{
                   			//if(i==0)
                   			//cout<<"hey2"<<j<<endl;
                   			flag =1;
                   			break;
                   		}
                   		if(vis[arr[i]/j]>1)
                   		{
                   			flag=1;
                   			break;

                   		}
                   
                   }  
               }
                  
		}
		

		if(flag==0)
		{
			cnt++;
			//cout<<arr[i]<<endl;
		}
	}

	
	cout<<cnt<<endl;
}
	

	


	
	

	
	


	
	return 0;
}

Measured memory_bytes: 12908
unittest
{
	assert( [ "6", "G W Y P Y W" ].parse.expand.solve == "Four" );
	assert( [ "9", "G W W G P W P G G" ].parse.expand.solve == "Three" );
	assert( [ "8", "P Y W G Y W Y Y" ].parse.expand.solve == "Four" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto ss = input.front.split.to!( string[] );
	return tuple( ss );
}

auto solve( string[] ss )
{
	return ( ss.sort().uniq.count == 3 ) ? "Three" : "Four";
}


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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}
 
inline void fast_io(){ios_base::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple
 
short B[3000300];
int H[2048], W[2048];
int main()
{
  int N, M;
  short K = 0;
  while (N = in(), M = in()){
    K++;
    for (int i = 1; i <= N; i++){
      H[i] = H[i - 1] + in();
      B[H[i]] = K;
    }
    for (int i = 1; i <= M; i++){
      W[i] = W[i - 1] + in();
    }
    int ans = 0;
    for (int y = 0; y < N; y++){
      for (int x = 0; x < M; x++){
        for (int z = x + 1; z <= M; z++){
          int d = W[z] - W[x];
          if (H[N] - H[y] < d) break;
          ans += B[H[y] + d] == K;
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 2184
def solve(r, T):
    d = [int(i[0]) for i in r if int(i[1]) <= T]
    if len(d):
        return min(d)
    else:
        return "TLE"


if __name__ == "__main__":
    N, T = tuple(input().split(" "))
    r = [input().split(" ") for i in range(int(N))]
    print(solve(r, int(T)))


Measured memory_bytes: 3060
#include"bits/stdc++.h"
using namespace std;
int main(){
        int n,i,j,mul;
        scanf("%d",&n);
        for(i=1;i<=9;i++){
                mul=0;
            for(j=1;j<=9;j++){
                mul=i*j;
                 if(mul==n){
            printf("Yes");
            return 0;
        }

            }
        }
        if(mul!=n){
            printf("No");
        }


return 0;

}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
using namespace std;

int main()
{
	int n;
	int number;
	ll int sum = 0LL;
	int cmin = 0;
	int min = MOD_P;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> number;
		if (number < 0) {
			number*= -1;
			cmin++;
		}
		if (number < min) {
			min = number;
		}
		sum += (ll int)number;
	}

	if (cmin % 2) {
		sum -= 2LL * (ll int)min;
	}

	printf("%lld", sum);

	return 0;
}

Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <functional>
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int H,W;
vector<vector<bool>> used;
vector<string> G;
int cnt = 0;
bool ok = true;

bool solve(){
  cin >> W >> H;
  if(H==0 && W==0) return false;
  G = vector<string>(H);
  used = vector<vector<bool>>(H,vector<bool>(W,false));
  for(int i=0; i<H; i++){
    cin >> G[i];
  }
  function<void(int,int,char)> dfs = [&dfs](int h,int w,char c) -> int{
    used[h][w] = true;
    cnt++;
    for(int k=0; k<4; k++){
      int ny = h + dy[k];
      int nx = w + dx[k];
      if(ny<0 || ny>=H || nx<0 || nx>=W) continue;
      if(used[ny][nx]) continue;
      if(G[ny][nx] == c) continue;
      if(G[ny][nx]!=c && G[ny][nx]!='.'){
        ok = false;
        continue;
      }
      dfs(ny,nx,c);
    }
  };
  map<char,int> mp;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(G[i][j] != '.'){
        for(int k=0; k<4; k++){
          int ny = i + dy[k];
          int nx = j + dx[k];
          if(ny<0 || ny>=H || nx<0 || nx>=W) continue;
          if(used[ny][nx]) continue;
          if(G[ny][nx] != '.') continue;
          ok = true;
          cnt = 0;
          dfs(ny,nx,G[i][j]);
          if(ok){
            mp[G[i][j]] += cnt;
          }
        }
      }
    }
  }
  cout << mp['B'] << " " << mp['W'] << "\n";
  return true;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  while(solve());
  return 0;
}


Measured memory_bytes: 3392
import sys
input=sys.stdin.readline
from operator import itemgetter
n,q=map(int,input().split())
c=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(q)]
for i in range(q):
  l[i].append(i)
l.sort(key=lambda x:x[1])

L=[-1]*(5*10**5+1)

class Bit:
  def __init__(self,n):
    self.size=n
    self.tree=[0]*(n + 1)
    self.depth=n.bit_length()

  def sum(self,i):
    s=0
    while i>0:
      s+=self.tree[i]
      i-=i&-i
    return s

  def add(self,i,x):
    while i<=self.size:
      self.tree[i]+=x
      i+=i&-i

BIT=Bit(n+1)

ans=[0]*q
ct=0
for i in range(q):
  while ct<=l[i][1]:
    if L[c[ct-1]-1]!=-1:
      BIT.add(L[c[ct-1]-1],-1)
    L[c[ct-1]-1]=ct+1
    BIT.add(ct+1,1)
    ct+=1
  ans[l[i][2]]=BIT.sum(l[i][1]+1)-BIT.sum(l[i][0])

for i in ans:
  print(i)

Measured memory_bytes: 232316
#include<bits/stdc++.h>
using namespace std;
void ng(){cout<<"No"<<endl;exit(0);}
int p[324000],n;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){cin>>p[i];if(i%2==p[i]%2)ng();}
	for(int i=n-3;i>=0;i--)if(p[i]>p[i+1]&&p[i+1]>p[i+2])swap(p[i],p[i+2]);
	for(int i=1;i<n-1;i++)if((p[i-1]>p[i+1])&&(p[i-1]<p[i]||p[i]<p[i+1]))ng();
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] a = new int[N];
        int[] color = new int[8];
        int legend = 0;
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
            int index = color(a[i]);
            if (index != -1) {
                color[index] += 1;
            } else {
                legend += 1;
            }
        }
        int minimum = 0;
        for (int i = 0; i < 8; i++) {
            if (0 < color[i]) {
                minimum += 1;
            }
        }
        if (minimum == 0) {
            System.out.println(1 + " " + (minimum + legend));
        } else {
            System.out.println(minimum + " " + (minimum + legend));
        }
    }
    private static int color(int score) {
        if (score < 400) {
            return 0;
        }
        if (score < 800) {
            return 1;
        }
        if (score < 1200) {
            return 2;
        }
        if (score < 1600) {
            return 3;
        }
        if (score < 2000) {
            return 4;
        }
        if (score < 2400) {
            return 5;
        }
        if (score < 2800) {
            return 6;
        }
        if (score < 3200) {
            return 7;
        }
        return -1;
    }
}


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

typedef long long int ll;

int main( void )
{
	int n;
	std::cin >> n;

	std::vector<ll> b( n );
	for( int i = 0; i < n; i++ ) {
		std::cin >> b[ i ];
		b[ i ] = b[ i ] - ( i + 1 );
	}

	std::sort( b.begin(), b.end() );

	ll med = b[ n / 2 ];
	ll ans = 0;
	for( int i = 0; i < n; i++ ) {
		ans = ans + std::abs( b[ i ] - med );
	}
	
	std::cout << ans << std::endl;
	return 0;
}


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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll a, b, n; gi(a), gi(b), gi(n);
	if(n >= b) {
		print((a*(b-1))/b - (a*((b-1)/b)));
		return 0;
	}
	print((a*n)/b - (a*(n/b)));
}


Measured memory_bytes: 3632
A = list([0] * 10 for x in range(3))
B = list([0] * 10 for x in range(3))
C = list([0] * 10 for x in range(3))
D = list([0] * 10 for x in range(3))

official_house = [A, B, C, D]

n = int(input())

for i in range(n):
    b, f, r, v = map(int, input().split())
    official_house[b - 1][f - 1][r- 1] += v

for i, b in enumerate(official_house):
    for f in b:
        print("", " ".join(map(str, f)))
    if i != len(official_house) - 1:
        print("####################")


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
const int MOD = 1000000007;

int fib(int x){
  int i=1,ans=1,a=1,b=1;
  if(x==-1) ans=0;
  else if(x&&x!=1) while(i<x){
    ans=(a+b)%MOD;
    a=b;
    b=ans;
    i++;
  } 
  return ans;
}

int main(){
  int n,m,ans=1;cin>>n>>m;
  vector<int> x(m+2,0);
  x.at(0)=-1;
  x.at(m+1)=n+1;
  for(int i=1;i<m+1;i++) cin>>x.at(i);
  for(int i=0;i<m+1;i++){
    int num=fib(x.at(i+1)-x.at(i)-2);
    ans=(int)(((long long)ans*(long long)num)%MOD);
  }
  cout<<ans;
}

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

int main() {
  int N;
  cin >> N;
  int count = 0;
  bool a = false;
  vector<int> A(N), B(N);
  for(int i =0 ; i < N; i++){
    cin >> A.at(i) >> B.at(i);
    if(A.at(i) == B.at(i)){
      count++;
      if(count == 3){
        a = true;
        break;
      }
    }
    else count = 0;
  }
  
  if(a) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>

using namespace std;

typedef long long ll;
ll mod = 1e9+7;

int main() {
    ll h, w;    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++)
        cin >> s[i];

    vector<vector<ll> > dp(h, vector<ll>(w, 0));
    dp[0][0] = 1;
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#')
                dp[i][j] = 0;
            if (i+1 < h) {
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= mod;
            }
            if (j+1 < w) {
                dp[i][j+1] += dp[i][j];
                dp[i][j+1] %= mod;
            }
        }
    }

    cout << dp[h-1][w-1] << endl;

    return 0;
}


Measured memory_bytes: 13004
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void qmax(int &x,int y) {if (x<y) x=y;}
void qmin(int &x,int y) {if (x>y) x=y;}
inline int read()
{
	char s;
	int k=0,base=1;
	while((s=getchar())!='-'&&s!=EOF&&!(isdigit(s)));
	if(s==EOF)exit(0);
	if(s=='-')base=-1,s=getchar();
	while(isdigit(s)){k=k*10+(s^'0');s=getchar();}
	return k*base;
}
inline void write(int x)
{
	static char cnt,num[15];cnt=0;
	if (!x)
	{
		putchar('0');
		return;
	}
	for (;x;x/=10) num[++cnt]=x%10;
	for (;cnt;putchar(num[cnt--]+48));
}
char ch[30];
int Map[30],n;
int main()
{
	scanf("%s",ch+1); 
	n=strlen(ch+1);
	if (n!=26)
	{
		for (int i=1;i<=n;i++) Map[ch[i]-'a']=1;
		printf("%s",ch+1);
		for (int i=0;i<26;i++)
		if (!Map[i])
		{
			printf("%c",i+'a');
			return 0;
		}
	}
	int p=n-1;
	for (;p>=0;p--)
	{
		if (ch[p]<ch[p+1]) break; 
	}
	if (p==0)
	{
		printf("-1");
	}
	int j=n;while (ch[j]<ch[p]) j--;
	ch[p]=ch[j];
	for (int i=1;i<=p;i++) printf("%c",ch[i]);
	return 0;
} 



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

using namespace std;

#define f first
#define s second
#define pb push_back
#define np next_permutation
#define bs binary_search
#define mp make_pair
#define all(x) x.begin(), x.end()
#define bp __builtin_popcountll
#define sqr(x) ((llong)sqrt (x))
#define b_ctz __builtin_ctzll
#define b_clz __builtin_clzll

#define y1 road_to_respa_top_6
#define prev road_to_respa_top_6
#define Abdrakhman abcdefghijklmnopqrstuvwxyzRakhman
#define left kotoriy_levee_chem_right
#define right kotoriy_pravee_chem_left

#define android ios_base::sync_with_stdio(0), cin.tie (0), cout.tie (0)
#define fn ""

typedef long long llong;
typedef long double ldouble;
typedef unsigned long long ullong;

typedef vector <int> vi;
typedef vector <string> vs;
typedef vector <vector <llong> > matrix;

typedef pair <llong, llong> pll;
typedef pair <int, int> pii;

typedef map <int, int> mii;

typedef set <llong> sl;

const int MXN = 1e6 + 1;
const llong MNN = 1e3 + 1;
const llong MOD = 1e9 + 7;
const int INF = 1e9;
const llong LINF = 1e18;
const llong MAGIC = 1000;
const ldouble EPS = 1e-9;
const ldouble PI = 3.1415926536;
const string TIME = "rovno_ushten_push_ketti";

inline llong log2 (llong x) {return 64 - b_clz (x) - 1;};
inline llong __lcm (llong a, llong b) {return a / __gcd (a, b) * b;}

string s, t;

int main () {
    android;
    //freopen ("input.txt", "r", stdin);
    cin >> s >> t;
    for (int i = 1; i <= s.size (); i ++) {
        string x = "";
        x += s[s.size () - 1];
        for (int j = 0; j < s.size () - 1; j ++) {
            x += s[j];
        }
        s = x;
        if (s == t) return cout << "Yes", 0;
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
n,m,k=map(int,input().split())
ans="No"
for i in range(n+1):
  if (2*i-n)==0:
    if k==m*n//2:
      ans="Yes"
  else:
    if (k-n*m+m*i)%(2*i-n)==0 and 0<=(k-n*m+m*i)//(2*i-n)<=m:
      ans="Yes"
print(ans)

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;


string s, t;
ll dp[3010][3010];
int main(){
	cin >> s >> t;
	REP(i, 0, s.size()){
		REP(j,0,t.size()){
			if(s[i] == t[j]){
				if(dp[i+1][j+1] < dp[i][j] + 1){
					dp[i+1][j+1] = dp[i][j] + 1;
				}
			}

			if(dp[i+1][j+1] < dp[i+1][j]){
				dp[i+1][j+1] = dp[i+1][j];
			}
			if(dp[i+1][j+1] < dp[i][j+1]){
				dp[i+1][j+1] = dp[i][j+1];
			}
		}
	}

	string ans = "";
	ll i = s.size(), j = t.size();
	while (i > 0 && j > 0)
	{
		if (dp[i][j] == dp[i-1][j]) {
			--i;
		}
		else if (dp[i][j] == dp[i][j-1]) {
			--j;
		}
		else {
			ans = s[i-1] + ans;
			--i, --j;
		}
	}
	p(ans);
	return 0;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using ll=long long;
using namespace std;
const long MOD=1e9+7;
template<class T>
T lcm(T a,T b){
    return a/__gcd(a,b)*b;
}

int main(){
    long n;cin >> n;
    long long pow=1;
    for(long i=1;i<=n;i++){
        pow=(pow*i)%MOD;
    }
    cout << pow;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Map<Integer, Integer> map = new HashMap<Integer, Integer>();
    for (int i = 1; i < N + 1; i++)
      map.put(i, sc.nextInt());
    System.out.println(String.join(" ", map.entrySet().stream().sorted(Entry.<Integer, Integer>comparingByValue()).map(Map.Entry::getKey).map(String::valueOf).collect(Collectors.toList())));
  }
}

Measured memory_bytes: 76632
#include<bits/stdc++.h>
using namespace std;
const int SIZE = 102;
int D[SIZE][2];
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>D[i][0]>>D[i][1];
    }
    for(int i=0;i+2<n;i++){
        bool suc=1;
        for(int j=0;j<3;j++){
            if(D[i+j][0]!=D[i+j][1])suc=0;
        }
        if(suc){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3672
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
#define int long long
using namespace std;
using point = pair< int,int >;

signed main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a && b && !c || !a && !b && c) {
        OUT("Open");
    } else {
        OUT("Close");
    }
    return 0;
}




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

int main(void) {
  int n; cin >> n;
  string s; cin >> s;
  int cnt = 0;
  vector<int> cnts;
  
  cnts.push_back(cnt);
  for (int i=0; i<n; i++) {
    if (s[i] == 'I') cnt++;
    if (s[i] == 'D') cnt--;
    cnts.push_back(cnt);
  }
  
  cout << *max_element(cnts.begin(), cnts.end()) << endl;
  return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>
int main(void)
{
  int f=0;
  char s[6];
  scanf("%s",s);
  if(s[2]==s[3]){
    if(s[4]==s[5]) f=1;
  }
  if(f==1) printf("Yes");
  else printf("No");
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<bitset>
#define LL long long
#define MINF (-1000000000000000)
int N;
int F[101][11];
LL P[101][101];
LL ans = MINF;
std::bitset<10> BB;
int main() {
	std::cin >> N;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= 10; j++) {
			std::cin >> F[i][j];
		}
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= 10; j++) {
			std::cin >> P[i][j];
		}
	}
	for (int i = 1; i < 1024; i++) {
		BB = i;
		LL sum = 0;
		for (int j = 1; j <= N; j++) {
			int c = 0;
			for (int k = 1; k <= 10; k++) {
				if (BB[k - 1] == 1 && F[j][k] == 1) {
					c++;
				}
			}
			sum += P[j][c];
		}
		ans = std::max(ans, sum);
	}
	std::cout << ans << std::endl;
	return 0;
}

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

#define LL long long

int main(){
    LL n;
    cin>>n;
    vector<LL>a(n);
    vector<LL>b(n);
    for(LL i=0;i<n;i++){
        cin>>a[i];
    }
    b=a;
    sort(b.begin(),b.end());
    for(LL i=0;i<n;i++){
        if(a[i]!=b[n-1]){
            cout<<b[n-1]<<endl;
        }
        else cout<<b[n-2]<<endl;
    }
    return 0;
}


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

int main(){
  int n,k;
  cin>>n>>k;
  
  vector<int>sunuke(n);
  rep(i,n)sunuke[i]=0;
  rep(i,k){
    int d;
    cin>>d;
    int temp=0;
    rep(j,d){
      cin>>temp;
      sunuke[temp-1]++;
    }
  }
  int ans=0;
  rep(i,n)if(sunuke[i]==0)ans++;  
  cout<<ans<<endl;
  return 0;
}

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

int main(){
  int w,h;
  int map[30][30];		//?£???????,???,???,??????????????????????????????1,2,4,8????????????
  while(cin >> w >> h && w>0 && h>0){
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
        map[i][j]=0;

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(i==0) map[i][j]|=1;
        else{
          int wall;
          cin >> wall;
          if(wall==1){
            map[i-1][j]|=8;
            map[i][j]|=1;
          }
        }
        if(i==h-1) map[i][j]|=8;
      }

      map[i][0]|=2;
      for(int j=1;j<w;j++){
        int wall;
        cin >> wall;
        if(wall==1){
          map[i][j-1]|=4;
          map[i][j]|=2;
        }
      }
      map[i][w-1]|=4;
    }

    int d[30][30];
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
        d[i][j]=0;

    d[0][0]=1;
    queue<int> cur;
    cur.push(0*w+0);
    int sh[4]={-w,-1,1,w};

    while(!cur.empty()){
      for(int i=0;i<4;i++){
        if((map[cur.front()/w][cur.front()%w] & (1<<i))==0 && d[(cur.front()+sh[i])/w][(cur.front()+sh[i])%w]==0){
          d[(cur.front()+sh[i])/w][(cur.front()+sh[i])%w]=d[cur.front()/w][cur.front()%w]+1;
          cur.push(cur.front()+sh[i]);
        }
      }
      cur.pop();
    }

    cout << d[h-1][w-1] << endl;
  }

  return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<pair<ll,ll>> a(n);
  rep(i,n){
    ll c,b;
    cin >> c>>b;
    a.at(i)=make_pair(b,c);
  }
  sort(a.begin(),a.end());
  ll sum=0;
  string s="Yes";
  rep(i,n){
    sum+=a.at(i).second;
    if(sum>a.at(i).first){
      s="No";
    }
  }
  cout << s;
}
    

Measured memory_bytes: 6412
from collections import deque

N, D, A = map(int, input().split())
X = []
for _ in range(N):
    x, h = map(int, input().split())
    X.append((x, h))
X = sorted(X)[::-1]
Q = deque([])

ans = 0
k = 0
while X:
    if len(Q) == 0 or X[-1][0] <= Q[0][0]:
        x, h = X.pop()
        h = max(h - k * A, 0)
        a = (h + A - 1) // A
        ans += a
        k += a
        deque.append(Q, (x + 2 * D, a))
    else:
        x, a = deque.popleft(Q)
        k -= a

print(ans)

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

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

S = input()

if S == "Sunny":
    print("Cloudy")
elif S == "Cloudy":
    print("Rainy")
else:
    print("Sunny")



Measured memory_bytes: 8968