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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

const ll mod = 1000000000 + 7;

int n, k;
ll p[5000000], pinv[5000000], inv[5000000], dp[3000];

ll binom(int n, int k) {
  return (((p[n] * pinv[n - k]) % mod) * pinv[k]) % mod;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n >> k;
	p[0] = p[1] = pinv[0] = pinv[1] = inv[1] = 1;
	for (int i = 2; i <= n * k; i++)
		inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod, p[i] = (p[i - 1] * i) % mod, pinv[i] = (pinv[i - 1] * inv[i]) % mod;
  if (k == 1) {
    cout << "1\n";
    return 0;
  }
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = i; j >= 0; j--)
      dp[j + 1] = (dp[j + 2] + dp[j] * binom(i * k - j + k - 2, k - 2)) % mod;
    dp[0] = dp[1];
    // for (int j = 0; j <= i + 1; j++)
    //   cerr << dp[j] << (j < i + 1 ? " " : "\n");
  }
  cout << (dp[0] * p[n]) % mod << "\n";
}


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

using namespace std;

int main() {
    string s;
    int k;
    cin >> s >> k;
    vector<string> sub;
    for (int i = 1; i <= 5 && i <= s.size(); ++i) {
        for (int j = 0; j <= s.size() - i; ++j) {
            sub.push_back(s.substr(j, i));
        }
    }
    sort(sub.begin(), sub.end());
    sub.erase(unique(sub.begin(), sub.end()), sub.end());
    cout << sub.at(k - 1) << endl;
    return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <complex>
#include <vector>
#include <cmath>
using namespace std;

#define EPS 1e-7
#define INF 360
#define PI M_PI


int N, M;

typedef complex<double> Point;

namespace std{
	bool operator < (const Point &a, const Point &b){
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
	Point operator / (const Point &p, const double &a){
		return Point(real(p)/a, imag(p)/a);
	}
	Point operator * (const Point &p, const double &a){
		return Point(real(p) * a, imag(p)*a);
	}
	bool operator == (const Point &a, const Point &b){
		return real(a) == real(b) && imag(a) == imag(b);
	}
}
struct Line : public vector<Point>{
	Line(){}
	Line (const Point &a, const Point &b){
		push_back(a); push_back(b);
	}
};

double distancePP(const Point &a, const Point &b){
	return abs(a-b);
}

double cross(const Point &a, const Point &b){
	return imag(conj(a)*b);
}

double dot(const Point &a, const Point &b){
 return real(conj(a) * b);
}



int main(void){
	int n,m;
	int x, y, px, py;
	double d, pd;
	while(cin >> n , n){
		vector<vector<double> > lines(n+1);
		vector<vector<int> > dists(n+1);
		for(int i = 0; i <= n; i++){
			cin >> m;
			for(int j = 0; j < m; j++){
				cin >> x >> y;
        if (j == 0){
        }else{
          d = (x == px ? y-py : x-px);
          lines[i].push_back(distancePP(Point(px,py), Point(x,y)));
          if (j != 1) {
          	int f;
            if (x == px) {
              f = ( pd * d > 0 ?  1 : -1 );
            } else {
              f = ( pd * d > 0 ? -1 :  1 );
            }
            dists[i].push_back(f);
          }
        }
        px = x; py = y; pd = d;
      }
		}
		for(int i = 1; i < lines.size(); i++){
//printf("line [%d %d] dists[%d %d]\n", lines[i].size(), lines[n].size(), dists[i].size(), dists[n].size());
			if(lines[i].size() != lines[0].size() || dists[i].size() != dists[0].size()) continue;
			int f = 1;
			for(int j = 0; j < lines[i].size(); j++){
//				cout << "lines : " << lines[i][j] << ":" << lines[0][j] << endl;
				if(lines[i][j] != lines[0][j]) f = 0;
			}
			for(int j = 0; j < dists[i].size(); j++){
//				cout << "dists : " << dists[i][j] << ":" << dists[0][j] << endl;
				if(dists[i][j] != dists[0][j]) f = 0;
			}
			if(f){ cout << i << endl; continue;}
			f = 1;
			for(int j = 0; j < lines[i].size(); j++){
				if(lines[i][j] != lines[0][lines[i].size()-1-j]) f = 0;
			}
			for(int j = 0; j < dists[i].size(); j++){
				if(dists[i][j] != dists[0][dists[i].size()-1-j] * -1) f = 0;
			}
			if(f){ cout << i << endl; continue;}
		}
		cout << "+++++" << endl;
	}
	return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i< (n);i++)
#define SORT(a) sort((a).begin(),(a).end());
#define che(a,string) cout<<string<<":"<<(a)<<endl;
#define ch(a,string) cout<<string<<":"<<(a)<<" ";
using namespace std;
typedef pair<int,int> p;
int main(){
	 int n,m;
	 cin>>n>>m;
	priority_queue<long long> pq;
	rep(i,n){
	long long a;
	cin>>a;
	pq.push(a);	
	  }
	  rep(i,m){
		 long long M=pq.top();
		 M/=2;
		 pq.pop();
		 pq.push(M); 
		}
		long long sum =0;
		while (!pq.empty()){
			long long k = pq.top();
			pq.pop();
			sum+=k;
		  }
		  cout<<sum<<endl;
	    }


Measured memory_bytes: 1400
#include <stdio.h>

int main()
{
	int m, f, r;
	int s;

	while (1) {
		scanf("%d%d%d", &m, &f, &r);
		if (m == -1 && f == -1 && r == -1) break;

		if (m < 0 || f < 0) puts("F");
		else {
			s = m + f;
			if (s >= 80) puts("A");
			else if (s >= 65) puts("B");
			else if (s >= 50) puts("C");
			else if (s < 30) puts("F");
			else puts(r >= 50 ? "C" : "D");
		}
	}
	return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
using namespace std;
typedef long long ll;
const ll INF=1e18;
typedef tuple<ll,int,int> p;
typedef vector<int> vi;
set <int> st;
int n;
vector<ll> a(2005);
vector<ll> b(2005);
ll tim=0,x;
ll tmp=0;
ll mintmp=INF;

int main(int argc,char const* argv[])
{
  cin >> n >> x;
  for(int i=0;i<n;i++)
    {
      cin >> a[i];
      b[i]=a[i];
    }
  for(int i=0;i<n;i++)
    {
      tmp=i*x;
      for(int j=0;j<n;j++)
	{
	  if(j-i<0) b[j]=min(b[j],a[n+j-i]);
	  else b[j]=min(b[j],a[j-i]);
	  tmp+=b[j];
	}
      if(tmp<=mintmp) mintmp=tmp;
    }
  cout << mintmp << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,W,b,c=0;
scanf("%d%d%d",&W,&a,&b);
if(b>(a+W)){
c=b-(a+W);	
printf("%d",c);
}
else if(a>(W+b)){
c=a-(W+b);
printf("%d",c);
}	
else 
printf("%d",c);
}

	
	
	
	
	
	
	
	


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<MOD>;

int N,K;
vector<vector<int>> G;
vector<mint> cnt;
void dfs(int v, int pv, int k) {
    cnt[v] = k;
    k = pv == -1 ? K : K-1;
    for (auto nv : G[v]) {
        if (nv == pv) continue;
        dfs(nv,v,--k);
    }
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N >> K;
    G.resize(N); cnt.resize(N);
    rep(i,N-1) {
        int a,b; cin >> a >> b;
        --a; --b;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    dfs(0,-1,K);
    mint ans = 1;
    rep(i,N) ans *= cnt[i];

    cout << ans.a << ln;


}

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

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

int n,cnt[14],ans[54];

bool solve(int idx,int sum){
	if(idx == 0 && sum == 0) return true;
	if(idx < 0 || sum < 0) return false;

	rep(i,14){
		if(cnt[i]>0 && (sum - i) % i == 0){
			ans[idx-1] = i;
			cnt[i]--;
			if(solve(idx-1,sum-i)) return true;
			cnt[i]++;
		}
	}

	return false;
}

int main(void){
	while(cin>>n,n){
		int sum = 0;
		memset(cnt,0,sizeof(cnt));
		rep(i,n){
			int x;
			cin>>x;
			sum += x;
			cnt[x]++;
		}
		bool flg = solve(n,sum);
		if(flg){
			rep(i,n-1) cout<<ans[i]<<" ";
			cout<<ans[n-1]<<endl;
		}
		else{
			cout<<"No\n";
		}
	}

	return 0;
}

Measured memory_bytes: 868
#include<bits/stdc++.h>
#define reg(i,a,b) for(int i=a;i<=b;i++)
#define reh(i,a,b) for(int i=b;i>=a;i--)
#define in(x) scanf("%d",&x)
#define fro freopen("D:\\testdata.in", "r", stdin)
#define il inline
#define lson(q) q<<1
#define rson(q) q<<1|1
using namespace std;
typedef long long ll;
const int mx=1e5+10;
ll res;
int f(int a) {
	if(a<=9) {
		return a;
	} else if(a<100) {
		return 9;
	} else if(a<=999) {
		return a-100+1+9;
	} else if(a<10000) {
		return 909;
	} else if(a<=99999) {
		return a-10000+1+9+900;
	} else {
		return 90909;
	}
}
int main() {
	int n,t;
	scanf("%d",&n);
	cout<<f(n)<<endl;
	return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    ll n, p = 0, q = 0, r = 0, s = 0;
    scanf("%lld", &n);
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        scanf("%lld", a.begin() + i);
        if ((r + a.at(i)) * (i % 2 * 2 - 1) < 1) {
            p += 1 - (r + a.at(i)) * (i % 2 * 2 - 1);
            r = i % 2 * 2 - 1;
        } else r += a.at(i);
        if ((s + a.at(i)) * (i % 2 * -2 + 1) < 1) {
            q += 1 - (s + a.at(i)) * (i % 2 * -2 + 1);
            s = i % 2 * -2 + 1;
        } else s += a.at(i);
    }
    printf("%lld\n", min(p, q));
    return 0;
}


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

int main() {
  int n;
  int size = 0;
  cin >> n;
  long long a[n];
  long long b[n];

  for(int i = 0; i<n; i++){
    cin >> a[i];
    if(i > 0){
      if (a[i] != a[i-1]){
        b[size] = a[i];
        size++;
      }
    }else{
      b[size] = a[i];
      size++;
    }
  }
  b[size] = -1;
  long long my_money = 1000;
  long long c = 0;
  long long d;
  for(int i=0; i<size; i++){
    if(b[i] < b[i+1]){
      if(my_money >= b[i]){
        c = my_money / b[i];
        d = b[i] * c;
        my_money -= d;
      }
    }else{
      d = b[i] * c;
      my_money += d;
      c = 0;
    }
  }
  cout << my_money << endl;
  return 0;
  
}

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

bool solve(string s, string t){
    int n = s.size();
    for(int i=0; i<n; i++){
        if(s[i]!=t[i]){
            return false;
        }
    }
    return true;
}

int main(){
    string s1, s2;
    cin >> s1;
    cin >> s2;
    bool ans = solve(s1, s2);
    if(ans){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
}

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

int main()
{
	int  h,w;

	while (1)
	{
		cin >> h >> w;

		if (h==0&&w==0)
		{
			break;
		}

		for (int i = 0; i < h; i++)
		{
			for (int j = 0; j < w; j++)
			{
				if ((i+j)%2==0)
				{
					cout << "#";
				}
				else{ cout << "."; }
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  bool flag=true;
  for(int i=0;i<N;i++){
    char S;
    cin>>S;
    if(S=='Y'){
      flag=false;
    }
    else{
    }
  }
  if(flag){
    cout<<"Three"<<endl;
  }
  else{
    cout<<"Four"<<endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#define REG register 
using namespace std;

char s[100];
int cnt=0;

int main(){
    
    scanf("%s",s); 
    int lens=strlen(s);
    if ( s[0]!='A' ) {
        printf("WA");
        return 0;
    }
    if ( !(s[1]>='a' && s[1]<='z') ) {
        printf("WA");
        return 0;
    }
    cnt=0;
    for ( REG int i=2 ; i<lens-1 ; i++ ) {
        if ( s[i]=='C' ) cnt++;
        if ( s[i]>='A' && s[i]<='Z' && s[i]!='C' ) {
            printf("WA");
            return 0;
        }
        if ( cnt>1 ) {
            printf("WA");
            return 0;
        }
        
    }
    
    if ( !(s[lens-1]>='a' && s[lens-1]<='z') || cnt==0 ) {
        printf("WA");
        return 0;
    }
    
    printf("AC");
    
    return 0;
}

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

int main(){
    int v,s;
    while(1){
        cin>>v>>s;
        if(v==0&&s==0) break;
        for(int i=0;i<v;i++){
            for(int j=0;j<s;j++){
                if((i+j)%2==0){
                    cout<<'#';
                }else{
                    cout<<'.';
                }
            }
            cout<<'\n';
        }
        cout<<'\n';
    }
}


Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+1];
        int[] B = new int[N];

        for (int i = 0; i < N+1; i++) {
            A[i]=sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i]=sc.nextInt();
        }

        long ans = 0;


        for (int i = 0; i < N; i++) {
            int b = Math.min(A[i],B[i]);
            ans+=b;
            int rest = B[i]-b;
            int b2 = Math.min(A[i+1],rest);
            ans+=b2;
            A[i+1] -=b2;
        }



        System.out.println(ans);

    }
}


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

int main() {
  int c, n, m, k, a;
  cin >> n >> m >> c;
  int b[m];
  for (int i=0;i<m;i++){
    cin >> b[i];
  }
  int cl = 0;
  for (int i=0;i<n;i++){
    k=0;
    for (int j=0;j<m;j++){
      cin >> a;
      k = k + a*b[j];
    }
    k = k + c;
    if (k > 0) cl++;
  }
  
  cout << cl << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter


def main():
    n, k = map(int, input().split())
    aa = list(map(int, input().split()))
    counts = Counter(aa)
    if len(counts) <= k:
        print(0)
        return
    res = sum(sorted(counts.values())[:len(counts) - k])
    print(res)


if __name__ == '__main__':
    main()


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

int main() {
  string s;
  ll k;
  cin >> s;
  cin >> k;

  ll n = s.size();

  // num is less than S
  vector<vector<ll>> dp1(n + 1, vector<ll>(k + 2));
  // num can be S
  vector<vector<ll>> dp2(n + 1, vector<ll>(k + 2));

  // index 0: digit
  // index 1: num of nonzeros left

  dp2[0][k] = 1;

  for (ll i = 0; i < n; i++) {
    ll d = s[i] - '0';
    for (ll j = 0; j <= k; j++) {
      if (d == 0) {
        dp1[i + 1][j] = dp1[i][j]     * 1  // 0
                      + dp1[i][j + 1] * 9; // 1 ~ 9

        dp2[i + 1][j] = dp2[i][j]     * 1; // 0

      } else {
        dp1[i + 1][j] = dp1[i][j]     * 1        // 0
                      + dp1[i][j + 1] * 9        // 1 ~ 9
                      + dp2[i][j]     * 1        // 0
                      + dp2[i][j + 1] * (d - 1); // 1 ~ d - 1

        dp2[i + 1][j] = dp2[i][j + 1] * 1;       // d
      }
    }
  }
  cout << dp1[n][0] + dp2[n][0] << endl;
}


Measured memory_bytes: 256
n = int(input())
c = [0]*(n+1)
c[0], c[1] = map(int, input().split())
for i in range(2, n+1):
    c[i] = int(input().split()[1])

dp = [[10**7]*(n+1) for i in range(n+1)]  # dp[i][j] <- M_i~M_j

for i in range(1, n+1):  # l=1
    dp[i][i] = 0

for l in range(2, n+1):  # l=j-i+1(length of chain)
    for i in range(1, n-l+2):
        j = i+l-1
        for k in range(i, j):  # kirutokoro
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + c[i-1]*c[k]*c[j])

print(dp[1][n])

Measured memory_bytes: 7792
#include<stdio.h>
int main(){
	int n,m,i[101],j,b,a[1000][101],ans[1000]={},ai,ue,oka;
	scanf("%d %d",&n,&m);
	for(ai=0;ai<n;ai++){
		for(ue=0;ue<m;ue++){
			scanf("%d",&a[ai][ue]);
		}
	}
	for(oka=0;oka<m;oka++){
		scanf("%d",&i[oka]);
	}
	for(ai=0;ai<n;ai++){
		for(ue=0;ue<m;ue++){
			ans[ai]+=i[ue]*a[ai][ue];
		}
	}
	
	for(oka=0;oka<n;oka++){
		printf("%d\n",ans[oka]);
	}
	
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  int w , Q;
  int a[101];
 
  while(1) {
  cin >> w >> Q;
  if(w == 0 && Q == 0) break;
 
  for(int i=0;i<w;i++) a[i] = -1;
 
  for(int q=0;q<Q;q++) {
    string sta;
    int neko,haba;
    cin >> sta;
 
    int count = 0,flg = -1;
    if(sta[0] == 's'){
      cin >> neko >> haba;
      for(int i=0;i<w;i++) {
    if(a[i] == -1)count++;
    else  count = 0;
 
    if(count == haba) {
      for(int j=i-count+1;j<=i;j++) a[j] = neko; 
      flg = i - count+1;
      break;
    }
      }
      if(flg != -1) cout << flg << endl;
      else cout << "impossible" << endl;
    }
    else if(sta[0] == 'w') {
      cin >> neko;
      for(int i=0;i<w;i++) {
    if(a[i] == neko) 
      a[i] = -1;
      }
    }
  }
   cout << "END" <<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {


        // Scannerクラスのインスタンスの生成
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = 0;

        d = (b + c) - a;
        if (d < 0) {
        	System.out.println(0);
        } else {
        System.out.println(d);
        }



	}



}

Measured memory_bytes: 23636
fun main() {
    val a = readInt()
    println(a + a * a + a * a * a)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 34240
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }

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

  int r, d, x2000; cin >> r >> d >> x2000;
  int cur = x2000;
  for (int i = 1; i <= 10; ++i) {
    (cur *= r) -= d;
    print(cur);
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; (i) < (n); ++(i))
#define REP3(i,m,n) for (int i = (m); (i) < (n); ++(i))
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;

int solve(int h, int w, int p, vector<int> const & y, vector<int> const & x) {
    vector<int> t(p);
    REP (i, p) {
        t[i] = (x[i] < w ? w - x[i] : x[i] - w + 1) + (h - y[i]);
    }
    sort(ALL(t));
    int cur = 0;
    for (int t_i : t) {
        if (cur < t_i) {
            cur = t_i;
        } else {
            ++ cur;
        }
    }
    return cur;
}

int main() {
    int h, w, p; cin >> h >> w >> p;
    vector<int> y(p), x(p);
    REP (i, p) {
        cin >> y[i] >> x[i];
        -- y[i];
        -- x[i];
    }
    cout << solve(h, w, p, y, x) << endl;
    return 0;
}



Measured memory_bytes: 8524
#2020-04-29
x = 0
lst = [0]
n = int(input())
s = list(input())

for i in range(n):
    if s[i] == 'I':
        x += 1
        lst.append(x)
    else:
        x -= 1
        lst.append(x)

print(max(lst))

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

int main(){
  string S, S_inv, T1, T1_inv, T2, T2_inv;
  cin >> S;
  S_inv = S;
  int N = S.size();
  reverse(S_inv.begin(), S_inv.end());
  T1 = S.substr(0, (N-1)/2);
  T1_inv = T1;
  reverse(T1_inv.begin(), T1_inv.end());
  T2 = S_inv.substr(0, (N-1)/2);
  T2_inv = T2;
  reverse(T2_inv.begin(), T2_inv.end());
  if (S==S_inv && T1==T1_inv && T2==T2_inv) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3620
N,M=map(int,input().split())
A=[0]*N
B=[0]*N
C=[0]*M
D=[0]*M
for i in range (N):
	A[i],B[i]=map(int,input().split())
for i in range (M):
	C[i],D[i]=map(int,input().split())
E=[10000000000]*N
F=[1]*N
tmp=('inf')
for i in range (N):
	for j in range (M):
		tmp=(abs(A[i]-C[j])+abs(B[i]-D[j]))
		if E[i]>tmp:
			F[i]=j+1
			E[i]=tmp
		
for i in range (N):
	print(F[i])

Measured memory_bytes: 3064
from collections import OrderedDict, deque


def main():
    n = int(input())
    edges = [tuple(map(int, input().split())) for _ in range(n - 1)]
    tree = [[] for _ in range(n)]  # こうしないとすべて同じリストObjになる.
    coloring = OrderedDict()
    for e in edges:
        a, b = e[0] - 1, e[1] - 1
        tree[a].append(b)
        tree[b].append(a)
        coloring[(a, b)] = 0

    q = deque()
    q_append = q.append
    q_popleft = q.popleft
    seen = [False] * n
    q_append(0)
    col_count_by_v = [set() for _ in range(n)]
    while len(q):
        new_v = q_popleft()
        seen[new_v] = True
        color_i = 1  # One-based index.
        for adj in tree[new_v]:
            if seen[adj]:
                continue
            q_append(adj)
            while color_i in col_count_by_v[new_v]:
                color_i += 1
            coloring[(new_v, adj)] = color_i
            col_count_by_v[new_v].add(color_i)
            col_count_by_v[adj].add(color_i)

    print(len(set(coloring.values())))
    for c in coloring.values():
        print(c)


if __name__ == '__main__':
    main()

# なんでか分からないが, こうして main() に仕舞ってあげたほうが少し早い.


Measured memory_bytes: 95072
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
const ll INF = 1e18;
const int MX=3e5+1;
int N, M, k;
set<int> st;
int f(int n, int s)
{
    if(s == 0) return -n;
    return +n;
}
char ss(int i)
{
    if(i) return '+';
    return '-';
}
int main()
{
    string s;
    cin>>s;
    int a=s[0]-'0';
    for(int i=0;i<2;i++)
    {
        for(int j=0;j<2;j++)
        {
            for(int k=0;k<2;k++)
            {
                int b=f(s[1]-'0', i);
                int c=f(s[2]-'0', j);
                int d=f(s[3]-'0', k);

                if(a + b+ c+d== 7)
                {
                    cout<<a;
                    if(b >= 0) cout<<'+';
                    cout<<b;
                    if(c >= 0) cout<<'+';
                    cout<<c;
                    if(d >= 0) cout<<'+';
                    cout<<d<<"=7";
                    return 0;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()
	{
		string S = Console.ReadLine();
		string T = Console.ReadLine();

		string SS = S + S;

		Console.WriteLine((SS.IndexOf(T) != -1) ? "Yes" : "No");
	}	
}





Measured memory_bytes: 11360
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

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

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    int a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b));

    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

int main(void)
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP (i,N) {
        cin >> A[i];
    }

    ll ans = 0;
    ll x = 0;
    for (int i = 0; i < N; i++) {
        ans = (ans + A[i] * x)%MOD;
        x = (x+A[i])%MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4848
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#define rep(i, n) for ((i)=0;(i)<(n);(i)++)

int tmp1, tmp2, tmp3;

typedef struct {
    int top;
    int S;
    int E;
    int W;
    int N;
    int bottom;
} Dice2;

void roll_S(Dice2 *a) {
    tmp1 = a->S;
    a->S = a->top;
    tmp2 = a->bottom;
    a->bottom = tmp1;
    tmp3 = a->N;
    a->N = tmp2;
    a->top = tmp3;
}

void roll_E(Dice2 *b) {
    tmp1 = b->E;
    b->E = b->top;
    tmp2 = b->bottom;
    b->bottom = tmp1;
    tmp3 = b->W;
    b->W = tmp2;
    b->top = tmp3;
}

void roll_N(Dice2 *c) {
    tmp1 = c->N;
    c->N = c->top;
    tmp2 = c->bottom;
    c->bottom = tmp1;
    tmp3 = c->S;
    c->S = tmp2;
    c->top = tmp3;
}

void roll_W(Dice2 *d) {
    tmp1 = d->W;
    d->W = d->top;
    tmp2 = d->bottom;
    d->bottom = tmp1;
    tmp3 = d->E;
    d->E = tmp2;
    d->top = tmp3;
}

int main(void) {
    int i, q, x, y;
    Dice2 dice;
    i = 0;
    char commands[4] = {'S','E','N','W'};
    char command;
    scanf("%d %d %d %d %d %d",&dice.top,&dice.S,&dice.E,&dice.W,&dice.N,&dice.bottom);
    scanf("%d", &q);
    rep(i, q) {
        scanf("%d %d", &x, &y);
        srand((unsigned)time(NULL));
        while (1) {
            command = commands[rand()%4];
            if (command == 'S') roll_S(&dice);
            else if (command == 'E') roll_E(&dice);
            else if (command == 'N') roll_N(&dice);
            else if (command == 'W') roll_W(&dice);
            
            if (dice.top == x && dice.S == y) {
                printf("%d\n", dice.E);
                break;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  string s;
  cin>>s;
  int n=s.size();
  for(int i=1;i<n;i++){
    if((n-i)%2) continue;
    string t=s.substr(0,n-i);
    //cout<<(n-i)/2<<endl;
    string u=t.substr(0,(n-i)/2),v=t.substr((n-i)/2,(n-i)/2);
    if(u!=v) continue;
    cout<<n-i<<endl;
    break;
  }
  return 0;
}


Measured memory_bytes: 256
my ($n,$a,$b)=get.words;
my $s=0;
for (0..9) -> $a1 {
	for (0..($b-$a1 min 9)) -> $a2 {
		for (0..($b-$a1-$a2 min 9)) -> $a3 {
			for (($a-$a1-$a2-$a3 max 0)..($b-$a1-$a2-$a3 min 9)) -> $a4 {
				my$t=$a1*1000+$a2*100+$a3*10+$a4;
				$s+=$t if $n>=$t;
			}
		}
	}
}
say $s+($n==10000&&$a==1??10000!!0)

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

int n;
vector<string> v;

int solve(int r, int c) {
    if(v[r][c]=='+') {
        int res = 0;
        int p = r + 1;
        while(p<n && c<v[p].size() && v[p][c]=='.') {
            if(v[p][c+1] != '.') res += solve(p, c+1);
            p++;
        }
        return res;
    }
    else if(v[r][c] == '*') {
        int res = 1;
        int p = r + 1;
        while(p<n && c<v[p].size() && v[p][c] == '.') {
            if(v[p][c+1] != '.') res *= solve(p, c+1);
            p++;
        }
        return res;
    }
    else if(isdigit(v[r][c])) return v[r][c] - '0';
    else assert(false);
}

int main() {
    while(cin >> n, n) {
        v.resize(n);
        rep(i,n) cin >> v[i];
        P(solve(0,0));
    }
}

Measured memory_bytes: 3040
n,*ab=map(int,open(0).read().split())
a=ab[::2]
b=ab[1::2]
m=n//2
a.sort()
b.sort()
ans=0
if n&1==1:
  ans=b[m]-a[m]+1
else:
  ans=int(2*((b[m]+b[m-1])/2-(a[m]+a[m-1])/2))
  ans+=1
print(ans)

Measured memory_bytes: 55272
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=100000000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;
typedef pair<int,string> Q;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
//void swap(ll a,ll b){
//	ll d;
//	d=a;
//	a=b;
//	b=d;
//	return;
//}
ll mypow(ll x,int m){
	if(m==0)return 1;
	if(m%2==0){
		int x2=mypow(x,m/2);
		return x2*x2;
	}else{
		int x2=mypow(x,m/2);
		return x2*x2*x;
	}
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
//    	cout<<b<<endl;
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll total=0;
int a[200000],b[200000];
int n;
int m1,m2,n1,n2;
int c[100005]={};
string s;
vector<P> v[200001];
int ans[100005]={};
int main() {
	cin>>n;
	rep(i,0,n+1){
		if(int(i*1.08)==n){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<":("<<endl;
	return 0;
}


Measured memory_bytes: 6016
using System;
using System.Collections.Generic;

namespace atbc_115
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');

            int dataCnt = int.Parse(line[0]);
            int selectCnt = int.Parse(line[1]);

            List<long> dataList = new List<long>();

            for (int i = 0; i < dataCnt; i++)
            {
                dataList.Add(long.Parse(Console.ReadLine()));
            }

            dataList.Sort();

            long min = dataList[0 + selectCnt - 1] - dataList[0];

            for (int i = 1; i < dataCnt - selectCnt + 1; i++)
            {
                long tmp = dataList[i + selectCnt - 1] - dataList[i];
                if (tmp < min)
                {
                    min = tmp;
                }
            }

            Console.WriteLine(min);
        }
    }
}


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

int main(){
  int n,k;
  cin>>n>>k;
  double a=0;
  for(int i=1;i<=n;i++){
    int num=i;
    double t=1.0/n;
    while(num<k){
      num*=2;
      t/=2;
    }
    a+=t;
  }
  cout<<fixed<<setprecision(20)<<a<<endl;
}


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

bool kaibun(string s){
    string r(s.rbegin(), s.rend());
    return s == r;
}

int main(){
    string S, fr, ba;
    cin >> S;
    int N = S.size();
    if(kaibun(S) && kaibun(S.substr(0, (N-1)/2)) && kaibun(S.substr((N+3)/2-1))){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


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

int main() {
    int vid, att, x;
    
    scanf("%d %d", &vid, &att);
    int poer = 0;
    for (int i = 0; i < att; ++i){
        scanf("%d", &x);
        poer += x;
    }
    
    if (vid - poer > 0)
        printf("No\n");
    else
        printf("Yes\n");
    
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

#define SIZE 1001

using namespace std;

int main() {
    long  long int B,i,j,k,M,K,Q;
    long  long int X,N,Y,Z,nb;
    long  D[SIZE];
    char C;

    cin >> N;
    N--;
    X = 26;
    nb = 1;
    while (N >= X) {
      N -= X;
      X *= 26;
      nb++;
    }
    for (i=0;i<nb;i++) {
      D[i] = N % 26;
      N = N/26;
    }
    for (j=nb-1;j>=0;j--) {
      C = D[j]+'a';
      cout << C;
    }
    cout << endl;

  return 0;

}


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

using namespace std;

int a, b, h, m;
double pi, va, vb, routea, routeb, routec, c;

int main (void)
{
	scanf("%d%d%d%d",&a,&b,&h,&m);
	pi=acos(-1.0);
	va=2*pi/12/60;
	vb=2*pi/60;
	routea=1.0*(h*60+m)*va;
	while (routea>=2*pi) routea-=2*pi;
	routeb=1.0*(h*60+m)*vb;
	while (routeb>=2*pi) routeb-=2*pi;
	routec=abs(routea-routeb);
	while (routec>=2*pi) routec-=2*pi;
	//printf("%.10f\n",routec/pi);
	c=sqrt(a*a+b*b-2*a*b*cos(routec));
	printf("%.15f\n",c); 
	return 0;
}

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

using namespace std;

using int64 = long long;

void ans(int64 n) {
  cout << "! " << n << endl;
  exit(0);
}

bool ask(int64 n) {
  cout << "? " << n << endl;
  char c;
  cin >> c;
  return c == 'Y';
}

int main() {

  int64 mul = 10;
  int64 low = -1, high = -1;
  for(int i = 2; i <= 10; i++) {
    if(!ask(mul)) {
      low = mul / 10;
      high = mul;
      break;
    }
    mul *= 10;
  }
  if(low == -1) {
    mul = 10;
    for(int i = 1; i <= 10; i++) {
      if(ask(mul - 1)) ans(mul / 10);
      mul *= 10;
    }
  }

  while(high - low > 1) {
    int64 mid = (low + high) / 2;
    if(ask(mid * 10)) high = mid;
    else low = mid;
  }
  ans(high);
}


Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<a<<endl
#define debug2(a,b) cout<<a<<" "<<b<<endl
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define debug4(a) cout<<"chu "<<a<<endl
#define sz(a) (ll)(a.size())
#define endl "\n"

ll a[105];
ll dp[100005][105];
ll sum[100005][105];

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n,k;
  cin>>n>>k;
  forn(i,1,n+1) cin>>a[i];
  forn(i,1,n+1) {dp[0][i]=1;sum[0][i]=1;}
  forn(i,0,a[1]+1) dp[i][1]=1;
  forn(i,1,a[1]+1) sum[i][1]=(sum[i-1][1]+1)%mod;
  forn(i,a[1]+1,k+1) sum[i][1]=sum[i-1][1];
  forn(i,2,n+1){
    forn(j,1,k+1){
      dp[j][i]=(dp[j][i]+sum[j][i-1])%mod;
      if(j-a[i]-1>=0) dp[j][i]=(dp[j][i]-sum[j-a[i]-1][i-1]+mod)%mod;
      sum[j][i]=(sum[j-1][i]+dp[j][i])%mod;
    }
  }
  ll ans=dp[k][n];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 164352
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int N, M;
        N = scanner.nextInt();
        M = scanner.nextInt();

        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i <= M; i++) map.put(i, 0);

        for (int n = 0; n < N; n++) {
            int max = scanner.nextInt();

            for (int i = 0; i < max; i++) {
                int value = scanner.nextInt();
                map.put(value, map.get(value) + 1);
            }
        }

        int count = 0;
        for (int i = 0; i <= M; i++) count += map.get(i) == N ? 1 : 0;

        System.out.println(count);
    }

}


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

#define MOD 1000000007
#define lli long long int
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = n - 1; ~i; i--)
#define pb push_back
#define mkp make_pair
#define endl "\n"

using namespace std;

bool enable_test_case = false;
bool enable_google = false;

void solve()
{
    lli n;
    cin >> n;
    lli h[n];
    lli dp[n];
    rep(i, n)
    {
        cin >> h[i];
        dp[i] = INT64_MAX;
    }
    dp[0] = 0;
    for (int i = 1; i < n; i++)
    {
        for (int j = 1; j <= 2; j++)
        {
            if ((i - j) >= 0)
                dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]));
        }
    }
    cout << dp[n - 1] << endl;
}

void google_contests(int t)
{
    cout << "Case #" << t + 1 << ": ";
}

void test_case()
{
    if (enable_test_case)
    {
        lli t;
        cin >> t;
        rep(i, t)
        {
            if (enable_google)
                google_contests(i);
            solve();
        }
    }
    else
    {
        solve();
    }
}

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

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

    test_case();

    return 0;
}


Measured memory_bytes: 5152
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            if (i * j == N) {
                cout << "Yes" << endl;
                return 0;
            }        
        }
    }

    cout << "No" << endl;

    return 0;
}


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

int main()
{
	long long a,b;
	scanf("%lld %lld",&a,&b);
	if(a*b <= 0)
	{
		printf("Zero");
		return 0;
	}
	else if(a > 0)
	{
		printf("Positive");
		return 0;
	}
	else
	{
		if((b-a)%2 == 0)
		{
			printf("Negative");
			return 0;
		}
		else
		{
			printf("Positive");
			return 0;
		}
	}
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;


int ans;

struct edge {
	int num;
	std::vector<int> fri;
	bool visit;
};


void dfs(std::vector<edge> v, int x){
	v[x].visit = false;
	bool flag = true;
	for (size_t i = 0; i < v.size(); i++) {
		if (v[i].visit) {
			flag = false;
			break;
		}
	}
	if (flag) {
		ans++;
		return ;
	}
	for (size_t i = 0; i < v[x].fri.size(); i++) {
		if (v[v[x].fri[i]].visit) {
			dfs(v,v[x].fri[i]);
		}
	}
}

int main(int argc, char const *argv[]) {
	int n,m;
	std::cin >> n >> m;
	std::vector<edge> v;
	for (size_t i = 0; i < n; i++) {
		v.push_back({i,{},true});
	}
	for (size_t i = 0; i < m; i++) {
		int a,b;
		std::cin >> a >> b;
		a--;
		b--;
		v[a].fri.push_back(b);
		v[b].fri.push_back(a);
	}
	ans = 0;
	dfs(v,0);
	std::cout << ans << '\n';
	return 0;
}


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

#define check(val) std::cout << "\033[31m" << #val << ": " << val << "\033[m" << std::endl
#define check_v(vec) \
  std::cout << "\033[31m" << #vec << ": [ ";\
  for(auto it=vec.begin(); it!=vec.end(); it++){cout << *it << " ";}\
  cout << "]"<< "\033[m" << endl;


double kitai(int p) {
  double ret;
  ret = (double(p) + 1.0) / 2.0;
  // check(ret);
  return ret;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<double> p(n+k+1);
  int tmp_1;
  rep(i,n){
    cin >> tmp_1;
    p[i] = kitai(tmp_1);
  }
  // check_v(p);
  double ans = 0;
  rep(i,k) {
    ans += p[i];
  }
  double tmp = ans;
  rep(i,n) {
    // check(tmp);
    tmp = tmp - p[i] + p[i+k];
    if(tmp >= ans){
      ans = tmp;
    }
  }
  if(tmp >= ans){
      ans = tmp;
  }
  printf("%.10f\n", ans);
  // cout << fixed << setprecision(2) << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
import collections as col
N=int(input())
A=[ai for ai in map(int,input().split())]
Ans=False
CA=col.Counter(A)
if len(CA)==1 and 0 in CA:
    Ans=True
elif len(A)%3==0:
    if len(CA)==3:
        K=list(CA.keys())
        if (K[0]^K[1]==K[2]) and (CA[K[0]]==CA[K[1]]==CA[K[2]]):
            Ans=True
    elif len(CA)==2:
        K=list(sorted(CA.keys()))
        if CA[K[0]]*2==CA[K[1]]:
            Ans=True

print("Yes" if Ans==True else "No")


Measured memory_bytes: 14468
#include<bits/stdc++.h>
using namespace std;
int f[26];
int main(){
string s;
cin>>s;
for(char x:s)f[x-'a']++;

for(int i=0;i<26;i++){
if(f[i]%2==1){
puts("No");
return 0;
}
}
puts("Yes");
return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<cmath>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
int main() {
	int N;
	scanf("%d", &N);
	puts(N % 10 == 7 || N / 10 % 10 == 7 || N / 100 % 10 == 7 ? "Yes":"No");
	return 0;
}


Measured memory_bytes: 1648
import java.util.Scanner;

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

        while (true) {

            int H = sc.nextInt();
            int W = sc.nextInt();

            if (H == 0 && W == 0)
                break;

            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (i == 0 || i == H - 1) {
                        System.out.print("#");
                    } else if (j == 0 || j == W - 1) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
}


Measured memory_bytes: 35928
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<typename T>
struct hungarian{//n<=m
	const T inf=numeric_limits<T>::max();
	int n, m, max_match, root;
	T max_cost;
	vector<vector<T>> cost;
	vector<T> lx, ly, slack;
	vector<int> xy, yx, prev, slackx;
	vector<bool> s, t;
	void update_labels(){
		T delta=inf;
		for(int y=0; y<m; y++) if(!t[y]) delta=min(delta, slack[y]);
		for(int x=0; x<n; x++) if(s[x]) lx[x]-=delta;
		for(int y=0; y<m; y++) if(t[y]) ly[y]+=delta;
		for(int y=0; y<m; y++) if(!t[y]) slack[y]-=delta;
	}
	void add_to_tree(int x, int prevx){
		s[x]=true;
		prev[x]=prevx;
		for(int y=0; y<m; y++){
			if(lx[x]+ly[y]-cost[x][y]<slack[y]){
				slack[y]=lx[x]+ly[y]-cost[x][y];
				slackx[y]=x;
			}
		}
	}
	void augment(){
		if(max_match==n) return;
		fill(s.begin(), s.end(), false);
		fill(t.begin(), t.end(), false);
		fill(prev.begin(), prev.end(), -1);
		queue<int> que;
		for(int x=0; x<n; x++){
			if(xy[x]==-1){
				root=x;
				que.push(x);
				prev[x]=-2;
				s[x]=true;
				break;
			}
		}
		for(int y=0; y<m; y++){
			slack[y]=lx[root]+ly[y]-cost[root][y];
			slackx[y]=root;
		}
		int x, y;
		while(1){
			while(!que.empty()){
				x=que.front(); que.pop();
				for(y=0; y<m; y++){
					if(cost[x][y]==lx[x]+ly[y] && !t[y]){
						if(yx[y]==-1) break;
						t[y]=true;
						que.push(yx[y]);
						add_to_tree(yx[y], x);
					}
				}
				if(y<m) break;
			}
			if(y<m) break;
			update_labels();
			for(y=0; y<m; y++){
				if(!t[y] && slack[y]==0){
					if(yx[y]==-1){
						x=slackx[y];
						break;
					}else{
						t[y]=true;
						que.push(yx[y]);
						add_to_tree(yx[y], slackx[y]);
					}
				}
			}
			if(y<m) break;
		}
		if(y<m){
			max_match++;
			for(int cx=x, cy=y, ty; cx!=-2; cx=prev[cx], cy=ty){
				ty=xy[cx];
				yx[cy]=cx, xy[cx]=cy;
			}
			augment();
		}
	}
	hungarian(const vector<vector<T>> &cost):max_match(0), max_cost(0), cost(cost), n(cost.size()), m(cost[0].size()), lx(n, -inf), ly(m), xy(n, -1), yx(m, -1), s(n), t(m), prev(n), slack(m), slackx(m){
		for(int x=0; x<n; x++) for(int y=0; y<m; y++) lx[x]=max(lx[x], cost[x][y]);
		augment();
		for(int x=0; x<n; x++) max_cost+=cost[x][xy[x]];
	}
};
int gcd(int a, int b){
	if(b==0) return a;
	return gcd(b, a%b);
}
int main()
{
	while(1){
		int m, n;
		cin>>m>>n;
		if(m==0) return 0;
		int b[505], r[505];
		for(int i=0; i<m; i++) cin>>b[i];
		for(int i=0; i<n; i++) cin>>r[i];
		if(m>n) swap(m, n), swap(b, r);
		vector<vector<int>> a(m, vector<int>(n));
		for(int i=0; i<m; i++) for(int j=0; j<n; j++) if(gcd(b[i], r[j])>1) a[i][j]++;
		hungarian<int> h(a);
		printf("%d\n", h.max_cost);
	}
    return 0;
}



Measured memory_bytes: 5760
N,K = map(int,input().split())
sum=0.0

for i in range(1,N+1):
    temp = i
    cnt = 0
    while  temp < K:
        temp = temp*2
        cnt+=1

    sum +=  (1/N)*((1/2)**cnt)
    
    
print(sum)
    

    

Measured memory_bytes: 9224